S60 3rd Edition SDK for Symbian OS
Example Applications Guide

PickSelectAppUi.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : PickSelectAppUi.cpp
00004 *  Part of     : OpenGLEx / PickSelect
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 "PickSelectAppUi.h"
00018 #include "PickSelectContainer.h" 
00019 #include <PickSelect.rsg>
00020 #include "pickselect.hrh"
00021 
00022 #include <avkon.hrh>
00023 
00024 // ================= MEMBER FUNCTIONS =======================
00025 //
00026 // ----------------------------------------------------------
00027 // CPickSelectAppUi::ConstructL
00028 // Symbian 2nd phase constructor can leave.
00029 // ----------------------------------------------------------
00030 //
00031 void CPickSelectAppUi::ConstructL()
00032     {
00033     BaseConstructL();
00034     iAppContainer = new (ELeave) CPickSelectContainer;
00035     iAppContainer->SetMopParent(this);
00036     iAppContainer->ConstructL( ClientRect() );
00037     AddToStackL( iAppContainer );
00038     }
00039 
00040 // Destructor
00041 CPickSelectAppUi::~CPickSelectAppUi()
00042     {
00043     if ( iAppContainer )
00044         {
00045         RemoveFromStack( iAppContainer );
00046         delete iAppContainer;
00047         }
00048    }
00049 
00050 // ------------------------------------------------------------------------------
00051 // CPickSelectAppUi::DynInitMenuPaneL
00052 //  This function is called by the EIKON framework just before it displays
00053 //  a menu pane. Its default implementation is empty, and by overriding it,
00054 //  the application can set the state of menu items dynamically according
00055 //  to the state of application data.
00056 // ------------------------------------------------------------------------------
00057 //
00058 void CPickSelectAppUi::DynInitMenuPaneL(
00059     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
00060     {
00061     }
00062 
00063 // ----------------------------------------------------
00064 // CPickSelectAppUi::HandleKeyEventL
00065 // Key event handler
00066 // ----------------------------------------------------
00067 //
00068 TKeyResponse CPickSelectAppUi::HandleKeyEventL(
00069     const TKeyEvent& aKeyEvent,TEventCode aType)
00070     {
00071     if ( aType == EEventKeyDown )
00072         {
00073         TUint scan = aKeyEvent.iScanCode;
00074         
00075         switch ( scan )
00076             {
00077             case(EStdKeyUpArrow):
00078                 iAppContainer->iPickSelect->MoveUp(ETrue);
00079                 return EKeyWasConsumed;
00080             case(EStdKeyDownArrow):
00081                 iAppContainer->iPickSelect->MoveDown(ETrue);
00082                 return EKeyWasConsumed;
00083             case(EStdKeyLeftArrow):
00084                 iAppContainer->iPickSelect->MoveLeft(ETrue);
00085                 return EKeyWasConsumed;
00086             case(EStdKeyRightArrow):
00087                 iAppContainer->iPickSelect->MoveRight(ETrue);
00088                 return EKeyWasConsumed;
00089             case(EStdKeyDevice3):  // Rocker Middle Button 
00090                 iAppContainer->iPickSelect->SelectObject();
00091                 return EKeyWasConsumed;
00092             default:
00093                 return EKeyWasNotConsumed;
00094             }
00095         }
00096     else if ( aType == EEventKeyUp )
00097         {
00098         TUint scan = aKeyEvent.iScanCode;
00099         
00100         switch ( scan )
00101             {
00102             case(16):
00103                 iAppContainer->iPickSelect->MoveUp(EFalse);
00104                 return EKeyWasConsumed;
00105             case(17):
00106                 iAppContainer->iPickSelect->MoveDown(EFalse);
00107                 return EKeyWasConsumed;
00108             case(14):
00109                 iAppContainer->iPickSelect->MoveLeft(EFalse);
00110                 return EKeyWasConsumed;
00111             case(15):
00112                 iAppContainer->iPickSelect->MoveRight(EFalse);
00113                 return EKeyWasConsumed;
00114             default:
00115                 return EKeyWasNotConsumed;
00116             }
00117         }
00118     else
00119         {
00120         return EKeyWasNotConsumed;
00121         }
00122     }
00123 
00124 // ----------------------------------------------------
00125 // CPickSelectAppUi::HandleCommandL(TInt aCommand)
00126 // Command handler
00127 // ----------------------------------------------------
00128 //
00129 void CPickSelectAppUi::HandleCommandL(TInt aCommand)
00130     {
00131     switch ( aCommand )
00132         {
00133         case EAknSoftkeyBack:
00134         case EEikCmdExit:
00135             {
00136             Exit();
00137             break;
00138             }
00139         case EPickSelectPolygon:
00140             {
00141             iAppContainer->iPickSelect->SetPolygonSelection();
00142             break;
00143             }
00144         case EPickSelectObject:
00145             {
00146             iAppContainer->iPickSelect->SetObjectSelection();
00147             break;
00148             }
00149         default:
00150             break;      
00151         }
00152     }
00153 
00154 // End of File  

© Nokia 2006

Back to top