vtuis/videotelui/src/CVtUiContextControl.cpp
changeset 0 ed9695c8bcbe
child 2 4a81900cd18b
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     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                         {
       
    95                         if ( !( iAppUi.CanSwapImagePlaces() ) )
       
    96                             {
       
    97                             return;
       
    98                             }	
       
    99                         iAppUi.HandleCommandL( EVtUiCmdSwapImagesPlaces );
       
   100                         }
       
   101                 }
       
   102             else
       
   103                 {
       
   104                 SetGloballyCapturing( EFalse );
       
   105                 SetPointerCapture( EFalse); 
       
   106                 iOkToSwapOnButtonUp = ETrue;
       
   107                 }
       
   108             }
       
   109         }
       
   110     __VTPRINTEXIT( "CtxCtrl.HandlePointerEventL" )
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CVtUiContextControl::HandleSizeChanged
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CVtUiContextControl::HandleSizeChanged()
       
   118     {
       
   119     __VTPRINTENTER( "CtxCtrl.HandleSizeChanged" )
       
   120     TRect screen;
       
   121     VtUiLayout::GetApplicationParentRect( screen );
       
   122 
       
   123     TAknWindowLineLayout control;
       
   124     VtUiLayout::GetFirstWindowBackgroundLayout( control );
       
   125     TAknLayoutRect backLayout;
       
   126     backLayout.LayoutRect( screen, control );
       
   127     BitmapManager().SetSize( iBackgroundId, backLayout.Rect().Size() );
       
   128 
       
   129     const TPoint positionRelativeToScreen( -PositionRelativeToScreen() );
       
   130 
       
   131     VtUiLayout::GetFirstWindowStreamDisabledIconLayout( control );
       
   132     TAknLayoutRect blindLayout;
       
   133     blindLayout.LayoutRect( screen, control );
       
   134     iBlindRect = blindLayout.Rect();
       
   135     iBlindRect.Move( positionRelativeToScreen );
       
   136     BitmapManager().SetSize( iBlindId, iBlindRect.Size() );
       
   137     BitmapManager().SetSize( iBlindMaskId, iBlindRect.Size() );
       
   138 
       
   139     VtUiLayout::GetFirstWindowStreamLayout( control );
       
   140     TAknLayoutRect streamLayout;
       
   141     streamLayout.LayoutRect( screen, control );
       
   142     iStreamRect = streamLayout.Rect();
       
   143     iStreamRect.Move( positionRelativeToScreen ) ;
       
   144     __VTPRINTEXIT( "CtxCtrl.HandleSizeChanged" )
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CVtUiContextControl::StreamBlitPosition
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 TPoint CVtUiContextControl::StreamBlitPosition() const
       
   152     {
       
   153     __VTPRINTENTER( "CtxCtrl.StreamBlitPosition" )
       
   154     __VTPRINTEXIT( "CtxCtrl.StreamBlitPosition" )
       
   155     return iStreamRect.iTl;
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // CVtUiContextControl::StreamClippingRect
       
   160 // ---------------------------------------------------------------------------
       
   161 //
       
   162 TRect CVtUiContextControl::StreamClippingRect() const
       
   163     {
       
   164     __VTPRINTENTER( "CtxCtrl.StreamClippingRect" )
       
   165     __VTPRINTEXIT( "CtxCtrl.StreamClippingRect" )
       
   166     return iStreamRect;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CVtUiContextControl::DrawColoredBackground
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 void CVtUiContextControl::DrawColoredBackground( CWindowGc& aGc ) const
       
   174     {
       
   175     __VTPRINTENTER( "CtxCtrl.DrawColoredBackground" )
       
   176     CVtUiVideoControlBase::DrawColoredBackground( aGc );
       
   177     // Draw background image
       
   178     CFbsBitmap* bg = NULL;
       
   179     CFbsBitmap* bgMask = NULL;
       
   180     BitmapManager().GetBitmaps( iBackgroundId, bg, bgMask );
       
   181     if ( bg )
       
   182         {
       
   183         const TPoint origin;
       
   184         const TRect rect( origin, bg->SizeInPixels() );
       
   185         if ( bgMask )
       
   186             {
       
   187             aGc.BitBltMasked( origin, bg, rect, bgMask, ETrue );
       
   188             }
       
   189         else
       
   190             {
       
   191             aGc.BitBlt( origin, bg );
       
   192             }
       
   193         }
       
   194     __VTPRINTEXIT( "CtxCtrl.DrawColoredBackground" )
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CVtUiContextControl::BlindImage
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 CFbsBitmap* CVtUiContextControl::BlindImage() const
       
   202     {
       
   203     __VTPRINTENTER( "CtxCtrl.BlindImage" )
       
   204     __VTPRINTEXIT( "CtxCtrl.BlindImage" )
       
   205     return Bitmap( iBlindId );
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CVtUiContextControl::BlindMask
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 CFbsBitmap* CVtUiContextControl::BlindMask() const
       
   213     {
       
   214     __VTPRINTENTER( "CtxCtrl.BlindImage" )
       
   215     __VTPRINTEXIT( "CtxCtrl.BlindImage" )
       
   216     return Bitmap( iBlindMaskId );
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CVtUiContextControl::BlindBlitPosition
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 TPoint CVtUiContextControl::BlindBlitPosition() const
       
   224     {
       
   225     __VTPRINTENTER( "CtxCtrl.BlindBlitPosition" )
       
   226     __VTPRINTEXIT( "CtxCtrl.BlindBlitPosition" )
       
   227     return iBlindRect.iTl;
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CVtUiContextControl::CVtUiContextControl
       
   232 // C++ constructor can NOT contain any code, that
       
   233 // might leave.
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 CVtUiContextControl::CVtUiContextControl(
       
   237         CVtUiBitmapManager& aBitmapManager,
       
   238         CVtUiAppUi& aAppUi,
       
   239         TVtUiStates& aUiStates )
       
   240     : CVtUiVideoControlBase( aBitmapManager ),
       
   241       iAppUi( aAppUi ),
       
   242       iUiStates( aUiStates )
       
   243     {
       
   244     __VTPRINTENTER( "CtxCtrl.ctor" )
       
   245     SetRenderingHint( ENoWaitingText );
       
   246     SetRenderingHint( EColoredBackground );
       
   247     __VTPRINTEXIT( "CtxCtrl.ctor" )
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CVtUiContextControl::ConstructL
       
   252 // Symbian 2nd phase constructor.
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 void CVtUiContextControl::ConstructL()
       
   256     {
       
   257     __VTPRINTENTER( "CtxCtrl.ConstructL" )
       
   258     BaseConstructL();
       
   259     iBackgroundId =
       
   260         BitmapManager().AddBitmapsL(
       
   261             EVtUiBitmap_qgn_graf_call_video_out_bg,
       
   262             EVtUiBitmap_qgn_graf_call_video_out_bg_mask,
       
   263             EFalse );
       
   264     BitmapManager().SetAspectRatio( iBackgroundId, EFalse );
       
   265     iBlindId =
       
   266         BitmapManager().AddBitmapL(
       
   267             EVtUiBitmap_qgn_indi_call_video_blind_out,
       
   268             EFalse );
       
   269     BitmapManager().SetAspectRatio( iBlindId, EFalse );
       
   270     iBlindMaskId =
       
   271         BitmapManager().AddBitmapL(
       
   272             EVtUiBitmap_qgn_indi_call_video_blind_out_mask_icon,
       
   273             EFalse );
       
   274     BitmapManager().SetAspectRatio( iBlindMaskId, EFalse );
       
   275     SetNonFocusing();
       
   276     if ( iAppUi.EventMonitor() )
       
   277         {
       
   278         iAppUi.EventMonitor()->AddObserverL( this );
       
   279         }
       
   280         
       
   281     iOkToSwapOnButtonUp = ETrue;
       
   282     __VTPRINTEXIT( "CtxCtrl.ConstructL" )
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CVtUiContextControl::HandleWsEventL
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void CVtUiContextControl::HandleWsEventL( const TWsEvent& aEvent,
       
   290     CCoeControl* aDestination )
       
   291     {
       
   292     __VTPRINTENTER( "CVtUiContextControl.HandleWsEventL" )
       
   293     if( aEvent.Type() == EEventPointer )
       
   294         {
       
   295         // Touch outside of volume popup, close volume popup
       
   296         if ( aEvent.Pointer()->iType == TPointerEvent::EButton1Down )
       
   297             {
       
   298             if ( aDestination == this )
       
   299                 {
       
   300                 iOkToSwapOnButtonUp = !iUiStates.IsZoomModeOn() &&
       
   301                     !iUiStates.IsCaptureModeOn() &&
       
   302                     !iUiStates.IsContrastModeOn() &&
       
   303                     !iUiStates.IsBrightnessModeOn() &&
       
   304                     !iUiStates.IsVolumeModeOn();
       
   305                     SetGloballyCapturing( ETrue );
       
   306                     SetPointerCapture( ETrue ); 
       
   307                 }
       
   308             }             
       
   309         }
       
   310     __VTPRINTEXIT( "CVtUiContextControl.HandleWsEventL" )
       
   311     }
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // CVtUiContextControl::LayoutRemoteVideo
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 void CVtUiContextControl::LayoutRemoteVideo()
       
   318     {
       
   319     __VTPRINTENTER( "CVtUiContextControl.LayoutRemoteVideo" )
       
   320     if ( NULL != iRemoteVideoControl )
       
   321         {
       
   322         TRect rectRemoteVideo(StreamClippingRect());
       
   323         rectRemoteVideo.Move(PositionRelativeToScreen());
       
   324         iRemoteVideoControl->SetExtent(rectRemoteVideo.iTl,rectRemoteVideo.Size());        
       
   325         }
       
   326     __VTPRINTEXIT( "CVtUiContextControl.LayoutRemoteVideo" )
       
   327     }
       
   328 //  End of File