S60 3rd Edition SDK for Symbian OS
Example Applications Guide

HierarchyAppUi.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : HierarchyAppUi.cpp
00004 *  Part of     : OpenGLEx / Hierarchy
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 "HierarchyAppUi.h"
00018 #include "HierarchyContainer.h" 
00019 #include <Hierarchy.rsg>
00020 #include "hierarchy.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 // CHierarchyAppUi::ConstructL
00044 // Symbian 2nd phase constroctor can leave
00045 // ----------------------------------------------------------
00046 //
00047 void CHierarchyAppUi::ConstructL()
00048     {
00049     BaseConstructL();
00050     iAppContainer = new (ELeave) CHierarchyContainer;
00051     iAppContainer->SetMopParent(this);
00052     iAppContainer->ConstructL( ClientRect() );
00053     AddToStackL( iAppContainer );
00054     }
00055 
00056 // ----------------------------------------------------
00057 // CHierarchyAppUi::~CHierarchyAppUi
00058 // Destructor
00059 // ----------------------------------------------------
00060 //
00061 CHierarchyAppUi::~CHierarchyAppUi()
00062     {
00063     if ( iAppContainer )
00064         {
00065         RemoveFromStack( iAppContainer );
00066         delete iAppContainer;
00067         }
00068    }
00069 
00070 // ------------------------------------------------------------------------------
00071 // CHierarchyAppUi::DynInitMenuPaneL
00072 //  This function is called by the EIKON framework just before it displays
00073 //  a menu pane. Its default implementation is empty, and by overriding it,
00074 //  the application can set the state of menu items dynamically according
00075 //  to the state of application data.
00076 // ------------------------------------------------------------------------------
00077 //
00078 void CHierarchyAppUi::DynInitMenuPaneL(
00079     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
00080     {
00081     }
00082 
00083 // ----------------------------------------------------
00084 // CHierarchyAppUi::HandleKeyEventL
00085 // Key event handler
00086 // ----------------------------------------------------
00087 //
00088 TKeyResponse CHierarchyAppUi::HandleKeyEventL(
00089     const TKeyEvent& aKeyEvent, TEventCode aType )
00090     {
00091     if ( aType == EEventKeyDown )
00092         {
00093         TUint scan = aKeyEvent.iScanCode;
00094         
00095         switch ( scan )
00096             {
00097             case(EStdKeyUpArrow):
00098                 iAppContainer->iHierarchy->RotateObjectUp(ETrue);
00099                 return EKeyWasConsumed;
00100             case(EStdKeyDownArrow):
00101                 iAppContainer->iHierarchy->RotateObjectDown(ETrue);
00102                 return EKeyWasConsumed;
00103             case(EStdKeyDevice3):
00104                 iAppContainer->iHierarchy->SwitchRotateMode();
00105                 return EKeyWasConsumed;
00106             default:
00107                 return EKeyWasNotConsumed;
00108             }
00109         }
00110     else if ( aType == EEventKeyUp )
00111         {
00112         TUint scan = aKeyEvent.iScanCode;
00113         
00114         switch ( scan )
00115             {
00116             case(EStdKeyUpArrow):
00117                 iAppContainer->iHierarchy->RotateObjectUp(EFalse);
00118                 return EKeyWasConsumed;
00119             case(EStdKeyDownArrow):
00120                 iAppContainer->iHierarchy->RotateObjectDown(EFalse);
00121                 return EKeyWasConsumed;
00122             default:
00123                 return EKeyWasNotConsumed;
00124             }
00125         }
00126     else
00127         {
00128         return EKeyWasNotConsumed;
00129         }
00130     }
00131 
00132 // ----------------------------------------------------
00133 // CHierarchyAppUi::HandleCommandL
00134 // Command handler
00135 // ----------------------------------------------------
00136 //
00137 void CHierarchyAppUi::HandleCommandL(TInt aCommand)
00138     {
00139     switch ( aCommand )
00140         {
00141         case EAknSoftkeyBack:
00142         case EEikCmdExit:
00143             {
00144             Exit();
00145             break;
00146             }
00147         default:
00148             break;      
00149         }
00150     }
00151 
00152 // End of File  

© Nokia 2006

Back to top