]>
Commit | Line | Data |
---|---|---|
66760199 WS |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: menu.tex | |
3 | %% Purpose: wxMenu documentation | |
4 | %% Author: wxWidgets Team | |
5 | %% Modified by: | |
6 | %% Created: | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) wxWidgets Team | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
a660d684 KB |
12 | \section{\class{wxMenu}}\label{wxmenu} |
13 | ||
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 | |
0472ece7 | 16 | menu). Menus may be used to construct either menu bars or popup menus. |
a660d684 KB |
17 | |
18 | A menu item has an integer ID associated with it which can be used to | |
0472ece7 VZ |
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. | |
22 | ||
bb772a8e | 23 | {\bf NB:} Please note that {\it wxID\_ABOUT} and {\it wxID\_EXIT} are |
c436b310 RR |
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 | |
66760199 WS |
27 | MacOS X interface guideline). On PalmOS {\it wxID\_EXIT} is disabled according |
28 | to Palm OS Companion guidelines. | |
c436b310 | 29 | |
0472ece7 VZ |
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. | |
fc2171bd | 33 | wxWidgets automatically toggles the flag value when the item is clicked and its |
0472ece7 VZ |
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. | |
38 | ||
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 | |
25057aba JS |
45 | the radio items risks to not work correctly. Finally note that radio items |
46 | are not supported under Motif. | |
a660d684 | 47 | |
2b5f62a0 VZ |
48 | \wxheading{Allocation strategy} |
49 | ||
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. | |
54 | ||
a660d684 KB |
55 | \wxheading{Derived from} |
56 | ||
57 | \helpref{wxEvtHandler}{wxevthandler}\\ | |
58 | \helpref{wxObject}{wxobject} | |
59 | ||
954b8ae6 JS |
60 | \wxheading{Include files} |
61 | ||
62 | <wx/menu.h> | |
63 | ||
a660d684 KB |
64 | \wxheading{Event handling} |
65 | ||
66 | If the menu is part of a menubar, then \helpref{wxMenuBar}{wxmenubar} event processing is used. | |
67 | ||
68 | With a popup menu, there is a variety of ways to handle a menu selection event | |
69 | (wxEVT\_COMMAND\_MENU\_SELECTED). | |
70 | ||
71 | \begin{enumerate}\itemsep=0pt | |
a660d684 KB |
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 | |
75 | this window. | |
1aaef614 | 76 | \item Define a callback of type wxFunction, which you pass to the wxMenu constructor. |
874a1686 | 77 | The callback takes a reference to the menu, and a reference to a |
1aaef614 VZ |
78 | \helpref{wxCommandEvent}{wxcommandevent}. This method is deprecated and should |
79 | not be used in the new code, it is provided for backwards compatibility only. | |
a660d684 KB |
80 | \end{enumerate} |
81 | ||
82 | \wxheading{See also} | |
83 | ||
84 | \helpref{wxMenuBar}{wxmenubar}, \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu},\rtfsp | |
484bdc6a VZ |
85 | \helpref{Event handling overview}{eventhandlingoverview},\rtfsp |
86 | \helpref{wxFileHistory (most recently used files menu)}{wxfilehistory} | |
87 | ||
88 | ||
a660d684 KB |
89 | |
90 | \latexignore{\rtfignore{\wxheading{Members}}} | |
91 | ||
3786c8b5 | 92 | |
dcbd177f | 93 | \membersection{wxMenu::wxMenu}\label{wxmenuctor} |
a660d684 | 94 | |
b1462dfa | 95 | \func{}{wxMenu}{\param{const wxString\& }{title = ""}, \param{long}{ style = 0}} |
a660d684 KB |
96 | |
97 | Constructs a wxMenu object. | |
98 | ||
99 | \wxheading{Parameters} | |
100 | ||
101 | \docparam{title}{A title for the popup menu: the empty string denotes no title.} | |
102 | ||
809f39fe | 103 | \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).} |
06d20283 | 104 | |
407f3681 | 105 | \func{}{wxMenu}{\param{long}{ style}} |
4e986502 KB |
106 | |
107 | Constructs a wxMenu object. | |
108 | ||
109 | \wxheading{Parameters} | |
407f3681 | 110 | |
809f39fe | 111 | \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).} |
4e986502 | 112 | |
3786c8b5 | 113 | |
dcbd177f | 114 | \membersection{wxMenu::\destruct{wxMenu}}\label{wxmenudtor} |
a660d684 KB |
115 | |
116 | \func{}{\destruct{wxMenu}}{\void} | |
117 | ||
118 | Destructor, destroying the menu. | |
119 | ||
b412f9be JS |
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. | |
126 | ||
3786c8b5 | 127 | |
a660d684 KB |
128 | \membersection{wxMenu::Append}\label{wxmenuappend} |
129 | ||
9add9367 | 130 | \func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp |
98322660 | 131 | \param{wxItemKind}{ kind = wxITEM\_NORMAL}} |
a660d684 KB |
132 | |
133 | Adds a string item to the end of the menu. | |
134 | ||
9add9367 | 135 | \func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp |
a660d684 KB |
136 | \param{const wxString\& }{helpString = ""}} |
137 | ||
2b5f62a0 VZ |
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 | |
140 | registered properly. | |
a660d684 | 141 | |
9add9367 | 142 | \func{wxMenuItem*}{Append}{\param{wxMenuItem*}{ menuItem}} |
a660d684 | 143 | |
1aaef614 VZ |
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, | |
a660d684 KB |
147 | such as bitmaps and fonts. |
148 | ||
149 | \wxheading{Parameters} | |
150 | ||
151 | \docparam{id}{The menu command identifier.} | |
152 | ||
153 | \docparam{item}{The string to appear on the menu item.} | |
154 | ||
155 | \docparam{menu}{Pull-right submenu.} | |
156 | ||
98322660 JS |
157 | \docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL}, |
158 | {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}} | |
a660d684 KB |
159 | |
160 | \docparam{helpString}{An optional help string associated with the item. | |
684761db | 161 | By default, the handler for the wxEVT\_MENU\_HIGHLIGHT event displays |
a660d684 KB |
162 | this string in the status line.} |
163 | ||
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.} | |
166 | ||
167 | \wxheading{Remarks} | |
168 | ||
169 | This command can be used after the menu has been shown, as well as on initial | |
170 | creation of a menu or menubar. | |
171 | ||
69440cd2 VZ |
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): | |
d2c2afc9 | 181 | |
69440cd2 VZ |
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} | |
41b78190 | 196 | \twocolitem{{\tt ESC} or {\tt ESCAPE}}{Escape key (Windows only)} |
69440cd2 VZ |
197 | \end{twocollist} |
198 | ||
a660d684 KB |
199 | \wxheading{See also} |
200 | ||
1aaef614 | 201 | \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator},\rtfsp |
d65c269b VZ |
202 | \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem},\rtfsp |
203 | \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem},\rtfsp | |
3786c8b5 | 204 | \helpref{wxMenu::AppendSubMenu}{wxmenuappendsubmenu},\rtfsp |
1aaef614 VZ |
205 | \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp |
206 | \helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp | |
a660d684 KB |
207 | \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem} |
208 | ||
06d20283 | 209 | \pythonnote{In place of a single overloaded method name, wxPython |
d2c2afc9 JS |
210 | implements the following methods: |
211 | ||
06d20283 | 212 | \indented{2cm}{\begin{twocollist} |
cc81d32f | 213 | \twocolitem{{\bf Append(id, string, helpStr="", checkable=false)}}{} |
c9110876 VS |
214 | \twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")}}{} |
215 | \twocolitem{{\bf AppendItem(aMenuItem)}}{} | |
06d20283 RD |
216 | \end{twocollist}} |
217 | } | |
218 | ||
3786c8b5 | 219 | |
d65c269b VZ |
220 | \membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem} |
221 | ||
9add9367 | 222 | \func{wxMenuItem*}{AppendCheckItem}{\param{int}{ id},\rtfsp |
d65c269b VZ |
223 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}} |
224 | ||
225 | Adds a checkable item to the end of the menu. | |
226 | ||
227 | \wxheading{See also} | |
228 | ||
229 | \helpref{wxMenu::Append}{wxmenuappend},\rtfsp | |
230 | \helpref{wxMenu::InsertCheckItem}{wxmenuinsertcheckitem} | |
231 | ||
3786c8b5 | 232 | |
d65c269b VZ |
233 | \membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem} |
234 | ||
9add9367 | 235 | \func{wxMenuItem*}{AppendRadioItem}{\param{int}{ id},\rtfsp |
d65c269b VZ |
236 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}} |
237 | ||
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. | |
241 | ||
242 | {\bf NB:} Currently only implemented under Windows and GTK, use | |
7af3ca16 | 243 | {\tt\#if wxHAS\_RADIO\_MENU\_ITEMS} to test for availability of this feature. |
d65c269b VZ |
244 | |
245 | \wxheading{See also} | |
246 | ||
247 | \helpref{wxMenu::Append}{wxmenuappend},\rtfsp | |
248 | \helpref{wxMenu::InsertRadioItem}{wxmenuinsertradioitem} | |
249 | ||
3786c8b5 | 250 | |
a660d684 KB |
251 | \membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator} |
252 | ||
9add9367 | 253 | \func{wxMenuItem*}{AppendSeparator}{\void} |
a660d684 KB |
254 | |
255 | Adds a separator to the end of the menu. | |
256 | ||
257 | \wxheading{See also} | |
258 | ||
d65c269b VZ |
259 | \helpref{wxMenu::Append}{wxmenuappend},\rtfsp |
260 | \helpref{wxMenu::InsertSeparator}{wxmenuinsertseparator} | |
a660d684 | 261 | |
3786c8b5 VZ |
262 | |
263 | \membersection{wxMenu::AppendSubMenu}\label{wxmenuappendsubmenu} | |
264 | ||
265 | \func{wxMenuItem *}{AppendSubMenu}{\param{wxMenu *}{submenu}, \param{const wxString\& }{text}, \param{const wxString\& }{help = wxEmptyString}} | |
266 | ||
267 | Adds the given \arg{submenu} to this menu. \arg{text} is the text shown in the | |
268 | menu for it and \arg{help} is the help string shown in the status bar when the | |
269 | submenu item is selected. | |
270 | ||
271 | ||
a660d684 KB |
272 | \membersection{wxMenu::Break}\label{wxmenubreak} |
273 | ||
274 | \func{void}{Break}{\void} | |
275 | ||
276 | Inserts a break in a menu, causing the next appended item to appear in a new column. | |
277 | ||
3786c8b5 | 278 | |
a660d684 KB |
279 | \membersection{wxMenu::Check}\label{wxmenucheck} |
280 | ||
eaaa6a06 | 281 | \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}} |
a660d684 KB |
282 | |
283 | Checks or unchecks the menu item. | |
284 | ||
285 | \wxheading{Parameters} | |
286 | ||
287 | \docparam{id}{The menu item identifier.} | |
288 | ||
cc81d32f | 289 | \docparam{check}{If true, the item will be checked, otherwise it will be unchecked.} |
a660d684 KB |
290 | |
291 | \wxheading{See also} | |
292 | ||
293 | \helpref{wxMenu::IsChecked}{wxmenuischecked} | |
294 | ||
3786c8b5 | 295 | |
fc9c7c09 RR |
296 | \membersection{wxMenu::Delete}\label{wxmenudelete} |
297 | ||
298 | \func{void}{Delete}{\param{int }{id}} | |
299 | ||
1aaef614 VZ |
300 | \func{void}{Delete}{\param{wxMenuItem *}{item}} |
301 | ||
874a1686 | 302 | Deletes the menu item from the menu. If the item is a submenu, it will |
1aaef614 VZ |
303 | {\bf not} be deleted. Use \helpref{Destroy}{wxmenudestroy} if you want to |
304 | delete a submenu. | |
fc9c7c09 RR |
305 | |
306 | \wxheading{Parameters} | |
307 | ||
1aaef614 | 308 | \docparam{id}{Id of the menu item to be deleted.} |
fc9c7c09 | 309 | |
1aaef614 VZ |
310 | \docparam{item}{Menu item to be deleted.} |
311 | ||
312 | \wxheading{See also} | |
313 | ||
314 | \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp | |
315 | \helpref{wxMenu::Destroy}{wxmenudestroy},\rtfsp | |
316 | \helpref{wxMenu::Remove}{wxmenuremove} | |
317 | ||
3786c8b5 | 318 | |
1aaef614 VZ |
319 | \membersection{wxMenu::Destroy}\label{wxmenudestroy} |
320 | ||
321 | \func{void}{Destroy}{\param{int }{id}} | |
322 | ||
323 | \func{void}{Destroy}{\param{wxMenuItem *}{item}} | |
324 | ||
874a1686 | 325 | Deletes the menu item from the menu. If the item is a submenu, it will |
1aaef614 VZ |
326 | be deleted. Use \helpref{Remove}{wxmenuremove} if you want to keep the submenu |
327 | (for example, to reuse it later). | |
fc9c7c09 | 328 | |
1aaef614 VZ |
329 | \wxheading{Parameters} |
330 | ||
331 | \docparam{id}{Id of the menu item to be deleted.} | |
332 | ||
333 | \docparam{item}{Menu item to be deleted.} | |
fc9c7c09 RR |
334 | |
335 | \wxheading{See also} | |
336 | ||
1aaef614 VZ |
337 | \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp |
338 | \helpref{wxMenu::Deletes}{wxmenudelete},\rtfsp | |
339 | \helpref{wxMenu::Remove}{wxmenuremove} | |
fc9c7c09 | 340 | |
3786c8b5 | 341 | |
a660d684 KB |
342 | \membersection{wxMenu::Enable}\label{wxmenuenable} |
343 | ||
eaaa6a06 | 344 | \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}} |
a660d684 KB |
345 | |
346 | Enables or disables (greys out) a menu item. | |
347 | ||
348 | \wxheading{Parameters} | |
349 | ||
350 | \docparam{id}{The menu item identifier.} | |
351 | ||
cc81d32f | 352 | \docparam{enable}{true to enable the menu item, false to disable it.} |
a660d684 KB |
353 | |
354 | \wxheading{See also} | |
355 | ||
356 | \helpref{wxMenu::IsEnabled}{wxmenuisenabled} | |
357 | ||
3786c8b5 | 358 | |
a660d684 KB |
359 | \membersection{wxMenu::FindItem}\label{wxmenufinditem} |
360 | ||
361 | \constfunc{int}{FindItem}{\param{const wxString\& }{itemString}} | |
362 | ||
363 | Finds the menu item id for a menu item string. | |
364 | ||
1aaef614 | 365 | \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu **}{menu = NULL}} |
407f3681 | 366 | |
1aaef614 VZ |
367 | Finds the menu item object associated with the given menu item identifier and, |
368 | optionally, the (sub)menu it belongs to. | |
a660d684 | 369 | |
5873607e VZ |
370 | \perlnote{In wxPerl this method takes just the {\tt id} parameter; |
371 | in scalar context it returns the associated {\tt Wx::MenuItem}, in list | |
9722642d | 372 | context it returns a 2-element list {\tt ( item, submenu )}} |
5873607e | 373 | |
a660d684 KB |
374 | \wxheading{Parameters} |
375 | ||
e12be2f7 JS |
376 | \docparam{itemString}{Menu item string to find.} |
377 | ||
a660d684 KB |
378 | \docparam{id}{Menu item identifier.} |
379 | ||
3980000c | 380 | \docparam{menu}{If the pointer is not NULL, it will be filled with the item's |
1aaef614 VZ |
381 | parent menu (if the item was found)} |
382 | ||
a660d684 KB |
383 | \wxheading{Return value} |
384 | ||
a8d08dbd | 385 | First form: menu item identifier, or {\tt wxNOT\_FOUND} if none is found. |
a660d684 | 386 | |
e12be2f7 | 387 | Second form: returns the menu item object, or NULL if it is not found. |
a660d684 | 388 | |
e12be2f7 JS |
389 | \wxheading{Remarks} |
390 | ||
391 | Any special menu codes are stripped out of source and target strings | |
392 | before matching. | |
a660d684 | 393 | |
fa482912 | 394 | \pythonnote{The name of this method in wxPython is {\tt FindItemById} |
874a1686 RD |
395 | and it does not support the second parameter.} |
396 | ||
3786c8b5 | 397 | |
bd582574 JS |
398 | \membersection{wxMenu::FindItemByPosition}\label{wxmenufinditembyposition} |
399 | ||
62313dec | 400 | \constfunc{wxMenuItem*}{FindItemByPosition}{\param{size\_t }{position}} |
bd582574 JS |
401 | |
402 | Returns the wxMenuItem given a position in the menu. | |
403 | ||
3786c8b5 | 404 | |
a660d684 KB |
405 | \membersection{wxMenu::GetHelpString}\label{wxmenugethelpstring} |
406 | ||
eaaa6a06 | 407 | \constfunc{wxString}{GetHelpString}{\param{int}{ id}} |
a660d684 KB |
408 | |
409 | Returns the help string associated with a menu item. | |
410 | ||
411 | \wxheading{Parameters} | |
412 | ||
413 | \docparam{id}{The menu item identifier.} | |
414 | ||
415 | \wxheading{Return value} | |
416 | ||
417 | The help string, or the empty string if there is no help string or the | |
418 | item was not found. | |
419 | ||
420 | \wxheading{See also} | |
421 | ||
422 | \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenu::Append}{wxmenuappend} | |
423 | ||
3786c8b5 | 424 | |
a660d684 KB |
425 | \membersection{wxMenu::GetLabel}\label{wxmenugetlabel} |
426 | ||
eaaa6a06 | 427 | \constfunc{wxString}{GetLabel}{\param{int}{ id}} |
a660d684 KB |
428 | |
429 | Returns a menu item label. | |
430 | ||
431 | \wxheading{Parameters} | |
432 | ||
433 | \docparam{id}{The menu item identifier.} | |
434 | ||
435 | \wxheading{Return value} | |
436 | ||
437 | The item label, or the empty string if the item was not found. | |
438 | ||
439 | \wxheading{See also} | |
440 | ||
441 | \helpref{wxMenu::SetLabel}{wxmenusetlabel} | |
442 | ||
3786c8b5 | 443 | |
1aaef614 VZ |
444 | \membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount} |
445 | ||
446 | \constfunc{size\_t}{GetMenuItemCount}{\void} | |
447 | ||
448 | Returns the number of items in the menu. | |
449 | ||
3786c8b5 | 450 | |
1aaef614 VZ |
451 | \membersection{wxMenu::GetMenuItems}\label{wxmenugetmenuitems} |
452 | ||
453 | \constfunc{wxMenuItemList\&}{GetMenuItems}{\void} | |
454 | ||
455 | Returns the list of items in the menu. wxMenuItemList is a pseudo-template | |
456 | list class containing wxMenuItem pointers. | |
457 | ||
3786c8b5 | 458 | |
a660d684 KB |
459 | \membersection{wxMenu::GetTitle}\label{wxmenugettitle} |
460 | ||
461 | \constfunc{wxString}{GetTitle}{\void} | |
462 | ||
463 | Returns the title of the menu. | |
464 | ||
465 | \wxheading{Remarks} | |
466 | ||
706f30f8 VZ |
467 | This is relevant only to popup menus, use |
468 | \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop} for the menus in the | |
469 | menubar. | |
a660d684 KB |
470 | |
471 | \wxheading{See also} | |
472 | ||
473 | \helpref{wxMenu::SetTitle}{wxmenusettitle} | |
474 | ||
3786c8b5 | 475 | |
1aaef614 VZ |
476 | \membersection{wxMenu::Insert}\label{wxmenuinsert} |
477 | ||
9add9367 | 478 | \func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}} |
1aaef614 | 479 | |
9add9367 | 480 | \func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp |
d65c269b | 481 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp |
98322660 | 482 | \param{wxItemKind}{ kind = wxITEM\_NORMAL}} |
d65c269b | 483 | |
1aaef614 | 484 | Inserts the given {\it item} before the position {\it pos}. Inserting the item |
3980000c | 485 | at position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same |
1aaef614 VZ |
486 | as appending it. |
487 | ||
488 | \wxheading{See also} | |
489 | ||
d65c269b VZ |
490 | \helpref{wxMenu::Append}{wxmenuappend},\rtfsp |
491 | \helpref{wxMenu::Prepend}{wxmenuprepend} | |
492 | ||
3786c8b5 | 493 | |
d65c269b VZ |
494 | \membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem} |
495 | ||
9add9367 | 496 | \func{wxMenuItem*}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp |
d65c269b VZ |
497 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}} |
498 | ||
499 | Inserts a checkable item at the given position. | |
500 | ||
501 | \wxheading{See also} | |
502 | ||
503 | \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp | |
504 | \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem} | |
505 | ||
3786c8b5 | 506 | |
d65c269b VZ |
507 | \membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem} |
508 | ||
9add9367 | 509 | \func{wxMenuItem*}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp |
d65c269b VZ |
510 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}} |
511 | ||
512 | Inserts a radio item at the given position. | |
513 | ||
514 | \wxheading{See also} | |
515 | ||
516 | \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp | |
517 | \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem} | |
518 | ||
3786c8b5 | 519 | |
d65c269b VZ |
520 | \membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator} |
521 | ||
9add9367 | 522 | \func{wxMenuItem*}{InsertSeparator}{\param{size\_t }{pos}} |
d65c269b VZ |
523 | |
524 | Inserts a separator at the given position. | |
525 | ||
526 | \wxheading{See also} | |
527 | ||
528 | \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp | |
529 | \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator} | |
1aaef614 | 530 | |
3786c8b5 | 531 | |
a660d684 KB |
532 | \membersection{wxMenu::IsChecked}\label{wxmenuischecked} |
533 | ||
eaaa6a06 | 534 | \constfunc{bool}{IsChecked}{\param{int}{ id}} |
a660d684 KB |
535 | |
536 | Determines whether a menu item is checked. | |
537 | ||
538 | \wxheading{Parameters} | |
539 | ||
540 | \docparam{id}{The menu item identifier.} | |
541 | ||
542 | \wxheading{Return value} | |
543 | ||
cc81d32f | 544 | true if the menu item is checked, false otherwise. |
a660d684 KB |
545 | |
546 | \wxheading{See also} | |
547 | ||
548 | \helpref{wxMenu::Check}{wxmenucheck} | |
549 | ||
3786c8b5 | 550 | |
a660d684 KB |
551 | \membersection{wxMenu::IsEnabled}\label{wxmenuisenabled} |
552 | ||
eaaa6a06 | 553 | \constfunc{bool}{IsEnabled}{\param{int}{ id}} |
a660d684 KB |
554 | |
555 | Determines whether a menu item is enabled. | |
556 | ||
557 | \wxheading{Parameters} | |
558 | ||
559 | \docparam{id}{The menu item identifier.} | |
560 | ||
561 | \wxheading{Return value} | |
562 | ||
cc81d32f | 563 | true if the menu item is enabled, false otherwise. |
a660d684 KB |
564 | |
565 | \wxheading{See also} | |
566 | ||
567 | \helpref{wxMenu::Enable}{wxmenuenable} | |
568 | ||
3786c8b5 | 569 | |
d65c269b VZ |
570 | \membersection{wxMenu::Prepend}\label{wxmenuprepend} |
571 | ||
9add9367 | 572 | \func{wxMenuItem*}{Prepend}{\param{wxMenuItem *}{item}} |
d65c269b | 573 | |
9add9367 | 574 | \func{wxMenuItem*}{Prepend}{\param{int}{ id},\rtfsp |
d65c269b | 575 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp |
98322660 | 576 | \param{wxItemKind}{ kind = wxITEM\_NORMAL}} |
d65c269b | 577 | |
3980000c | 578 | Inserts the given {\it item} at position $0$, i.e. before all the other |
0cde01ae | 579 | existing items. |
d65c269b VZ |
580 | |
581 | \wxheading{See also} | |
582 | ||
583 | \helpref{wxMenu::Append}{wxmenuappend},\rtfsp | |
3980000c | 584 | \helpref{wxMenu::Insert}{wxmenuinsert} |
d65c269b | 585 | |
3786c8b5 | 586 | |
d65c269b VZ |
587 | \membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem} |
588 | ||
9add9367 | 589 | \func{wxMenuItem*}{PrependCheckItem}{\param{int}{ id},\rtfsp |
d65c269b VZ |
590 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}} |
591 | ||
3980000c | 592 | Inserts a checkable item at position $0$. |
d65c269b VZ |
593 | |
594 | \wxheading{See also} | |
595 | ||
596 | \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp | |
597 | \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem} | |
598 | ||
3786c8b5 | 599 | |
d65c269b VZ |
600 | \membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem} |
601 | ||
9add9367 | 602 | \func{wxMenuItem*}{PrependRadioItem}{\param{int}{ id},\rtfsp |
d65c269b VZ |
603 | \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}} |
604 | ||
3980000c | 605 | Inserts a radio item at position $0$. |
d65c269b VZ |
606 | |
607 | \wxheading{See also} | |
608 | ||
609 | \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp | |
610 | \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem} | |
611 | ||
3786c8b5 | 612 | |
d65c269b VZ |
613 | \membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator} |
614 | ||
f6e9a818 | 615 | \func{wxMenuItem*}{PrependSeparator}{\void} |
d65c269b | 616 | |
3980000c | 617 | Inserts a separator at position $0$. |
d65c269b VZ |
618 | |
619 | \wxheading{See also} | |
620 | ||
621 | \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp | |
622 | \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator} | |
623 | ||
3786c8b5 | 624 | |
1aaef614 VZ |
625 | \membersection{wxMenu::Remove}\label{wxmenuremove} |
626 | ||
627 | \func{wxMenuItem *}{Remove}{\param{int }{id}} | |
628 | ||
629 | \func{wxMenuItem *}{Remove}{\param{wxMenuItem *}{item}} | |
630 | ||
631 | Removes the menu item from the menu but doesn't delete the associated C++ | |
632 | object. This allows to reuse the same item later by adding it back to the menu | |
633 | (especially useful with submenus). | |
634 | ||
635 | \wxheading{Parameters} | |
636 | ||
637 | \docparam{id}{The identifier of the menu item to remove.} | |
638 | ||
639 | \docparam{item}{The menu item to remove.} | |
640 | ||
641 | \wxheading{Return value} | |
642 | ||
643 | The item which was detached from the menu. | |
644 | ||
3786c8b5 | 645 | |
a660d684 KB |
646 | \membersection{wxMenu::SetHelpString}\label{wxmenusethelpstring} |
647 | ||
eaaa6a06 | 648 | \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}} |
a660d684 KB |
649 | |
650 | Sets an item's help string. | |
651 | ||
652 | \wxheading{Parameters} | |
653 | ||
654 | \docparam{id}{The menu item identifier.} | |
655 | ||
656 | \docparam{helpString}{The help string to set.} | |
657 | ||
658 | \wxheading{See also} | |
659 | ||
660 | \helpref{wxMenu::GetHelpString}{wxmenugethelpstring} | |
661 | ||
3786c8b5 | 662 | |
a660d684 KB |
663 | \membersection{wxMenu::SetLabel}\label{wxmenusetlabel} |
664 | ||
eaaa6a06 | 665 | \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}} |
a660d684 KB |
666 | |
667 | Sets the label of a menu item. | |
668 | ||
669 | \wxheading{Parameters} | |
670 | ||
671 | \docparam{id}{The menu item identifier.} | |
672 | ||
673 | \docparam{label}{The menu item label to set.} | |
674 | ||
675 | \wxheading{See also} | |
676 | ||
677 | \helpref{wxMenu::Append}{wxmenuappend}, \helpref{wxMenu::GetLabel}{wxmenugetlabel} | |
678 | ||
3786c8b5 | 679 | |
a660d684 KB |
680 | \membersection{wxMenu::SetTitle}\label{wxmenusettitle} |
681 | ||
682 | \func{void}{SetTitle}{\param{const wxString\& }{title}} | |
683 | ||
684 | Sets the title of the menu. | |
685 | ||
686 | \wxheading{Parameters} | |
687 | ||
688 | \docparam{title}{The title to set.} | |
689 | ||
690 | \wxheading{Remarks} | |
691 | ||
706f30f8 VZ |
692 | This is relevant only to popup menus, use |
693 | \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop} for the menus in the | |
694 | menubar. | |
a660d684 KB |
695 | |
696 | \wxheading{See also} | |
697 | ||
706f30f8 | 698 | \helpref{wxMenu::GetTitle}{wxmenugettitle} |
a660d684 | 699 | |
3786c8b5 | 700 | |
631f1bfe JS |
701 | \membersection{wxMenu::UpdateUI}\label{wxmenuupdateui} |
702 | ||
703 | \constfunc{void}{UpdateUI}{\param{wxEvtHandler*}{ source = NULL}} | |
704 | ||
705 | Sends events to {\it source} (or owning window if NULL) to update the | |
706 | menu UI. This is called just before the menu is popped up with \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu}, but | |
707 | the application may call it at other times if required. | |
708 | ||
709 | \wxheading{See also} | |
710 | ||
711 | \helpref{wxUpdateUIEvent}{wxupdateuievent} | |
712 | ||
a660d684 KB |
713 | \section{\class{wxMenuBar}}\label{wxmenubar} |
714 | ||
715 | A menu bar is a series of menus accessible from the top of a frame. | |
716 | ||
717 | \wxheading{Derived from} | |
718 | ||
2138129e | 719 | \helpref{wxWindow}{wxwindow}\\ |
a660d684 KB |
720 | \helpref{wxEvtHandler}{wxevthandler}\\ |
721 | \helpref{wxObject}{wxobject} | |
722 | ||
954b8ae6 JS |
723 | \wxheading{Include files} |
724 | ||
725 | <wx/menu.h> | |
726 | ||
a660d684 KB |
727 | \wxheading{Event handling} |
728 | ||
729 | To respond to a menu selection, provide a handler for EVT\_MENU, in the frame | |
e702ff0f JS |
730 | that contains the menu bar. If you have a toolbar which uses the same identifiers |
731 | as your EVT\_MENU entries, events from the toolbar will also be processed by your | |
732 | EVT\_MENU event handlers. | |
733 | ||
0ddef74d JS |
734 | {\bf Tip:} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu) |
735 | are not working, check any EVT\_CHAR events you are handling in child windows. | |
736 | If you are not calling {\tt event.Skip()} for events that you don't process in these event handlers, | |
737 | menu shortcuts may cease to work. | |
738 | ||
a660d684 KB |
739 | \wxheading{See also} |
740 | ||
741 | \helpref{wxMenu}{wxmenu}, \helpref{Event handling overview}{eventhandlingoverview} | |
742 | ||
743 | \latexignore{\rtfignore{\wxheading{Members}}} | |
744 | ||
3786c8b5 | 745 | |
dcbd177f | 746 | \membersection{wxMenuBar::wxMenuBar}\label{wxmenubarctor} |
a660d684 | 747 | |
f6e9a818 | 748 | \func{}{wxMenuBar}{\param{long }{style = 0}} |
a660d684 KB |
749 | |
750 | Default constructor. | |
751 | ||
294ea16d | 752 | \func{}{wxMenuBar}{\param{size\_t}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}, \param{long }{style = 0}} |
a660d684 KB |
753 | |
754 | Construct a menu bar from arrays of menus and titles. | |
755 | ||
756 | \wxheading{Parameters} | |
757 | ||
758 | \docparam{n}{The number of menus.} | |
759 | ||
760 | \docparam{menus}{An array of menus. Do not use this array again - it now belongs to the | |
761 | menu bar.} | |
762 | ||
763 | \docparam{titles}{An array of title strings. Deallocate this array after creating the menu bar.} | |
764 | ||
d17f05af | 765 | \docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).} |
17e79918 | 766 | |
06d20283 | 767 | \pythonnote{Only the default constructor is supported in wxPython. |
294ea16d | 768 | Use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.} |
06d20283 | 769 | |
2edb0bde | 770 | \perlnote{wxPerl only supports the first constructor: |
294ea16d | 771 | use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.} |
5873607e | 772 | |
3786c8b5 | 773 | |
dcbd177f | 774 | \membersection{wxMenuBar::\destruct{wxMenuBar}}\label{wxmenubardtor} |
a660d684 KB |
775 | |
776 | \func{void}{\destruct{wxMenuBar}}{\void} | |
777 | ||
778 | Destructor, destroying the menu bar and removing it from the parent frame (if any). | |
779 | ||
3786c8b5 | 780 | |
a660d684 KB |
781 | \membersection{wxMenuBar::Append}\label{wxmenubarappend} |
782 | ||
1aaef614 | 783 | \func{bool}{Append}{\param{wxMenu *}{menu}, \param{const wxString\& }{title}} |
a660d684 KB |
784 | |
785 | Adds the item to the end of the menu bar. | |
786 | ||
787 | \wxheading{Parameters} | |
788 | ||
789 | \docparam{menu}{The menu to add. Do not deallocate this menu after calling {\bf Append}.} | |
790 | ||
791 | \docparam{title}{The title of the menu.} | |
792 | ||
1aaef614 VZ |
793 | \wxheading{Return value} |
794 | ||
cc81d32f | 795 | true on success, false if an error occurred. |
1aaef614 VZ |
796 | |
797 | \wxheading{See also} | |
798 | ||
799 | \helpref{wxMenuBar::Insert}{wxmenubarinsert} | |
800 | ||
3786c8b5 | 801 | |
a660d684 KB |
802 | \membersection{wxMenuBar::Check}\label{wxmenubarcheck} |
803 | ||
eaaa6a06 | 804 | \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}} |
a660d684 KB |
805 | |
806 | Checks or unchecks a menu item. | |
807 | ||
808 | \wxheading{Parameters} | |
809 | ||
810 | \docparam{id}{The menu item identifier.} | |
811 | ||
cc81d32f | 812 | \docparam{check}{If true, checks the menu item, otherwise the item is unchecked.} |
a660d684 KB |
813 | |
814 | \wxheading{Remarks} | |
815 | ||
816 | Only use this when the menu bar has been associated | |
817 | with a frame; otherwise, use the wxMenu equivalent call. | |
818 | ||
3786c8b5 | 819 | |
a660d684 KB |
820 | \membersection{wxMenuBar::Enable}\label{wxmenubarenable} |
821 | ||
eaaa6a06 | 822 | \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}} |
a660d684 KB |
823 | |
824 | Enables or disables (greys out) a menu item. | |
825 | ||
826 | \wxheading{Parameters} | |
827 | ||
828 | \docparam{id}{The menu item identifier.} | |
829 | ||
cc81d32f | 830 | \docparam{enable}{true to enable the item, false to disable it.} |
a660d684 KB |
831 | |
832 | \wxheading{Remarks} | |
833 | ||
834 | Only use this when the menu bar has been | |
835 | associated with a frame; otherwise, use the wxMenu equivalent call. | |
836 | ||
3786c8b5 | 837 | |
a660d684 KB |
838 | \membersection{wxMenuBar::EnableTop}\label{wxmenubarenabletop} |
839 | ||
eaaa6a06 | 840 | \func{void}{EnableTop}{\param{int}{ pos}, \param{const bool}{ enable}} |
a660d684 KB |
841 | |
842 | Enables or disables a whole menu. | |
843 | ||
844 | \wxheading{Parameters} | |
845 | ||
846 | \docparam{pos}{The position of the menu, starting from zero.} | |
847 | ||
cc81d32f | 848 | \docparam{enable}{true to enable the menu, false to disable it.} |
a660d684 KB |
849 | |
850 | \wxheading{Remarks} | |
851 | ||
852 | Only use this when the menu bar has been | |
853 | associated with a frame. | |
854 | ||
3786c8b5 | 855 | |
270e8b6a VZ |
856 | \membersection{wxMenuBar::FindMenu}\label{wxmenubarfindmenu} |
857 | ||
858 | \constfunc{int}{FindMenu}{\param{const wxString\& }{title}} | |
859 | ||
a8d08dbd | 860 | Returns the index of the menu with the given {\it title} or {\tt wxNOT\_FOUND} if no |
270e8b6a VZ |
861 | such menu exists in this menubar. The {\it title} parameter may specify either |
862 | the menu title (with accelerator characters, i.e. {\tt "\&File"}) or just the | |
863 | menu label ({\tt "File"}) indifferently. | |
864 | ||
3786c8b5 | 865 | |
a660d684 KB |
866 | \membersection{wxMenuBar::FindMenuItem}\label{wxmenubarfindmenuitem} |
867 | ||
868 | \constfunc{int}{FindMenuItem}{\param{const wxString\& }{menuString}, \param{const wxString\& }{itemString}} | |
869 | ||
870 | Finds the menu item id for a menu name/menu item string pair. | |
871 | ||
872 | \wxheading{Parameters} | |
873 | ||
874 | \docparam{menuString}{Menu title to find.} | |
875 | ||
876 | \docparam{itemString}{Item to find.} | |
877 | ||
878 | \wxheading{Return value} | |
879 | ||
a8d08dbd | 880 | The menu item identifier, or {\tt wxNOT\_FOUND} if none was found. |
a660d684 KB |
881 | |
882 | \wxheading{Remarks} | |
883 | ||
884 | Any special menu codes are stripped out of source and target strings | |
885 | before matching. | |
886 | ||
3786c8b5 | 887 | |
fc9c7c09 | 888 | \membersection{wxMenuBar::FindItem}\label{wxmenubarfinditem} |
a660d684 | 889 | |
407f3681 | 890 | \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu}{ **menu = NULL}} |
a660d684 | 891 | |
fc9c7c09 | 892 | Finds the menu item object associated with the given menu item identifier. |
a660d684 KB |
893 | |
894 | \wxheading{Parameters} | |
895 | ||
896 | \docparam{id}{Menu item identifier.} | |
407f3681 | 897 | |
fc9c7c09 | 898 | \docparam{menu}{If not NULL, menu will get set to the associated menu.} |
a660d684 KB |
899 | |
900 | \wxheading{Return value} | |
901 | ||
902 | The found menu item object, or NULL if one was not found. | |
903 | ||
3786c8b5 | 904 | |
a660d684 KB |
905 | \membersection{wxMenuBar::GetHelpString}\label{wxmenubargethelpstring} |
906 | ||
eaaa6a06 | 907 | \constfunc{wxString}{GetHelpString}{\param{int}{ id}} |
a660d684 | 908 | |
2edb0bde | 909 | Gets the help string associated with the menu item identifier. |
a660d684 KB |
910 | |
911 | \wxheading{Parameters} | |
912 | ||
913 | \docparam{id}{The menu item identifier.} | |
914 | ||
915 | \wxheading{Return value} | |
916 | ||
917 | The help string, or the empty string if there was no help string or the menu item | |
918 | was not found. | |
919 | ||
920 | \wxheading{See also} | |
921 | ||
922 | \helpref{wxMenuBar::SetHelpString}{wxmenubarsethelpstring} | |
923 | ||
3786c8b5 | 924 | |
a660d684 KB |
925 | \membersection{wxMenuBar::GetLabel}\label{wxmenubargetlabel} |
926 | ||
eaaa6a06 | 927 | \constfunc{wxString}{GetLabel}{\param{int}{ id}} |
a660d684 KB |
928 | |
929 | Gets the label associated with a menu item. | |
930 | ||
931 | \wxheading{Parameters} | |
932 | ||
933 | \docparam{id}{The menu item identifier.} | |
934 | ||
935 | \wxheading{Return value} | |
936 | ||
937 | The menu item label, or the empty string if the item was not found. | |
938 | ||
939 | \wxheading{Remarks} | |
940 | ||
941 | Use only after the menubar has been associated with a frame. | |
942 | ||
3786c8b5 | 943 | |
a660d684 KB |
944 | \membersection{wxMenuBar::GetLabelTop}\label{wxmenubargetlabeltop} |
945 | ||
eaaa6a06 | 946 | \constfunc{wxString}{GetLabelTop}{\param{int}{ pos}} |
a660d684 | 947 | |
706f30f8 VZ |
948 | Returns the label of a top-level menu. Note that the returned string does not |
949 | include the accelerator characters which could have been specified in the menu | |
950 | title string during its construction. | |
a660d684 KB |
951 | |
952 | \wxheading{Parameters} | |
953 | ||
954 | \docparam{pos}{Position of the menu on the menu bar, starting from zero.} | |
955 | ||
956 | \wxheading{Return value} | |
957 | ||
958 | The menu label, or the empty string if the menu was not found. | |
959 | ||
960 | \wxheading{Remarks} | |
961 | ||
962 | Use only after the menubar has been associated with a frame. | |
963 | ||
964 | \wxheading{See also} | |
965 | ||
966 | \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop} | |
967 | ||
3786c8b5 | 968 | |
7f555861 JS |
969 | \membersection{wxMenuBar::GetMenu}\label{wxmenubargetmenu} |
970 | ||
971 | \constfunc{wxMenu*}{GetMenu}{\param{int}{ menuIndex}} | |
972 | ||
973 | Returns the menu at {\it menuIndex} (zero-based). | |
974 | ||
3786c8b5 | 975 | |
7f555861 JS |
976 | \membersection{wxMenuBar::GetMenuCount}\label{wxmenubargetmenucount} |
977 | ||
978 | \constfunc{int}{GetMenuCount}{\void} | |
979 | ||
980 | Returns the number of menus in this menubar. | |
981 | ||
3786c8b5 | 982 | |
e12be2f7 | 983 | \membersection{wxMenuBar::Insert}\label{wxmenubarinsert} |
1aaef614 VZ |
984 | |
985 | \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}} | |
986 | ||
987 | Inserts the menu at the given position into the menu bar. Inserting menu at | |
fa482912 JS |
988 | position $0$ will insert it in the very beginning of it, inserting at position |
989 | \helpref{GetMenuCount()}{wxmenubargetmenucount} is the same as calling | |
1aaef614 VZ |
990 | \helpref{Append()}{wxmenubarappend}. |
991 | ||
992 | \wxheading{Parameters} | |
993 | ||
994 | \docparam{pos}{The position of the new menu in the menu bar} | |
995 | ||
996 | \docparam{menu}{The menu to add. wxMenuBar owns the menu and will free it.} | |
997 | ||
998 | \docparam{title}{The title of the menu.} | |
999 | ||
1000 | \wxheading{Return value} | |
1001 | ||
cc81d32f | 1002 | true on success, false if an error occurred. |
1aaef614 VZ |
1003 | |
1004 | \wxheading{See also} | |
1005 | ||
1006 | \helpref{wxMenuBar::Append}{wxmenubarappend} | |
1007 | ||
3786c8b5 | 1008 | |
a660d684 KB |
1009 | \membersection{wxMenuBar::IsChecked}\label{wxmenubarischecked} |
1010 | ||
eaaa6a06 | 1011 | \constfunc{bool}{IsChecked}{\param{int}{ id}} |
a660d684 KB |
1012 | |
1013 | Determines whether an item is checked. | |
1014 | ||
1015 | \wxheading{Parameters} | |
1016 | ||
1017 | \docparam{id}{The menu item identifier.} | |
1018 | ||
1019 | \wxheading{Return value} | |
1020 | ||
cc81d32f | 1021 | true if the item was found and is checked, false otherwise. |
a660d684 | 1022 | |
3786c8b5 | 1023 | |
a660d684 KB |
1024 | \membersection{wxMenuBar::IsEnabled}\label{wxmenubarisenabled} |
1025 | ||
eaaa6a06 | 1026 | \constfunc{bool}{IsEnabled}{\param{int}{ id}} |
a660d684 KB |
1027 | |
1028 | Determines whether an item is enabled. | |
1029 | ||
1030 | \wxheading{Parameters} | |
1031 | ||
1032 | \docparam{id}{The menu item identifier.} | |
1033 | ||
1034 | \wxheading{Return value} | |
1035 | ||
cc81d32f | 1036 | true if the item was found and is enabled, false otherwise. |
a660d684 | 1037 | |
3786c8b5 | 1038 | |
63dcfc15 PA |
1039 | \membersection{wxMenuBar::Refresh}\label{wxmenubarrefresh} |
1040 | ||
1041 | \func{void}{Refresh}{\void} | |
1042 | ||
1043 | Redraw the menu bar | |
1044 | ||
3786c8b5 | 1045 | |
1aaef614 VZ |
1046 | \membersection{wxMenuBar::Remove}\label{wxmenubarremove} |
1047 | ||
1048 | \func{wxMenu *}{Remove}{\param{size\_t }{pos}} | |
1049 | ||
1050 | Removes the menu from the menu bar and returns the menu object - the caller is | |
d7d17624 | 1051 | responsible for deleting it. This function may be used together with |
1aaef614 VZ |
1052 | \helpref{wxMenuBar::Insert}{wxmenubarinsert} to change the menubar |
1053 | dynamically. | |
1054 | ||
1055 | \wxheading{See also} | |
1056 | ||
2182e26f | 1057 | \helpref{wxMenuBar::Replace}{wxmenubarreplace} |
1aaef614 | 1058 | |
3786c8b5 | 1059 | |
1aaef614 VZ |
1060 | \membersection{wxMenuBar::Replace}\label{wxmenubarreplace} |
1061 | ||
1062 | \func{wxMenu *}{Replace}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}} | |
1063 | ||
fa482912 | 1064 | Replaces the menu at the given position with another one. |
1aaef614 VZ |
1065 | |
1066 | \wxheading{Parameters} | |
1067 | ||
1068 | \docparam{pos}{The position of the new menu in the menu bar} | |
1069 | ||
1070 | \docparam{menu}{The menu to add.} | |
1071 | ||
1072 | \docparam{title}{The title of the menu.} | |
1073 | ||
1074 | \wxheading{Return value} | |
1075 | ||
3980000c | 1076 | The menu which was previously at position {\it pos}. The caller is |
1aaef614 VZ |
1077 | responsible for deleting it. |
1078 | ||
1079 | \wxheading{See also} | |
1080 | ||
1081 | \helpref{wxMenuBar::Insert}{wxmenubarinsert},\rtfsp | |
1082 | \helpref{wxMenuBar::Remove}{wxmenubarremove} | |
1083 | ||
3786c8b5 | 1084 | |
a660d684 KB |
1085 | \membersection{wxMenuBar::SetHelpString}\label{wxmenubarsethelpstring} |
1086 | ||
eaaa6a06 | 1087 | \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}} |
a660d684 KB |
1088 | |
1089 | Sets the help string associated with a menu item. | |
1090 | ||
1091 | \wxheading{Parameters} | |
1092 | ||
1093 | \docparam{id}{Menu item identifier.} | |
1094 | ||
1095 | \docparam{helpString}{Help string to associate with the menu item.} | |
1096 | ||
1097 | \wxheading{See also} | |
1098 | ||
1099 | \helpref{wxMenuBar::GetHelpString}{wxmenubargethelpstring} | |
1100 | ||
3786c8b5 | 1101 | |
a660d684 KB |
1102 | \membersection{wxMenuBar::SetLabel}\label{wxmenubarsetlabel} |
1103 | ||
eaaa6a06 | 1104 | \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}} |
a660d684 KB |
1105 | |
1106 | Sets the label of a menu item. | |
1107 | ||
1108 | \wxheading{Parameters} | |
1109 | ||
1110 | \docparam{id}{Menu item identifier.} | |
1111 | ||
1112 | \docparam{label}{Menu item label.} | |
1113 | ||
1114 | \wxheading{Remarks} | |
1115 | ||
1116 | Use only after the menubar has been associated with a frame. | |
1117 | ||
1118 | \wxheading{See also} | |
1119 | ||
1120 | \helpref{wxMenuBar::GetLabel}{wxmenubargetlabel} | |
1121 | ||
3786c8b5 | 1122 | |
a660d684 KB |
1123 | \membersection{wxMenuBar::SetLabelTop}\label{wxmenubarsetlabeltop} |
1124 | ||
eaaa6a06 | 1125 | \func{void}{SetLabelTop}{\param{int}{ pos}, \param{const wxString\& }{label}} |
a660d684 KB |
1126 | |
1127 | Sets the label of a top-level menu. | |
1128 | ||
1129 | \wxheading{Parameters} | |
1130 | ||
1131 | \docparam{pos}{The position of a menu on the menu bar, starting from zero.} | |
1132 | ||
1133 | \docparam{label}{The menu label.} | |
1134 | ||
1135 | \wxheading{Remarks} | |
1136 | ||
1137 | Use only after the menubar has been associated with a frame. | |
1138 | ||
1139 | \wxheading{See also} | |
1140 | ||
1141 | \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop} | |
1142 |