Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: eikmenub.h
Link against: eikcoctl.lib

Class CEikMenuBar

CEikMenuBar

Support

Supported from 6.0

Description

Menu bar.

Menu bars are constructed from MENU_BAR resources and issue application commands which should be handled by overriding CEikAppUi::HandleCommandL().

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCoeControlControl base class from which all other controls are derived
CEikBorderedControlA control which is drawn surrounded by a rectangular border
CEikMenuBarMenu bar

Defined in CEikMenuBar:
CEikMenuBar(), CTitleArray, ChangeMenuBarL(), ConstructFromResourceL(), ConstructL(), DrawItem(), FindCommandIdInResourceL(), GetColorUseListL(), HandlePointerEventL(), HandleResourceChange(), HotKeyTable(), MenuBarObserver(), MoveHighlightToL(), ReduceRect(), SCursor, SelectedItem(), SelectedTitle(), SetHotKeyTable(), SetMenuCursor(), SetMenuTitleArray(), SetMenuTitleResourceId(), SetTitleArrayOwnedExternally(), SetTitleDimmed(), SetTitleL(), StopDisplayingMenuBar(), TryDisplayMenuBarL(), UseSmallAdornments(), ~CEikMenuBar()

Inherited from CBase:
operator new()

Inherited from CCoeControl:
ActivateGc(), ActivateL(), BackedUpWindow(), CapturesPointer(), ClaimPointerGrab(), CloseWindow(), ComponentControl(), ControlContext(), ControlEnv(), CopyControlContextFrom(), CountComponentControls(), CreateBackedUpWindowL(), CreateWindowL(), DeactivateGc(), DrawDeferred(), DrawNow(), DrawableWindow(), EnableDragEvents(), FocusChanged(), GetColor(), GetHelpContext(), GrabbingComponent(), HandleComponentControlsResourceChange(), HandlePointerBufferReadyL(), HandleRedrawEvent(), IgnoreEventsUntilNextPointerUp(), Index(), InputCapabilities(), IsActivated(), IsBackedUp(), IsBeingDestroyed(), IsBlank(), IsDimmed(), IsFocused(), IsNonFocusing(), IsReadyToDraw(), IsVisible(), MakeVisible(), MinimumSize(), Observer(), OfferKeyEventL(), OverrideColorL(), OwnsWindow(), Position(), PositionChanged(), PositionRelativeToScreen(), PrepareForFocusGainL(), PrepareForFocusLossL(), Rect(), RecursivelyMergedInputCapabilities(), ReportEventL(), ResetGc(), SetAllowStrayPointers(), SetBlank(), SetCanDrawOutsideRect(), SetComponentsToInheritVisibility(), SetContainerWindow(), SetContainerWindowL(), SetControlContext(), SetCornerAndSize(), SetCornerAndSizeL(), SetDimmed(), SetExtent(), SetExtentL(), SetExtentToWholeScreen(), SetExtentToWholeScreenL(), SetFocus(), SetFocusing(), SetGloballyCapturing(), SetNeighbor(), SetNonFocusing(), SetObserver(), SetPointerCapture(), SetPosition(), SetRect(), SetRectL(), SetSize(), SetSizeL(), SetSizeWithoutNotification(), SetSizeWithoutNotificationL(), Size(), SizeChanged(), SizeChangedL(), SystemGc(), Window()

Inherited from CEikBorderedControl:
Border(), Draw(), HasBorder(), SetAdjacent(), SetBorder(), iBorder


Construction and destruction


CEikMenuBar()

CEikMenuBar();

Description

Default constructor. See also ConstructL().


ConstructL()

void ConstructL(MEikMenuObserver* aMenuObserver,TInt aHotKeyResourceId=0,TInt aMenuTitleResourceId=0);

Description

Allocates and constructs a menu bar. This constructor sets an observer for the menu, optionally creates a hot key table, creates a menu title array and an array to hold menu positions.

Parameters

MEikMenuObserver* aMenuObserver

The menu’s observer.

TInt aHotKeyResourceId=0

The ID of the resource, of type HOTKEY from which the hotkey table is created. This is optional.

TInt aMenuTitleResourceId=0

The ID of the resource, of type MENU_BAR from which the menu title array is created. This is optional.


ConstructFromResourceL()

void ConstructFromResourceL(TResourceReader& aReader);

Description

Constructs a menu bar using the specified resource reader.

Parameters

TResourceReader& aReader

The resource reader to use.


~CEikMenuBar()

~CEikMenuBar();

Description

Destructor. Removes everything associated with the menu bar, except the array holding menu titles if it is externally owned.

[Top]


Creating and changing a menu


ChangeMenuBarL()

void ChangeMenuBarL(TInt aHotKeyResourceId=0,TInt aMenuTitleResourceId=0,TInt aDisplayNow=ETrue);

Description

Dynamically changes a menu bar to use another resource. The menu bar and its relative menu pane is automatically displayed if EDisplayNow is ETrue.

Parameters

TInt aHotKeyResourceId=0

The resource, of type HOTKEY, that defines the hotkeys associated with this menu. Specifying a new set of hotkeys for the new menu means that hotkeys are context-dependent and the same hotkey can be used to perform different commands.

TInt aMenuTitleResourceId=0

The resource, of type MENU_BAR, that defines the menu to use.

TInt aDisplayNow=ETrue

If ETrue — display the new menu bar immediately. If EFalse — display the new menu bar when invoked by the user.


SetTitleL()

void SetTitleL(const TDesC& aText, TInt aResourceId, CGulIcon* aIcon = NULL);

Description

Sets the text and optionally icon for the specified title.

Parameters

const TDesC& aText

The title’s text.

TInt aResourceId

The resource ID of the title for which the text and icon are set.

CGulIcon* aIcon = NULL

The icon, none if this is NULL.


SetTitleArrayOwnedExternally()

void SetTitleArrayOwnedExternally(TBool aOwnedExternally);

Description

Sets the title array as externally owned. Sets the menu bar title array as externally owned if aOwnedExternally is ETrue.

Parameters

TBool aOwnedExternally

If ETrue sets the menu bar title array as externally owned. If EFalse sets the menu bar title array as not being externally owned.


SetHotKeyTable()

CEikHotKeyTable* SetHotKeyTable(CEikHotKeyTable* aHotKeyTable);

Description

Sets the hot key table.

Parameters

CEikHotKeyTable* aHotKeyTable

Hot key table to use.


SetMenuCursor()

SCursor SetMenuCursor(const SCursor& aCursor);

Description

Sets the cursor to the specifed menu pane and menu item.

Parameters

const SCursor& aCursor

The menu pane and menu item to which the cursor is set.

Return value

SCursor

An SCursor structure holding a menu item within a menu pane.


SetMenuTitleArray()

void SetMenuTitleArray(CTitleArray* aTitleArray);

Description

Sets the menu title array. Removes the current array if it is not externally owned.

Parameters

CTitleArray* aTitleArray

The menu title array to use.


SetMenuTitleResourceId()

void SetMenuTitleResourceId(TInt aMenuTitleResourceId);

Description

Sets the menu’s resource ID.

Parameters

TInt aMenuTitleResourceId

The ID of the resource to use.


UseSmallAdornments()

inline TBool UseSmallAdornments() const;

Description

Tests whether the smallest possible spacing is being used by the menu bar.

Return value

TBool

ETrue if the menu bar is using the smallest spacing values defined in the Laf.

[Top]


Displaying the menu


DrawItem()

void DrawItem(TInt aItem) const;

Description

Draws the specified menu bar title.

Parameters

TInt aItem

The menu bar title to draw.


MoveHighlightToL()

void MoveHighlightToL(TInt aNewSelectedTitle,TInt aNewSelectedItem);

Description

Highlights the specified item. The aNewSelectedTitle value identifies the new title bar to highlight. While aNewSelectedItem, if specified, is used to identify the a menu pane item to highlight.

This function also redraws any previously highlighted item so that it is no longer highlighted. If the specified item is dimmed, and so cannot accept input, this function calls HandleAttemptDimmedSelectionL() on the menu’s observer.

Parameters

TInt aNewSelectedTitle

The ID of the menu title to highlight.

TInt aNewSelectedItem

Optional, if supplied this identifies which menu item to highlight.


ReduceRect()

void ReduceRect(TRect& aRect) const;

Description

If the menu bar is visible, removes the menu bar height from the top of aRect and returns the new rectangle in a new value of aRect.

Parameters

TRect& aRect

A rectangle that on return is reduced in height by the height of the menu bar.


SetTitleDimmed()

void SetTitleDimmed(TInt aTitleIndex, TBool aTitleDimmed);

Description

Sets the specified title’s dim state. Dimming usually indicates that user-input cannot be accepted.

Parameters

TInt aTitleIndex

The title for which the dim state is being set.

TBool aTitleDimmed

If ETrue the title will be dimmed. If EFalse the title will be undimmed.


StopDisplayingMenuBar()

void StopDisplayingMenuBar();

Description

Stops displaying the menu bar.

This function causes the menu bar to disappear from the screen until it is invoked again by the user. In most circumstances this is done by the Uikon framework, so an application program will not normally need to use this function.


TryDisplayMenuBarL()

void TryDisplayMenuBarL();

Description

Displays the menu bar. If the menu is not already displayed, this function displays the menu bar and allows the user to make a selection. In most circumstances this is done by the Uikon framework, so an application program will not normally need to use this function.

[Top]


Information retrieval


FindCommandIdInResourceL()

void FindCommandIdInResourceL(TInt aCommandId,TInt& aPaneindex,TInt& aItemindex);

Description

Searches for the menu item that corresponds to the specified command.

Parameters

TInt aCommandId

The ID to search for.

TInt& aPaneindex

Menu pane index.

TInt& aItemindex

Menu item index.


GetColorUseListL()

virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;

Description

Gets a list of logical colours used in the control, paired with an explanation of how they are used. Appends the list to aColorUseList.

Parameters

CArrayFix<TCoeColorUse>& aColorUseList

The array to which the list of logical colours is added.


HotKeyTable()

CEikHotKeyTable* HotKeyTable() const;

Description

Gets a pointer to the menu’s hot key table.

Return value

CEikHotKeyTable*

Pointer to the menu’s hot key table.


MenuBarObserver()

MEikMenuObserver* MenuBarObserver() const;

Description

Gets a pointer to the menu’s observer.

Return value

MEikMenuObserver*

Pointer to the menu’s observer.


SelectedItem()

TInt SelectedItem();

Description

Gets the index of the menu item selected by the cursor.

Return value

TInt

The index of the selected menu item.


SelectedTitle()

TInt SelectedTitle();

Description

Gets the index of the menu pane selected by the cursor.

Return value

TInt

The index of the selected menu pane.

[Top]


Handling pointer events and resource changes


HandlePointerEventL()

void HandlePointerEventL(const TPointerEvent& aPointerEvent);

Description

Handles a pointer event on the menu.

Parameters

const TPointerEvent& aPointerEvent

The pointer event.


HandleResourceChange()

virtual void HandleResourceChange(TInt aType);

Description

Handles a change to the menu's resources which are shared across the environment. For example, colours or fonts.

Parameters

TInt aType

The type of resource that has changed.

[Top]


Member structs


Struct SCursor

SCursor

Description

Specifies a menu item within a menu pane.

Defined in CEikMenuBar::SCursor:
iMenuItemIndex, iMenuPaneIndex

iMenuItemIndex


TInt iMenuItemIndex

Description

Index of an item in a menu pane.

iMenuPaneIndex


TInt iMenuPaneIndex

Description

Index of a title in the menu bar.

[Top]


Class CTitleArray

CTitleArray

Description

This class enables construction, and destruction of an array of information about menu bar titles.

Derivation

CArrayFixA thin templated base class for arrays of fixed length objects
CArrayFixBaseBase class for arrays of fixed length objects
CArrayPtrA thin templated base class for arrays of pointers to objects
CArrayPtrFlatArray of pointers to objects implemented using a flat dynamic buffer
CBaseBase class for all classes to be instantiated on the heap
CEikMenuBar::CTitleArrayThis class enables construction, and destruction of an array of information about menu bar titles

Defined in CEikMenuBar::CTitleArray:
CTitleArray(), ~CTitleArray()

Inherited from CArrayFix:
AppendL(), AppendL()Append, Array(), At(), Back(), End(), ExpandL(), ExtendL(), Find(), FindIsq(), InsertIsqAllowDuplicatesL(), InsertIsqL(), InsertL(), ResizeL(), operator[]

Inherited from CArrayFixBase:
Compress(), Count(), Delete(), Length(), Reset(), Sort()

Inherited from CArrayPtr:
ResetAndDestroy()

Inherited from CArrayPtrFlat:
SetReserveL()

Inherited from CBase:
operator new()


CTitleArray()

CTitleArray();

Description

Constructor.


~CTitleArray()

~CTitleArray();

Description

Destructor. This also destroys all menu bar titles.