uifw/AvKon/aknconf/src/aknconfphysicssettinglist.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 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  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknconfphysics.rsg>
       
    21 #include <akntextsettingpage.h>
       
    22 #include <centralrepository.h>
       
    23 #include <aknphysicscrkeys.h>
       
    24 
       
    25 #include "aknconfsettingitem.h"
       
    26 #include "aknconfphysicssettinglist.h"
       
    27 #include "aknconf.hrh"
       
    28 
       
    29 const TUid KPhysicsCenRepUid( KCRUidAknPhysicsSettings );
       
    30 const TInt KPhysicsCenRepMassKey( KViewMass );
       
    31 const TInt KPhysicsCenRepGravityKey( KGravity );
       
    32 const TInt KPhysicsCenRepSurfaceSoftErpKey( KSurfaceErp );
       
    33 const TInt KPhysicsCenRepSurfaceSoftCfmKey( KSurfaceCfm );
       
    34 const TInt KPhysicsCenRepHighlightTimeoutKey( KHighlightTimeout );
       
    35 const TInt KPhysicsCenRepDragThresholdKey( KDragTreshold );
       
    36 const TInt KPhysicsCenRepFrameDelay( KFrameDelay );
       
    37 const TInt KPhysicsCenRepMinFrameInterval( KMinFrameInterval );
       
    38 const TInt KPhysicsCenRepFeatureEnabledKey( KFeatureEnabled );
       
    39 const TInt KPhysicsCenRepFpsLoggingEnabledKey( KFpsLoggingEnabled );
       
    40 
       
    41 _LIT( KResourceFile, "\\resource\\apps\\aknconfphysics.rsc" );
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CAknConfPhysicsSettingList::NewL()
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CAknConfPhysicsSettingList* CAknConfPhysicsSettingList::NewL()
       
    50     {
       
    51     CAknConfPhysicsSettingList* self = new ( ELeave ) CAknConfPhysicsSettingList();
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CAknConfPhysicsSettingList::~CAknConfPhysicsSettingList()
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CAknConfPhysicsSettingList::~CAknConfPhysicsSettingList()
       
    64     {
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CAknConfPhysicsSettingList::ResetValues()
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CAknConfPhysicsSettingList::ResetValues()
       
    72     {
       
    73     if ( iCenRep )
       
    74         {
       
    75         iCenRep->Reset();
       
    76         TInt cenRepKey( -1 );
       
    77         ValueFromCenRep( EAknConfPhysicsSettingMass, cenRepKey );
       
    78         ValueFromCenRep( EAknConfPhysicsSettingGravity, cenRepKey );
       
    79         ValueFromCenRep( EAknConfPhysicsSettingSurfaceSoftErp, cenRepKey );
       
    80         ValueFromCenRep( EAknConfPhysicsSettingSurfaceSoftCfm, cenRepKey );
       
    81         ValueFromCenRep( EAknConfPhysicsSettingHighlightTimeout, cenRepKey );
       
    82         ValueFromCenRep( EAknConfPhysicsSettingDragThreshold, cenRepKey );
       
    83         ValueFromCenRep( EAknConfPhysicsSettingFrameDelay, cenRepKey );
       
    84         ValueFromCenRep( EAknConfPhysicsSettingMinFrameInterval, cenRepKey );
       
    85         ValueFromCenRep( EAknConfPhysicsSettingFeatureEnabled, cenRepKey );
       
    86         ValueFromCenRep( EAknConfPhysicsSettingShortListEmptySpace, cenRepKey );
       
    87         ValueFromCenRep( EAknConfPhysicsSettingLongListEmptySpace, cenRepKey );
       
    88         ValueFromCenRep( EAknConfPhysicsSettingFpsLoggingEnabled, cenRepKey );
       
    89         TRAP_IGNORE( LoadSettingsL() );
       
    90         DrawDeferred();
       
    91         }
       
    92     }
       
    93 
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CAknConfPhysicsSettingList::CreateSettingItemL()
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CAknSettingItem* CAknConfPhysicsSettingList::CreateSettingItemL( TInt aIdentifier )
       
   100     {
       
   101     if ( aIdentifier != EAknConfPhysicsSettingShortListEmptySpace
       
   102             && aIdentifier != EAknConfPhysicsSettingLongListEmptySpace
       
   103             && aIdentifier != EAknConfPhysicsSettingFeatureEnabled
       
   104             && aIdentifier != EAknConfPhysicsSettingFpsLoggingEnabled )
       
   105         {
       
   106         return CAknConfSettingList::CreateSettingItemL( aIdentifier );
       
   107         }
       
   108     CAknSettingItem* settingItem = NULL;
       
   109     TInt cenRepKey( 0 );
       
   110 
       
   111     TInt* settingValue( ValueFromCenRep( aIdentifier, cenRepKey ) );
       
   112 
       
   113     if ( aIdentifier == EAknConfPhysicsSettingShortListEmptySpace
       
   114         || aIdentifier == EAknConfPhysicsSettingLongListEmptySpace )
       
   115         {
       
   116         settingItem = 
       
   117             new ( ELeave ) CAknConfSliderSettingItem( 
       
   118                 this, *settingValue, aIdentifier, cenRepKey );
       
   119         }
       
   120     else if ( aIdentifier == EAknConfPhysicsSettingFeatureEnabled
       
   121         || aIdentifier == EAknConfPhysicsSettingFpsLoggingEnabled )
       
   122         {
       
   123         settingItem 
       
   124             =  new ( ELeave ) CAknConfBinarySettingItem( 
       
   125                 this, *settingValue, aIdentifier, cenRepKey );
       
   126         }
       
   127     return settingItem;
       
   128     }
       
   129 
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CAknConfPhysicsSettingList::CAknConfPhysicsSettingList()
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 CAknConfPhysicsSettingList::CAknConfPhysicsSettingList()
       
   136     :
       
   137     CAknConfSettingList(),
       
   138     iMass( 0 ),
       
   139     iGravity( 0 ),
       
   140     iSurfaceSoftErp( 0 ),
       
   141     iSurfaceSoftCfm( 0 ),
       
   142     iHighlightTimeout( 0 ),
       
   143     iDragThreshold( 0 ),
       
   144     iFrameDelay( 0 ),
       
   145     iMinFrameInterval( 0 ),
       
   146     iShortListEmptySpace( 0 ),
       
   147     iLongListEmptySpace( 0 )
       
   148     {
       
   149     }
       
   150 
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CAknConfPhysicsSettingList::ConstructL()
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void CAknConfPhysicsSettingList::ConstructL()
       
   157     {
       
   158     CAknConfSettingList::ConstructL( KPhysicsCenRepUid, KResourceFile );
       
   159     CAknConfSettingList::ConstructFromResourceL( R_AKNCONF_PHYSICS_SETTINGITEMLIST );
       
   160     }
       
   161 
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CAknConfPhysicsSettingList::DataValuePointer()
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 TInt* CAknConfPhysicsSettingList::DataValuePointer( const TInt& aId, TInt& aCenRepKey )
       
   168     {
       
   169     TInt* valuePtr( NULL );
       
   170     switch ( aId )
       
   171         {
       
   172         case EAknConfPhysicsSettingMass:
       
   173             valuePtr = &iMass;
       
   174             aCenRepKey = KPhysicsCenRepMassKey;
       
   175             break;
       
   176         case EAknConfPhysicsSettingGravity:
       
   177             valuePtr = &iGravity;
       
   178             aCenRepKey = KPhysicsCenRepGravityKey;
       
   179             break;
       
   180         case EAknConfPhysicsSettingSurfaceSoftErp:
       
   181             valuePtr = &iSurfaceSoftErp;
       
   182             aCenRepKey = KPhysicsCenRepSurfaceSoftErpKey;
       
   183             break;
       
   184         case EAknConfPhysicsSettingSurfaceSoftCfm:
       
   185             valuePtr = &iSurfaceSoftCfm;
       
   186             aCenRepKey = KPhysicsCenRepSurfaceSoftCfmKey;
       
   187             break;
       
   188         case EAknConfPhysicsSettingHighlightTimeout:
       
   189             valuePtr = &iHighlightTimeout;
       
   190             aCenRepKey = KPhysicsCenRepHighlightTimeoutKey;
       
   191             break;
       
   192         case EAknConfPhysicsSettingDragThreshold:
       
   193             valuePtr = &iDragThreshold;
       
   194             aCenRepKey = KPhysicsCenRepDragThresholdKey;
       
   195             break;
       
   196         case EAknConfPhysicsSettingFrameDelay:
       
   197             valuePtr = &iFrameDelay;
       
   198             aCenRepKey = KPhysicsCenRepFrameDelay;
       
   199             break;   
       
   200         case EAknConfPhysicsSettingMinFrameInterval:
       
   201             valuePtr = &iMinFrameInterval;
       
   202             aCenRepKey = KPhysicsCenRepMinFrameInterval;
       
   203             break;   
       
   204         case EAknConfPhysicsSettingFeatureEnabled:
       
   205             valuePtr = &iFeatureEnabled;
       
   206             aCenRepKey = KPhysicsCenRepFeatureEnabledKey;
       
   207             break;
       
   208         case EAknConfPhysicsSettingShortListEmptySpace:
       
   209             valuePtr = &iShortListEmptySpace;
       
   210             aCenRepKey = KShortListEmptySpace;
       
   211             break;
       
   212         case EAknConfPhysicsSettingLongListEmptySpace:
       
   213             valuePtr = &iLongListEmptySpace;
       
   214             aCenRepKey = KLongListEmptySpace;
       
   215             break;
       
   216         case EAknConfPhysicsSettingFpsLoggingEnabled:
       
   217             valuePtr = &iFpsLoggingEnabled;
       
   218             aCenRepKey = KPhysicsCenRepFpsLoggingEnabledKey;
       
   219             break;
       
   220         default:
       
   221             break;
       
   222         }
       
   223     return valuePtr;
       
   224     }
       
   225 
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CAknConfPhysicsSettingList::ValueFromCenRep()
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 TInt* CAknConfPhysicsSettingList::ValueFromCenRep( const TInt& aId, 
       
   232                                             TInt& aCenRepKey )
       
   233     {
       
   234     aCenRepKey = 0;
       
   235     TInt* settingValue( DataValuePointer( aId, aCenRepKey ) );
       
   236     if ( !settingValue || !aCenRepKey )
       
   237         {
       
   238         return NULL;
       
   239         }
       
   240 
       
   241     TInt value( -1 );
       
   242     if ( iCenRep )
       
   243         {
       
   244         iCenRep->Get( aCenRepKey, value );
       
   245         }
       
   246     *settingValue = value;
       
   247     return settingValue;
       
   248     }
       
   249 // End of File