|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikmenub.h> |
|
20 #include <eikmenup.h> |
|
21 #include <eikmobs.h> |
|
22 #include <eikhkeyt.h> |
|
23 #include <eikon.hrh> |
|
24 #include <barsread.h> |
|
25 #include <eikenv.h> |
|
26 #include <eikcmobs.h> |
|
27 #include <gulutil.h> |
|
28 #include <eikbtgpc.h> |
|
29 #include <eikkeys.h> |
|
30 #include <eikappui.h> |
|
31 #include <aknappui.h> |
|
32 #include <aknborders.h> // AKNLAF |
|
33 #include <aknenv.h> |
|
34 #include <AknUtils.h> |
|
35 |
|
36 #include <gulcolor.h> |
|
37 #include <gulicon.h> |
|
38 #include "LAFMENUB.H" |
|
39 #include "LAFMENUP.H" |
|
40 #include "eikmop.h" |
|
41 |
|
42 #include <avkon.rsg> |
|
43 #include <avkon.hrh> |
|
44 #include <AknLayout.lag> |
|
45 #include <aknsoundsystem.h> |
|
46 #include <AknPopupFader.h> |
|
47 #include <AiwServiceHandler.h> |
|
48 |
|
49 #include <gfxtranseffect/gfxtranseffect.h> |
|
50 #include <akntranseffect.h> |
|
51 #include <akntransitionutils.h> |
|
52 #include "avkoninternalpskeys.h" //KAknMenuOptionNoTaskSwapper |
|
53 #include <AknCapServerDefs.h> |
|
54 #include <e32property.h> |
|
55 |
|
56 #include <AknTasHook.h> |
|
57 |
|
58 #include <touchfeedback.h> |
|
59 #include <aknitemactionmenu.h> |
|
60 #include "aknitemactionmenuregister.h" |
|
61 #include <aknPriv.hrh> |
|
62 #include "akntrace.h" |
|
63 |
|
64 enum { EEikMenuBarTitleArrayGranularity=10 }; |
|
65 enum { EEikMenuBarPosArrayGranularity=2 }; |
|
66 const TInt KExtraBaselineOffsetForFirstPaneItem=4; |
|
67 |
|
68 NONSHARABLE_CLASS(CEikMenuBarExtension) : public CBase, public MAknFadedComponent |
|
69 { |
|
70 public: |
|
71 static CEikMenuBarExtension* NewL(CEikMenuBar* aBar); |
|
72 ~CEikMenuBarExtension(); |
|
73 |
|
74 void FadeBehindPopup(TBool aFade); |
|
75 |
|
76 /** |
|
77 * Sets item specific commands dimmed if highlight is not visible. |
|
78 */ |
|
79 void SetItemCommandsDimmedL(); |
|
80 |
|
81 /** |
|
82 * Saves current value of iItemActionMenu->CollectionHighlightVisible() to |
|
83 * a member variable iCollectionHighlightVisible |
|
84 */ |
|
85 void StoreCollectionHighlightValue(); |
|
86 public: // from MAknFadedComponent |
|
87 TInt CountFadedComponents(); |
|
88 CCoeControl* FadedComponent(TInt aIndex); |
|
89 |
|
90 private: |
|
91 CEikMenuBarExtension(CEikMenuBar* aBar); |
|
92 void ConstructL(); |
|
93 |
|
94 private: |
|
95 CEikMenuBar* iBar; |
|
96 TAknPopupFader iFader; |
|
97 public: |
|
98 TInt iContextMenuTitleResourceId; |
|
99 TInt iOriginalMenuTitleResourceId; |
|
100 |
|
101 CEikMenuBar::TMenuType iMenuType; |
|
102 |
|
103 |
|
104 // controls fader and transition aborting behaviour |
|
105 // with transition effects |
|
106 TBool iDoingMenuCloseTransition; |
|
107 |
|
108 /** |
|
109 * Item action menu. |
|
110 * Not own. |
|
111 */ |
|
112 CAknItemActionMenu* iItemActionMenu; |
|
113 |
|
114 /** |
|
115 * When menu pane is opened this value is updated to store the value about |
|
116 * collection highlight visibility |
|
117 */ |
|
118 TBool iCollectionHighlightVisible; |
|
119 }; |
|
120 |
|
121 |
|
122 CEikMenuBarExtension* CEikMenuBarExtension::NewL(CEikMenuBar* aBar) |
|
123 { |
|
124 CEikMenuBarExtension* self = new(ELeave) CEikMenuBarExtension(aBar); |
|
125 CleanupStack::PushL(self); |
|
126 self->ConstructL(); |
|
127 CleanupStack::Pop(self); |
|
128 return self; |
|
129 } |
|
130 |
|
131 CEikMenuBarExtension::~CEikMenuBarExtension() |
|
132 { |
|
133 AknItemActionMenuRegister::UnregisterMenuBar( *iBar ); |
|
134 iBar = NULL; |
|
135 } |
|
136 |
|
137 void CEikMenuBarExtension::FadeBehindPopup(TBool aFade) |
|
138 { |
|
139 _AKNTRACE_FUNC_ENTER; |
|
140 _AKNTRACE( "iDoingMenuCloseTransition: %d", iDoingMenuCloseTransition ); |
|
141 if( iDoingMenuCloseTransition == EFalse ) |
|
142 { |
|
143 iFader.FadeBehindPopup(this, iBar, aFade); |
|
144 } |
|
145 _AKNTRACE_FUNC_EXIT; |
|
146 } |
|
147 |
|
148 |
|
149 void CEikMenuBarExtension::SetItemCommandsDimmedL() |
|
150 { |
|
151 if ( !iItemActionMenu ) |
|
152 { |
|
153 AknItemActionMenuRegister::RegisterMenuBarL( *iBar ); |
|
154 } |
|
155 // hide item-specific commands if highlight not visible |
|
156 if ( iBar->GetMenuType() != CEikMenuBar::EMenuContext |
|
157 && iItemActionMenu |
|
158 && !iItemActionMenu->CollectionHighlightVisible() ) |
|
159 { |
|
160 iBar->iMenuPane->SetItemCommandsDimmed(); |
|
161 } |
|
162 } |
|
163 |
|
164 |
|
165 void CEikMenuBarExtension::StoreCollectionHighlightValue() |
|
166 { |
|
167 if ( iItemActionMenu ) |
|
168 { |
|
169 iCollectionHighlightVisible |
|
170 = iItemActionMenu->CollectionHighlightVisible(); |
|
171 } |
|
172 } |
|
173 CEikMenuBarExtension::CEikMenuBarExtension(CEikMenuBar* aBar) |
|
174 :iBar(aBar), |
|
175 iDoingMenuCloseTransition(EFalse), |
|
176 iItemActionMenu( NULL ) |
|
177 { |
|
178 } |
|
179 |
|
180 void CEikMenuBarExtension::ConstructL() |
|
181 { |
|
182 } |
|
183 |
|
184 TInt CEikMenuBarExtension::CountFadedComponents() |
|
185 { |
|
186 TInt count = 1; // the cba |
|
187 |
|
188 // count the menu pane and it's cascade panes |
|
189 CEikMenuPane* pane = iBar->iMenuPane; |
|
190 while (pane) |
|
191 { |
|
192 count++; |
|
193 pane = pane->CascadeMenuPane(); |
|
194 } |
|
195 |
|
196 return count; |
|
197 } |
|
198 |
|
199 CCoeControl* CEikMenuBarExtension::FadedComponent(TInt aIndex) |
|
200 { |
|
201 if (aIndex == 0) |
|
202 return iBar->iMenuCba; |
|
203 |
|
204 // count down the list of cascade menus to find the one in question |
|
205 aIndex--; |
|
206 CEikMenuPane* pane = iBar->iMenuPane; |
|
207 while (aIndex > 0 && pane != NULL) |
|
208 { |
|
209 aIndex--; |
|
210 pane = pane->CascadeMenuPane(); |
|
211 } |
|
212 |
|
213 return pane; |
|
214 } |
|
215 |
|
216 |
|
217 // |
|
218 // class CTitleArray |
|
219 // |
|
220 |
|
221 EXPORT_C CEikMenuBar::CTitleArray::~CTitleArray() |
|
222 { |
|
223 ResetAndDestroy(); |
|
224 } |
|
225 |
|
226 EXPORT_C CEikMenuBar::CTitleArray::CTitleArray() |
|
227 : CArrayPtrFlat<CEikMenuBarTitle>(EEikMenuBarTitleArrayGranularity) |
|
228 { |
|
229 __DECLARE_NAME(_S("CEikMenuBar::CTitleArray")); |
|
230 } |
|
231 |
|
232 /** |
|
233 * Adds the menu bar title aMenuTitle to the end of the array owned by the menu bar |
|
234 * and transfers ownership. |
|
235 */ |
|
236 EXPORT_C void CEikMenuBar::CTitleArray::AddTitleL(CEikMenuBarTitle* aMenuTitle) |
|
237 { |
|
238 AppendL(aMenuTitle); |
|
239 } |
|
240 |
|
241 |
|
242 void CEikMenuBar::CTitleArray::DeleteResource(TInt aResource) |
|
243 { |
|
244 TInt count = Count(); |
|
245 for (TInt ii=0; ii<count; ii++) |
|
246 { |
|
247 CEikMenuBarTitle* title = At(ii); |
|
248 if (title->iData.iMenuPaneResourceId == aResource) |
|
249 { |
|
250 delete title; |
|
251 Delete(ii); |
|
252 return; |
|
253 } |
|
254 } |
|
255 } |
|
256 |
|
257 |
|
258 |
|
259 // |
|
260 // class CEikMenuBarTitle |
|
261 // |
|
262 |
|
263 //const TInt KTitleGranularity=1; |
|
264 //const TInt KIconOwnedExternally = 0x01; |
|
265 //const TInt KSameBitmapAndMask = 0x10; |
|
266 //const TInt KTitleWithImageMask = 0xf000; |
|
267 |
|
268 |
|
269 EXPORT_C CEikMenuBarTitle::CEikMenuBarTitle() |
|
270 {} |
|
271 |
|
272 EXPORT_C CEikMenuBarTitle::~CEikMenuBarTitle() |
|
273 { |
|
274 delete iIcon; |
|
275 } |
|
276 |
|
277 EXPORT_C void CEikMenuBarTitle::SetIcon(CGulIcon* aIcon) |
|
278 { |
|
279 if (iIcon) |
|
280 delete iIcon; |
|
281 iIcon = aIcon; |
|
282 } |
|
283 |
|
284 /** |
|
285 * Returns the value of the extra left margin for the title text which will take into account the |
|
286 * width of the title icon. |
|
287 */ |
|
288 TInt CEikMenuBarTitle::ExtraLeftMargin() const |
|
289 { |
|
290 CFbsBitmap* bitmap = IconBitmap(); |
|
291 TInt extraMargin = 0; |
|
292 if (bitmap != NULL) |
|
293 extraMargin = bitmap->SizeInPixels().iWidth; |
|
294 return extraMargin; |
|
295 } |
|
296 |
|
297 /** |
|
298 * Adjusts the value of the title text baseline offset aBaseLine to take into account the any |
|
299 * size of any title icon. |
|
300 */ |
|
301 void CEikMenuBarTitle::CalculateBaseLine(TInt& aBaseLine, TInt& aTitleHeight) |
|
302 { |
|
303 CFbsBitmap* bitmap = IconBitmap(); |
|
304 if (bitmap != NULL) |
|
305 { |
|
306 TInt tempBaseline = aBaseLine; |
|
307 const TSize bitmapSize(bitmap->SizeInPixels()); |
|
308 if (bitmapSize.iHeight > aTitleHeight) |
|
309 { |
|
310 tempBaseline += ((bitmapSize.iHeight - aTitleHeight) >> 1); |
|
311 aTitleHeight = bitmapSize.iHeight; |
|
312 } |
|
313 if (tempBaseline > aBaseLine) |
|
314 aBaseLine = tempBaseline; |
|
315 } |
|
316 } |
|
317 |
|
318 /** |
|
319 * Draws the title icon to the graphics context aGc, inside the rect aRect with an offset from the left side of |
|
320 * the rectangle of size aLeftMargin |
|
321 */ |
|
322 EXPORT_C void CEikMenuBarTitle::DrawIcon(CWindowGc& aGc, TRect aRect, TInt aLeftMargin) const |
|
323 { |
|
324 CFbsBitmap* bitmap = IconBitmap(); |
|
325 if (bitmap != NULL) |
|
326 { |
|
327 TSize imageSize = bitmap->SizeInPixels(); |
|
328 aRect.iTl.iX += aLeftMargin; |
|
329 TInt height = aRect.iBr.iY - aRect.iTl.iY; |
|
330 if (height > imageSize.iHeight) |
|
331 aRect.iTl.iY += (TInt) ((height - imageSize.iHeight) / 2 ); |
|
332 aGc.BitBltMasked(aRect.iTl, bitmap, imageSize, IconMask(), ETrue); |
|
333 } |
|
334 } |
|
335 |
|
336 /** |
|
337 * Sets the title icon to be ownded externally if aOwnedExternally is ETrue. |
|
338 */ |
|
339 EXPORT_C void CEikMenuBarTitle::SetBitmapsOwnedExternally(TBool aOwnedExternally) |
|
340 { |
|
341 iIcon->SetBitmapsOwnedExternally(aOwnedExternally); |
|
342 } |
|
343 |
|
344 /** |
|
345 * Returns a pointer to the picture bitmap of the title icon. |
|
346 * Does not normally imply transfer of ownership. |
|
347 */ |
|
348 EXPORT_C CFbsBitmap* CEikMenuBarTitle::IconBitmap() const |
|
349 { |
|
350 if (iIcon) |
|
351 return iIcon->Bitmap(); |
|
352 return NULL; |
|
353 } |
|
354 |
|
355 /** |
|
356 * Returns a pointer to the mask bitmap of the title icon. |
|
357 * Does not normally imply transfer of ownership. |
|
358 */ |
|
359 EXPORT_C CFbsBitmap* CEikMenuBarTitle::IconMask() const |
|
360 { |
|
361 if (iIcon) |
|
362 return iIcon->Mask(); |
|
363 return NULL; |
|
364 } |
|
365 |
|
366 /** |
|
367 * Sets the picture bitmap for the title icon to aBitmap. |
|
368 * Transfers ownership unless the bitmaps are owned externally. |
|
369 */ |
|
370 EXPORT_C void CEikMenuBarTitle::SetIconBitmapL(CFbsBitmap* aBitmap) |
|
371 { |
|
372 if (!iIcon) |
|
373 iIcon=CGulIcon::NewL(); |
|
374 |
|
375 iIcon->SetBitmap(aBitmap); |
|
376 } |
|
377 |
|
378 /** |
|
379 * Sets the mask bitmap for the title icon to aMask. |
|
380 * Transfers ownership unless the bitmaps are owned externally. |
|
381 */ |
|
382 EXPORT_C void CEikMenuBarTitle::SetIconMaskL(CFbsBitmap* aMask) |
|
383 { |
|
384 if (!iIcon) |
|
385 iIcon=CGulIcon::NewL(); |
|
386 |
|
387 iIcon->SetMask(aMask); |
|
388 } |
|
389 |
|
390 /** |
|
391 * Constructs an new icon for the title, taking ownership of the picture bitmap |
|
392 * aBitmap and the mask bitmap aMask unless the icon bitmaps have been set to be |
|
393 * owned externally. |
|
394 */ |
|
395 EXPORT_C void CEikMenuBarTitle::CreateIconL(CFbsBitmap* aBitmap, CFbsBitmap* aMask) |
|
396 { |
|
397 if (iIcon) |
|
398 delete iIcon; |
|
399 iIcon = CGulIcon::NewL(aBitmap, aMask); |
|
400 } |
|
401 |
|
402 |
|
403 // |
|
404 // class CEikMenuBar |
|
405 // |
|
406 |
|
407 //const TInt KEikMenuBarHBorder=8; |
|
408 //const TInt KEikMenuBarVBorder=2; |
|
409 //const TInt KEikMenuMnenPad=3; |
|
410 //const TInt KEikMaxMenuTitlePadding=10; |
|
411 //const TInt KEikNumOfSideButtons=5; |
|
412 //const TInt KEikSidebarPopupXPos=5; |
|
413 //const TInt KMenuPaneOverlap=1; |
|
414 |
|
415 //const TInt KMenuTitleLeftSpace = 12; |
|
416 //const TInt KMenuTitleRightSpace = 12; |
|
417 //const TInt KMenuTitleLeftSmallSpace = 2; |
|
418 //const TInt KMenuTitleRightSmallSpace = 2; |
|
419 |
|
420 inline TBool CEikMenuBar::MenuHasItems() const |
|
421 { |
|
422 return iMenuFlags&EMenuHasItems; |
|
423 } |
|
424 |
|
425 inline void CEikMenuBar::SetMenuHasItems() |
|
426 { |
|
427 iMenuFlags|=EMenuHasItems; |
|
428 iExt->StoreCollectionHighlightValue(); |
|
429 } |
|
430 |
|
431 inline TBool CEikMenuBar::MenuHasPane() const |
|
432 { |
|
433 return iMenuFlags&EMenuHasPane; |
|
434 } |
|
435 |
|
436 inline void CEikMenuBar::SetMenuHasPane() |
|
437 { |
|
438 iMenuFlags|=EMenuHasPane; |
|
439 } |
|
440 |
|
441 inline TBool CEikMenuBar::TitleArrayOwnedExternally() const |
|
442 { |
|
443 return iMenuFlags&ETitleArrayOwnedExternally; |
|
444 } |
|
445 |
|
446 EXPORT_C CEikMenuBar::~CEikMenuBar() |
|
447 { |
|
448 AKNTASHOOK_REMOVE(); |
|
449 // Inform FEP about the destruction. |
|
450 MEikMenuObserver* fepMenuObserver = CAknEnv::Static()->FepMenuObserver(); |
|
451 if ( fepMenuObserver ) |
|
452 { |
|
453 fepMenuObserver->ProcessCommandL( EAknCmdEditMenuClose ); |
|
454 } |
|
455 |
|
456 delete iPastMenuPosArray; |
|
457 iPastMenuPosArray = NULL; |
|
458 |
|
459 delete iHotKeyTable; |
|
460 iHotKeyTable = NULL; |
|
461 |
|
462 if ( iMenuPane ) |
|
463 { |
|
464 // make sure imenupane is not visible |
|
465 // otherwise Deregister may try to draw |
|
466 // when closing application |
|
467 iMenuPane->MakeVisible( EFalse ); |
|
468 // deregister main options menu component |
|
469 GfxTransEffect::Abort( iMenuPane ); |
|
470 GfxTransEffect::Deregister( iMenuPane ); |
|
471 delete iMenuPane; |
|
472 iMenuPane = NULL; |
|
473 } |
|
474 |
|
475 if ( !TitleArrayOwnedExternally() && iTitleArray ) |
|
476 { |
|
477 ResetTitleArray(); |
|
478 delete iTitleArray; |
|
479 iTitleArray = NULL; |
|
480 } |
|
481 |
|
482 delete iExt; |
|
483 iExt = NULL; |
|
484 |
|
485 if ( iMenuCba ) // should have been deleted before, but still... |
|
486 { |
|
487 delete iMenuCba; |
|
488 iMenuCba = NULL; |
|
489 } |
|
490 |
|
491 iMenuObserver = NULL; // not owned |
|
492 iEditMenuObserver = NULL; |
|
493 iActiveEditMenuObserver = NULL; |
|
494 |
|
495 } |
|
496 |
|
497 EXPORT_C CEikMenuBar::CEikMenuBar() |
|
498 : iSelectedTitle(ENothingSelected) |
|
499 { |
|
500 __DECLARE_NAME(_S("CEikMenuBar")); |
|
501 iBorder=TGulBorder(AknBorderId::EAknBorderMenuPopup); |
|
502 AKNTASHOOK_ADD( this, "CEikMenuBar" ); |
|
503 } |
|
504 |
|
505 /** |
|
506 * Resets the menu bar's title array and destroys its elements. |
|
507 * |
|
508 * @since ER5U |
|
509 */ |
|
510 void CEikMenuBar::ResetTitleArray() |
|
511 { |
|
512 if (iTitleArray) |
|
513 iTitleArray->ResetAndDestroy(); |
|
514 } |
|
515 |
|
516 /** |
|
517 * Creates a new menu bar title array if one does not already exist. Resets and destroys the elements |
|
518 * of an existing array.. |
|
519 * |
|
520 * @since ER5U |
|
521 */ |
|
522 void CEikMenuBar::CreateTitleArrayL() |
|
523 { |
|
524 if (iTitleArray) |
|
525 iTitleArray->ResetAndDestroy(); |
|
526 else |
|
527 iTitleArray=new(ELeave) CTitleArray; |
|
528 } |
|
529 |
|
530 /** |
|
531 * Sets the flags on the menu pane owned by the menu bar to aFlags. |
|
532 * |
|
533 * @since ER5U |
|
534 */ |
|
535 void CEikMenuBar::SetMenuPaneFlag(TInt aFlag) |
|
536 { |
|
537 iMenuPane->SetScrollBarOnLeft(aFlag&EEikMenuItemScrollBarLeft); |
|
538 iMenuPane->SetArrowHeadScrollBar(aFlag&EEikMenuItemScrollBarArrowHead); |
|
539 } |
|
540 |
|
541 |
|
542 EXPORT_C void CEikMenuBar::ConstructL(MEikMenuObserver* aMenuObserver,TInt aHotKeyResourceId,TInt aMenuTitleResourceId) |
|
543 { |
|
544 iExt = CEikMenuBarExtension::NewL(this); |
|
545 |
|
546 iMenuObserver=aMenuObserver; |
|
547 iMenuHotKeyResourceId=aHotKeyResourceId; |
|
548 iMenuTitleResourceId=aMenuTitleResourceId; |
|
549 iBaseLine=iEikonEnv->NormalFont()->AscentInPixels()+KExtraBaselineOffsetForFirstPaneItem; |
|
550 iPastMenuPosArray=new(ELeave) CArrayFixFlat<SPosition>(EEikMenuBarPosArrayGranularity); |
|
551 CreateTitleArrayL(); |
|
552 |
|
553 iMenuPane=new(ELeave) CEikMenuPane(iMenuObserver); |
|
554 iMenuPane->SetMopParent(this); |
|
555 iMenuPane->SetBorder(AknBorderId::EAknBorderMenuPopup); |
|
556 iMenuPane->SetParent( this ); |
|
557 MakeVisible(EFalse); |
|
558 // register main options menu component |
|
559 GfxTransEffect::Register( iMenuPane, KGfxOptionsMenuControlUid, EFalse ); |
|
560 GfxTransEffect::Enable(); |
|
561 } |
|
562 |
|
563 /** |
|
564 * Constructs the menu bar using the resource reader aReader. |
|
565 */ |
|
566 EXPORT_C void CEikMenuBar::ConstructFromResourceL(TResourceReader& aReader) |
|
567 { |
|
568 TInt count=aReader.ReadInt16(); |
|
569 while (count--) |
|
570 { |
|
571 CEikMenuBarTitle* title = new(ELeave) CEikMenuBarTitle; |
|
572 CleanupStack::PushL(title); |
|
573 title->iData.iMenuPaneResourceId=aReader.ReadInt32(); |
|
574 title->iTitleFlags=0; |
|
575 const TPtrC ptr=aReader.ReadTPtrC(); |
|
576 title->iData.iText=ptr; |
|
577 title->iTitleFlags=aReader.ReadInt32(); |
|
578 // Skip over icon info |
|
579 aReader.ReadTPtrC(); |
|
580 aReader.ReadInt16(); |
|
581 aReader.ReadInt16(); |
|
582 iTitleArray->AddTitleL(title); |
|
583 aReader.ReadInt32(); // extension link |
|
584 CleanupStack::Pop(); |
|
585 } |
|
586 aReader.ReadInt32(); // extension link |
|
587 } |
|
588 |
|
589 EXPORT_C void CEikMenuBar::FindCommandIdInResourceL(TInt aCommandId,TInt& aPaneindex,TInt& aItemindex) |
|
590 { |
|
591 aPaneindex=-1; |
|
592 aItemindex=-1; |
|
593 TResourceReader reader; |
|
594 |
|
595 TInt panes=iTitleArray->Count(); |
|
596 for (TInt pindex=0;pindex<panes;++pindex) |
|
597 { |
|
598 CEikMenuBarTitle* title=(*iTitleArray)[pindex]; |
|
599 ControlEnv()->CreateResourceReaderLC(reader,title->iData.iMenuPaneResourceId); |
|
600 const TInt count=reader.ReadInt16(); |
|
601 for (TInt iindex=0;iindex<count;++iindex) |
|
602 { |
|
603 TInt commandId=reader.ReadInt32(); |
|
604 reader.ReadInt32(); //cascadeId |
|
605 reader.ReadInt32(); // data flags |
|
606 reader.ReadTPtrC(); |
|
607 reader.ReadTPtrC(); |
|
608 reader.ReadInt32(); // title flags |
|
609 reader.ReadTPtrC(); // bitmap file |
|
610 reader.ReadInt16(); // bitmapId |
|
611 reader.ReadInt16(); // bitmapMaskId |
|
612 reader.ReadInt32(); // item extension |
|
613 if (commandId==aCommandId) |
|
614 { |
|
615 aItemindex=iindex; |
|
616 break; |
|
617 } |
|
618 } |
|
619 if (aItemindex>=0) |
|
620 { |
|
621 aPaneindex=pindex; |
|
622 CleanupStack::PopAndDestroy(); // buffer(reader) |
|
623 return; |
|
624 } |
|
625 CleanupStack::PopAndDestroy(); // buffer(reader) |
|
626 } |
|
627 } |
|
628 |
|
629 |
|
630 EXPORT_C void CEikMenuBar::ChangeMenuBarL(TInt /*aHotKeyResourceId*/,TInt /*aMenuTitleResourceId*/,TBool /*aDisplayNow*/) |
|
631 { |
|
632 } |
|
633 |
|
634 void CEikMenuBar::SaveCurrentMenuPositionL() |
|
635 //Save position on current menu |
|
636 //See if current menu is already on past menu array. |
|
637 //If it is, just change the cursor value, if it is not |
|
638 //add a new element to the array. |
|
639 { |
|
640 const TInt count = iPastMenuPosArray->Count(); |
|
641 for (TInt ii = 0; ii < count; ++ii) |
|
642 { |
|
643 if ((*iPastMenuPosArray)[ii].iMenuId == iMenuTitleResourceId) |
|
644 { |
|
645 (*iPastMenuPosArray)[ii].iMenuCursorPos = iCursor; |
|
646 return; |
|
647 } |
|
648 } |
|
649 SPosition menuPos; |
|
650 menuPos.iMenuId = iMenuTitleResourceId; |
|
651 menuPos.iMenuCursorPos = iCursor; |
|
652 iPastMenuPosArray->AppendL(&menuPos, sizeof(menuPos)); |
|
653 } |
|
654 |
|
655 void CEikMenuBar::SetCursorPositionFromArray() |
|
656 //Set cursor position |
|
657 //Check position array to see if menu previously displayed and use that last position. |
|
658 { |
|
659 const TInt count=iPastMenuPosArray?iPastMenuPosArray->Count():0; |
|
660 for (TInt ii=0;ii<count;++ii)//Use same count as above cos we wont be interested in menu we have just added to the list |
|
661 { |
|
662 if ((*iPastMenuPosArray)[ii].iMenuId==iMenuTitleResourceId) |
|
663 { |
|
664 iCursor=(*iPastMenuPosArray)[ii].iMenuCursorPos; |
|
665 return; |
|
666 } |
|
667 } |
|
668 iCursor.iMenuPaneIndex=0; |
|
669 iCursor.iMenuItemIndex=0; |
|
670 } |
|
671 |
|
672 EXPORT_C CEikHotKeyTable* CEikMenuBar::SetHotKeyTable(CEikHotKeyTable* /*aHotKeyTable*/) |
|
673 { |
|
674 return NULL; |
|
675 } |
|
676 |
|
677 EXPORT_C void CEikMenuBar::SetMenuTitleResourceId(TInt aMenuTitleResourceId) |
|
678 { |
|
679 SetCursorPositionFromArray(); // defaults set here if this menu not previously displayed |
|
680 if (iMenuPane && !MenuHasPane()) |
|
681 { |
|
682 iMenuPane->SetSelectedItem(0); |
|
683 } |
|
684 iSelectedTitle=ENothingSelected; |
|
685 iMenuTitleResourceId=aMenuTitleResourceId; |
|
686 } |
|
687 |
|
688 EXPORT_C void CEikMenuBar::SetContextMenuTitleResourceId(TInt aMenuTitleResourceId) |
|
689 { |
|
690 SetCursorPositionFromArray(); // defaults set here if this menu not previously displayed |
|
691 if (iMenuPane && !MenuHasPane()) |
|
692 { |
|
693 iMenuPane->SetSelectedItem(0); |
|
694 } |
|
695 iSelectedTitle=ENothingSelected; |
|
696 iExt->iContextMenuTitleResourceId=aMenuTitleResourceId; |
|
697 } |
|
698 |
|
699 EXPORT_C void CEikMenuBar::SetMenuTitleArray(CTitleArray* /*aTitleArray*/) |
|
700 { |
|
701 } |
|
702 |
|
703 /** |
|
704 * Sets the menu bar title array to be owned externally if aOwnedExternally is ETrue. |
|
705 * |
|
706 * since ER5U |
|
707 */ |
|
708 EXPORT_C void CEikMenuBar::SetTitleArrayOwnedExternally(TBool /*aOwnedExternally*/) |
|
709 { |
|
710 } |
|
711 |
|
712 EXPORT_C TKeyResponse CEikMenuBar::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
713 { |
|
714 const TInt code=aKeyEvent.iCode; |
|
715 |
|
716 if (MenuHasPane()) |
|
717 { |
|
718 iMenuPane->OfferKeyEventL(aKeyEvent, aType); |
|
719 return (aKeyEvent.iScanCode == EStdKeyYes ? EKeyWasNotConsumed : EKeyWasConsumed); |
|
720 } |
|
721 else |
|
722 { |
|
723 switch (code) |
|
724 { |
|
725 case EEikSidebarMenuKey: |
|
726 case EKeyMenu: |
|
727 TryDisplayMenuBarL(); |
|
728 return EKeyWasConsumed; |
|
729 default: |
|
730 break; |
|
731 } |
|
732 } |
|
733 |
|
734 if (!MenuHasItems()) // menu bar not currently displayed |
|
735 return EKeyWasNotConsumed; |
|
736 |
|
737 // When displaying, the menu bar must comsume all keys, even those it doesn't use. |
|
738 // So use callback here to see if app wants key. |
|
739 iMenuObserver->OfferKeyToAppL(aKeyEvent, aType); |
|
740 return EKeyWasConsumed; |
|
741 |
|
742 } |
|
743 |
|
744 |
|
745 |
|
746 LOCAL_C void CleanupMenu(TAny* aPtr) |
|
747 { |
|
748 ((CEikMenuBar*)aPtr)->StopDisplayingMenuBar(); |
|
749 } |
|
750 |
|
751 EXPORT_C TInt CEikMenuBar::SelectedTitle() |
|
752 { |
|
753 return iCursor.iMenuPaneIndex; |
|
754 } |
|
755 |
|
756 EXPORT_C TInt CEikMenuBar::SelectedItem() |
|
757 { |
|
758 return iCursor.iMenuItemIndex; |
|
759 } |
|
760 |
|
761 EXPORT_C void CEikMenuBar::TryDisplayMenuBarL() |
|
762 { |
|
763 if (MenuHasItems()) |
|
764 return; // menu already being displayed |
|
765 iActiveEditMenuObserver = iEditMenuObserver; |
|
766 CleanupStack::PushL(TCleanupItem(CleanupMenu,this)); |
|
767 StartDisplayingMenuBarL(); |
|
768 CleanupStack::Pop(); |
|
769 } |
|
770 |
|
771 EXPORT_C void CEikMenuBar::TryDisplayContextMenuBarL() |
|
772 { |
|
773 if (MenuHasItems() || !iExt || !iExt->iContextMenuTitleResourceId) |
|
774 return; // menu already being displayed or no extension or no context resource id |
|
775 iActiveEditMenuObserver = iEditMenuObserver; |
|
776 CleanupStack::PushL(TCleanupItem(CleanupMenu,this)); |
|
777 // use context specific menu resource for this menu |
|
778 iExt->iOriginalMenuTitleResourceId = iMenuTitleResourceId; |
|
779 iMenuTitleResourceId = iExt->iContextMenuTitleResourceId; |
|
780 SetMenuType(EMenuContext); |
|
781 StartDisplayingMenuBarL(); |
|
782 CleanupStack::Pop(); |
|
783 } |
|
784 |
|
785 |
|
786 void CEikMenuBar::HideMenuPane() |
|
787 { |
|
788 if (MenuHasPane()) |
|
789 { |
|
790 iCursor.iMenuPaneIndex=iSelectedTitle; // !! check this can never be -1 |
|
791 iCursor.iMenuItemIndex=iMenuPane->SelectedItem(); |
|
792 iMenuPane->CancelActiveMenuPane(); |
|
793 iMenuFlags&=~EMenuHasPane; |
|
794 iMenuPane->Reset(); |
|
795 iMenuPane->MakeVisible(EFalse); |
|
796 } |
|
797 iSelectedTitle=ENothingSelected; |
|
798 } |
|
799 |
|
800 |
|
801 EXPORT_C void CEikMenuBar::MoveHighlightToL(TInt /*aNewSelectedTitle*/,TInt /*aNewSelectedItem*/) |
|
802 { |
|
803 } |
|
804 |
|
805 EXPORT_C void CEikMenuBar::StopDisplayingMenuBar() |
|
806 { |
|
807 _AKNTRACE_FUNC_ENTER; |
|
808 if (iMenuFlags&ESoundsInstalled) |
|
809 { |
|
810 iAvkonAppUi->KeySounds()->PopContext(); |
|
811 iMenuFlags &= ~ESoundsInstalled; |
|
812 } |
|
813 if( !iExt->iDoingMenuCloseTransition && IsDisplayed() ) |
|
814 { |
|
815 // abort component effects |
|
816 GfxTransEffect::Abort(); |
|
817 } |
|
818 |
|
819 iAvkonEnv->UnRegisterIntermediateState(this); |
|
820 |
|
821 delete iMenuCba; |
|
822 iMenuCba = NULL; |
|
823 |
|
824 iMenuObserver->SetEmphasis(this,EFalse); |
|
825 iMenuFlags&=~EMenuHasItems; |
|
826 HideMenuPane(); |
|
827 MEikMenuObserver* fepMenuObserver = CAknEnv::Static()->FepMenuObserver(); |
|
828 if (fepMenuObserver) |
|
829 fepMenuObserver->SetEmphasis(this, EFalse); |
|
830 if (iActiveEditMenuObserver) |
|
831 iActiveEditMenuObserver->SetEmphasis(this, EFalse); |
|
832 iActiveEditMenuObserver=NULL; // forget active observer till menu next added |
|
833 iMenuPane->SetFocus(EFalse); |
|
834 iMenuPane->Close(); |
|
835 iTitleArray->ResetAndDestroy(); |
|
836 if (OwnsWindow()) |
|
837 CloseWindow(); |
|
838 |
|
839 // normal options menu must be restored if context specific menu was displayed |
|
840 if (iExt && iMenuTitleResourceId == iExt->iContextMenuTitleResourceId && |
|
841 iExt->iOriginalMenuTitleResourceId) |
|
842 { |
|
843 iMenuTitleResourceId = iExt->iOriginalMenuTitleResourceId; |
|
844 SetMenuType(EMenuOptions); |
|
845 } |
|
846 |
|
847 if (iMenuFlags&EBackgroundFaded) |
|
848 { |
|
849 if (iExt) |
|
850 iExt->FadeBehindPopup(EFalse); |
|
851 iMenuFlags &= ~EBackgroundFaded; |
|
852 } |
|
853 _AKNTRACE_FUNC_EXIT; |
|
854 } |
|
855 |
|
856 void CEikMenuBar::StartDisplayingMenuBarL() |
|
857 { |
|
858 _AKNTRACE_FUNC_ENTER; |
|
859 // Inform AIW framework that a menu bar is being launched. |
|
860 CAiwServiceHandler::ReportMenuLaunch(); |
|
861 |
|
862 CreateWindowL(iCoeEnv->RootWin()); |
|
863 const TSize screenSize = iAvkonAppUi->ApplicationRect().Size(); |
|
864 |
|
865 __ASSERT_DEBUG(iMenuCba == NULL, User::Panic(_L("CEikMenuBar"), KErrAlreadyExists)); |
|
866 TInt softkeyResourceId = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT; |
|
867 if ((User::Language() & KAknLanguageMask) == ELangJapanese) |
|
868 { |
|
869 // In Japanese UI language Select-Back softkey combination is used. |
|
870 // Command Id for Back is same as for Cancel. |
|
871 softkeyResourceId = R_AVKON_SOFTKEYS_SELECT_BACK__SELECT; |
|
872 } |
|
873 |
|
874 iMenuPane->ConstructL(NULL, iActiveEditMenuObserver); |
|
875 |
|
876 MEikMenuObserver* fepMenuObserver = CAknEnv::Static()->FepMenuObserver(); |
|
877 |
|
878 iMenuObserver->RestoreMenuL(this,iMenuTitleResourceId,MEikMenuObserver::EMenuBar); |
|
879 |
|
880 if (fepMenuObserver) |
|
881 { |
|
882 AddFEPMenuL(); |
|
883 fepMenuObserver->DynInitMenuBarL(iMenuTitleResourceId, this); |
|
884 } |
|
885 |
|
886 TInt titles = iTitleArray->Count() - 1; |
|
887 |
|
888 if ( titles < 0 ) |
|
889 { |
|
890 delete iMenuCba; |
|
891 iMenuCba = NULL; |
|
892 iTitleArray->ResetAndDestroy(); |
|
893 iMenuPane->Close(); |
|
894 return; |
|
895 } |
|
896 |
|
897 // Create the menu pane using the last pane in the menu bar |
|
898 iMenuObserver->RestoreMenuL(iMenuPane,(*iTitleArray)[titles]->iData.iMenuPaneResourceId,MEikMenuObserver::EMenuPane); |
|
899 if (fepMenuObserver) |
|
900 fepMenuObserver->DynInitMenuPaneL((*iTitleArray)[titles]->iData.iMenuPaneResourceId,iMenuPane); |
|
901 if (iActiveEditMenuObserver) |
|
902 iActiveEditMenuObserver->DynInitMenuPaneL((*iTitleArray)[titles]->iData.iMenuPaneResourceId,iMenuPane); |
|
903 |
|
904 titles = iTitleArray->Count() - 2; |
|
905 iMenuPane->FilterDimmedItems(); |
|
906 |
|
907 // Add the remaining menu panes from right to left at the end of the current pane |
|
908 while (titles >= 0) |
|
909 { |
|
910 TInt resource = (*iTitleArray)[titles]->iData.iMenuPaneResourceId; |
|
911 iMenuPane->AddMenuItemsL(resource, 0, ETrue); |
|
912 iMenuObserver->DynInitMenuPaneL(resource,iMenuPane); |
|
913 if (fepMenuObserver) |
|
914 fepMenuObserver->DynInitMenuPaneL(resource,iMenuPane); |
|
915 if (iActiveEditMenuObserver) |
|
916 iActiveEditMenuObserver->DynInitMenuPaneL(resource,iMenuPane); |
|
917 iExt->SetItemCommandsDimmedL(); |
|
918 iMenuPane->FilterDimmedItems(); |
|
919 titles--; |
|
920 } |
|
921 iMenuObserver->SetEmphasis(this,ETrue); |
|
922 iMenuCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, |
|
923 CEikButtonGroupContainer::EHorizontal, |
|
924 this, softkeyResourceId, *iMenuPane, |
|
925 CEikButtonGroupContainer::EIsEmbedded | |
|
926 CEikButtonGroupContainer::EDelayActivation ); |
|
927 |
|
928 CEikCba* cba = static_cast<CEikCba*>( iMenuCba->ButtonGroup() ); |
|
929 if ( cba ) |
|
930 { |
|
931 iMenuPane->SetEmbeddedCba( cba ); |
|
932 } |
|
933 |
|
934 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
935 if ( feedback ) |
|
936 { |
|
937 feedback->FlushRegistryUpdates(); |
|
938 } |
|
939 |
|
940 TInt taskSwapper ( ETaskSwapper ); |
|
941 RProperty::Get( |
|
942 KPSUidAvkonInternal, |
|
943 KAknMenuOptionNoTaskSwapper, |
|
944 taskSwapper); |
|
945 if ( iMenuPane->NumberOfItemsInPane() != 0 && iExt->iMenuType == EMenuOptions && taskSwapper == ETaskSwapper ) |
|
946 { |
|
947 // 'Active Applications' menu item is added at the first item of the |
|
948 // options menu after other menu items are added. |
|
949 iMenuPane->AddMenuItemsL(R_AVKON_MENUPANE_TASK_SWAPPER); |
|
950 } |
|
951 |
|
952 if (iMenuPane->NumberOfItemsInPane() == 0) |
|
953 { |
|
954 delete iMenuCba; |
|
955 iMenuCba = NULL; |
|
956 iMenuObserver->SetEmphasis(this,EFalse); |
|
957 iTitleArray->ResetAndDestroy(); |
|
958 iMenuPane->Close(); |
|
959 return; |
|
960 } |
|
961 |
|
962 if (!(iMenuFlags&EBackgroundFaded)) |
|
963 { |
|
964 iExt->FadeBehindPopup(ETrue); |
|
965 iMenuFlags |= EBackgroundFaded; |
|
966 } |
|
967 |
|
968 iMenuCba->SetBoundingRect(TRect(TPoint(0,0), screenSize)); |
|
969 |
|
970 SetMenuHasPane(); |
|
971 SetMenuHasItems(); |
|
972 |
|
973 TInt positionOffTaskSwapper; |
|
974 if (iMenuPane->MenuItemExists(EAknCmdTaskSwapper, positionOffTaskSwapper)) |
|
975 { |
|
976 // Default selected item is just after 'Active Applications' menu |
|
977 // item if it exists. |
|
978 iMenuPane->SetSelectedItem(positionOffTaskSwapper + 1); |
|
979 } |
|
980 else |
|
981 { |
|
982 iMenuPane->SetSelectedItem( 0 ); |
|
983 } |
|
984 |
|
985 iMenuPane->SetFocus(ETrue); |
|
986 if (fepMenuObserver) |
|
987 fepMenuObserver->SetEmphasis(this, ETrue); |
|
988 if (iActiveEditMenuObserver) |
|
989 iActiveEditMenuObserver->SetEmphasis(this, ETrue); |
|
990 |
|
991 // Set the position of the menu pane to the top of the CBA area, |
|
992 // and set the width to the width of the screen |
|
993 TPoint menuPosition = TPoint(0, screenSize.iHeight - iMenuCba->Size().iHeight); |
|
994 |
|
995 if(AknLayoutUtils::PenEnabled()) |
|
996 { |
|
997 // menu pane captures all pointer events, and forwards them to CBA if neccessary |
|
998 iMenuPane->SetGloballyCapturing(ETrue); |
|
999 iMenuPane->SetPointerCapture(ETrue); |
|
1000 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1001 if ( feedback ) |
|
1002 { |
|
1003 TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp; |
|
1004 if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) ) |
|
1005 { |
|
1006 fbLogicalType = ETouchFeedbackIncreasingPopUp; |
|
1007 } |
|
1008 feedback->InstantFeedback( |
|
1009 this, |
|
1010 fbLogicalType, |
|
1011 ETouchFeedbackVibra, |
|
1012 TPointerEvent() ); |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 iMenuPane->MakeVisible( EFalse ); |
|
1017 |
|
1018 // options menu launch animation |
|
1019 TBool optMenuFg = iAvkonAppUi->IsForeground(); |
|
1020 |
|
1021 if( optMenuFg ) |
|
1022 { |
|
1023 GfxTransEffect::Begin( iMenuPane, KGfxControlAppearAction ); |
|
1024 } |
|
1025 |
|
1026 iMenuPane->StartDisplayingMenuPane(NULL, menuPosition, NULL, screenSize.iWidth, EPopupTargetBottomLeft); |
|
1027 iMenuCba->ActivateL(); |
|
1028 |
|
1029 iAvkonEnv->RegisterIntermediateStateL(this); |
|
1030 iAvkonAppUi->KeySounds()->PushContextL(R_AVKON_DEFAULT_SKEY_LIST); |
|
1031 iMenuFlags |= ESoundsInstalled; |
|
1032 |
|
1033 if( optMenuFg ) |
|
1034 { |
|
1035 TRect demarcation; |
|
1036 CAknTransitionUtils::GetDemarcation( CAknTransitionUtils::EOptionsMenu, |
|
1037 demarcation ); |
|
1038 GfxTransEffect::SetDemarcation( iMenuPane, demarcation ); |
|
1039 GfxTransEffect::End( iMenuPane ); |
|
1040 } |
|
1041 _AKNTRACE_FUNC_EXIT; |
|
1042 } |
|
1043 |
|
1044 |
|
1045 EXPORT_C void CEikMenuBar::Draw(const TRect& /*aRect*/) const |
|
1046 { |
|
1047 |
|
1048 } |
|
1049 |
|
1050 EXPORT_C void CEikMenuBar::DrawItem(TInt /*aItem*/) const |
|
1051 { |
|
1052 } |
|
1053 |
|
1054 EXPORT_C void* CEikMenuBar::ExtensionInterface( TUid /*aInterface*/ ) |
|
1055 { |
|
1056 return NULL; |
|
1057 } |
|
1058 |
|
1059 EXPORT_C void CEikMenuBar::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
1060 { |
|
1061 const TRect rect=Rect(); |
|
1062 if (!rect.Contains(aPointerEvent.iPosition)) |
|
1063 { |
|
1064 switch (aPointerEvent.iType) |
|
1065 { |
|
1066 case TPointerEvent::EButton1Down: |
|
1067 case TPointerEvent::EButton1Up: |
|
1068 ProcessCommandL( EAknSoftkeyCancel ); |
|
1069 iMenuObserver->ProcessCommandL(EEikCmdCanceled); // shouldn't Leave in practiceReportCancelled(); |
|
1070 return; |
|
1071 case TPointerEvent::EDrag: |
|
1072 // dragging off a pane sometimes sends the events to the bar; this code redirects the event |
|
1073 // to the pane so that highlighing can be removed. |
|
1074 if (iMenuPane) |
|
1075 { |
|
1076 TPoint panepos= iMenuPane->Position(); |
|
1077 TRect panerect= TRect(panepos, iMenuPane->Size()); |
|
1078 if (!panerect.Contains(aPointerEvent.iPosition)) |
|
1079 { |
|
1080 TPointerEvent aPEvent=aPointerEvent; |
|
1081 aPEvent.iPosition=aPointerEvent.iPosition - panepos; |
|
1082 iMenuPane->HandlePointerEventL(aPEvent); |
|
1083 } |
|
1084 } |
|
1085 return; |
|
1086 default: |
|
1087 return; |
|
1088 } |
|
1089 } |
|
1090 const TInt yPos=aPointerEvent.iPosition.iY; |
|
1091 if (yPos<2 || yPos>iSize.iHeight-2) |
|
1092 return; |
|
1093 const TInt xPos=aPointerEvent.iPosition.iX; |
|
1094 const TInt count=iTitleArray->Count(); |
|
1095 for (TInt ii=0;ii<count;++ii) |
|
1096 { |
|
1097 CEikMenuBarTitle* title=(*iTitleArray)[ii]; |
|
1098 if (xPos<title->iPos) |
|
1099 return; |
|
1100 if (xPos<title->iPos+title->iWidth) |
|
1101 { |
|
1102 MoveHighlightToL(ii); |
|
1103 return; |
|
1104 } |
|
1105 } |
|
1106 } |
|
1107 |
|
1108 EXPORT_C TCoeInputCapabilities CEikMenuBar::InputCapabilities() const |
|
1109 { |
|
1110 return TCoeInputCapabilities(TCoeInputCapabilities::EAllText); // Max length parameter removed for Release15 |
|
1111 } |
|
1112 |
|
1113 EXPORT_C CEikMenuBar::SCursor CEikMenuBar::SetMenuCursor(const SCursor& aCursor) |
|
1114 { |
|
1115 SCursor ret=iCursor; |
|
1116 iCursor=aCursor; |
|
1117 return ret; |
|
1118 } |
|
1119 |
|
1120 /** |
|
1121 * Gets the list of logical colors employed in the drawing of the control, |
|
1122 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
1123 * |
|
1124 * @since ER5U |
|
1125 */ |
|
1126 EXPORT_C void CEikMenuBar::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
1127 { |
|
1128 LafMenuBar::GetColorUseListL(aColorUseList); |
|
1129 } |
|
1130 |
|
1131 /** |
|
1132 * Handles a change to the control's resources of type aType |
|
1133 * which are shared across the environment, e.g. colors or fonts. |
|
1134 * |
|
1135 * @since ER5U |
|
1136 */ |
|
1137 EXPORT_C void CEikMenuBar::HandleResourceChange(TInt aType) |
|
1138 { |
|
1139 if ( aType == KEikDynamicLayoutVariantSwitch |
|
1140 || aType == KEikMessageWindowsFadeChange |
|
1141 || aType == KEikMessageUnfadeWindows |
|
1142 || aType == KEikMessageFadeAllWindows |
|
1143 || aType == KAknMessageFocusLost |
|
1144 || ( IsDisplayed() && aType == KAknsMessageSkinChange ) ) |
|
1145 { |
|
1146 if ( iMenuPane ) |
|
1147 { |
|
1148 iMenuPane->HandleResourceChange( aType ); |
|
1149 } |
|
1150 } |
|
1151 } |
|
1152 |
|
1153 EXPORT_C void CEikMenuBar::Reserved_1() |
|
1154 {} |
|
1155 |
|
1156 EXPORT_C void CEikMenuBar::Reserved_2() |
|
1157 {} |
|
1158 |
|
1159 void CEikMenuBar::ProcessCommandL(TInt aCommandId) |
|
1160 { |
|
1161 TRect demarcation; |
|
1162 switch (aCommandId) |
|
1163 { |
|
1164 // AKNLAF start |
|
1165 case EAknSoftkeyOk: |
|
1166 iMenuPane->ActivateCurrentItemL(); |
|
1167 break; |
|
1168 case EAknSoftkeySelect: |
|
1169 iMenuPane->ActivateCurrentItemL(); |
|
1170 break; |
|
1171 case EAknSoftkeyCancel: |
|
1172 // options menu cancel animation, does not apply to the case |
|
1173 // when something is chosen from the menu |
|
1174 GfxTransEffect::Begin( iMenuPane, KGfxControlDisappearAction ); |
|
1175 |
|
1176 iExt->iDoingMenuCloseTransition = ETrue; |
|
1177 StopDisplayingMenuBar(); |
|
1178 iExt->iDoingMenuCloseTransition = EFalse; |
|
1179 |
|
1180 CAknTransitionUtils::GetDemarcation( |
|
1181 CAknTransitionUtils::EOptionsMenu, demarcation ); |
|
1182 GfxTransEffect::SetDemarcation( iMenuPane, demarcation ); |
|
1183 GfxTransEffect::End( iMenuPane ); |
|
1184 |
|
1185 // do the fading a bit later than in StopDisplayingMenuBar |
|
1186 iExt->FadeBehindPopup( EFalse ); |
|
1187 |
|
1188 if ( AknLayoutUtils::PenEnabled() ) |
|
1189 { |
|
1190 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1191 if ( feedback ) |
|
1192 { |
|
1193 TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp; |
|
1194 if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) ) |
|
1195 { |
|
1196 fbLogicalType = ETouchFeedbackDecreasingPopUp; |
|
1197 } |
|
1198 feedback->InstantFeedback( |
|
1199 this, |
|
1200 fbLogicalType, |
|
1201 ETouchFeedbackVibra, |
|
1202 TPointerEvent() ); |
|
1203 } |
|
1204 } |
|
1205 break; |
|
1206 // AKNLAF end |
|
1207 default: |
|
1208 break; |
|
1209 } |
|
1210 } |
|
1211 |
|
1212 |
|
1213 EXPORT_C void CEikMenuBar::ReduceRect(TRect& aRect) const |
|
1214 { |
|
1215 if (!IsVisible()) |
|
1216 return; |
|
1217 aRect.iTl.iY+=iSize.iHeight; |
|
1218 } |
|
1219 |
|
1220 |
|
1221 void CEikMenuBar::AddFEPMenuL() |
|
1222 { |
|
1223 if (iPreventFepMenu) |
|
1224 { |
|
1225 iPreventFepMenu = EFalse; |
|
1226 iTitleArray->DeleteResource(R_AVKON_MENUPANE_LANGUAGE_DEFAULT); |
|
1227 iTitleArray->DeleteResource(R_AVKON_MENUPANE_EDITTEXT_DEFAULT); |
|
1228 iTitleArray->DeleteResource(R_AVKON_MENUPANE_FEP_DEFAULT); |
|
1229 } |
|
1230 else |
|
1231 { |
|
1232 AddMenuIfNotPresentL(R_AVKON_MENUPANE_LANGUAGE_DEFAULT); |
|
1233 AddMenuIfNotPresentL(R_AVKON_MENUPANE_EDITTEXT_DEFAULT); |
|
1234 AddMenuIfNotPresentL(R_AVKON_MENUPANE_FEP_DEFAULT); |
|
1235 } |
|
1236 } |
|
1237 |
|
1238 void CEikMenuBar::AddMenuIfNotPresentL(TInt aResourceId) |
|
1239 { |
|
1240 TInt titleCount = iTitleArray->Count(); |
|
1241 for (TInt ii=0; ii<titleCount; ii++) |
|
1242 { |
|
1243 if ((*(iTitleArray))[ii]->iData.iMenuPaneResourceId == aResourceId) |
|
1244 return; |
|
1245 } |
|
1246 |
|
1247 // Automatically add the FEP menu to the top of the menu |
|
1248 CEikMenuBarTitle* title = new(ELeave) CEikMenuBarTitle; |
|
1249 CleanupStack::PushL(title); |
|
1250 title->iData.iMenuPaneResourceId = aResourceId; |
|
1251 title->iTitleFlags=0; |
|
1252 iTitleArray->AddTitleL(title); |
|
1253 CleanupStack::Pop(); |
|
1254 } |
|
1255 |
|
1256 |
|
1257 EXPORT_C CEikMenuPane* CEikMenuBar::MenuPane() |
|
1258 { |
|
1259 return iMenuPane; |
|
1260 } |
|
1261 |
|
1262 EXPORT_C CEikMenuBar::CTitleArray* CEikMenuBar::TitleArray() |
|
1263 { |
|
1264 return iTitleArray; |
|
1265 } |
|
1266 |
|
1267 EXPORT_C void CEikMenuBar::SetEditMenuObserver(MEikMenuObserver* aEditMenuObserver) |
|
1268 { |
|
1269 iEditMenuObserver = aEditMenuObserver; |
|
1270 } |
|
1271 |
|
1272 void CEikMenuBar::UpdateTitleTextBaseline() |
|
1273 { |
|
1274 iBaseLine = LafMenuBar::NormalFont(iEikonEnv->LafEnv())->AscentInPixels() + LafMenuBar::ExtraBaselineOffsetForFirstPaneItem(); |
|
1275 if (iTitleArray) |
|
1276 { |
|
1277 const TInt count = iTitleArray->Count(); |
|
1278 TInt maxTitleHeight = LafMenuBar::NormalFont(iEikonEnv->LafEnv())->HeightInPixels(); |
|
1279 TInt baselineOffset = 0; |
|
1280 for (TInt ii = 0; ii < count; ii++) |
|
1281 { |
|
1282 CEikMenuBarTitle* title=(*iTitleArray)[ii]; |
|
1283 title->CalculateBaseLine(iBaseLine, maxTitleHeight); |
|
1284 } |
|
1285 iBaseLine += baselineOffset; |
|
1286 } |
|
1287 } |
|
1288 EXPORT_C void CEikMenuBar::RemoveEditMenuObserver(MEikMenuObserver* aEditMenuObserver) |
|
1289 { |
|
1290 if (iActiveEditMenuObserver == aEditMenuObserver) |
|
1291 iActiveEditMenuObserver = NULL; |
|
1292 if (iEditMenuObserver == aEditMenuObserver) |
|
1293 iEditMenuObserver = NULL; |
|
1294 } |
|
1295 |
|
1296 // |
|
1297 // class CEikMenuPaneTitle |
|
1298 // |
|
1299 |
|
1300 EXPORT_C CEikMenuPaneTitle::CEikMenuPaneTitle(CEikMenuBar* aMenuBar) |
|
1301 : iMenuBar(aMenuBar) |
|
1302 { |
|
1303 AKNTASHOOK_ADD( this, "CEikMenuPaneTitle" ); |
|
1304 } |
|
1305 |
|
1306 EXPORT_C void CEikMenuPaneTitle::ConstructL() |
|
1307 { |
|
1308 } |
|
1309 |
|
1310 EXPORT_C void CEikMenuPaneTitle::SetSelectedTitle(TInt /*aSelectedTitle*/) |
|
1311 { |
|
1312 } |
|
1313 |
|
1314 EXPORT_C void CEikMenuPaneTitle::Draw(const TRect& /*aRect*/) const |
|
1315 { |
|
1316 } |
|
1317 |
|
1318 EXPORT_C void CEikMenuPaneTitle::HandlePointerEventL(const TPointerEvent&) |
|
1319 { |
|
1320 } |
|
1321 |
|
1322 EXPORT_C void* CEikMenuPaneTitle::ExtensionInterface( TUid /*aInterface*/ ) |
|
1323 { |
|
1324 return NULL; |
|
1325 } |
|
1326 |
|
1327 EXPORT_C TMargins CEikMenuPaneTitle::Margins() const |
|
1328 { |
|
1329 return iBorder.Margins(); |
|
1330 } |
|
1331 |
|
1332 EXPORT_C void CEikMenuPaneTitle::Close() |
|
1333 { |
|
1334 } |
|
1335 |
|
1336 /** |
|
1337 * Gets the list of logical colors employed in the drawing of the control, |
|
1338 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
1339 * |
|
1340 * @since ER5U |
|
1341 */ |
|
1342 EXPORT_C void CEikMenuPaneTitle::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
1343 { |
|
1344 LafMenuPaneTitle::GetColorUseListL(aColorUseList); |
|
1345 } |
|
1346 |
|
1347 /** |
|
1348 * Handles a change to the control's resources of type aType |
|
1349 * which are shared across the environment, e.g. colors or fonts. |
|
1350 * |
|
1351 * @since ER5U |
|
1352 */ |
|
1353 EXPORT_C void CEikMenuPaneTitle::HandleResourceChange(TInt /*aType*/) |
|
1354 { |
|
1355 } |
|
1356 /** |
|
1357 * Allows the client to determine if the menubar instance is displayed ("UP") |
|
1358 * |
|
1359 * @since Avkon |
|
1360 */ |
|
1361 EXPORT_C TBool CEikMenuBar::IsDisplayed() |
|
1362 { |
|
1363 return MenuHasPane(); |
|
1364 } |
|
1365 |
|
1366 EXPORT_C void CEikMenuBar::SetMenuType(TMenuType aMenuType) |
|
1367 { |
|
1368 iExt->iMenuType = aMenuType; |
|
1369 } |
|
1370 |
|
1371 EXPORT_C CEikMenuBar::TMenuType CEikMenuBar::GetMenuType() const |
|
1372 { |
|
1373 return iExt->iMenuType; |
|
1374 } |
|
1375 |
|
1376 |
|
1377 EXPORT_C TBool CEikMenuBar::ItemSpecificCommandsEnabled() const |
|
1378 { |
|
1379 TBool enabled( ETrue ); |
|
1380 if ( MenuHasPane() && iExt->iItemActionMenu ) |
|
1381 { |
|
1382 enabled = iExt->iCollectionHighlightVisible; |
|
1383 } |
|
1384 else if ( iExt->iItemActionMenu && |
|
1385 !iExt->iItemActionMenu->CollectionHighlightVisible() ) |
|
1386 { |
|
1387 enabled = EFalse; |
|
1388 } |
|
1389 return enabled; |
|
1390 } |
|
1391 |
|
1392 |
|
1393 void CEikMenuBar::SetItemActionMenu( CAknItemActionMenu* aItemActionMenu ) |
|
1394 { |
|
1395 if ( aItemActionMenu ) |
|
1396 { |
|
1397 iExt->iItemActionMenu = aItemActionMenu; |
|
1398 iExt->iItemActionMenu->SetMenuBar( iMenuObserver, this ); |
|
1399 } |
|
1400 } |
|
1401 |
|
1402 |
|
1403 CAknItemActionMenu* CEikMenuBar::ItemActionMenu() const |
|
1404 { |
|
1405 return iExt->iItemActionMenu; |
|
1406 } |
|
1407 |
|
1408 CEikMenuPane* CEikMenuBar::PopulateItemActionMenuL( |
|
1409 CAknItemActionMenu& aItemActionMenu ) |
|
1410 { |
|
1411 CEikMenuPane* menuPane( NULL ); |
|
1412 CAiwServiceHandler::ReportMenuLaunch(); |
|
1413 if ( !iExt->iItemActionMenu ) |
|
1414 { |
|
1415 SetItemActionMenu( &aItemActionMenu ); |
|
1416 } |
|
1417 |
|
1418 if ( iMenuTitleResourceId ) |
|
1419 { |
|
1420 menuPane = CEikMenuPane::NewItemCommandMenuL( iMenuObserver ); |
|
1421 CleanupStack::PushL( menuPane ); |
|
1422 iMenuObserver->RestoreMenuL( |
|
1423 this, |
|
1424 iMenuTitleResourceId, |
|
1425 MEikMenuObserver::EMenuBar ); |
|
1426 TInt titles = iTitleArray->Count(); |
|
1427 if ( titles > 0 ) |
|
1428 { |
|
1429 titles--; |
|
1430 while ( titles >= 0 ) |
|
1431 { |
|
1432 TInt resource |
|
1433 = ( *iTitleArray )[ titles ]->iData.iMenuPaneResourceId; |
|
1434 |
|
1435 if ( iCoeEnv->IsResourceAvailableL( resource ) ) |
|
1436 { |
|
1437 menuPane->AddMenuItemsL( resource, 0 ); |
|
1438 iMenuObserver->DynInitMenuPaneL( resource, menuPane ); |
|
1439 } |
|
1440 titles--; |
|
1441 } |
|
1442 menuPane->AddMenuItemsToItemActionMenuL( |
|
1443 iExt->iItemActionMenu->MenuData() ); |
|
1444 } |
|
1445 iTitleArray->ResetAndDestroy(); |
|
1446 CleanupStack::Pop( menuPane ); |
|
1447 } |
|
1448 return menuPane; |
|
1449 } |
|
1450 |
|
1451 |
|
1452 void CEikMenuBar::CloseState() |
|
1453 { |
|
1454 StopDisplayingMenuBar(); |
|
1455 } |
|
1456 |
|
1457 EXPORT_C void CEikMenuBar::TryDisplayMenuBarWithoutFepMenusL() |
|
1458 { |
|
1459 iPreventFepMenu = ETrue; |
|
1460 TryDisplayMenuBarL(); |
|
1461 } |
|
1462 |
|
1463 TTypeUid::Ptr CEikMenuBar::MopSupplyObject(TTypeUid aId) |
|
1464 { |
|
1465 return SupplyMopObject(aId, iMenuCba); |
|
1466 } |