skins/AknSkins/alsrc/AknsAlShared.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Utility class for storing animation value and binding the animation
       
    15 *                value to timing model.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "AknsAlShared.h"
       
    22 
       
    23 #include "AknsRlEffectPlugin.h"
       
    24 #include "AknsAlEffectParamContainer.h"
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 /**
       
    28 * Utility class for binding animation value to name.
       
    29 */
       
    30 NONSHARABLE_CLASS( CAknsAlNamedReference ): public CBase
       
    31     {
       
    32     protected:
       
    33         CAknsAlNamedReference();
       
    34         void ConstructL( const TDesC& aName,
       
    35                          const MAknsAlAnimationValue* aValue );
       
    36 
       
    37     public:
       
    38         ~CAknsAlNamedReference();
       
    39         static CAknsAlNamedReference* NewL(  const TDesC& aName,
       
    40                                              const MAknsAlAnimationValue* aValue );
       
    41         inline void FillData( TAknsRlParameterData& aData ) const;
       
    42 
       
    43     private:
       
    44         HBufC* iName; // Owned
       
    45         const MAknsAlAnimationValue* iAnimationValue; // Referenced only
       
    46     };
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CAknsAlNamedReference::CAknsAlNamedReference
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CAknsAlNamedReference::CAknsAlNamedReference()
       
    53     {
       
    54     // Derived from CBase -> members are zeroed
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CAknsAlNamedReference::ConstructL
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CAknsAlNamedReference::ConstructL(
       
    62     const TDesC& aName, const MAknsAlAnimationValue* aValue )
       
    63     {
       
    64     if( NULL == aValue )
       
    65         User::Leave( KErrArgument );
       
    66 
       
    67     iAnimationValue = aValue;
       
    68     iName           = aName.AllocL();
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CAknsAlNamedReference::~CAknsAlNamedReference
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 CAknsAlNamedReference::~CAknsAlNamedReference()
       
    76     {
       
    77     delete iName;
       
    78     iAnimationValue = NULL; // Removes lint nag
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CAknsAlNamedReference::NewL
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CAknsAlNamedReference* CAknsAlNamedReference::NewL(
       
    86     const TDesC& aName, const MAknsAlAnimationValue* aValue )
       
    87     {
       
    88     CAknsAlNamedReference* self = new(ELeave) CAknsAlNamedReference();
       
    89     CleanupStack::PushL( self );
       
    90     self->ConstructL( aName, aValue);
       
    91     CleanupStack::Pop( self );
       
    92     return self;
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CAknsAlNamedReference::FillData
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 inline void CAknsAlNamedReference::FillData( TAknsRlParameterData& aData ) const
       
   100     {
       
   101     iAnimationValue->FillData( aData );
       
   102     aData.iName   = iName;
       
   103     }
       
   104 
       
   105 // ============================ MEMBER FUNCTIONS ===============================
       
   106 /**
       
   107 * Utility class for storing named references and providing a parameter iterator
       
   108 * access to them.
       
   109 */
       
   110 NONSHARABLE_CLASS( CAknsAlNamedReferenceContainer ):
       
   111     public CBase, public MAknsRlParameterIterator
       
   112     {
       
   113     public:
       
   114         CAknsAlNamedReferenceContainer();
       
   115         ~CAknsAlNamedReferenceContainer();
       
   116         void AddNamedReferenceL( const TDesC& aName,
       
   117                                  const MAknsAlAnimationValue* aValue );
       
   118         void Begin();
       
   119 
       
   120     public: // Implementation of MAknsRlParameterIterator
       
   121         TBool HasNext();
       
   122         const TAknsRlParameterData* NextL();
       
   123 
       
   124     private:
       
   125         TAknsRlParameterData iIteratorData;
       
   126         // Stores the time bound parameters, owned
       
   127         RPointerArray<CAknsAlNamedReference> iNamedRefs;
       
   128         TInt iIteratorIndex;
       
   129     };
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CAknsAlNamedReferenceContainer::CAknsAlNamedReferenceContainer
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 CAknsAlNamedReferenceContainer::CAknsAlNamedReferenceContainer()
       
   136     {
       
   137     // Derived from CBase -> members are zeroed
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CAknsAlNamedReferenceContainer::~CAknsAlNamedReferenceContainer
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 CAknsAlNamedReferenceContainer::~CAknsAlNamedReferenceContainer()
       
   145     {
       
   146     iNamedRefs.ResetAndDestroy(); //lint !e1551 No exception thrown
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CAknsAlNamedReferenceContainer::AddNamedReferenceL
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 void CAknsAlNamedReferenceContainer::AddNamedReferenceL(
       
   154     const TDesC& aName, const MAknsAlAnimationValue* aValue )
       
   155     {
       
   156     CAknsAlNamedReference* ref = CAknsAlNamedReference::NewL( aName, aValue );
       
   157     CleanupStack::PushL( ref );
       
   158     User::LeaveIfError( iNamedRefs.Append( ref ) );
       
   159     CleanupStack::Pop( ref );
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CAknsAlNamedReferenceContainer::Begin
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CAknsAlNamedReferenceContainer::Begin()
       
   167     {
       
   168     iIteratorIndex = 0;
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CAknsAlNamedReferenceContainer::HasNext
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 TBool CAknsAlNamedReferenceContainer::HasNext()
       
   176     {
       
   177     if( iIteratorIndex < iNamedRefs.Count() )
       
   178         return ETrue;
       
   179 
       
   180     return EFalse;
       
   181     }
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CAknsAlNamedReferenceContainer::NextL
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 const TAknsRlParameterData* CAknsAlNamedReferenceContainer::NextL()
       
   188     {
       
   189     if( iNamedRefs.Count() <= iIteratorIndex )
       
   190         User::Leave( KErrOverflow );
       
   191 
       
   192     CAknsAlNamedReference* ref = iNamedRefs[iIteratorIndex];
       
   193     ref->FillData( iIteratorData );
       
   194 
       
   195     iIteratorIndex++;
       
   196 
       
   197     return &iIteratorData;
       
   198     }
       
   199 
       
   200 // ============================ MEMBER FUNCTIONS ===============================
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CAknsAlAnimationValueContainer::CAknsAlAnimationValueContainer
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 CAknsAlAnimationValueContainer::CAknsAlAnimationValueContainer()
       
   207     {
       
   208     // Derived from CBase -> members are zeroed
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CAknsAlAnimationValueContainer::ConstructL
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CAknsAlAnimationValueContainer::ConstructL( MAknsAlAnimationValue* aValue,
       
   216                  const MAknsAlTimingModel* aModel )
       
   217     {
       
   218     if( NULL == aValue || NULL == aModel )
       
   219         User::Leave( KErrArgument );
       
   220 
       
   221     iAnimationValue = aValue;
       
   222     iTimingModel    = aModel;
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CAknsAlAnimationValueContainer::~CAknsAlAnimationValueContainer
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 CAknsAlAnimationValueContainer::~CAknsAlAnimationValueContainer()
       
   230     {
       
   231     delete iAnimationValue; //lint !e1551 No exception thrown
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CAknsAlAnimationValueContainer::NewL
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 CAknsAlAnimationValueContainer* CAknsAlAnimationValueContainer::NewL(
       
   239     MAknsAlAnimationValue* aValue, const MAknsAlTimingModel* aModel )
       
   240     {
       
   241     CAknsAlAnimationValueContainer* self = new(ELeave) CAknsAlAnimationValueContainer();
       
   242     CleanupStack::PushL( self );
       
   243     self->ConstructL( aValue, aModel );
       
   244     CleanupStack::Pop( self );
       
   245     return self;
       
   246     }
       
   247 
       
   248 // ============================ MEMBER FUNCTIONS ===============================
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CAknsAlAnimationCommand::CAknsAlAnimationCommand
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 CAknsAlAnimationCommand::CAknsAlAnimationCommand()
       
   255     {
       
   256     // Derived from CBase -> members are zeroed
       
   257     }
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 // CAknsAlAnimationCommand::ConstructL
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 void CAknsAlAnimationCommand::ConstructL()
       
   264     {
       
   265     iParamContainer = CAknsAlEffectParamContainer::NewL();
       
   266     iReferenceContainer = new(ELeave) CAknsAlNamedReferenceContainer();
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CAknsAlAnimationCommand::NewL
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 CAknsAlAnimationCommand* CAknsAlAnimationCommand::NewL()
       
   274     {
       
   275     CAknsAlAnimationCommand* self = new(ELeave) CAknsAlAnimationCommand();
       
   276     CleanupStack::PushL( self );
       
   277     self->ConstructL();
       
   278     CleanupStack::Pop( self );
       
   279     return self;
       
   280     }
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 // CAknsAlAnimationCommand::~CAknsAlAnimationCommand
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 CAknsAlAnimationCommand::~CAknsAlAnimationCommand()
       
   287     {
       
   288     delete iPlugin; //lint !e1551 No exception thrown
       
   289     delete iParamContainer; //lint !e1551 No exception thrown
       
   290     delete iReferenceContainer; //lint !e1551 No exception thrown
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CAknsAlAnimationCommand::Effect
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 MAknsRlEffect* CAknsAlAnimationCommand::Effect()
       
   298     {
       
   299     return iPlugin->Effect( KAknsRlEffectPluginInterfaceEffect );
       
   300     }
       
   301 
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // CAknsAlAnimationCommand::AddParameterL
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 void CAknsAlAnimationCommand::AddParameterL( const TAknsRlParameterData& aParam )
       
   308     {
       
   309     iParamContainer->AddParamL( aParam );
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CAknsAlAnimationCommand::AddNamedReferenceL
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 void CAknsAlAnimationCommand::AddNamedReferenceL( const TDesC& aName,
       
   317                          const MAknsAlAnimationValue* aValue )
       
   318     {
       
   319     iReferenceContainer->AddNamedReferenceL( aName, aValue );
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CAknsAlAnimationCommand::SetPlugin
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CAknsAlAnimationCommand::SetPlugin( CAknsRlEffectPlugin* aPlugin )
       
   327     {
       
   328     iPlugin = aPlugin;
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CAknsAlAnimationCommand::SetLayerConfig
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 void CAknsAlAnimationCommand::SetLayerConfig( const TAknsRlRenderOpParam& aConfig )
       
   336     {
       
   337     iLayerConfig = aConfig;
       
   338     }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CAknsAlAnimationCommand::LayerConfig
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 const TAknsRlRenderOpParam& CAknsAlAnimationCommand::LayerConfig() const
       
   345     {
       
   346     return iLayerConfig;
       
   347     }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // CAknsAlAnimationCommand::ParameterIterator
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 MAknsRlParameterIterator* CAknsAlAnimationCommand::ParameterIterator()
       
   354     {
       
   355     iParamContainer->Begin();
       
   356     return iParamContainer;
       
   357     }
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // CAknsAlAnimationCommand::NamedReferenceIterator
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 MAknsRlParameterIterator* CAknsAlAnimationCommand::NamedReferenceIterator()
       
   364     {
       
   365     iReferenceContainer->Begin();
       
   366     return iReferenceContainer;
       
   367     }
       
   368 
       
   369 // End of file.