S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SimpleLightAppUi.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : SimpleLightAppUi.cpp
00004 *  Part of     : OpenGLEx / SimpleLight
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include "SimpleLightAppUi.h"
00018 #include "SimpleLightContainer.h" 
00019 #include <SimpleLight.rsg>
00020 #include "simplelight.hrh"
00021 
00022 #include <eikmenup.h>
00023 #include <avkon.hrh>
00024 
00025 // ================= MEMBER FUNCTIONS =======================
00026 //
00027 // ----------------------------------------------------------
00028 // CSimpleLightAppUi::ConstructL
00029 // Symbian 2nd phase constructor can leave.
00030 // ----------------------------------------------------------
00031 //
00032 void CSimpleLightAppUi::ConstructL()
00033     {
00034     BaseConstructL();
00035     iAppContainer = new (ELeave) CSimpleLightContainer;
00036     iAppContainer->SetMopParent(this);
00037     iAppContainer->ConstructL( ClientRect() );
00038     AddToStackL( iAppContainer );
00039     }
00040 
00041 // Destructor
00042 CSimpleLightAppUi::~CSimpleLightAppUi()
00043     {
00044     if ( iAppContainer )
00045         {
00046         RemoveFromStack( iAppContainer );
00047         delete iAppContainer;
00048         }
00049     }
00050 
00051 // ------------------------------------------------------------------------------
00052 //  CSimpleLightAppUi::DynInitMenuPaneL
00053 //  This function is called by the EIKON framework just before it displays
00054 //  a menu pane. Its default implementation is empty, and by overriding it,
00055 //  the application can set the state of menu items dynamically according
00056 //  to the state of application data.
00057 // ------------------------------------------------------------------------------
00058 //
00059 void CSimpleLightAppUi::DynInitMenuPaneL(
00060     TInt aResourceId, CEikMenuPane* aMenuPane )
00061     {
00062     // Item texts for the lighting menu. 
00063     if ( aResourceId == R_SIMPLELIGHT_LIGHTING_MENU )
00064         {
00065         // Text for switching the lights on/off. 
00066         if ( iAppContainer->iSimpleLight->iLightingEnabled )
00067             {
00068             aMenuPane->SetItemTextL( ESimpleLightLights, R_LIGHTS_OFF );
00069             }
00070         else
00071             {
00072             aMenuPane->SetItemTextL( ESimpleLightLights, R_LIGHTS_ON  );
00073             }
00074         
00075         // Text for switching the lamp on/off. 
00076         if ( iAppContainer->iSimpleLight->iLampEnabled )
00077             {
00078             aMenuPane->SetItemTextL( ESimpleLightLamp, R_LAMP_OFF );
00079             }
00080         else
00081             {
00082             aMenuPane->SetItemTextL( ESimpleLightLamp, R_LAMP_ON );
00083             }
00084         
00085         // Text for switching the spot on/off. 
00086         if ( iAppContainer->iSimpleLight->iSpotEnabled )
00087             {
00088             aMenuPane->SetItemTextL( ESimpleLightSpot, R_SPOT_OFF );
00089             }
00090         else
00091             {
00092             aMenuPane->SetItemTextL( ESimpleLightSpot, R_SPOT_ON );
00093             }
00094         }
00095     }
00096 
00097 // ----------------------------------------------------
00098 // CSimpleLightAppUi::HandleKeyEventL
00099 // Key event handler
00100 // ----------------------------------------------------
00101 //
00102 TKeyResponse CSimpleLightAppUi::HandleKeyEventL(
00103     const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
00104     {
00105     return EKeyWasNotConsumed;
00106     }
00107 
00108 // ----------------------------------------------------
00109 // CSimpleLightAppUi::HandleCommandL
00110 // Command handler
00111 // ----------------------------------------------------
00112 //
00113 void CSimpleLightAppUi::HandleCommandL(TInt aCommand)
00114     {
00115     switch ( aCommand )
00116         {
00117         case EAknSoftkeyBack:
00118         case EEikCmdExit:
00119             {
00120             Exit();
00121             break;
00122             }
00123         case ESimpleLightLights:
00124             iAppContainer->iSimpleLight->ToggleLighting();
00125             break;
00126         case ESimpleLightLamp:
00127             iAppContainer->iSimpleLight->ToggleLamp();
00128             break;
00129         case ESimpleLightSpot:
00130             iAppContainer->iSimpleLight->ToggleSpot();
00131             break;
00132         case ESimpleLightDuck:
00133             iAppContainer->iSimpleLight->DuckModel();
00134             break;
00135         case ESimpleLightHead:
00136             iAppContainer->iSimpleLight->HeadModel();
00137             break;
00138         default:
00139             break;      
00140         }
00141     }
00142 
00143 // End of File  

© Nokia 2006

Back to top