Contents Up Previous Next

wxMenuBar

A menu bar is a series of menus accessible from the top of a frame.

Derived from

wxEvtHandler
wxObject

Include files

<wx/menu.h>

Event handling

To respond to a menu selection, provide a handler for EVT_MENU, in the frame that contains the menu bar.

See also

wxMenu, Event handling overview

Members

wxMenuBar::wxMenuBar
wxMenuBar::~wxMenuBar
wxMenuBar::Append
wxMenuBar::Check
wxMenuBar::Enable
wxMenuBar::EnableTop
wxMenuBar::FindMenuItem
wxMenuBar::FindItemById
wxMenuBar::GetHelpString
wxMenuBar::GetLabel
wxMenuBar::GetLabelTop
wxMenuBar::GetMenu
wxMenuBar::GetMenuCount
wxMenuBar::IsChecked
wxMenuBar::IsEnabled
wxMenuBar::SetHelpString
wxMenuBar::SetLabel
wxMenuBar::SetLabelTop


wxMenuBar::wxMenuBar

void wxMenuBar()

Default constructor.

void wxMenuBar(int n, wxMenu* menus[], const wxString titles[])

Construct a menu bar from arrays of menus and titles.

Parameters

n

menus

titles

wxPython note:
Only the default constructor is supported in wxPython. Use wxMenuBar.Append instead.


wxMenuBar::~wxMenuBar

void ~wxMenuBar()

Destructor, destroying the menu bar and removing it from the parent frame (if any).


wxMenuBar::Append

void Append(wxMenu *menu, const wxString& title)

Adds the item to the end of the menu bar.

Parameters

menu

title


wxMenuBar::Check

void Check(int id, const bool check)

Checks or unchecks a menu item.

Parameters

id

check

Remarks

Only use this when the menu bar has been associated with a frame; otherwise, use the wxMenu equivalent call.


wxMenuBar::Enable

void Enable(int id, const bool enable)

Enables or disables (greys out) a menu item.

Parameters

id

enable

Remarks

Only use this when the menu bar has been associated with a frame; otherwise, use the wxMenu equivalent call.


wxMenuBar::EnableTop

void EnableTop(int pos, const bool enable)

Enables or disables a whole menu.

Parameters

pos

enable

Remarks

Only use this when the menu bar has been associated with a frame.


wxMenuBar::FindMenuItem

int FindMenuItem(const wxString& menuString, const wxString& itemString) const

Finds the menu item id for a menu name/menu item string pair.

Parameters

menuString

itemString

Return value

The menu item identifier, or -1 if none was found.

Remarks

Any special menu codes are stripped out of source and target strings before matching.


wxMenuBar::FindItemById

wxMenuItem * FindItemById(int id) const

Finds the menu item object associated with the given menu item identifier,

Parameters

id

Return value

The found menu item object, or NULL if one was not found.


wxMenuBar::GetHelpString

wxString GetHelpString(int id) const

Gets the help string associated with the menu item identifer.

Parameters

id

Return value

The help string, or the empty string if there was no help string or the menu item was not found.

See also

wxMenuBar::SetHelpString


wxMenuBar::GetLabel

wxString GetLabel(int id) const

Gets the label associated with a menu item.

Parameters

id

Return value

The menu item label, or the empty string if the item was not found.

Remarks

Use only after the menubar has been associated with a frame.


wxMenuBar::GetLabelTop

wxString GetLabelTop(int pos) const

Returns the label of a top-level menu.

Parameters

pos

Return value

The menu label, or the empty string if the menu was not found.

Remarks

Use only after the menubar has been associated with a frame.

See also

wxMenuBar::SetLabelTop


wxMenuBar::GetMenu

wxMenu* GetMenu(int menuIndex) const

Returns the menu at menuIndex (zero-based).


wxMenuBar::GetMenuCount

int GetMenuCount() const

Returns the number of menus in this menubar.


wxMenuBar::IsChecked

bool IsChecked(int id) const

Determines whether an item is checked.

Parameters

id

Return value

TRUE if the item was found and is checked, FALSE otherwise.


wxMenuBar::IsEnabled

bool IsEnabled(int id) const

Determines whether an item is enabled.

Parameters

id

Return value

TRUE if the item was found and is enabled, FALSE otherwise.


wxMenuBar::SetHelpString

void SetHelpString(int id, const wxString& helpString)

Sets the help string associated with a menu item.

Parameters

id

helpString

See also

wxMenuBar::GetHelpString


wxMenuBar::SetLabel

void SetLabel(int id, const wxString& label)

Sets the label of a menu item.

Parameters

id

label

Remarks

Use only after the menubar has been associated with a frame.

See also

wxMenuBar::GetLabel


wxMenuBar::SetLabelTop

void SetLabelTop(int pos, const wxString& label)

Sets the label of a top-level menu.

Parameters

pos

label

Remarks

Use only after the menubar has been associated with a frame.

See also

wxMenuBar::GetLabelTop