1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxMenu documentation
4 %% Author: wxWidgets Team
8 %% Copyright: (c) wxWidgets Team
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxMenu
}}\label{wxmenu
}
14 A menu is a popup (or pull down) list of items, one of which may be
15 selected before the menu goes away (clicking elsewhere dismisses the
16 menu). Menus may be used to construct either menu bars or popup menus.
18 A menu item has an integer ID associated with it which can be used to
19 identify the selection, or to change the menu item in some way. A menu item
20 with a special identifier $-
1$ is a separator item and doesn't have an
21 associated command but just makes a separator line appear in the menu.
23 {\bf NB:
} Please note that
{\it wxID
\_ABOUT} and
{\it wxID
\_EXIT} are
24 predefined by wxWidgets and have a special meaning since entries
25 using these IDs will be taken out of the normal menus under MacOS X
26 and will be inserted into the system menu (following the appropriate
27 MacOS X interface guideline). On PalmOS
{\it wxID
\_EXIT} is disabled according
28 to Palm OS Companion guidelines.
30 Menu items may be either normal items, check items or radio items. Normal items
31 don't have any special properties while the check items have a boolean flag
32 associated to them and they show a checkmark in the menu when the flag is set.
33 wxWidgets automatically toggles the flag value when the item is clicked and its
34 value may be retrieved using either
\helpref{IsChecked
}{wxmenuischecked
} method
35 of wxMenu or wxMenuBar itself or by using
36 \helpref{wxEvent::IsChecked
}{wxcommandeventischecked
} when you get the menu
37 notification for the item in question.
39 The radio items are similar to the check items except that all the other items
40 in the same radio group are unchecked when a radio item is checked. The radio
41 group is formed by a contiguous range of radio items, i.e. it starts at the
42 first item of this kind and ends with the first item of a different kind (or
43 the end of the menu). Notice that because the radio groups are defined in terms
44 of the item positions inserting or removing the items in the menu containing
45 the radio items risks to not work correctly. Finally note that radio items
46 are not supported under Motif.
48 \wxheading{Allocation strategy
}
50 All menus except the popup ones must be created on the heap. All menus
51 attached to a menubar or to another menu will be deleted by their parent when
52 it is deleted. As the frame menubar is deleted by the frame itself, it means
53 that normally all menus used are deleted automatically.
55 \wxheading{Derived from
}
57 \helpref{wxEvtHandler
}{wxevthandler
}\\
58 \helpref{wxObject
}{wxobject
}
60 \wxheading{Include files
}
66 \helpref{wxCore
}{librarieslist
}
68 \wxheading{Event handling
}
70 If the menu is part of a menubar, then
\helpref{wxMenuBar
}{wxmenubar
} event processing is used.
72 With a popup menu, there is a variety of ways to handle a menu selection event
73 (wxEVT
\_COMMAND\_MENU\_SELECTED).
75 \begin{enumerate
}\itemsep=
0pt
76 \item Derive a new class from wxMenu and define event table entries using the EVT
\_MENU macro.
77 \item Set a new event handler for wxMenu, using an object whose class has EVT
\_MENU entries.
78 \item Provide EVT
\_MENU handlers in the window which pops up the menu, or in an ancestor of
84 \helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
},
\rtfsp
85 \helpref{Event handling overview
}{eventhandlingoverview
},
\rtfsp
86 \helpref{wxFileHistory (most recently used files menu)
}{wxfilehistory
}
90 \latexignore{\rtfignore{\wxheading{Members
}}}
93 \membersection{wxMenu::wxMenu
}\label{wxmenuctor
}
95 \func{}{wxMenu
}{\param{const wxString\&
}{title = ""
},
\param{long
}{ style =
0}}
97 Constructs a wxMenu object.
99 \wxheading{Parameters
}
101 \docparam{title
}{A title for the popup menu: the empty string denotes no title.
}
103 \docparam{style
}{If set to
{\tt wxMENU
\_TEAROFF}, the menu will be detachable (wxGTK only).
}
105 \func{}{wxMenu
}{\param{long
}{ style
}}
107 Constructs a wxMenu object.
109 \wxheading{Parameters
}
111 \docparam{style
}{If set to
{\tt wxMENU
\_TEAROFF}, the menu will be detachable (wxGTK only).
}
114 \membersection{wxMenu::
\destruct{wxMenu
}}\label{wxmenudtor
}
116 \func{}{\destruct{wxMenu
}}{\void}
118 Destructor, destroying the menu.
120 Note: under Motif, a popup menu must have a valid parent (the window
121 it was last popped up on) when being destroyed. Therefore, make sure
122 you delete or re-use the popup menu
{\it before
} destroying the
123 parent window. Re-use in this context means popping up the menu on
124 a different window from last time, which causes an implicit destruction
125 and recreation of internal data structures.
128 \membersection{wxMenu::Append
}\label{wxmenuappend
}
130 \func{wxMenuItem*
}{Append
}{\param{int
}{ id
},
\param{const wxString\&
}{ item = ""
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
131 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
133 Adds a string item to the end of the menu.
135 \func{wxMenuItem*
}{Append
}{\param{int
}{ id
},
\param{const wxString\&
}{ item
},
\param{wxMenu *
}{subMenu
},
\rtfsp
136 \param{const wxString\&
}{helpString = ""
}}
138 Adds a pull-right submenu to the end of the menu. Append the submenu to the parent
139 menu
{\it after
} you have added your menu items, or accelerators may not be
142 \func{wxMenuItem*
}{Append
}{\param{wxMenuItem*
}{ menuItem
}}
144 Adds a menu item object. This is the most generic variant of Append() method
145 because it may be used for both items (including separators) and submenus and
146 because you can also specify various extra properties of a menu item this way,
147 such as bitmaps and fonts.
149 \wxheading{Parameters
}
151 \docparam{id
}{The menu command identifier.
}
153 \docparam{item
}{The string to appear on the menu item.
}
155 \docparam{menu
}{Pull-right submenu.
}
157 \docparam{kind
}{May be
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
158 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}}
160 \docparam{helpString
}{An optional help string associated with the item.
161 By default, the handler for the wxEVT
\_MENU\_HIGHLIGHT event displays
162 this string in the status line.
}
164 \docparam{menuItem
}{A menuitem object. It will be owned by the wxMenu object after this function
165 is called, so do not delete it yourself.
}
169 This command can be used after the menu has been shown, as well as on initial
170 creation of a menu or menubar.
172 The
{\it item
} string for the normal menu items (not submenus or separators)
173 may include the accelerator which can be used to activate the menu item
174 from keyboard. The accelerator string follows the item label and is separated
175 from it by a
{\tt TAB
} character (
{\tt '$
\backslash$t'
}). Its general syntax is
176 any combination of
{\tt "CTRL"
},
{\tt "ALT"
} and
{\tt "SHIFT"
} strings (case
177 doesn't matter) separated by either
{\tt '-'
} or
{\tt '+'
} characters and
178 followed by the accelerator itself. The accelerator may be any alphanumeric
179 character, any function key (from
{\tt F1
} to
{\tt F12
}) or one of the special
180 characters listed in the table below (again, case doesn't matter):
182 \begin{twocollist
}\itemsep=
0pt
183 \twocolitem{{\tt DEL
} or
{\tt DELETE
}}{Delete key
}
184 \twocolitem{{\tt INS
} or
{\tt INSERT
}}{Insert key
}
185 \twocolitem{{\tt ENTER
} or
{\tt RETURN
}}{Enter key
}
186 \twocolitem{{\tt PGUP
}}{PageUp key
}
187 \twocolitem{{\tt PGDN
}}{PageDown key
}
188 \twocolitem{{\tt LEFT
}}{Left cursor arrow key
}
189 \twocolitem{{\tt RIGHT
}}{Right cursor arrow key
}
190 \twocolitem{{\tt UP
}}{Up cursor arrow key
}
191 \twocolitem{{\tt DOWN
}}{Down cursor arrow key
}
192 \twocolitem{{\tt HOME
}}{Home key
}
193 \twocolitem{{\tt END
}}{End key
}
194 \twocolitem{{\tt SPACE
}}{Space
}
195 \twocolitem{{\tt TAB
}}{Tab key
}
196 \twocolitem{{\tt ESC
} or
{\tt ESCAPE
}}{Escape key (Windows only)
}
201 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
},
\rtfsp
202 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
},
\rtfsp
203 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
},
\rtfsp
204 \helpref{wxMenu::AppendSubMenu
}{wxmenuappendsubmenu
},
\rtfsp
205 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
206 \helpref{wxMenu::SetLabel
}{wxmenusetlabel
},
\helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
},
\rtfsp
207 \helpref{wxMenu::SetHelpString
}{wxmenusethelpstring
},
\helpref{wxMenuItem
}{wxmenuitem
}
209 \pythonnote{In place of a single overloaded method name, wxPython
210 implements the following methods:
212 \indented{2cm
}{\begin{twocollist
}
213 \twocolitem{{\bf Append(id, string, helpStr="", checkable=false)
}}{}
214 \twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")
}}{}
215 \twocolitem{{\bf AppendItem(aMenuItem)
}}{}
220 \membersection{wxMenu::AppendCheckItem
}\label{wxmenuappendcheckitem
}
222 \func{wxMenuItem*
}{AppendCheckItem
}{\param{int
}{ id
},
\rtfsp
223 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
225 Adds a checkable item to the end of the menu.
229 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
230 \helpref{wxMenu::InsertCheckItem
}{wxmenuinsertcheckitem
}
233 \membersection{wxMenu::AppendRadioItem
}\label{wxmenuappendradioitem
}
235 \func{wxMenuItem*
}{AppendRadioItem
}{\param{int
}{ id
},
\rtfsp
236 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
238 Adds a radio item to the end of the menu. All consequent radio items form a
239 group and when an item in the group is checked, all the others are
240 automatically unchecked.
244 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
245 \helpref{wxMenu::InsertRadioItem
}{wxmenuinsertradioitem
}
248 \membersection{wxMenu::AppendSeparator
}\label{wxmenuappendseparator
}
250 \func{wxMenuItem*
}{AppendSeparator
}{\void}
252 Adds a separator to the end of the menu.
256 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
257 \helpref{wxMenu::InsertSeparator
}{wxmenuinsertseparator
}
260 \membersection{wxMenu::AppendSubMenu
}\label{wxmenuappendsubmenu
}
262 \func{wxMenuItem *
}{AppendSubMenu
}{\param{wxMenu *
}{submenu
},
\param{const wxString\&
}{text
},
\param{const wxString\&
}{help = wxEmptyString
}}
264 Adds the given
\arg{submenu
} to this menu.
\arg{text
} is the text shown in the
265 menu for it and
\arg{help
} is the help string shown in the status bar when the
266 submenu item is selected.
269 \membersection{wxMenu::Break
}\label{wxmenubreak
}
271 \func{void
}{Break
}{\void}
273 Inserts a break in a menu, causing the next appended item to appear in a new column.
276 \membersection{wxMenu::Check
}\label{wxmenucheck
}
278 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
280 Checks or unchecks the menu item.
282 \wxheading{Parameters
}
284 \docparam{id
}{The menu item identifier.
}
286 \docparam{check
}{If true, the item will be checked, otherwise it will be unchecked.
}
290 \helpref{wxMenu::IsChecked
}{wxmenuischecked
}
293 \membersection{wxMenu::Delete
}\label{wxmenudelete
}
295 \func{void
}{Delete
}{\param{int
}{id
}}
297 \func{void
}{Delete
}{\param{wxMenuItem *
}{item
}}
299 Deletes the menu item from the menu. If the item is a submenu, it will
300 {\bf not
} be deleted. Use
\helpref{Destroy
}{wxmenudestroy
} if you want to
303 \wxheading{Parameters
}
305 \docparam{id
}{Id of the menu item to be deleted.
}
307 \docparam{item
}{Menu item to be deleted.
}
311 \helpref{wxMenu::FindItem
}{wxmenufinditem
},
\rtfsp
312 \helpref{wxMenu::Destroy
}{wxmenudestroy
},
\rtfsp
313 \helpref{wxMenu::Remove
}{wxmenuremove
}
316 \membersection{wxMenu::Destroy
}\label{wxmenudestroy
}
318 \func{void
}{Destroy
}{\param{int
}{id
}}
320 \func{void
}{Destroy
}{\param{wxMenuItem *
}{item
}}
322 Deletes the menu item from the menu. If the item is a submenu, it will
323 be deleted. Use
\helpref{Remove
}{wxmenuremove
} if you want to keep the submenu
324 (for example, to reuse it later).
326 \wxheading{Parameters
}
328 \docparam{id
}{Id of the menu item to be deleted.
}
330 \docparam{item
}{Menu item to be deleted.
}
334 \helpref{wxMenu::FindItem
}{wxmenufinditem
},
\rtfsp
335 \helpref{wxMenu::Deletes
}{wxmenudelete
},
\rtfsp
336 \helpref{wxMenu::Remove
}{wxmenuremove
}
339 \membersection{wxMenu::Enable
}\label{wxmenuenable
}
341 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
343 Enables or disables (greys out) a menu item.
345 \wxheading{Parameters
}
347 \docparam{id
}{The menu item identifier.
}
349 \docparam{enable
}{true to enable the menu item, false to disable it.
}
353 \helpref{wxMenu::IsEnabled
}{wxmenuisenabled
}
356 \membersection{wxMenu::FindItem
}\label{wxmenufinditem
}
358 \constfunc{int
}{FindItem
}{\param{const wxString\&
}{itemString
}}
360 Finds the menu item id for a menu item string.
362 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu **
}{menu = NULL
}}
364 Finds the menu item object associated with the given menu item identifier and,
365 optionally, the (sub)menu it belongs to.
367 \perlnote{In wxPerl this method takes just the
{\tt id
} parameter;
368 in scalar context it returns the associated
{\tt Wx::MenuItem
}, in list
369 context it returns a
2-element list
{\tt ( item, submenu )
}}
371 \wxheading{Parameters
}
373 \docparam{itemString
}{Menu item string to find.
}
375 \docparam{id
}{Menu item identifier.
}
377 \docparam{menu
}{If the pointer is not NULL, it will be filled with the item's
378 parent menu (if the item was found)
}
380 \wxheading{Return value
}
382 First form: menu item identifier, or
{\tt wxNOT
\_FOUND} if none is found.
384 Second form: returns the menu item object, or NULL if it is not found.
388 Any special menu codes are stripped out of source and target strings
391 \pythonnote{The name of this method in wxPython is
{\tt FindItemById
}
392 and it does not support the second parameter.
}
395 \membersection{wxMenu::FindItemByPosition
}\label{wxmenufinditembyposition
}
397 \constfunc{wxMenuItem*
}{FindItemByPosition
}{\param{size
\_t }{position
}}
399 Returns the wxMenuItem given a position in the menu.
402 \membersection{wxMenu::GetHelpString
}\label{wxmenugethelpstring
}
404 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
406 Returns the help string associated with a menu item.
408 \wxheading{Parameters
}
410 \docparam{id
}{The menu item identifier.
}
412 \wxheading{Return value
}
414 The help string, or the empty string if there is no help string or the
419 \helpref{wxMenu::SetHelpString
}{wxmenusethelpstring
},
\helpref{wxMenu::Append
}{wxmenuappend
}
422 \membersection{wxMenu::GetLabel
}\label{wxmenugetlabel
}
424 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
426 Returns a menu item label.
428 \wxheading{Parameters
}
430 \docparam{id
}{The menu item identifier.
}
432 \wxheading{Return value
}
434 The item label, or the empty string if the item was not found.
438 \helpref{wxMenu::GetLabelText
}{wxmenugetlabeltext
},
\helpref{wxMenu::SetLabel
}{wxmenusetlabel
}
441 \membersection{wxMenu::GetLabelText
}\label{wxmenugetlabeltext
}
443 \constfunc{wxString
}{GetLabelText
}{\param{int
}{ id
}}
445 Returns a menu item label, without any of the original mnemonics and accelerators.
447 \wxheading{Parameters
}
449 \docparam{id
}{The menu item identifier.
}
451 \wxheading{Return value
}
453 The item label, or the empty string if the item was not found.
457 \helpref{wxMenu::GetLabel
}{wxmenugetlabel
},
\helpref{wxMenu::SetLabel
}{wxmenusetlabel
}
459 \membersection{wxMenu::GetMenuItemCount
}\label{wxmenugetmenuitemcount
}
461 \constfunc{size
\_t}{GetMenuItemCount
}{\void}
463 Returns the number of items in the menu.
466 \membersection{wxMenu::GetMenuItems
}\label{wxmenugetmenuitems
}
468 \constfunc{wxMenuItemList\&
}{GetMenuItems
}{\void}
470 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
471 list class containing wxMenuItem pointers, see
\helpref{wxList
}{wxlist
}.
474 \membersection{wxMenu::GetTitle
}\label{wxmenugettitle
}
476 \constfunc{wxString
}{GetTitle
}{\void}
478 Returns the title of the menu.
482 This is relevant only to popup menus, use
483 \helpref{wxMenuBar::GetMenuLabel
}{wxmenubargetmenulabel
} for the menus in the
488 \helpref{wxMenu::SetTitle
}{wxmenusettitle
}
491 \membersection{wxMenu::Insert
}\label{wxmenuinsert
}
493 \func{wxMenuItem*
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenuItem *
}{item
}}
495 \func{wxMenuItem*
}{Insert
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
496 \param{const wxString\&
}{ item = ""
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
497 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
499 Inserts the given
{\it item
} before the position
{\it pos
}. Inserting the item
500 at position
\helpref{GetMenuItemCount
}{wxmenugetmenuitemcount
} is the same
505 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
506 \helpref{wxMenu::Prepend
}{wxmenuprepend
}
509 \membersection{wxMenu::InsertCheckItem
}\label{wxmenuinsertcheckitem
}
511 \func{wxMenuItem*
}{InsertCheckItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
512 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
514 Inserts a checkable item at the given position.
518 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
519 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
522 \membersection{wxMenu::InsertRadioItem
}\label{wxmenuinsertradioitem
}
524 \func{wxMenuItem*
}{InsertRadioItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
525 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
527 Inserts a radio item at the given position.
531 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
532 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
535 \membersection{wxMenu::InsertSeparator
}\label{wxmenuinsertseparator
}
537 \func{wxMenuItem*
}{InsertSeparator
}{\param{size
\_t }{pos
}}
539 Inserts a separator at the given position.
543 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
544 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
547 \membersection{wxMenu::IsChecked
}\label{wxmenuischecked
}
549 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
551 Determines whether a menu item is checked.
553 \wxheading{Parameters
}
555 \docparam{id
}{The menu item identifier.
}
557 \wxheading{Return value
}
559 true if the menu item is checked, false otherwise.
563 \helpref{wxMenu::Check
}{wxmenucheck
}
566 \membersection{wxMenu::IsEnabled
}\label{wxmenuisenabled
}
568 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
570 Determines whether a menu item is enabled.
572 \wxheading{Parameters
}
574 \docparam{id
}{The menu item identifier.
}
576 \wxheading{Return value
}
578 true if the menu item is enabled, false otherwise.
582 \helpref{wxMenu::Enable
}{wxmenuenable
}
585 \membersection{wxMenu::Prepend
}\label{wxmenuprepend
}
587 \func{wxMenuItem*
}{Prepend
}{\param{wxMenuItem *
}{item
}}
589 \func{wxMenuItem*
}{Prepend
}{\param{int
}{ id
},
\rtfsp
590 \param{const wxString\&
}{ item = ""
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
591 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
593 Inserts the given
{\it item
} at position $
0$, i.e. before all the other
598 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
599 \helpref{wxMenu::Insert
}{wxmenuinsert
}
602 \membersection{wxMenu::PrependCheckItem
}\label{wxmenuprependcheckitem
}
604 \func{wxMenuItem*
}{PrependCheckItem
}{\param{int
}{ id
},
\rtfsp
605 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
607 Inserts a checkable item at position $
0$.
611 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
612 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
615 \membersection{wxMenu::PrependRadioItem
}\label{wxmenuprependradioitem
}
617 \func{wxMenuItem*
}{PrependRadioItem
}{\param{int
}{ id
},
\rtfsp
618 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
620 Inserts a radio item at position $
0$.
624 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
625 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
628 \membersection{wxMenu::PrependSeparator
}\label{wxmenuprependseparator
}
630 \func{wxMenuItem*
}{PrependSeparator
}{\void}
632 Inserts a separator at position $
0$.
636 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
637 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
640 \membersection{wxMenu::Remove
}\label{wxmenuremove
}
642 \func{wxMenuItem *
}{Remove
}{\param{int
}{id
}}
644 \func{wxMenuItem *
}{Remove
}{\param{wxMenuItem *
}{item
}}
646 Removes the menu item from the menu but doesn't delete the associated C++
647 object. This allows to reuse the same item later by adding it back to the menu
648 (especially useful with submenus).
650 \wxheading{Parameters
}
652 \docparam{id
}{The identifier of the menu item to remove.
}
654 \docparam{item
}{The menu item to remove.
}
656 \wxheading{Return value
}
658 The item which was detached from the menu.
661 \membersection{wxMenu::SetHelpString
}\label{wxmenusethelpstring
}
663 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
665 Sets an item's help string.
667 \wxheading{Parameters
}
669 \docparam{id
}{The menu item identifier.
}
671 \docparam{helpString
}{The help string to set.
}
675 \helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
}
678 \membersection{wxMenu::SetLabel
}\label{wxmenusetlabel
}
680 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
682 Sets the label of a menu item.
684 \wxheading{Parameters
}
686 \docparam{id
}{The menu item identifier.
}
688 \docparam{label
}{The menu item label to set.
}
692 \helpref{wxMenu::Append
}{wxmenuappend
},
\helpref{wxMenu::GetLabel
}{wxmenugetlabel
}
695 \membersection{wxMenu::SetTitle
}\label{wxmenusettitle
}
697 \func{void
}{SetTitle
}{\param{const wxString\&
}{title
}}
699 Sets the title of the menu.
701 \wxheading{Parameters
}
703 \docparam{title
}{The title to set.
}
707 This is relevant only to popup menus, use
708 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
} for the menus in the
713 \helpref{wxMenu::GetTitle
}{wxmenugettitle
}
716 \membersection{wxMenu::UpdateUI
}\label{wxmenuupdateui
}
718 \constfunc{void
}{UpdateUI
}{\param{wxEvtHandler*
}{ source = NULL
}}
720 Sends events to
{\it source
} (or owning window if NULL) to update the
721 menu UI. This is called just before the menu is popped up with
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
}, but
722 the application may call it at other times if required.
726 \helpref{wxUpdateUIEvent
}{wxupdateuievent
}
728 \section{\class{wxMenuBar
}}\label{wxmenubar
}
730 A menu bar is a series of menus accessible from the top of a frame.
732 \wxheading{Derived from
}
734 \helpref{wxWindow
}{wxwindow
}\\
735 \helpref{wxEvtHandler
}{wxevthandler
}\\
736 \helpref{wxObject
}{wxobject
}
738 \wxheading{Include files
}
744 \helpref{wxCore
}{librarieslist
}
746 \wxheading{Event handling
}
748 To respond to a menu selection, provide a handler for EVT
\_MENU, in the frame
749 that contains the menu bar. If you have a toolbar which uses the same identifiers
750 as your EVT
\_MENU entries, events from the toolbar will also be processed by your
751 EVT
\_MENU event handlers.
753 {\bf Tip:
} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
754 are not working, check any EVT
\_CHAR events you are handling in child windows.
755 If you are not calling
{\tt event.Skip()
} for events that you don't process in these event handlers,
756 menu shortcuts may cease to work.
760 \helpref{wxMenu
}{wxmenu
},
\helpref{Event handling overview
}{eventhandlingoverview
}
762 \latexignore{\rtfignore{\wxheading{Members
}}}
765 \membersection{wxMenuBar::wxMenuBar
}\label{wxmenubarctor
}
767 \func{}{wxMenuBar
}{\param{long
}{style =
0}}
771 \func{}{wxMenuBar
}{\param{size
\_t}{ n
},
\param{wxMenu*
}{ menus
[]},
\param{const wxString
}{titles
[]},
\param{long
}{style =
0}}
773 Construct a menu bar from arrays of menus and titles.
775 \wxheading{Parameters
}
777 \docparam{n
}{The number of menus.
}
779 \docparam{menus
}{An array of menus. Do not use this array again - it now belongs to the
782 \docparam{titles
}{An array of title strings. Deallocate this array after creating the menu bar.
}
784 \docparam{style
}{If
{\tt wxMB
\_DOCKABLE} the menu bar can be detached (wxGTK only).
}
786 \pythonnote{Only the default constructor is supported in wxPython.
787 Use
\helpref{wxMenuBar::Append
}{wxmenubarappend
} instead.
}
789 \perlnote{wxPerl only supports the first constructor:
790 use
\helpref{wxMenuBar::Append
}{wxmenubarappend
} instead.
}
793 \membersection{wxMenuBar::
\destruct{wxMenuBar
}}\label{wxmenubardtor
}
795 \func{void
}{\destruct{wxMenuBar
}}{\void}
797 Destructor, destroying the menu bar and removing it from the parent frame (if any).
800 \membersection{wxMenuBar::Append
}\label{wxmenubarappend
}
802 \func{bool
}{Append
}{\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
804 Adds the item to the end of the menu bar.
806 \wxheading{Parameters
}
808 \docparam{menu
}{The menu to add. Do not deallocate this menu after calling
{\bf Append
}.
}
810 \docparam{title
}{The title of the menu.
}
812 \wxheading{Return value
}
814 true on success, false if an error occurred.
818 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
}
821 \membersection{wxMenuBar::Check
}\label{wxmenubarcheck
}
823 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
825 Checks or unchecks a menu item.
827 \wxheading{Parameters
}
829 \docparam{id
}{The menu item identifier.
}
831 \docparam{check
}{If true, checks the menu item, otherwise the item is unchecked.
}
835 Only use this when the menu bar has been associated
836 with a frame; otherwise, use the wxMenu equivalent call.
839 \membersection{wxMenuBar::Enable
}\label{wxmenubarenable
}
841 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
843 Enables or disables (greys out) a menu item.
845 \wxheading{Parameters
}
847 \docparam{id
}{The menu item identifier.
}
849 \docparam{enable
}{true to enable the item, false to disable it.
}
853 Only use this when the menu bar has been
854 associated with a frame; otherwise, use the wxMenu equivalent call.
857 \membersection{wxMenuBar::EnableTop
}\label{wxmenubarenabletop
}
859 \func{void
}{EnableTop
}{\param{int
}{ pos
},
\param{const bool
}{ enable
}}
861 Enables or disables a whole menu.
863 \wxheading{Parameters
}
865 \docparam{pos
}{The position of the menu, starting from zero.
}
867 \docparam{enable
}{true to enable the menu, false to disable it.
}
871 Only use this when the menu bar has been
872 associated with a frame.
875 \membersection{wxMenuBar::FindMenu
}\label{wxmenubarfindmenu
}
877 \constfunc{int
}{FindMenu
}{\param{const wxString\&
}{title
}}
879 Returns the index of the menu with the given
{\it title
} or
{\tt wxNOT
\_FOUND} if no
880 such menu exists in this menubar. The
{\it title
} parameter may specify either
881 the menu title (with accelerator characters, i.e.
{\tt "\&File"
}) or just the
882 menu label (
{\tt "File"
}) indifferently.
885 \membersection{wxMenuBar::FindMenuItem
}\label{wxmenubarfindmenuitem
}
887 \constfunc{int
}{FindMenuItem
}{\param{const wxString\&
}{menuString
},
\param{const wxString\&
}{itemString
}}
889 Finds the menu item id for a menu name/menu item string pair.
891 \wxheading{Parameters
}
893 \docparam{menuString
}{Menu title to find.
}
895 \docparam{itemString
}{Item to find.
}
897 \wxheading{Return value
}
899 The menu item identifier, or
{\tt wxNOT
\_FOUND} if none was found.
903 Any special menu codes are stripped out of source and target strings
907 \membersection{wxMenuBar::FindItem
}\label{wxmenubarfinditem
}
909 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu
}{ **menu = NULL
}}
911 Finds the menu item object associated with the given menu item identifier.
913 \wxheading{Parameters
}
915 \docparam{id
}{Menu item identifier.
}
917 \docparam{menu
}{If not NULL, menu will get set to the associated menu.
}
919 \wxheading{Return value
}
921 The found menu item object, or NULL if one was not found.
924 \membersection{wxMenuBar::GetHelpString
}\label{wxmenubargethelpstring
}
926 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
928 Gets the help string associated with the menu item identifier.
930 \wxheading{Parameters
}
932 \docparam{id
}{The menu item identifier.
}
934 \wxheading{Return value
}
936 The help string, or the empty string if there was no help string or the menu item
941 \helpref{wxMenuBar::SetHelpString
}{wxmenubarsethelpstring
}
944 \membersection{wxMenuBar::GetLabel
}\label{wxmenubargetlabel
}
946 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
948 Gets the label associated with a menu item.
950 \wxheading{Parameters
}
952 \docparam{id
}{The menu item identifier.
}
954 \wxheading{Return value
}
956 The menu item label, or the empty string if the item was not found.
960 Use only after the menubar has been associated with a frame.
963 \membersection{wxMenuBar::GetLabelTop
}\label{wxmenubargetlabeltop
}
965 \constfunc{wxString
}{GetLabelTop
}{\param{int
}{ pos
}}
967 Returns the label of a top-level menu. Note that the returned string does not
968 include the accelerator characters which could have been specified in the menu
969 title string during its construction.
971 \wxheading{Parameters
}
973 \docparam{pos
}{Position of the menu on the menu bar, starting from zero.
}
975 \wxheading{Return value
}
977 The menu label, or the empty string if the menu was not found.
981 Use only after the menubar has been associated with a frame.
983 This function is deprecated in favour of
\helpref{GetMenuLabel
}{wxmenubargetmenulabel
} and
\helpref{GetMenuLabelText
}{wxmenubargetmenulabeltext
}.
987 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
}
990 \membersection{wxMenuBar::GetMenu
}\label{wxmenubargetmenu
}
992 \constfunc{wxMenu*
}{GetMenu
}{\param{int
}{ menuIndex
}}
994 Returns the menu at
{\it menuIndex
} (zero-based).
997 \membersection{wxMenuBar::GetMenuCount
}\label{wxmenubargetmenucount
}
999 \constfunc{size
\_t}{GetMenuCount
}{\void}
1001 Returns the number of menus in this menubar.
1004 \membersection{wxMenuBar::GetMenuLabel
}\label{wxmenubargetmenulabel
}
1006 \constfunc{wxString
}{GetMenuLabel
}{\param{int
}{ pos
}}
1008 Returns the label of a top-level menu. Note that the returned string
1009 includes the accelerator characters that have been specified in the menu
1010 title string during its construction.
1012 \wxheading{Parameters
}
1014 \docparam{pos
}{Position of the menu on the menu bar, starting from zero.
}
1016 \wxheading{Return value
}
1018 The menu label, or the empty string if the menu was not found.
1022 Use only after the menubar has been associated with a frame.
1024 \wxheading{See also
}
1026 \helpref{wxMenuBar::GetMenuLabelText
}{wxmenubargetmenulabeltext
},
\helpref{wxMenuBar::SetMenuLabel
}{wxmenubarsetmenulabel
}
1029 \membersection{wxMenuBar::GetMenuLabelText
}\label{wxmenubargetmenulabeltext
}
1031 \constfunc{wxString
}{GetMenuLabelText
}{\param{int
}{ pos
}}
1033 Returns the label of a top-level menu. Note that the returned string does not
1034 include any accelerator characters that may have been specified in the menu
1035 title string during its construction.
1037 \wxheading{Parameters
}
1039 \docparam{pos
}{Position of the menu on the menu bar, starting from zero.
}
1041 \wxheading{Return value
}
1043 The menu label, or the empty string if the menu was not found.
1047 Use only after the menubar has been associated with a frame.
1049 \wxheading{See also
}
1051 \helpref{wxMenuBar::GetMenuLabel
}{wxmenubargetmenulabel
},
\helpref{wxMenuBar::SetMenuLabel
}{wxmenubarsetmenulabel
}
1054 \membersection{wxMenuBar::Insert
}\label{wxmenubarinsert
}
1056 \func{bool
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
1058 Inserts the menu at the given position into the menu bar. Inserting menu at
1059 position $
0$ will insert it in the very beginning of it, inserting at position
1060 \helpref{GetMenuCount()
}{wxmenubargetmenucount
} is the same as calling
1061 \helpref{Append()
}{wxmenubarappend
}.
1063 \wxheading{Parameters
}
1065 \docparam{pos
}{The position of the new menu in the menu bar
}
1067 \docparam{menu
}{The menu to add. wxMenuBar owns the menu and will free it.
}
1069 \docparam{title
}{The title of the menu.
}
1071 \wxheading{Return value
}
1073 true on success, false if an error occurred.
1075 \wxheading{See also
}
1077 \helpref{wxMenuBar::Append
}{wxmenubarappend
}
1080 \membersection{wxMenuBar::IsChecked
}\label{wxmenubarischecked
}
1082 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
1084 Determines whether an item is checked.
1086 \wxheading{Parameters
}
1088 \docparam{id
}{The menu item identifier.
}
1090 \wxheading{Return value
}
1092 true if the item was found and is checked, false otherwise.
1095 \membersection{wxMenuBar::IsEnabled
}\label{wxmenubarisenabled
}
1097 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
1099 Determines whether an item is enabled.
1101 \wxheading{Parameters
}
1103 \docparam{id
}{The menu item identifier.
}
1105 \wxheading{Return value
}
1107 true if the item was found and is enabled, false otherwise.
1110 \membersection{wxMenuBar::Refresh
}\label{wxmenubarrefresh
}
1112 \func{void
}{Refresh
}{\void}
1117 \membersection{wxMenuBar::Remove
}\label{wxmenubarremove
}
1119 \func{wxMenu *
}{Remove
}{\param{size
\_t }{pos
}}
1121 Removes the menu from the menu bar and returns the menu object - the caller is
1122 responsible for deleting it. This function may be used together with
1123 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
} to change the menubar
1126 \wxheading{See also
}
1128 \helpref{wxMenuBar::Replace
}{wxmenubarreplace
}
1131 \membersection{wxMenuBar::Replace
}\label{wxmenubarreplace
}
1133 \func{wxMenu *
}{Replace
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
1135 Replaces the menu at the given position with another one.
1137 \wxheading{Parameters
}
1139 \docparam{pos
}{The position of the new menu in the menu bar
}
1141 \docparam{menu
}{The menu to add.
}
1143 \docparam{title
}{The title of the menu.
}
1145 \wxheading{Return value
}
1147 The menu which was previously at position
{\it pos
}. The caller is
1148 responsible for deleting it.
1150 \wxheading{See also
}
1152 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
},
\rtfsp
1153 \helpref{wxMenuBar::Remove
}{wxmenubarremove
}
1156 \membersection{wxMenuBar::SetHelpString
}\label{wxmenubarsethelpstring
}
1158 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
1160 Sets the help string associated with a menu item.
1162 \wxheading{Parameters
}
1164 \docparam{id
}{Menu item identifier.
}
1166 \docparam{helpString
}{Help string to associate with the menu item.
}
1168 \wxheading{See also
}
1170 \helpref{wxMenuBar::GetHelpString
}{wxmenubargethelpstring
}
1173 \membersection{wxMenuBar::SetLabel
}\label{wxmenubarsetlabel
}
1175 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
1177 Sets the label of a menu item.
1179 \wxheading{Parameters
}
1181 \docparam{id
}{Menu item identifier.
}
1183 \docparam{label
}{Menu item label.
}
1187 Use only after the menubar has been associated with a frame.
1189 \wxheading{See also
}
1191 \helpref{wxMenuBar::GetLabel
}{wxmenubargetlabel
}
1194 \membersection{wxMenuBar::SetLabelTop
}\label{wxmenubarsetlabeltop
}
1196 \func{void
}{SetLabelTop
}{\param{int
}{ pos
},
\param{const wxString\&
}{label
}}
1198 Sets the label of a top-level menu.
1200 \wxheading{Parameters
}
1202 \docparam{pos
}{The position of a menu on the menu bar, starting from zero.
}
1204 \docparam{label
}{The menu label.
}
1208 Use only after the menubar has been associated with a frame.
1210 This function has been deprecated in favour of
\helpref{SetMenuLabel
}{wxmenubarsetmenulabel
}.
1212 \wxheading{See also
}
1214 \helpref{wxMenuBar::GetLabelTop
}{wxmenubargetlabeltop
}
1217 \membersection{wxMenuBar::SetMenuLabel
}\label{wxmenubarsetmenulabel
}
1219 \func{void
}{SetMenuLabel
}{\param{int
}{ pos
},
\param{const wxString\&
}{label
}}
1221 Sets the label of a top-level menu.
1223 \wxheading{Parameters
}
1225 \docparam{pos
}{The position of a menu on the menu bar, starting from zero.
}
1227 \docparam{label
}{The menu label.
}
1231 Use only after the menubar has been associated with a frame.
1233 \wxheading{See also
}
1235 \helpref{wxMenuBar::GetMenuLabel
}{wxmenubargetmenulabel
},
\helpref{wxMenuBar::GetMenuLabelText
}{wxmenubargetmenulabeltext
}