]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/menu.tex
added more wxUSE_XXX symbols (modified patch 1758917)
[wxWidgets.git] / docs / latex / wx / menu.tex
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
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
16 menu). Menus may be used to construct either menu bars or popup menus.
17
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.
22
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.
29
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.
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
45 the radio items risks to not work correctly. Finally note that radio items
46 are not supported under Motif.
47
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
55 \wxheading{Derived from}
56
57 \helpref{wxEvtHandler}{wxevthandler}\\
58 \helpref{wxObject}{wxobject}
59
60 \wxheading{Include files}
61
62 <wx/menu.h>
63
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
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.
76 \end{enumerate}
77
78 \wxheading{See also}
79
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}
83
84
85
86 \latexignore{\rtfignore{\wxheading{Members}}}
87
88
89 \membersection{wxMenu::wxMenu}\label{wxmenuctor}
90
91 \func{}{wxMenu}{\param{const wxString\& }{title = ""}, \param{long}{ style = 0}}
92
93 Constructs a wxMenu object.
94
95 \wxheading{Parameters}
96
97 \docparam{title}{A title for the popup menu: the empty string denotes no title.}
98
99 \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
100
101 \func{}{wxMenu}{\param{long}{ style}}
102
103 Constructs a wxMenu object.
104
105 \wxheading{Parameters}
106
107 \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
108
109
110 \membersection{wxMenu::\destruct{wxMenu}}\label{wxmenudtor}
111
112 \func{}{\destruct{wxMenu}}{\void}
113
114 Destructor, destroying the menu.
115
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.
122
123
124 \membersection{wxMenu::Append}\label{wxmenuappend}
125
126 \func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item = ""}, \param{const wxString\& }{helpString = ""},\rtfsp
127 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
128
129 Adds a string item to the end of the menu.
130
131 \func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
132 \param{const wxString\& }{helpString = ""}}
133
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
136 registered properly.
137
138 \func{wxMenuItem*}{Append}{\param{wxMenuItem*}{ menuItem}}
139
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.
144
145 \wxheading{Parameters}
146
147 \docparam{id}{The menu command identifier.}
148
149 \docparam{item}{The string to appear on the menu item.}
150
151 \docparam{menu}{Pull-right submenu.}
152
153 \docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
154 {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
155
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.}
159
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.}
162
163 \wxheading{Remarks}
164
165 This command can be used after the menu has been shown, as well as on initial
166 creation of a menu or menubar.
167
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):
177
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)}
193 \end{twocollist}
194
195 \wxheading{See also}
196
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}
204
205 \pythonnote{In place of a single overloaded method name, wxPython
206 implements the following methods:
207
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)}}{}
212 \end{twocollist}}
213 }
214
215
216 \membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem}
217
218 \func{wxMenuItem*}{AppendCheckItem}{\param{int}{ id},\rtfsp
219 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
220
221 Adds a checkable item to the end of the menu.
222
223 \wxheading{See also}
224
225 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
226 \helpref{wxMenu::InsertCheckItem}{wxmenuinsertcheckitem}
227
228
229 \membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem}
230
231 \func{wxMenuItem*}{AppendRadioItem}{\param{int}{ id},\rtfsp
232 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
233
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.
237
238 \wxheading{See also}
239
240 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
241 \helpref{wxMenu::InsertRadioItem}{wxmenuinsertradioitem}
242
243
244 \membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
245
246 \func{wxMenuItem*}{AppendSeparator}{\void}
247
248 Adds a separator to the end of the menu.
249
250 \wxheading{See also}
251
252 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
253 \helpref{wxMenu::InsertSeparator}{wxmenuinsertseparator}
254
255
256 \membersection{wxMenu::AppendSubMenu}\label{wxmenuappendsubmenu}
257
258 \func{wxMenuItem *}{AppendSubMenu}{\param{wxMenu *}{submenu}, \param{const wxString\& }{text}, \param{const wxString\& }{help = wxEmptyString}}
259
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.
263
264
265 \membersection{wxMenu::Break}\label{wxmenubreak}
266
267 \func{void}{Break}{\void}
268
269 Inserts a break in a menu, causing the next appended item to appear in a new column.
270
271
272 \membersection{wxMenu::Check}\label{wxmenucheck}
273
274 \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
275
276 Checks or unchecks the menu item.
277
278 \wxheading{Parameters}
279
280 \docparam{id}{The menu item identifier.}
281
282 \docparam{check}{If true, the item will be checked, otherwise it will be unchecked.}
283
284 \wxheading{See also}
285
286 \helpref{wxMenu::IsChecked}{wxmenuischecked}
287
288
289 \membersection{wxMenu::Delete}\label{wxmenudelete}
290
291 \func{void}{Delete}{\param{int }{id}}
292
293 \func{void}{Delete}{\param{wxMenuItem *}{item}}
294
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
297 delete a submenu.
298
299 \wxheading{Parameters}
300
301 \docparam{id}{Id of the menu item to be deleted.}
302
303 \docparam{item}{Menu item to be deleted.}
304
305 \wxheading{See also}
306
307 \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
308 \helpref{wxMenu::Destroy}{wxmenudestroy},\rtfsp
309 \helpref{wxMenu::Remove}{wxmenuremove}
310
311
312 \membersection{wxMenu::Destroy}\label{wxmenudestroy}
313
314 \func{void}{Destroy}{\param{int }{id}}
315
316 \func{void}{Destroy}{\param{wxMenuItem *}{item}}
317
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).
321
322 \wxheading{Parameters}
323
324 \docparam{id}{Id of the menu item to be deleted.}
325
326 \docparam{item}{Menu item to be deleted.}
327
328 \wxheading{See also}
329
330 \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
331 \helpref{wxMenu::Deletes}{wxmenudelete},\rtfsp
332 \helpref{wxMenu::Remove}{wxmenuremove}
333
334
335 \membersection{wxMenu::Enable}\label{wxmenuenable}
336
337 \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
338
339 Enables or disables (greys out) a menu item.
340
341 \wxheading{Parameters}
342
343 \docparam{id}{The menu item identifier.}
344
345 \docparam{enable}{true to enable the menu item, false to disable it.}
346
347 \wxheading{See also}
348
349 \helpref{wxMenu::IsEnabled}{wxmenuisenabled}
350
351
352 \membersection{wxMenu::FindItem}\label{wxmenufinditem}
353
354 \constfunc{int}{FindItem}{\param{const wxString\& }{itemString}}
355
356 Finds the menu item id for a menu item string.
357
358 \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu **}{menu = NULL}}
359
360 Finds the menu item object associated with the given menu item identifier and,
361 optionally, the (sub)menu it belongs to.
362
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 )}}
366
367 \wxheading{Parameters}
368
369 \docparam{itemString}{Menu item string to find.}
370
371 \docparam{id}{Menu item identifier.}
372
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)}
375
376 \wxheading{Return value}
377
378 First form: menu item identifier, or {\tt wxNOT\_FOUND} if none is found.
379
380 Second form: returns the menu item object, or NULL if it is not found.
381
382 \wxheading{Remarks}
383
384 Any special menu codes are stripped out of source and target strings
385 before matching.
386
387 \pythonnote{The name of this method in wxPython is {\tt FindItemById}
388 and it does not support the second parameter.}
389
390
391 \membersection{wxMenu::FindItemByPosition}\label{wxmenufinditembyposition}
392
393 \constfunc{wxMenuItem*}{FindItemByPosition}{\param{size\_t }{position}}
394
395 Returns the wxMenuItem given a position in the menu.
396
397
398 \membersection{wxMenu::GetHelpString}\label{wxmenugethelpstring}
399
400 \constfunc{wxString}{GetHelpString}{\param{int}{ id}}
401
402 Returns the help string associated with a menu item.
403
404 \wxheading{Parameters}
405
406 \docparam{id}{The menu item identifier.}
407
408 \wxheading{Return value}
409
410 The help string, or the empty string if there is no help string or the
411 item was not found.
412
413 \wxheading{See also}
414
415 \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenu::Append}{wxmenuappend}
416
417
418 \membersection{wxMenu::GetLabel}\label{wxmenugetlabel}
419
420 \constfunc{wxString}{GetLabel}{\param{int}{ id}}
421
422 Returns a menu item label.
423
424 \wxheading{Parameters}
425
426 \docparam{id}{The menu item identifier.}
427
428 \wxheading{Return value}
429
430 The item label, or the empty string if the item was not found.
431
432 \wxheading{See also}
433
434 \helpref{wxMenu::SetLabel}{wxmenusetlabel}
435
436
437 \membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount}
438
439 \constfunc{size\_t}{GetMenuItemCount}{\void}
440
441 Returns the number of items in the menu.
442
443
444 \membersection{wxMenu::GetMenuItems}\label{wxmenugetmenuitems}
445
446 \constfunc{wxMenuItemList\&}{GetMenuItems}{\void}
447
448 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
449 list class containing wxMenuItem pointers, see \helpref{wxList}{wxlist}.
450
451
452 \membersection{wxMenu::GetTitle}\label{wxmenugettitle}
453
454 \constfunc{wxString}{GetTitle}{\void}
455
456 Returns the title of the menu.
457
458 \wxheading{Remarks}
459
460 This is relevant only to popup menus, use
461 \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop} for the menus in the
462 menubar.
463
464 \wxheading{See also}
465
466 \helpref{wxMenu::SetTitle}{wxmenusettitle}
467
468
469 \membersection{wxMenu::Insert}\label{wxmenuinsert}
470
471 \func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
472
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}}
476
477 Inserts the given {\it item} before the position {\it pos}. Inserting the item
478 at position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same
479 as appending it.
480
481 \wxheading{See also}
482
483 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
484 \helpref{wxMenu::Prepend}{wxmenuprepend}
485
486
487 \membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem}
488
489 \func{wxMenuItem*}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
490 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
491
492 Inserts a checkable item at the given position.
493
494 \wxheading{See also}
495
496 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
497 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
498
499
500 \membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem}
501
502 \func{wxMenuItem*}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
503 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
504
505 Inserts a radio item at the given position.
506
507 \wxheading{See also}
508
509 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
510 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
511
512
513 \membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator}
514
515 \func{wxMenuItem*}{InsertSeparator}{\param{size\_t }{pos}}
516
517 Inserts a separator at the given position.
518
519 \wxheading{See also}
520
521 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
522 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
523
524
525 \membersection{wxMenu::IsChecked}\label{wxmenuischecked}
526
527 \constfunc{bool}{IsChecked}{\param{int}{ id}}
528
529 Determines whether a menu item is checked.
530
531 \wxheading{Parameters}
532
533 \docparam{id}{The menu item identifier.}
534
535 \wxheading{Return value}
536
537 true if the menu item is checked, false otherwise.
538
539 \wxheading{See also}
540
541 \helpref{wxMenu::Check}{wxmenucheck}
542
543
544 \membersection{wxMenu::IsEnabled}\label{wxmenuisenabled}
545
546 \constfunc{bool}{IsEnabled}{\param{int}{ id}}
547
548 Determines whether a menu item is enabled.
549
550 \wxheading{Parameters}
551
552 \docparam{id}{The menu item identifier.}
553
554 \wxheading{Return value}
555
556 true if the menu item is enabled, false otherwise.
557
558 \wxheading{See also}
559
560 \helpref{wxMenu::Enable}{wxmenuenable}
561
562
563 \membersection{wxMenu::Prepend}\label{wxmenuprepend}
564
565 \func{wxMenuItem*}{Prepend}{\param{wxMenuItem *}{item}}
566
567 \func{wxMenuItem*}{Prepend}{\param{int}{ id},\rtfsp
568 \param{const wxString\& }{ item = ""}, \param{const wxString\& }{helpString = ""},\rtfsp
569 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
570
571 Inserts the given {\it item} at position $0$, i.e. before all the other
572 existing items.
573
574 \wxheading{See also}
575
576 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
577 \helpref{wxMenu::Insert}{wxmenuinsert}
578
579
580 \membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem}
581
582 \func{wxMenuItem*}{PrependCheckItem}{\param{int}{ id},\rtfsp
583 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
584
585 Inserts a checkable item at position $0$.
586
587 \wxheading{See also}
588
589 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
590 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
591
592
593 \membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem}
594
595 \func{wxMenuItem*}{PrependRadioItem}{\param{int}{ id},\rtfsp
596 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
597
598 Inserts a radio item at position $0$.
599
600 \wxheading{See also}
601
602 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
603 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
604
605
606 \membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator}
607
608 \func{wxMenuItem*}{PrependSeparator}{\void}
609
610 Inserts a separator at position $0$.
611
612 \wxheading{See also}
613
614 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
615 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
616
617
618 \membersection{wxMenu::Remove}\label{wxmenuremove}
619
620 \func{wxMenuItem *}{Remove}{\param{int }{id}}
621
622 \func{wxMenuItem *}{Remove}{\param{wxMenuItem *}{item}}
623
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).
627
628 \wxheading{Parameters}
629
630 \docparam{id}{The identifier of the menu item to remove.}
631
632 \docparam{item}{The menu item to remove.}
633
634 \wxheading{Return value}
635
636 The item which was detached from the menu.
637
638
639 \membersection{wxMenu::SetHelpString}\label{wxmenusethelpstring}
640
641 \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
642
643 Sets an item's help string.
644
645 \wxheading{Parameters}
646
647 \docparam{id}{The menu item identifier.}
648
649 \docparam{helpString}{The help string to set.}
650
651 \wxheading{See also}
652
653 \helpref{wxMenu::GetHelpString}{wxmenugethelpstring}
654
655
656 \membersection{wxMenu::SetLabel}\label{wxmenusetlabel}
657
658 \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
659
660 Sets the label of a menu item.
661
662 \wxheading{Parameters}
663
664 \docparam{id}{The menu item identifier.}
665
666 \docparam{label}{The menu item label to set.}
667
668 \wxheading{See also}
669
670 \helpref{wxMenu::Append}{wxmenuappend}, \helpref{wxMenu::GetLabel}{wxmenugetlabel}
671
672
673 \membersection{wxMenu::SetTitle}\label{wxmenusettitle}
674
675 \func{void}{SetTitle}{\param{const wxString\& }{title}}
676
677 Sets the title of the menu.
678
679 \wxheading{Parameters}
680
681 \docparam{title}{The title to set.}
682
683 \wxheading{Remarks}
684
685 This is relevant only to popup menus, use
686 \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop} for the menus in the
687 menubar.
688
689 \wxheading{See also}
690
691 \helpref{wxMenu::GetTitle}{wxmenugettitle}
692
693
694 \membersection{wxMenu::UpdateUI}\label{wxmenuupdateui}
695
696 \constfunc{void}{UpdateUI}{\param{wxEvtHandler*}{ source = NULL}}
697
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.
701
702 \wxheading{See also}
703
704 \helpref{wxUpdateUIEvent}{wxupdateuievent}
705
706 \section{\class{wxMenuBar}}\label{wxmenubar}
707
708 A menu bar is a series of menus accessible from the top of a frame.
709
710 \wxheading{Derived from}
711
712 \helpref{wxWindow}{wxwindow}\\
713 \helpref{wxEvtHandler}{wxevthandler}\\
714 \helpref{wxObject}{wxobject}
715
716 \wxheading{Include files}
717
718 <wx/menu.h>
719
720 \wxheading{Event handling}
721
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.
726
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.
731
732 \wxheading{See also}
733
734 \helpref{wxMenu}{wxmenu}, \helpref{Event handling overview}{eventhandlingoverview}
735
736 \latexignore{\rtfignore{\wxheading{Members}}}
737
738
739 \membersection{wxMenuBar::wxMenuBar}\label{wxmenubarctor}
740
741 \func{}{wxMenuBar}{\param{long }{style = 0}}
742
743 Default constructor.
744
745 \func{}{wxMenuBar}{\param{size\_t}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}, \param{long }{style = 0}}
746
747 Construct a menu bar from arrays of menus and titles.
748
749 \wxheading{Parameters}
750
751 \docparam{n}{The number of menus.}
752
753 \docparam{menus}{An array of menus. Do not use this array again - it now belongs to the
754 menu bar.}
755
756 \docparam{titles}{An array of title strings. Deallocate this array after creating the menu bar.}
757
758 \docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).}
759
760 \pythonnote{Only the default constructor is supported in wxPython.
761 Use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
762
763 \perlnote{wxPerl only supports the first constructor:
764 use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
765
766
767 \membersection{wxMenuBar::\destruct{wxMenuBar}}\label{wxmenubardtor}
768
769 \func{void}{\destruct{wxMenuBar}}{\void}
770
771 Destructor, destroying the menu bar and removing it from the parent frame (if any).
772
773
774 \membersection{wxMenuBar::Append}\label{wxmenubarappend}
775
776 \func{bool}{Append}{\param{wxMenu *}{menu}, \param{const wxString\& }{title}}
777
778 Adds the item to the end of the menu bar.
779
780 \wxheading{Parameters}
781
782 \docparam{menu}{The menu to add. Do not deallocate this menu after calling {\bf Append}.}
783
784 \docparam{title}{The title of the menu.}
785
786 \wxheading{Return value}
787
788 true on success, false if an error occurred.
789
790 \wxheading{See also}
791
792 \helpref{wxMenuBar::Insert}{wxmenubarinsert}
793
794
795 \membersection{wxMenuBar::Check}\label{wxmenubarcheck}
796
797 \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
798
799 Checks or unchecks a menu item.
800
801 \wxheading{Parameters}
802
803 \docparam{id}{The menu item identifier.}
804
805 \docparam{check}{If true, checks the menu item, otherwise the item is unchecked.}
806
807 \wxheading{Remarks}
808
809 Only use this when the menu bar has been associated
810 with a frame; otherwise, use the wxMenu equivalent call.
811
812
813 \membersection{wxMenuBar::Enable}\label{wxmenubarenable}
814
815 \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
816
817 Enables or disables (greys out) a menu item.
818
819 \wxheading{Parameters}
820
821 \docparam{id}{The menu item identifier.}
822
823 \docparam{enable}{true to enable the item, false to disable it.}
824
825 \wxheading{Remarks}
826
827 Only use this when the menu bar has been
828 associated with a frame; otherwise, use the wxMenu equivalent call.
829
830
831 \membersection{wxMenuBar::EnableTop}\label{wxmenubarenabletop}
832
833 \func{void}{EnableTop}{\param{int}{ pos}, \param{const bool}{ enable}}
834
835 Enables or disables a whole menu.
836
837 \wxheading{Parameters}
838
839 \docparam{pos}{The position of the menu, starting from zero.}
840
841 \docparam{enable}{true to enable the menu, false to disable it.}
842
843 \wxheading{Remarks}
844
845 Only use this when the menu bar has been
846 associated with a frame.
847
848
849 \membersection{wxMenuBar::FindMenu}\label{wxmenubarfindmenu}
850
851 \constfunc{int}{FindMenu}{\param{const wxString\& }{title}}
852
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.
857
858
859 \membersection{wxMenuBar::FindMenuItem}\label{wxmenubarfindmenuitem}
860
861 \constfunc{int}{FindMenuItem}{\param{const wxString\& }{menuString}, \param{const wxString\& }{itemString}}
862
863 Finds the menu item id for a menu name/menu item string pair.
864
865 \wxheading{Parameters}
866
867 \docparam{menuString}{Menu title to find.}
868
869 \docparam{itemString}{Item to find.}
870
871 \wxheading{Return value}
872
873 The menu item identifier, or {\tt wxNOT\_FOUND} if none was found.
874
875 \wxheading{Remarks}
876
877 Any special menu codes are stripped out of source and target strings
878 before matching.
879
880
881 \membersection{wxMenuBar::FindItem}\label{wxmenubarfinditem}
882
883 \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu}{ **menu = NULL}}
884
885 Finds the menu item object associated with the given menu item identifier.
886
887 \wxheading{Parameters}
888
889 \docparam{id}{Menu item identifier.}
890
891 \docparam{menu}{If not NULL, menu will get set to the associated menu.}
892
893 \wxheading{Return value}
894
895 The found menu item object, or NULL if one was not found.
896
897
898 \membersection{wxMenuBar::GetHelpString}\label{wxmenubargethelpstring}
899
900 \constfunc{wxString}{GetHelpString}{\param{int}{ id}}
901
902 Gets the help string associated with the menu item identifier.
903
904 \wxheading{Parameters}
905
906 \docparam{id}{The menu item identifier.}
907
908 \wxheading{Return value}
909
910 The help string, or the empty string if there was no help string or the menu item
911 was not found.
912
913 \wxheading{See also}
914
915 \helpref{wxMenuBar::SetHelpString}{wxmenubarsethelpstring}
916
917
918 \membersection{wxMenuBar::GetLabel}\label{wxmenubargetlabel}
919
920 \constfunc{wxString}{GetLabel}{\param{int}{ id}}
921
922 Gets the label associated with a menu item.
923
924 \wxheading{Parameters}
925
926 \docparam{id}{The menu item identifier.}
927
928 \wxheading{Return value}
929
930 The menu item label, or the empty string if the item was not found.
931
932 \wxheading{Remarks}
933
934 Use only after the menubar has been associated with a frame.
935
936
937 \membersection{wxMenuBar::GetLabelTop}\label{wxmenubargetlabeltop}
938
939 \constfunc{wxString}{GetLabelTop}{\param{int}{ pos}}
940
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.
944
945 \wxheading{Parameters}
946
947 \docparam{pos}{Position of the menu on the menu bar, starting from zero.}
948
949 \wxheading{Return value}
950
951 The menu label, or the empty string if the menu was not found.
952
953 \wxheading{Remarks}
954
955 Use only after the menubar has been associated with a frame.
956
957 \wxheading{See also}
958
959 \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop}
960
961
962 \membersection{wxMenuBar::GetMenu}\label{wxmenubargetmenu}
963
964 \constfunc{wxMenu*}{GetMenu}{\param{int}{ menuIndex}}
965
966 Returns the menu at {\it menuIndex} (zero-based).
967
968
969 \membersection{wxMenuBar::GetMenuCount}\label{wxmenubargetmenucount}
970
971 \constfunc{size\_t}{GetMenuCount}{\void}
972
973 Returns the number of menus in this menubar.
974
975
976 \membersection{wxMenuBar::Insert}\label{wxmenubarinsert}
977
978 \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
979
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}.
984
985 \wxheading{Parameters}
986
987 \docparam{pos}{The position of the new menu in the menu bar}
988
989 \docparam{menu}{The menu to add. wxMenuBar owns the menu and will free it.}
990
991 \docparam{title}{The title of the menu.}
992
993 \wxheading{Return value}
994
995 true on success, false if an error occurred.
996
997 \wxheading{See also}
998
999 \helpref{wxMenuBar::Append}{wxmenubarappend}
1000
1001
1002 \membersection{wxMenuBar::IsChecked}\label{wxmenubarischecked}
1003
1004 \constfunc{bool}{IsChecked}{\param{int}{ id}}
1005
1006 Determines whether an item is checked.
1007
1008 \wxheading{Parameters}
1009
1010 \docparam{id}{The menu item identifier.}
1011
1012 \wxheading{Return value}
1013
1014 true if the item was found and is checked, false otherwise.
1015
1016
1017 \membersection{wxMenuBar::IsEnabled}\label{wxmenubarisenabled}
1018
1019 \constfunc{bool}{IsEnabled}{\param{int}{ id}}
1020
1021 Determines whether an item is enabled.
1022
1023 \wxheading{Parameters}
1024
1025 \docparam{id}{The menu item identifier.}
1026
1027 \wxheading{Return value}
1028
1029 true if the item was found and is enabled, false otherwise.
1030
1031
1032 \membersection{wxMenuBar::Refresh}\label{wxmenubarrefresh}
1033
1034 \func{void}{Refresh}{\void}
1035
1036 Redraw the menu bar
1037
1038
1039 \membersection{wxMenuBar::Remove}\label{wxmenubarremove}
1040
1041 \func{wxMenu *}{Remove}{\param{size\_t }{pos}}
1042
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
1046 dynamically.
1047
1048 \wxheading{See also}
1049
1050 \helpref{wxMenuBar::Replace}{wxmenubarreplace}
1051
1052
1053 \membersection{wxMenuBar::Replace}\label{wxmenubarreplace}
1054
1055 \func{wxMenu *}{Replace}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
1056
1057 Replaces the menu at the given position with another one.
1058
1059 \wxheading{Parameters}
1060
1061 \docparam{pos}{The position of the new menu in the menu bar}
1062
1063 \docparam{menu}{The menu to add.}
1064
1065 \docparam{title}{The title of the menu.}
1066
1067 \wxheading{Return value}
1068
1069 The menu which was previously at position {\it pos}. The caller is
1070 responsible for deleting it.
1071
1072 \wxheading{See also}
1073
1074 \helpref{wxMenuBar::Insert}{wxmenubarinsert},\rtfsp
1075 \helpref{wxMenuBar::Remove}{wxmenubarremove}
1076
1077
1078 \membersection{wxMenuBar::SetHelpString}\label{wxmenubarsethelpstring}
1079
1080 \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
1081
1082 Sets the help string associated with a menu item.
1083
1084 \wxheading{Parameters}
1085
1086 \docparam{id}{Menu item identifier.}
1087
1088 \docparam{helpString}{Help string to associate with the menu item.}
1089
1090 \wxheading{See also}
1091
1092 \helpref{wxMenuBar::GetHelpString}{wxmenubargethelpstring}
1093
1094
1095 \membersection{wxMenuBar::SetLabel}\label{wxmenubarsetlabel}
1096
1097 \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
1098
1099 Sets the label of a menu item.
1100
1101 \wxheading{Parameters}
1102
1103 \docparam{id}{Menu item identifier.}
1104
1105 \docparam{label}{Menu item label.}
1106
1107 \wxheading{Remarks}
1108
1109 Use only after the menubar has been associated with a frame.
1110
1111 \wxheading{See also}
1112
1113 \helpref{wxMenuBar::GetLabel}{wxmenubargetlabel}
1114
1115
1116 \membersection{wxMenuBar::SetLabelTop}\label{wxmenubarsetlabeltop}
1117
1118 \func{void}{SetLabelTop}{\param{int}{ pos}, \param{const wxString\& }{label}}
1119
1120 Sets the label of a top-level menu.
1121
1122 \wxheading{Parameters}
1123
1124 \docparam{pos}{The position of a menu on the menu bar, starting from zero.}
1125
1126 \docparam{label}{The menu label.}
1127
1128 \wxheading{Remarks}
1129
1130 Use only after the menubar has been associated with a frame.
1131
1132 \wxheading{See also}
1133
1134 \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop}
1135