phoneuis/BubbleManager/bmcustomization/src/telbubbleanim.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Default animation implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <AknBitmapAnimation.h>  // Animation definition
       
    19 #include <eikimage.h>
       
    20 
       
    21 #include "telbubbleanim.h"
       
    22 
       
    23 // ======== LOCAL FUNCTIONS ========
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CBubbleAnim::NewL
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C CTelBubbleAnim* CTelBubbleAnim::NewL( TInt aFrameInterval )
       
    30     {
       
    31     CTelBubbleAnim* self = new( ELeave )CTelBubbleAnim();
       
    32     CleanupStack::PushL( self );
       
    33     self->ConstructL( aFrameInterval );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CTelBubbleAnim::~CTelBubbleAnim
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CTelBubbleAnim::~CTelBubbleAnim()
       
    43     {
       
    44     delete iAnimation;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CTelBubbleAnim::StartAnimation
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C void CTelBubbleAnim::StartAnimationL()
       
    52     {
       
    53     iAnimation->StartAnimationL();
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CTelBubbleAnim::StopAnimation
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 EXPORT_C void CTelBubbleAnim::StopAnimation()
       
    61     {
       
    62     iAnimation->CancelAnimation();
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CTelBubbleAnim::AddFrameToAnimationLD
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C void CTelBubbleAnim::AddFrameToAnimationLD( CEikImage* aFrame ) const
       
    70     {
       
    71     CleanupStack::PushL( aFrame );
       
    72 
       
    73     CBitmapFrameData* frame = CBitmapFrameData::NewL(
       
    74         MUTABLE_CAST( CFbsBitmap*, aFrame->Bitmap() ),
       
    75         MUTABLE_CAST( CFbsBitmap*, aFrame->Mask() ) );
       
    76     aFrame->SetPictureOwnedExternally( ETrue );
       
    77     CleanupStack::PushL( frame );
       
    78     
       
    79     frame->SetInterval( KErrNotFound );
       
    80     frame->SetBitmapsOwnedExternally( EFalse );
       
    81     iAnimation->BitmapAnimData()->AppendFrameL( frame ); // Takes ownership
       
    82 
       
    83     CleanupStack::Pop( frame );
       
    84     CleanupStack::PopAndDestroy( aFrame );
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CTelBubbleAnim::AddFrameToAnimationL
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void CTelBubbleAnim::AddFrameToAnimationL( CEikImage& aFrame ) const
       
    92     {
       
    93     CBitmapFrameData* frame = CBitmapFrameData::NewL(
       
    94         MUTABLE_CAST( CFbsBitmap*, aFrame.Bitmap() ),
       
    95         MUTABLE_CAST( CFbsBitmap*, aFrame.Mask() ) );
       
    96     CleanupStack::PushL( frame );
       
    97     
       
    98     frame->SetInterval( KErrNotFound );
       
    99     frame->SetBitmapsOwnedExternally( ETrue );
       
   100     iAnimation->BitmapAnimData()->AppendFrameL( frame ); // Takes ownership
       
   101 
       
   102     CleanupStack::Pop( frame );
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CTelBubbleAnim::Reset
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C void CTelBubbleAnim::Reset() const
       
   110     {
       
   111     iAnimation->BitmapAnimData()->ResetFrameArray();
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CTelBubbleAnim::CountComponentControls
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 EXPORT_C TInt CTelBubbleAnim::CountComponentControls() const
       
   119     {
       
   120     // do not return animation here!
       
   121     return 0;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CTelBubbleAnim::Reset
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 EXPORT_C void CTelBubbleAnim::SetContainerWindowL( const CCoeControl& aContainer )
       
   129     {
       
   130     CCoeControl::SetContainerWindowL( aContainer );
       
   131 
       
   132     iAnimation->SetContainerWindowL( aContainer );
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CTelBubbleAnim::Reset
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C void CTelBubbleAnim::SizeChanged()
       
   140     {
       
   141     CCoeControl::SizeChanged();
       
   142     
       
   143     iAnimation->SetRect( Rect() );
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CTelBubbleAnim::Draw
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 EXPORT_C void CTelBubbleAnim::Draw( const TRect& /*aRect*/ ) const
       
   151     {
       
   152     // drawing is done in iAnimation
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // CTelBubbleAnim::MakeVisible
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C void CTelBubbleAnim::MakeVisible( TBool aVisible )
       
   160     {
       
   161     CCoeControl::MakeVisible( aVisible );
       
   162     iAnimation->MakeVisible( aVisible );
       
   163     
       
   164     if( !aVisible )
       
   165         {
       
   166         StopAnimation();
       
   167         }
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // CTelBubbleAnim::ConstructL
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C void CTelBubbleAnim::ConstructL( TInt aFrameInterval )
       
   175     {
       
   176     iAnimation = CAknBitmapAnimation::NewL();
       
   177 
       
   178     iAnimation->MakeVisible( EFalse );
       
   179     iAnimation->SetContainerWindowL( *this );
       
   180     iAnimation->ActivateL();
       
   181 
       
   182     CBitmapAnimClientData* animData = iAnimation->BitmapAnimData();
       
   183     animData->SetPlayMode( CBitmapAnimClientData::ECycle );
       
   184     animData->SetFrameInterval( aFrameInterval );
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CTelBubbleAnim::CTelBubbleAnim
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C CTelBubbleAnim::CTelBubbleAnim()
       
   192     {
       
   193     }
       
   194 
       
   195 // end of file
       
   196