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