Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #if !defined(__EIKMENUB_H__)
20 #define __EIKMENUB_H__
22 #if !defined(__EIKDEF_H__)
26 #if !defined(__EIKBCTRL_H__)
30 #if !defined(__EIKMENUP_H__)
36 #include <aknintermediate.h>
38 class CEikHotKeyTable;
39 class CEikMenuBarExtension;
43 * The CEikMenuBarTitle class encapsulates the data needed to define a menu bar title and
44 * provides some of the functionality required to display the title.
48 class CEikMenuBarTitle : public CBase
52 * Defines a menu bar. See also @c MEikMenuObserver::DynInitMenuPaneL().
53 * See also @c MENU_TITLE for details of the resource interface to menu
59 /** Nominal legth of the text. */
63 * The resource ID from which the menu pane is constructed.
65 TInt iMenuPaneResourceId;
67 * The text to display on the menu pane.
69 TBuf<ENominalTextLength> iText; // less than this actually stored
73 * C++ default constructor.
75 IMPORT_C CEikMenuBarTitle();
79 IMPORT_C ~CEikMenuBarTitle();
81 * Sets the title icon.
83 * @param aIcon The icon to set.
85 IMPORT_C void SetIcon(CGulIcon* aIcon);
88 * Sets whether the bitmap and mask are owned externally or not.
90 * @param aOwnedExternally @c ETrue if bitmaps are set as externally owned.
91 * @c EFalse if bitmaps are set as not being externally owned.
93 IMPORT_C void SetBitmapsOwnedExternally(TBool aOwnedExternally);
96 * Draws the title icon to the graphics context @c aGc, inside the rect @c
97 * aRect with an offset from the left side of the rectangle of size @c
100 * @param aGc Window graphic context.
101 * @param aRect Rectangle area.
102 * @param aLeftMargin Left margin.
104 IMPORT_C void DrawIcon(CWindowGc& aGc, TRect aRect, TInt aLeftMargin) const;
107 * Constructs a new icon for the title, taking ownership of the picture
108 * bitmap and the mask bitmap unless they are externally owned.
110 * @param aBitmap Bitmap.
111 * @param aMask Mask of the bitmap.
113 IMPORT_C void CreateIconL(CFbsBitmap* aBitmap, CFbsBitmap* aMask);
116 * Sets the bitmap for the icon. Transfers
117 * ownership unless the bitmaps are owned externally.
119 * @param aBitmap Bitmap
121 IMPORT_C void SetIconBitmapL(CFbsBitmap* aBitmap);
124 * Sets the bitmap mask for the icon. Transfers ownership
125 * unless the bitmaps are owned externally.
127 * @param aMask Mask of a bitmap.
129 IMPORT_C void SetIconMaskL(CFbsBitmap* aMask);
132 * Gets a pointer to the title icon’s bitmap. Does not imply transfer of
135 * @return Pointer to the title icon’s bitmap.
137 IMPORT_C CFbsBitmap* IconBitmap() const;
140 * Gets a pointer to the title icon’s bitmap mask. Does not imply transfer
143 * @return Pointer to the title icon’s bitmap mask.
145 IMPORT_C CFbsBitmap* IconMask() const;
147 public: // other functions
150 * Gets the value of the extra left margin for the title text which will
151 * take into account the width of the title icon.
153 * @return Value of extra left margin.
155 TInt ExtraLeftMargin() const;
158 * Adjusts the value of the title text baseline offset @c aBaseLine to take
159 * into account any size of the title icon.
161 * @param[in,out] aBaseLine Gets result of baseline.
162 * @param[in,out] aTitleHeight Gets result of height.
164 void CalculateBaseLine(TInt& aBaseLine, TInt& aTitleHeight);
168 /** The title’s position on the menu bar. */
171 /** The title’s width. */
174 /** The menu bar title text. */
177 /** Flags used internally by the menu bar title. */
185 * Menu bars are constructed from @c MENU_BAR resources and issue application
186 * commands which should be handled by overriding @c
187 * CEikAppUi::HandleCommandL().
189 class CEikMenuBar : public CEikBorderedControl,
190 public MEikCommandObserver,
191 public MAknIntermediateState
197 * Declares an object type for a class, in order to allow the object
198 * provider mechanism to locate and provide objects from the class.
200 DECLARE_TYPE_ID(0x101F4106)
202 /** Specifies the menu item within the menu pane. */
205 /** Index of a title in the menu bar. */
208 /** Index of an item in a menu pane. */
219 SCursor iMenuCursorPos;
224 * Options menu launched from the Options softkey.
225 * This is the default value.
230 * Context sensitive menu that is launched from selection key
231 * when the application supports it.
236 * Edit menu containing editing specific items.
241 * Options menu launched from the Options softkey. Task swapper item
244 EMenuOptionsNoTaskSwapper = 3
247 friend class CEikMenuPaneTitle;
251 enum {ENothingSelected=-1};
258 IMPORT_C ~CEikMenuBar();
261 * C++ default constructor.
263 IMPORT_C CEikMenuBar();
268 * From @c CCoeControl
270 * Handles key events offered to the menu by the control environment and
271 * provides an appropriate implementation of
272 * @c CCoeControl::OfferKeyEventL().
274 * @param aKeyEvent The key event.
275 * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or @c
278 * @return Indicates whether or not the key event was used by this control.
280 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
284 * From @c CCoeControl
286 * Handles pointer events. This function gets called whenever a pointer
287 * event occurs in the control, i.e. when the pointer is within the
288 * control's extent, or when the control has grabbed the pointer. The
289 * control should implement this function to handle pointer events.
291 * Note: events of type @c EButton1Down are processed before @c
292 * HandlePointerEventL() is called, in order to transfer keyboard focus to
293 * the control in which the @c EButton1Down event occurred.
295 * If overriding @c HandlePointerEventL(), the implementation must include
296 * a base call to @c CCoeControl's @c HandlePointerEventL().
298 * @param aPointerEvent The pointer event.
300 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
303 * From @c CCoeControl
309 IMPORT_C void Draw(const TRect& aRect) const;
316 IMPORT_C void* ExtensionInterface( TUid aInterface );
318 private: // from MCoeInputObserver
320 IMPORT_C TCoeInputCapabilities InputCapabilities() const;
325 * This class enables construction, and destruction of an array of
326 * information about menu bar titles.
328 class CTitleArray : public CArrayPtrFlat<CEikMenuBarTitle>
336 IMPORT_C ~CTitleArray();
339 * C++ default constructor.
341 IMPORT_C CTitleArray();
344 * Adds the menu bar title @c aMenuTitle to the end of the array owned
345 * by the menu bar and transfers ownership.
347 * @param aMenuTitle Append object to flat array.
349 IMPORT_C void AddTitleL(CEikMenuBarTitle* aMenuTitle);
352 * Deletes selected index into array.
354 * @param aResource Array index that will be delete.
356 void DeleteResource(TInt aResource);
359 public: // new functions
362 * Second phase constructor for a menu bar.
364 * @param aMenuObserver The menu's observer.
365 * @param aHotKeyResourceId The ID of the resource, of type HOTKEY from
366 * which the hotkey table is created. This is optional. By default
368 * @param aMenuTitleResourceId The ID of the resource, of type @c MENU_BAR
369 * from which the menu title array is created. This is optional. By
373 IMPORT_C void ConstructL(MEikMenuObserver* aMenuObserver,
374 TInt aHotKeyResourceId=0,
375 TInt aMenuTitleResourceId=0);
378 * Second phase constructor for a menu bar which builds the menu bar from
379 * the given resource file.
381 * @param aReader The resource reader.
383 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
388 * @param aHotKeyResourceId Not used.
389 * @param aMenuTitleResourceId Not used.
390 * @param aDisplayNow Not used.
392 IMPORT_C void ChangeMenuBarL(TInt aHotKeyResourceId=0,
393 TInt aMenuTitleResourceId=0,
394 TInt aDisplayNow=ETrue);
399 * @param aHotKeyTable Not used.
402 IMPORT_C CEikHotKeyTable* SetHotKeyTable(CEikHotKeyTable* aHotKeyTable);
405 * Sets the menu’s resource ID.
407 * @param aMenuTitleResourceId The ID of the resource to use.
409 IMPORT_C void SetMenuTitleResourceId(TInt aMenuTitleResourceId);
414 * @param aMenuTitleResourceId
416 IMPORT_C void SetContextMenuTitleResourceId(TInt aMenuTitleResourceId);
421 * @param aTitleArray Not used.
423 IMPORT_C void SetMenuTitleArray(CTitleArray* aTitleArray);
428 * @param aOwnedExternally Not used.
430 IMPORT_C void SetTitleArrayOwnedExternally(TBool aOwnedExternally);
433 * Sets the cursor to the specifed menu pane and menu item.
435 * @param aCursor The menu pane and menu item to which the cursor is set.
436 * @return A @c SCursor structure holding the menu item within the menu
439 IMPORT_C SCursor SetMenuCursor(const SCursor& aCursor);
442 * Stops displaying the menu bar.
444 * This function causes the menu bar to disappear from the screen until it
445 * is invoked again by the user. In most circumstances this is done by the
446 * @c Uikon framework, so an application program will not normally need to
449 IMPORT_C void StopDisplayingMenuBar();
452 * Displays the menu bar.
454 * If the menu is not already displayed, this function displays the menu
455 * bar and allows the user to make a selection. In most circumstances this
456 * is done by the @c Uikon framework, so an application program will not
457 * normally need to use this function.
459 IMPORT_C void TryDisplayMenuBarL();
460 IMPORT_C void TryDisplayContextMenuBarL();
462 * If the menu is not already displayed, this function displays the menu
463 * bar without fep menu and allows the user to make a selection. In most
464 * circumstances this is done by the @c Uikon framework, so an application
465 * program will not normally need to use this function.
467 IMPORT_C void TryDisplayMenuBarWithoutFepMenusL();
472 * @param aNewSelectedTitle Not used
473 * @param aNewSelectedItem Not used.
475 IMPORT_C void MoveHighlightToL(TInt aNewSelectedTitle,
476 TInt aNewSelectedItem=0);
481 * @param aItem Not used.
483 IMPORT_C void DrawItem(TInt aItem) const;
486 * Gets a pointer to the menu’s hot key table.
488 CEikHotKeyTable* HotKeyTable() const { return(iHotKeyTable); }
491 * Gets the index of the menu pane selected by the cursor.
493 * @return The index of the selected menu pane.
495 IMPORT_C TInt SelectedTitle();
498 * Gets the index of the menu item selected by the cursor.
500 * @return The index of the selected menu item.
502 IMPORT_C TInt SelectedItem();
505 * Searches for the menu item that corresponds to the specified command.
507 * @param aCommandId The ID to search for.
508 * @param aPaneindex Menu pane index.
509 * @param aItemindex Menu item index.
511 IMPORT_C virtual void FindCommandIdInResourceL(TInt aCommandId,
516 * Gets a menu pane resource.
518 * @return The pointer to @c CEikMenuPane object containing a menu pane
521 IMPORT_C CEikMenuPane* MenuPane();
524 * If the menu bar is visible, removes the menu bar height from the top of
525 * @c aRect and returns the new rectangle in a new value of @c aRect.
527 * @param[in,out] aRect A rectangle that on return is reduced in height by
528 * the height of the menu bar.
530 IMPORT_C void ReduceRect(TRect& aRect) const;
533 * Gets array of information about the menu bar titles.
535 * @return Pointer to @c CTitleArray object containing array of information
536 * about menu bar titles.
538 IMPORT_C CTitleArray* TitleArray();
541 * Sets menu observer interface.
543 * @param aEditMenuObserver Menu observer interface.
545 IMPORT_C void SetEditMenuObserver(MEikMenuObserver* aEditMenuObserver);
548 * Sets the menu observer interface to @c NULL.
550 * @param aEditMenuObserver Menu observer interface that will be set to @c
553 IMPORT_C void RemoveEditMenuObserver(MEikMenuObserver* aEditMenuObserver);
556 * Allows the client to determine if the menubar instance is displayed.
558 * @return @c Etrue if displayed and @c EFalse if not.
560 IMPORT_C TBool IsDisplayed();
563 * Sets type of the menu. Menu can be for example Options menu launched from
564 * Options softkey or context sensitive menu launched from the selection key.
565 * By default the launched menu is options menu.
567 * @param aMenuType One of values of CEikMenuBar::TMenuType enumeration.
569 IMPORT_C void SetMenuType(TMenuType aMenuType);
571 private: // from MAknIntermediateState
575 public: // from CCoeControl
578 * From @c CCoeControl.
580 * Gets the list of logical colours used to draw the control.
582 * The list includes an explanation of how each colour is used. By default,
583 * this function has an empty implementation.
586 * @param aColorUseList The colour list.
588 IMPORT_C virtual void GetColorUseListL(
589 CArrayFix<TCoeColorUse>& aColorUseList) const;
592 * From @c CCoeControl.
594 * Handles a change to the control's resources.
596 * The types of resources handled are those which are shared across the
597 * environment, e.g. colours or fonts.
600 * @param aType A message UID value. The most common is @c
601 * KEikMessageColorSchemeChange which controls get when the colour
602 * scheme is changed. Other examples include: @c
603 * KEikMessageFadeAllWindows, @c KEikMessageUnfadeWindows, @c
604 * KEikMessageZoomChange, @c KEikMessageVirtualCursorStateChange, @c
605 * KEikMessageCapsLock, @c KEikMessagePrepareForSave.
607 IMPORT_C virtual void HandleResourceChange(TInt aType);
609 private: // from CCoeControl
610 IMPORT_C void Reserved_1();
611 IMPORT_C void Reserved_2();
612 // from MEikCommandObserver
613 void ProcessCommandL(TInt aCommandId);
614 private: // from MObjectProvider
615 TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
617 void StartDisplayingMenuBarL();
619 void SaveCurrentMenuPositionL();
620 void SetCursorPositionFromArray();
621 TBool MenuHasItems() const;
622 void SetMenuHasItems();
623 TBool MenuHasPane() const;
624 void SetMenuHasPane();
625 TBool TitleArrayOwnedExternally() const;
626 void ResetTitleArray();
627 void CreateTitleArrayL();
628 void SetMenuPaneFlag(TInt aFlag);
630 void AddMenuIfNotPresentL(TInt aResourceId);
631 void UpdateTitleTextBaseline();
633 enum TEikMenuFlags {ETitleArrayOwnedExternally=0x01,EMenuHasItems=0x02,EMenuHasPane=0x04,EBackgroundFaded=0x08, ESoundsInstalled=0x10};
634 CEikButtonGroupContainer* iMenuCba;
635 MEikMenuObserver* iMenuObserver;
636 MEikMenuObserver* iEditMenuObserver;
637 MEikMenuObserver* iActiveEditMenuObserver;
638 CEikMenuPane* iMenuPane;
639 CEikHotKeyTable* iHotKeyTable;
641 TInt iMenuTitleResourceId;
642 TInt iMenuPaneResourceId;
643 TInt iMenuHotKeyResourceId;
646 TInt iMenuTitleLeftSpace;
648 CTitleArray* iTitleArray;
649 CArrayFixFlat<SPosition>* iPastMenuPosArray;
650 TBool iPreventFepMenu;
651 friend class CEikMenuBarExtension;
652 CEikMenuBarExtension* iExt;
656 * This class is not intended to be used by application programmers.
658 class CEikMenuPaneTitle : public CEikBorderedControl
664 * Default C++ constructor
666 IMPORT_C CEikMenuPaneTitle(CEikMenuBar* aMenuBar);
669 * Second phase constructor for a menu bar. By default Symbian 2nd phase
670 * constructor is private.
672 IMPORT_C void ConstructL();
677 * @param aSelectedTitle Not used.
679 IMPORT_C void SetSelectedTitle(TInt aSelectedTitle);
684 * @param aRect Not used.
686 IMPORT_C void Draw(const TRect& aRect) const;
689 * Gets the menu pane title’s margins.
691 * @return The menu pane title’s margins.
693 IMPORT_C TMargins Margins() const;
698 IMPORT_C void Close();
705 * @param aPointerEvent Not used.
707 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
710 * From @c CCoeControl.
712 * Gets the list of logical colours used to draw the control.
714 * The list includes an explanation of how each colour is used. By default,
715 * this function has an empty implementation.
719 * @param aColorUseList The colour list.
721 IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
726 * @param aType Not used.
728 IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u
734 IMPORT_C void* ExtensionInterface( TUid aInterface );
736 CEikMenuBar* const iMenuBar;