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
}
64 \wxheading{Event handling
}
66 If the menu is part of a menubar, then
\helpref{wxMenuBar
}{wxmenubar
} event processing is used.
68 With a popup menu, there is a variety of ways to handle a menu selection event
69 (wxEVT
\_COMMAND\_MENU\_SELECTED).
71 \begin{enumerate
}\itemsep=
0pt
72 \item Derive a new class from wxMenu and define event table entries using the EVT
\_MENU macro.
73 \item Set a new event handler for wxMenu, using an object whose class has EVT
\_MENU entries.
74 \item Provide EVT
\_MENU handlers in the window which pops up the menu, or in an ancestor of
80 \helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
},
\rtfsp
81 \helpref{Event handling overview
}{eventhandlingoverview
},
\rtfsp
82 \helpref{wxFileHistory (most recently used files menu)
}{wxfilehistory
}
86 \latexignore{\rtfignore{\wxheading{Members
}}}
89 \membersection{wxMenu::wxMenu
}\label{wxmenuctor
}
91 \func{}{wxMenu
}{\param{const wxString\&
}{title = ""
},
\param{long
}{ style =
0}}
93 Constructs a wxMenu object.
95 \wxheading{Parameters
}
97 \docparam{title
}{A title for the popup menu: the empty string denotes no title.
}
99 \docparam{style
}{If set to
{\tt wxMENU
\_TEAROFF}, the menu will be detachable (wxGTK only).
}
101 \func{}{wxMenu
}{\param{long
}{ style
}}
103 Constructs a wxMenu object.
105 \wxheading{Parameters
}
107 \docparam{style
}{If set to
{\tt wxMENU
\_TEAROFF}, the menu will be detachable (wxGTK only).
}
110 \membersection{wxMenu::
\destruct{wxMenu
}}\label{wxmenudtor
}
112 \func{}{\destruct{wxMenu
}}{\void}
114 Destructor, destroying the menu.
116 Note: under Motif, a popup menu must have a valid parent (the window
117 it was last popped up on) when being destroyed. Therefore, make sure
118 you delete or re-use the popup menu
{\it before
} destroying the
119 parent window. Re-use in this context means popping up the menu on
120 a different window from last time, which causes an implicit destruction
121 and recreation of internal data structures.
124 \membersection{wxMenu::Append
}\label{wxmenuappend
}
126 \func{wxMenuItem*
}{Append
}{\param{int
}{ id
},
\param{const wxString\&
}{ item = ""
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
127 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
129 Adds a string item to the end of the menu.
131 \func{wxMenuItem*
}{Append
}{\param{int
}{ id
},
\param{const wxString\&
}{ item
},
\param{wxMenu *
}{subMenu
},
\rtfsp
132 \param{const wxString\&
}{helpString = ""
}}
134 Adds a pull-right submenu to the end of the menu. Append the submenu to the parent
135 menu
{\it after
} you have added your menu items, or accelerators may not be
138 \func{wxMenuItem*
}{Append
}{\param{wxMenuItem*
}{ menuItem
}}
140 Adds a menu item object. This is the most generic variant of Append() method
141 because it may be used for both items (including separators) and submenus and
142 because you can also specify various extra properties of a menu item this way,
143 such as bitmaps and fonts.
145 \wxheading{Parameters
}
147 \docparam{id
}{The menu command identifier.
}
149 \docparam{item
}{The string to appear on the menu item.
}
151 \docparam{menu
}{Pull-right submenu.
}
153 \docparam{kind
}{May be
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
154 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}}
156 \docparam{helpString
}{An optional help string associated with the item.
157 By default, the handler for the wxEVT
\_MENU\_HIGHLIGHT event displays
158 this string in the status line.
}
160 \docparam{menuItem
}{A menuitem object. It will be owned by the wxMenu object after this function
161 is called, so do not delete it yourself.
}
165 This command can be used after the menu has been shown, as well as on initial
166 creation of a menu or menubar.
168 The
{\it item
} string for the normal menu items (not submenus or separators)
169 may include the accelerator which can be used to activate the menu item
170 from keyboard. The accelerator string follows the item label and is separated
171 from it by a
{\tt TAB
} character (
{\tt '$
\backslash$t'
}). Its general syntax is
172 any combination of
{\tt "CTRL"
},
{\tt "ALT"
} and
{\tt "SHIFT"
} strings (case
173 doesn't matter) separated by either
{\tt '-'
} or
{\tt '+'
} characters and
174 followed by the accelerator itself. The accelerator may be any alphanumeric
175 character, any function key (from
{\tt F1
} to
{\tt F12
}) or one of the special
176 characters listed in the table below (again, case doesn't matter):
178 \begin{twocollist
}\itemsep=
0pt
179 \twocolitem{{\tt DEL
} or
{\tt DELETE
}}{Delete key
}
180 \twocolitem{{\tt INS
} or
{\tt INSERT
}}{Insert key
}
181 \twocolitem{{\tt ENTER
} or
{\tt RETURN
}}{Enter key
}
182 \twocolitem{{\tt PGUP
}}{PageUp key
}
183 \twocolitem{{\tt PGDN
}}{PageDown key
}
184 \twocolitem{{\tt LEFT
}}{Left cursor arrow key
}
185 \twocolitem{{\tt RIGHT
}}{Right cursor arrow key
}
186 \twocolitem{{\tt UP
}}{Up cursor arrow key
}
187 \twocolitem{{\tt DOWN
}}{Down cursor arrow key
}
188 \twocolitem{{\tt HOME
}}{Home key
}
189 \twocolitem{{\tt END
}}{End key
}
190 \twocolitem{{\tt SPACE
}}{Space
}
191 \twocolitem{{\tt TAB
}}{Tab key
}
192 \twocolitem{{\tt ESC
} or
{\tt ESCAPE
}}{Escape key (Windows only)
}
197 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
},
\rtfsp
198 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
},
\rtfsp
199 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
},
\rtfsp
200 \helpref{wxMenu::AppendSubMenu
}{wxmenuappendsubmenu
},
\rtfsp
201 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
202 \helpref{wxMenu::SetLabel
}{wxmenusetlabel
},
\helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
},
\rtfsp
203 \helpref{wxMenu::SetHelpString
}{wxmenusethelpstring
},
\helpref{wxMenuItem
}{wxmenuitem
}
205 \pythonnote{In place of a single overloaded method name, wxPython
206 implements the following methods:
208 \indented{2cm
}{\begin{twocollist
}
209 \twocolitem{{\bf Append(id, string, helpStr="", checkable=false)
}}{}
210 \twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")
}}{}
211 \twocolitem{{\bf AppendItem(aMenuItem)
}}{}
216 \membersection{wxMenu::AppendCheckItem
}\label{wxmenuappendcheckitem
}
218 \func{wxMenuItem*
}{AppendCheckItem
}{\param{int
}{ id
},
\rtfsp
219 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
221 Adds a checkable item to the end of the menu.
225 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
226 \helpref{wxMenu::InsertCheckItem
}{wxmenuinsertcheckitem
}
229 \membersection{wxMenu::AppendRadioItem
}\label{wxmenuappendradioitem
}
231 \func{wxMenuItem*
}{AppendRadioItem
}{\param{int
}{ id
},
\rtfsp
232 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
234 Adds a radio item to the end of the menu. All consequent radio items form a
235 group and when an item in the group is checked, all the others are
236 automatically unchecked.
240 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
241 \helpref{wxMenu::InsertRadioItem
}{wxmenuinsertradioitem
}
244 \membersection{wxMenu::AppendSeparator
}\label{wxmenuappendseparator
}
246 \func{wxMenuItem*
}{AppendSeparator
}{\void}
248 Adds a separator to the end of the menu.
252 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
253 \helpref{wxMenu::InsertSeparator
}{wxmenuinsertseparator
}
256 \membersection{wxMenu::AppendSubMenu
}\label{wxmenuappendsubmenu
}
258 \func{wxMenuItem *
}{AppendSubMenu
}{\param{wxMenu *
}{submenu
},
\param{const wxString\&
}{text
},
\param{const wxString\&
}{help = wxEmptyString
}}
260 Adds the given
\arg{submenu
} to this menu.
\arg{text
} is the text shown in the
261 menu for it and
\arg{help
} is the help string shown in the status bar when the
262 submenu item is selected.
265 \membersection{wxMenu::Break
}\label{wxmenubreak
}
267 \func{void
}{Break
}{\void}
269 Inserts a break in a menu, causing the next appended item to appear in a new column.
272 \membersection{wxMenu::Check
}\label{wxmenucheck
}
274 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
276 Checks or unchecks the menu item.
278 \wxheading{Parameters
}
280 \docparam{id
}{The menu item identifier.
}
282 \docparam{check
}{If true, the item will be checked, otherwise it will be unchecked.
}
286 \helpref{wxMenu::IsChecked
}{wxmenuischecked
}
289 \membersection{wxMenu::Delete
}\label{wxmenudelete
}
291 \func{void
}{Delete
}{\param{int
}{id
}}
293 \func{void
}{Delete
}{\param{wxMenuItem *
}{item
}}
295 Deletes the menu item from the menu. If the item is a submenu, it will
296 {\bf not
} be deleted. Use
\helpref{Destroy
}{wxmenudestroy
} if you want to
299 \wxheading{Parameters
}
301 \docparam{id
}{Id of the menu item to be deleted.
}
303 \docparam{item
}{Menu item to be deleted.
}
307 \helpref{wxMenu::FindItem
}{wxmenufinditem
},
\rtfsp
308 \helpref{wxMenu::Destroy
}{wxmenudestroy
},
\rtfsp
309 \helpref{wxMenu::Remove
}{wxmenuremove
}
312 \membersection{wxMenu::Destroy
}\label{wxmenudestroy
}
314 \func{void
}{Destroy
}{\param{int
}{id
}}
316 \func{void
}{Destroy
}{\param{wxMenuItem *
}{item
}}
318 Deletes the menu item from the menu. If the item is a submenu, it will
319 be deleted. Use
\helpref{Remove
}{wxmenuremove
} if you want to keep the submenu
320 (for example, to reuse it later).
322 \wxheading{Parameters
}
324 \docparam{id
}{Id of the menu item to be deleted.
}
326 \docparam{item
}{Menu item to be deleted.
}
330 \helpref{wxMenu::FindItem
}{wxmenufinditem
},
\rtfsp
331 \helpref{wxMenu::Deletes
}{wxmenudelete
},
\rtfsp
332 \helpref{wxMenu::Remove
}{wxmenuremove
}
335 \membersection{wxMenu::Enable
}\label{wxmenuenable
}
337 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
339 Enables or disables (greys out) a menu item.
341 \wxheading{Parameters
}
343 \docparam{id
}{The menu item identifier.
}
345 \docparam{enable
}{true to enable the menu item, false to disable it.
}
349 \helpref{wxMenu::IsEnabled
}{wxmenuisenabled
}
352 \membersection{wxMenu::FindItem
}\label{wxmenufinditem
}
354 \constfunc{int
}{FindItem
}{\param{const wxString\&
}{itemString
}}
356 Finds the menu item id for a menu item string.
358 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu **
}{menu = NULL
}}
360 Finds the menu item object associated with the given menu item identifier and,
361 optionally, the (sub)menu it belongs to.
363 \perlnote{In wxPerl this method takes just the
{\tt id
} parameter;
364 in scalar context it returns the associated
{\tt Wx::MenuItem
}, in list
365 context it returns a
2-element list
{\tt ( item, submenu )
}}
367 \wxheading{Parameters
}
369 \docparam{itemString
}{Menu item string to find.
}
371 \docparam{id
}{Menu item identifier.
}
373 \docparam{menu
}{If the pointer is not NULL, it will be filled with the item's
374 parent menu (if the item was found)
}
376 \wxheading{Return value
}
378 First form: menu item identifier, or
{\tt wxNOT
\_FOUND} if none is found.
380 Second form: returns the menu item object, or NULL if it is not found.
384 Any special menu codes are stripped out of source and target strings
387 \pythonnote{The name of this method in wxPython is
{\tt FindItemById
}
388 and it does not support the second parameter.
}
391 \membersection{wxMenu::FindItemByPosition
}\label{wxmenufinditembyposition
}
393 \constfunc{wxMenuItem*
}{FindItemByPosition
}{\param{size
\_t }{position
}}
395 Returns the wxMenuItem given a position in the menu.
398 \membersection{wxMenu::GetHelpString
}\label{wxmenugethelpstring
}
400 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
402 Returns the help string associated with a menu item.
404 \wxheading{Parameters
}
406 \docparam{id
}{The menu item identifier.
}
408 \wxheading{Return value
}
410 The help string, or the empty string if there is no help string or the
415 \helpref{wxMenu::SetHelpString
}{wxmenusethelpstring
},
\helpref{wxMenu::Append
}{wxmenuappend
}
418 \membersection{wxMenu::GetLabel
}\label{wxmenugetlabel
}
420 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
422 Returns a menu item label.
424 \wxheading{Parameters
}
426 \docparam{id
}{The menu item identifier.
}
428 \wxheading{Return value
}
430 The item label, or the empty string if the item was not found.
434 \helpref{wxMenu::SetLabel
}{wxmenusetlabel
}
437 \membersection{wxMenu::GetMenuItemCount
}\label{wxmenugetmenuitemcount
}
439 \constfunc{size
\_t}{GetMenuItemCount
}{\void}
441 Returns the number of items in the menu.
444 \membersection{wxMenu::GetMenuItems
}\label{wxmenugetmenuitems
}
446 \constfunc{wxMenuItemList\&
}{GetMenuItems
}{\void}
448 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
449 list class containing wxMenuItem pointers, see
\helpref{wxList
}{wxlist
}.
452 \membersection{wxMenu::GetTitle
}\label{wxmenugettitle
}
454 \constfunc{wxString
}{GetTitle
}{\void}
456 Returns the title of the menu.
460 This is relevant only to popup menus, use
461 \helpref{wxMenuBar::GetLabelTop
}{wxmenubargetlabeltop
} for the menus in the
466 \helpref{wxMenu::SetTitle
}{wxmenusettitle
}
469 \membersection{wxMenu::Insert
}\label{wxmenuinsert
}
471 \func{wxMenuItem*
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenuItem *
}{item
}}
473 \func{wxMenuItem*
}{Insert
}{\param{size
\_t }{pos
},
\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
} before the position
{\it pos
}. Inserting the item
478 at position
\helpref{GetMenuItemCount
}{wxmenugetmenuitemcount
} is the same
483 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
484 \helpref{wxMenu::Prepend
}{wxmenuprepend
}
487 \membersection{wxMenu::InsertCheckItem
}\label{wxmenuinsertcheckitem
}
489 \func{wxMenuItem*
}{InsertCheckItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
490 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
492 Inserts a checkable item at the given position.
496 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
497 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
500 \membersection{wxMenu::InsertRadioItem
}\label{wxmenuinsertradioitem
}
502 \func{wxMenuItem*
}{InsertRadioItem
}{\param{size
\_t }{pos
},
\param{int
}{ id
},
\rtfsp
503 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
505 Inserts a radio item at the given position.
509 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
510 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
513 \membersection{wxMenu::InsertSeparator
}\label{wxmenuinsertseparator
}
515 \func{wxMenuItem*
}{InsertSeparator
}{\param{size
\_t }{pos
}}
517 Inserts a separator at the given position.
521 \helpref{wxMenu::Insert
}{wxmenuinsert
},
\rtfsp
522 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
525 \membersection{wxMenu::IsChecked
}\label{wxmenuischecked
}
527 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
529 Determines whether a menu item is checked.
531 \wxheading{Parameters
}
533 \docparam{id
}{The menu item identifier.
}
535 \wxheading{Return value
}
537 true if the menu item is checked, false otherwise.
541 \helpref{wxMenu::Check
}{wxmenucheck
}
544 \membersection{wxMenu::IsEnabled
}\label{wxmenuisenabled
}
546 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
548 Determines whether a menu item is enabled.
550 \wxheading{Parameters
}
552 \docparam{id
}{The menu item identifier.
}
554 \wxheading{Return value
}
556 true if the menu item is enabled, false otherwise.
560 \helpref{wxMenu::Enable
}{wxmenuenable
}
563 \membersection{wxMenu::Prepend
}\label{wxmenuprepend
}
565 \func{wxMenuItem*
}{Prepend
}{\param{wxMenuItem *
}{item
}}
567 \func{wxMenuItem*
}{Prepend
}{\param{int
}{ id
},
\rtfsp
568 \param{const wxString\&
}{ item = ""
},
\param{const wxString\&
}{helpString = ""
},
\rtfsp
569 \param{wxItemKind
}{ kind = wxITEM
\_NORMAL}}
571 Inserts the given
{\it item
} at position $
0$, i.e. before all the other
576 \helpref{wxMenu::Append
}{wxmenuappend
},
\rtfsp
577 \helpref{wxMenu::Insert
}{wxmenuinsert
}
580 \membersection{wxMenu::PrependCheckItem
}\label{wxmenuprependcheckitem
}
582 \func{wxMenuItem*
}{PrependCheckItem
}{\param{int
}{ id
},
\rtfsp
583 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
585 Inserts a checkable item at position $
0$.
589 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
590 \helpref{wxMenu::AppendCheckItem
}{wxmenuappendcheckitem
}
593 \membersection{wxMenu::PrependRadioItem
}\label{wxmenuprependradioitem
}
595 \func{wxMenuItem*
}{PrependRadioItem
}{\param{int
}{ id
},
\rtfsp
596 \param{const wxString\&
}{ item
},
\param{const wxString\&
}{helpString = ""
}}
598 Inserts a radio item at position $
0$.
602 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
603 \helpref{wxMenu::AppendRadioItem
}{wxmenuappendradioitem
}
606 \membersection{wxMenu::PrependSeparator
}\label{wxmenuprependseparator
}
608 \func{wxMenuItem*
}{PrependSeparator
}{\void}
610 Inserts a separator at position $
0$.
614 \helpref{wxMenu::Prepend
}{wxmenuprepend
},
\rtfsp
615 \helpref{wxMenu::AppendSeparator
}{wxmenuappendseparator
}
618 \membersection{wxMenu::Remove
}\label{wxmenuremove
}
620 \func{wxMenuItem *
}{Remove
}{\param{int
}{id
}}
622 \func{wxMenuItem *
}{Remove
}{\param{wxMenuItem *
}{item
}}
624 Removes the menu item from the menu but doesn't delete the associated C++
625 object. This allows to reuse the same item later by adding it back to the menu
626 (especially useful with submenus).
628 \wxheading{Parameters
}
630 \docparam{id
}{The identifier of the menu item to remove.
}
632 \docparam{item
}{The menu item to remove.
}
634 \wxheading{Return value
}
636 The item which was detached from the menu.
639 \membersection{wxMenu::SetHelpString
}\label{wxmenusethelpstring
}
641 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
643 Sets an item's help string.
645 \wxheading{Parameters
}
647 \docparam{id
}{The menu item identifier.
}
649 \docparam{helpString
}{The help string to set.
}
653 \helpref{wxMenu::GetHelpString
}{wxmenugethelpstring
}
656 \membersection{wxMenu::SetLabel
}\label{wxmenusetlabel
}
658 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
660 Sets the label of a menu item.
662 \wxheading{Parameters
}
664 \docparam{id
}{The menu item identifier.
}
666 \docparam{label
}{The menu item label to set.
}
670 \helpref{wxMenu::Append
}{wxmenuappend
},
\helpref{wxMenu::GetLabel
}{wxmenugetlabel
}
673 \membersection{wxMenu::SetTitle
}\label{wxmenusettitle
}
675 \func{void
}{SetTitle
}{\param{const wxString\&
}{title
}}
677 Sets the title of the menu.
679 \wxheading{Parameters
}
681 \docparam{title
}{The title to set.
}
685 This is relevant only to popup menus, use
686 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
} for the menus in the
691 \helpref{wxMenu::GetTitle
}{wxmenugettitle
}
694 \membersection{wxMenu::UpdateUI
}\label{wxmenuupdateui
}
696 \constfunc{void
}{UpdateUI
}{\param{wxEvtHandler*
}{ source = NULL
}}
698 Sends events to
{\it source
} (or owning window if NULL) to update the
699 menu UI. This is called just before the menu is popped up with
\helpref{wxWindow::PopupMenu
}{wxwindowpopupmenu
}, but
700 the application may call it at other times if required.
704 \helpref{wxUpdateUIEvent
}{wxupdateuievent
}
706 \section{\class{wxMenuBar
}}\label{wxmenubar
}
708 A menu bar is a series of menus accessible from the top of a frame.
710 \wxheading{Derived from
}
712 \helpref{wxWindow
}{wxwindow
}\\
713 \helpref{wxEvtHandler
}{wxevthandler
}\\
714 \helpref{wxObject
}{wxobject
}
716 \wxheading{Include files
}
720 \wxheading{Event handling
}
722 To respond to a menu selection, provide a handler for EVT
\_MENU, in the frame
723 that contains the menu bar. If you have a toolbar which uses the same identifiers
724 as your EVT
\_MENU entries, events from the toolbar will also be processed by your
725 EVT
\_MENU event handlers.
727 {\bf Tip:
} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
728 are not working, check any EVT
\_CHAR events you are handling in child windows.
729 If you are not calling
{\tt event.Skip()
} for events that you don't process in these event handlers,
730 menu shortcuts may cease to work.
734 \helpref{wxMenu
}{wxmenu
},
\helpref{Event handling overview
}{eventhandlingoverview
}
736 \latexignore{\rtfignore{\wxheading{Members
}}}
739 \membersection{wxMenuBar::wxMenuBar
}\label{wxmenubarctor
}
741 \func{}{wxMenuBar
}{\param{long
}{style =
0}}
745 \func{}{wxMenuBar
}{\param{size
\_t}{ n
},
\param{wxMenu*
}{ menus
[]},
\param{const wxString
}{titles
[]},
\param{long
}{style =
0}}
747 Construct a menu bar from arrays of menus and titles.
749 \wxheading{Parameters
}
751 \docparam{n
}{The number of menus.
}
753 \docparam{menus
}{An array of menus. Do not use this array again - it now belongs to the
756 \docparam{titles
}{An array of title strings. Deallocate this array after creating the menu bar.
}
758 \docparam{style
}{If
{\tt wxMB
\_DOCKABLE} the menu bar can be detached (wxGTK only).
}
760 \pythonnote{Only the default constructor is supported in wxPython.
761 Use
\helpref{wxMenuBar::Append
}{wxmenubarappend
} instead.
}
763 \perlnote{wxPerl only supports the first constructor:
764 use
\helpref{wxMenuBar::Append
}{wxmenubarappend
} instead.
}
767 \membersection{wxMenuBar::
\destruct{wxMenuBar
}}\label{wxmenubardtor
}
769 \func{void
}{\destruct{wxMenuBar
}}{\void}
771 Destructor, destroying the menu bar and removing it from the parent frame (if any).
774 \membersection{wxMenuBar::Append
}\label{wxmenubarappend
}
776 \func{bool
}{Append
}{\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
778 Adds the item to the end of the menu bar.
780 \wxheading{Parameters
}
782 \docparam{menu
}{The menu to add. Do not deallocate this menu after calling
{\bf Append
}.
}
784 \docparam{title
}{The title of the menu.
}
786 \wxheading{Return value
}
788 true on success, false if an error occurred.
792 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
}
795 \membersection{wxMenuBar::Check
}\label{wxmenubarcheck
}
797 \func{void
}{Check
}{\param{int
}{ id
},
\param{const bool
}{ check
}}
799 Checks or unchecks a menu item.
801 \wxheading{Parameters
}
803 \docparam{id
}{The menu item identifier.
}
805 \docparam{check
}{If true, checks the menu item, otherwise the item is unchecked.
}
809 Only use this when the menu bar has been associated
810 with a frame; otherwise, use the wxMenu equivalent call.
813 \membersection{wxMenuBar::Enable
}\label{wxmenubarenable
}
815 \func{void
}{Enable
}{\param{int
}{ id
},
\param{const bool
}{ enable
}}
817 Enables or disables (greys out) a menu item.
819 \wxheading{Parameters
}
821 \docparam{id
}{The menu item identifier.
}
823 \docparam{enable
}{true to enable the item, false to disable it.
}
827 Only use this when the menu bar has been
828 associated with a frame; otherwise, use the wxMenu equivalent call.
831 \membersection{wxMenuBar::EnableTop
}\label{wxmenubarenabletop
}
833 \func{void
}{EnableTop
}{\param{int
}{ pos
},
\param{const bool
}{ enable
}}
835 Enables or disables a whole menu.
837 \wxheading{Parameters
}
839 \docparam{pos
}{The position of the menu, starting from zero.
}
841 \docparam{enable
}{true to enable the menu, false to disable it.
}
845 Only use this when the menu bar has been
846 associated with a frame.
849 \membersection{wxMenuBar::FindMenu
}\label{wxmenubarfindmenu
}
851 \constfunc{int
}{FindMenu
}{\param{const wxString\&
}{title
}}
853 Returns the index of the menu with the given
{\it title
} or
{\tt wxNOT
\_FOUND} if no
854 such menu exists in this menubar. The
{\it title
} parameter may specify either
855 the menu title (with accelerator characters, i.e.
{\tt "\&File"
}) or just the
856 menu label (
{\tt "File"
}) indifferently.
859 \membersection{wxMenuBar::FindMenuItem
}\label{wxmenubarfindmenuitem
}
861 \constfunc{int
}{FindMenuItem
}{\param{const wxString\&
}{menuString
},
\param{const wxString\&
}{itemString
}}
863 Finds the menu item id for a menu name/menu item string pair.
865 \wxheading{Parameters
}
867 \docparam{menuString
}{Menu title to find.
}
869 \docparam{itemString
}{Item to find.
}
871 \wxheading{Return value
}
873 The menu item identifier, or
{\tt wxNOT
\_FOUND} if none was found.
877 Any special menu codes are stripped out of source and target strings
881 \membersection{wxMenuBar::FindItem
}\label{wxmenubarfinditem
}
883 \constfunc{wxMenuItem *
}{FindItem
}{\param{int
}{ id
},
\param{wxMenu
}{ **menu = NULL
}}
885 Finds the menu item object associated with the given menu item identifier.
887 \wxheading{Parameters
}
889 \docparam{id
}{Menu item identifier.
}
891 \docparam{menu
}{If not NULL, menu will get set to the associated menu.
}
893 \wxheading{Return value
}
895 The found menu item object, or NULL if one was not found.
898 \membersection{wxMenuBar::GetHelpString
}\label{wxmenubargethelpstring
}
900 \constfunc{wxString
}{GetHelpString
}{\param{int
}{ id
}}
902 Gets the help string associated with the menu item identifier.
904 \wxheading{Parameters
}
906 \docparam{id
}{The menu item identifier.
}
908 \wxheading{Return value
}
910 The help string, or the empty string if there was no help string or the menu item
915 \helpref{wxMenuBar::SetHelpString
}{wxmenubarsethelpstring
}
918 \membersection{wxMenuBar::GetLabel
}\label{wxmenubargetlabel
}
920 \constfunc{wxString
}{GetLabel
}{\param{int
}{ id
}}
922 Gets the label associated with a menu item.
924 \wxheading{Parameters
}
926 \docparam{id
}{The menu item identifier.
}
928 \wxheading{Return value
}
930 The menu item label, or the empty string if the item was not found.
934 Use only after the menubar has been associated with a frame.
937 \membersection{wxMenuBar::GetLabelTop
}\label{wxmenubargetlabeltop
}
939 \constfunc{wxString
}{GetLabelTop
}{\param{int
}{ pos
}}
941 Returns the label of a top-level menu. Note that the returned string does not
942 include the accelerator characters which could have been specified in the menu
943 title string during its construction.
945 \wxheading{Parameters
}
947 \docparam{pos
}{Position of the menu on the menu bar, starting from zero.
}
949 \wxheading{Return value
}
951 The menu label, or the empty string if the menu was not found.
955 Use only after the menubar has been associated with a frame.
959 \helpref{wxMenuBar::SetLabelTop
}{wxmenubarsetlabeltop
}
962 \membersection{wxMenuBar::GetMenu
}\label{wxmenubargetmenu
}
964 \constfunc{wxMenu*
}{GetMenu
}{\param{int
}{ menuIndex
}}
966 Returns the menu at
{\it menuIndex
} (zero-based).
969 \membersection{wxMenuBar::GetMenuCount
}\label{wxmenubargetmenucount
}
971 \constfunc{size
\_t}{GetMenuCount
}{\void}
973 Returns the number of menus in this menubar.
976 \membersection{wxMenuBar::Insert
}\label{wxmenubarinsert
}
978 \func{bool
}{Insert
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
980 Inserts the menu at the given position into the menu bar. Inserting menu at
981 position $
0$ will insert it in the very beginning of it, inserting at position
982 \helpref{GetMenuCount()
}{wxmenubargetmenucount
} is the same as calling
983 \helpref{Append()
}{wxmenubarappend
}.
985 \wxheading{Parameters
}
987 \docparam{pos
}{The position of the new menu in the menu bar
}
989 \docparam{menu
}{The menu to add. wxMenuBar owns the menu and will free it.
}
991 \docparam{title
}{The title of the menu.
}
993 \wxheading{Return value
}
995 true on success, false if an error occurred.
999 \helpref{wxMenuBar::Append
}{wxmenubarappend
}
1002 \membersection{wxMenuBar::IsChecked
}\label{wxmenubarischecked
}
1004 \constfunc{bool
}{IsChecked
}{\param{int
}{ id
}}
1006 Determines whether an item is checked.
1008 \wxheading{Parameters
}
1010 \docparam{id
}{The menu item identifier.
}
1012 \wxheading{Return value
}
1014 true if the item was found and is checked, false otherwise.
1017 \membersection{wxMenuBar::IsEnabled
}\label{wxmenubarisenabled
}
1019 \constfunc{bool
}{IsEnabled
}{\param{int
}{ id
}}
1021 Determines whether an item is enabled.
1023 \wxheading{Parameters
}
1025 \docparam{id
}{The menu item identifier.
}
1027 \wxheading{Return value
}
1029 true if the item was found and is enabled, false otherwise.
1032 \membersection{wxMenuBar::Refresh
}\label{wxmenubarrefresh
}
1034 \func{void
}{Refresh
}{\void}
1039 \membersection{wxMenuBar::Remove
}\label{wxmenubarremove
}
1041 \func{wxMenu *
}{Remove
}{\param{size
\_t }{pos
}}
1043 Removes the menu from the menu bar and returns the menu object - the caller is
1044 responsible for deleting it. This function may be used together with
1045 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
} to change the menubar
1048 \wxheading{See also
}
1050 \helpref{wxMenuBar::Replace
}{wxmenubarreplace
}
1053 \membersection{wxMenuBar::Replace
}\label{wxmenubarreplace
}
1055 \func{wxMenu *
}{Replace
}{\param{size
\_t }{pos
},
\param{wxMenu *
}{menu
},
\param{const wxString\&
}{title
}}
1057 Replaces the menu at the given position with another one.
1059 \wxheading{Parameters
}
1061 \docparam{pos
}{The position of the new menu in the menu bar
}
1063 \docparam{menu
}{The menu to add.
}
1065 \docparam{title
}{The title of the menu.
}
1067 \wxheading{Return value
}
1069 The menu which was previously at position
{\it pos
}. The caller is
1070 responsible for deleting it.
1072 \wxheading{See also
}
1074 \helpref{wxMenuBar::Insert
}{wxmenubarinsert
},
\rtfsp
1075 \helpref{wxMenuBar::Remove
}{wxmenubarremove
}
1078 \membersection{wxMenuBar::SetHelpString
}\label{wxmenubarsethelpstring
}
1080 \func{void
}{SetHelpString
}{\param{int
}{ id
},
\param{const wxString\&
}{helpString
}}
1082 Sets the help string associated with a menu item.
1084 \wxheading{Parameters
}
1086 \docparam{id
}{Menu item identifier.
}
1088 \docparam{helpString
}{Help string to associate with the menu item.
}
1090 \wxheading{See also
}
1092 \helpref{wxMenuBar::GetHelpString
}{wxmenubargethelpstring
}
1095 \membersection{wxMenuBar::SetLabel
}\label{wxmenubarsetlabel
}
1097 \func{void
}{SetLabel
}{\param{int
}{ id
},
\param{const wxString\&
}{label
}}
1099 Sets the label of a menu item.
1101 \wxheading{Parameters
}
1103 \docparam{id
}{Menu item identifier.
}
1105 \docparam{label
}{Menu item label.
}
1109 Use only after the menubar has been associated with a frame.
1111 \wxheading{See also
}
1113 \helpref{wxMenuBar::GetLabel
}{wxmenubargetlabel
}
1116 \membersection{wxMenuBar::SetLabelTop
}\label{wxmenubarsetlabeltop
}
1118 \func{void
}{SetLabelTop
}{\param{int
}{ pos
},
\param{const wxString\&
}{label
}}
1120 Sets the label of a top-level menu.
1122 \wxheading{Parameters
}
1124 \docparam{pos
}{The position of a menu on the menu bar, starting from zero.
}
1126 \docparam{label
}{The menu label.
}
1130 Use only after the menubar has been associated with a frame.
1132 \wxheading{See also
}
1134 \helpref{wxMenuBar::GetLabelTop
}{wxmenubargetlabeltop
}