|
1 /* |
|
2 * Copyright (c) 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: Application UI class |
|
15 * Version : %version: MM_176.1.28.1.52 % << Don't touch! Updated by Synergy at check-out. |
|
16 * Version : %version: MM_176.1.28.1.52 % << Don't touch! Updated by Synergy at check-out. |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <e32cmn.h> |
|
22 #include <avkon.hrh> |
|
23 #include <avkon.rsg> |
|
24 #include <akntitle.h> |
|
25 #include <eikmenub.h> |
|
26 #include <akntoolbar.h> |
|
27 #include <aknbutton.h> |
|
28 #include <e32hashtab.h> |
|
29 #include <layoutmetadata.cdl.h> |
|
30 #include <gulicon.h> |
|
31 #include <fbs.h> |
|
32 #include <eikcmbut.h> |
|
33 #include <hlplch.h> |
|
34 #include <aknlists.h> |
|
35 #include <StringLoader.h> |
|
36 #include <activeidle2domainpskeys.h> |
|
37 #include <UikonInternalPSKeys.h> |
|
38 #include <e32property.h> |
|
39 #include <AknTaskList.h> |
|
40 #include <AknSgcc.h> // for transition effects |
|
41 #include <featmgr.h> |
|
42 #include <matrixmenu.rsg> |
|
43 #include <akntabgrp.h> |
|
44 #include <apgcli.h> |
|
45 #include <hwrmdomainpskeys.h> //flip status enums |
|
46 #include <AknDef.hrh> |
|
47 #include <AknDlgShut.h> |
|
48 #include <mmenuinternalPSkeys.h> |
|
49 #include <aknstyluspopupmenu.h> //stylus popup for long tap event |
|
50 |
|
51 #include "mmgui.hrh" |
|
52 #include "mmguiconstants.h" |
|
53 #include "mmappui.h" |
|
54 #include "menudebug.h" |
|
55 #include "hnengine.h" |
|
56 #include "hnglobals.h" |
|
57 #include "hnsuitemodelcontainer.h" |
|
58 #include "hnmenuitemmodel.h" |
|
59 #include "hntoolbarmodel.h" |
|
60 #include "hnbuttonmodel.h" |
|
61 #include "hnitemmodel.h" |
|
62 #include "hnconvutils.h" |
|
63 #include "hnsuitemodel.h" |
|
64 #include "hnmdbasekey.h" |
|
65 #include "hnmdkeyfactory.h" |
|
66 #include "mmwidgetcontainer.h" |
|
67 #include "mmtemplatelibrary.h" |
|
68 #include "mmextensionmanager.h" |
|
69 #include "mmpropertysubscriber.h" |
|
70 #include "hnitemsorder.h" |
|
71 |
|
72 #include "mmnomemory.h" |
|
73 #include "mmappkeyhandler.h" |
|
74 |
|
75 enum TMenuTransEffectContext |
|
76 { |
|
77 EMenuOpenFolderEffect = 1001, |
|
78 EMenuCloseFolderEffect = 1002 |
|
79 }; |
|
80 |
|
81 // ============================ MEMBER FUNCTIONS ============================= |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CMmAppUi::ConstructL() |
|
88 { |
|
89 DEBUG(("_Mm_:CMmAppUi::ConstructL IN")); |
|
90 MMPERF(("Test Logger speed...")); |
|
91 MMPERF(("Test Logger speed - DONE")); |
|
92 MMPERF(("GO!")); |
|
93 |
|
94 //set matrix to be system app |
|
95 iEikonEnv->SetSystem( ETrue ); |
|
96 |
|
97 TInt appUiFlags = AknLayoutUtils::PenEnabled() ? |
|
98 EAknEnableSkin | EAknSingleClickCompatible : |
|
99 EAknEnableSkin | EAknEnableMSK; |
|
100 BaseConstructL( appUiFlags ); |
|
101 iAppUiFactory = CEikonEnv::Static()->AppUiFactory( *this ); |
|
102 ASSERT( iAppUiFactory ); |
|
103 |
|
104 FeatureManager::InitializeLibL(); |
|
105 iIsKastorEffectStarted = EFalse; |
|
106 StartLayoutSwitchFullScreen( AknTransEffect::EApplicationStart ); |
|
107 |
|
108 RefreshUiPanesL( ETrue ); |
|
109 Cba()->MakeVisible( EFalse ); |
|
110 StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
111 |
|
112 iDummyTemplateLib = CMmTemplateLibrary::NewL(); |
|
113 iDummyContainer = CMmWidgetContainer::NewGridContainerL( ClientRect(), |
|
114 this, iDummyTemplateLib ); |
|
115 iDummyContainer->SetEmptyTextL( KNullDesC ); |
|
116 AddToStackL( iDummyContainer, ECoeStackPriorityDefault, |
|
117 ECoeStackFlagRefusesFocus | ECoeStackFlagRefusesAllKeys ); |
|
118 iDummyContainer->MakeVisible( ETrue ); |
|
119 iDummyContainer->DrawNow(); |
|
120 |
|
121 iHNInterface = CHnEngine::NewL( *this ); |
|
122 iTemplateLibrary = CMmTemplateLibrary::NewL(); |
|
123 InitializeL(); |
|
124 |
|
125 iMmExtManager = CMMExtensionManager::NewL( *this ); |
|
126 |
|
127 iKeyboardFlipStatus = EPSHWRMFlipStatusUninitialized; |
|
128 iSliderEventSubscriber = CMmPropertySubscriber::NewL(KPSUidHWRM, |
|
129 KHWRMFlipStatus, *this); |
|
130 |
|
131 iScreenOn = ETrue; |
|
132 iSkinChangeNeeded = EFalse; |
|
133 iSkinChangeInProgress = EFalse; |
|
134 iHasFocus = ETrue; |
|
135 |
|
136 iSkinSrvSession.Connect(this); |
|
137 iAppkeyHandler = CMmAppkeyHandler::NewL(); |
|
138 iOptionsMenuIsOpen = EFalse; |
|
139 |
|
140 RProperty::Define( KMMenuPSCat, KMMenuLastViewKey, RProperty::EText ); |
|
141 |
|
142 MMPERF(("CMmAppUi::ConstructL - HN ready")); |
|
143 DEBUG(("_Mm_:CMmAppUi::ConstructL OUT")); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 TBool CMmAppUi::IsRootdisplayedL() |
|
151 { |
|
152 TBool ret( EFalse ); |
|
153 if( iHNInterface && iHNInterface->GetSuiteModelsCountL() == KModelCountForRoot ) |
|
154 { |
|
155 ret = ETrue; |
|
156 } |
|
157 return ret; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 CMmAppUi::CMmAppUi() |
|
165 { |
|
166 // No implementation required |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 CMmAppUi::~CMmAppUi() |
|
174 { |
|
175 DEBUG(("_Mm_:CMmAppUi::~CMmAppUi IN")); |
|
176 |
|
177 delete iOutOfMemoryHandler; |
|
178 if (iCurrentSuiteModel) |
|
179 { |
|
180 iCurrentSuiteModel->UnregisterSuiteObserver( this ); |
|
181 } |
|
182 delete iToolbar; |
|
183 iCascadeMenuMap.Close(); |
|
184 RemoveFromStack( iCurrentContainer ); |
|
185 RemoveFromStack( iDummyContainer ); |
|
186 iDummyContainer->MakeVisible( EFalse ); |
|
187 delete iDummyContainer; |
|
188 ResetContainerMap(); |
|
189 iGarbage.ResetAndDestroy(); |
|
190 delete iHNInterface; |
|
191 FeatureManager::UnInitializeLib(); |
|
192 delete iMmExtManager; |
|
193 delete iSliderEventSubscriber; |
|
194 delete iTemplateLibrary; |
|
195 delete iDummyTemplateLib; |
|
196 delete iAppkeyHandler; |
|
197 delete iPopupMenu; |
|
198 iSkinSrvSession.Close(); |
|
199 |
|
200 MMPERF(("Matrix closed")); |
|
201 DEBUG(("_Mm_:CMmAppUi::~CMmAppUi OUT")); |
|
202 |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CMmAppUi::HandleResourceChangeL( TInt aType ) |
|
210 { |
|
211 CAknAppUi::HandleResourceChangeL( aType ); |
|
212 |
|
213 //we're interested in layout change events |
|
214 //only if container is available |
|
215 if ( aType == KEikDynamicLayoutVariantSwitch && |
|
216 iCurrentContainer && iCurrentSuiteModel ) |
|
217 { |
|
218 MMPERF(("Layout change START")); |
|
219 // Do not call StartLayoutSwitchFullScreen(), |
|
220 // layout switch effect is started automatically |
|
221 iIsKastorEffectStarted = ETrue; |
|
222 TInt lastItemIndex = iCurrentContainer->NumberOfItems() - 1; |
|
223 |
|
224 TBool makeLastItemVisible = lastItemIndex >= 0 && |
|
225 iCurrentContainer->ItemIsFullyVisible( lastItemIndex ); |
|
226 |
|
227 iCurrentContainer->SetRect( ClientRect() ); |
|
228 iDummyContainer->SetRect( ClientRect() ); |
|
229 |
|
230 // This fixes a problem (view scrolled one row up) that occurs when |
|
231 // switching from portrait to landscape orientation with scrollbar |
|
232 // in bottom position. |
|
233 if ( makeLastItemVisible ) |
|
234 { |
|
235 iCurrentContainer->Widget()->View()->SetTopItemIndex( |
|
236 iCurrentContainer->Widget()->View()-> |
|
237 CalcNewTopItemIndexSoItemIsVisible( lastItemIndex ) ); |
|
238 } |
|
239 |
|
240 THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap ); |
|
241 while( iterator.NextKey() ) |
|
242 { |
|
243 CMmWidgetContainer* container = *iterator.CurrentValue(); |
|
244 if ( container != iCurrentContainer ) |
|
245 { |
|
246 container->SetRect( ClientRect() ); |
|
247 container->HandleResourceChange( aType ); |
|
248 } |
|
249 } |
|
250 ShowSuiteL(); |
|
251 EndFullScreen(); |
|
252 MMPERF(("Layout change END")); |
|
253 } |
|
254 |
|
255 if ( aType == KEikMessageFadeAllWindows && iCurrentContainer ) |
|
256 { |
|
257 iCurrentContainer->SetIsFaded( ETrue ); |
|
258 } |
|
259 else if ( aType == KEikMessageUnfadeWindows && iCurrentContainer ) |
|
260 { |
|
261 iCurrentContainer->SetIsFaded( EFalse ); |
|
262 } |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 TBool CMmAppUi::ProcessCommandParametersL( TApaCommand aCommand, |
|
270 TFileName& aDocumentName, |
|
271 const TDesC8& aTail ) |
|
272 { |
|
273 DEBUG(("_Mm_:CMmAppUi::ProcessCommandParametersL IN")); |
|
274 DEBUG8(("\t_Mm_:tail: %S", &aTail)); |
|
275 |
|
276 if ( aTail.Length() ) |
|
277 { |
|
278 DEBUG(("\t_Mm_:call HandleMessageL")); |
|
279 HandleMessageL( aTail ); |
|
280 } |
|
281 |
|
282 TBool result = CEikAppUi::ProcessCommandParametersL( aCommand, |
|
283 aDocumentName, |
|
284 aTail ); |
|
285 |
|
286 MMPERF(("Matrix started and ready!")); |
|
287 DEBUG(("_Mm_:CMmAppUi::ProcessCommandParametersL OUT")); |
|
288 return result; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CMmAppUi::ProcessCommandL(TInt aCommand) |
|
296 { |
|
297 TBool ignoreCommand = EFalse; |
|
298 |
|
299 // ignore options click in edit mode and intermediate states for non-touch |
|
300 if ( aCommand == EAknSoftkeyOptions && iEditModeStatus != ENoEditMode && |
|
301 !AknLayoutUtils::PenEnabled() ) |
|
302 { |
|
303 ignoreCommand = ETrue; |
|
304 } |
|
305 |
|
306 // ignore keyselect for non-touch while in edit mode or stopping edit mode |
|
307 if ( aCommand == KKeyIdSelect && !AknLayoutUtils::PenEnabled() && |
|
308 ( iEditModeStatus == ETransitionFromEditMode || IsEditMode() ) ) |
|
309 { |
|
310 ignoreCommand = ETrue; |
|
311 } |
|
312 |
|
313 if ( !ignoreCommand ) |
|
314 { |
|
315 CAknAppUi::ProcessCommandL( aCommand ); |
|
316 } |
|
317 |
|
318 if (iCurrentContainer && iCurrentContainer == TopFocusedControl() ) |
|
319 { |
|
320 iCurrentContainer->HandleTopFocusL(); |
|
321 } |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 void CMmAppUi::ProcessMessageL( TUid /*aUid*/, const TDesC8& aParams ) |
|
329 { |
|
330 DEBUG(("_Mm_:CMmAppUi::ProcessMessageL IN")); |
|
331 DEBUG8(("\t_Mm_:params: %S", &aParams)); |
|
332 MMPERF(("APA Message Recieved")); |
|
333 |
|
334 // fix for the CR 417-35490 |
|
335 // Handle empty message sends by AVKON after app key press or switch |
|
336 // to Menu via task swapper. |
|
337 if( !aParams.Compare( KNullDesC8 ) ) |
|
338 { |
|
339 if ( !iAppkeyHandler->IsActive() ) |
|
340 { |
|
341 CleanupForExitL( EExitKeyApplication ); |
|
342 User::LeaveIfError( iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( |
|
343 CEikonEnv::Static()->RootWin().Identifier(), 0 ) ); |
|
344 iAppkeyHandler->StartL(); |
|
345 } |
|
346 } |
|
347 |
|
348 // first refresh model, show afterwords |
|
349 if ( aParams.Length() ) |
|
350 { |
|
351 DEBUG(("\t_Mm_:call HandleMessageL")); |
|
352 HandleMessageL( aParams ); |
|
353 } |
|
354 |
|
355 MMPERF(("APA Message Processed")); |
|
356 DEBUG(("_Mm_:CMmAppUi::ProcessMessageL OUT")); |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 MCoeMessageObserver::TMessageResponse CMmAppUi::HandleMessageL( |
|
364 TUint32 aClientHandleOfTargetWindowGroup, |
|
365 TUid aMessageUid, |
|
366 const TDesC8& aMessageParameters ) |
|
367 { |
|
368 if ( aMessageUid.iUid == KUidApaMessageSwitchOpenFileValue ) |
|
369 { |
|
370 ProcessMessageL( aMessageUid, aMessageParameters ); |
|
371 return EMessageHandled; |
|
372 } |
|
373 else |
|
374 { |
|
375 return CAknAppUi::HandleMessageL( |
|
376 aClientHandleOfTargetWindowGroup, |
|
377 aMessageUid, |
|
378 aMessageParameters ); |
|
379 } |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CMmAppUi::HandleCommandL( TInt aCommand ) |
|
387 { |
|
388 DEBUG(("_Mm_:CMmAppUi::HandleCommandL IN")); |
|
389 DEBUG(("\t_Mm_:aCommand: %d",aCommand)); |
|
390 |
|
391 // in case something has gone wrong |
|
392 ClearTransitionFromEditModeFlag(); |
|
393 |
|
394 switch( aCommand ) |
|
395 { |
|
396 case EEikCmdExit: |
|
397 { |
|
398 DEBUG(("\t_Mm_:EEikCmdExit")); |
|
399 // Simply exit |
|
400 Exit(); |
|
401 } |
|
402 break; |
|
403 |
|
404 case EMmOptionsExit: |
|
405 { |
|
406 MMPERF(("Options->Exit pressed")); |
|
407 DEBUG(("\t_Mm_:EMmOptionsExit")); |
|
408 |
|
409 //Check if it is a folder suite.If Yes really exit. |
|
410 //Otherwise behave like LSK. |
|
411 if( iCurrentSuiteModel && |
|
412 iCurrentSuiteModel->SuiteName().Compare( KFolderSuite) ) |
|
413 { |
|
414 if( iCurrentSuiteModel->ExitMode() == EExitModeHide ) |
|
415 { |
|
416 // hide and reset menu |
|
417 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
418 TApaTask me = taskList.FindApp( KUidMatrixMenuApp ); |
|
419 me.SendToBackground(); |
|
420 CleanupForExitL( EExitKeyApplication ); |
|
421 } |
|
422 else |
|
423 { |
|
424 StartLayoutSwitchFullScreen( EMenuCloseFolderEffect ); |
|
425 HandleBackCommandL(); |
|
426 } |
|
427 } |
|
428 else |
|
429 { |
|
430 ExitMatrix( EExitReally ); |
|
431 } |
|
432 } |
|
433 break; |
|
434 |
|
435 case EAknSoftkeyExit: |
|
436 { |
|
437 MMPERF(("SoftkeyExit pressed")); |
|
438 DEBUG(("\t_Mm_:EAknSoftkeyExit")); |
|
439 ExitMatrix( EExitToPhone ); |
|
440 } |
|
441 break; |
|
442 |
|
443 case EAknSoftkeyBack: |
|
444 { |
|
445 StartLayoutSwitchFullScreen( EMenuCloseFolderEffect ); |
|
446 |
|
447 if( iCurrentSuiteModel && iCurrentSuiteModel->ExitMode() == EExitModeHide ) |
|
448 { |
|
449 // hide and reset menu |
|
450 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
451 TApaTask me = taskList.FindApp( KUidMatrixMenuApp ); |
|
452 me.SendToBackground(); |
|
453 if ( iCurrentContainer ) |
|
454 { |
|
455 iCurrentContainer->MakeVisible( EFalse ); |
|
456 } |
|
457 iDummyContainer->MakeVisible( ETrue ); |
|
458 RefreshCbaL(); |
|
459 iDummyContainer->DrawNow(); |
|
460 CleanupForExitL( EExitKeyApplication ); |
|
461 } |
|
462 else if( iCurrentSuiteModel ) |
|
463 { |
|
464 HandleBackCommandL(); |
|
465 } |
|
466 } |
|
467 break; |
|
468 |
|
469 case EAknSoftkeyOk: |
|
470 case EAknSoftkeyDone: |
|
471 { |
|
472 ASSERT( IsEditMode() ); |
|
473 SetEditModeL( EFalse ); |
|
474 } |
|
475 break; |
|
476 default: |
|
477 { |
|
478 ForwardEventToHNL( aCommand ); |
|
479 } |
|
480 break; |
|
481 } |
|
482 DEBUG(("_Mm_:CMmAppUi::HandleCommandL OUT")); |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 // --------------------------------------------------------------------------- |
|
488 // |
|
489 void CMmAppUi::HandleBackCommandL() |
|
490 { |
|
491 DEBUG(("_Mm_:CMmAppUi::HandleBackCommandL IN")); |
|
492 MMPERF(("CMmAppUi::HandleBackCommandL - START")); |
|
493 DEBUG16(("\t_Mm_:current genre: %S",&iCurrentSuiteModel->SuiteName())); |
|
494 |
|
495 iDummyContainer->MakeVisible( ETrue ); |
|
496 RefreshUiPanesL( ETrue ); |
|
497 iCurrentContainer->MakeVisible( EFalse ); |
|
498 iDummyContainer->DrawNow(); |
|
499 |
|
500 iHNInterface->HandleBackEventL( iCurrentSuiteModel->SuiteName() ); |
|
501 |
|
502 MMPERF(("CMmAppUi::HandleBackCommandL - DONE")); |
|
503 DEBUG(("_Mm_:CMmAppUi::HandleBackCommandL OUT")); |
|
504 } |
|
505 |
|
506 // --------------------------------------------------------------------------- |
|
507 // |
|
508 // --------------------------------------------------------------------------- |
|
509 // |
|
510 CMmWidgetContainer* CMmAppUi::GetAppropriateContainerToLoadL() |
|
511 { |
|
512 CMmWidgetContainer* retContainer = NULL; |
|
513 if ( iCurrentSuiteModel ) |
|
514 { |
|
515 TInt currentSuiteId = iCurrentSuiteModel->GetItemsOrder()->GetSuiteId(); |
|
516 |
|
517 CMmWidgetContainer** ret = iContainerMap.Find( currentSuiteId ); |
|
518 retContainer = (ret) ? *ret : NULL; |
|
519 |
|
520 if ( ret && (*ret)->WidgetType() != iCurrentSuiteModel->WidgetType() ) |
|
521 { |
|
522 iMakeHightlightedItemFullyVisible = ETrue; |
|
523 iGarbage.AppendL( *ret ); |
|
524 iContainerMap.Remove( |
|
525 iCurrentSuiteModel->GetItemsOrder()->GetSuiteId() ); |
|
526 retContainer = NULL; |
|
527 } |
|
528 } |
|
529 return retContainer; |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 void CMmAppUi::ShowSuiteL() |
|
537 { |
|
538 DEBUG(("_Mm_:CMmAppUi::ShowSuiteL IN")); |
|
539 // DEBUG16(("\t_Mm_:current genre: %S", &iCurrentSuiteModel->SuiteName())); |
|
540 |
|
541 if ( iCurrentSuiteModel ) |
|
542 { |
|
543 CMmWidgetContainer* containerToLoad = GetAppropriateContainerToLoadL(); |
|
544 TBool makeHandlePresentationChange( ETrue ); |
|
545 |
|
546 if (!containerToLoad) |
|
547 { |
|
548 makeHandlePresentationChange = CreateNewContainerL( |
|
549 iCurrentSuiteModel, containerToLoad ); |
|
550 } |
|
551 |
|
552 if( makeHandlePresentationChange ) |
|
553 { |
|
554 HandlePresentationChangeL( containerToLoad ); |
|
555 } |
|
556 } |
|
557 |
|
558 DEBUG(("_Mm_:CMmAppUi::ShowSuiteL OUT")); |
|
559 } |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 TBool CMmAppUi::CreateNewContainerL( |
|
566 CHnSuiteModel* aSuiteModel, CMmWidgetContainer*& aContainerToLoad ) |
|
567 { |
|
568 TRect rect = ClientRect(); |
|
569 switch( aSuiteModel->WidgetType() ) |
|
570 { |
|
571 case ECoverFlowWidget : |
|
572 case EGridWidget : |
|
573 aContainerToLoad = CMmWidgetContainer::NewGridContainerL( |
|
574 rect, this, iTemplateLibrary ); |
|
575 break; |
|
576 case EListWidget : |
|
577 aContainerToLoad = CMmWidgetContainer::NewListBoxContainerL( |
|
578 rect, this, iTemplateLibrary ); |
|
579 break; |
|
580 case EUnspecified: |
|
581 default: |
|
582 return EFalse; |
|
583 } |
|
584 aContainerToLoad->SetLongTapObserver(this); |
|
585 aContainerToLoad->HandleItemAdditionL(); |
|
586 iContainerMap.InsertL( |
|
587 aSuiteModel->GetItemsOrder()->GetSuiteId(), |
|
588 aContainerToLoad ); |
|
589 return ETrue; |
|
590 } |
|
591 |
|
592 // --------------------------------------------------------------------------- |
|
593 // |
|
594 // --------------------------------------------------------------------------- |
|
595 // |
|
596 void CMmAppUi::ForwardEventToHNL( TInt aEvent, TInt aItemId, |
|
597 CLiwGenericParamList* aEventParams ) |
|
598 { |
|
599 DEBUG(("\t_Mm_:event ID: %d for item ID %d", aEvent, aItemId)); |
|
600 |
|
601 TInt id = iCurrentSuiteModel->IdByIndex( aItemId ); |
|
602 if ( id >= 0 ) |
|
603 { |
|
604 MMPERF(("Handling event %d for item %d - START",aEvent,aItemId)); |
|
605 |
|
606 if( aEvent == KKeyIdSelect ) |
|
607 { |
|
608 MMPERF(("This is a 'select' event")); |
|
609 |
|
610 TInt modelId = iCurrentSuiteModel->IdByIndex( aItemId ); |
|
611 CHnItemModel* itemModel = |
|
612 iCurrentSuiteModel->GetItemModel( modelId ); |
|
613 TInt effect = GetKastorEffectL( itemModel ); |
|
614 TRect rect = GetKastorRectL( itemModel, aItemId ); |
|
615 TUid appUid = itemModel->GetItemType() == EItemTypeApplication ? |
|
616 itemModel->GetItemUid() : KUidMatrixMenuApp; |
|
617 |
|
618 if (iScreenOn && IsForeground() && effect |
|
619 != AknTransEffect::ENone) |
|
620 { |
|
621 DEBUG(("_MM_:CMmAppUi::ForwardEventToHNL Foreground")); |
|
622 GfxTransEffect::BeginFullScreen( |
|
623 effect, rect, |
|
624 AknTransEffect::EParameterType, |
|
625 AknTransEffect::GfxTransParam( appUid ) ); |
|
626 } |
|
627 } |
|
628 |
|
629 iHNInterface->TriggerHnEventL( aEvent, id, aEventParams ); |
|
630 MMPERF(("Handling event - END")); |
|
631 } |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 TInt CMmAppUi::GetKastorEffectL( CHnItemModel* aItemModel ) |
|
639 { |
|
640 TInt effect( AknTransEffect::ENone ); |
|
641 if ((IsEditMode() || iEditModeStatus == ETransitionFromEditMode) |
|
642 && !AknLayoutUtils::PenEnabled()) |
|
643 { |
|
644 return effect; |
|
645 } |
|
646 switch( aItemModel->GetItemType() ) |
|
647 { |
|
648 case EItemTypeApplication: |
|
649 { |
|
650 if( !IsEditMode() && !aItemModel->IsDrmExpired() ) |
|
651 { |
|
652 if( aItemModel->IsRunning() ) |
|
653 { |
|
654 effect = AknTransEffect::EApplicationStartSwitchRect; |
|
655 } |
|
656 else |
|
657 { |
|
658 effect = AknTransEffect::EApplicationStartRect; |
|
659 } |
|
660 } |
|
661 break; |
|
662 } |
|
663 case EItemTypeSuite: |
|
664 { |
|
665 if( !IsEditMode() ) |
|
666 { |
|
667 effect = EMenuOpenFolderEffect; |
|
668 iIsKastorEffectStarted = ETrue; |
|
669 } |
|
670 break; |
|
671 } |
|
672 case EItemTypeParentFolder: |
|
673 { |
|
674 effect = EMenuCloseFolderEffect; |
|
675 iIsKastorEffectStarted = ETrue; |
|
676 break; |
|
677 } |
|
678 case EItemTypeFolder: |
|
679 { |
|
680 if (!(IsEditMode() && aItemModel->IsDeleteLocked())) |
|
681 { |
|
682 effect = EMenuOpenFolderEffect; |
|
683 iIsKastorEffectStarted = ETrue; |
|
684 } |
|
685 break; |
|
686 } |
|
687 case EItemTypeUnknown: |
|
688 default: |
|
689 { |
|
690 effect = AknTransEffect::ENone; |
|
691 break; |
|
692 } |
|
693 } |
|
694 return effect; |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 TRect CMmAppUi::GetKastorRectL( CHnItemModel* aItemModel, TInt aItemId ) |
|
702 { |
|
703 TRect rect = TRect(); |
|
704 if( aItemModel->GetItemType() == EItemTypeApplication ) |
|
705 { |
|
706 rect = iCurrentContainer->GetItemRectL( aItemId ); |
|
707 RRegion region; CleanupClosePushL( region ); |
|
708 StatusPane()->GetShapeL( region, true, true ); |
|
709 TInt statusPaneHeight = region.BoundingRect().Height(); |
|
710 rect.iBr.iY += statusPaneHeight; |
|
711 rect.iTl.iY += statusPaneHeight; |
|
712 CleanupStack::PopAndDestroy( ®ion ); |
|
713 } |
|
714 return rect; |
|
715 } |
|
716 |
|
717 // --------------------------------------------------------------------------- |
|
718 // |
|
719 // --------------------------------------------------------------------------- |
|
720 // |
|
721 void CMmAppUi::ForwardEventToHNL( TInt aEvent ) |
|
722 { |
|
723 DEBUG(("_Mm_:CMmAppUi::ForwardEventToHNL IN")); |
|
724 DEBUG(("\t_Mm_:event ID: %d", aEvent)); |
|
725 |
|
726 if ( iCurrentContainer ) |
|
727 { |
|
728 TBool idByContainer = iCurrentContainer->IsHighlightVisible() && |
|
729 iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1; |
|
730 TInt current = idByContainer ? |
|
731 iCurrentContainer->GetHighlight() : KErrNotFound; |
|
732 ForwardEventToHNL( aEvent, current ); |
|
733 } |
|
734 |
|
735 DEBUG(("_Mm_:CMmAppUi::ForwardEventToHNL OUT")); |
|
736 } |
|
737 |
|
738 // --------------------------------------------------------------------------- |
|
739 // |
|
740 // --------------------------------------------------------------------------- |
|
741 // |
|
742 void CMmAppUi::NotifyUiRefreshL( const THnUiRefreshType aRefreshType ) |
|
743 { |
|
744 DEBUG(("_Mm_:CMmAppUi::NotifyUiRefreshL IN")); |
|
745 DEBUG(("\t_Mm_:refresh type: %d", aRefreshType)); |
|
746 |
|
747 switch (aRefreshType) |
|
748 { |
|
749 case ERefreshSuite: |
|
750 TRAPD( err, ShowSuiteL() ); |
|
751 if ( KErrNoMemory == err ) |
|
752 { |
|
753 HandleOutOfMemoryL(); |
|
754 User::Leave( KErrNoMemory ); |
|
755 } |
|
756 break; |
|
757 case ERefreshToolbar: |
|
758 RefreshToolbarL(); |
|
759 break; |
|
760 case EStartEditMode: |
|
761 SetEditModeL( ETrue ); |
|
762 break; |
|
763 case EStopEditMode: |
|
764 SetEditModeL( EFalse ); |
|
765 break; |
|
766 case EZoomLarge: |
|
767 SetZoom( EAknUiZoomLarge ); |
|
768 break; |
|
769 case EZoomSmall: |
|
770 SetZoom( EAknUiZoomSmall ); |
|
771 break; |
|
772 case EZoomNormal: |
|
773 SetZoom( EAknUiZoomNormal ); |
|
774 break; |
|
775 case EForegroundGain: |
|
776 { |
|
777 DEBUG(("_MM_:CMmAppUi::NotifyUiRefreshL Foreground")); |
|
778 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
779 TApaTask me = taskList.FindApp( KUidMatrixMenuApp ); |
|
780 me.BringToForeground(); |
|
781 } |
|
782 break; |
|
783 case EBackgroundGain: |
|
784 { |
|
785 DEBUG(("_MM_:CMmAppUi::NotifyUiRefreshL Foreground")); |
|
786 TApaTaskList taskList( iCoeEnv->WsSession() ); |
|
787 TApaTask me = taskList.FindApp( KUidMatrixMenuApp ); |
|
788 me.SendToBackground(); |
|
789 } |
|
790 break; |
|
791 case ELightOn: |
|
792 { |
|
793 DEBUG(("_Mm_:CMmAppUi::NotifyUiRefreshL - ELightOn")); |
|
794 iScreenOn = ETrue; |
|
795 if ( IsForeground() && iCurrentSuiteModel ) |
|
796 { |
|
797 iCurrentSuiteModel->SetVisibleL( ETrue ); |
|
798 } |
|
799 if ( iCurrentContainer ) |
|
800 { |
|
801 iCurrentContainer->HandleForegroundGainedL(); |
|
802 } |
|
803 } |
|
804 break; |
|
805 case ELightOff: |
|
806 { |
|
807 DEBUG(("_Mm_:CMmAppUi::NotifyUiRefreshL - ELightOff")); |
|
808 iScreenOn = EFalse; |
|
809 if (iCurrentContainer) |
|
810 { |
|
811 iCurrentContainer->HandleBackgroundGainedL(); |
|
812 if (IsEditMode() && iCurrentContainer->IsDraggable()) |
|
813 { |
|
814 iCurrentContainer->CancelDragL(EFalse); |
|
815 } |
|
816 } |
|
817 if (iCurrentSuiteModel) |
|
818 { |
|
819 iCurrentSuiteModel->SetVisibleL(EFalse); |
|
820 } |
|
821 if( iMmExtManager ) |
|
822 { |
|
823 iMmExtManager->ExecuteActionL(TUid::Null(), KCommandDeleteDialog, NULL ); |
|
824 } |
|
825 } |
|
826 break; |
|
827 case ERemoveLiwObjects: |
|
828 { |
|
829 THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap ); |
|
830 while( iterator.NextKey() ) |
|
831 { |
|
832 CMmWidgetContainer** container = iterator.CurrentValue(); |
|
833 (*container)->RemoveLiwObjects(); |
|
834 } |
|
835 } |
|
836 break; |
|
837 default: |
|
838 ASSERT( false ); |
|
839 } |
|
840 DEBUG(("_Mm_:CMmAppUi::NotifyUiRefreshL OUT")); |
|
841 } |
|
842 |
|
843 // --------------------------------------------------------------------------- |
|
844 // |
|
845 // --------------------------------------------------------------------------- |
|
846 // |
|
847 void CMmAppUi::RefreshToolbarL() |
|
848 { |
|
849 DEBUG(("_Mm_:CMmAppUi::RefreshToolbarL IN")); |
|
850 HandleToolbarVisibilityL(); |
|
851 UpdateToolbarL(); |
|
852 DEBUG(("_Mm_:CMmAppUi::RefreshToolbarL OUT")); |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // |
|
857 // --------------------------------------------------------------------------- |
|
858 // |
|
859 void CMmAppUi::RefreshUiPanesL( TBool aReset ) |
|
860 { |
|
861 // refresh status pane |
|
862 CAknTitlePane* titlePane = |
|
863 static_cast<CAknTitlePane*>( |
|
864 StatusPane()->ControlL( |
|
865 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
866 |
|
867 if( aReset ) |
|
868 { |
|
869 titlePane->SetTextL( KNullDesC ); |
|
870 } |
|
871 else |
|
872 { |
|
873 if ( IsEditMode() && iCurrentSuiteModel ) |
|
874 { |
|
875 HBufC* title = NULL; |
|
876 if ( IsRootdisplayedL() ) |
|
877 { |
|
878 title = StringLoader::LoadLC( R_ORG_ROOT_EDITING_TITLE ); |
|
879 } |
|
880 else |
|
881 { |
|
882 title = StringLoader::LoadLC( |
|
883 R_ORG_FOLDER_EDITING_TITLE, |
|
884 iCurrentSuiteModel->Title() ); |
|
885 } |
|
886 ASSERT( title ); |
|
887 titlePane->SetTextL( title->Des() ); |
|
888 CleanupStack::PopAndDestroy( title ); |
|
889 } |
|
890 else if ( iCurrentSuiteModel && iCurrentContainer ) |
|
891 { |
|
892 // refresh status pane |
|
893 titlePane->SetTextL( iCurrentSuiteModel->Title() ); |
|
894 |
|
895 // inform AVKON about current suite to allow proper handling |
|
896 // of AppKey and FSW |
|
897 RProperty::Set( KMMenuPSCat, KMMenuLastViewKey, iCurrentSuiteModel->SuiteName() ); |
|
898 } |
|
899 else |
|
900 { |
|
901 titlePane->SetTextL( KNullDesC ); |
|
902 } |
|
903 } |
|
904 |
|
905 RefreshCbaL(); |
|
906 SetMiddleSoftKeyL(); |
|
907 |
|
908 StatusPane()->DrawNow(); |
|
909 Cba()->DrawNow(); |
|
910 } |
|
911 |
|
912 // --------------------------------------------------------------------------- |
|
913 // |
|
914 // --------------------------------------------------------------------------- |
|
915 // |
|
916 void CMmAppUi::RefreshCbaL() |
|
917 { |
|
918 if ( ( iDummyContainer && iDummyContainer->IsVisible() ) || |
|
919 !iCurrentSuiteModel ) |
|
920 { |
|
921 // R_MENU_SOFTKEYS_EMPTY__EMPTY looks much better than |
|
922 // R_AVKON_SOFTKEYS_EMPTY |
|
923 Cba()->SetCommandSetL( R_MENU_SOFTKEYS_EMPTY__EMPTY ); |
|
924 } |
|
925 else |
|
926 { |
|
927 if ( IsEditMode() ) |
|
928 { |
|
929 Cba()->SetCommandSetL( AknLayoutUtils::PenEnabled() ? |
|
930 R_AVKON_SOFTKEYS_OPTIONS_DONE : |
|
931 R_AVKON_SOFTKEYS_OK_EMPTY__OK ); |
|
932 } |
|
933 else if ( IsRootdisplayedL() ) |
|
934 { |
|
935 Cba()->SetCommandSetL( AknLayoutUtils::PenEnabled() ? |
|
936 R_AVKON_SOFTKEYS_OPTIONS_EXIT : |
|
937 R_AVKON_SOFTKEYS_OPTIONS_EXIT__SELECT ); |
|
938 } |
|
939 else if ( iCurrentSuiteModel && |
|
940 iCurrentSuiteModel->SuiteName().Compare(KParamFolderSuite) ) |
|
941 { |
|
942 Cba()->SetCommandSetL( AknLayoutUtils::PenEnabled() ? |
|
943 R_MENU_SOFTKEYS_OPTIONS_BEXIT : |
|
944 R_MENU_SOFTKEYS_OPTIONS_BEXIT__SELECT ); |
|
945 } |
|
946 else |
|
947 { |
|
948 Cba()->SetCommandSetL( AknLayoutUtils::PenEnabled() ? |
|
949 R_AVKON_SOFTKEYS_OPTIONS_BACK : |
|
950 R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT ); |
|
951 } |
|
952 } |
|
953 } |
|
954 |
|
955 // --------------------------------------------------------------------------- |
|
956 // |
|
957 // --------------------------------------------------------------------------- |
|
958 // |
|
959 TKeyResponse CMmAppUi::HandleKeyPressedL( const TKeyEvent &aKeyEvent, |
|
960 TEventCode aType ) |
|
961 { |
|
962 TKeyResponse resp = EKeyWasNotConsumed; |
|
963 |
|
964 // handling enter key - touch & non touch |
|
965 if ( ( aKeyEvent.iScanCode == EStdKeyEnter || |
|
966 aKeyEvent.iScanCode == EStdKeyNkpEnter || |
|
967 aKeyEvent.iScanCode == EStdKeyDevice3 ) && aType == EEventKeyDown ) |
|
968 { |
|
969 if ( iCurrentContainer->IsHighlightVisible() ) |
|
970 { |
|
971 DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - enter")); |
|
972 ForwardEventToHNL( KKeyIdSelect ); |
|
973 resp = EKeyWasConsumed; |
|
974 } |
|
975 } |
|
976 |
|
977 //handling enter key - non touch / edit mode |
|
978 if ( ( aKeyEvent.iScanCode == EStdKeyEnter || |
|
979 aKeyEvent.iScanCode == EStdKeyDevice3 ) && |
|
980 aType == EEventKeyDown && |
|
981 IsEditMode() && !Layout_Meta_Data::IsPenEnabled() ) |
|
982 { |
|
983 DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - enter in edit mode")); |
|
984 HandleCommandL( EAknSoftkeyOk ); |
|
985 resp = EKeyWasConsumed; |
|
986 } |
|
987 |
|
988 // handle the key exactly as container does (the same conditions) |
|
989 if ( ( aKeyEvent.iRepeats > 0 && aType == EEventKey ) || |
|
990 ( aKeyEvent.iRepeats == 0 && aType == EEventKeyUp ) ) |
|
991 { |
|
992 TBool navigationEvent = |
|
993 aKeyEvent.iScanCode == EStdKeyRightArrow || |
|
994 aKeyEvent.iScanCode == EStdKeyLeftArrow || |
|
995 aKeyEvent.iScanCode == EStdKeyUpArrow || |
|
996 aKeyEvent.iScanCode == EStdKeyDownArrow; |
|
997 |
|
998 if ( navigationEvent ) |
|
999 { |
|
1000 DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - navi event: %d", |
|
1001 aKeyEvent.iScanCode)); |
|
1002 MMPERF(("Rocker navigation - START")); |
|
1003 UpdateToolbarL(); |
|
1004 SetMiddleSoftKeyL(); |
|
1005 resp = EKeyWasConsumed; |
|
1006 MMPERF(("Rocker navigation - END")); |
|
1007 } |
|
1008 else if ( aKeyEvent.iScanCode == EStdKeyBackspace ) |
|
1009 { |
|
1010 // handle clear key event |
|
1011 DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - clear key")); |
|
1012 ForwardEventToHNL( KKeyIdClear ); |
|
1013 resp = EKeyWasConsumed; |
|
1014 } |
|
1015 } |
|
1016 |
|
1017 if( aType == EEventUser ) |
|
1018 { |
|
1019 if ( aKeyEvent.iScanCode == EStdKeyNull && |
|
1020 iCurrentContainer->IsHighlightVisible() ) |
|
1021 { |
|
1022 DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - User press -> forward key:select to HN")); |
|
1023 UpdateToolbarL(); |
|
1024 SetMiddleSoftKeyL(); |
|
1025 ForwardEventToHNL( KKeyIdSelect ); |
|
1026 resp = EKeyWasConsumed; |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 return resp; |
|
1031 } |
|
1032 |
|
1033 // ----------------------------------------------------------------------------- |
|
1034 // |
|
1035 // |
|
1036 // ----------------------------------------------------------------------------- |
|
1037 // |
|
1038 void CMmAppUi::HandleDragStartL( TInt aModelItemIndex ) |
|
1039 { |
|
1040 MMPERF(("CMmAppUi::HandleDragStartL - START")); |
|
1041 |
|
1042 if ( IsEditMode() ) |
|
1043 { |
|
1044 |
|
1045 TInt modelId = iCurrentSuiteModel->IdByIndex( aModelItemIndex ); |
|
1046 if (modelId != KErrNotFound) |
|
1047 { |
|
1048 CHnItemModel *itModel = iCurrentSuiteModel->GetItemModel( modelId ); |
|
1049 if (itModel->GetItemType() == EItemTypeParentFolder) |
|
1050 { |
|
1051 iCurrentContainer->CancelDragL( EFalse ); |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 iItemDragged = aModelItemIndex; |
|
1056 iIdDragged = iCurrentSuiteModel->IdByIndex( aModelItemIndex ); |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 MMPERF(("CMmAppUi::HandleDragStartL - STOP")); |
|
1061 } |
|
1062 |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // |
|
1065 // |
|
1066 // ----------------------------------------------------------------------------- |
|
1067 // |
|
1068 void CMmAppUi::HandleDragOverL( TInt /* aModelItemIndex */ ) |
|
1069 { |
|
1070 MMPERF(("CMmAppUi::HandleDragOverL - START")); |
|
1071 |
|
1072 MMPERF(("CMmAppUi::HandleDragOverL - STOP")); |
|
1073 } |
|
1074 |
|
1075 // ----------------------------------------------------------------------------- |
|
1076 // |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // |
|
1079 void CMmAppUi::HandleDraggedIndexUpdatedL( TInt aModelItemIndex ) |
|
1080 { |
|
1081 MMPERF(("CMmAppUi::HandleDraggedIndexUpdatedL - START")); |
|
1082 iItemDragged = aModelItemIndex; |
|
1083 MMPERF(("CMmAppUi::HandleDraggedIndexUpdatedL - STOP")); |
|
1084 } |
|
1085 |
|
1086 // ----------------------------------------------------------------------------- |
|
1087 // |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // |
|
1090 void CMmAppUi::HandleDragStopL( TInt aModelItemIndex ) |
|
1091 { |
|
1092 MMPERF(("CMmAppUi::HandleDragStopL - START")); |
|
1093 if ( IsEditMode() ) |
|
1094 { |
|
1095 TInt itemId = iCurrentSuiteModel->IdByIndex( aModelItemIndex ); |
|
1096 TMcsItemType typeCurr = |
|
1097 iCurrentSuiteModel->GetItemType( aModelItemIndex ); |
|
1098 TBool isOverFolder = ( AknLayoutUtils::PenEnabled() && |
|
1099 ( typeCurr == EItemTypeParentFolder || typeCurr == EItemTypeFolder ) ); |
|
1100 TBool isDeleteLocked = (itemId != KErrNotFound) ? |
|
1101 iCurrentSuiteModel->GetItemModel( itemId )->IsDeleteLocked(): |
|
1102 EFalse; |
|
1103 |
|
1104 TBuf8< KMaxLength > beforeCustomId; |
|
1105 beforeCustomId.Num( KErrNotFound ); |
|
1106 if ( aModelItemIndex + 1 < iCurrentContainer->NumberOfItems() ) |
|
1107 { |
|
1108 beforeCustomId.Num( iCurrentSuiteModel->GetItemModel( |
|
1109 iCurrentSuiteModel->IdByIndex( aModelItemIndex + 1 ) )->CustomId() ); |
|
1110 } |
|
1111 |
|
1112 TBuf8< KMaxLength > draggedCustomId; |
|
1113 draggedCustomId.Num( KErrNotFound ); |
|
1114 CHnItemModel* draggedModel = iCurrentSuiteModel->GetItemModel( iIdDragged ); |
|
1115 if (draggedModel) |
|
1116 { |
|
1117 draggedCustomId.Num( iCurrentSuiteModel->GetItemModel( iIdDragged )->CustomId() ); |
|
1118 } |
|
1119 |
|
1120 CLiwGenericParamList* eventParameters = CLiwGenericParamList::NewL(); |
|
1121 CleanupStack::PushL( eventParameters ); |
|
1122 CHnMdBaseKey* tempKeys = HnMdKeyFactory::CreateL( |
|
1123 HnEvent::KEventArgNamespace8(), KKeyTypeMap(), KNullDesC8() ); |
|
1124 CleanupStack::PushL( tempKeys ); |
|
1125 |
|
1126 CHnMdBaseKey* baseKey = HnMdKeyFactory::CreateL( |
|
1127 HnEvent::KEventArgNamespace8(), KKeyTypeMap(), KNullDesC8() ); |
|
1128 CleanupStack::PushL( baseKey ); |
|
1129 baseKey->AddSubKeyL( HnMdKeyFactory::CreateL( HnEvent::KDroppedBefore8(), |
|
1130 KKeyTypeInteger(), beforeCustomId ) ); |
|
1131 baseKey->AddSubKeyL( HnMdKeyFactory::CreateL( HnEvent::KDragged8(), |
|
1132 KKeyTypeInteger(), draggedCustomId ) ); |
|
1133 CleanupStack::Pop( baseKey ); |
|
1134 tempKeys->AddSubKeyL( baseKey ); |
|
1135 |
|
1136 tempKeys->ToGenericParamListL( *eventParameters ); |
|
1137 CleanupStack::PopAndDestroy( tempKeys ); |
|
1138 |
|
1139 if ( iIdDragged != itemId |
|
1140 && isOverFolder && !isDeleteLocked) |
|
1141 { |
|
1142 iCurrentSuiteModel->RemoveItemL( iIdDragged ); |
|
1143 if ( iItemDragged < aModelItemIndex ) |
|
1144 { |
|
1145 // indices of all items after iItemDragged have been |
|
1146 // decreased when the dragged item got removed from the |
|
1147 // current suite; prevent highlighted item change |
|
1148 iCurrentSuiteModel->SetSuiteHighlightL( aModelItemIndex - 1 ); |
|
1149 iCurrentContainer->SetManualHighlightL( |
|
1150 iCurrentContainer->GetHighlight() - 1, EFalse ); |
|
1151 } |
|
1152 |
|
1153 iCurrentContainer->HandleItemRemovalL(); |
|
1154 iCurrentContainer->CancelDragL( EFalse ); |
|
1155 |
|
1156 if( typeCurr == EItemTypeParentFolder ) |
|
1157 { |
|
1158 StartLayoutSwitchFullScreen( EMenuCloseFolderEffect ); |
|
1159 } |
|
1160 else |
|
1161 { |
|
1162 StartLayoutSwitchFullScreen( EMenuOpenFolderEffect ); |
|
1163 } |
|
1164 iHNInterface->TriggerHnEventL( KKeyIdMoveInto, itemId, eventParameters ); |
|
1165 iMakeHightlightedItemFullyVisible = ETrue; |
|
1166 } |
|
1167 else if ( iIdDragged == itemId ) |
|
1168 { |
|
1169 iCurrentContainer->CancelDragL( ETrue ); |
|
1170 TBool result = iHNInterface->TriggerHnEventL( KKeyIdMove, itemId, eventParameters ); |
|
1171 // fix for: edit->move, then LSK->Up->LSK->LSK FAST... (short options show up) |
|
1172 if ( result != KErrNone && !AknLayoutUtils::PenEnabled() ) |
|
1173 { |
|
1174 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
|
1175 TLiwGenericParam command(KHnRequest, TLiwVariant( KEvaluateMdModel)); |
|
1176 paramList->AppendL(command); |
|
1177 HandleRequestL(*paramList); |
|
1178 CleanupStack::PopAndDestroy(paramList); |
|
1179 } |
|
1180 } |
|
1181 else |
|
1182 { |
|
1183 iCurrentContainer->CancelDragL( ETrue ); |
|
1184 if (!AknLayoutUtils::PenEnabled()) |
|
1185 { |
|
1186 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
|
1187 TLiwGenericParam command(KHnRequest, TLiwVariant( KEvaluateMdModel)); |
|
1188 paramList->AppendL(command); |
|
1189 HandleRequestL(*paramList); |
|
1190 CleanupStack::PopAndDestroy(paramList); |
|
1191 } |
|
1192 } |
|
1193 |
|
1194 CleanupStack::PopAndDestroy( eventParameters ); |
|
1195 } |
|
1196 MMPERF(("CMmAppUi::HandleDragStopL - STOP")); |
|
1197 } |
|
1198 |
|
1199 // --------------------------------------------------------------------------- |
|
1200 // |
|
1201 // --------------------------------------------------------------------------- |
|
1202 // |
|
1203 void CMmAppUi::HandleEventDraggingActionedL() |
|
1204 { |
|
1205 SetMiddleSoftKeyL(); |
|
1206 UpdateToolbarL(); |
|
1207 iKeyClickLocked = ETrue; |
|
1208 } |
|
1209 // --------------------------------------------------------------------------- |
|
1210 // |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // |
|
1213 void CMmAppUi::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
1214 MEikListBoxObserver::TListBoxEvent aEventType ) |
|
1215 { |
|
1216 DEBUG(("_Mm_:CMmAppUi::HandleListBoxEventL IN")); |
|
1217 DEBUG(("\t_Mm_: aEventType = %d", (TInt) aEventType ) ); |
|
1218 |
|
1219 TInt currentHighlight = iCurrentContainer->GetHighlight(); |
|
1220 |
|
1221 DEBUG(("\t_Mm_: CurrentHighlight = %d", currentHighlight ) ); |
|
1222 |
|
1223 if ( aEventType == MEikListBoxObserver::EEventItemDraggingActioned ) |
|
1224 { |
|
1225 DEBUG8(("\t_Mm_:CMmAppUi::HandleListBoxEventL EEventItemDraggingActioned")); |
|
1226 HandleEventDraggingActionedL(); |
|
1227 } |
|
1228 else if ( aEventType == MEikListBoxObserver::EEventPenDownOnItem ) |
|
1229 { |
|
1230 DEBUG(("\t_Mm_:CMmAppUi::HandleListBoxEventL EEventItemClicked")); |
|
1231 HandleHighlightItemPenDownL( iCurrentContainer->GetHighlight() ); |
|
1232 } |
|
1233 else if ( aEventType == MEikListBoxObserver::EEventItemDoubleClicked ) |
|
1234 { |
|
1235 DEBUG(("\t_Mm_:CMmAppUi::HandleListBoxEventL EEventItemDoubleClicked")); |
|
1236 HandleHighlightItemDoubleClickedL( iCurrentContainer->GetHighlight() ); |
|
1237 } |
|
1238 else if ( aEventType == MEikListBoxObserver::EEventItemSingleClicked ) |
|
1239 { |
|
1240 DEBUG(("\t_Mm_:CMmAppUi::HandleListBoxEventL EEventItemSingleClicked")); |
|
1241 HandleHighlightItemSingleClickedL( iCurrentContainer->Widget()->CurrentItemIndex() ); |
|
1242 } |
|
1243 else if ( aEventType == MEikListBoxObserver::EEventPanningStarted ) |
|
1244 { |
|
1245 iKeyClickLocked = ETrue; |
|
1246 } |
|
1247 |
|
1248 DEBUG(("_Mm_:CMmAppUi::HandleListBoxEventL OUT")); |
|
1249 } |
|
1250 |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // |
|
1253 // --------------------------------------------------------------------------- |
|
1254 // |
|
1255 void CMmAppUi::HandleLongTapEventL( const TPoint& aPenEventLocation ) |
|
1256 { |
|
1257 TBool popupMenuDisplayed(EFalse); |
|
1258 if (iPopupMenu) |
|
1259 { |
|
1260 delete iPopupMenu; |
|
1261 iPopupMenu = NULL; |
|
1262 } |
|
1263 iPopupMenu = CAknStylusPopUpMenu::NewL(this,aPenEventLocation); |
|
1264 |
|
1265 if ( AknLayoutUtils::LayoutMirrored() ) |
|
1266 { |
|
1267 iPopupMenu->SetPosition( aPenEventLocation, |
|
1268 CAknStylusPopUpMenu::EPositionTypeRightBottom ); |
|
1269 } |
|
1270 else |
|
1271 { |
|
1272 iPopupMenu->SetPosition( aPenEventLocation, |
|
1273 CAknStylusPopUpMenu::EPositionTypeLeftBottom ); |
|
1274 } |
|
1275 |
|
1276 if( iCurrentSuiteModel == iHNInterface->GetLastSuiteModelL() |
|
1277 && iCurrentContainer->IsHighlightVisible() |
|
1278 && iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1 ) |
|
1279 { |
|
1280 MMPERF(("CMmAppUi::DynInitMenuPaneL - START")); |
|
1281 //fill the main menu structure, look for cascade menus |
|
1282 //reset the helper hash map |
|
1283 iCascadeMenuMap.Close(); |
|
1284 |
|
1285 MHnMenuItemModelIterator* menuIterator = |
|
1286 iCurrentSuiteModel->GetMenuStructureL( |
|
1287 iCurrentSuiteModel->IdByIndex( |
|
1288 iCurrentContainer->GetHighlight() ) ); |
|
1289 |
|
1290 // check if there is a menu structure available |
|
1291 // for the specified item |
|
1292 if ( menuIterator ) |
|
1293 { |
|
1294 //create item sorting helper objects |
|
1295 RArray<TInt> positionArray; |
|
1296 CleanupClosePushL( positionArray ); |
|
1297 RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap; |
|
1298 CleanupClosePushL( menuItemMap ); |
|
1299 |
|
1300 while ( menuIterator->HasNextSpecific() ) |
|
1301 { |
|
1302 CHnMenuItemModel* childItem = menuIterator->GetNextSpecific(); |
|
1303 CEikMenuPaneItem::SData childData; |
|
1304 childData.iCommandId = childItem->Command(); |
|
1305 childData.iText = childItem->NameL(). |
|
1306 Left( CEikMenuPaneItem::SData::ENominalTextLength ); |
|
1307 childData.iFlags = 0; |
|
1308 childData.iCascadeId = 0; |
|
1309 |
|
1310 positionArray.AppendL( childItem->Position() ); |
|
1311 menuItemMap.InsertL( childItem->Position(), childData ); |
|
1312 } |
|
1313 |
|
1314 positionArray.Sort(); |
|
1315 |
|
1316 //add items in correct order |
|
1317 for ( TInt i = 0; i < positionArray.Count(); ++i ) |
|
1318 { |
|
1319 iPopupMenu-> |
|
1320 AddMenuItemL( |
|
1321 menuItemMap.FindL( positionArray[i] ).iText, |
|
1322 menuItemMap.FindL( positionArray[i] ).iCommandId ); |
|
1323 } |
|
1324 |
|
1325 if (positionArray.Count()>0) |
|
1326 { |
|
1327 iPopupMenu->ShowMenu(); |
|
1328 popupMenuDisplayed = ETrue; |
|
1329 } |
|
1330 CleanupStack::PopAndDestroy( &menuItemMap ); |
|
1331 CleanupStack::PopAndDestroy( &positionArray ); |
|
1332 } |
|
1333 MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP")); |
|
1334 } |
|
1335 |
|
1336 if ( !popupMenuDisplayed && iCurrentContainer |
|
1337 && iCurrentContainer == TopFocusedControl() ) |
|
1338 { |
|
1339 iCurrentContainer->HandleTopFocusL( EFalse ); |
|
1340 HandleHighlightItemSingleClickedL( |
|
1341 iCurrentContainer->Widget()->CurrentItemIndex() ); |
|
1342 } |
|
1343 } |
|
1344 |
|
1345 // --------------------------------------------------------------------------- |
|
1346 // |
|
1347 // --------------------------------------------------------------------------- |
|
1348 // |
|
1349 void CMmAppUi::HandleHighlightItemDoubleClickedL( TInt aIndex ) |
|
1350 { |
|
1351 if ( iKeyClickLocked ) |
|
1352 return; |
|
1353 |
|
1354 if ( iCurrentSuiteModel->WidgetType() == EListWidget |
|
1355 && iCurrentContainer->GetPreviousHighlight() == aIndex ) |
|
1356 { |
|
1357 ForwardEventToHNL( KKeyIdSelect, aIndex ); |
|
1358 } |
|
1359 else if ( iCurrentSuiteModel->WidgetType() == EGridWidget && FlipOpen() ) |
|
1360 { |
|
1361 ForwardEventToHNL( KKeyIdSelect, aIndex ); |
|
1362 } |
|
1363 else if ( iCurrentSuiteModel->WidgetType() == EGridWidget |
|
1364 && IsEditMode() && iCurrentContainer->GetPreviousHighlight() == aIndex |
|
1365 && !iCurrentContainer->IsDraggable()) |
|
1366 { |
|
1367 ForwardEventToHNL( KKeyIdSelect, aIndex ); |
|
1368 } |
|
1369 } |
|
1370 |
|
1371 // --------------------------------------------------------------------------- |
|
1372 // |
|
1373 // --------------------------------------------------------------------------- |
|
1374 // |
|
1375 void CMmAppUi::HandleHighlightItemPenDownL( TInt /* aIndex */ ) |
|
1376 { |
|
1377 DEBUG(("CMmAppUi::HandleHighlightItemPenDownL - IN")); |
|
1378 UpdateToolbarL(); |
|
1379 SetMiddleSoftKeyL(); |
|
1380 iKeyClickLocked = EFalse; |
|
1381 DEBUG(("CMmAppUi::HandleHighlightItemPenDownL - OUT")); |
|
1382 } |
|
1383 |
|
1384 // --------------------------------------------------------------------------- |
|
1385 // |
|
1386 // --------------------------------------------------------------------------- |
|
1387 // |
|
1388 void CMmAppUi::HandleHighlightItemSingleClickedL( TInt aIndex ) |
|
1389 { |
|
1390 if ( !iKeyClickLocked && !IsFaded() ) |
|
1391 { |
|
1392 ForwardEventToHNL( KKeyIdSelect, aIndex ); |
|
1393 } |
|
1394 } |
|
1395 |
|
1396 // --------------------------------------------------------------------------- |
|
1397 // |
|
1398 // --------------------------------------------------------------------------- |
|
1399 // |
|
1400 void CMmAppUi::ResetContainerMap() |
|
1401 { |
|
1402 THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap ); |
|
1403 while( iterator.NextKey() ) |
|
1404 { |
|
1405 CMmWidgetContainer** container = iterator.CurrentValue(); |
|
1406 delete *container; |
|
1407 iterator.RemoveCurrent(); |
|
1408 } |
|
1409 iContainerMap.Close(); |
|
1410 } |
|
1411 |
|
1412 // --------------------------------------------------------------------------- |
|
1413 // |
|
1414 // --------------------------------------------------------------------------- |
|
1415 // |
|
1416 void CMmAppUi::ResetContainerMapToRootL() |
|
1417 { |
|
1418 TInt err( KErrNone ); |
|
1419 CHnSuiteModel* currentSuite = iHNInterface->GetLastSuiteModelL(); |
|
1420 |
|
1421 // there is a loaded suite configuration |
|
1422 if( currentSuite ) |
|
1423 { |
|
1424 TInt id( currentSuite->GetItemsOrder()->GetSuiteId() ); |
|
1425 TRAP( err, iCurrentContainer = iContainerMap.FindL( id ) ); |
|
1426 |
|
1427 // configuration loaded but there is no container |
|
1428 if( err != KErrNone ) |
|
1429 { |
|
1430 HandleSuiteModelInitializedL( currentSuite ); |
|
1431 } |
|
1432 else if( iContainerMap.Count() > 0 ) |
|
1433 { |
|
1434 THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap ); |
|
1435 while( iterator.NextKey() ) |
|
1436 { |
|
1437 CMmWidgetContainer** container = iterator.CurrentValue(); |
|
1438 if( iCurrentContainer != *container ) |
|
1439 { |
|
1440 RemoveFromStack( *container ); |
|
1441 iGarbage.AppendL( *container ); |
|
1442 iterator.RemoveCurrent(); |
|
1443 } |
|
1444 } |
|
1445 } |
|
1446 } |
|
1447 else |
|
1448 { |
|
1449 ResetContainerMap(); |
|
1450 InitializeL(); |
|
1451 } |
|
1452 } |
|
1453 |
|
1454 // --------------------------------------------------------------------------- |
|
1455 // |
|
1456 // --------------------------------------------------------------------------- |
|
1457 // |
|
1458 void CMmAppUi::HandleMessageL( const TDesC8& aMessage ) |
|
1459 { |
|
1460 if ( IsEditMode() ) |
|
1461 { |
|
1462 SetEditModeL( EFalse ); |
|
1463 } |
|
1464 |
|
1465 if ( aMessage.Find( KRootWithPref ) != KErrNotFound ) |
|
1466 { |
|
1467 RemoveFromStack( iCurrentContainer ); |
|
1468 iDummyContainer->MakeVisible( ETrue ); |
|
1469 RefreshCbaL(); |
|
1470 iGarbage.ResetAndDestroy(); |
|
1471 ResetContainerMap(); |
|
1472 iCurrentSuiteModel = NULL; |
|
1473 iCurrentContainer = NULL; |
|
1474 } |
|
1475 |
|
1476 TRAPD( err, iHNInterface->LoadSuitesFromUriL( aMessage ) ); |
|
1477 |
|
1478 if ( err && iCurrentContainer && ( aMessage.Find( KSetFocusWithPref ) == KErrNotFound ) ) |
|
1479 { |
|
1480 HandleSuiteEventL( ESuiteModelInitialized, iHNInterface->GetLastSuiteModelL() ); |
|
1481 } |
|
1482 } |
|
1483 |
|
1484 // --------------------------------------------------------------------------- |
|
1485 // |
|
1486 // --------------------------------------------------------------------------- |
|
1487 // |
|
1488 void CMmAppUi::DynInitMenuPaneL( TInt aResourceId, |
|
1489 CEikMenuPane* aMenuPane ) |
|
1490 { |
|
1491 aMenuPane->EnableMarqueeL( ETrue ); |
|
1492 if( iCurrentSuiteModel == iHNInterface->GetLastSuiteModelL() ) |
|
1493 { |
|
1494 switch ( aResourceId ) |
|
1495 { |
|
1496 case R_MAIN_MENU_PANE: |
|
1497 { |
|
1498 MMPERF(("CMmAppUi::DynInitMenuPaneL - START")); |
|
1499 //fill the main menu structure, look for cascade menus |
|
1500 //reset the helper hash map |
|
1501 iCascadeMenuMap.Close(); |
|
1502 |
|
1503 MHnMenuItemModelIterator* menuIterator = NULL; |
|
1504 TBool ignoreItemSpecific( EFalse ); |
|
1505 if ( iCurrentSuiteModel ) |
|
1506 { |
|
1507 TInt itemId( KErrNotFound ); |
|
1508 TBool suiteModelHasItems = iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1; |
|
1509 TBool highlightVisible = iCurrentContainer->IsHighlightVisible(); |
|
1510 if ( !highlightVisible && suiteModelHasItems ) |
|
1511 { |
|
1512 // if there is no highlight, but there are items, show menuitems for logically |
|
1513 // current suite highlight fetched from suite model. |
|
1514 TInt suiteHighlight = iCurrentSuiteModel->GetSuiteHighlight(); |
|
1515 ASSERT( suiteHighlight != KErrNotFound ); |
|
1516 itemId = iCurrentSuiteModel->IdByIndex( suiteHighlight ); |
|
1517 ignoreItemSpecific = ETrue; |
|
1518 } |
|
1519 else |
|
1520 { |
|
1521 TBool idByContainer = highlightVisible && suiteModelHasItems; |
|
1522 itemId = idByContainer ? |
|
1523 iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) : |
|
1524 iCurrentSuiteModel->IdByIndex( KErrNotFound ); |
|
1525 } |
|
1526 menuIterator = iCurrentSuiteModel->GetMenuStructureL( itemId ); |
|
1527 } |
|
1528 |
|
1529 // check if there is a menu structure available |
|
1530 // for the specified item |
|
1531 if ( menuIterator ) |
|
1532 { |
|
1533 //create item sorting helper objects |
|
1534 RArray<TInt> positionArray; |
|
1535 CleanupClosePushL( positionArray ); |
|
1536 RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap; |
|
1537 CleanupClosePushL( menuItemMap ); |
|
1538 |
|
1539 //get original (rss defined) items positions |
|
1540 for ( TInt i = 0; i < aMenuPane->NumberOfItemsInPane(); ++i ) |
|
1541 { |
|
1542 //multiply to make space for suite defined entries |
|
1543 //first item has 100th conceptual position |
|
1544 positionArray.AppendL( ( i + 1 ) * KMenuPosMultiplier ); |
|
1545 //store items, position as the key |
|
1546 menuItemMap.InsertL( ( i + 1 ) * KMenuPosMultiplier, |
|
1547 aMenuPane-> |
|
1548 ItemData( aMenuPane->MenuItemCommandId( i ) ) ); |
|
1549 } |
|
1550 |
|
1551 //get custom menu items and their positions |
|
1552 while ( menuIterator->HasNext() ) |
|
1553 { |
|
1554 CHnMenuItemModel* menuItem = menuIterator->GetNext(); |
|
1555 if ( !menuItem->IsItemSpecific() || !ignoreItemSpecific ) |
|
1556 { |
|
1557 CEikMenuPaneItem::SData menuData; |
|
1558 menuData.iCommandId = menuItem->Command(); |
|
1559 menuData.iText = menuItem->NameL(). |
|
1560 Left( CEikMenuPaneItem::SData::ENominalTextLength ); |
|
1561 menuData.iFlags = 0; |
|
1562 |
|
1563 //check for children |
|
1564 MHnMenuItemModelIterator* childIterator = |
|
1565 menuItem->GetMenuStructure(); |
|
1566 if ( childIterator->HasNext() ) |
|
1567 { |
|
1568 //this is a cascade item |
|
1569 //one menu item can contain only one cascade menu |
|
1570 //check if there are available cascade menu containers |
|
1571 TInt freeResource = GetNextCascadeMenuResourceId(); |
|
1572 if ( freeResource != KErrNotFound ) |
|
1573 { |
|
1574 //error checking |
|
1575 if( !iCascadeMenuMap.Insert( freeResource, |
|
1576 childIterator ) ) |
|
1577 { |
|
1578 //add item only if there is an |
|
1579 //available resource |
|
1580 menuData.iCascadeId = freeResource; |
|
1581 } |
|
1582 } |
|
1583 } |
|
1584 else |
|
1585 { |
|
1586 //normal entry |
|
1587 menuData.iCascadeId = 0; |
|
1588 } |
|
1589 positionArray.AppendL( menuItem->Position() ); |
|
1590 menuItemMap.InsertL( menuItem->Position(), menuData ); |
|
1591 } |
|
1592 } |
|
1593 |
|
1594 aMenuPane->Reset(); |
|
1595 positionArray.Sort(); |
|
1596 |
|
1597 //add items in correct order |
|
1598 for ( TInt i = 0; i < positionArray.Count(); ++i ) |
|
1599 { |
|
1600 aMenuPane-> |
|
1601 AddMenuItemL( |
|
1602 ( menuItemMap.FindL( positionArray[i] ) ) ); |
|
1603 } |
|
1604 |
|
1605 CleanupStack::PopAndDestroy( &menuItemMap ); |
|
1606 CleanupStack::PopAndDestroy( &positionArray ); |
|
1607 } |
|
1608 MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP")); |
|
1609 } |
|
1610 break; |
|
1611 |
|
1612 case R_CASCADE_MENU_PANE_1: |
|
1613 case R_CASCADE_MENU_PANE_2: |
|
1614 case R_CASCADE_MENU_PANE_3: |
|
1615 { |
|
1616 //realod cascade menu map |
|
1617 ReloadCascadeMenuMapL(); |
|
1618 //fill the cascade menu panes |
|
1619 MHnMenuItemModelIterator* childIteratorPtr = |
|
1620 iCascadeMenuMap.FindL( aResourceId ); |
|
1621 |
|
1622 // check if child iterator available |
|
1623 if ( childIteratorPtr ) |
|
1624 { |
|
1625 childIteratorPtr->Reset(); |
|
1626 |
|
1627 //create item sorting helper objects |
|
1628 RArray<TInt> positionArray; |
|
1629 CleanupClosePushL( positionArray ); |
|
1630 RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap; |
|
1631 CleanupClosePushL( menuItemMap ); |
|
1632 |
|
1633 while ( childIteratorPtr->HasNext() ) |
|
1634 { |
|
1635 CHnMenuItemModel* childItem = childIteratorPtr->GetNext(); |
|
1636 |
|
1637 CEikMenuPaneItem::SData childData; |
|
1638 childData.iCommandId = childItem->Command(); |
|
1639 childData.iText = childItem->NameL(). |
|
1640 Left( CEikMenuPaneItem::SData::ENominalTextLength ); |
|
1641 childData.iFlags = 0; |
|
1642 childData.iCascadeId = 0; |
|
1643 |
|
1644 positionArray.AppendL( childItem->Position() ); |
|
1645 menuItemMap.InsertL( childItem->Position(), childData ); |
|
1646 } |
|
1647 |
|
1648 positionArray.Sort(); |
|
1649 //add items in correct order |
|
1650 for ( TInt i = 0; i < positionArray.Count(); ++i ) |
|
1651 { |
|
1652 aMenuPane->AddMenuItemL( |
|
1653 ( menuItemMap.FindL( positionArray[i] ) ) ); |
|
1654 } |
|
1655 |
|
1656 CleanupStack::PopAndDestroy( &menuItemMap ); |
|
1657 CleanupStack::PopAndDestroy( &positionArray ); |
|
1658 } |
|
1659 } |
|
1660 break; |
|
1661 |
|
1662 default: |
|
1663 break; |
|
1664 } |
|
1665 } |
|
1666 else if( aResourceId == R_MAIN_MENU_PANE ) |
|
1667 { |
|
1668 aMenuPane->SetItemDimmed( EMmOptionsExit, ETrue ); |
|
1669 } |
|
1670 } |
|
1671 |
|
1672 // --------------------------------------------------------------------------- |
|
1673 // |
|
1674 // --------------------------------------------------------------------------- |
|
1675 // |
|
1676 void CMmAppUi::ReloadCascadeMenuMapL() |
|
1677 { |
|
1678 iCascadeMenuMap.Close(); |
|
1679 MHnMenuItemModelIterator* menuIterator = NULL; |
|
1680 if ( iCurrentSuiteModel ) |
|
1681 { |
|
1682 TBool idByContainer = iCurrentContainer->IsHighlightVisible() && |
|
1683 iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1; |
|
1684 TInt itemId = idByContainer ? |
|
1685 iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) : |
|
1686 iCurrentSuiteModel->IdByIndex( KErrNotFound ); |
|
1687 menuIterator = iCurrentSuiteModel->GetMenuStructureL( itemId ); |
|
1688 } |
|
1689 |
|
1690 if ( menuIterator ) |
|
1691 { |
|
1692 while ( menuIterator->HasNext() ) |
|
1693 { |
|
1694 CHnMenuItemModel* menuItem = menuIterator->GetNext(); |
|
1695 |
|
1696 MHnMenuItemModelIterator* childIterator = |
|
1697 menuItem->GetMenuStructure(); |
|
1698 if ( childIterator->HasNext() ) |
|
1699 { |
|
1700 TInt freeResource = GetNextCascadeMenuResourceId(); |
|
1701 if ( freeResource != KErrNotFound ) |
|
1702 { |
|
1703 iCascadeMenuMap.Insert( freeResource, childIterator ); |
|
1704 } |
|
1705 } |
|
1706 } |
|
1707 } |
|
1708 } |
|
1709 |
|
1710 // --------------------------------------------------------------------------- |
|
1711 // |
|
1712 // --------------------------------------------------------------------------- |
|
1713 // |
|
1714 TInt CMmAppUi::GetNextCascadeMenuResourceId() |
|
1715 { |
|
1716 //if needed add additional placeholders in matrixmenu.rss |
|
1717 //next add additional cases in this method and the |
|
1718 //CMmAppUi::DynInitMenuPaneL |
|
1719 |
|
1720 TInt freeResource( KErrNotFound ); |
|
1721 switch ( iCascadeMenuMap.Count() ) |
|
1722 { |
|
1723 case 0: |
|
1724 { |
|
1725 freeResource = R_CASCADE_MENU_PANE_1; |
|
1726 } |
|
1727 break; |
|
1728 case 1: |
|
1729 { |
|
1730 freeResource = R_CASCADE_MENU_PANE_2; |
|
1731 } |
|
1732 break; |
|
1733 case 2: |
|
1734 { |
|
1735 freeResource = R_CASCADE_MENU_PANE_3; |
|
1736 } |
|
1737 break; |
|
1738 default: |
|
1739 break; |
|
1740 } |
|
1741 return freeResource; |
|
1742 } |
|
1743 |
|
1744 // --------------------------------------------------------------------------- |
|
1745 // |
|
1746 // --------------------------------------------------------------------------- |
|
1747 // |
|
1748 void CMmAppUi::HandleWidgetChangeRefreshL( |
|
1749 CMmWidgetContainer* aWidgetContainer ) |
|
1750 { |
|
1751 DEBUG(("_Mm_:CMmAppUi::HandleWidgetChangeRefreshL IN")); |
|
1752 |
|
1753 CMmWidgetContainer* previousContainer = iCurrentContainer; |
|
1754 if (previousContainer) |
|
1755 { |
|
1756 previousContainer->SetObserver(NULL); |
|
1757 RemoveFromStack(previousContainer); |
|
1758 } |
|
1759 |
|
1760 iCurrentContainer = aWidgetContainer; |
|
1761 iCurrentContainer->Widget()->View()->SetDisableRedraw(ETrue); |
|
1762 iDummyContainer->MakeVisible( ETrue ); |
|
1763 RefreshCbaL(); |
|
1764 iCurrentContainer->SetZoom( iZoom ); |
|
1765 iCurrentContainer->SetFlipOpenL( FlipOpen() ); |
|
1766 iCurrentContainer->SetEditModeL( IsEditMode() ); |
|
1767 iCurrentContainer->SetSuiteModelL( iCurrentSuiteModel ); |
|
1768 iCurrentContainer->HandleResourceChange( KAknsMessageSkinChange ); |
|
1769 iCurrentContainer->HandleResourceChange( KUidValueCoeColorSchemeChangeEvent ); |
|
1770 iCurrentContainer->SetEmptyTextL( iCurrentSuiteModel->EmptyText() ); |
|
1771 iCurrentContainer->SetHasFocusL( iHasFocus ); |
|
1772 iCurrentContainer->SetIsFaded( IsFaded() ); |
|
1773 iCurrentContainer->SetObserver( this ); |
|
1774 |
|
1775 if ( previousContainer && previousContainer->WidgetType() != iCurrentContainer->WidgetType() |
|
1776 && previousContainer->GetSuiteModelL() == iCurrentContainer->GetSuiteModelL() ) |
|
1777 { |
|
1778 iCurrentSuiteModel->SetSuiteHighlightL( KErrNotFound ); |
|
1779 } |
|
1780 |
|
1781 AddToStackL( iCurrentContainer ); |
|
1782 if ( previousContainer ) |
|
1783 { |
|
1784 previousContainer->MakeVisible( EFalse ); |
|
1785 } |
|
1786 |
|
1787 DEBUG(("_Mm_:CMmAppUi::HandleWidgetChangeRefreshL OUT")); |
|
1788 } |
|
1789 |
|
1790 // --------------------------------------------------------------------------- |
|
1791 // |
|
1792 // --------------------------------------------------------------------------- |
|
1793 // |
|
1794 void CMmAppUi::HandleNoWidgetChangeRefreshL() |
|
1795 { |
|
1796 if ( iCurrentSuiteModel ) |
|
1797 { |
|
1798 iCurrentContainer->Widget()->View()->SetDisableRedraw(ETrue); |
|
1799 iCurrentContainer->SetZoom( iZoom ); |
|
1800 iCurrentContainer->SetFlipOpenL( FlipOpen() ); |
|
1801 iCurrentContainer->SetEditModeL( IsEditMode() ); |
|
1802 iCurrentContainer->SetSuiteModelL( iCurrentSuiteModel ); |
|
1803 iCurrentContainer->SetEmptyTextL( iCurrentSuiteModel->EmptyText() ); |
|
1804 iCurrentContainer->SetHasFocusL( iHasFocus ); |
|
1805 iCurrentContainer->SetIsFaded( IsFaded() ); |
|
1806 iCurrentContainer->SetObserver(this); |
|
1807 } |
|
1808 } |
|
1809 |
|
1810 // --------------------------------------------------------------------------- |
|
1811 // |
|
1812 // --------------------------------------------------------------------------- |
|
1813 // |
|
1814 TBool CMmAppUi::IsEditMode() |
|
1815 { |
|
1816 return (iEditModeStatus == EEditMode |
|
1817 || iEditModeStatus == ETransitionToEditMode); |
|
1818 } |
|
1819 // --------------------------------------------------------------------------- |
|
1820 // |
|
1821 // --------------------------------------------------------------------------- |
|
1822 // |
|
1823 void CMmAppUi::HandlePresentationChangeL( |
|
1824 CMmWidgetContainer* aWidgetContainer ) |
|
1825 { |
|
1826 DEBUG(("_Mm_:CMmAppUi::HandlePresentationChangeL IN")); |
|
1827 |
|
1828 if ( iToolbar && iToolbar->IsShown() ) |
|
1829 { |
|
1830 iToolbar->SetToolbarVisibility( EFalse ); |
|
1831 } |
|
1832 |
|
1833 if( iCurrentContainer != aWidgetContainer ) |
|
1834 { |
|
1835 if( iCurrentContainer && aWidgetContainer && |
|
1836 iCurrentContainer->WidgetType() != aWidgetContainer->WidgetType() ) |
|
1837 { |
|
1838 StartLayoutSwitchFullScreen(); |
|
1839 } |
|
1840 HandleWidgetChangeRefreshL( aWidgetContainer ); |
|
1841 } |
|
1842 else |
|
1843 { |
|
1844 HandleNoWidgetChangeRefreshL(); |
|
1845 } |
|
1846 |
|
1847 if( iCurrentContainer ) |
|
1848 { |
|
1849 iCurrentContainer->SetRect(ClientRect()); |
|
1850 iDummyContainer->SetRect(ClientRect()); |
|
1851 if( IsForeground() ) |
|
1852 { |
|
1853 // should be called before MakeVisible (and after SetRect or SetupLayout, |
|
1854 // so that default highlight is displayed correctly when zoomed) |
|
1855 ApplyHighlightFromModelL(); |
|
1856 |
|
1857 // There is defferences in code because behaviour in non-touch edit mode |
|
1858 // and non-touch edit mode is different. |
|
1859 if (!AknLayoutUtils::PenEnabled()) |
|
1860 { |
|
1861 // While starting non-touch edit mode we have to scroll view in case when |
|
1862 // higlighted item is placed on top/bottow row of view and there |
|
1863 // are more rows over/under one to show all needed indicator arrows. |
|
1864 // DrawNow() method caused jumping both scrollbar and view to old positions. |
|
1865 iCurrentContainer->MakeVisible(ETrue); |
|
1866 iCurrentContainer->Widget()->View()->SetDisableRedraw(EFalse); |
|
1867 iCurrentContainer->SetEditModeL(IsEditMode()); |
|
1868 iDummyContainer->MakeVisible(EFalse); |
|
1869 } |
|
1870 else |
|
1871 { |
|
1872 // For touch normal mode we have to redraw container in case |
|
1873 // we back "parent folder" which was edited in edit mode. |
|
1874 // Thanks to DrawNow() method we avoid drawing items's backdrop icons |
|
1875 // and switching between edit mode's and normal mode's views |
|
1876 iCurrentContainer->SetEditModeL(IsEditMode()); |
|
1877 iCurrentContainer->MakeVisible(ETrue); |
|
1878 |
|
1879 // cache widget position so that we can restore it after DrawNow(), which |
|
1880 // changes it for no apparent reason when using list view. |
|
1881 iCurrentContainer->CacheWidgetPosition(); |
|
1882 |
|
1883 // draw container before effects gets snapshot |
|
1884 iCurrentContainer->DrawNow(); |
|
1885 iCurrentContainer->Widget()->View()->SetDisableRedraw(EFalse); |
|
1886 iDummyContainer->MakeVisible(EFalse); |
|
1887 |
|
1888 // restore the correct widget position |
|
1889 iCurrentContainer->RestoreWidgetPosition(); |
|
1890 } |
|
1891 |
|
1892 // refresh changed items only |
|
1893 iCurrentContainer->DrawView(); |
|
1894 RefreshUiPanesL(); |
|
1895 RefreshToolbarL(); |
|
1896 } |
|
1897 else |
|
1898 { |
|
1899 iCurrentContainer->SetupWidgetLayoutL(); |
|
1900 iCurrentContainer->Widget()->View()->SetDisableRedraw( EFalse ); |
|
1901 ApplyHighlightFromModelL(); |
|
1902 } |
|
1903 } |
|
1904 |
|
1905 MMPERF(("CMmAppUi::HandlePresentationChangeL - model swapped")); |
|
1906 DEBUG(("_Mm_:CMmAppUi::HandlePresentationChangeL OUT")); |
|
1907 } |
|
1908 |
|
1909 // --------------------------------------------------------------------------- |
|
1910 // |
|
1911 // --------------------------------------------------------------------------- |
|
1912 // |
|
1913 void CMmAppUi::OfferToolbarEventL( TInt aCommand ) |
|
1914 { |
|
1915 TInt itemId = iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ); |
|
1916 CHnItemModel* itemModel = iCurrentSuiteModel->GetItemModel( itemId ); |
|
1917 ASSERT( itemModel ); |
|
1918 const CHnToolbarModel* toolbarModel = itemModel->GetToolbarModel(); |
|
1919 ASSERT( toolbarModel ); |
|
1920 const CHnButtonModel* buttonModel = toolbarModel->GetButton( aCommand ); |
|
1921 ASSERT( buttonModel ); |
|
1922 |
|
1923 ForwardEventToHNL( buttonModel->GetEventId() ); |
|
1924 } |
|
1925 // --------------------------------------------------------------------------- |
|
1926 // |
|
1927 // --------------------------------------------------------------------------- |
|
1928 // |
|
1929 TInt CMmAppUi::ExecuteExtensionActionL( const TUid aUid , const TDesC& aCommand, |
|
1930 CLiwGenericParamList* aEventParamList ) |
|
1931 { |
|
1932 return iMmExtManager->ExecuteActionL( aUid, aCommand, aEventParamList); |
|
1933 } |
|
1934 // --------------------------------------------------------------------------- |
|
1935 // |
|
1936 // --------------------------------------------------------------------------- |
|
1937 // |
|
1938 void CMmAppUi::HandleToolbarVisibilityL() |
|
1939 { |
|
1940 TBool suiteModelHasToolbar = |
|
1941 iCurrentSuiteModel && iCurrentSuiteModel->HasToolbar(); |
|
1942 |
|
1943 if ( suiteModelHasToolbar ) |
|
1944 { |
|
1945 if ( iToolbar ) |
|
1946 { |
|
1947 // could have gotten hidden during view change |
|
1948 iToolbar->SetToolbarVisibility( ETrue ); |
|
1949 } |
|
1950 else |
|
1951 { |
|
1952 iToolbar = CAknToolbar::NewL( R_GLOBAL_TOOLBAR ); |
|
1953 iToolbar->SetToolbarObserver( this ); |
|
1954 iToolbar->SetToolbarVisibility( ETrue ); |
|
1955 |
|
1956 // substract the toolbar from display's visible area |
|
1957 TRect remainingArea( ClientRect() ); |
|
1958 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1959 remainingArea.Resize( 0, -iToolbar->Size().iHeight ); |
|
1960 iCurrentContainer->SetRect( remainingArea ); |
|
1961 } |
|
1962 } |
|
1963 else if ( !suiteModelHasToolbar && iToolbar ) |
|
1964 { |
|
1965 iToolbar->SetToolbarVisibility( EFalse ); |
|
1966 delete iToolbar; |
|
1967 iToolbar = NULL; |
|
1968 iCurrentContainer->SetRect( ClientRect() ); |
|
1969 } |
|
1970 } |
|
1971 |
|
1972 // --------------------------------------------------------------------------- |
|
1973 // |
|
1974 // --------------------------------------------------------------------------- |
|
1975 // |
|
1976 void CMmAppUi::UpdateToolbarL() |
|
1977 { |
|
1978 // drop toolbar handling if there should be none |
|
1979 if ( iToolbar && iCurrentSuiteModel->HasToolbar() ) |
|
1980 { |
|
1981 iToolbar->RemoveItem( EMmToolbarControl1 ); |
|
1982 iToolbar->RemoveItem( EMmToolbarControl2 ); |
|
1983 iToolbar->RemoveItem( EMmToolbarControl3 ); |
|
1984 |
|
1985 TInt itemId = iCurrentSuiteModel->IdByIndex( iCurrentContainer->Widget()->CurrentItemIndex() ); |
|
1986 CHnItemModel* itemModel = iCurrentSuiteModel->GetItemModel( itemId ); |
|
1987 if ( !itemModel ) |
|
1988 { |
|
1989 return; |
|
1990 } |
|
1991 const CHnToolbarModel* toolbarModel = itemModel->GetToolbarModel(); |
|
1992 |
|
1993 CAknButton* button( NULL ); |
|
1994 for ( TInt i = 0; i < KNumOfButtonsInToolbar; ++i ) |
|
1995 { |
|
1996 const CHnButtonModel* buttonModel = toolbarModel->GetButton( i ); |
|
1997 // get button icon and help text from model |
|
1998 if ( buttonModel ) |
|
1999 { |
|
2000 CGulIcon* originalIcon = buttonModel->GetIcon(); |
|
2001 CGulIcon* iconCopy( NULL ); |
|
2002 if ( originalIcon && originalIcon->Bitmap() ) |
|
2003 { |
|
2004 // create a copy of the icon if exists, |
|
2005 // CAknButton takes ownership of the icon but we |
|
2006 // want to reuse it, |
|
2007 // also duplicate bitmaps for proper scaling |
|
2008 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
2009 CleanupStack::PushL( bitmap ); |
|
2010 bitmap->Duplicate( originalIcon->Bitmap()->Handle() ); |
|
2011 |
|
2012 CFbsBitmap* mask( NULL ); |
|
2013 if ( originalIcon->Mask() ) |
|
2014 { |
|
2015 mask = new (ELeave) CFbsBitmap; |
|
2016 CleanupStack::PushL( mask ); |
|
2017 mask->Duplicate( originalIcon->Mask()->Handle() ); |
|
2018 } |
|
2019 |
|
2020 iconCopy = CGulIcon::NewL( bitmap, mask ); |
|
2021 if ( mask ) |
|
2022 { |
|
2023 CleanupStack::Pop( mask ); |
|
2024 } |
|
2025 CleanupStack::Pop( bitmap ); |
|
2026 CleanupStack::PushL( iconCopy ); |
|
2027 } |
|
2028 button = CAknButton::NewL( iconCopy, |
|
2029 NULL, |
|
2030 NULL, |
|
2031 NULL, |
|
2032 KNullDesC, |
|
2033 buttonModel->GetButtonText(), |
|
2034 0, |
|
2035 0 ); |
|
2036 if ( iconCopy ) |
|
2037 { |
|
2038 CleanupStack::Pop( iconCopy ); |
|
2039 } |
|
2040 CleanupStack::PushL( button ); |
|
2041 button->SetDimmed( buttonModel->GetDimmed() ); |
|
2042 } |
|
2043 else |
|
2044 { |
|
2045 button = CAknButton::NewLC(); |
|
2046 } |
|
2047 iToolbar->AddItemL( button, |
|
2048 EAknCtButton, |
|
2049 EMmToolbarControl1 + i, |
|
2050 0 ); |
|
2051 CleanupStack::Pop( button ); |
|
2052 } |
|
2053 } |
|
2054 } |
|
2055 |
|
2056 // --------------------------------------------------------------------------- |
|
2057 // |
|
2058 // --------------------------------------------------------------------------- |
|
2059 // |
|
2060 void CMmAppUi::SetEditModeL( TBool aIsEditMode ) |
|
2061 { |
|
2062 MMPERF(("CMmAppUi::SetEditModeL %d - START",aIsEditMode)); |
|
2063 if ( IsEditMode() != aIsEditMode && iCurrentSuiteModel ) |
|
2064 { |
|
2065 |
|
2066 // stops moving items. This must be called when leaving non-touch edit mode to save |
|
2067 // the current visible order of the items. In non-touch it is called only once when completing editing |
|
2068 |
|
2069 iHNInterface->SetEditModeL(aIsEditMode); |
|
2070 iCurrentContainer->StopMovingL(); |
|
2071 |
|
2072 if ( aIsEditMode ) |
|
2073 { |
|
2074 iEditModeStatus = ETransitionToEditMode; |
|
2075 } |
|
2076 else |
|
2077 { |
|
2078 if ( iEditModeStatus == ETransitionToEditMode ) |
|
2079 { |
|
2080 iEditModeStatus = EFastTransitionFromEditMode; |
|
2081 } |
|
2082 else |
|
2083 { |
|
2084 iEditModeStatus = ETransitionFromEditMode; |
|
2085 } |
|
2086 } |
|
2087 |
|
2088 HandleHighlightOffsetL( aIsEditMode ? EOffsetNext : EOffsetPrevious ); |
|
2089 iCurrentSuiteModel->SetSuiteHighlightL( |
|
2090 AdjustEditModeHighlightL( iCurrentSuiteModel->GetSuiteHighlight() ) ); |
|
2091 |
|
2092 // update the container at the end when highlight is proper, |
|
2093 // this will ensure correct focus/unfocus action handling |
|
2094 iCurrentContainer->CacheWidgetPosition(); |
|
2095 iCurrentContainer->SetEditModeL( IsEditMode() ); |
|
2096 |
|
2097 if ( iCurrentContainer->IsHighlightVisible() ) |
|
2098 { |
|
2099 iMakeHightlightedItemFullyVisible = ETrue; |
|
2100 } |
|
2101 |
|
2102 RefreshUiPanesL(); |
|
2103 |
|
2104 //disable redraw so that no redrawing events coming from window server cause redrawing until |
|
2105 //everything is ready to draw. Then iCurrentContainer->DrawNow in HandlePresentationChangeL is called |
|
2106 if (IsEditMode()) |
|
2107 { |
|
2108 iCurrentContainer->Widget()->View()->SetDisableRedraw(ETrue); |
|
2109 } |
|
2110 } |
|
2111 |
|
2112 MMPERF(("CMmAppUi::SetEditModeL - STOP")); |
|
2113 } |
|
2114 |
|
2115 // --------------------------------------------------------------------------- |
|
2116 // |
|
2117 // --------------------------------------------------------------------------- |
|
2118 // |
|
2119 void CMmAppUi::HandleWsEventL( const TWsEvent& aEvent, |
|
2120 CCoeControl* aDestination ) |
|
2121 { |
|
2122 DEBUG(("_Mm_:CMmAppUi::HandleWsEventL %d - IN", aEvent.Type())); |
|
2123 |
|
2124 if ( aEvent.Type() == KAknUidValueEndKeyCloseEvent ) |
|
2125 { |
|
2126 // return when the red key was pressed |
|
2127 MMPERF(("End key pressed")); |
|
2128 DEBUG(("_Mm_:CMmAppUi::HandleWsEventL - End key")); |
|
2129 ExitMatrix( EExitToIdle ); |
|
2130 return; |
|
2131 } |
|
2132 |
|
2133 TEventCode type = static_cast< TEventCode >( aEvent.Type() ); |
|
2134 |
|
2135 if ( ( type == EEventFocusLost || type == KAknFullOrPartialForegroundLost ) |
|
2136 && iCurrentContainer ) |
|
2137 { |
|
2138 iCurrentContainer->CacheWidgetPosition(); |
|
2139 } |
|
2140 |
|
2141 // base's HandleWsEventL needs to be called before foreground handling, |
|
2142 // otherwise the screen saver will be turned off |
|
2143 CAknAppUi::HandleWsEventL( aEvent, aDestination ); |
|
2144 |
|
2145 // refreshes toolbar when pen down event was invoked |
|
2146 if ( type == EEventPointer ) |
|
2147 { |
|
2148 if ( iCurrentSuiteModel ) |
|
2149 { |
|
2150 RefreshToolbarL(); |
|
2151 } |
|
2152 } |
|
2153 else if ( type == EEventFocusGained ) |
|
2154 { |
|
2155 HandleFocusGainedL(); |
|
2156 } |
|
2157 else if ( type == EEventFocusLost ) |
|
2158 { |
|
2159 HandleFocusLostL(); |
|
2160 } |
|
2161 else if ( type == KAknFullOrPartialForegroundGained ) |
|
2162 { |
|
2163 HandleFullOrPartialForegroundGainedL(); |
|
2164 } |
|
2165 else if( type == KAknFullOrPartialForegroundLost ) |
|
2166 { |
|
2167 HandleFullOrPartialForegroundLostL(); |
|
2168 } |
|
2169 |
|
2170 DetectOptionsMenuOpenDisplayChangeL(); |
|
2171 } |
|
2172 // --------------------------------------------------------------------------- |
|
2173 // |
|
2174 // --------------------------------------------------------------------------- |
|
2175 // |
|
2176 TErrorHandlerResponse CMmAppUi::HandleError(TInt aError, |
|
2177 const SExtendedError& /*aExtErr*/, |
|
2178 TDes& /*aErrorText*/, |
|
2179 TDes& /*aContextText*/ ) |
|
2180 { |
|
2181 if( aError == KErrNoMemory ) |
|
2182 { |
|
2183 TRAP_IGNORE( ResetToInitialStateL( ) ); |
|
2184 } |
|
2185 return EErrorNotHandled; |
|
2186 } |
|
2187 |
|
2188 |
|
2189 |
|
2190 // --------------------------------------------------------------------------- |
|
2191 // |
|
2192 // --------------------------------------------------------------------------- |
|
2193 // |
|
2194 void CMmAppUi::HandleSuiteEventL ( |
|
2195 THnCustomSuiteEvent aCustomSuiteEvent, CHnSuiteModel* aModel ) |
|
2196 { |
|
2197 |
|
2198 DEBUG(("_Mm_:CMmAppUi::HandleSuiteEventL %d - IN",aCustomSuiteEvent)); |
|
2199 switch ( aCustomSuiteEvent ) |
|
2200 { |
|
2201 case ESuitePushedToStack: |
|
2202 { |
|
2203 aModel->RegisterSuiteObserverL( this, EPriorityMuchLess ); |
|
2204 } |
|
2205 break; |
|
2206 case ESuitePoppedFromStack: |
|
2207 { |
|
2208 |
|
2209 } |
|
2210 break; |
|
2211 case ESuiteModelInitialized: |
|
2212 { |
|
2213 HandleSuiteModelInitializedL( aModel ); |
|
2214 } |
|
2215 break; |
|
2216 default: |
|
2217 break; |
|
2218 } |
|
2219 |
|
2220 if ( iCurrentSuiteModel == aModel ) |
|
2221 { |
|
2222 //We are interested in the following event |
|
2223 //only if they come from the current suite. |
|
2224 TBool redraw = (iScreenOn && IsForeground()) ? ETrue : EFalse; |
|
2225 switch (aCustomSuiteEvent) |
|
2226 { |
|
2227 case ESuiteModelDestroyed: |
|
2228 { |
|
2229 iCurrentContainer->PrepareForGarbage(); |
|
2230 iGarbage.AppendL(iCurrentContainer); |
|
2231 iContainerMap.Remove( |
|
2232 iCurrentSuiteModel->GetItemsOrder()->GetSuiteId()); |
|
2233 RemoveFromStack(iCurrentContainer); |
|
2234 iDummyContainer->MakeVisible( ETrue ); |
|
2235 iCurrentContainer->SetObserver(NULL); |
|
2236 iCurrentSuiteModel = NULL; |
|
2237 iCurrentContainer = NULL; |
|
2238 } |
|
2239 break; |
|
2240 case ESuiteItemsAdded: |
|
2241 { |
|
2242 //we need consistent view/state before item is added |
|
2243 //so draggind should be cancelled |
|
2244 if( IsEditMode() && iCurrentContainer->IsDraggable() ) |
|
2245 { |
|
2246 iCurrentContainer->CancelDragL( EFalse ); |
|
2247 iCurrentContainer->DrawNow(); |
|
2248 } |
|
2249 HandleNumberOfItemsChangedL( EItemsAdded ); |
|
2250 } |
|
2251 break; |
|
2252 case ESuiteItemsRemoved: |
|
2253 { |
|
2254 //we need consistent view/state before item is removed |
|
2255 //so draggind should be cancelled |
|
2256 if( IsEditMode() && iCurrentContainer->IsDraggable() ) |
|
2257 { |
|
2258 iCurrentContainer->CancelDragL( EFalse ); |
|
2259 iCurrentContainer->DrawNow(); |
|
2260 } |
|
2261 HandleNumberOfItemsChangedL( EItemsRemoved ); |
|
2262 } |
|
2263 break; |
|
2264 case ESuiteItemsUpdated: |
|
2265 { |
|
2266 ClearTransitionFromEditModeFlag(); |
|
2267 iCurrentContainer->DrawView(); |
|
2268 } |
|
2269 break; |
|
2270 case ESuiteHighlightChanged: |
|
2271 { |
|
2272 iCurrentContainer->SetManualHighlightL( |
|
2273 iCurrentSuiteModel->GetSuiteHighlight(), redraw ); |
|
2274 } |
|
2275 break; |
|
2276 default: |
|
2277 break; |
|
2278 } |
|
2279 } |
|
2280 DEBUG(("_Mm_:CMmAppUi::HandleSuiteEventL OUT")); |
|
2281 } |
|
2282 |
|
2283 // --------------------------------------------------------------------------- |
|
2284 // |
|
2285 // --------------------------------------------------------------------------- |
|
2286 // |
|
2287 void CMmAppUi::ClearTransitionFromEditModeFlag() |
|
2288 { |
|
2289 if ( iEditModeStatus == ETransitionFromEditMode || |
|
2290 iEditModeStatus == EFastTransitionFromEditMode ) |
|
2291 { |
|
2292 iEditModeStatus = ENoEditMode; |
|
2293 } |
|
2294 } |
|
2295 |
|
2296 // --------------------------------------------------------------------------- |
|
2297 // |
|
2298 // --------------------------------------------------------------------------- |
|
2299 // |
|
2300 TInt CMmAppUi::AdjustEditModeHighlightL( TInt aOriginalHighlight ) |
|
2301 { |
|
2302 if ( AknLayoutUtils::PenEnabled() ) |
|
2303 { |
|
2304 if ( !iCurrentContainer->IsHighlightVisible() |
|
2305 && iEditModeStatus == ETransitionToEditMode ) |
|
2306 { |
|
2307 aOriginalHighlight = KErrNotFound ; |
|
2308 } |
|
2309 } |
|
2310 return aOriginalHighlight; |
|
2311 } |
|
2312 |
|
2313 // --------------------------------------------------------------------------- |
|
2314 // |
|
2315 // --------------------------------------------------------------------------- |
|
2316 // |
|
2317 void CMmAppUi::HandleOutOfMemoryL() |
|
2318 { |
|
2319 if( !iOutOfMemoryHandler ) |
|
2320 { |
|
2321 iOutOfMemoryHandler = CMmNoMemory::NewL(); |
|
2322 } |
|
2323 iOutOfMemoryHandler->Start(); |
|
2324 } |
|
2325 |
|
2326 // --------------------------------------------------------------------------- |
|
2327 // |
|
2328 // --------------------------------------------------------------------------- |
|
2329 // |
|
2330 void CMmAppUi::ResetToInitialStateL() |
|
2331 { |
|
2332 iDummyContainer->MakeVisible( ETrue ); |
|
2333 iDummyContainer->DrawNow(); |
|
2334 RefreshCbaL(); |
|
2335 |
|
2336 if (iCurrentSuiteModel) |
|
2337 { |
|
2338 iCurrentSuiteModel->UnregisterSuiteObserver( this ); |
|
2339 } |
|
2340 RemoveFromStack( iCurrentContainer ); |
|
2341 ResetContainerMap(); |
|
2342 iGarbage.ResetAndDestroy(); |
|
2343 delete iHNInterface; |
|
2344 iHNInterface = NULL; |
|
2345 delete iMmExtManager; |
|
2346 iMmExtManager = NULL; |
|
2347 delete iSliderEventSubscriber; |
|
2348 iSliderEventSubscriber = NULL; |
|
2349 delete iTemplateLibrary; |
|
2350 iTemplateLibrary = NULL; |
|
2351 |
|
2352 iCurrentSuiteModel = NULL; |
|
2353 iCurrentContainer = NULL; |
|
2354 iContainerMap.Close(); |
|
2355 iEditModeStatus = ENoEditMode; |
|
2356 |
|
2357 GfxTransEffect::AbortFullScreen(); |
|
2358 iIsKastorEffectStarted = EFalse; |
|
2359 |
|
2360 RefreshUiPanesL(); |
|
2361 Cba()->MakeVisible( EFalse ); |
|
2362 StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
2363 |
|
2364 iHNInterface = CHnEngine::NewL( *this ); |
|
2365 iTemplateLibrary = CMmTemplateLibrary::NewL(); |
|
2366 InitializeL(); |
|
2367 |
|
2368 iMmExtManager = CMMExtensionManager::NewL( *this ); |
|
2369 |
|
2370 iKeyboardFlipStatus = EPSHWRMFlipStatusUninitialized; |
|
2371 |
|
2372 iScreenOn = ETrue; |
|
2373 iSkinChangeNeeded = EFalse; |
|
2374 iSkinChangeInProgress = EFalse; |
|
2375 } |
|
2376 |
|
2377 // --------------------------------------------------------------------------- |
|
2378 // |
|
2379 // --------------------------------------------------------------------------- |
|
2380 // |
|
2381 void CMmAppUi::HandleSuiteModelInitializedL( CHnSuiteModel* aModel ) |
|
2382 { |
|
2383 StatusPane()->MakeVisible( ETrue ); |
|
2384 Cba()->MakeVisible( ETrue ); |
|
2385 |
|
2386 if ( aModel == iHNInterface->GetLastSuiteModelL() ) |
|
2387 { |
|
2388 TBool showOpenFolderEffect(iCurrentSuiteModel |
|
2389 && (iCurrentSuiteModel->CustomId() != aModel->CustomId() |
|
2390 || iCurrentSuiteModel->WidgetType() |
|
2391 != aModel->WidgetType())); |
|
2392 if( showOpenFolderEffect ) |
|
2393 { |
|
2394 StartLayoutSwitchFullScreen( EMenuOpenFolderEffect ); |
|
2395 } |
|
2396 |
|
2397 if ( iCurrentSuiteModel ) |
|
2398 { |
|
2399 iCurrentSuiteModel->SetVisibleL( EFalse ); |
|
2400 DEBUG16(("\t\t_Mm_:SetVisible EFalse - %S", |
|
2401 &(iCurrentSuiteModel->SuiteName()))); |
|
2402 } |
|
2403 iCurrentSuiteModel = aModel; |
|
2404 ShowSuiteL(); |
|
2405 iGarbage.ResetAndDestroy(); |
|
2406 |
|
2407 if ( iEditModeStatus == ETransitionToEditMode ) |
|
2408 { |
|
2409 iEditModeStatus = EEditMode; |
|
2410 } |
|
2411 else if ( iEditModeStatus == ETransitionFromEditMode ) |
|
2412 { |
|
2413 iEditModeStatus = ENoEditMode; |
|
2414 } |
|
2415 |
|
2416 if (iScreenOn && IsForeground()) |
|
2417 { |
|
2418 iCurrentSuiteModel->SetVisibleL( ETrue ); |
|
2419 DEBUG16(("\t\t_Mm_:SetVisible ETrue - %S", |
|
2420 &(iCurrentSuiteModel->SuiteName()))); |
|
2421 } |
|
2422 |
|
2423 HideMenuPaneIfVisibleL(); |
|
2424 EndFullScreen(); |
|
2425 } |
|
2426 else |
|
2427 { |
|
2428 if( iHNInterface->SuiteModelLoadedL( |
|
2429 aModel->GetItemsOrder()->GetSuiteId() ) ) |
|
2430 { |
|
2431 CMmWidgetContainer* containerToLoad = NULL; |
|
2432 TBool created( CreateNewContainerL( aModel, containerToLoad ) ); |
|
2433 if( created ) |
|
2434 { |
|
2435 containerToLoad->Widget()->View()->SetDisableRedraw( ETrue ); |
|
2436 containerToLoad->SetFlipOpenL( FlipOpen() ); |
|
2437 containerToLoad->SetEditModeL( IsEditMode() ); |
|
2438 containerToLoad->SetSuiteModelL( aModel ); |
|
2439 containerToLoad->SetEmptyTextL( aModel->EmptyText() ); |
|
2440 containerToLoad->SetObserver( this ); |
|
2441 containerToLoad->SetRect( ClientRect() ); |
|
2442 containerToLoad->MakeVisible( EFalse ); |
|
2443 } |
|
2444 } |
|
2445 } |
|
2446 } |
|
2447 |
|
2448 // --------------------------------------------------------------------------- |
|
2449 // |
|
2450 // --------------------------------------------------------------------------- |
|
2451 // |
|
2452 void CMmAppUi::HideMenuPaneIfVisibleL() |
|
2453 { |
|
2454 if ( iEikonEnv->AppUiFactory()->MenuBar()->IsDisplayed() ) |
|
2455 { |
|
2456 iEikonEnv->AppUiFactory()->MenuBar()->StopDisplayingMenuBar(); |
|
2457 } |
|
2458 } |
|
2459 |
|
2460 // --------------------------------------------------------------------------- |
|
2461 // |
|
2462 // --------------------------------------------------------------------------- |
|
2463 // |
|
2464 void CMmAppUi::ExitMatrix( TExitType aExitType ) |
|
2465 { |
|
2466 DEBUG(("_Mm_:CMmAppUi::ExitMatrix - IN")); |
|
2467 DEBUG(("\t_Mm_:Exit type: %d",aExitType)); |
|
2468 |
|
2469 if ( aExitType == EExitReally ) |
|
2470 { |
|
2471 // Calling PrepareHomescreenForMatrixExitL instead of ShowHomescreenL |
|
2472 // allows for avoiding a bug that would occur if appkey was pressed |
|
2473 // immediately after exiting the menu via Options->Exit. |
|
2474 // The bug would be that on pressing the appkey homescreen would be |
|
2475 // displayed and then the menu would appear again on the screen for |
|
2476 // a fraction of second causing an ugly and confusing flicker effect. |
|
2477 TRAP_IGNORE( PrepareHomescreenForMatrixExitL() ); |
|
2478 // ShowHomescreenL( aExitType ); |
|
2479 //if we got exit cmd from OS, let's really exit. |
|
2480 Exit(); |
|
2481 } |
|
2482 else |
|
2483 { |
|
2484 GfxTransEffect::AbortFullScreen(); |
|
2485 iIsKastorEffectStarted = EFalse; |
|
2486 StartLayoutSwitchFullScreen( AknTransEffect::EApplicationExit ); |
|
2487 |
|
2488 TRAP_IGNORE( ShowHomescreenL( aExitType ) ); |
|
2489 TRAP_IGNORE( CleanupForExitL( EExitKeyRed ) ); |
|
2490 } |
|
2491 |
|
2492 DEBUG(("_Mm_:CMmAppUi::ExitMatrix - OUT")); |
|
2493 } |
|
2494 |
|
2495 // --------------------------------------------------------------------------- |
|
2496 // |
|
2497 // --------------------------------------------------------------------------- |
|
2498 // |
|
2499 void CMmAppUi::CleanupForExitL( TExitKeyType aExitKey ) |
|
2500 { |
|
2501 DEBUG(("_Mm_:CMmAppUi::CleanupForExitL - IN")); |
|
2502 |
|
2503 // closing all dialogs opened in ui extensions before exit |
|
2504 iMmExtManager->ExecuteActionL( TUid::Null(), KCommandDeleteDialog, NULL ); |
|
2505 if( IsDisplayingDialog() ) |
|
2506 { |
|
2507 AknDialogShutter::ShutDialogsL( *iEikonEnv ); |
|
2508 } |
|
2509 |
|
2510 if ( IsEditMode() && iCurrentContainer ) |
|
2511 { |
|
2512 DEBUG(("\t_Mm_:Edit Mode turned off")); |
|
2513 iCurrentContainer->CancelDragL( EFalse ); |
|
2514 SetEditModeL( EFalse ); |
|
2515 } |
|
2516 |
|
2517 // reset model - revert to root if current view is not a suite view |
|
2518 CHnSuiteModel* model = iHNInterface->GetLastSuiteModelL(); |
|
2519 if ( model && aExitKey == EExitKeyApplication ) |
|
2520 { |
|
2521 TBool topSuiteIsBeingEvaluated = |
|
2522 !model->GetItemsOrder()->IsSuiteReadyToShow(); |
|
2523 TBool topSuiteChanged = ResetToRootL(); |
|
2524 model = NULL; // ResetToRootL might have deleted the model |
|
2525 TBool presentationChangeExpected = topSuiteChanged || topSuiteIsBeingEvaluated; |
|
2526 |
|
2527 TBool mustDrawImmediately = |
|
2528 !presentationChangeExpected || !iDummyContainer->IsVisible(); |
|
2529 |
|
2530 if ( iCurrentContainer && mustDrawImmediately ) |
|
2531 { |
|
2532 DEBUG(("\t_Mm_:Top item index reset")); |
|
2533 iCurrentContainer->ResetWidgetPosition(); |
|
2534 iCurrentContainer->Widget()->UpdateScrollBarsL(); |
|
2535 iCurrentContainer->MakeVisible( ETrue ); |
|
2536 iCurrentContainer->DrawNow(); |
|
2537 } |
|
2538 } |
|
2539 |
|
2540 DEBUG(("_Mm_:CMmAppUi::CleanupForExitL - OUT")); |
|
2541 } |
|
2542 |
|
2543 // --------------------------------------------------------------------------- |
|
2544 // |
|
2545 // --------------------------------------------------------------------------- |
|
2546 // |
|
2547 void CMmAppUi::ShowHomescreenL( TExitType aExitType ) |
|
2548 { |
|
2549 TInt appToShowUid(0); |
|
2550 TInt idleid(0); |
|
2551 if (aExitType == EExitToIdle) |
|
2552 { |
|
2553 User::LeaveIfError(RProperty::Get(KPSUidAiInformation, KActiveIdleUid, |
|
2554 appToShowUid)); |
|
2555 OpenAppL(TUid::Uid(appToShowUid)); |
|
2556 } |
|
2557 else if (KErrNone == RProperty::Get(KPSUidUikon, KUikVideoCallTopApp, |
|
2558 idleid)) |
|
2559 { |
|
2560 // Possible error code not relevant, as we have valid id anyway |
|
2561 if (idleid != KVideoCallAppUid) // idle or phone |
|
2562 { |
|
2563 OpenAppL(TUid::Uid(KPhoneAppUid)); |
|
2564 } |
|
2565 else |
|
2566 { |
|
2567 CreateActivateViewEventL(TVwsViewId(TUid::Uid(idleid), |
|
2568 TUid::Uid(idleid)), KNullUid, KNullDesC8()); |
|
2569 } |
|
2570 } |
|
2571 else |
|
2572 { |
|
2573 OpenAppL(TUid::Uid(KPhoneAppUid)); |
|
2574 } |
|
2575 } |
|
2576 |
|
2577 // --------------------------------------------------------------------------- |
|
2578 // |
|
2579 // --------------------------------------------------------------------------- |
|
2580 // |
|
2581 void CMmAppUi::PrepareHomescreenForMatrixExitL() |
|
2582 { |
|
2583 TBool succeeded( EFalse ); |
|
2584 |
|
2585 CAknTaskList* taskList = CAknTaskList::NewL( iCoeEnv->WsSession() ); |
|
2586 TApaTask task = taskList->FindRootApp( TUid::Uid( KPhoneAppUid ) ); |
|
2587 delete taskList; |
|
2588 |
|
2589 if ( task.Exists() ) |
|
2590 { |
|
2591 succeeded = !iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( |
|
2592 task.WgId(), 1 ); |
|
2593 } |
|
2594 |
|
2595 if( !succeeded ) |
|
2596 { |
|
2597 ShowHomescreenL( EExitReally ); |
|
2598 } |
|
2599 } |
|
2600 |
|
2601 // --------------------------------------------------------------------------- |
|
2602 // |
|
2603 // --------------------------------------------------------------------------- |
|
2604 // |
|
2605 void CMmAppUi::OpenAppL( const TUid aUid ) |
|
2606 { |
|
2607 DEBUG(("_Mm_:CMmAppUi::OpenAppL - IN")); |
|
2608 DEBUG(("\t_Mm_:aUid: 0x%x",aUid.iUid)); |
|
2609 |
|
2610 // Get the correct application data |
|
2611 CAknTaskList* taskList = CAknTaskList::NewL( iCoeEnv->WsSession() ); |
|
2612 TApaTask task = taskList->FindRootApp( aUid ); |
|
2613 delete taskList; |
|
2614 |
|
2615 if ( task.Exists() ) |
|
2616 { |
|
2617 CAknSgcClient::MoveApp( task.WgId(), ESgcMoveAppToForeground ); |
|
2618 } |
|
2619 else |
|
2620 { |
|
2621 // Task doesn't exist, launch a new instance of an application |
|
2622 TApaAppInfo appInfo; |
|
2623 TApaAppCapabilityBuf capabilityBuf; |
|
2624 RApaLsSession lsSession; |
|
2625 User::LeaveIfError( lsSession.Connect() ); |
|
2626 CleanupClosePushL( lsSession ); |
|
2627 User::LeaveIfError( lsSession.GetAppInfo( appInfo, aUid ) ); |
|
2628 User::LeaveIfError( |
|
2629 lsSession.GetAppCapability( capabilityBuf, aUid ) ); |
|
2630 |
|
2631 TApaAppCapability& caps = capabilityBuf(); |
|
2632 TFileName appName = appInfo.iFullName; |
|
2633 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
2634 cmdLine->SetExecutableNameL( appName ); |
|
2635 |
|
2636 if ( caps.iLaunchInBackground ) |
|
2637 { |
|
2638 cmdLine->SetCommandL( EApaCommandBackground ); |
|
2639 } |
|
2640 else |
|
2641 { |
|
2642 cmdLine->SetCommandL( EApaCommandRun ); |
|
2643 } |
|
2644 |
|
2645 User::LeaveIfError( lsSession.StartApp( *cmdLine ) ); |
|
2646 |
|
2647 CleanupStack::PopAndDestroy( cmdLine ); |
|
2648 CleanupStack::PopAndDestroy( &lsSession ); |
|
2649 } |
|
2650 |
|
2651 DEBUG(("_Mm_:CMmAppUi::OpenAppL - OUT")); |
|
2652 } |
|
2653 // --------------------------------------------------------------------------- |
|
2654 // |
|
2655 // --------------------------------------------------------------------------- |
|
2656 // |
|
2657 void CMmAppUi::InitializeL() |
|
2658 { |
|
2659 DEBUG(("_MM_:CMmAppUi::InitializeL IN")); |
|
2660 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
|
2661 CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); |
|
2662 |
|
2663 HBufC* suiteName = StringLoader::LoadLC( R_MENU_TITLE ); |
|
2664 |
|
2665 paramList->AppendL( TLiwGenericParam( KParamSuiteName8, |
|
2666 TLiwVariant( KParamFolderSuite ) ) ); |
|
2667 map->InsertL( KParamSuiteName8, TLiwVariant( suiteName ) ); |
|
2668 map->InsertL( KParamFolderId8, TLiwVariant( KParamFolderId ) ); |
|
2669 map->InsertL( KParamRemoveLocked8, TLiwVariant( KParamFalse ) ); |
|
2670 map->InsertL( KParentFolderId8, TLiwVariant( KParamFolderId ) ); |
|
2671 map->InsertL( KTmpParentFolderId8, TLiwVariant( KParamFolderId ) ); |
|
2672 paramList->AppendL( TLiwGenericParam( KParams8, TLiwVariant( map ) ) ); |
|
2673 |
|
2674 iHNInterface->InitializeL( *paramList ); |
|
2675 |
|
2676 CleanupStack::PopAndDestroy( suiteName ); |
|
2677 CleanupStack::PopAndDestroy( map ); |
|
2678 CleanupStack::PopAndDestroy( paramList ); |
|
2679 DEBUG(("_MM_:CMmAppUi::InitializeL OUT")); |
|
2680 } |
|
2681 |
|
2682 // --------------------------------------------------------------------------- |
|
2683 // |
|
2684 // --------------------------------------------------------------------------- |
|
2685 // |
|
2686 void CMmAppUi::SetMiddleSoftKeyL() |
|
2687 { |
|
2688 DEBUG(("_Mm_:CMmAppUi::SetMiddleSoftKeyL - IN")); |
|
2689 if ( iCurrentSuiteModel && !AknLayoutUtils::PenEnabled() && !IsEditMode() ) |
|
2690 { |
|
2691 DEBUG(("\t_Mm_:suite highlight: %d", |
|
2692 iCurrentSuiteModel->GetSuiteHighlight())); |
|
2693 |
|
2694 TBool idByContainer = iCurrentContainer->IsHighlightVisible() && |
|
2695 iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1; |
|
2696 TInt itemId = idByContainer ? |
|
2697 iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) : |
|
2698 iCurrentSuiteModel->IdByIndex( KErrNotFound ); |
|
2699 CHnItemModel* itemModel = iCurrentSuiteModel->GetItemModel( itemId ); |
|
2700 |
|
2701 CHnButtonModel* mskModel = NULL; |
|
2702 |
|
2703 if ( itemModel ) |
|
2704 { |
|
2705 mskModel = itemModel->GetMiddleSoftKey(); |
|
2706 } |
|
2707 |
|
2708 if ( mskModel ) |
|
2709 { |
|
2710 TInt event = (mskModel->GetEventId() == KErrNotFound) ? |
|
2711 KKeyIdSelect : mskModel->GetEventId(); |
|
2712 Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
2713 event, mskModel->GetButtonText()); |
|
2714 } |
|
2715 else |
|
2716 { |
|
2717 // reset to default |
|
2718 RefreshCbaL(); |
|
2719 } |
|
2720 } |
|
2721 DEBUG(("_Mm_:CMmAppUi::SetMiddleSoftKeyL - OUT")); |
|
2722 } |
|
2723 |
|
2724 // --------------------------------------------------------------------------- |
|
2725 // |
|
2726 // --------------------------------------------------------------------------- |
|
2727 // |
|
2728 void CMmAppUi::StartLayoutSwitchFullScreen( TInt aKastorEffect ) |
|
2729 { |
|
2730 if( ( !iIsKastorEffectStarted && iScreenOn && IsForeground() ) || |
|
2731 aKastorEffect == AknTransEffect::EApplicationStart || |
|
2732 aKastorEffect == AknTransEffect::EApplicationExit ) |
|
2733 { |
|
2734 DEBUG(("_MM_:CMmAppUi::StartLayoutSwitchFullScreen Foreground")); |
|
2735 TUid uid1( KUidMatrixMenuApp ); |
|
2736 TUid uid2( KUidMatrixMenuApp ); |
|
2737 if ( aKastorEffect == AknTransEffect::EApplicationExit ) |
|
2738 { |
|
2739 uid2 = TUid::Null(); |
|
2740 } |
|
2741 |
|
2742 AknTransEffect::TParamBuffer params = AknTransEffect::GfxTransParam( |
|
2743 uid1, uid2, AknTransEffect::TParameter::EFlagNone ); |
|
2744 |
|
2745 GfxTransEffect::BeginFullScreen( aKastorEffect, TRect(), |
|
2746 AknTransEffect::EParameterType, params ); |
|
2747 |
|
2748 iIsKastorEffectStarted = ETrue; |
|
2749 } |
|
2750 } |
|
2751 |
|
2752 // --------------------------------------------------------------------------- |
|
2753 // |
|
2754 // --------------------------------------------------------------------------- |
|
2755 // |
|
2756 void CMmAppUi::EndFullScreen() |
|
2757 { |
|
2758 if( iIsKastorEffectStarted && iScreenOn ) |
|
2759 { |
|
2760 DEBUG(("_MM_:CMmAppUi::EndFullScreen Foreground")); |
|
2761 GfxTransEffect::EndFullScreen(); |
|
2762 iIsKastorEffectStarted = EFalse; |
|
2763 } |
|
2764 } |
|
2765 // --------------------------------------------------------------------------- |
|
2766 // |
|
2767 // --------------------------------------------------------------------------- |
|
2768 // |
|
2769 void CMmAppUi::HandleRequestL( const CLiwGenericParamList& aParam, |
|
2770 CLiwGenericParamList* aOutput ) |
|
2771 { |
|
2772 iHNInterface->HandleRequestL( aParam, aOutput ); |
|
2773 } |
|
2774 |
|
2775 // --------------------------------------------------------------------------- |
|
2776 // |
|
2777 // --------------------------------------------------------------------------- |
|
2778 // |
|
2779 void CMmAppUi::PropertyChangedL(TInt aValue) |
|
2780 { |
|
2781 iKeyboardFlipStatus = (EPSHWRMFlipStatus)aValue; |
|
2782 |
|
2783 if ( iCurrentContainer ) |
|
2784 { |
|
2785 if( iKeyboardFlipStatus == EPSHWRMFlipOpen ) |
|
2786 { |
|
2787 TBool wasHighlightVisible = iCurrentContainer->IsHighlightVisible(); |
|
2788 iCurrentContainer->SetFlipOpenL( ETrue ); |
|
2789 if ( IsForeground() && !IsEditMode() && !wasHighlightVisible ) |
|
2790 { |
|
2791 iCurrentContainer->SetDefaultHighlightL( ETrue ); |
|
2792 } |
|
2793 } |
|
2794 else if( iKeyboardFlipStatus == EPSHWRMFlipClosed ) |
|
2795 { |
|
2796 iCurrentContainer->SetFlipOpenL( EFalse ); |
|
2797 } |
|
2798 } |
|
2799 } |
|
2800 |
|
2801 // --------------------------------------------------------------------------- |
|
2802 // |
|
2803 // --------------------------------------------------------------------------- |
|
2804 // |
|
2805 TBool CMmAppUi::FlipOpen() |
|
2806 { |
|
2807 return iKeyboardFlipStatus == EPSHWRMFlipOpen; |
|
2808 } |
|
2809 |
|
2810 // --------------------------------------------------------------------------- |
|
2811 // |
|
2812 // --------------------------------------------------------------------------- |
|
2813 // |
|
2814 void CMmAppUi::SetZoom( TAknUiZoom aZoom ) |
|
2815 { |
|
2816 if ( iZoom != aZoom) |
|
2817 { |
|
2818 if ( iCurrentContainer ) |
|
2819 { |
|
2820 iCurrentContainer->HandleZoomChanged( aZoom ); |
|
2821 } |
|
2822 } |
|
2823 iZoom = aZoom; |
|
2824 } |
|
2825 |
|
2826 // --------------------------------------------------------------------------- |
|
2827 // |
|
2828 // --------------------------------------------------------------------------- |
|
2829 // |
|
2830 TBool CMmAppUi::ResetToRootL() |
|
2831 { |
|
2832 TBool resetConsumed( EFalse ); |
|
2833 if( iHNInterface && iCurrentSuiteModel && |
|
2834 !IsRootdisplayedL() ) |
|
2835 { |
|
2836 RemoveFromStack( iCurrentContainer ); |
|
2837 iDummyContainer->MakeVisible( ETrue ); |
|
2838 iHNInterface->HandleBackEventL( |
|
2839 iCurrentSuiteModel->SuiteName(), |
|
2840 iHNInterface->GetSuiteModelsCountL() - 1 ); |
|
2841 ResetContainerMapToRootL(); |
|
2842 if( iCurrentContainer ) |
|
2843 { |
|
2844 iCurrentContainer->ResetWidgetPosition(); |
|
2845 iCurrentContainer->SetZoom( iZoom ); |
|
2846 AddToStackL( iCurrentContainer ); |
|
2847 } |
|
2848 RefreshUiPanesL( ETrue ); |
|
2849 resetConsumed = ETrue; |
|
2850 } |
|
2851 return resetConsumed; |
|
2852 } |
|
2853 |
|
2854 // --------------------------------------------------------------------------- |
|
2855 // |
|
2856 // --------------------------------------------------------------------------- |
|
2857 // |
|
2858 void CMmAppUi::SkinContentChanged() |
|
2859 { |
|
2860 iSkinChangeNeeded = ETrue; |
|
2861 iSkinChangeInProgress = ETrue; |
|
2862 } |
|
2863 // --------------------------------------------------------------------------- |
|
2864 // |
|
2865 // --------------------------------------------------------------------------- |
|
2866 // |
|
2867 void CMmAppUi::SkinConfigurationChanged( |
|
2868 const TAknsSkinStatusConfigurationChangeReason aReason) |
|
2869 { |
|
2870 DEBUG(("_Mm_:CMmAppUi::SkinConfigurationChanged IN - aReason:%d iSkinChangeNeeded:%d iSkinChangeInProgress:%d", aReason, iSkinChangeNeeded, iSkinChangeInProgress)); |
|
2871 switch (aReason) |
|
2872 { |
|
2873 case EAknsSkinStatusConfigurationMerged:// = 1, |
|
2874 { |
|
2875 iSkinChangeNeeded = ETrue; |
|
2876 iSkinChangeInProgress = ETrue; |
|
2877 } |
|
2878 break; |
|
2879 case EAknsSkinStatusConfigurationDeployed:// = 2, |
|
2880 { |
|
2881 iSkinChangeInProgress = EFalse; |
|
2882 if (IsForeground()) |
|
2883 { |
|
2884 TRAPD( err, RefreshIconsL()); |
|
2885 if (!err) |
|
2886 { |
|
2887 iSkinChangeNeeded = ETrue; |
|
2888 } |
|
2889 } |
|
2890 } |
|
2891 break; |
|
2892 default: |
|
2893 { |
|
2894 |
|
2895 } |
|
2896 } |
|
2897 DEBUG(("_Mm_:CMmAppUi::SkinConfigurationChanged OUT - aReason:%d iSkinChangeNeeded:%d iSkinChangeInProgress:%d", aReason, iSkinChangeNeeded, iSkinChangeInProgress)); |
|
2898 } |
|
2899 |
|
2900 // --------------------------------------------------------------------------- |
|
2901 // |
|
2902 // --------------------------------------------------------------------------- |
|
2903 // |
|
2904 void CMmAppUi::SkinPackageChanged(const TAknsSkinStatusPackageChangeReason /*aReason*/) |
|
2905 { |
|
2906 } |
|
2907 |
|
2908 // --------------------------------------------------------------------------- |
|
2909 // |
|
2910 // --------------------------------------------------------------------------- |
|
2911 // |
|
2912 void CMmAppUi::RefreshIconsL() |
|
2913 { |
|
2914 iSkinChangeNeeded = EFalse; |
|
2915 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
|
2916 TLiwGenericParam command(KHnRequest, TLiwVariant( KRefreshIcons)); |
|
2917 paramList->AppendL(command); |
|
2918 HandleRequestL(*paramList); |
|
2919 CleanupStack::PopAndDestroy(paramList); |
|
2920 } |
|
2921 |
|
2922 // --------------------------------------------------------------------------- |
|
2923 // |
|
2924 // --------------------------------------------------------------------------- |
|
2925 // |
|
2926 void CMmAppUi::HandleHighlightOffsetL( TInt aOffset ) |
|
2927 { |
|
2928 if( AknLayoutUtils::PenEnabled() ) |
|
2929 { |
|
2930 iHNInterface->TriggerHnEventL( KKeyIdMoveHighlight, aOffset, NULL ); |
|
2931 } |
|
2932 } |
|
2933 |
|
2934 // --------------------------------------------------------------------------- |
|
2935 // |
|
2936 // --------------------------------------------------------------------------- |
|
2937 // |
|
2938 void CMmAppUi::HandleNumberOfItemsChangedL( TItemsChangeType aChange ) |
|
2939 { |
|
2940 iCurrentContainer->NumberOfItemsChangedL( aChange ); |
|
2941 TBool scrollConsumed( EFalse ); |
|
2942 scrollConsumed = |
|
2943 iCurrentContainer->ScrollToItemL( iCurrentSuiteModel->GetSuiteHighlight() ); |
|
2944 if ( !scrollConsumed || !AknLayoutUtils::PenEnabled() ) |
|
2945 { |
|
2946 iCurrentContainer->DrawNow(); |
|
2947 } |
|
2948 RefreshUiPanesL(); |
|
2949 } |
|
2950 |
|
2951 // --------------------------------------------------------------------------- |
|
2952 // |
|
2953 // --------------------------------------------------------------------------- |
|
2954 // |
|
2955 void CMmAppUi::ApplyHighlightFromModelL() |
|
2956 { |
|
2957 if ( iCurrentSuiteModel && iCurrentContainer ) |
|
2958 { |
|
2959 TInt highlightedItemIndex = iCurrentSuiteModel->GetSuiteHighlight(); |
|
2960 iCurrentContainer->RestoreWidgetPosition(); |
|
2961 |
|
2962 iCurrentContainer->SetManualHighlightL( |
|
2963 highlightedItemIndex, EFalse ); |
|
2964 if ( iMakeHightlightedItemFullyVisible && |
|
2965 !iCurrentContainer->ItemIsFullyVisible( highlightedItemIndex ) ) |
|
2966 { |
|
2967 iCurrentContainer->ScrollToItemL( highlightedItemIndex ); |
|
2968 } |
|
2969 iCurrentContainer->CacheWidgetPosition(); |
|
2970 iMakeHightlightedItemFullyVisible = EFalse; |
|
2971 } |
|
2972 } |
|
2973 |
|
2974 // --------------------------------------------------------------------------- |
|
2975 // |
|
2976 // --------------------------------------------------------------------------- |
|
2977 // |
|
2978 void CMmAppUi::HandleFocusGainedL() |
|
2979 { |
|
2980 DEBUG(("_Mm_:CMmAppUi::HandleWsEventL " |
|
2981 "- EEventFocusGained")); |
|
2982 |
|
2983 iHasFocus = ETrue; |
|
2984 |
|
2985 // Tricky: lack of iCurrentSuiteModel indicates that suite evaluation is in |
|
2986 // progress - do not call HandlePresentationChangeL if evalution has not |
|
2987 // finished. |
|
2988 if ( iCurrentContainer && !iCurrentContainer->IsVisible() && |
|
2989 iCurrentSuiteModel ) |
|
2990 { |
|
2991 HandlePresentationChangeL( iCurrentContainer ); |
|
2992 } |
|
2993 |
|
2994 if ( iCurrentSuiteModel && iCurrentContainer ) |
|
2995 { |
|
2996 iDummyContainer->MakeVisible( EFalse ); |
|
2997 iCurrentContainer->MakeVisible( ETrue ); |
|
2998 iCurrentContainer->DrawNow(); |
|
2999 } |
|
3000 if( IsForeground() ) |
|
3001 { |
|
3002 RefreshUiPanesL(); |
|
3003 } |
|
3004 if ( iCurrentContainer ) |
|
3005 { |
|
3006 iCurrentContainer->SetHasFocusL( ETrue ); |
|
3007 } |
|
3008 if ( iCurrentSuiteModel ) |
|
3009 { |
|
3010 iCurrentSuiteModel->SetVisibleL( ETrue ); |
|
3011 } |
|
3012 } |
|
3013 |
|
3014 // --------------------------------------------------------------------------- |
|
3015 // |
|
3016 // --------------------------------------------------------------------------- |
|
3017 // |
|
3018 void CMmAppUi::HandleFocusLostL() |
|
3019 { |
|
3020 DEBUG(("_Mm_:CMmAppUi::HandleWsEventL " |
|
3021 "- EEventFocusLost")); |
|
3022 |
|
3023 iHasFocus = EFalse; |
|
3024 |
|
3025 if( iCurrentContainer ) |
|
3026 { |
|
3027 //This is needed in case some popup is displayed |
|
3028 //while touching item in grid. Highlight |
|
3029 //should be reset to normal then. |
|
3030 if( AknLayoutUtils::PenEnabled() ) |
|
3031 { |
|
3032 if( iCurrentContainer->WidgetType() == EGridWidget |
|
3033 && !FlipOpen() && !IsEditMode() ) |
|
3034 { |
|
3035 iCurrentContainer->Widget()->View()->ItemDrawer()-> |
|
3036 SetFlags( CListItemDrawer::EDisableHighlight ); |
|
3037 } |
|
3038 iCurrentContainer->Widget()->View()-> |
|
3039 ItemDrawer()->ClearFlags( CListItemDrawer::EPressedDownState ); |
|
3040 iCurrentContainer->Widget()->View()->DrawItem( |
|
3041 iCurrentContainer->Widget()->CurrentItemIndex() ) ; |
|
3042 } |
|
3043 if( IsEditMode() && iCurrentContainer->IsDraggable() ) |
|
3044 { |
|
3045 iCurrentContainer->CancelDragL( EFalse ); |
|
3046 iCurrentContainer->DrawNow(); |
|
3047 } |
|
3048 iCurrentContainer->SetHasFocusL( EFalse ); |
|
3049 } |
|
3050 if ( iCurrentSuiteModel ) |
|
3051 { |
|
3052 iCurrentSuiteModel->SetVisibleL( EFalse ); |
|
3053 } |
|
3054 |
|
3055 } |
|
3056 |
|
3057 // --------------------------------------------------------------------------- |
|
3058 // |
|
3059 // --------------------------------------------------------------------------- |
|
3060 // |
|
3061 void CMmAppUi::HandleFullOrPartialForegroundGainedL() |
|
3062 { |
|
3063 DEBUG(("_Mm_:CMmAppUi::HandleWsEventL " |
|
3064 "- KAknFullOrPartialForegroundGained")); |
|
3065 if (iCurrentContainer && iCurrentSuiteModel ) |
|
3066 { |
|
3067 iCurrentContainer->HandleForegroundGainedL(); |
|
3068 iDummyContainer->MakeVisible( EFalse ); |
|
3069 iCurrentContainer->MakeVisible( ETrue ); |
|
3070 RefreshUiPanesL(); |
|
3071 } |
|
3072 if (iSkinChangeNeeded && !iSkinChangeInProgress) |
|
3073 { |
|
3074 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
3075 if (skinInstance && !skinInstance->IsUpdateInProgress()) |
|
3076 { |
|
3077 RefreshIconsL(); |
|
3078 } |
|
3079 } |
|
3080 } |
|
3081 |
|
3082 // --------------------------------------------------------------------------- |
|
3083 // |
|
3084 // --------------------------------------------------------------------------- |
|
3085 // |
|
3086 void CMmAppUi::HandleFullOrPartialForegroundLostL() |
|
3087 { |
|
3088 DEBUG(("_Mm_:CMmAppUi::HandleWsEventL " |
|
3089 "- KAknFullOrPartialForegroundLost")); |
|
3090 iMmExtManager->ExecuteActionL( |
|
3091 TUid::Null(), KCommandDeleteDialog, NULL ); |
|
3092 if ( iCurrentContainer ) |
|
3093 { |
|
3094 iCurrentContainer->HandleBackgroundGainedL(); |
|
3095 if ( !IsRootdisplayedL() || IsEditMode() || |
|
3096 iEditModeStatus == ETransitionFromEditMode ) |
|
3097 { |
|
3098 iDummyContainer->MakeVisible( ETrue ); |
|
3099 RefreshUiPanesL( ETrue ); |
|
3100 iCurrentContainer->MakeVisible( EFalse ); |
|
3101 iDummyContainer->DrawNow(); |
|
3102 } |
|
3103 if ( IsRootdisplayedL() ) |
|
3104 { |
|
3105 iCurrentContainer->RestoreWidgetPosition(); |
|
3106 iCurrentContainer->CacheWidgetPosition(); |
|
3107 } |
|
3108 } |
|
3109 } |
|
3110 |
|
3111 // --------------------------------------------------------------------------- |
|
3112 // |
|
3113 // --------------------------------------------------------------------------- |
|
3114 // |
|
3115 void CMmAppUi::DetectOptionsMenuOpenDisplayChangeL() |
|
3116 { |
|
3117 CEikMenuBar* menuBar = iAppUiFactory->MenuBar(); |
|
3118 TBool optionsMenuIsOpen = menuBar && menuBar->IsDisplayed(); |
|
3119 if ( !!iOptionsMenuIsOpen != !!optionsMenuIsOpen ) |
|
3120 { |
|
3121 iOptionsMenuIsOpen = optionsMenuIsOpen; |
|
3122 if ( iCurrentContainer ) |
|
3123 { |
|
3124 iCurrentContainer->HandleOptionsMenuVisibilityChangeL( |
|
3125 iOptionsMenuIsOpen ); |
|
3126 } |
|
3127 } |
|
3128 } |
|
3129 |
|
3130 // End of File |