skins/AknSkins/alsrc/AknsAlEffectParamContainer.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Combined container & iterator for storing RL parameters.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "AknsAlEffectParamContainer.h"
       
    21 
       
    22 // ============================ INTERNAL CLASSES ===============================
       
    23 NONSHARABLE_CLASS( CAknsAlParamData ): public CBase
       
    24     {
       
    25     private:
       
    26 
       
    27         CAknsAlParamData()
       
    28             {
       
    29             // Derived from CBase -> members zeroed automatically
       
    30             }
       
    31 
       
    32         void ConstructL( const TAknsRlParameterData& aData )
       
    33             {
       
    34             iName = aData.iName->AllocL();
       
    35             iType = aData.iType;
       
    36 
       
    37             switch( aData.iType )
       
    38                 {
       
    39                 case EAknsRlParameterTypeNumber:
       
    40                     iNumber = aData.iNumber;
       
    41                     break;
       
    42                 case EAknsRlParameterTypeString:
       
    43                     iBuffer = aData.iString->AllocL();
       
    44                     break;
       
    45                 case EAknsRlParameterTypeGraphics:
       
    46                     iBuffer         = aData.iGfx->iFilename->AllocL();
       
    47                     iGfx.iFilename  = iBuffer;
       
    48                     iGfx.iIndex     = aData.iGfx->iIndex;
       
    49                     iGfx.iMaskIndex = aData.iGfx->iMaskIndex;
       
    50                     break;
       
    51                 }
       
    52             }
       
    53 
       
    54     public:
       
    55 
       
    56         static CAknsAlParamData* NewL( const TAknsRlParameterData& aData )
       
    57             {
       
    58             CAknsAlParamData* self = new(ELeave) CAknsAlParamData();
       
    59             CleanupStack::PushL( self );
       
    60             self->ConstructL( aData );
       
    61             CleanupStack::Pop( self );
       
    62             return self;
       
    63             }
       
    64 
       
    65         virtual ~CAknsAlParamData()
       
    66             {
       
    67             delete iName;
       
    68             delete iBuffer;
       
    69             }
       
    70 
       
    71         void FillData( TAknsRlParameterData& aData ) const
       
    72             {
       
    73             aData.iName = iName;
       
    74             aData.iType = iType;
       
    75 
       
    76             switch( iType )
       
    77                 {
       
    78                 case EAknsRlParameterTypeNumber:
       
    79                     aData.iNumber = iNumber;
       
    80                     break;
       
    81                 case EAknsRlParameterTypeString:
       
    82                     aData.iString = iBuffer;
       
    83                     break;
       
    84                 case EAknsRlParameterTypeGraphics:
       
    85                     aData.iGfx = &iGfx;
       
    86                     break;
       
    87                 }
       
    88             }
       
    89 
       
    90     private:
       
    91         HBufC* iName;
       
    92         TAknsRlParameterType iType;
       
    93         HBufC* iBuffer;
       
    94         TInt iNumber;
       
    95         TAknsRlGraphicsParam iGfx;
       
    96     };
       
    97 
       
    98 // ============================ MEMBER FUNCTIONS ===============================
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CAknsAlEffectParamContainer::CAknsAlEffectParamContainer
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 CAknsAlEffectParamContainer::CAknsAlEffectParamContainer()
       
   105     {
       
   106     // Derived from CBase -> members zeroed
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CAknsAlEffectParamContainer::CAknsAlEffectParamContainer
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 CAknsAlEffectParamContainer* CAknsAlEffectParamContainer::NewL()
       
   114     {
       
   115     CAknsAlEffectParamContainer* self = new(ELeave) CAknsAlEffectParamContainer();
       
   116     return self;
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CAknsAlEffectParamContainer::~CAknsAlEffectParamContainer
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 CAknsAlEffectParamContainer::~CAknsAlEffectParamContainer()
       
   124     {
       
   125     // Deletes the referenced parameters
       
   126     iParams.ResetAndDestroy(); //lint !e1551 No exception thrown
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CAknsAlEffectParamContainer::HasNext
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 TBool CAknsAlEffectParamContainer::HasNext()
       
   134     {
       
   135     if( iIteratorIndex < iParams.Count() )
       
   136         return ETrue;
       
   137 
       
   138     return EFalse;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CAknsAlEffectParamContainer::NextL
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 const TAknsRlParameterData* CAknsAlEffectParamContainer::NextL()
       
   146     {
       
   147     if( iParams.Count() <= iIteratorIndex )
       
   148         User::Leave( KErrOverflow );
       
   149 
       
   150     CAknsAlParamData* param = iParams[iIteratorIndex];
       
   151     param->FillData( iIteratorData );
       
   152 
       
   153     iIteratorIndex++;
       
   154 
       
   155     return &iIteratorData;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CAknsAlEffectParamContainer::AddParamL
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CAknsAlEffectParamContainer::AddParamL( const TAknsRlParameterData& aParam )
       
   163     {
       
   164     CAknsAlParamData* data = CAknsAlParamData::NewL( aParam );
       
   165     CleanupStack::PushL( data );
       
   166     iParams.AppendL( data );
       
   167     CleanupStack::Pop( data );
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CAknsAlEffectParamContainer::Begin
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CAknsAlEffectParamContainer::Begin()
       
   175     {
       
   176     iIteratorIndex = 0;
       
   177     }
       
   178 
       
   179 // End of file