Nokia N97 SDK
Example Applications Guide

TextureAppUi.cpp

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

© Nokia 2009

Back to top