1 /* |
|
2 * Copyright (c) 2002-2007 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: Provides Psln Application Base view methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "PslnBaseView.h" |
|
22 |
|
23 #include <mpslnfwmsklabelobserver.h> |
|
24 |
|
25 #include <aknnavi.h> |
|
26 #include <aknnavide.h> |
|
27 #include <aknViewAppUi.h> |
|
28 #include <akntitle.h> |
|
29 #include <barsread.h> |
|
30 #include <StringLoader.h> |
|
31 #include <eikbtgpc.h> |
|
32 #include <eikmenup.h> |
|
33 #include <avkon.rsg> |
|
34 |
|
35 #include <psln.rsg> |
|
36 |
|
37 #include "PslnFeatures.h" |
|
38 #include "PslnUi.h" |
|
39 #include "PslnBaseContainer.h" |
|
40 #include "PslnConst.h" |
|
41 |
|
42 // ========================= MEMBER FUNCTIONS ================================ |
|
43 // --------------------------------------------------------------------------- |
|
44 // Constructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CPslnBaseView::CPslnBaseView() |
|
48 { |
|
49 iPslnUi = static_cast<CPslnUi*>( AppUi() ); |
|
50 |
|
51 if ( !iModel ) |
|
52 { |
|
53 iModel = iPslnUi->Model(); |
|
54 } |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Destructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CPslnBaseView::~CPslnBaseView() |
|
62 { |
|
63 if ( iContainer ) |
|
64 { |
|
65 iPslnUi->RemoveFromStack( iContainer ); |
|
66 delete iContainer; |
|
67 } |
|
68 if ( iNaviPaneContext && |
|
69 iNaviPaneContext != iPslnUi->PslnTabGroup() ) |
|
70 { |
|
71 delete iNaviPaneContext; |
|
72 } |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CPslnBaseView::HandleListBoxEventL |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CPslnBaseView::HandleListBoxEventL( |
|
80 CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
81 { |
|
82 switch ( aEventType ) |
|
83 { |
|
84 case EEventItemClicked: |
|
85 case EEventFlickStopped: |
|
86 if ( iContainer && iContainer->GetMiddleSoftkeyObserver() ) |
|
87 { |
|
88 iContainer->GetMiddleSoftkeyObserver()->CheckMiddleSoftkeyLabelL(); |
|
89 } |
|
90 HandleListBoxItemHighlightL(); |
|
91 break; |
|
92 case EEventEnterKeyPressed: |
|
93 case EEventItemDoubleClicked: |
|
94 case EEventItemSingleClicked: |
|
95 HandleListBoxSelectionL(); |
|
96 break; |
|
97 case EEventPenDownOnItem: |
|
98 HandleListBoxStylusDown(); |
|
99 break; |
|
100 case EEventItemDraggingActioned: |
|
101 HandleListBoxStylusDrag(); |
|
102 break; |
|
103 default: |
|
104 break; |
|
105 } |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CPslnBaseView::DoActivateL |
|
110 // Activates the view. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CPslnBaseView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
114 TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/ ) |
|
115 { |
|
116 if( aPrevViewId.iViewUid == Id() && |
|
117 aPrevViewId.iAppUid == KUidPsln )//same view? |
|
118 { |
|
119 //if continuous activate same view twice,direct return,do nothing |
|
120 return; |
|
121 } |
|
122 |
|
123 if( iContainer ) |
|
124 { |
|
125 RemoveContainer(); |
|
126 } |
|
127 |
|
128 CreateContainerL(); |
|
129 iPslnUi->AddToStackL( *this, iContainer ); |
|
130 iContainer->SetListBoxObserver( this ); |
|
131 |
|
132 SetNaviPaneL(); |
|
133 TInt titlePaneResourceID = KErrNone; |
|
134 SetTitlePaneL( titlePaneResourceID ); |
|
135 // Retrieve title pane and set it. |
|
136 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
137 if ( sp ) |
|
138 { |
|
139 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( |
|
140 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
141 if ( ( titlePaneResourceID > KErrNone ) && titlePane ) |
|
142 { |
|
143 HBufC* titlePaneText = NULL; |
|
144 titlePaneText = StringLoader::LoadLC( titlePaneResourceID ); |
|
145 titlePane->SetTextL( titlePaneText->Des() ); |
|
146 CleanupStack::PopAndDestroy( titlePaneText ); |
|
147 } |
|
148 } |
|
149 |
|
150 CEikButtonGroupContainer* cba = Cba(); |
|
151 if (cba) |
|
152 { |
|
153 TInt id = CbaResourceId( aPrevViewId, aCustomMessageId ); |
|
154 cba->SetCommandSetL( id ); |
|
155 cba->DrawDeferred(); |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CPslnBaseView::DoDeactivate |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CPslnBaseView::DoDeactivate() |
|
164 { |
|
165 if ( iContainer ) |
|
166 { |
|
167 iCurrentItem = iContainer->CurrentItemIndex(); |
|
168 RemoveContainer(); |
|
169 } |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CPslnBaseView::CreateContainerL() |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CPslnBaseView::CreateContainerL() |
|
177 { |
|
178 NewContainerL(); |
|
179 iContainer->SetMopParent( this ); |
|
180 |
|
181 CPslnBaseContainer* container = iContainer; |
|
182 iContainer = NULL; |
|
183 CleanupStack::PushL( container ); |
|
184 container->ConstructL( ClientRect() ); |
|
185 CleanupStack::Pop( container ); |
|
186 iContainer = container; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CPslnBaseView::SetNaviPaneL |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CPslnBaseView::SetNaviPaneL() |
|
194 { |
|
195 #ifndef RD_CONTROL_PANEL |
|
196 CAknNavigationControlContainer* naviPane = iPslnUi->NaviContainer(); |
|
197 if ( !naviPane ) |
|
198 { |
|
199 return; |
|
200 } |
|
201 if ( iNaviPaneContext ) |
|
202 { |
|
203 iPslnUi->NaviContainer()->PushL( *iNaviPaneContext ); |
|
204 |
|
205 if ( iNaviPaneContext == iPslnUi->PslnTabGroup() ) |
|
206 { |
|
207 iPslnUi->UpdateTabIndex(); |
|
208 } |
|
209 } |
|
210 else |
|
211 { |
|
212 iPslnUi->NaviContainer()->PushDefaultL(); |
|
213 } |
|
214 #else |
|
215 iPslnUi->NaviContainer()->PushDefaultL(); |
|
216 #endif //RD_CONTROL_PANEL |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // Sets middle softkey label. |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 void CPslnBaseView::SetMiddleSoftKeyLabelL( |
|
224 const TInt aResourceId, const TInt aCommandId ) |
|
225 { |
|
226 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
227 if ( cbaGroup ) |
|
228 { |
|
229 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
230 TPtr mskPtr = middleSKText->Des(); |
|
231 cbaGroup->AddCommandToStackL( |
|
232 KPslnMSKControlID, |
|
233 aCommandId, |
|
234 mskPtr ); |
|
235 CleanupStack::PopAndDestroy( middleSKText ); |
|
236 } |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // Removes Help if it is not supported. |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CPslnBaseView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
244 { |
|
245 if ( aResourceId == R_PSLN_BASIC_MENUPANE ) |
|
246 { |
|
247 if( !PslnFeatures::IsHelpSupported() ) |
|
248 { |
|
249 // Disable help if not supported |
|
250 aMenuPane->SetItemDimmed( EPslnCmdAppHelp, ETrue ); |
|
251 } |
|
252 } |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // Whether to set right softkey as exit |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 TInt CPslnBaseView::CbaResourceId(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/ ) |
|
260 { |
|
261 return R_AVKON_SOFTKEYS_OPTIONS_BACK; |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // Handle listbox stylus move event. |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CPslnBaseView::HandleListBoxStylusDown() |
|
269 { |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // Handle listbox stylus move event. |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void CPslnBaseView::HandleListBoxStylusDrag() |
|
277 { |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // Removes container. |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 void CPslnBaseView::RemoveContainer() |
|
285 { |
|
286 if ( iPslnUi ) |
|
287 { |
|
288 iPslnUi->RemoveFromStack( iContainer ); |
|
289 } |
|
290 delete iContainer; |
|
291 iContainer = NULL; |
|
292 } |
|
293 |
|
294 //End of File |
|