\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
+\wxheading{Include files}
+
+<wx/menu.h>
+
\wxheading{Event handling}
If the menu is part of a menubar, then \helpref{wxMenuBar}{wxmenubar} event processing is used.
\begin{enumerate}\itemsep=0pt
\item Define a callback of type wxFunction, which you pass to the wxMenu constructor.
-The callback takes a reference to a window, and a reference to a \helpref{wxCommandEvent}{wxcommandevent}.
+The callback takes a reference to the menu, and a reference to a \helpref{wxCommandEvent}{wxcommandevent}.
\item Derive a new class from wxMenu and define event table entries using the EVT\_MENU macro.
\item Set a new event handler for wxMenu, using an object whose class has EVT\_MENU entries.
\item Provide EVT\_MENU handlers in the window which pops up the menu, or in an ancestor of
\docparam{func}{A callback function if the menu is used as a popup using \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu}.}
+\pythonnote{The wxPython version of the \tt{wxMenu} constructor
+doesn't accept the callback argument because of reference counting
+issues. There is a specialized wxMenu constructor called
+\tt{wxPyMenu} which does and can be used for PopupMenus when callbacks
+are needed. You must retain a reference to the menu while useing it
+otherwise your callback function will get dereferenced when the menu
+does.
+}
+
\membersection{wxMenu::\destruct{wxMenu}}
\func{}{\destruct{wxMenu}}{\void}
Destructor, destroying the menu.
+Note: under Motif, a popup menu must have a valid parent (the window
+it was last popped up on) when being destroyed. Therefore, make sure
+you delete or re-use the popup menu {\it before} destroying the
+parent window. Re-use in this context means popping up the menu on
+a different window from last time, which causes an implicit destruction
+and recreation of internal data structures.
+
\membersection{wxMenu::Append}\label{wxmenuappend}
-\func{void}{Append}{\param{const int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
+\func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
\param{const bool}{ checkable = FALSE}}
Adds a string item to the end of the menu.
-\func{void}{Append}{\param{const int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
+\func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
\param{const wxString\& }{helpString = ""}}
Adds a pull-right submenu to the end of the menu.
\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}, \helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp
\helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem}
+
+\pythonnote{In place of a single overloaded method name, wxPython
+implements the following methods:\par
+\indented{2cm}{\begin{twocollist}
+\twocolitem{\bf{Append(id, string, helpStr="", checkable=FALSE)}}{}
+\twocolitem{\bf{AppendMenu(id, string, aMenu, helpStr="")}}{}
+\twocolitem{\bf{AppendItem(aMenuItem)}}{}
+\end{twocollist}}
+}
+
+
\membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
\func{void}{AppendSeparator}{\void}
\membersection{wxMenu::Check}\label{wxmenucheck}
-\func{void}{Check}{\param{const int}{ id}, \param{const bool}{ check}}
+\func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
Checks or unchecks the menu item.
\membersection{wxMenu::Enable}\label{wxmenuenable}
-\func{void}{Enable}{\param{const int}{ id}, \param{const bool}{ enable}}
+\func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
Enables or disables (greys out) a menu item.
\helpref{wxMenu::FindItemForId}{wxmenufinditemforid}
-\membersection{wxMenu::FindItemForId}\label{wxmenufinditemforid}
+\membersection{wxMenu::FindItemForId}\label{wxmenufinditem}
-\constfunc{wxMenuItem*}{FindItemForId}{\param{const int}{ id}}
+\constfunc{wxMenuItem*}{FindItemForId}{\param{int}{ id}, \param{wxMenu **}{ menuForItem = NULL}}
Finds the menu item object associated with the given menu item identifier.
\wxheading{Parameters}
\docparam{id}{Menu item identifier.}
+\docparam{menuForItem}{will be filled with the menu for this item if not NULL.}
\wxheading{Return value}
\membersection{wxMenu::GetHelpString}\label{wxmenugethelpstring}
-\constfunc{wxString}{GetHelpString}{\param{const int}{ id}}
+\constfunc{wxString}{GetHelpString}{\param{int}{ id}}
Returns the help string associated with a menu item.
\membersection{wxMenu::GetLabel}\label{wxmenugetlabel}
-\constfunc{wxString}{GetLabel}{\param{const int}{ id}}
+\constfunc{wxString}{GetLabel}{\param{int}{ id}}
Returns a menu item label.
\membersection{wxMenu::IsChecked}\label{wxmenuischecked}
-\constfunc{bool}{IsChecked}{\param{const int}{ id}}
+\constfunc{bool}{IsChecked}{\param{int}{ id}}
Determines whether a menu item is checked.
\membersection{wxMenu::IsEnabled}\label{wxmenuisenabled}
-\constfunc{bool}{IsEnabled}{\param{const int}{ id}}
+\constfunc{bool}{IsEnabled}{\param{int}{ id}}
Determines whether a menu item is enabled.
\membersection{wxMenu::SetHelpString}\label{wxmenusethelpstring}
-\func{void}{SetHelpString}{\param{const int}{ id}, \param{const wxString\& }{helpString}}
+\func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
Sets an item's help string.
\membersection{wxMenu::SetLabel}\label{wxmenusetlabel}
-\func{void}{SetLabel}{\param{const int}{ id}, \param{const wxString\& }{label}}
+\func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
Sets the label of a menu item.
\helpref{wxMenu::SetTitle}{wxmenusettitle}
+\membersection{wxMenu::UpdateUI}\label{wxmenuupdateui}
+
+\constfunc{void}{UpdateUI}{\param{wxEvtHandler*}{ source = NULL}}
+
+Sends events to {\it source} (or owning window if NULL) to update the
+menu UI. This is called just before the menu is popped up with \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu}, but
+the application may call it at other times if required.
+
+\wxheading{See also}
+
+\helpref{wxUpdateUIEvent}{wxupdateuievent}
+
\section{\class{wxMenuBar}}\label{wxmenubar}
A menu bar is a series of menus accessible from the top of a frame.
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
+\wxheading{Include files}
+
+<wx/menu.h>
+
\wxheading{Event handling}
To respond to a menu selection, provide a handler for EVT\_MENU, in the frame
-that contains the menu bar.
+that contains the menu bar. If you have a toolbar which uses the same identifiers
+as your EVT\_MENU entries, events from the toolbar will also be processed by your
+EVT\_MENU event handlers.
+
+Note that menu commands (and UI update events for menus) are first sent to
+the focus window within the frame. If no window within the frame has the focus,
+then the events are sent directly to the frame. This allows command and UI update
+handling to be processed by specific windows and controls, and not necessarily
+by the application frame.
\wxheading{See also}
Default constructor.
-\func{void}{wxMenuBar}{\param{const int}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}}
+\func{void}{wxMenuBar}{\param{int}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}}
Construct a menu bar from arrays of menus and titles.
\docparam{titles}{An array of title strings. Deallocate this array after creating the menu bar.}
+\pythonnote{Only the default constructor is supported in wxPython.
+Use wxMenuBar.Append instead.}
+
+
\membersection{wxMenuBar::\destruct{wxMenuBar}}
\func{void}{\destruct{wxMenuBar}}{\void}
\membersection{wxMenuBar::Check}\label{wxmenubarcheck}
-\func{void}{Check}{\param{const int}{ id}, \param{const bool}{ check}}
+\func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
Checks or unchecks a menu item.
\membersection{wxMenuBar::Enable}\label{wxmenubarenable}
-\func{void}{Enable}{\param{const int}{ id}, \param{const bool}{ enable}}
+\func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
Enables or disables (greys out) a menu item.
\membersection{wxMenuBar::EnableTop}\label{wxmenubarenabletop}
-\func{void}{EnableTop}{\param{const int}{ pos}, \param{const bool}{ enable}}
+\func{void}{EnableTop}{\param{int}{ pos}, \param{const bool}{ enable}}
Enables or disables a whole menu.
Any special menu codes are stripped out of source and target strings
before matching.
-\membersection{wxMenuBar::FindItemById}\label{wxmenubarfinditembyid}
+\membersection{wxMenuBar::FindItemForId}\label{wxmenubarfinditemforid}
-\constfunc{wxMenuItem *}{FindItemById}{\param{const int}{ id}}
+\constfunc{wxMenuItem *}{FindItemForId}{\param{int}{ id}}
Finds the menu item object associated with the given menu item identifier,
\membersection{wxMenuBar::GetHelpString}\label{wxmenubargethelpstring}
-\constfunc{wxString}{GetHelpString}{\param{const int}{ id}}
+\constfunc{wxString}{GetHelpString}{\param{int}{ id}}
Gets the help string associated with the menu item identifer.
\membersection{wxMenuBar::GetLabel}\label{wxmenubargetlabel}
-\constfunc{wxString}{GetLabel}{\param{const int}{ id}}
+\constfunc{wxString}{GetLabel}{\param{int}{ id}}
Gets the label associated with a menu item.
\membersection{wxMenuBar::GetLabelTop}\label{wxmenubargetlabeltop}
-\constfunc{wxString}{GetLabelTop}{\param{const int}{ pos}}
+\constfunc{wxString}{GetLabelTop}{\param{int}{ pos}}
Returns the label of a top-level menu.
\helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop}
+\membersection{wxMenuBar::GetMenu}\label{wxmenubargetmenu}
+
+\constfunc{wxMenu*}{GetMenu}{\param{int}{ menuIndex}}
+
+Returns the menu at {\it menuIndex} (zero-based).
+
+\membersection{wxMenuBar::GetMenuCount}\label{wxmenubargetmenucount}
+
+\constfunc{int}{GetMenuCount}{\void}
+
+Returns the number of menus in this menubar.
+
\membersection{wxMenuBar::IsChecked}\label{wxmenubarischecked}
-\constfunc{bool}{IsChecked}{\param{const int}{ id}}
+\constfunc{bool}{IsChecked}{\param{int}{ id}}
Determines whether an item is checked.
\membersection{wxMenuBar::IsEnabled}\label{wxmenubarisenabled}
-\constfunc{bool}{IsEnabled}{\param{const int}{ id}}
+\constfunc{bool}{IsEnabled}{\param{int}{ id}}
Determines whether an item is enabled.
\membersection{wxMenuBar::SetHelpString}\label{wxmenubarsethelpstring}
-\func{void}{SetHelpString}{\param{const int}{ id}, \param{const wxString\& }{helpString}}
+\func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
Sets the help string associated with a menu item.
\membersection{wxMenuBar::SetLabel}\label{wxmenubarsetlabel}
-\func{void}{SetLabel}{\param{const int}{ id}, \param{const wxString\& }{label}}
+\func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
Sets the label of a menu item.
\membersection{wxMenuBar::SetLabelTop}\label{wxmenubarsetlabeltop}
-\func{void}{SetLabelTop}{\param{const int}{ pos}, \param{const wxString\& }{label}}
+\func{void}{SetLabelTop}{\param{int}{ pos}, \param{const wxString\& }{label}}
Sets the label of a top-level menu.