1 \section{\class{wxMenu
}}\label{wxmenu
}
3 A menu is a popup (or pull down) list of items, one of which may be
4 selected before the menu goes away (clicking elsewhere dismisses the
5 menu). Menus may be used to construct either menu bars or popup menus.
7 A menu item has an integer ID associated with it which can be used to
8 identify the selection, or to change the menu item in some way. A menu item
9 with a special identifier $-
1$ is a separator item and doesn't have an
10 associated command but just makes a separator line appear in the menu.
12 Menu items may be either normal items, check items or radio items. Normal items
13 don't have any special properties while the check items have a boolean flag
14 associated to them and they show a checkmark in the menu when the flag is set.
15 wxWindows automatically toggles the flag value when the item is clicked and its
16 value may be retrieved using either
\helpref{IsChecked
}{wxmenuischecked
} method
17 of wxMenu or wxMenuBar itself or by using
18 \helpref{wxEvent::IsChecked
}{wxcommandeventischecked
} when you get the menu
19 notification for the item in question.
21 The radio items are similar to the check items except that all the other items
22 in the same radio group are unchecked when a radio item is checked. The radio
23 group is formed by a contiguous range of radio items, i.e. it starts at the
24 first item of this kind and ends with the first item of a different kind (or
25 the end of the menu). Notice that because the radio groups are defined in terms
26 of the item positions inserting or removing the items in the menu containing
27 the radio items risks to not work correctly. Finally note that the radio items
28 are only supported under Windows and GTK+ currently.
30 \wxheading{Derived from
}
32 \helpref{wxEvtHandler
}{wxevthandler
}\\
33 \helpref{wxObject
}{wxobject
}
35 \wxheading{Include files
}
39 \wxheading{Event handling
}
41 If the menu is part of a menubar, then
\helpref{wxMenuBar
}{wxmenubar
} event processing is used.
43 With a popup menu, there is a variety of ways to handle a menu selection event
44 (wxEVT
\_COMMAND\_MENU\_SELECTED).
46 \begin{enumerate
}\itemsep=
0pt
47 \item Derive a new class from wxMenu and define event table entries using the EVT
\_MENU macro.
48 \item Set a new event handler for wxMenu, using an object whose class has EVT
\_MENU entries.
49 \item Provide EVT
\_MENU handlers in the window which pops up the menu, or in an ancestor of
51 \item Define a callback of type wxFunction, which you pass to the wxMenu constructor.
52 The callback takes a reference to the menu, and a reference to a
53 \helpref{wxCommandEvent
}{wxcommandevent
}. This method is deprecated and should
54 not be used in the new code, it is provided for backwards compatibility only.
59 \helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
},
\rtfsp
60 \helpref{Event handling overview
}{eventhandlingoverview
}
62 \latexignore{\rtfignore{\wxheading{Members
}}}
64 \membersection{wxMenu::wxMenu
}\label{wxmenuconstr
}
66 \func{}{wxMenu
}{\param{const wxString\&
}{title = ""
},
\param{long
}{ style =
0}}
68 Constructs a wxMenu object.
70 \wxheading{Parameters
}
72 \docparam{title
}{A title for the popup menu: the empty string denotes no title.
}
74 \docparam{style
}{If set to
{\tt wxMENU
\_TEAROFF}, the menu will be detachable (wxGTK only).
}
76 \func{}{wxMenu
}{\param{long
}{ style
}}
78 Constructs a wxMenu object.
80 \wxheading{Parameters
}
82 \docparam{style
}{If set to
{\tt wxMENU
\_TEAROFF}, the menu will be detachable (wxGTK only).
}
84 \membersection{wxMenu::
\destruct{wxMenu
}}
86 \func{}{\destruct{wxMenu
}}{\void}
88 Destructor, destroying the menu.
90 Note: under Motif, a popup menu must have a valid parent (the window
91 it was last popped up on) when being destroyed. Therefore, make sure
92 you delete or re-use the popup menu
{\it before
} destroying the
93 parent window. Re-use in this context means popping up the menu on
94 a different window from last time, which causes an implicit destruction
95 and recreation of internal data structures.
97 \membersection{wxMenu::Append
}\label{wxmenuappend
}
99 \func{void
}{Append
}{\param{int
}{ id
},
\param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
100 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
102 Adds a string item to the end of the menu.
104 \func{void
}{Append
}{\param{int
}{ id
},
\param{const wxString\&
}{ item
},
\param{wxMenu *
}{subMenu
},
\rtfsp
105 \param{const wxString\&
}{helpString = ""
}}
107 Adds a pull-right submenu to the end of the menu.
109 \func{void
}{Append
}{\param{wxMenuItem*
}{ menuItem
}}
111 Adds a menu item object. This is the most generic variant of Append() method
112 because it may be used for both items (including separators) and submenus and
113 because you can also specify various extra properties of a menu item this way,
114 such as bitmaps and fonts.
116 \wxheading{Parameters
}
118 \docparam{id
}{The menu command identifier.
}
120 \docparam{item
}{The string to appear on the menu item.
}
122 \docparam{menu
}{Pull-right submenu.
}
124 \docparam{kind
}{May be
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
125 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}}
127 \docparam{helpString
}{An optional help string associated with the item.
128 By default,
\helpref{wxFrame::OnMenuHighlight
}{wxframeonmenuhighlight
} displays
129 this string in the status line.
}
131 \docparam{menuItem
}{A menuitem object. It will be owned by the wxMenu object after this function
132 is called, so do not delete it yourself.
}
136 This command can be used after the menu has been shown, as well as on initial
137 creation of a menu or menubar.
141 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
},
\rtfsp
142 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
},
\rtfsp
143 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
},
\rtfsp
144 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
145 \helpref{wxMenu::SetLabel
}{wxmenusetlabel
},
\helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
},
\rtfsp
146 \helpref{wxMenu::SetHelpString
}{wxmenusethelpstring
},
\helpref{wxMenuItem
}{wxmenuitem
}
148 \pythonnote{In place of a single overloaded method name, wxPython
149 implements the following methods:
\par
150 \indented{2cm
}{\begin{twocollist
}
151 \twocolitem{{\bf Append(id, string, helpStr="", checkable=FALSE)
}}{}
152 \twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")
}}{}
153 \twocolitem{{\bf AppendItem(aMenuItem)
}}{}
157 \membersection{wxMenu::AppendCheckItem
}\label{wxmenuappendcheckitem
}
159 \func{void
}{AppendCheckItem
}{\param{int
}{ id
},
\rtfsp
160 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
162 Adds a checkable item to the end of the menu.
166 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
167 \helpref{wxMenu::InsertCheckItem
}{wxmenuinsertcheckitem
}
169 \membersection{wxMenu::AppendRadioItem
}\label{wxmenuappendradioitem
}
171 \func{void
}{AppendRadioItem
}{\param{int
}{ id
},
\rtfsp
172 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
174 Adds a radio item to the end of the menu. All consequent radio items form a
175 group and when an item in the group is checked, all the others are
176 automatically unchecked.
178 {\bf NB:
} Currently only implemented under Windows and GTK, use
179 {\tt\#if wxHAS
\_RADIO\_MENU\_ITEMS} to test for availability of this feature.
183 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
184 \helpref{wxMenu::InsertRadioItem
}{wxmenuinsertradioitem
}
186 \membersection{wxMenu::AppendSeparator
}\label{wxmenuappendseparator
}
188 \func{void
}{AppendSeparator
}{\void}
190 Adds a separator to the end of the menu.
194 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
195 \helpref{wxMenu::InsertSeparator
}{wxmenuinsertseparator
}
197 \membersection{wxMenu::Break
}\label{wxmenubreak
}
199 \func{void
}{Break
}{\void}
201 Inserts a break in a menu, causing the next appended item to appear in a new column.
203 \membersection{wxMenu::Check
}\label{wxmenucheck
}
205 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
207 Checks or unchecks the menu item.
209 \wxheading{Parameters
}
211 \docparam{id
}{The menu item identifier.
}
213 \docparam{check
}{If TRUE, the item will be checked, otherwise it will be unchecked.
}
217 \helpref{wxMenu::IsChecked
}{wxmenuischecked
}
219 \membersection{wxMenu::Delete
}\label{wxmenudelete
}
221 \func{void
}{Delete
}{\param{int
}{id
}}
223 \func{void
}{Delete
}{\param{wxMenuItem *
}{item
}}
225 Deletes the menu item from the menu. If the item is a submenu, it will
226 {\bf not
} be deleted. Use
\helpref{Destroy
}{wxmenudestroy
} if you want to
229 \wxheading{Parameters
}
231 \docparam{id
}{Id of the menu item to be deleted.
}
233 \docparam{item
}{Menu item to be deleted.
}
237 \helpref{wxMenu::FindItem
}{wxmenufinditem
},
\rtfsp
238 \helpref{wxMenu::Destroy
}{wxmenudestroy
},
\rtfsp
239 \helpref{wxMenu::Remove
}{wxmenuremove
}
241 \membersection{wxMenu::Destroy
}\label{wxmenudestroy
}
243 \func{void
}{Destroy
}{\param{int
}{id
}}
245 \func{void
}{Destroy
}{\param{wxMenuItem *
}{item
}}
247 Deletes the menu item from the menu. If the item is a submenu, it will
248 be deleted. Use
\helpref{Remove
}{wxmenuremove
} if you want to keep the submenu
249 (for example, to reuse it later).
251 \wxheading{Parameters
}
253 \docparam{id
}{Id of the menu item to be deleted.
}
255 \docparam{item
}{Menu item to be deleted.
}
259 \helpref{wxMenu::FindItem
}{wxmenufinditem
},
\rtfsp
260 \helpref{wxMenu::Deletes
}{wxmenudelete
},
\rtfsp
261 \helpref{wxMenu::Remove
}{wxmenuremove
}
263 \membersection{wxMenu::Enable
}\label{wxmenuenable
}
265 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
267 Enables or disables (greys out) a menu item.
269 \wxheading{Parameters
}
271 \docparam{id
}{The menu item identifier.
}
273 \docparam{enable
}{TRUE to enable the menu item, FALSE to disable it.
}
277 \helpref{wxMenu::IsEnabled
}{wxmenuisenabled
}
279 \membersection{wxMenu::FindItem
}\label{wxmenufinditem
}
281 \constfunc{int
}{FindItem
}{\param{const wxString\&
}{itemString
}}
283 Finds the menu item id for a menu item string.
285 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu **
}{menu = NULL
}}
287 Finds the menu item object associated with the given menu item identifier and,
288 optionally, the (sub)menu it belongs to.
290 \perlnote{In wxPerl this method takes just the
{\tt id
} parameter;
291 in scalar context it returns the associated
{\tt Wx::MenuItem
}, in list
292 context it returns a
2-element list
{\tt ( item, submenu )
}}
294 \wxheading{Parameters
}
296 \docparam{itemString
}{Menu item string to find.
}
298 \docparam{id
}{Menu item identifier.
}
300 \docparam{menu
}{If the pointer is not NULL, it will be filled with the items
301 parent menu (if the item was found)
}
303 \wxheading{Return value
}
305 First form: menu item identifier, or wxNOT
\_FOUND if none is found.
307 Second form: returns the menu item object, or NULL if it is not found.
311 Any special menu codes are stripped out of source and target strings
314 \pythonnote{The name of this method in wxPython is
{\tt FindItemById
}
315 and it does not support the second parameter.
}
317 \membersection{wxMenu::GetHelpString
}\label{wxmenugethelpstring
}
319 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
321 Returns the help string associated with a menu item.
323 \wxheading{Parameters
}
325 \docparam{id
}{The menu item identifier.
}
327 \wxheading{Return value
}
329 The help string, or the empty string if there is no help string or the
334 \helpref{wxMenu::SetHelpString
}{wxmenusethelpstring
},
\helpref{wxMenu::Append
}{wxmenuappend
}
336 \membersection{wxMenu::GetLabel
}\label{wxmenugetlabel
}
338 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
340 Returns a menu item label.
342 \wxheading{Parameters
}
344 \docparam{id
}{The menu item identifier.
}
346 \wxheading{Return value
}
348 The item label, or the empty string if the item was not found.
352 \helpref{wxMenu::SetLabel
}{wxmenusetlabel
}
354 \membersection{wxMenu::GetMenuItemCount
}\label{wxmenugetmenuitemcount
}
356 \constfunc{size
\_t}{GetMenuItemCount
}{\void}
358 Returns the number of items in the menu.
360 \membersection{wxMenu::GetMenuItems
}\label{wxmenugetmenuitems
}
362 \constfunc{wxMenuItemList\&
}{GetMenuItems
}{\void}
364 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
365 list class containing wxMenuItem pointers.
367 \membersection{wxMenu::GetTitle
}\label{wxmenugettitle
}
369 \constfunc{wxString
}{GetTitle
}{\void}
371 Returns the title of the menu.
375 This is relevant only to popup menus, use
376 \helpref{wxMenuBar::GetLabelTop
}{wxmenubargetlabeltop
} for the menus in the
381 \helpref{wxMenu::SetTitle
}{wxmenusettitle
}
383 \membersection{wxMenu::Insert
}\label{wxmenuinsert
}
385 \func{bool
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenuItem *
}{item
}}
387 \func{void
}{Insert
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
388 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
389 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
391 Inserts the given
{\it item
} before the position
{\it pos
}. Inserting the item
392 at the position
\helpref{GetMenuItemCount
}{wxmenugetmenuitemcount
} is the same
397 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
398 \helpref{wxMenu::Prepend
}{wxmenuprepend
}
400 \membersection{wxMenu::InsertCheckItem
}\label{wxmenuinsertcheckitem
}
402 \func{void
}{InsertCheckItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
403 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
405 Inserts a checkable item at the given position.
409 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
410 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
412 \membersection{wxMenu::InsertRadioItem
}\label{wxmenuinsertradioitem
}
414 \func{void
}{InsertRadioItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
415 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
417 Inserts a radio item at the given position.
421 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
422 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
424 \membersection{wxMenu::InsertSeparator
}\label{wxmenuinsertseparator
}
426 \func{void
}{InsertSeparator
}{\param{size
\_t }{pos
}}
428 Inserts a separator at the given position.
432 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
433 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
435 \membersection{wxMenu::IsChecked
}\label{wxmenuischecked
}
437 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
439 Determines whether a menu item is checked.
441 \wxheading{Parameters
}
443 \docparam{id
}{The menu item identifier.
}
445 \wxheading{Return value
}
447 TRUE if the menu item is checked, FALSE otherwise.
451 \helpref{wxMenu::Check
}{wxmenucheck
}
453 \membersection{wxMenu::IsEnabled
}\label{wxmenuisenabled
}
455 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
457 Determines whether a menu item is enabled.
459 \wxheading{Parameters
}
461 \docparam{id
}{The menu item identifier.
}
463 \wxheading{Return value
}
465 TRUE if the menu item is enabled, FALSE otherwise.
469 \helpref{wxMenu::Enable
}{wxmenuenable
}
471 \membersection{wxMenu::Prepend
}\label{wxmenuprepend
}
473 \func{bool
}{Prepend
}{\param{size
\_t }{pos
},
\param{wxMenuItem *
}{item
}}
475 \func{void
}{Prepend
}{\param{int
}{ id
},
\rtfsp
476 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
477 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
479 Inserts the given
{\it item
} at the position $
0$.
483 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
484 \helpref{wxMenu::Inserts
}{wxmenuinsert
}
486 \membersection{wxMenu::PrependCheckItem
}\label{wxmenuprependcheckitem
}
488 \func{void
}{PrependCheckItem
}{\param{int
}{ id
},
\rtfsp
489 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
491 Inserts a checkable item at the position $
0$.
495 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
496 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
498 \membersection{wxMenu::PrependRadioItem
}\label{wxmenuprependradioitem
}
500 \func{void
}{PrependRadioItem
}{\param{int
}{ id
},
\rtfsp
501 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
503 Inserts a radio item at the position $
0$.
507 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
508 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
510 \membersection{wxMenu::PrependSeparator
}\label{wxmenuprependseparator
}
512 \func{void
}{PrependSeparator
}{\param{size
\_t }{pos
}}
514 Inserts a separator at the position $
0$.
518 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
519 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
521 \membersection{wxMenu::Remove
}\label{wxmenuremove
}
523 \func{wxMenuItem *
}{Remove
}{\param{int
}{id
}}
525 \func{wxMenuItem *
}{Remove
}{\param{wxMenuItem *
}{item
}}
527 Removes the menu item from the menu but doesn't delete the associated C++
528 object. This allows to reuse the same item later by adding it back to the menu
529 (especially useful with submenus).
531 \wxheading{Parameters
}
533 \docparam{id
}{The identifier of the menu item to remove.
}
535 \docparam{item
}{The menu item to remove.
}
537 \wxheading{Return value
}
539 The item which was detached from the menu.
541 \membersection{wxMenu::SetHelpString
}\label{wxmenusethelpstring
}
543 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
545 Sets an item's help string.
547 \wxheading{Parameters
}
549 \docparam{id
}{The menu item identifier.
}
551 \docparam{helpString
}{The help string to set.
}
555 \helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
}
557 \membersection{wxMenu::SetLabel
}\label{wxmenusetlabel
}
559 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
561 Sets the label of a menu item.
563 \wxheading{Parameters
}
565 \docparam{id
}{The menu item identifier.
}
567 \docparam{label
}{The menu item label to set.
}
571 \helpref{wxMenu::Append
}{wxmenuappend
},
\helpref{wxMenu::GetLabel
}{wxmenugetlabel
}
573 \membersection{wxMenu::SetTitle
}\label{wxmenusettitle
}
575 \func{void
}{SetTitle
}{\param{const wxString\&
}{title
}}
577 Sets the title of the menu.
579 \wxheading{Parameters
}
581 \docparam{title
}{The title to set.
}
585 This is relevant only to popup menus, use
586 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
} for the menus in the
591 \helpref{wxMenu::GetTitle
}{wxmenugettitle
}
593 \membersection{wxMenu::UpdateUI
}\label{wxmenuupdateui
}
595 \constfunc{void
}{UpdateUI
}{\param{wxEvtHandler*
}{ source = NULL
}}
597 Sends events to
{\it source
} (or owning window if NULL) to update the
598 menu UI. This is called just before the menu is popped up with
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
}, but
599 the application may call it at other times if required.
603 \helpref{wxUpdateUIEvent
}{wxupdateuievent
}
605 \section{\class{wxMenuBar
}}\label{wxmenubar
}
607 A menu bar is a series of menus accessible from the top of a frame.
609 \wxheading{Derived from
}
611 \helpref{wxEvtHandler
}{wxevthandler
}\\
612 \helpref{wxObject
}{wxobject
}
614 \wxheading{Include files
}
618 \wxheading{Event handling
}
620 To respond to a menu selection, provide a handler for EVT
\_MENU, in the frame
621 that contains the menu bar. If you have a toolbar which uses the same identifiers
622 as your EVT
\_MENU entries, events from the toolbar will also be processed by your
623 EVT
\_MENU event handlers.
625 Note that menu commands (and UI update events for menus) are first sent to
626 the focus window within the frame. If no window within the frame has the focus,
627 then the events are sent directly to the frame. This allows command and UI update
628 handling to be processed by specific windows and controls, and not necessarily
629 by the application frame.
631 {\bf Tip:
} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
632 are not working, check any EVT
\_CHAR events you are handling in child windows.
633 If you are not calling
{\tt event.Skip()
} for events that you don't process in these event handlers,
634 menu shortcuts may cease to work.
638 \helpref{wxMenu
}{wxmenu
},
\helpref{Event handling overview
}{eventhandlingoverview
}
640 \latexignore{\rtfignore{\wxheading{Members
}}}
642 \membersection{wxMenuBar::wxMenuBar
}\label{wxmenubarconstr
}
644 \func{void
}{wxMenuBar
}{\param{long
}{style =
0}}
648 \func{void
}{wxMenuBar
}{\param{int
}{ n
},
\param{wxMenu*
}{ menus
[]},
\param{const wxString
}{titles
[]}}
650 Construct a menu bar from arrays of menus and titles.
652 \wxheading{Parameters
}
654 \docparam{n
}{The number of menus.
}
656 \docparam{menus
}{An array of menus. Do not use this array again - it now belongs to the
659 \docparam{titles
}{An array of title strings. Deallocate this array after creating the menu bar.
}
661 \docparam{style
}{If
{\tt wxMB
\_DOCKABLE} the menu bar can be detached (wxGTK only).
}
663 \pythonnote{Only the default constructor is supported in wxPython.
664 Use wxMenuBar.Append instead.
}
666 \perlnote{wxPerl only supports the first constructor:
667 use
{\tt Append
} instead.
}
669 \membersection{wxMenuBar::
\destruct{wxMenuBar
}}
671 \func{void
}{\destruct{wxMenuBar
}}{\void}
673 Destructor, destroying the menu bar and removing it from the parent frame (if any).
675 \membersection{wxMenuBar::Append
}\label{wxmenubarappend
}
677 \func{bool
}{Append
}{\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
679 Adds the item to the end of the menu bar.
681 \wxheading{Parameters
}
683 \docparam{menu
}{The menu to add. Do not deallocate this menu after calling
{\bf Append
}.
}
685 \docparam{title
}{The title of the menu.
}
687 \wxheading{Return value
}
689 TRUE on success, FALSE if an error occurred.
693 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
}
695 \membersection{wxMenuBar::Check
}\label{wxmenubarcheck
}
697 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
699 Checks or unchecks a menu item.
701 \wxheading{Parameters
}
703 \docparam{id
}{The menu item identifier.
}
705 \docparam{check
}{If TRUE, checks the menu item, otherwise the item is unchecked.
}
709 Only use this when the menu bar has been associated
710 with a frame; otherwise, use the wxMenu equivalent call.
712 \membersection{wxMenuBar::Enable
}\label{wxmenubarenable
}
714 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
716 Enables or disables (greys out) a menu item.
718 \wxheading{Parameters
}
720 \docparam{id
}{The menu item identifier.
}
722 \docparam{enable
}{TRUE to enable the item, FALSE to disable it.
}
726 Only use this when the menu bar has been
727 associated with a frame; otherwise, use the wxMenu equivalent call.
729 \membersection{wxMenuBar::EnableTop
}\label{wxmenubarenabletop
}
731 \func{void
}{EnableTop
}{\param{int
}{ pos
},
\param{const bool
}{ enable
}}
733 Enables or disables a whole menu.
735 \wxheading{Parameters
}
737 \docparam{pos
}{The position of the menu, starting from zero.
}
739 \docparam{enable
}{TRUE to enable the menu, FALSE to disable it.
}
743 Only use this when the menu bar has been
744 associated with a frame.
746 \membersection{wxMenuBar::FindMenu
}\label{wxmenubarfindmenu
}
748 \constfunc{int
}{FindMenu
}{\param{const wxString\&
}{title
}}
750 Returns the index of the menu with the given
{\it title
} or wxNOT
\_FOUND if no
751 such menu exists in this menubar. The
{\it title
} parameter may specify either
752 the menu title (with accelerator characters, i.e.
{\tt "\&File"
}) or just the
753 menu label (
{\tt "File"
}) indifferently.
755 \membersection{wxMenuBar::FindMenuItem
}\label{wxmenubarfindmenuitem
}
757 \constfunc{int
}{FindMenuItem
}{\param{const wxString\&
}{menuString
},
\param{const wxString\&
}{itemString
}}
759 Finds the menu item id for a menu name/menu item string pair.
761 \wxheading{Parameters
}
763 \docparam{menuString
}{Menu title to find.
}
765 \docparam{itemString
}{Item to find.
}
767 \wxheading{Return value
}
769 The menu item identifier, or wxNOT
\_FOUND if none was found.
773 Any special menu codes are stripped out of source and target strings
776 \membersection{wxMenuBar::FindItem
}\label{wxmenubarfinditem
}
778 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu
}{ **menu = NULL
}}
780 Finds the menu item object associated with the given menu item identifier.
782 \wxheading{Parameters
}
784 \docparam{id
}{Menu item identifier.
}
786 \docparam{menu
}{If not NULL, menu will get set to the associated menu.
}
788 \wxheading{Return value
}
790 The found menu item object, or NULL if one was not found.
792 \membersection{wxMenuBar::GetHelpString
}\label{wxmenubargethelpstring
}
794 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
796 Gets the help string associated with the menu item identifier.
798 \wxheading{Parameters
}
800 \docparam{id
}{The menu item identifier.
}
802 \wxheading{Return value
}
804 The help string, or the empty string if there was no help string or the menu item
809 \helpref{wxMenuBar::SetHelpString
}{wxmenubarsethelpstring
}
811 \membersection{wxMenuBar::GetLabel
}\label{wxmenubargetlabel
}
813 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
815 Gets the label associated with a menu item.
817 \wxheading{Parameters
}
819 \docparam{id
}{The menu item identifier.
}
821 \wxheading{Return value
}
823 The menu item label, or the empty string if the item was not found.
827 Use only after the menubar has been associated with a frame.
829 \membersection{wxMenuBar::GetLabelTop
}\label{wxmenubargetlabeltop
}
831 \constfunc{wxString
}{GetLabelTop
}{\param{int
}{ pos
}}
833 Returns the label of a top-level menu. Note that the returned string does not
834 include the accelerator characters which could have been specified in the menu
835 title string during its construction.
837 \wxheading{Parameters
}
839 \docparam{pos
}{Position of the menu on the menu bar, starting from zero.
}
841 \wxheading{Return value
}
843 The menu label, or the empty string if the menu was not found.
847 Use only after the menubar has been associated with a frame.
851 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
}
853 \membersection{wxMenuBar::GetMenu
}\label{wxmenubargetmenu
}
855 \constfunc{wxMenu*
}{GetMenu
}{\param{int
}{ menuIndex
}}
857 Returns the menu at
{\it menuIndex
} (zero-based).
859 \membersection{wxMenuBar::GetMenuCount
}\label{wxmenubargetmenucount
}
861 \constfunc{int
}{GetMenuCount
}{\void}
863 Returns the number of menus in this menubar.
865 \membersection{wxMenuBar::Insert
}\label{wxmenubarinsert
}
867 \func{bool
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
869 Inserts the menu at the given position into the menu bar. Inserting menu at
870 position $
0$ will insert it in the very beginning of it, inserting at position
871 \helpref{GetMenuCount()
}{wxmenubargetmenucount
} is the same as calling
872 \helpref{Append()
}{wxmenubarappend
}.
874 \wxheading{Parameters
}
876 \docparam{pos
}{The position of the new menu in the menu bar
}
878 \docparam{menu
}{The menu to add. wxMenuBar owns the menu and will free it.
}
880 \docparam{title
}{The title of the menu.
}
882 \wxheading{Return value
}
884 TRUE on success, FALSE if an error occurred.
888 \helpref{wxMenuBar::Append
}{wxmenubarappend
}
890 \membersection{wxMenuBar::IsChecked
}\label{wxmenubarischecked
}
892 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
894 Determines whether an item is checked.
896 \wxheading{Parameters
}
898 \docparam{id
}{The menu item identifier.
}
900 \wxheading{Return value
}
902 TRUE if the item was found and is checked, FALSE otherwise.
904 \membersection{wxMenuBar::IsEnabled
}\label{wxmenubarisenabled
}
906 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
908 Determines whether an item is enabled.
910 \wxheading{Parameters
}
912 \docparam{id
}{The menu item identifier.
}
914 \wxheading{Return value
}
916 TRUE if the item was found and is enabled, FALSE otherwise.
918 \membersection{wxMenuBar::Refresh
}\label{wxmenubarrefresh
}
920 \func{void
}{Refresh
}{\void}
924 \membersection{wxMenuBar::Remove
}\label{wxmenubarremove
}
926 \func{wxMenu *
}{Remove
}{\param{size
\_t }{pos
}}
928 Removes the menu from the menu bar and returns the menu object - the caller is
929 responsible for deleting it. This function may be used together with
930 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
} to change the menubar
935 \helpref{wxMenuBar::Replace
}{wxmenubarreplace
}
937 \membersection{wxMenuBar::Replace
}\label{wxmenubarreplace
}
939 \func{wxMenu *
}{Replace
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
941 Replaces the menu at the given position with another one.
943 \wxheading{Parameters
}
945 \docparam{pos
}{The position of the new menu in the menu bar
}
947 \docparam{menu
}{The menu to add.
}
949 \docparam{title
}{The title of the menu.
}
951 \wxheading{Return value
}
953 The menu which was previously at the position
{\it pos
}. The caller is
954 responsible for deleting it.
958 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
},
\rtfsp
959 \helpref{wxMenuBar::Remove
}{wxmenubarremove
}
961 \membersection{wxMenuBar::SetHelpString
}\label{wxmenubarsethelpstring
}
963 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
965 Sets the help string associated with a menu item.
967 \wxheading{Parameters
}
969 \docparam{id
}{Menu item identifier.
}
971 \docparam{helpString
}{Help string to associate with the menu item.
}
975 \helpref{wxMenuBar::GetHelpString
}{wxmenubargethelpstring
}
977 \membersection{wxMenuBar::SetLabel
}\label{wxmenubarsetlabel
}
979 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
981 Sets the label of a menu item.
983 \wxheading{Parameters
}
985 \docparam{id
}{Menu item identifier.
}
987 \docparam{label
}{Menu item label.
}
991 Use only after the menubar has been associated with a frame.
995 \helpref{wxMenuBar::GetLabel
}{wxmenubargetlabel
}
997 \membersection{wxMenuBar::SetLabelTop
}\label{wxmenubarsetlabeltop
}
999 \func{void
}{SetLabelTop
}{\param{int
}{ pos
},
\param{const wxString\&
}{label
}}
1001 Sets the label of a top-level menu.
1003 \wxheading{Parameters
}
1005 \docparam{pos
}{The position of a menu on the menu bar, starting from zero.
}
1007 \docparam{label
}{The menu label.
}
1011 Use only after the menubar has been associated with a frame.
1013 \wxheading{See also
}
1015 \helpref{wxMenuBar::GetLabelTop
}{wxmenubargetlabeltop
}