Nokia N97 SDK
Example Applications Guide

datamobilityappmenuview.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name         : datamobilityappmenuview.cpp
00004 *  Part of      : datamobility
00005 *  Description  : CDataMobilityAppMenuView implementation.
00006 *
00007 *  Copyright (c) 2007 Nokia Corporation.
00008 *  This material, including documentation and any related
00009 *  computer programs, is protected by copyright controlled by
00010 *  Nokia Corporation.
00011 * ============================================================================
00012 */
00013 
00014 // INCLUDE FILES
00015 #include  <aknviewappui.h>
00016 #include  <barsread.h>  //TResourceReader
00017 #include  <datamobility.rsg>
00018 #include  "datamobilityappmenuview.h"
00019 #include  "datamobilityappmenucontainer.h"
00020 #include  "datamobility.hrh"
00021 #include  "datamobilityappui.h"
00022 
00023 
00024 // ============================ MEMBER FUNCTIONS ===============================
00025 
00026 // -----------------------------------------------------------------------------
00027 // CDataMobilityAppMenuView::NewL
00028 //
00029 // Symbian OS Two-phased constructor.
00030 // -----------------------------------------------------------------------------
00031 //
00032 CDataMobilityAppMenuView* CDataMobilityAppMenuView::NewL()
00033     {
00034     CDataMobilityAppMenuView* self =
00035         new ( ELeave ) CDataMobilityAppMenuView();
00036     CleanupStack::PushL( self );
00037     self->ConstructL();
00038     CleanupStack::Pop( self );
00039     return self;
00040     }
00041 
00042 // -----------------------------------------------------------------------------
00043 // CDataMobilityAppMenuView::ConstructL
00044 //
00045 // Symbian OS two-phased constructor
00046 // -----------------------------------------------------------------------------
00047 //
00048 void CDataMobilityAppMenuView::ConstructL()
00049     {
00050     BaseConstructL( R_APPUI_MENUVIEW );
00051     }
00052 
00053 // -----------------------------------------------------------------------------
00054 // CDataMobilityAppMenuView::~CDataMobilityAppMenuView
00055 //
00056 // Destructor
00057 // -----------------------------------------------------------------------------
00058 //
00059 CDataMobilityAppMenuView::~CDataMobilityAppMenuView()
00060     {
00061     if ( iContainer )
00062         {
00063         AppUi()->RemoveFromViewStack( *this, iContainer );
00064         delete iContainer;
00065         }
00066 
00067     delete iNaviDecorator;
00068     }
00069 
00070 // -----------------------------------------------------------------------------
00071 // TUid CDataMobilityAppMenuView::Id
00072 //
00073 // Returns view´s id.
00074 // -----------------------------------------------------------------------------
00075 //
00076 TUid CDataMobilityAppMenuView::Id() const
00077     {
00078     return TUid::Uid( EMenuViewId );
00079     }
00080 
00081 // -----------------------------------------------------------------------------
00082 // CDataMobilityAppMenuView::HandleCommandL
00083 //
00084 // Handles a command.
00085 // -----------------------------------------------------------------------------
00086 //
00087 void CDataMobilityAppMenuView::HandleCommandL( TInt aCommand )
00088     {
00089     switch ( aCommand )
00090         {
00091         case EAknSoftkeyBack:
00092             {
00093             AppUi()->HandleCommandL( EEikCmdExit );
00094             break;
00095             }
00096         case EAknCmdOpen:
00097             {
00098             TInt activeLine = iContainer->GetActiveLine();
00099             iContainer->HandleSelectedListItemL( activeLine );
00100             }
00101             break;
00102         default:
00103             {
00104             AppUi()->HandleCommandL( aCommand );
00105             break;
00106             }
00107         }
00108     }
00109 
00110 // -----------------------------------------------------------------------------
00111 // CDataMobilityAppMenuView::DoActivateL
00112 //
00113 // Initializes view when activated.
00114 // -----------------------------------------------------------------------------
00115 //
00116 void CDataMobilityAppMenuView::DoActivateL(
00117    const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
00118    const TDesC8& /*aCustomMessage*/ )
00119     {
00120     if ( !iContainer )
00121         {
00122         iContainer = new ( ELeave ) CDataMobilityAppMenuContainer;
00123         iContainer->SetMopParent( this );
00124         iContainer->ConstructL( ClientRect() );
00125         AppUi()->AddToStackL( *this, iContainer );
00126         }
00127 
00128     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
00129     CAknNavigationControlContainer* navigation =
00130         static_cast<CAknNavigationControlContainer*>
00131             ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
00132 
00133     TResourceReader reader;
00134     iCoeEnv->CreateResourceReaderLC( reader, R_NAVITITLE_MENUVIEW );
00135     iNaviDecorator = navigation->CreateNavigationLabelL( reader );
00136     CleanupStack::PopAndDestroy(); // resource reader
00137 
00138     navigation->PushL( *iNaviDecorator );
00139    }
00140 
00141 // -----------------------------------------------------------------------------
00142 // CAppUIView::DoDeactivate
00143 //
00144 // Deactivates view.
00145 // -----------------------------------------------------------------------------
00146 //
00147 void CDataMobilityAppMenuView::DoDeactivate()
00148     {
00149     if ( iContainer )
00150         {
00151         AppUi()->RemoveFromViewStack( *this, iContainer );
00152         delete iContainer;
00153         iContainer = NULL;
00154         }
00155     delete iNaviDecorator;
00156     iNaviDecorator = NULL;
00157     }
00158 
00159 // End of File

© Nokia 2009

Back to top