S60 3rd Edition SDK for Symbian OS
Example Applications Guide

LensFlareAppUi.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : LensFlareAppUi.cpp
00004 *  Part of     : OpenGLEx / LensFlare
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 "LensFlareAppUi.h"
00018 #include "LensFlareContainer.h" 
00019 #include <LensFlare.rsg>
00020 #include "lensflare.hrh"
00021 
00022 #include <avkon.hrh>
00023 
00024 // EXTERNAL DATA STRUCTURES
00025 
00026 // EXTERNAL FUNCTION PROTOTYPES  
00027 
00028 // CONSTANTS
00029 
00030 // MACROS
00031 
00032 // LOCAL CONSTANTS AND MACROS
00033 
00034 // MODULE DATA STRUCTURES
00035 
00036 // LOCAL FUNCTION PROTOTYPES
00037 
00038 // FORWARD DECLARATIONS
00039 
00040 // ================= MEMBER FUNCTIONS =======================
00041 //
00042 // ----------------------------------------------------------
00043 // CLensFlareAppUi::ConstructL()
00044 // Symbian 2nd phase constructor can leave.
00045 // ----------------------------------------------------------
00046 //
00047 void CLensFlareAppUi::ConstructL()
00048     {
00049     BaseConstructL();
00050     iAppContainer = new (ELeave) CLensFlareContainer;
00051     iAppContainer->SetMopParent(this);
00052     iAppContainer->ConstructL( ClientRect() );
00053     AddToStackL( iAppContainer );
00054     }
00055 
00056 // ----------------------------------------------------
00057 // CLensFlareAppUi::~CLensFlareAppUi()
00058 // Destructor
00059 // Frees reserved resources
00060 // ----------------------------------------------------
00061 //
00062 CLensFlareAppUi::~CLensFlareAppUi()
00063     {
00064     if (iAppContainer)
00065         {
00066         RemoveFromStack( iAppContainer );
00067         delete iAppContainer;
00068         }
00069         }
00070 
00071 // ------------------------------------------------------------------------------
00072 // CLensFlareAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
00073 //  This function is called by the EIKON framework just before it displays
00074 //  a menu pane. Its default implementation is empty, and by overriding it,
00075 //  the application can set the state of menu items dynamically according
00076 //  to the state of application data.
00077 // ------------------------------------------------------------------------------
00078 //
00079 void CLensFlareAppUi::DynInitMenuPaneL(
00080     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
00081     {
00082     }
00083 
00084 // ----------------------------------------------------
00085 // CLensFlareAppUi::HandleKeyEventL(
00086 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00087 // Key event handler
00088 // ----------------------------------------------------
00089 //
00090 TKeyResponse CLensFlareAppUi::HandleKeyEventL(
00091         const TKeyEvent& aKeyEvent, TEventCode aType)
00092         {
00093         if ( iAppContainer->iLensflare->GetState() == CLensflare::ERunning )
00094                 {
00095                 if ( aType == EEventKeyDown )
00096                         {
00097                         switch ( aKeyEvent.iScanCode )
00098                                 {
00099                                 case EStdKeyLeftArrow:
00100                                         {
00101                                         GLbyte & direction = iAppContainer->iLensflare->iDirection;
00102               
00103                                         if ( direction != 0 )
00104                                                 {
00105                                                 direction = 0;
00106                                                 }
00107                                         else
00108                                                 {
00109                                                 direction = -1;
00110                                                 }
00111                                         }
00112                         return EKeyWasConsumed;
00113                                 case EStdKeyRightArrow:
00114                                         {
00115                                         GLbyte & direction = iAppContainer->iLensflare->iDirection;
00116               
00117                                         if ( direction != 0 )
00118                                                 {
00119                                                 direction = 0;
00120                                                 }
00121                                         else 
00122                                                 {
00123                                                 direction = +1;
00124                                                 }
00125                                         }
00126                         return EKeyWasConsumed;
00127                                 case EStdKeyUpArrow:
00128                                         iAppContainer->iLensflare->TurnCameraElevation(-1, 1.0f);
00129                                         return EKeyWasConsumed;
00130                                 case EStdKeyDownArrow:
00131                                         iAppContainer->iLensflare->TurnCameraElevation(+1, 1.0f);
00132                                         return EKeyWasConsumed;
00133                                 default:
00134                                         return EKeyWasNotConsumed;
00135                                 }
00136                         }
00137                 }
00138                 return EKeyWasNotConsumed;
00139         }
00140 
00141 // ----------------------------------------------------
00142 // CLensFlareAppUi::HandleCommandL(TInt aCommand)
00143 // Command handler
00144 // ----------------------------------------------------
00145 //
00146 void CLensFlareAppUi::HandleCommandL(TInt aCommand)
00147     {
00148     switch ( aCommand )
00149         {
00150         case EAknSoftkeyBack:
00151         case EEikCmdExit:
00152             {
00153             Exit();
00154             break;
00155             }
00156         default:
00157             break;      
00158         }
00159     }
00160 
00161 // End of File  

© Nokia 2006

Back to top