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 togles 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.
379 \helpref{wxMenu::SetTitle
}{wxmenusettitle
}
381 \membersection{wxMenu::Insert
}\label{wxmenuinsert
}
383 \func{bool
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenuItem *
}{item
}}
385 \func{void
}{Insert
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
386 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
387 \param{wxItemKind
}{ kind = wxItem
\_Normal}}
389 Inserts the given
{\it item
} before the position
{\it pos
}. Inserting the item
390 at the position
\helpref{GetMenuItemCount
}{wxmenugetmenuitemcount
} is the same
395 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
396 \helpref{wxMenu::Prepend
}{wxmenuprepend
}
398 \membersection{wxMenu::InsertCheckItem
}\label{wxmenuinsertcheckitem
}
400 \func{void
}{InsertCheckItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
401 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
403 Inserts a checkable item at the given position.
407 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
408 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
410 \membersection{wxMenu::InsertRadioItem
}\label{wxmenuinsertradioitem
}
412 \func{void
}{InsertRadioItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
413 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
415 Inserts a radio item at the given position.
419 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
420 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
422 \membersection{wxMenu::InsertSeparator
}\label{wxmenuinsertseparator
}
424 \func{void
}{InsertSeparator
}{\param{size
\_t }{pos
}}
426 Inserts a separator at the given position.
430 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
431 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
433 \membersection{wxMenu::IsChecked
}\label{wxmenuischecked
}
435 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
437 Determines whether a menu item is checked.
439 \wxheading{Parameters
}
441 \docparam{id
}{The menu item identifier.
}
443 \wxheading{Return value
}
445 TRUE if the menu item is checked, FALSE otherwise.
449 \helpref{wxMenu::Check
}{wxmenucheck
}
451 \membersection{wxMenu::IsEnabled
}\label{wxmenuisenabled
}
453 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
455 Determines whether a menu item is enabled.
457 \wxheading{Parameters
}
459 \docparam{id
}{The menu item identifier.
}
461 \wxheading{Return value
}
463 TRUE if the menu item is enabled, FALSE otherwise.
467 \helpref{wxMenu::Enable
}{wxmenuenable
}
469 \membersection{wxMenu::Prepend
}\label{wxmenuprepend
}
471 \func{bool
}{Prepend
}{\param{size
\_t }{pos
},
\param{wxMenuItem *
}{item
}}
473 \func{void
}{Prepend
}{\param{int
}{ id
},
\rtfsp
474 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
475 \param{wxItemKind
}{ kind = wxItem
\_Normal}}
477 Inserts the given
{\it item
} at the position $
0$.
481 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
482 \helpref{wxMenu::Inserts
}{wxmenuinsert
}
484 \membersection{wxMenu::PrependCheckItem
}\label{wxmenuprependcheckitem
}
486 \func{void
}{PrependCheckItem
}{\param{int
}{ id
},
\rtfsp
487 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
489 Inserts a checkable item at the position $
0$.
493 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
494 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
496 \membersection{wxMenu::PrependRadioItem
}\label{wxmenuprependradioitem
}
498 \func{void
}{PrependRadioItem
}{\param{int
}{ id
},
\rtfsp
499 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
501 Inserts a radio item at the position $
0$.
505 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
506 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
508 \membersection{wxMenu::PrependSeparator
}\label{wxmenuprependseparator
}
510 \func{void
}{PrependSeparator
}{\param{size
\_t }{pos
}}
512 Inserts a separator at the position $
0$.
516 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
517 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
519 \membersection{wxMenu::Remove
}\label{wxmenuremove
}
521 \func{wxMenuItem *
}{Remove
}{\param{int
}{id
}}
523 \func{wxMenuItem *
}{Remove
}{\param{wxMenuItem *
}{item
}}
525 Removes the menu item from the menu but doesn't delete the associated C++
526 object. This allows to reuse the same item later by adding it back to the menu
527 (especially useful with submenus).
529 \wxheading{Parameters
}
531 \docparam{id
}{The identifier of the menu item to remove.
}
533 \docparam{item
}{The menu item to remove.
}
535 \wxheading{Return value
}
537 The item which was detached from the menu.
539 \membersection{wxMenu::SetHelpString
}\label{wxmenusethelpstring
}
541 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
543 Sets an item's help string.
545 \wxheading{Parameters
}
547 \docparam{id
}{The menu item identifier.
}
549 \docparam{helpString
}{The help string to set.
}
553 \helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
}
555 \membersection{wxMenu::SetLabel
}\label{wxmenusetlabel
}
557 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
559 Sets the label of a menu item.
561 \wxheading{Parameters
}
563 \docparam{id
}{The menu item identifier.
}
565 \docparam{label
}{The menu item label to set.
}
569 \helpref{wxMenu::Append
}{wxmenuappend
},
\helpref{wxMenu::GetLabel
}{wxmenugetlabel
}
571 \membersection{wxMenu::SetTitle
}\label{wxmenusettitle
}
573 \func{void
}{SetTitle
}{\param{const wxString\&
}{title
}}
575 Sets the title of the menu.
577 \wxheading{Parameters
}
579 \docparam{title
}{The title to set.
}
583 This is relevant only to popup menus.
587 \helpref{wxMenu::SetTitle
}{wxmenusettitle
}
589 \membersection{wxMenu::UpdateUI
}\label{wxmenuupdateui
}
591 \constfunc{void
}{UpdateUI
}{\param{wxEvtHandler*
}{ source = NULL
}}
593 Sends events to
{\it source
} (or owning window if NULL) to update the
594 menu UI. This is called just before the menu is popped up with
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
}, but
595 the application may call it at other times if required.
599 \helpref{wxUpdateUIEvent
}{wxupdateuievent
}
601 \section{\class{wxMenuBar
}}\label{wxmenubar
}
603 A menu bar is a series of menus accessible from the top of a frame.
605 \wxheading{Derived from
}
607 \helpref{wxEvtHandler
}{wxevthandler
}\\
608 \helpref{wxObject
}{wxobject
}
610 \wxheading{Include files
}
614 \wxheading{Event handling
}
616 To respond to a menu selection, provide a handler for EVT
\_MENU, in the frame
617 that contains the menu bar. If you have a toolbar which uses the same identifiers
618 as your EVT
\_MENU entries, events from the toolbar will also be processed by your
619 EVT
\_MENU event handlers.
621 Note that menu commands (and UI update events for menus) are first sent to
622 the focus window within the frame. If no window within the frame has the focus,
623 then the events are sent directly to the frame. This allows command and UI update
624 handling to be processed by specific windows and controls, and not necessarily
625 by the application frame.
627 {\bf Tip:
} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
628 are not working, check any EVT
\_CHAR events you are handling in child windows.
629 If you are not calling
{\tt event.Skip()
} for events that you don't process in these event handlers,
630 menu shortcuts may cease to work.
634 \helpref{wxMenu
}{wxmenu
},
\helpref{Event handling overview
}{eventhandlingoverview
}
636 \latexignore{\rtfignore{\wxheading{Members
}}}
638 \membersection{wxMenuBar::wxMenuBar
}\label{wxmenubarconstr
}
640 \func{void
}{wxMenuBar
}{\param{long
}{style =
0}}
644 \func{void
}{wxMenuBar
}{\param{int
}{ n
},
\param{wxMenu*
}{ menus
[]},
\param{const wxString
}{titles
[]}}
646 Construct a menu bar from arrays of menus and titles.
648 \wxheading{Parameters
}
650 \docparam{n
}{The number of menus.
}
652 \docparam{menus
}{An array of menus. Do not use this array again - it now belongs to the
655 \docparam{titles
}{An array of title strings. Deallocate this array after creating the menu bar.
}
657 \docparam{style
}{If
{\tt wxMB
\_DOCKABLE} the menu bar can be detached (wxGTK only).
}
659 \pythonnote{Only the default constructor is supported in wxPython.
660 Use wxMenuBar.Append instead.
}
662 \perlnote{wxPerl only supports the first contructor:
663 use
{\tt Append
} instead.
}
665 \membersection{wxMenuBar::
\destruct{wxMenuBar
}}
667 \func{void
}{\destruct{wxMenuBar
}}{\void}
669 Destructor, destroying the menu bar and removing it from the parent frame (if any).
671 \membersection{wxMenuBar::Append
}\label{wxmenubarappend
}
673 \func{bool
}{Append
}{\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
675 Adds the item to the end of the menu bar.
677 \wxheading{Parameters
}
679 \docparam{menu
}{The menu to add. Do not deallocate this menu after calling
{\bf Append
}.
}
681 \docparam{title
}{The title of the menu.
}
683 \wxheading{Return value
}
685 TRUE on success, FALSE if an error occurred.
689 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
}
691 \membersection{wxMenuBar::Check
}\label{wxmenubarcheck
}
693 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
695 Checks or unchecks a menu item.
697 \wxheading{Parameters
}
699 \docparam{id
}{The menu item identifier.
}
701 \docparam{check
}{If TRUE, checks the menu item, otherwise the item is unchecked.
}
705 Only use this when the menu bar has been associated
706 with a frame; otherwise, use the wxMenu equivalent call.
708 \membersection{wxMenuBar::Enable
}\label{wxmenubarenable
}
710 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
712 Enables or disables (greys out) a menu item.
714 \wxheading{Parameters
}
716 \docparam{id
}{The menu item identifier.
}
718 \docparam{enable
}{TRUE to enable the item, FALSE to disable it.
}
722 Only use this when the menu bar has been
723 associated with a frame; otherwise, use the wxMenu equivalent call.
725 \membersection{wxMenuBar::EnableTop
}\label{wxmenubarenabletop
}
727 \func{void
}{EnableTop
}{\param{int
}{ pos
},
\param{const bool
}{ enable
}}
729 Enables or disables a whole menu.
731 \wxheading{Parameters
}
733 \docparam{pos
}{The position of the menu, starting from zero.
}
735 \docparam{enable
}{TRUE to enable the menu, FALSE to disable it.
}
739 Only use this when the menu bar has been
740 associated with a frame.
742 \membersection{wxMenuBar::FindMenu
}\label{wxmenubarfindmenu
}
744 \constfunc{int
}{FindMenu
}{\param{const wxString\&
}{title
}}
746 Returns the index of the menu with the given
{\it title
} or wxNOT
\_FOUND if no
747 such menu exists in this menubar. The
{\it title
} parameter may specify either
748 the menu title (with accelerator characters, i.e.
{\tt "\&File"
}) or just the
749 menu label (
{\tt "File"
}) indifferently.
751 \membersection{wxMenuBar::FindMenuItem
}\label{wxmenubarfindmenuitem
}
753 \constfunc{int
}{FindMenuItem
}{\param{const wxString\&
}{menuString
},
\param{const wxString\&
}{itemString
}}
755 Finds the menu item id for a menu name/menu item string pair.
757 \wxheading{Parameters
}
759 \docparam{menuString
}{Menu title to find.
}
761 \docparam{itemString
}{Item to find.
}
763 \wxheading{Return value
}
765 The menu item identifier, or wxNOT
\_FOUND if none was found.
769 Any special menu codes are stripped out of source and target strings
772 \membersection{wxMenuBar::FindItem
}\label{wxmenubarfinditem
}
774 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu
}{ **menu = NULL
}}
776 Finds the menu item object associated with the given menu item identifier.
778 \wxheading{Parameters
}
780 \docparam{id
}{Menu item identifier.
}
782 \docparam{menu
}{If not NULL, menu will get set to the associated menu.
}
784 \wxheading{Return value
}
786 The found menu item object, or NULL if one was not found.
788 \membersection{wxMenuBar::GetHelpString
}\label{wxmenubargethelpstring
}
790 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
792 Gets the help string associated with the menu item identifer.
794 \wxheading{Parameters
}
796 \docparam{id
}{The menu item identifier.
}
798 \wxheading{Return value
}
800 The help string, or the empty string if there was no help string or the menu item
805 \helpref{wxMenuBar::SetHelpString
}{wxmenubarsethelpstring
}
807 \membersection{wxMenuBar::GetLabel
}\label{wxmenubargetlabel
}
809 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
811 Gets the label associated with a menu item.
813 \wxheading{Parameters
}
815 \docparam{id
}{The menu item identifier.
}
817 \wxheading{Return value
}
819 The menu item label, or the empty string if the item was not found.
823 Use only after the menubar has been associated with a frame.
825 \membersection{wxMenuBar::GetLabelTop
}\label{wxmenubargetlabeltop
}
827 \constfunc{wxString
}{GetLabelTop
}{\param{int
}{ pos
}}
829 Returns the label of a top-level menu.
831 \wxheading{Parameters
}
833 \docparam{pos
}{Position of the menu on the menu bar, starting from zero.
}
835 \wxheading{Return value
}
837 The menu label, or the empty string if the menu was not found.
841 Use only after the menubar has been associated with a frame.
845 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
}
847 \membersection{wxMenuBar::GetMenu
}\label{wxmenubargetmenu
}
849 \constfunc{wxMenu*
}{GetMenu
}{\param{int
}{ menuIndex
}}
851 Returns the menu at
{\it menuIndex
} (zero-based).
853 \membersection{wxMenuBar::GetMenuCount
}\label{wxmenubargetmenucount
}
855 \constfunc{int
}{GetMenuCount
}{\void}
857 Returns the number of menus in this menubar.
859 \membersection{wxMenuBar::Insert
}\label{wxmenubarinsert
}
861 \func{bool
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
863 Inserts the menu at the given position into the menu bar. Inserting menu at
864 position $
0$ will insert it in the very beginning of it, inserting at position
865 \helpref{GetMenuCount()
}{wxmenubargetmenucount
} is the same as calling
866 \helpref{Append()
}{wxmenubarappend
}.
868 \wxheading{Parameters
}
870 \docparam{pos
}{The position of the new menu in the menu bar
}
872 \docparam{menu
}{The menu to add. wxMenuBar owns the menu and will free it.
}
874 \docparam{title
}{The title of the menu.
}
876 \wxheading{Return value
}
878 TRUE on success, FALSE if an error occurred.
882 \helpref{wxMenuBar::Append
}{wxmenubarappend
}
884 \membersection{wxMenuBar::IsChecked
}\label{wxmenubarischecked
}
886 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
888 Determines whether an item is checked.
890 \wxheading{Parameters
}
892 \docparam{id
}{The menu item identifier.
}
894 \wxheading{Return value
}
896 TRUE if the item was found and is checked, FALSE otherwise.
898 \membersection{wxMenuBar::IsEnabled
}\label{wxmenubarisenabled
}
900 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
902 Determines whether an item is enabled.
904 \wxheading{Parameters
}
906 \docparam{id
}{The menu item identifier.
}
908 \wxheading{Return value
}
910 TRUE if the item was found and is enabled, FALSE otherwise.
912 \membersection{wxMenuBar::Refresh
}\label{wxmenubarrefresh
}
914 \func{void
}{Refresh
}{\void}
918 \membersection{wxMenuBar::Remove
}\label{wxmenubarremove
}
920 \func{wxMenu *
}{Remove
}{\param{size
\_t }{pos
}}
922 Removes the menu from the menu bar and returns the menu object - the caller is
923 responsible for deleting it. This function may be used together with
924 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
} to change the menubar
929 \helpref{wxMenuBar::Replace
}{wxmenubarreplace
}
931 \membersection{wxMenuBar::Replace
}\label{wxmenubarreplace
}
933 \func{wxMenu *
}{Replace
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
935 Replaces the menu at the given position with another one.
937 \wxheading{Parameters
}
939 \docparam{pos
}{The position of the new menu in the menu bar
}
941 \docparam{menu
}{The menu to add.
}
943 \docparam{title
}{The title of the menu.
}
945 \wxheading{Return value
}
947 The menu which was previously at the position
{\it pos
}. The caller is
948 responsible for deleting it.
952 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
},
\rtfsp
953 \helpref{wxMenuBar::Remove
}{wxmenubarremove
}
955 \membersection{wxMenuBar::SetHelpString
}\label{wxmenubarsethelpstring
}
957 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
959 Sets the help string associated with a menu item.
961 \wxheading{Parameters
}
963 \docparam{id
}{Menu item identifier.
}
965 \docparam{helpString
}{Help string to associate with the menu item.
}
969 \helpref{wxMenuBar::GetHelpString
}{wxmenubargethelpstring
}
971 \membersection{wxMenuBar::SetLabel
}\label{wxmenubarsetlabel
}
973 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
975 Sets the label of a menu item.
977 \wxheading{Parameters
}
979 \docparam{id
}{Menu item identifier.
}
981 \docparam{label
}{Menu item label.
}
985 Use only after the menubar has been associated with a frame.
989 \helpref{wxMenuBar::GetLabel
}{wxmenubargetlabel
}
991 \membersection{wxMenuBar::SetLabelTop
}\label{wxmenubarsetlabeltop
}
993 \func{void
}{SetLabelTop
}{\param{int
}{ pos
},
\param{const wxString\&
}{label
}}
995 Sets the label of a top-level menu.
997 \wxheading{Parameters
}
999 \docparam{pos
}{The position of a menu on the menu bar, starting from zero.
}
1001 \docparam{label
}{The menu label.
}
1005 Use only after the menubar has been associated with a frame.
1007 \wxheading{See also
}
1009 \helpref{wxMenuBar::GetLabelTop
}{wxmenubargetlabeltop
}