|
1 /* |
|
2 * Copyright (c) 2002 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: LandmarksUi Content File - Provides LM request container class methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include "CLmkBaseContainer.h" |
|
26 #include "MLmkKeyProcessor.h" |
|
27 #include "LmkUID.h" |
|
28 #include "LmkConsts.h" |
|
29 #include <aknViewAppUi.h> |
|
30 #include <aknnavide.h> |
|
31 #include <barsread.h> |
|
32 #include <akntabgrp.h> |
|
33 #include <eikmenub.h> |
|
34 #include "landmarks.hrh" |
|
35 #include <AknsUtils.h> |
|
36 #include <akntabgrp.h> |
|
37 #include <eikapp.h> |
|
38 #include <AknsSkinInstance.h> |
|
39 #include <f32file.h> |
|
40 #include <eikenv.h> |
|
41 #include <StringLoader.h> |
|
42 #include <eikenv.h> |
|
43 #include <aknViewAppUi.h> |
|
44 #include <apparc.h> |
|
45 #include "CLmkAppSelectorImplBase.h" |
|
46 #include <lmkerrors.h> |
|
47 #include "Debug.h" |
|
48 |
|
49 #if defined(_DEBUG) |
|
50 // CONSTANTS |
|
51 namespace { |
|
52 _LIT( KPanicText, "CLmkBaseContainer" ); |
|
53 |
|
54 void Panic( TPanicCode aReason ) |
|
55 { |
|
56 User::Panic( KPanicText, aReason ); |
|
57 } |
|
58 } // namespace |
|
59 #endif |
|
60 |
|
61 // ================= MEMBER FUNCTIONS ======================= |
|
62 // ---------------------------------------------------- |
|
63 // CLmkBaseContainer::CLmkBaseContainer |
|
64 // ---------------------------------------------------- |
|
65 // |
|
66 CLmkBaseContainer::CLmkBaseContainer( |
|
67 MLmkKeyProcessor& aKeyProcessor, |
|
68 const TDesC& aHelpContext ) |
|
69 :iKeyProcessor( aKeyProcessor ), |
|
70 iContextName( aHelpContext ) |
|
71 { |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------- |
|
75 // CLmkBaseContainer::BaseConstructL |
|
76 // ---------------------------------------------------- |
|
77 // |
|
78 void CLmkBaseContainer::BaseConstructL() |
|
79 { |
|
80 CEikStatusPane* sp = StatusPane(); |
|
81 // Fetch pointer to the default navi pane control |
|
82 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
83 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
84 } |
|
85 // ---------------------------------------------------- |
|
86 // CLmkBaseContainer::~CLmkBaseContainer |
|
87 // ---------------------------------------------------- |
|
88 // |
|
89 CLmkBaseContainer::~CLmkBaseContainer() |
|
90 { |
|
91 delete iSelector; |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CLmkBaseContainer::SelectorImpl() |
|
96 // ---------------------------------------------------------------------------- |
|
97 // |
|
98 CLmkAppSelectorImplBase& CLmkBaseContainer::SelectorImpl() |
|
99 { |
|
100 __ASSERT_DEBUG( iSelector, Panic( KLmkPanicNullMember ) ); |
|
101 return *iSelector; |
|
102 } |
|
103 // ---------------------------------------------------- |
|
104 // CLmkBaseContainer::ActivateTabL |
|
105 // ---------------------------------------------------- |
|
106 // |
|
107 void CLmkBaseContainer::ActivateTabL( |
|
108 CAknNavigationDecorator& aNaviDecorator, |
|
109 TInt aTabId ) |
|
110 { |
|
111 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
112 CAknNavigationControlContainer* naviPane = |
|
113 static_cast<CAknNavigationControlContainer*>( |
|
114 sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
115 CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( |
|
116 aNaviDecorator.DecoratedControl() ); |
|
117 tabGroup->SetActiveTabById( aTabId ); |
|
118 naviPane->PushL( aNaviDecorator ); |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------- |
|
122 // CLmkBaseContainer::GetHelpContext |
|
123 // ---------------------------------------------------- |
|
124 // |
|
125 void CLmkBaseContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
126 { |
|
127 aContext.iContext = iContextName; |
|
128 aContext.iMajor = TUid::Uid( KLmkAppUID3 ); |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------- |
|
132 // CLmkBaseContainer::OfferKeyEventL |
|
133 // ---------------------------------------------------- |
|
134 // |
|
135 TKeyResponse CLmkBaseContainer::OfferKeyEventL( |
|
136 const TKeyEvent& aKeyEvent, |
|
137 TEventCode aType ) |
|
138 { |
|
139 DEBUG( CLmkBaseContainer::OfferKeyEventL entered ); |
|
140 |
|
141 CAknNavigationDecorator* naviDecorator = NaviPane().Top(); |
|
142 |
|
143 // Check if navigation pane controls exists, because decorator does |
|
144 // not exist in every cases. |
|
145 if ( naviDecorator && naviDecorator->ControlType() == |
|
146 CAknNavigationDecorator::ETabGroup ) |
|
147 { |
|
148 if(aKeyEvent.iRepeats == 0) |
|
149 { |
|
150 if ( naviDecorator->DecoratedControl()->OfferKeyEventL( |
|
151 aKeyEvent, aType ) == EKeyWasConsumed ) |
|
152 { |
|
153 return EKeyWasConsumed; |
|
154 } |
|
155 } |
|
156 } |
|
157 |
|
158 if ( iKeyProcessor.ProcessKeyEventL( aKeyEvent, aType ) == |
|
159 EKeyWasConsumed ) |
|
160 { |
|
161 return EKeyWasConsumed; |
|
162 } |
|
163 |
|
164 if ( aType == EEventKey ) |
|
165 { |
|
166 TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) || |
|
167 (aKeyEvent.iModifiers & EModifierLeftShift) || |
|
168 (aKeyEvent.iModifiers & EModifierRightShift); |
|
169 |
|
170 if ( aKeyEvent.iCode == EKeyOK && !shiftKeyPressed && ContextSpecificMenuBar() ) |
|
171 { |
|
172 DEBUG( CLmkBaseContainer::OfferKeyEventL aKeyEvent.iCode == EKeyOK entered ); |
|
173 CEikMenuBar* menubar = MenuBar(); |
|
174 if ( menubar ) |
|
175 { |
|
176 menubar->SetMenuTitleResourceId( ContextSpecificMenuBar() ); |
|
177 menubar->StopDisplayingMenuBar(); |
|
178 TRAPD( err, menubar->TryDisplayMenuBarL() ); |
|
179 // set ordinary menubar back even in case of error |
|
180 menubar->SetMenuTitleResourceId( OptionsMenuBar() ); |
|
181 User::LeaveIfError( err ); |
|
182 } |
|
183 return EKeyWasConsumed; |
|
184 } |
|
185 if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter ) |
|
186 { |
|
187 TKeyEvent enterKeyEvent( aKeyEvent ); |
|
188 enterKeyEvent.iCode = EKeyOK; |
|
189 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
190 return cba->OfferKeyEventL( enterKeyEvent, aType ); |
|
191 } |
|
192 } |
|
193 |
|
194 for ( TInt i( 0 ); i < CountComponentControls(); ++i ) |
|
195 { |
|
196 if ( ComponentControl(i)->OfferKeyEventL( aKeyEvent, aType ) == |
|
197 EKeyWasConsumed ) |
|
198 { |
|
199 return EKeyWasConsumed; |
|
200 } |
|
201 } |
|
202 DEBUG( CLmkBaseContainer::OfferKeyEventL end ); |
|
203 return EKeyWasNotConsumed; |
|
204 } |
|
205 |
|
206 // ---------------------------------------------------- |
|
207 // CLmkBaseContainer::LmkAppUi |
|
208 // ---------------------------------------------------- |
|
209 // |
|
210 CAknViewAppUi* CLmkBaseContainer::ViewAppUi() |
|
211 { |
|
212 return static_cast<CAknViewAppUi*>( iAvkonAppUi ); |
|
213 } |
|
214 |
|
215 // ---------------------------------------------------- |
|
216 // CLmkBaseContainer::NaviPane |
|
217 // ---------------------------------------------------- |
|
218 // |
|
219 CAknNavigationControlContainer& CLmkBaseContainer::NaviPane() |
|
220 { |
|
221 // default navi pane should always exist: |
|
222 __ASSERT_DEBUG( iNaviPane, Panic( KLmkPanicNullNaviPane ) ); |
|
223 return *iNaviPane; |
|
224 } |
|
225 |
|
226 // ---------------------------------------------------- |
|
227 // CLmkBaseContainer::CreateNaviPaneL |
|
228 // ---------------------------------------------------- |
|
229 // |
|
230 CAknNavigationDecorator* CLmkBaseContainer::CreateNaviPaneL( |
|
231 TInt aResource ) |
|
232 { |
|
233 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
234 // Fetch pointer to the default navi pane control |
|
235 CAknNavigationControlContainer* naviPane = |
|
236 static_cast<CAknNavigationControlContainer*>(sp->ControlL( |
|
237 TUid::Uid(EEikStatusPaneUidNavi))); |
|
238 |
|
239 CAknNavigationDecorator* decorator = NULL; |
|
240 if ( aResource == KZeroResourceId ) // dummy tab |
|
241 { |
|
242 naviPane->PushDefaultL( EFalse ); |
|
243 } |
|
244 else |
|
245 { |
|
246 decorator = naviPane->CreateTabGroupL(iKeyProcessor.TabObserver()); |
|
247 decorator->SetControlType( CAknNavigationDecorator::ETabGroup ); |
|
248 CAknTabGroup* tabGroup = |
|
249 static_cast< CAknTabGroup* > ( decorator->DecoratedControl() ); |
|
250 AddTabsL( *tabGroup ); |
|
251 } |
|
252 return decorator; |
|
253 } |
|
254 |
|
255 // ---------------------------------------------------- |
|
256 // CLmkBaseContainer::StatusPane |
|
257 // ---------------------------------------------------- |
|
258 // |
|
259 CEikStatusPane* CLmkBaseContainer::StatusPane() |
|
260 { |
|
261 return iEikonEnv->AppUiFactory()->StatusPane(); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CLmkBaseContainer::MenuBar |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 CEikMenuBar* CLmkBaseContainer::MenuBar() |
|
269 { |
|
270 return NULL; |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // CLmkBaseContainer::ContextSpecificMenuBar |
|
275 // --------------------------------------------------------- |
|
276 // |
|
277 TInt CLmkBaseContainer::ContextSpecificMenuBar() |
|
278 { |
|
279 return 0; |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------- |
|
283 // CLmkBaseContainer::OptionsMenuBar |
|
284 // --------------------------------------------------------- |
|
285 // |
|
286 TInt CLmkBaseContainer::OptionsMenuBar() |
|
287 { |
|
288 return 0; |
|
289 } |
|
290 |
|
291 // Code added by gaurav fro Tab Icons -start- |
|
292 // ---------------------------------------------------- |
|
293 // CLmkBaseContainer::AddTabsL |
|
294 // ---------------------------------------------------- |
|
295 // |
|
296 void CLmkBaseContainer::AddTabsL(CAknTabGroup& aTabGroup) |
|
297 { |
|
298 aTabGroup.SetTabFixedWidthL(EAknTabWidthWithTwoTabs); |
|
299 |
|
300 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
301 HBufC* filename = GetBitmapFilenameLC(); |
|
302 CFbsBitmap* bitmap = NULL; |
|
303 CFbsBitmap* bitmapMask = NULL; |
|
304 |
|
305 //Add tab icon 1 |
|
306 AknsUtils::CreateIconLC( skin, |
|
307 KAknsIIDQgnPropLmNamesTab2, |
|
308 bitmap, |
|
309 bitmapMask, |
|
310 *filename, |
|
311 EMbmLandmarksQgn_prop_lm_names_tab2, |
|
312 EMbmLandmarksQgn_prop_lm_names_tab2_mask ); |
|
313 aTabGroup.AddTabL( ELmkByLmView, bitmap, bitmapMask ); //ELmkByLmView |
|
314 CleanupStack::Pop(2); //bitmap, bitmapmask |
|
315 |
|
316 |
|
317 //Add tab icon 2 |
|
318 AknsUtils::CreateIconLC( skin, |
|
319 KAknsIIDQgnPropLmCategoriesTab2, |
|
320 bitmap, |
|
321 bitmapMask, |
|
322 *filename, |
|
323 EMbmLandmarksQgn_prop_lm_categories_tab2, |
|
324 EMbmLandmarksQgn_prop_lm_categories_tab2_mask ); |
|
325 aTabGroup.AddTabL(ELmkByCategoryView, bitmap, bitmapMask ); // ELmkByCategoryView |
|
326 CleanupStack::Pop(2); //bitmap, bitmapmask |
|
327 |
|
328 CleanupStack::PopAndDestroy(); //filename |
|
329 } |
|
330 |
|
331 // ---------------------------------------------------------------------------- |
|
332 // CLmkBaseContainer::GetBitmapFilenameL |
|
333 // ---------------------------------------------------------------------------- |
|
334 // |
|
335 HBufC* CLmkBaseContainer::GetBitmapFilenameLC() |
|
336 { |
|
337 |
|
338 TBuf<2> aApp; |
|
339 CEikAppUi *appUi = (CEikAppUi *)(iCoeEnv->AppUi()); |
|
340 TFileName* full = new( ELeave ) TFileName; |
|
341 CleanupStack::PushL( full ); |
|
342 *full = appUi->Application()->AppFullName(); |
|
343 TParsePtr ptr(*full); |
|
344 aApp.Copy(ptr.Drive()); |
|
345 |
|
346 // Path and file name: |
|
347 TFileName* file = new( ELeave ) TFileName; |
|
348 CleanupStack::PushL( file ); |
|
349 file->Append( KLmkSystemMbmPath ); // always safe |
|
350 file->Append( KLandmarksIconFileName ); // always safe |
|
351 |
|
352 // Add drive to path & file name: |
|
353 TParse* parse = new(ELeave) TParse; |
|
354 CleanupStack::PushL( parse ); |
|
355 User::LeaveIfError( parse->Set( *file, &aApp, NULL ) ); |
|
356 HBufC* retFileName = parse->FullName().AllocLC(); |
|
357 CleanupStack::Pop();//retFileName |
|
358 CleanupStack::PopAndDestroy(3); |
|
359 CleanupStack::PushL( retFileName ); |
|
360 return retFileName; |
|
361 } |
|
362 |
|
363 // --------------------------------------------------------- |
|
364 // CLmkBaseContainer::ResolveMskDisplayItem() |
|
365 // --------------------------------------------------------- |
|
366 // |
|
367 TLmkMskDispItem CLmkBaseContainer::ResolveMskDisplayItem() |
|
368 { |
|
369 TLmkMskDispItem dispItem = ELabel; |
|
370 if (iSearchInitiated && (!SelectorImpl().ListVisibleItemCount())) |
|
371 { |
|
372 dispItem = ENoMsk; |
|
373 } |
|
374 else |
|
375 { |
|
376 const CArrayFix<TInt>* markedIndexes = NULL; |
|
377 markedIndexes = SelectorImpl().MarkedIndexes(); |
|
378 if(markedIndexes->Count() > 0 || |
|
379 !SelectorImpl().ListVisibleItemCount()) |
|
380 { |
|
381 dispItem = EContextMenu; |
|
382 } |
|
383 } |
|
384 |
|
385 return dispItem; |
|
386 } |
|
387 |
|
388 #ifdef RD_SCALABLE_UI_V2 |
|
389 // --------------------------------------------------------- |
|
390 // CLmkBaseContainer::SetListBoxObserver() |
|
391 // --------------------------------------------------------- |
|
392 // |
|
393 void CLmkBaseContainer::SetListBoxObserver(MEikListBoxObserver* /*aObserver*/) |
|
394 { |
|
395 //Since CLmkCategorySettingsContainer is directly derived from |
|
396 // CLmkBaseContainer, is the reason this function is made virtual |
|
397 //in this class. Most of the other container classes are derived |
|
398 //from CLmkLbWithFilterContainer, which is derived from CLmkBaseContainer, |
|
399 //hence there will be two overriding of this function, |
|
400 //1. In CLmkCategorySettingsContainer |
|
401 //2. In CLmkLbWithFilterContainer |
|
402 //since both the above classes holds the CEikListBox member, where the |
|
403 //observer needs to be set. |
|
404 } |
|
405 #endif//RD_SCALABLE_UI_V2 |
|
406 // End of File |