S60 3rd Edition SDK for Symbian OS
Example Applications Guide

TextureAppUi.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : TextureAppUi.cpp
00004 *  Part of     : OpenGLEx / Texture
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 "TextureAppUi.h"
00018 #include "TextureContainer.h" 
00019 #include "texture.hrh"
00020 
00021 #include <Texture.rsg>
00022 #include <eikmenup.h>
00023 #include <avkon.hrh>
00024 
00025 // ================= MEMBER FUNCTIONS =======================
00026 //
00027 // ----------------------------------------------------------
00028 // CTextureAppUi::ConstructL()
00029 // ?implementation_description
00030 // ----------------------------------------------------------
00031 //
00032 void CTextureAppUi::ConstructL()
00033 {
00034     BaseConstructL();
00035     
00036     iAppContainer = new (ELeave) CTextureContainer;
00037     iAppContainer->SetMopParent(this);
00038     
00039     iAppContainer->ConstructL( ClientRect() );
00040     AddToStackL( iAppContainer );
00041 }
00042 
00043 // ----------------------------------------------------
00044 // CTextureAppUi::~CTextureAppUi()
00045 // Destructor
00046 // Frees reserved resources
00047 // ----------------------------------------------------
00048 //
00049 CTextureAppUi::~CTextureAppUi()
00050 {
00051     if (iAppContainer)
00052     {
00053         RemoveFromStack( iAppContainer );
00054         delete iAppContainer;
00055     }
00056 }
00057 
00058 // ------------------------------------------------------------------------------
00059 // CTextureAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
00060 //  This function is called by the EIKON framework just before it displays
00061 //  a menu pane. Its default implementation is empty, and by overriding it,
00062 //  the application can set the state of menu items dynamically according
00063 //  to the state of application data.
00064 // ------------------------------------------------------------------------------
00065 //
00066 void CTextureAppUi::DynInitMenuPaneL(
00067     TInt aResourceId, CEikMenuPane* aMenuPane)
00068 {
00069         /* Texts for menu items. */
00070     if( aResourceId == R_TEXTURE_MENU )
00071     {
00072         /* Text for perspective correction. */
00073         if( iAppContainer->iTexture->iPerspectiveCorrEnabled )
00074         {
00075             aMenuPane->SetItemTextL( ETexturePerspective, R_PERSPECTIVE_OFF );
00076         }
00077         else
00078         {
00079             aMenuPane->SetItemTextL( ETexturePerspective, R_PERSPECTIVE_ON );
00080         }
00081         
00082         /* Text for texture wrapping.*/
00083         if( iAppContainer->iTexture->iTextureWrapEnabled )
00084         {
00085             aMenuPane->SetItemTextL( ETextureWrapping, R_WRAPPING_OFF );
00086         }
00087         else
00088         {
00089             aMenuPane->SetItemTextL( ETextureWrapping, R_WRAPPING_ON );
00090         }
00091         
00092         /* Text for lighting.*/
00093         if( iAppContainer->iTexture->iLightingEnabled )
00094         {
00095             aMenuPane->SetItemTextL( ETextureLights, R_LIGHTS_OFF );
00096         }
00097         else
00098         {
00099             aMenuPane->SetItemTextL( ETextureLights, R_LIGHTS_ON );
00100         }
00101     }
00102 }
00103 
00104 // ----------------------------------------------------
00105 // CTextureAppUi::HandleKeyEventL(
00106 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00107 // ?implementation_description
00108 // ----------------------------------------------------
00109 //
00110 TKeyResponse CTextureAppUi::HandleKeyEventL(
00111     const TKeyEvent& aKeyEvent, TEventCode aType )
00112 {
00113     if ( iAppContainer->iTexture->GetState() == CTexture::ERunning )
00114                 {
00115                         if( aType == EEventKeyDown )
00116                         {
00117                             TUint scan = aKeyEvent.iScanCode;
00118                             
00119                             switch(scan)
00120                             {
00121                             case(167):
00122                                         iAppContainer->iTexture->ToggleBlending();
00123                                         return EKeyWasConsumed;
00124                             default:
00125                                         return EKeyWasNotConsumed;
00126                             }
00127                         }
00128                 }
00129     return EKeyWasNotConsumed;
00130 }
00131 
00132 // ----------------------------------------------------
00133 // CTextureAppUi::HandleCommandL(TInt aCommand)
00134 // ?implementation_description
00135 // ----------------------------------------------------
00136 //
00137 void CTextureAppUi::HandleCommandL(TInt aCommand)
00138 {
00139     switch ( aCommand )
00140     {
00141     case EAknSoftkeyBack:
00142     case EEikCmdExit:
00143     {
00144         Exit();
00145         break;
00146     }
00147     case ETexturePerspective:
00148     {
00149         iAppContainer->iTexture->TogglePerspective();
00150         break;
00151     }
00152     case ETextureWrapping:
00153     {
00154         iAppContainer->iTexture->ToggleWrapping();
00155         break;
00156     }
00157     case ETextureLights:
00158         iAppContainer->iTexture->ToggleLighting();
00159         break;
00160     default:
00161         break;      
00162     }
00163 }
00164 
00165 // End of File  

© Nokia 2006

Back to top