vtuis/videotelui/src/cvtuivideocontrolbase.cpp
changeset 0 ed9695c8bcbe
child 2 4a81900cd18b
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Video control base class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <cvtlogger.h>
       
    20 #include    <featmgr.h>
       
    21 #include    <aknsdrawutils.h>
       
    22 #include    <aknsutils.h>
       
    23 #include    <aknbiditextutils.h>
       
    24 #include    <stringloader.h>
       
    25 #include    <videotelui.rsg>
       
    26 
       
    27 #include     <aknsbasicbackgroundcontrolcontext.h>
       
    28 #include    <aknstatuspaneutils.h>
       
    29 #include    "cvtuivideocontrolbase.h"
       
    30 #include    "mvtuicomponentmanager.h"
       
    31 #include    "VtUiLayout.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // Index of white color.
       
    36 const TInt KVtUiColorWhite = 0;
       
    37 
       
    38 // Amount of characters reserved per line.
       
    39 const TInt KVtUiWaitingExtraSpacePerLine = KAknBidiExtraSpacePerLine + 1;
       
    40 
       
    41 // Amount of lines used for 'waiting text'
       
    42 const TInt KVtUiWaitingLineCount = 2;
       
    43 
       
    44 // Implementation of CVtUiVideoControlBase
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CVtUiVideoControlBase::~CVtUiVideoControlBase
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CVtUiVideoControlBase::~CVtUiVideoControlBase()
       
    51     {
       
    52     __VTPRINTENTER( "VidCtrlBase.~" )
       
    53     AknsUtils::DeregisterControlPosition( this );
       
    54     iStreamBitmap = NULL; // not owned.
       
    55     delete iWaitingTextWrappedArray;
       
    56     delete iWaitingTextWrapped;
       
    57     delete iBgContext;
       
    58     __VTPRINTEXIT( "VidCtrlBase.~" )
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CVtUiVideoControlBase::CVtUiVideoControlBase
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CVtUiVideoControlBase::CVtUiVideoControlBase(
       
    66     CVtUiBitmapManager& aBitmapManager ) :
       
    67     iBitmapManager( &aBitmapManager )
       
    68     {
       
    69     __VTPRINTENTER( "VidCtrlBase.ctor" )
       
    70     __VTPRINTEXIT( "VidCtrlBase.ctor" )
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CVtUiVideoControlBase::BaseConstructL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CVtUiVideoControlBase::BaseConstructL()
       
    78     {
       
    79     __VTPRINTENTER( "VidCtrlBase.BaseConstructL" )
       
    80     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
    81                        KAknsIIDQsnBgAreaMain, Rect(), ETrue );
       
    82     CreateWindowL();
       
    83     SetExtent( TPoint(), TSize() );
       
    84     ActivateL();
       
    85     // Disable fading when using DP (eliminates nasty color error)
       
    86     if ( FeatureManager::FeatureSupported( KFeatureIdDisplayPost ) )
       
    87         {
       
    88         Window().SetNonFading( ETrue );
       
    89         }
       
    90     WrapOnDemand();
       
    91     __VTPRINTEXIT( "VidCtrlBase.BaseConstructL" )
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CVtUiVideoControlBase::SetRenderingHint
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CVtUiVideoControlBase::SetRenderingHint( TRenderingHint aHint )
       
    99     {
       
   100     __VTPRINTENTER( "VidCtrlBase.SetRenderingHint" )
       
   101     __VTPRINT2( DEBUG_GEN, "VidCtrlBase.SetRenderingHint aHint = %d", aHint )
       
   102     iHints.Set( aHint );
       
   103     __VTPRINTEXIT( "VidCtrlBase.SetRenderingHint" )
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // CVtUiVideoControlBase::ClearRenderingHint
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void CVtUiVideoControlBase::ClearRenderingHint( TRenderingHint aHint )
       
   111     {
       
   112     __VTPRINTENTER( "VidCtrlBase.ClearRenderingHint" )
       
   113     __VTPRINT2( DEBUG_GEN, "VidCtrlBase.ClearRenderingHint aHint = %d", aHint )
       
   114     iHints.Clear( aHint );
       
   115     __VTPRINTEXIT( "VidCtrlBase.ClearRenderingHint" )
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CVtUiVideoControlBase::BitmapManager
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CVtUiBitmapManager& CVtUiVideoControlBase::BitmapManager() const
       
   123     {
       
   124     return *iBitmapManager;
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // CVtUiVideoControlBase::Bitmap
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 CFbsBitmap* CVtUiVideoControlBase::Bitmap( TVtUiBitmapPoolId aId ) const
       
   132     {
       
   133     __VTPRINTENTER( "VidCtrlBase.Bitmap" )
       
   134     CFbsBitmap* bitmap = NULL;
       
   135     iBitmapManager->GetBitmap( aId, bitmap );
       
   136     __VTPRINTEXITR( "VidCtrlBase.Bitmap %d", TInt( bitmap ) )
       
   137     return bitmap;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CVtUiVideoControlBase::AdjustPointForDP
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 TPoint CVtUiVideoControlBase::AdjustPointForDP( const TPoint aPoint ) const
       
   145     {
       
   146     __VTPRINTENTER( "VidCtrlBase.AdjustPointForDP" )
       
   147     TPoint result( aPoint );
       
   148     if ( FeatureManager::FeatureSupported( KFeatureIdDisplayPost ) )
       
   149         {
       
   150         if ( result.iX & 1 )
       
   151             {
       
   152             result.iX++;
       
   153             }
       
   154         }
       
   155     __VTPRINTEXIT( "VidCtrlBase.AdjustPointForDP" )
       
   156     return result;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CVtUiVideoControlBase::AdjustRectForDP
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 TRect CVtUiVideoControlBase::AdjustRectForDP( const TRect aRect ) const
       
   164     {
       
   165     __VTPRINTENTER( "VidCtrlBase.AdjustRectForDP" )
       
   166     TRect result( aRect );
       
   167     if ( FeatureManager::FeatureSupported( KFeatureIdDisplayPost ) )
       
   168         {
       
   169         if ( result.iTl.iX & 1 )
       
   170             {
       
   171             result.Move( 1, 0 );
       
   172             result.SetWidth( Max( 0, result.Width() - 1 ) );
       
   173             }
       
   174         if ( result.Width() & 1 )
       
   175             {
       
   176             result.SetWidth( result.Width() - 1 );
       
   177             }
       
   178         }
       
   179     __VTPRINTEXIT( "VidCtrlBase.AdjustRectForDP" )
       
   180     return result;
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CVtUiVideoControlBase::WaitingTextLayout
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 TAknTextLineLayout CVtUiVideoControlBase::WaitingTextLayout( TInt )
       
   188     {
       
   189     return TAknTextLineLayout();
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CVtUiVideoControlBase::HandleSizeChanged
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 void CVtUiVideoControlBase::HandleSizeChanged()
       
   197     {
       
   198     __VTPRINTENTER( "VidCtrlBase.HandleSizeChanged" )
       
   199     __VTPRINTEXIT( "VidCtrlBase.HandleSizeChanged" )
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // CVtUiVideoControlBase::DrawSkinnedBackground
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 void CVtUiVideoControlBase::DrawSkinnedBackground( CWindowGc& aGc ) const
       
   207     {
       
   208     __VTPRINTENTER( "VidCtrlBase.DrawSkinnedBackground" )
       
   209     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   210     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   211     AknsDrawUtils::Background( skin, cc, this, aGc, Rect() );
       
   212     __VTPRINTEXIT( "VidCtrlBase.DrawSkinnedBackground" )
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CVtUiVideoControlBase::MopSupplyObject
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 
       
   220 TTypeUid::Ptr CVtUiVideoControlBase::MopSupplyObject( TTypeUid aId )
       
   221  {
       
   222      __VTPRINTENTER( "VidCtrlBase.MopSupplyObject" )
       
   223  // Required during rendering of the background skin in Draw()
       
   224  if (aId.iUid == MAknsControlContext::ETypeId)
       
   225      {
       
   226       __VTPRINTEXIT( "VidCtrlBase.MopSupplyObject.1" )
       
   227      return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   228      }
       
   229     __VTPRINTEXIT( "VidCtrlBase.MopSupplyObject.2" )
       
   230  return CCoeControl::MopSupplyObject( aId );
       
   231  }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CVtUiVideoControlBase::DrawColoredBackground
       
   235 // ---------------------------------------------------------------------------
       
   236 //
       
   237 void CVtUiVideoControlBase::DrawColoredBackground( CWindowGc& aGc ) const
       
   238     {
       
   239     __VTPRINTENTER( "VidCtrlBase.DrawColoredBackground" )
       
   240     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   241     aGc.SetPenStyle( CGraphicsContext::ENullPen );
       
   242     aGc.SetBrushColor( AKN_LAF_COLOR( KVtUiColorWhite ) );
       
   243     aGc.DrawRect( Rect() );
       
   244     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   245     __VTPRINTEXIT( "VidCtrlBase.DrawColoredBackground" )
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CVtUiVideoControlBase::DrawWaitingText
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 TBool CVtUiVideoControlBase::DrawWaitingText( CWindowGc& aGc ) const
       
   253     {
       
   254     __VTPRINTENTER( "VidCtrlBase.DrawWaitingText" )
       
   255     const TInt count( iWaitingTextWrappedArray->Count() );
       
   256     if ( count > 0 )
       
   257         {
       
   258         aGc.SetClippingRect( StreamClippingRect() );
       
   259         aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   260         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   261         TRgb color( iWaitingTextLine1Layout.Color() );
       
   262         AknsUtils::GetCachedColor(
       
   263             skin,
       
   264             color,
       
   265             KAknsIIDQsnTextColors,
       
   266             EAknsCIQsnTextColorsCG6 );
       
   267         iWaitingTextLine1Layout.DrawText(
       
   268             aGc,
       
   269             iWaitingTextWrappedArray->At( 0 ), // first line
       
   270             EFalse,
       
   271             color );
       
   272         if ( count > 1 ) // two lines
       
   273             {
       
   274             iWaitingTextLine2Layout.DrawText(
       
   275                 aGc,
       
   276                 iWaitingTextWrappedArray->At( 1 ), // second line
       
   277                 EFalse,
       
   278                 color );
       
   279             }
       
   280         }
       
   281     __VTPRINTEXITR( "VidCtrlBase.DrawWaitingText %d", ETrue )
       
   282     return ETrue;
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------------------------
       
   286 // CVtUiVideoControlBase::DrawBlind
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 void CVtUiVideoControlBase::DrawBlind( CWindowGc& aGc ) const
       
   290     {
       
   291     __VTPRINTENTER( "VidCtrlBase.DrawBlind" )
       
   292     CFbsBitmap* icon = BlindImage();
       
   293     if ( icon )
       
   294         {
       
   295         CFbsBitmap* mask = BlindMask();
       
   296         if ( mask )
       
   297             {
       
   298             aGc.BitBltMasked(
       
   299                 BlindBlitPosition(),
       
   300                 icon,
       
   301                 TRect( icon->SizeInPixels() ),
       
   302                 mask,
       
   303                 ETrue );
       
   304             }
       
   305         else
       
   306             {
       
   307             aGc.BitBlt(
       
   308                 BlindBlitPosition(),
       
   309                 icon );
       
   310             }
       
   311         }
       
   312     __VTPRINTEXIT( "VidCtrlBase.DrawBlind" )
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // CVtUiVideoControlBase::DrawStream
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void CVtUiVideoControlBase::DrawStream( CWindowGc& aGc ) const
       
   320     {
       
   321     __VTPRINTENTER( "VidCtrlBase.DrawStream" )
       
   322     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   323     aGc.SetClippingRect( StreamClippingRect() );
       
   324     aGc.BitBlt( StreamBlitPosition(), iStreamBitmap );
       
   325     aGc.CancelClippingRect();
       
   326     __VTPRINTEXIT( "VidCtrlBase.DrawStream" )
       
   327     }
       
   328 
       
   329 // ---------------------------------------------------------------------------
       
   330 // CVtUiVideoControlBase::StreamBlitPosition
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 TPoint CVtUiVideoControlBase::StreamBlitPosition() const
       
   334     {
       
   335     __VTPRINTENTER( "VidCtrlBase.StreamBlitPosition" )
       
   336     __VTPRINTEXIT( "VidCtrlBase.StreamBlitPosition" )
       
   337     return Rect().iTl;
       
   338     }
       
   339 
       
   340 // ---------------------------------------------------------------------------
       
   341 // CVtUiVideoControlBase::StreamClippingRect
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 TRect CVtUiVideoControlBase::StreamClippingRect() const
       
   345     {
       
   346     __VTPRINTENTER( "VidCtrlBase.StreamClippingRect" )
       
   347     __VTPRINTEXIT( "VidCtrlBase.StreamClippingRect" )
       
   348     return Rect();
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CVtUiVideoControlBase::BlindImage
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 CFbsBitmap* CVtUiVideoControlBase::BlindImage() const
       
   356     {
       
   357     __VTPRINTENTER( "VidCtrlBase.BlindImage" )
       
   358     __VTPRINTEXIT( "VidCtrlBase.BlindImage" )
       
   359     return NULL;
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------------------------
       
   363 // CVtUiVideoControlBase::BlindMask
       
   364 // ---------------------------------------------------------------------------
       
   365 //
       
   366 CFbsBitmap* CVtUiVideoControlBase::BlindMask() const
       
   367     {
       
   368     __VTPRINTENTER( "VidCtrlBase.BlindMask" )
       
   369     __VTPRINTEXIT( "VidCtrlBase.BlindMask" )
       
   370     return NULL;
       
   371     }
       
   372 
       
   373 // ---------------------------------------------------------------------------
       
   374 // CVtUiVideoControlBase::BlindBlitPosition
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 TPoint CVtUiVideoControlBase::BlindBlitPosition() const
       
   378     {
       
   379     __VTPRINTENTER( "VidCtrlBase.BlindBlitPosition" )
       
   380     __VTPRINTEXIT( "VidCtrlBase.BlindBlitPosition" )
       
   381     return TPoint();
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // CVtUiVideoControlBase::Reset
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 void CVtUiVideoControlBase::Reset()
       
   389     {
       
   390     __VTPRINTENTER( "VidCtrlBase.Reset" )
       
   391     iBlindStatus = EFalse;
       
   392     iStreamBitmap = NULL;
       
   393     iWaitingTextShow = EFalse;
       
   394     __VTPRINTEXIT( "VidCtrlBase.Reset" )
       
   395     }
       
   396 
       
   397 // ---------------------------------------------------------------------------
       
   398 // CVtUiVideoControlBase::SetBlind
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 void CVtUiVideoControlBase::SetBlind( TBool aBlindStatus )
       
   402     {
       
   403     __VTPRINTENTER( "VidCtrlBase.SetBlind" )
       
   404     if ( iBlindStatus != aBlindStatus )
       
   405         {
       
   406         iBlindStatus = aBlindStatus;
       
   407         DrawNow();
       
   408         }
       
   409     __VTPRINTEXITR( "VidCtrlBase.SetBlind %d", iBlindStatus )
       
   410     }
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 // CVtUiVideoControlBase::IsAlphaZero
       
   414 // Checks if the alpha has been set to zero.
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 TBool CVtUiVideoControlBase::IsAlphaZero() const
       
   418     {
       
   419     __VTPRINTENTER( "VidCtrlBase.IsAlphaZero" )
       
   420     TBool isZero( EFalse );
       
   421     const CWsScreenDevice& sdev(
       
   422         *static_cast< CWsScreenDevice*>( SystemGc().Device() ) );
       
   423     if ( sdev.DisplayMode() == EColor16MA )
       
   424         {
       
   425         TRgb color;
       
   426         TPoint point( Rect().Center() );
       
   427         sdev.GetPixel( color, point );
       
   428         isZero = ( color.Alpha() == 0 );
       
   429         }
       
   430     __VTPRINTEXITR( "VidCtrlBase.IsAlphaZero %d", isZero )
       
   431     return isZero;
       
   432     }
       
   433 
       
   434 // -----------------------------------------------------------------------------
       
   435 // CVtUiVideoControlBase::SetAlpha
       
   436 // Sets alpha.
       
   437 // -----------------------------------------------------------------------------
       
   438 //
       
   439 void CVtUiVideoControlBase::SetAlpha( CWindowGc& aGc ) const
       
   440     {
       
   441     __VTPRINTENTER( "VidCtrlBase.SetAlpha" )
       
   442     aGc.SetDrawMode( CGraphicsContext::EDrawModeOR );
       
   443     aGc.SetBrushColor( TRgb( 0, 0, 0, 255 ) );
       
   444     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   445     aGc.Clear();
       
   446     aGc.Reset();
       
   447     __VTPRINTEXIT( "VidCtrlBase.SetAlpha" )
       
   448     }
       
   449 
       
   450 // ---------------------------------------------------------------------------
       
   451 // CVtUiVideoControlBase::SetStreamBitmap
       
   452 // ---------------------------------------------------------------------------
       
   453 //
       
   454 void CVtUiVideoControlBase::SetStreamBitmap( CFbsBitmap* aStreamBitmap )
       
   455     {
       
   456     __VTPRINTENTER( "VidCtrlBase.SetStreamBitmap" )
       
   457     __VTPRINT2( DEBUG_GEN, "VidCtrlBase.SetStreamBitmap %d",
       
   458         (TInt) aStreamBitmap )
       
   459     const CFbsBitmap* oldBitmap( iStreamBitmap );
       
   460     iStreamBitmap = aStreamBitmap;
       
   461     iSetAlpha = IsAlphaZero();
       
   462     if ( iStreamBitmap )
       
   463         {
       
   464         RedrawStream();
       
   465         }
       
   466     else if ( oldBitmap )
       
   467         {
       
   468         DrawNow();
       
   469         }
       
   470     __VTPRINTEXIT( "VidCtrlBase.SetStreamBitmap" )
       
   471     }
       
   472 
       
   473 // ---------------------------------------------------------------------------
       
   474 // CVtUiVideoControlBase::SetStreamBitmapReserve
       
   475 // ---------------------------------------------------------------------------
       
   476 //
       
   477 void CVtUiVideoControlBase::SetStreamBitmapReserve(
       
   478     CFbsBitmap* aStreamBitmap )
       
   479     {
       
   480     __VTPRINTENTER( "VidCtrlBase.SetStreamBitmapReserve" )
       
   481     __VTPRINT2( DEBUG_GEN, "VidCtrlBase.SetStreamBitmapReserve %d",
       
   482         (TInt) aStreamBitmap )
       
   483     const CFbsBitmap* oldBitmap( iStreamBitmap );
       
   484     iStreamBitmap = aStreamBitmap;
       
   485     if ( iStreamBitmap )
       
   486         {
       
   487         RedrawStream();
       
   488         }
       
   489     else if ( oldBitmap )
       
   490         {
       
   491         DrawNow();
       
   492         }
       
   493     __VTPRINTEXIT( "VidCtrlBase.SetStreamBitmapReserve" )
       
   494     }
       
   495 
       
   496 // ---------------------------------------------------------------------------
       
   497 // CVtUiVideoControlBase::SetWaiting
       
   498 // ---------------------------------------------------------------------------
       
   499 //
       
   500 void CVtUiVideoControlBase::SetWaiting( TBool aShowWaitingText )
       
   501     {
       
   502     __VTPRINTENTER( "VidCtrlBase.SetWaiting" )
       
   503     if ( iWaitingTextShow != aShowWaitingText )
       
   504         {
       
   505         iWaitingTextShow = aShowWaitingText;
       
   506         WrapOnDemand();
       
   507         DrawNow();
       
   508         }
       
   509     __VTPRINTEXITR( "VidCtrlBase.SetWaiting %d", iWaitingTextShow )
       
   510     }
       
   511 
       
   512 // ---------------------------------------------------------------------------
       
   513 // CVtUiVideoControlBase::Redraw
       
   514 // ---------------------------------------------------------------------------
       
   515 //
       
   516 void CVtUiVideoControlBase::Redraw()
       
   517     {
       
   518     __VTPRINTENTER( "VidCtrlBase.Redraw" )
       
   519     if ( iStreamBitmap )
       
   520         {
       
   521         __VTPRINT( DEBUG_GEN, "VidCtrlBase.Redraw drawing" );
       
   522         DrawNow();
       
   523         }
       
   524     __VTPRINTEXIT( "VidCtrlBase.Redraw" )
       
   525     }
       
   526 
       
   527 // ---------------------------------------------------------------------------
       
   528 // CVtUiVideoControlBase::Draw
       
   529 // ---------------------------------------------------------------------------
       
   530 //
       
   531 void CVtUiVideoControlBase::Draw( const TRect& ) const
       
   532     {
       
   533     __VTPRINTENTER( "VidCtrlBase.Draw" )
       
   534     DoDraw( SystemGc() );
       
   535     __VTPRINTEXIT( "VidCtrlBase.Draw" )
       
   536     }
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 // CVtUiVideoControlBase::SizeChanged
       
   540 // -----------------------------------------------------------------------------
       
   541 //
       
   542 void CVtUiVideoControlBase::SizeChanged()
       
   543     {
       
   544     __VTPRINTENTER( "VidCtrlBase.SizeChanged" )
       
   545     AknsUtils::RegisterControlPosition( this );
       
   546 
       
   547     TRect bgRect;
       
   548     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, bgRect );
       
   549     iBgContext->SetRect( bgRect );
       
   550 
       
   551     HandleSizeChanged();
       
   552     TRect parent( Rect() );
       
   553     if ( !parent.IsEmpty() )
       
   554         {
       
   555         TAknTextLineLayout text( WaitingTextLayout( 0 ) );
       
   556         iWaitingTextLine1Layout.LayoutText( parent, text );
       
   557         text = WaitingTextLayout( 1 );
       
   558         iWaitingTextLine2Layout.LayoutText( parent, text );
       
   559         delete iWaitingTextWrapped;
       
   560         iWaitingTextWrapped = NULL;
       
   561         delete iWaitingTextWrappedArray;
       
   562         iWaitingTextWrappedArray = NULL;
       
   563         WrapOnDemand();
       
   564         }
       
   565     __VTPRINTEXIT( "VidCtrlBase.SizeChanged" )
       
   566     }
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CVtUiVideoControlBase::PositionChanged
       
   570 // -----------------------------------------------------------------------------
       
   571 //
       
   572 void CVtUiVideoControlBase::PositionChanged()
       
   573     {
       
   574     __VTPRINTENTER( "VidCtrlBase.SizeChanged" )
       
   575     AknsUtils::RegisterControlPosition( this );
       
   576     __VTPRINTEXIT( "VidCtrlBase.SizeChanged" )
       
   577     }
       
   578 
       
   579 // ---------------------------------------------------------------------------
       
   580 // CVtUiVideoControlBase::RedrawStream
       
   581 // ---------------------------------------------------------------------------
       
   582 //
       
   583 void CVtUiVideoControlBase::RedrawStream()
       
   584     {
       
   585     __VTPRINTENTER( "VidCtrlBase.RedrawStream" )
       
   586     const TRect clippingRect( StreamClippingRect() );
       
   587     Window().Invalidate( clippingRect );
       
   588     Window().BeginRedraw( clippingRect );
       
   589     ActivateGc();
       
   590     CWindowGc& gc = SystemGc();
       
   591     if ( iSetAlpha )
       
   592         {
       
   593         SetAlpha( gc );
       
   594         iSetAlpha = EFalse;
       
   595         }
       
   596     DoDrawStream( gc );
       
   597     DoDrawBlind( gc );
       
   598     DeactivateGc();
       
   599     Window().EndRedraw();
       
   600     __VTPRINTEXIT( "VidCtrlBase.RedrawStream" )
       
   601     }
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // CVtUiVideoControlBase::WrapOnDemand
       
   605 // -----------------------------------------------------------------------------
       
   606 //
       
   607 void CVtUiVideoControlBase::WrapOnDemand()
       
   608     {
       
   609     __VTPRINTENTER( "VidCtrlBase.WrapOnDemand" )
       
   610     if ( iWaitingTextShow && !iWaitingTextWrapped )
       
   611         {
       
   612         TRAP_IGNORE( WrapWaitingTextL() );
       
   613         }
       
   614     __VTPRINTEXIT( "VidCtrlBase.WrapOnDemand" )
       
   615     }
       
   616 
       
   617 // -----------------------------------------------------------------------------
       
   618 // CVtUiVideoControlBase::WrapWaitingTextL
       
   619 // -----------------------------------------------------------------------------
       
   620 //
       
   621 void CVtUiVideoControlBase::WrapWaitingTextL()
       
   622     {
       
   623     __VTPRINTENTER( "VidCtrlBase.WrapWaitingTextL" )
       
   624     HBufC* waitingText =
       
   625         StringLoader::LoadLC( R_VIDEOTELUI_QTN_INCAL_WAITING_IMAGE );
       
   626 
       
   627     CArrayFix< TInt >* lines =
       
   628         new ( ELeave ) CArrayFixFlat< TInt >( KVtUiWaitingLineCount );
       
   629     CleanupStack::PushL( lines );
       
   630     lines->AppendL( iWaitingTextLine1Layout.TextRect().Width() );
       
   631     lines->AppendL( iWaitingTextLine2Layout.TextRect().Width() );
       
   632 
       
   633     CArrayFix<TPtrC>* wrap =
       
   634         new ( ELeave ) CArrayFixFlat< TPtrC >( KVtUiWaitingLineCount );
       
   635     CleanupStack::PushL( wrap );
       
   636     wrap->AppendL( TPtrC() );
       
   637     wrap->AppendL( TPtrC() );
       
   638 
       
   639     HBufC* waitingTextWrapped =
       
   640         HBufC::NewLC(
       
   641             waitingText->Length() +
       
   642             lines->Count() * KVtUiWaitingExtraSpacePerLine );
       
   643 
       
   644     TPtr textBuf = waitingTextWrapped->Des();
       
   645     textBuf.Zero();
       
   646     textBuf.Append( *waitingText );
       
   647 
       
   648     AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
       
   649         textBuf,
       
   650         *lines,
       
   651         *iWaitingTextLine1Layout.Font(),
       
   652         *wrap,
       
   653         ETrue );
       
   654 
       
   655     CleanupStack::Pop( waitingTextWrapped );
       
   656     iWaitingTextWrapped = waitingTextWrapped;
       
   657 
       
   658     CleanupStack::Pop( wrap );
       
   659     iWaitingTextWrappedArray = wrap;
       
   660 
       
   661     CleanupStack::PopAndDestroy( lines );
       
   662     CleanupStack::PopAndDestroy( waitingText );
       
   663     __VTPRINTEXIT( "VidCtrlBase.WrapWaitingTextL" )
       
   664     }
       
   665 
       
   666 // ---------------------------------------------------------------------------
       
   667 // CVtUiVideoControlBase::DoDraw
       
   668 // ---------------------------------------------------------------------------
       
   669 //
       
   670 void CVtUiVideoControlBase::DoDraw( CWindowGc& aGc ) const
       
   671     {
       
   672     __VTPRINTENTER( "VidCtrlBase.Draw(gc)" )
       
   673     if ( iSetAlpha )
       
   674         {
       
   675         SetAlpha( aGc );
       
   676         iSetAlpha = EFalse;
       
   677         }
       
   678     DoDrawBackground( aGc );
       
   679     if ( !DoDrawWaitingText( aGc ) )
       
   680         {
       
   681         DoDrawStream( aGc );
       
   682         DoDrawBlind( aGc );
       
   683         }
       
   684     __VTPRINTEXIT( "VidCtrlBase.Draw(gc)" )
       
   685     }
       
   686 
       
   687 // ---------------------------------------------------------------------------
       
   688 // CVtUiVideoControlBase::DoDrawBackground
       
   689 // ---------------------------------------------------------------------------
       
   690 //
       
   691 void CVtUiVideoControlBase::DoDrawBackground( CWindowGc& aGc ) const
       
   692     {
       
   693     __VTPRINTENTER( "VidCtrlBase.DoDrawBackground" )
       
   694     if ( iHints.IsSet( ESkinnedBackground ) )
       
   695         {
       
   696         DrawSkinnedBackground( aGc );
       
   697         }
       
   698     else if ( iHints.IsSet( EColoredBackground ) )
       
   699         {
       
   700         DrawColoredBackground( aGc );
       
   701         }
       
   702     __VTPRINTEXIT( "VidCtrlBase.DoDrawBackground" )
       
   703     }
       
   704 
       
   705 // ---------------------------------------------------------------------------
       
   706 // CVtUiVideoControlBase::DoDrawWaitingText
       
   707 // ---------------------------------------------------------------------------
       
   708 //
       
   709 TBool CVtUiVideoControlBase::DoDrawWaitingText( CWindowGc& aGc ) const
       
   710     {
       
   711     __VTPRINTENTER( "VidCtrlBase.DoDrawWaitingText" )
       
   712     TBool wasDrawn( EFalse );
       
   713     if ( iHints.IsClear( ENoWaitingText ) && iWaitingTextShow &&
       
   714          iWaitingTextWrapped && iWaitingTextWrappedArray )
       
   715         {
       
   716         wasDrawn = DrawWaitingText( aGc );
       
   717         }
       
   718     __VTPRINTEXITR( "VidCtrlBase.DoDrawWaitingText %d", wasDrawn )
       
   719     return wasDrawn;
       
   720     }
       
   721 
       
   722 // ---------------------------------------------------------------------------
       
   723 // CVtUiVideoControlBase::DoDrawBlind
       
   724 // ---------------------------------------------------------------------------
       
   725 //
       
   726 void CVtUiVideoControlBase::DoDrawBlind( CWindowGc& aGc ) const
       
   727     {
       
   728     __VTPRINTENTER( "VidCtrlBase.DoDrawBlind" )
       
   729     if ( iBlindStatus && iHints.IsClear( ENoBlindIcon ) )
       
   730         {
       
   731         DrawBlind( aGc );
       
   732         }
       
   733     __VTPRINTEXIT( "VidCtrlBase.DoDrawBlind" )
       
   734     }
       
   735 
       
   736 // ---------------------------------------------------------------------------
       
   737 // CVtUiVideoControlBase::DoDrawStream
       
   738 // ---------------------------------------------------------------------------
       
   739 //
       
   740 void CVtUiVideoControlBase::DoDrawStream( CWindowGc& aGc ) const
       
   741     {
       
   742     __VTPRINTENTER( "VidCtrlBase.DoDrawStream" )
       
   743     if ( iStreamBitmap )
       
   744         {
       
   745         DrawStream( aGc );
       
   746         }
       
   747     __VTPRINTEXIT( "VidCtrlBase.DoDrawStream" )
       
   748     }
       
   749 
       
   750 // ---------------------------------------------------------------------------
       
   751 // CVtUiVideoControlBase::SetRemoteVideoControl
       
   752 // ---------------------------------------------------------------------------
       
   753 //
       
   754 void CVtUiVideoControlBase::SetRemoteVideoControl( CCoeControl* aRemoteControl )
       
   755     {
       
   756     __VTPRINTENTER( "VidCtrlBase.SetRemoteVideoControl" )
       
   757     iRemoteVideoControl = aRemoteControl;
       
   758     __VTPRINTEXIT( "VidCtrlBase.SetRemoteVideoControl" )
       
   759     }
       
   760 
       
   761 // ---------------------------------------------------------------------------
       
   762 // CVtUiVideoControlBase::LayoutRemoteVideo
       
   763 // ---------------------------------------------------------------------------
       
   764 //
       
   765 void CVtUiVideoControlBase:: LayoutRemoteVideo()
       
   766     {
       
   767     __VTPRINTENTER( "VidCtrlBase.LayoutRemoteVideo" )
       
   768     __VTPRINTEXIT( "VidCtrlBase.LayoutRemoteVideo" )
       
   769     }
       
   770 
       
   771 // ---------------------------------------------------------------------------
       
   772 // CVtUiVideoControlBase::RemoteVideoControl
       
   773 // ---------------------------------------------------------------------------
       
   774 //
       
   775 CCoeControl * CVtUiVideoControlBase::RemoteVideoControl()
       
   776     {
       
   777     __VTPRINTENTER( "VidCtrlBase.RemoteVideoControl" )
       
   778     __VTPRINTEXIT( "VidCtrlBase.RemoteVideoControl" )
       
   779     return iRemoteVideoControl;
       
   780         
       
   781     }