messagingappbase/msgeditor/mediacontrolsrc/MsgMediaControl.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:  
       
    15 *       Message Editor Base media control.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "MsgMediaControl.h"
       
    23 
       
    24 #include <avkon.hrh>
       
    25 #include <AknsConstants.h>                  // KAkn*
       
    26 #include <data_caging_path_literals.hrh>    // KDC_APP_BITMAP_DIR
       
    27 #include <AknUtils.h>                       // AknsUtils
       
    28 #include <AknsDrawUtils.h>                  // AknsDrawUtils
       
    29 #include <AknBitmapAnimation.h>
       
    30 
       
    31 #include <MsgEditorCommon.h>
       
    32 
       
    33 #ifdef RD_TACTILE_FEEDBACK
       
    34 #include <touchfeedback.h>
       
    35 #endif 
       
    36 
       
    37 #include "MsgIconControl.h"
       
    38 #include "MsgFrameControl.h"
       
    39 
       
    40 // ==========================================================
       
    41 
       
    42 // EXTERNAL DATA STRUCTURES
       
    43 
       
    44 // EXTERNAL FUNCTION PROTOTYPES
       
    45 
       
    46 // CONSTANTS
       
    47 
       
    48 // MACROS
       
    49 
       
    50 // LOCAL CONSTANTS AND MACROS
       
    51 const TInt KObserverArrayGranularity = 2;
       
    52 
       
    53 // MODULE DATA STRUCTURES
       
    54 
       
    55 // LOCAL FUNCTION PROTOTYPES
       
    56 
       
    57 // ================= MEMBER FUNCTIONS =======================
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CMsgMediaControl::CMsgMediaControl
       
    61 //
       
    62 // Constructor.
       
    63 // ---------------------------------------------------------
       
    64 //
       
    65 CMsgMediaControl::CMsgMediaControl( MMsgBaseControlObserver& aBaseControlObserver,
       
    66                                     TMsgControlId aMediaControlId,
       
    67                                     TMsgControlType aMediaControlType )
       
    68     :
       
    69     CMsgBaseControl( aBaseControlObserver ),
       
    70     iState( EMsgAsyncControlStateIdle )
       
    71     {
       
    72     iBaseLine = MsgEditorCommons::MsgBaseLineDelta();
       
    73     iUniqueContentId = ContentAccess::KDefaultContentObject();
       
    74     
       
    75     iControlId = aMediaControlId;
       
    76     iControlType = aMediaControlType;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CMsgMediaControl::BaseConstructL
       
    81 //
       
    82 // Should be called from derived class
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 void CMsgMediaControl::BaseConstructL( const CCoeControl& aParent, MMsgAsyncControlObserver* aObserver )
       
    86     {
       
    87     SetContainerWindowL( aParent );
       
    88     
       
    89     iObservers = new( ELeave ) CArrayPtrFlat<MMsgAsyncControlObserver>( KObserverArrayGranularity );
       
    90     
       
    91 #ifdef RD_SCALABLE_UI_V2
       
    92     User::LeaveIfError( SetHitTest( this ) );
       
    93 #endif // RD_SCALABLE_UI_V2
       
    94     
       
    95     if ( aObserver )
       
    96         {
       
    97         iObservers->AppendL( aObserver );
       
    98         }
       
    99     
       
   100     iIconControl = CMsgIconControl::NewL( *this );
       
   101     iFrame = CMsgFrameControl::NewL( *this );
       
   102     
       
   103     iControlModeFlags |= EMsgControlModeForceFocusStop;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CMsgMediaControl::~CMsgMediaControl
       
   108 //
       
   109 // Destructor
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 CMsgMediaControl::~CMsgMediaControl()
       
   113     {
       
   114     delete iObservers;
       
   115     delete iIconControl;
       
   116     delete iFrame;
       
   117     delete iAnimation;
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------
       
   121 // CMsgMediaControl::State
       
   122 // ---------------------------------------------------------
       
   123 //
       
   124 TMsgAsyncControlState CMsgMediaControl::State() const
       
   125     {
       
   126     return iState;
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // CMsgMediaControl::Error
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 TInt CMsgMediaControl::Error() const
       
   134     {
       
   135     return iError;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // CMsgMediaControl::AddObserverL
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CMsgMediaControl::AddObserverL( MMsgAsyncControlObserver& aObserver )
       
   143     {
       
   144     iObservers->AppendL( &aObserver );
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------
       
   148 // CMsgMediaControl::RemoveObserver
       
   149 // ---------------------------------------------------------
       
   150 //        
       
   151 void CMsgMediaControl::RemoveObserver( MMsgAsyncControlObserver& aObserver )
       
   152     {
       
   153     for ( TInt current = 0; current < iObservers->Count(); current++ )
       
   154         {
       
   155         if ( iObservers->At( current ) == &aObserver )
       
   156             {
       
   157             iObservers->Delete( current );
       
   158             break;
       
   159             }
       
   160         }
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CMsgMediaControl::FocusChanged
       
   165 //
       
   166 // Should be called from derived class
       
   167 // ---------------------------------------------------------
       
   168 //
       
   169 void CMsgMediaControl::FocusChanged( TDrawNow aDrawNow )
       
   170     {   
       
   171     DoUpdateFocus( aDrawNow );
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------
       
   175 // CMsgMediaControl::CurrentLineRect
       
   176 //
       
   177 // Returns the current control rect
       
   178 // ---------------------------------------------------------
       
   179 //
       
   180 TRect CMsgMediaControl::CurrentLineRect()
       
   181     {
       
   182     return Rect();
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------
       
   186 // CMsgMediaControl::ClipboardL
       
   187 //
       
   188 // Handles clipboard operation.
       
   189 // ---------------------------------------------------------
       
   190 //
       
   191 void CMsgMediaControl::ClipboardL(TMsgClipboardFunc /*aFunc*/ )
       
   192     {
       
   193     User::Leave( KErrNotSupported ); // Media controls does not support clipboard by default
       
   194     }
       
   195 
       
   196 // ---------------------------------------------------------
       
   197 // CMsgMediaControl::EditL
       
   198 //
       
   199 // Handles editing operation.
       
   200 // ---------------------------------------------------------
       
   201 //
       
   202 void CMsgMediaControl::EditL( TMsgEditFunc /*aFunc*/ )
       
   203     {
       
   204     User::Leave( KErrNotSupported ); // Media control is not editable by default
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------
       
   208 // CMsgMediaControl::IsFocusChangePossible
       
   209 //
       
   210 // Checks if the focus change up or down is possible and returns ETrue if it is.
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 TBool CMsgMediaControl::IsFocusChangePossible( TMsgFocusDirection /*aDirection*/ ) const
       
   214     {
       
   215     return ETrue;
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // CMsgMediaControl::IsCursorLocation
       
   220 //
       
   221 // Checks if the cursor location is on the topmost or downmost position and
       
   222 // returns ETrue if it is.
       
   223 // ---------------------------------------------------------
       
   224 //
       
   225 TBool CMsgMediaControl::IsCursorLocation( TMsgCursorLocation /*aLocation*/ ) const
       
   226     {
       
   227     return ETrue;
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // CMsgMediaControl::EditPermission
       
   232 //
       
   233 // Returns edit permission flags.
       
   234 // ---------------------------------------------------------
       
   235 //
       
   236 TUint32 CMsgMediaControl::EditPermission() const
       
   237     {
       
   238     return EMsgEditNone;
       
   239     }
       
   240 
       
   241 // ---------------------------------------------------------
       
   242 // CMsgMediaControl::PrepareForReadOnly
       
   243 //
       
   244 // Prepares for read only or non read only state.
       
   245 // ---------------------------------------------------------
       
   246 //
       
   247 void CMsgMediaControl::PrepareForReadOnly( TBool /*aReadOnly*/ )
       
   248     {
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------
       
   252 // CMmsImageControl::CountComponentControls
       
   253 //
       
   254 // Return count of controls be included in this component.
       
   255 // ---------------------------------------------------------
       
   256 //
       
   257 TInt CMsgMediaControl::CountComponentControls() const
       
   258     {
       
   259     TInt result( 2 );
       
   260     if ( iAnimation )
       
   261         {
       
   262         result++;
       
   263         }
       
   264     return result;
       
   265     }
       
   266 
       
   267 // ---------------------------------------------------------
       
   268 // CMmsImageControl::ComponentControl
       
   269 //
       
   270 // Return pointer to component in question.
       
   271 // Note! Image and Icon cannot exist at a same time.
       
   272 // ---------------------------------------------------------
       
   273 //
       
   274 CCoeControl* CMsgMediaControl::ComponentControl( TInt aIndex ) const
       
   275     {
       
   276     CCoeControl* result = NULL;
       
   277     switch ( aIndex )
       
   278         {
       
   279         case 0:
       
   280             {
       
   281             result = iFrame;
       
   282             break;
       
   283             }
       
   284         case 1:
       
   285             {
       
   286             result = iIconControl;
       
   287             break;
       
   288             }
       
   289         case 2:
       
   290             {
       
   291             result = iAnimation;
       
   292             break;
       
   293             }
       
   294         default:
       
   295             {
       
   296             break;
       
   297             }
       
   298         }
       
   299         
       
   300     return result;
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------
       
   304 // CMsgMediaControl::LoadIconL
       
   305 // ---------------------------------------------------------
       
   306 //
       
   307 EXPORT_C TBool CMsgMediaControl::LoadIconL( const TDesC& aFileName,                                   
       
   308                                          const TAknsItemID& aId,
       
   309                                          const TInt aFileBitmapId,
       
   310                                          const TInt aFileMaskId )
       
   311     {    
       
   312     if ( aFileBitmapId != KErrNotFound )
       
   313         {
       
   314         iIconControl->LoadIconL( aId,
       
   315                                  aFileName,
       
   316                                  aFileBitmapId,
       
   317                                  aFileMaskId );
       
   318         return ETrue;
       
   319         }    
       
   320     return EFalse;
       
   321     }
       
   322 
       
   323 // ---------------------------------------------------------
       
   324 // CMsgMediaControl::SetIconSizeL
       
   325 // ---------------------------------------------------------
       
   326 //
       
   327 EXPORT_C void CMsgMediaControl::SetIconSizeL( const TSize& aNewSize )
       
   328     {
       
   329     if ( aNewSize != iIconControl->Size() )
       
   330         {
       
   331         iIconControl->SetBitmapSizeL( aNewSize );
       
   332         iFrame->SetImageSize( aNewSize );
       
   333         
       
   334         SetComponentControlExtents();
       
   335         }
       
   336     }
       
   337 
       
   338 // ---------------------------------------------------------
       
   339 // CMsgMediaControl::SetIconVisible
       
   340 // ---------------------------------------------------------
       
   341 //
       
   342 EXPORT_C void CMsgMediaControl::SetIconVisible( TBool aVisibility )
       
   343     {
       
   344     iIconControl->MakeVisible( aVisibility );
       
   345     
       
   346     if ( iAnimation )
       
   347         {
       
   348         iAnimation->MakeVisible( EFalse );
       
   349         iAnimation->CancelAnimation();
       
   350         }
       
   351     
       
   352     DoUpdateFocus( EDrawNow );
       
   353     }
       
   354 
       
   355 // ---------------------------------------------------------
       
   356 // CMsgMediaControl::SetAnimationL
       
   357 // ---------------------------------------------------------
       
   358 //
       
   359 EXPORT_C void CMsgMediaControl::SetAnimationL( CAknBitmapAnimation* aAnimationControl )
       
   360     {   
       
   361     ReleaseAnimation();
       
   362     
       
   363     iAnimation = aAnimationControl;
       
   364     
       
   365     if ( iAnimation )
       
   366         {
       
   367         iAnimation->SetContainerWindowL( *this );
       
   368         iAnimation->MakeVisible( EFalse );
       
   369         iAnimation->ActivateL();
       
   370         }
       
   371     }
       
   372 
       
   373 // ---------------------------------------------------------
       
   374 // CMsgMediaControl::SetAnimationSizeL
       
   375 // ---------------------------------------------------------
       
   376 //
       
   377 EXPORT_C void CMsgMediaControl::SetAnimationSizeL( const TSize& aNewSize )
       
   378     {
       
   379     if ( iAnimation &&
       
   380          aNewSize != iAnimation->Size() )
       
   381         {
       
   382         iFrame->SetImageSize( aNewSize );
       
   383         
       
   384         TPoint center = Rect().Center();
       
   385         iAnimation->SetExtent( TPoint( center.iX - aNewSize.iWidth / 2,
       
   386                                        center.iY - aNewSize.iHeight / 2 ),
       
   387                                aNewSize );
       
   388         SetAnimationBackGroundFrameL();
       
   389         }
       
   390     }
       
   391 
       
   392 // ---------------------------------------------------------
       
   393 // CMsgMediaControl::SetAnimationVisibleL
       
   394 // ---------------------------------------------------------
       
   395 //
       
   396 EXPORT_C void CMsgMediaControl::SetAnimationVisibleL( TBool aVisibility )
       
   397     {
       
   398     if ( iAnimation )
       
   399         {
       
   400         iIconControl->MakeVisible( !aVisibility );
       
   401         iAnimation->MakeVisible( aVisibility );
       
   402         
       
   403         if ( aVisibility && DrawableWindow() )
       
   404             {
       
   405             // Rewind to beginning. Note! Cannot start animation until window is set.
       
   406             iAnimation->SetFrameIndexL( 0 );
       
   407             
       
   408             // Set the correct animation frame background
       
   409             SetAnimationBackGroundFrameL();
       
   410             }
       
   411         else
       
   412             {
       
   413             iAnimation->CancelAnimation();
       
   414             }
       
   415         }
       
   416     }
       
   417 
       
   418 // ---------------------------------------------------------
       
   419 // CMsgMediaControl::IconBitmapId
       
   420 // ---------------------------------------------------------
       
   421 //
       
   422 EXPORT_C TInt CMsgMediaControl::IconBitmapId() const
       
   423     {    
       
   424     return iIconControl->IconBitmapId();
       
   425     }
       
   426 
       
   427 // ---------------------------------------------------------
       
   428 // CMsgMediaControl::ReleaseAnimation
       
   429 // ---------------------------------------------------------
       
   430 //
       
   431 EXPORT_C void CMsgMediaControl::ReleaseAnimation()
       
   432     {
       
   433     if(iAnimation)
       
   434         {
       
   435         iAnimation->MakeVisible( EFalse );
       
   436         delete iAnimation;    
       
   437         iAnimation = NULL;
       
   438         }        
       
   439     }
       
   440 
       
   441 // ---------------------------------------------------------
       
   442 // CMsgMediaControl::SizeChanged
       
   443 // ---------------------------------------------------------
       
   444 //
       
   445 void CMsgMediaControl::SizeChanged()
       
   446     {
       
   447     SetComponentControlExtents();
       
   448     
       
   449     iFrame->SetRect( Rect() );
       
   450     }
       
   451 
       
   452 // ---------------------------------------------------------
       
   453 // CMsgMediaControl::Draw
       
   454 //
       
   455 // Draws basic skin background to the given area.
       
   456 // ---------------------------------------------------------
       
   457 //
       
   458 void CMsgMediaControl::Draw( const TRect& aRect ) const
       
   459     {
       
   460     CWindowGc& gc = SystemGc();
       
   461     
       
   462     if ( !AknsDrawUtils::Background( AknsUtils::SkinInstance(), 
       
   463                                      AknsDrawUtils::ControlContext( this ), 
       
   464                                      this, 
       
   465                                      gc, 
       
   466                                      aRect ) )
       
   467         {
       
   468         gc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
   469         gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   470 		gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   471     	gc.DrawRect( aRect );
       
   472         }
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------
       
   476 // CMsgMediaControl::HandleResourceChange
       
   477 // ---------------------------------------------------------
       
   478 //
       
   479 void CMsgMediaControl::HandleResourceChange( TInt aType )
       
   480     {
       
   481     for ( TInt current = 0; current < iObservers->Count(); current++ )
       
   482         {
       
   483         iObservers->At( current )->MsgAsyncControlResourceChanged( *this, aType );
       
   484         }
       
   485     
       
   486     CMsgBaseControl::HandleResourceChange( aType ); 
       
   487     
       
   488     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   489         {
       
   490         iBaseLine = MsgEditorCommons::MsgBaseLineDelta();
       
   491         }
       
   492     }
       
   493     
       
   494 // ---------------------------------------------------------
       
   495 // CMsgMediaControl::HandlePointerEventL
       
   496 // ---------------------------------------------------------
       
   497 //
       
   498 #ifdef RD_SCALABLE_UI_V2
       
   499 void CMsgMediaControl::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   500     {                    
       
   501 #ifdef RD_TACTILE_FEEDBACK 
       
   502     if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
   503         {     
       
   504         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   505         if ( feedback )
       
   506             {
       
   507             feedback->InstantFeedback( this, ETouchFeedbackBasic );
       
   508             }                   
       
   509         }
       
   510 #endif 
       
   511     }
       
   512 #else
       
   513 void CMsgMediaControl::HandlePointerEventL( const TPointerEvent& /*aPointerEvent*/ )
       
   514     {
       
   515     }
       
   516 #endif // RD_SCALABLE_UI_V2
       
   517 
       
   518 // ---------------------------------------------------------
       
   519 // CMsgMediaControl::NotifyViewEvent
       
   520 // ---------------------------------------------------------
       
   521 //
       
   522 void CMsgMediaControl::NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam)
       
   523     {   
       
   524     CMsgBaseControl::NotifyViewEvent( aEvent, aParam );
       
   525     }
       
   526 
       
   527 // ---------------------------------------------------------
       
   528 // CMsgMediaControl::DoUpdateFocus
       
   529 //
       
   530 // Updates the focus (i.e. set frame control visible/invisible).
       
   531 // Performs immediate redrawing of frame control if that 
       
   532 // is requested and frame control state is changed. Otherwise
       
   533 // normal deferred drawing is done. This is activated at 
       
   534 // CCoeControl::MakeVisible if needed.
       
   535 // ---------------------------------------------------------
       
   536 //
       
   537 void CMsgMediaControl::DoUpdateFocus( TDrawNow aDrawNow )
       
   538     {       
       
   539     TBool oldVisibility( iFrame->IsVisible() );
       
   540     
       
   541     if ( IsFocused() && VisiblePlaceholder() )
       
   542         {
       
   543         iFrame->MakeVisible( ETrue );
       
   544         }
       
   545     else 
       
   546         {
       
   547         iFrame->MakeVisible( EFalse );
       
   548         }
       
   549         
       
   550     if ( aDrawNow == EDrawNow &&
       
   551          iFrame->IsVisible() != oldVisibility )
       
   552         {
       
   553         DrawNow();
       
   554         }
       
   555     }
       
   556 
       
   557 // ---------------------------------------------------------
       
   558 // CMsgMediaControl::HitRegionContains
       
   559 // 
       
   560 // Evaluates whether control was "hit" by the pointer event.
       
   561 // Basic media control is hit only when pointer event is received
       
   562 // for icon area.
       
   563 // 
       
   564 // Note! CONE will do final verification if control is really hit so
       
   565 //       not need to do it here.
       
   566 // ---------------------------------------------------------
       
   567 //
       
   568 #ifdef RD_SCALABLE_UI_V2
       
   569 TBool CMsgMediaControl::HitRegionContains( const TPoint& aPoint, 
       
   570                                            const CCoeControl& /*aControl*/ ) const
       
   571     {
       
   572     TBool result( EFalse );
       
   573     
       
   574     CCoeControl* visiblePlaceholder = VisiblePlaceholder();
       
   575     
       
   576     if ( visiblePlaceholder )
       
   577         {
       
   578         result = visiblePlaceholder->Rect().Contains( aPoint );
       
   579         }
       
   580         
       
   581     return result;
       
   582     }
       
   583 #else
       
   584 TBool CMsgMediaControl::HitRegionContains( const TPoint& /*aPoint*/, 
       
   585                                            const CCoeControl& /*aControl*/ ) const
       
   586     {
       
   587     return EFalse;
       
   588     }
       
   589 #endif // RD_SCALABLE_UI_V2
       
   590 
       
   591 // ---------------------------------------------------------
       
   592 // CMsgMediaControl::SetComponentControlExtents
       
   593 //
       
   594 // Updates component controls position & size. 
       
   595 // Icon & animation controls are centered to the control area.
       
   596 // ---------------------------------------------------------
       
   597 //
       
   598 void CMsgMediaControl::SetComponentControlExtents()
       
   599     {
       
   600     //Center of the rect where we're drawing
       
   601     TPoint center = Rect().Center();
       
   602     
       
   603     //Size of the icon
       
   604     TSize size = iIconControl->BitmapSize();
       
   605     
       
   606     //Centered top left corner of the whole icon
       
   607     TPoint tlc = TPoint( center.iX - size.iWidth / 2,
       
   608                          center.iY - size.iHeight / 2 );
       
   609     
       
   610     iIconControl->SetExtent( tlc, size );
       
   611     
       
   612     if ( iAnimation )
       
   613         {
       
   614         TPoint newPosition( center.iX - iAnimation->Size().iWidth / 2,
       
   615                             center.iY - iAnimation->Size().iHeight / 2 );
       
   616         
       
   617         if ( newPosition != iAnimation->Position() )
       
   618             {
       
   619             iAnimation->SetPosition( newPosition );
       
   620                                    
       
   621             TRAP_IGNORE( SetAnimationBackGroundFrameL() );
       
   622             }
       
   623         }
       
   624     }
       
   625 
       
   626 // ---------------------------------------------------------
       
   627 // CMsgMediaControl::SetAnimationBackGroundFrameL
       
   628 //
       
   629 // Sets background bitmap for animation frame. This needs to be
       
   630 // updated to correct skin background depending current control position.
       
   631 // ---------------------------------------------------------
       
   632 //
       
   633 void CMsgMediaControl::SetAnimationBackGroundFrameL()
       
   634     {
       
   635     if ( AnimationVisible() )
       
   636         {
       
   637         const TDisplayMode displayMode( iCoeEnv->ScreenDevice()->DisplayMode() );
       
   638         
       
   639         CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap;
       
   640         CleanupStack::PushL( bitmap );
       
   641         
       
   642         User::LeaveIfError( bitmap->Create( iAnimation->Size(), displayMode ) );
       
   643         
       
   644         CFbsBitmapDevice* doubleBufferDev = CFbsBitmapDevice::NewL( bitmap );
       
   645         CleanupStack::PushL( doubleBufferDev );    
       
   646         
       
   647         CFbsBitGc* doubleBufferGc = NULL;
       
   648         User::LeaveIfError( doubleBufferDev->CreateContext( doubleBufferGc ) );    
       
   649         CleanupStack::PushL( doubleBufferGc );    
       
   650         
       
   651         if ( AknsDrawUtils::DrawBackground( AknsUtils::SkinInstance(), 
       
   652                                             AknsDrawUtils::ControlContext( this ), 
       
   653                                             this, 
       
   654                                             *doubleBufferGc,
       
   655                                             TPoint(), 
       
   656                                             iAnimation->Rect(), 
       
   657                                             KAknsDrawParamDefault ) )
       
   658             {
       
   659             CleanupStack::PopAndDestroy( 2 ); // doubleBufferGc, doubleBufferDev
       
   660             
       
   661             CBitmapFrameData* data = CBitmapFrameData::NewL();
       
   662             data->SetBitmapsOwnedExternally( EFalse );
       
   663             data->SetBitmap( bitmap );
       
   664         
       
   665             // Set background frame to animation
       
   666             iAnimation->BitmapAnimData()->SetBackgroundFrame( data ); // gets ownership
       
   667             CleanupStack::Pop( bitmap );
       
   668             
       
   669             // Make the change effective
       
   670             iAnimation->StartAnimationL();
       
   671             }
       
   672         else
       
   673             {
       
   674             CleanupStack::PopAndDestroy( 3 ); // doubleBufferGc, doubleBufferDev, bitmap
       
   675             }
       
   676         }                
       
   677     
       
   678     }
       
   679 
       
   680 // ---------------------------------------------------------
       
   681 // CMsgMediaControl::AnimationVisible
       
   682 // ---------------------------------------------------------
       
   683 //
       
   684 TBool CMsgMediaControl::AnimationVisible() const
       
   685     {
       
   686     TBool result( EFalse );
       
   687     if ( iAnimation && iAnimation->IsVisible() )
       
   688         {
       
   689         result = ETrue;
       
   690         }
       
   691         
       
   692     return result;
       
   693     }
       
   694 
       
   695 // ---------------------------------------------------------
       
   696 // CMsgMediaControl::VisiblePlaceholder
       
   697 // ---------------------------------------------------------
       
   698 //
       
   699 CCoeControl* CMsgMediaControl::VisiblePlaceholder() const
       
   700     {
       
   701     CCoeControl* result = NULL;
       
   702     if ( iIconControl->IsVisible() )
       
   703         {
       
   704         result = iIconControl;
       
   705         }
       
   706     else if ( AnimationVisible() )
       
   707         {
       
   708         result = iAnimation;
       
   709         }
       
   710         
       
   711     return result;
       
   712     }
       
   713 
       
   714 // ---------------------------------------------------------
       
   715 // ResetIconId
       
   716 // ---------------------------------------------------------
       
   717 //        
       
   718 void CMsgMediaControl::ResetIconId()
       
   719     {
       
   720     iIconControl->SetIcon( NULL );
       
   721     iFrame->ResetFrameSize();
       
   722     }
       
   723 
       
   724 //  End of File