vtuis/videotelui/src/CVtUiContextControl.cpp
changeset 18 d9b6a8729acd
parent 4 6dc066157ed4
child 23 c378a0498b84
child 27 dcbddbbaf8fd
equal deleted inserted replaced
4:6dc066157ed4 18:d9b6a8729acd
     1 /*
       
     2 * Copyright (c) 2004, 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of the CVtUiContextControl control class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CVtUiContextControl.h"
       
    22 #include    "VtUiLayout.h"
       
    23 #include    <aknsutils.h>
       
    24 #include    <aknsdrawutils.h>
       
    25 #include    <cvtlogger.h>
       
    26 #include    <featmgr.h>
       
    27 #include    "CVtUiAppUi.h"
       
    28 #include    "tvtuistates.h"
       
    29 #include    <aknsutils.h>
       
    30 #include	"tVtuifeaturevariation.h"
       
    31 
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CVtUiContextControl::NewL
       
    35 // Constructor that may leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CVtUiContextControl* CVtUiContextControl::NewL(
       
    39     CVtUiBitmapManager& aBitmapManager, CVtUiAppUi& aAppUi,
       
    40     TVtUiStates& aUiStates)
       
    41     {
       
    42     __VTPRINTENTER( "CtxCtrl.NewL" )
       
    43     CVtUiContextControl* self = new ( ELeave ) CVtUiContextControl(
       
    44         aBitmapManager, aAppUi, aUiStates );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop(); // self
       
    48     __VTPRINTEXIT( "CtxCtrl.NewL" )
       
    49     return self;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CVtUiContextControl::~CVtUiContextControl
       
    54 // Destructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CVtUiContextControl::~CVtUiContextControl()
       
    58     {
       
    59     __VTPRINTENTER( "CtxCtrl.~" )
       
    60     BitmapManager().RemoveBitmap( iBackgroundId );
       
    61     BitmapManager().RemoveBitmap( iBlindId );
       
    62     BitmapManager().RemoveBitmap( iBlindMaskId );
       
    63     if ( iAppUi.EventMonitor() )
       
    64         {
       
    65         iAppUi.EventMonitor()->RemoveObserver( this );
       
    66         }
       
    67     __VTPRINTEXIT( "CtxCtrl.~" )
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CVtUiContextControl::HandlePointerEventL
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CVtUiContextControl::HandlePointerEventL(
       
    75     const TPointerEvent& aPointerEvent)
       
    76     {
       
    77     __VTPRINTENTER( "CtxCtrl.HandlePointerEventL" )
       
    78     __VTPRINT2( DEBUG_GEN, "CtxCtrl.HandlePtr  ok= %d", iOkToSwapOnButtonUp )
       
    79     if ( AknLayoutUtils::PenEnabled() )
       
    80         {
       
    81         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
    82             {
       
    83             TRect window( Size() );
       
    84             if ( !window.Contains( aPointerEvent.iPosition ) )
       
    85                 {
       
    86                 iOkToSwapOnButtonUp = ETrue;
       
    87                 SetGloballyCapturing( EFalse );
       
    88                 SetPointerCapture( EFalse); 
       
    89                 }
       
    90             else if( iOkToSwapOnButtonUp )
       
    91                 {
       
    92                  if ( !iUiStates.IsWhiteBalanceModeOn() &&
       
    93                       !iUiStates.IsColorToneModeOn() &&
       
    94                       !iUiStates.IsZoomModeOn() &&
       
    95                       !iUiStates.IsCaptureModeOn() &&
       
    96                       !iUiStates.IsContrastModeOn() &&
       
    97                       !iUiStates.IsBrightnessModeOn() &&
       
    98                       !iUiStates.IsVolumeModeOn() )
       
    99                         {
       
   100                         if ( !( iAppUi.CanSwapImagePlaces() ) )
       
   101                             {
       
   102                             return;
       
   103                             }	
       
   104                         iAppUi.HandleCommandL( EVtUiCmdSwapImagesPlaces );
       
   105                         }
       
   106                 }
       
   107             else
       
   108                 {
       
   109                 SetGloballyCapturing( EFalse );
       
   110                 SetPointerCapture( EFalse); 
       
   111                 iOkToSwapOnButtonUp = ETrue;
       
   112                 }
       
   113             }
       
   114         }
       
   115     __VTPRINTEXIT( "CtxCtrl.HandlePointerEventL" )
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CVtUiContextControl::HandleSizeChanged
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CVtUiContextControl::HandleSizeChanged()
       
   123     {
       
   124     __VTPRINTENTER( "CtxCtrl.HandleSizeChanged" )
       
   125     TRect screen;
       
   126     VtUiLayout::GetApplicationParentRect( screen );
       
   127 
       
   128     TAknWindowLineLayout control;
       
   129     VtUiLayout::GetFirstWindowBackgroundLayout( control );
       
   130     TAknLayoutRect backLayout;
       
   131     backLayout.LayoutRect( screen, control );
       
   132     BitmapManager().SetSize( iBackgroundId, backLayout.Rect().Size() );
       
   133 
       
   134     const TPoint positionRelativeToScreen( -PositionRelativeToScreen() );
       
   135 
       
   136     VtUiLayout::GetFirstWindowStreamDisabledIconLayout( control );
       
   137     TAknLayoutRect blindLayout;
       
   138     blindLayout.LayoutRect( screen, control );
       
   139     iBlindRect = blindLayout.Rect();
       
   140     iBlindRect.Move( positionRelativeToScreen );
       
   141     BitmapManager().SetSize( iBlindId, iBlindRect.Size() );
       
   142     BitmapManager().SetSize( iBlindMaskId, iBlindRect.Size() );
       
   143 
       
   144     VtUiLayout::GetFirstWindowStreamLayout( control );
       
   145     TAknLayoutRect streamLayout;
       
   146     streamLayout.LayoutRect( screen, control );
       
   147     iStreamRect = streamLayout.Rect();
       
   148     iStreamRect.Move( positionRelativeToScreen ) ;
       
   149     __VTPRINTEXIT( "CtxCtrl.HandleSizeChanged" )
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CVtUiContextControl::StreamBlitPosition
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 TPoint CVtUiContextControl::StreamBlitPosition() const
       
   157     {
       
   158     __VTPRINTENTER( "CtxCtrl.StreamBlitPosition" )
       
   159     __VTPRINTEXIT( "CtxCtrl.StreamBlitPosition" )
       
   160     return iStreamRect.iTl;
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // CVtUiContextControl::StreamClippingRect
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 TRect CVtUiContextControl::StreamClippingRect() const
       
   168     {
       
   169     __VTPRINTENTER( "CtxCtrl.StreamClippingRect" )
       
   170     __VTPRINTEXIT( "CtxCtrl.StreamClippingRect" )
       
   171     return iStreamRect;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CVtUiContextControl::DrawColoredBackground
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 void CVtUiContextControl::DrawColoredBackground( CWindowGc& aGc ) const
       
   179     {
       
   180     __VTPRINTENTER( "CtxCtrl.DrawColoredBackground" )
       
   181     CVtUiVideoControlBase::DrawColoredBackground( aGc );
       
   182     // Draw background image
       
   183     CFbsBitmap* bg = NULL;
       
   184     CFbsBitmap* bgMask = NULL;
       
   185     BitmapManager().GetBitmaps( iBackgroundId, bg, bgMask );
       
   186     if ( bg )
       
   187         {
       
   188         const TPoint origin;
       
   189         const TRect rect( origin, bg->SizeInPixels() );
       
   190         if ( bgMask )
       
   191             {
       
   192             aGc.BitBltMasked( origin, bg, rect, bgMask, ETrue );
       
   193             }
       
   194         else
       
   195             {
       
   196             aGc.BitBlt( origin, bg );
       
   197             }
       
   198         }
       
   199     __VTPRINTEXIT( "CtxCtrl.DrawColoredBackground" )
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // CVtUiContextControl::BlindImage
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 CFbsBitmap* CVtUiContextControl::BlindImage() const
       
   207     {
       
   208     __VTPRINTENTER( "CtxCtrl.BlindImage" )
       
   209     __VTPRINTEXIT( "CtxCtrl.BlindImage" )
       
   210     return Bitmap( iBlindId );
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------------------------
       
   214 // CVtUiContextControl::BlindMask
       
   215 // ---------------------------------------------------------------------------
       
   216 //
       
   217 CFbsBitmap* CVtUiContextControl::BlindMask() const
       
   218     {
       
   219     __VTPRINTENTER( "CtxCtrl.BlindImage" )
       
   220     __VTPRINTEXIT( "CtxCtrl.BlindImage" )
       
   221     return Bitmap( iBlindMaskId );
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CVtUiContextControl::BlindBlitPosition
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 TPoint CVtUiContextControl::BlindBlitPosition() const
       
   229     {
       
   230     __VTPRINTENTER( "CtxCtrl.BlindBlitPosition" )
       
   231     __VTPRINTEXIT( "CtxCtrl.BlindBlitPosition" )
       
   232     return iBlindRect.iTl;
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CVtUiContextControl::CVtUiContextControl
       
   237 // C++ constructor can NOT contain any code, that
       
   238 // might leave.
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 CVtUiContextControl::CVtUiContextControl(
       
   242         CVtUiBitmapManager& aBitmapManager,
       
   243         CVtUiAppUi& aAppUi,
       
   244         TVtUiStates& aUiStates )
       
   245     : CVtUiVideoControlBase( aBitmapManager ),
       
   246       iAppUi( aAppUi ),
       
   247       iUiStates( aUiStates )
       
   248     {
       
   249     __VTPRINTENTER( "CtxCtrl.ctor" )
       
   250     SetRenderingHint( ENoWaitingText );
       
   251     SetRenderingHint( EColoredBackground );
       
   252     __VTPRINTEXIT( "CtxCtrl.ctor" )
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CVtUiContextControl::ConstructL
       
   257 // Symbian 2nd phase constructor.
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 void CVtUiContextControl::ConstructL()
       
   261     {
       
   262     __VTPRINTENTER( "CtxCtrl.ConstructL" )
       
   263     BaseConstructL();
       
   264     iBackgroundId =
       
   265         BitmapManager().AddBitmapsL(
       
   266             EVtUiBitmap_qgn_graf_call_video_out_bg,
       
   267             EVtUiBitmap_qgn_graf_call_video_out_bg_mask,
       
   268             EFalse );
       
   269     BitmapManager().SetAspectRatio( iBackgroundId, EFalse );
       
   270     iBlindId =
       
   271         BitmapManager().AddBitmapL(
       
   272             EVtUiBitmap_qgn_indi_call_video_blind_out,
       
   273             EFalse );
       
   274     BitmapManager().SetAspectRatio( iBlindId, EFalse );
       
   275     iBlindMaskId =
       
   276         BitmapManager().AddBitmapL(
       
   277             EVtUiBitmap_qgn_indi_call_video_blind_out_mask_icon,
       
   278             EFalse );
       
   279     BitmapManager().SetAspectRatio( iBlindMaskId, EFalse );
       
   280     SetNonFocusing();
       
   281     if ( iAppUi.EventMonitor() )
       
   282         {
       
   283         iAppUi.EventMonitor()->AddObserverL( this );
       
   284         }
       
   285         
       
   286     iOkToSwapOnButtonUp = ETrue;
       
   287     __VTPRINTEXIT( "CtxCtrl.ConstructL" )
       
   288     }
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // CVtUiContextControl::HandleWsEventL
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 void CVtUiContextControl::HandleWsEventL( const TWsEvent& aEvent,
       
   295     CCoeControl* aDestination )
       
   296     {
       
   297     __VTPRINTENTER( "CVtUiContextControl.HandleWsEventL" )
       
   298     if( aEvent.Type() == EEventPointer )
       
   299         {
       
   300         // Touch outside of volume popup, close volume popup
       
   301         if ( aEvent.Pointer()->iType == TPointerEvent::EButton1Down )
       
   302             {
       
   303             if ( aDestination == this )
       
   304                 {
       
   305                 iOkToSwapOnButtonUp = !iUiStates.IsZoomModeOn() &&
       
   306                     !iUiStates.IsCaptureModeOn() &&
       
   307                     !iUiStates.IsContrastModeOn() &&
       
   308                     !iUiStates.IsBrightnessModeOn() &&
       
   309                     !iUiStates.IsVolumeModeOn();
       
   310                     SetGloballyCapturing( ETrue );
       
   311                     SetPointerCapture( ETrue ); 
       
   312                 }
       
   313             }             
       
   314         }
       
   315     __VTPRINTEXIT( "CVtUiContextControl.HandleWsEventL" )
       
   316     }
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 // CVtUiContextControl::LayoutRemoteVideo
       
   320 // -----------------------------------------------------------------------------
       
   321 //
       
   322 void CVtUiContextControl::LayoutRemoteVideo()
       
   323     {
       
   324     __VTPRINTENTER( "CVtUiContextControl.LayoutRemoteVideo" )
       
   325     if ( NULL != iRemoteVideoControl )
       
   326         {
       
   327         TRect rectRemoteVideo(StreamClippingRect());
       
   328         rectRemoteVideo.Move(PositionRelativeToScreen());
       
   329         iRemoteVideoControl->SetExtent(rectRemoteVideo.iTl,rectRemoteVideo.Size());        
       
   330         }
       
   331     __VTPRINTEXIT( "CVtUiContextControl.LayoutRemoteVideo" )
       
   332     }
       
   333 //  End of File