vtuis/videotelui/src/CVtUiContextControl.cpp
branchRCL_3
changeset 24 f15ac8e65a02
parent 23 890b5dd735f8
child 25 779871d1e4f4
equal deleted inserted replaced
23:890b5dd735f8 24:f15ac8e65a02
     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    "tVtuifeaturevariation.h"
       
    30 #include    "CVtUiMainControl.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         __VTPRINT2( DEBUG_GEN, "CtxCtrl.HandlePtr.Position.iX = %d", aPointerEvent.iPosition.iX )
       
    82         __VTPRINT2( DEBUG_GEN, "CtxCtrl.HandlePtr.Position.iY = %d", aPointerEvent.iPosition.iY )
       
    83         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
    84             {
       
    85             TRect window( Size() );
       
    86             if ( !window.Contains( aPointerEvent.iPosition ) || 
       
    87                     iAppUi.MainControl().IsMainControlPointerEvent() )
       
    88                 {
       
    89                 __VTPRINT( DEBUG_GEN, "CtxCtrl.HandlePtr.Button1Down outside" )
       
    90                 // Down outside of Ctx ctrl, set inside false
       
    91                 iPointerButton1DownInside = EFalse;
       
    92                 }
       
    93             else
       
    94                 {
       
    95                 __VTPRINT( DEBUG_GEN, "CtxCtrl.HandlePtrButton1Down inside" )
       
    96                 // Only true here
       
    97                 iPointerButton1DownInside = ETrue;
       
    98                 }
       
    99             }
       
   100         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   101             {
       
   102             TRect window( Size() );
       
   103             if ( !window.Contains( aPointerEvent.iPosition ) ||
       
   104                     iAppUi.MainControl().IsMainControlPointerEvent() )
       
   105                 {
       
   106                 __VTPRINT( DEBUG_GEN, "CtxCtrl.HandlePtr.Button1Up outside" )
       
   107                 
       
   108                 // Up outside of Ctx ctrl, set inside false
       
   109                 iPointerButton1DownInside = EFalse;
       
   110                 
       
   111                 iOkToSwapOnButtonUp = ETrue;
       
   112                 SetGloballyCapturing( EFalse );
       
   113                 SetPointerCapture( EFalse ); 
       
   114                 }
       
   115             else if( iOkToSwapOnButtonUp )
       
   116                 {
       
   117                 __VTPRINT( DEBUG_GEN, "CtxCtrl.HandlePtr.Button1Up inside" )
       
   118                  if ( !iUiStates.IsWhiteBalanceModeOn() &&
       
   119                       !iUiStates.IsColorToneModeOn() &&
       
   120                       !iUiStates.IsZoomModeOn() &&
       
   121                       !iUiStates.IsCaptureModeOn() &&
       
   122                       !iUiStates.IsContrastModeOn() &&
       
   123                       !iUiStates.IsBrightnessModeOn() &&
       
   124                       !iUiStates.IsVolumeModeOn() )
       
   125                         {
       
   126                         if ( !iPointerButton1DownInside ||
       
   127                                 !( iAppUi.CanSwapImagePlaces() ) )
       
   128                             {
       
   129                             // Set the flag back
       
   130                             iPointerButton1DownInside = EFalse;
       
   131                             return;
       
   132                             }
       
   133                         // Set the flag back
       
   134                         iPointerButton1DownInside = EFalse;
       
   135                         iAppUi.HandleCommandL( EVtUiCmdSwapImagesPlaces );
       
   136                         }
       
   137                 }
       
   138             else
       
   139                 {
       
   140                 __VTPRINT( DEBUG_GEN, "CtxCtrl.HandlePtr.Button1Up inside" )
       
   141                 SetGloballyCapturing( EFalse );
       
   142                 SetPointerCapture( EFalse); 
       
   143                 iOkToSwapOnButtonUp = ETrue;
       
   144                 // Set the flag back
       
   145                 iPointerButton1DownInside = EFalse;
       
   146                 }
       
   147             }
       
   148         }
       
   149     __VTPRINTEXIT( "CtxCtrl.HandlePointerEventL" )
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CVtUiContextControl::HandleSizeChanged
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void CVtUiContextControl::HandleSizeChanged()
       
   157     {
       
   158     __VTPRINTENTER( "CtxCtrl.HandleSizeChanged" )
       
   159     TRect screen;
       
   160     VtUiLayout::GetApplicationParentRect( screen );
       
   161 
       
   162     TAknWindowLineLayout control;
       
   163     VtUiLayout::GetFirstWindowBackgroundLayout( control );
       
   164     TAknLayoutRect backLayout;
       
   165     backLayout.LayoutRect( screen, control );
       
   166     BitmapManager().SetSize( iBackgroundId, backLayout.Rect().Size() );
       
   167 
       
   168     const TPoint positionRelativeToScreen( -PositionRelativeToScreen() );
       
   169 
       
   170     VtUiLayout::GetFirstWindowStreamDisabledIconLayout( control );
       
   171     TAknLayoutRect blindLayout;
       
   172     blindLayout.LayoutRect( screen, control );
       
   173     iBlindRect = blindLayout.Rect();
       
   174     iBlindRect.Move( positionRelativeToScreen );
       
   175     BitmapManager().SetSize( iBlindId, iBlindRect.Size() );
       
   176     BitmapManager().SetSize( iBlindMaskId, iBlindRect.Size() );
       
   177 
       
   178     VtUiLayout::GetFirstWindowStreamLayout( control );
       
   179     TAknLayoutRect streamLayout;
       
   180     streamLayout.LayoutRect( screen, control );
       
   181     iStreamRect = streamLayout.Rect();
       
   182     iStreamRect.Move( positionRelativeToScreen ) ;
       
   183     __VTPRINTEXIT( "CtxCtrl.HandleSizeChanged" )
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CVtUiContextControl::StreamBlitPosition
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 TPoint CVtUiContextControl::StreamBlitPosition() const
       
   191     {
       
   192     __VTPRINTENTER( "CtxCtrl.StreamBlitPosition" )
       
   193     __VTPRINTEXIT( "CtxCtrl.StreamBlitPosition" )
       
   194     return iStreamRect.iTl;
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CVtUiContextControl::StreamClippingRect
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 TRect CVtUiContextControl::StreamClippingRect() const
       
   202     {
       
   203     __VTPRINTENTER( "CtxCtrl.StreamClippingRect" )
       
   204     __VTPRINTEXIT( "CtxCtrl.StreamClippingRect" )
       
   205     return iStreamRect;
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CVtUiContextControl::DrawColoredBackground
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 void CVtUiContextControl::DrawColoredBackground( CWindowGc& aGc ) const
       
   213     {
       
   214     __VTPRINTENTER( "CtxCtrl.DrawColoredBackground" )
       
   215     CVtUiVideoControlBase::DrawColoredBackground( aGc );
       
   216     // Draw background image
       
   217     CFbsBitmap* bg = NULL;
       
   218     CFbsBitmap* bgMask = NULL;
       
   219     BitmapManager().GetBitmaps( iBackgroundId, bg, bgMask );
       
   220     if ( bg )
       
   221         {
       
   222         const TPoint origin;
       
   223         const TRect rect( origin, bg->SizeInPixels() );
       
   224         if ( bgMask )
       
   225             {
       
   226             aGc.BitBltMasked( origin, bg, rect, bgMask, ETrue );
       
   227             }
       
   228         else
       
   229             {
       
   230             aGc.BitBlt( origin, bg );
       
   231             }
       
   232         }
       
   233     __VTPRINTEXIT( "CtxCtrl.DrawColoredBackground" )
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CVtUiContextControl::BlindImage
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 CFbsBitmap* CVtUiContextControl::BlindImage() const
       
   241     {
       
   242     __VTPRINTENTER( "CtxCtrl.BlindImage" )
       
   243     __VTPRINTEXIT( "CtxCtrl.BlindImage" )
       
   244     return Bitmap( iBlindId );
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 // CVtUiContextControl::BlindMask
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 CFbsBitmap* CVtUiContextControl::BlindMask() const
       
   252     {
       
   253     __VTPRINTENTER( "CtxCtrl.BlindImage" )
       
   254     __VTPRINTEXIT( "CtxCtrl.BlindImage" )
       
   255     return Bitmap( iBlindMaskId );
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 // CVtUiContextControl::BlindBlitPosition
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 TPoint CVtUiContextControl::BlindBlitPosition() const
       
   263     {
       
   264     __VTPRINTENTER( "CtxCtrl.BlindBlitPosition" )
       
   265     __VTPRINTEXIT( "CtxCtrl.BlindBlitPosition" )
       
   266     return iBlindRect.iTl;
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CVtUiContextControl::CVtUiContextControl
       
   271 // C++ constructor can NOT contain any code, that
       
   272 // might leave.
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 CVtUiContextControl::CVtUiContextControl(
       
   276         CVtUiBitmapManager& aBitmapManager,
       
   277         CVtUiAppUi& aAppUi,
       
   278         TVtUiStates& aUiStates )
       
   279     : CVtUiVideoControlBase( aBitmapManager ),
       
   280       iAppUi( aAppUi ),
       
   281       iUiStates( aUiStates )
       
   282     {
       
   283     __VTPRINTENTER( "CtxCtrl.ctor" )
       
   284     SetRenderingHint( ENoWaitingText );
       
   285     SetRenderingHint( EColoredBackground );
       
   286     __VTPRINTEXIT( "CtxCtrl.ctor" )
       
   287     }
       
   288 
       
   289 // -----------------------------------------------------------------------------
       
   290 // CVtUiContextControl::ConstructL
       
   291 // Symbian 2nd phase constructor.
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 void CVtUiContextControl::ConstructL()
       
   295     {
       
   296     __VTPRINTENTER( "CtxCtrl.ConstructL" )
       
   297     BaseConstructL();
       
   298     iBackgroundId =
       
   299         BitmapManager().AddBitmapsL(
       
   300             EVtUiBitmap_qgn_graf_call_video_out_bg,
       
   301             EVtUiBitmap_qgn_graf_call_video_out_bg_mask,
       
   302             EFalse );
       
   303     BitmapManager().SetAspectRatio( iBackgroundId, EFalse );
       
   304     iBlindId =
       
   305         BitmapManager().AddBitmapL(
       
   306             EVtUiBitmap_qgn_indi_call_video_blind_out,
       
   307             EFalse );
       
   308     BitmapManager().SetAspectRatio( iBlindId, EFalse );
       
   309     iBlindMaskId =
       
   310         BitmapManager().AddBitmapL(
       
   311             EVtUiBitmap_qgn_indi_call_video_blind_out_mask_icon,
       
   312             EFalse );
       
   313     BitmapManager().SetAspectRatio( iBlindMaskId, EFalse );
       
   314     SetNonFocusing();
       
   315     if ( iAppUi.EventMonitor() )
       
   316         {
       
   317         iAppUi.EventMonitor()->AddObserverL( this );
       
   318         }
       
   319         
       
   320     iOkToSwapOnButtonUp = ETrue;
       
   321     
       
   322     ClaimPointerGrab( ETrue );
       
   323     
       
   324     __VTPRINTEXIT( "CtxCtrl.ConstructL" )
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CVtUiContextControl::HandleWsEventL
       
   329 // -----------------------------------------------------------------------------
       
   330 //
       
   331 void CVtUiContextControl::HandleWsEventL( const TWsEvent& aEvent,
       
   332     CCoeControl* aDestination )
       
   333     {
       
   334     __VTPRINTENTER( "CVtUiContextControl.HandleWsEventL" )
       
   335     if( aEvent.Type() == EEventPointer )
       
   336         {
       
   337         // Touch outside of volume popup, close volume popup
       
   338         if ( aEvent.Pointer()->iType == TPointerEvent::EButton1Down )
       
   339             {
       
   340             __VTPRINT( DEBUG_GEN, "CtxCtrl.WsEvent.Button1Down inside" )
       
   341             iOkToSwapOnButtonUp = !iUiStates.IsZoomModeOn() &&
       
   342                     !iUiStates.IsContrastModeOn() &&
       
   343                     !iUiStates.IsBrightnessModeOn() &&
       
   344                     !iUiStates.IsVolumeModeOn();
       
   345             
       
   346             if( iUiStates.IsZoomModeOn() && iUiStates.IsCaptureModeOn() )
       
   347                 {
       
   348                 iOkToSwapOnButtonUp = ETrue;
       
   349                 }            
       
   350             
       
   351             if ( aDestination == this )
       
   352                 {
       
   353                 iOkToSwapOnButtonUp = !iUiStates.IsZoomModeOn() &&
       
   354                     !iUiStates.IsCaptureModeOn() &&
       
   355                     !iUiStates.IsContrastModeOn() &&
       
   356                     !iUiStates.IsBrightnessModeOn() &&
       
   357                     !iUiStates.IsVolumeModeOn();
       
   358                     SetGloballyCapturing( ETrue );
       
   359                     SetPointerCapture( ETrue ); 
       
   360                 }
       
   361             }
       
   362         else if ( aEvent.Pointer()->iType == TPointerEvent::EButton1Up )
       
   363             {
       
   364             __VTPRINT( DEBUG_GEN, "CtxCtrl.WsEvent.Button1Up inside" )
       
   365             }
       
   366         }
       
   367     __VTPRINTEXIT( "CVtUiContextControl.HandleWsEventL" )
       
   368     }
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // CVtUiContextControl::LayoutRemoteVideo
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 void CVtUiContextControl::LayoutRemoteVideo()
       
   375     {
       
   376     __VTPRINTENTER( "CVtUiContextControl.LayoutRemoteVideo" )
       
   377     if ( NULL != iRemoteVideoControl && iRemoteVideoControl->IsVisible() )
       
   378         {
       
   379         TRect rectRemoteVideo(StreamClippingRect());
       
   380         rectRemoteVideo.Move(PositionRelativeToScreen());
       
   381         iRemoteVideoControl->SetExtent(rectRemoteVideo.iTl,rectRemoteVideo.Size());        
       
   382         }
       
   383     __VTPRINTEXIT( "CVtUiContextControl.LayoutRemoteVideo" )
       
   384     }
       
   385 //  End of File