1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file contains CMainMenuView class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <aknViewAppUi.h> |
|
20 #include <barsread.h> //TResourceReader |
|
21 #include <Stifui.rsg> |
|
22 #include "MainMenuView.h" |
|
23 #include "MainMenuContainer.h" |
|
24 #include "Stifui.hrh" |
|
25 #include "AppUIAppUi.h" |
|
26 |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // CMainMenuView::ConstructL |
|
32 // |
|
33 // Symbian OS two-phased constructor |
|
34 // --------------------------------------------------------- |
|
35 // |
|
36 void CMainMenuView::ConstructL() |
|
37 { |
|
38 BaseConstructL( R_APPUI_MAINMENUVIEW ); |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // CMainMenuView::~CMainMenuView |
|
43 // |
|
44 // Destructor |
|
45 // --------------------------------------------------------- |
|
46 // |
|
47 CMainMenuView::~CMainMenuView() |
|
48 { |
|
49 if ( iContainer ) |
|
50 { |
|
51 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
52 delete iContainer; |
|
53 iContainer = NULL; |
|
54 } |
|
55 delete iNaviDecorator; |
|
56 iNaviDecorator = NULL; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // TUid CMainMenuView::Id |
|
61 // |
|
62 // Returns view´s id. |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 TUid CMainMenuView::Id() const |
|
66 { |
|
67 return TUid::Uid(EMainMenuViewId); //KMainMenuViewId; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // CMainMenuView::HandleCommandL |
|
72 // |
|
73 // Handles a command. |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 void CMainMenuView::HandleCommandL(TInt aCommand) |
|
77 { |
|
78 switch ( aCommand ) |
|
79 { |
|
80 case EAknSoftkeyBack: |
|
81 { |
|
82 AppUi()->HandleCommandL(EEikCmdExit); |
|
83 break; |
|
84 } |
|
85 case EAknCmdOpen: |
|
86 { |
|
87 TInt a = iContainer->GetActiveLine(); |
|
88 iContainer->HandleSelectedListItemL( a ); |
|
89 } |
|
90 break; |
|
91 default: |
|
92 { |
|
93 AppUi()->HandleCommandL( aCommand ); |
|
94 break; |
|
95 } |
|
96 } |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CMainMenuView::HandleClientRectChange |
|
101 // |
|
102 // Handles client rect changes. |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 void CMainMenuView::HandleClientRectChange() |
|
106 { |
|
107 if ( iContainer ) |
|
108 { |
|
109 iContainer->SetRect( ClientRect() ); |
|
110 } |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------- |
|
114 // CMainMenuView::DoActivateL |
|
115 // |
|
116 // Initializes view when activated. |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 void CMainMenuView::DoActivateL( |
|
120 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
121 const TDesC8& /*aCustomMessage*/) |
|
122 { |
|
123 if (!iContainer) |
|
124 { |
|
125 iContainer = new (ELeave) CMainMenuContainer; |
|
126 iContainer->SetMopParent(this); |
|
127 iContainer->ConstructL( ClientRect() ); |
|
128 AppUi()->AddToStackL( *this, iContainer ); |
|
129 } |
|
130 |
|
131 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
132 CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); |
|
133 |
|
134 TResourceReader reader; |
|
135 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_MAIN); |
|
136 iNaviDecorator = np->CreateNavigationLabelL( reader ); |
|
137 CleanupStack::PopAndDestroy(); // resource reader |
|
138 |
|
139 np->PushL(*iNaviDecorator); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CAppUIView::DoDeactivate |
|
144 // |
|
145 // Deactivates view. |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CMainMenuView::DoDeactivate() |
|
149 { |
|
150 if ( iContainer ) |
|
151 { |
|
152 iContainer->SaveActiveLine(); |
|
153 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
154 delete iContainer; |
|
155 iContainer = NULL; |
|
156 } |
|
157 delete iNaviDecorator; |
|
158 iNaviDecorator = NULL; |
|
159 } |
|
160 |
|
161 // End of File |
|
162 |
|
163 // End of File |
|