]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/menu.tex
fixed tex2rtf error
[wxWidgets.git] / docs / latex / wx / menu.tex
1 \section{\class{wxMenu}}\label{wxmenu}
2
3 A menu is a popup (or pull down) list of items, one of which may be
4 selected before the menu goes away (clicking elsewhere dismisses the
5 menu). Menus may be used to construct either menu bars or popup menus.
6
7 A menu item has an integer ID associated with it which can be used to
8 identify the selection, or to change the menu item in some way. A menu item
9 with a special identifier $-1$ is a separator item and doesn't have an
10 associated command but just makes a separator line appear in the menu.
11
12 Menu items may be either normal items, check items or radio items. Normal items
13 don't have any special properties while the check items have a boolean flag
14 associated to them and they show a checkmark in the menu when the flag is set.
15 wxWindows automatically toggles the flag value when the item is clicked and its
16 value may be retrieved using either \helpref{IsChecked}{wxmenuischecked} method
17 of wxMenu or wxMenuBar itself or by using
18 \helpref{wxEvent::IsChecked}{wxcommandeventischecked} when you get the menu
19 notification for the item in question.
20
21 The radio items are similar to the check items except that all the other items
22 in the same radio group are unchecked when a radio item is checked. The radio
23 group is formed by a contiguous range of radio items, i.e. it starts at the
24 first item of this kind and ends with the first item of a different kind (or
25 the end of the menu). Notice that because the radio groups are defined in terms
26 of the item positions inserting or removing the items in the menu containing
27 the radio items risks to not work correctly. Finally note that the radio items
28 are only supported under Windows and GTK+ currently.
29
30 \wxheading{Allocation strategy}
31
32 All menus except the popup ones must be created on the heap. All menus
33 attached to a menubar or to another menu will be deleted by their parent when
34 it is deleted. As the frame menubar is deleted by the frame itself, it means
35 that normally all menus used are deleted automatically.
36
37 \wxheading{Derived from}
38
39 \helpref{wxEvtHandler}{wxevthandler}\\
40 \helpref{wxObject}{wxobject}
41
42 \wxheading{Include files}
43
44 <wx/menu.h>
45
46 \wxheading{Event handling}
47
48 If the menu is part of a menubar, then \helpref{wxMenuBar}{wxmenubar} event processing is used.
49
50 With a popup menu, there is a variety of ways to handle a menu selection event
51 (wxEVT\_COMMAND\_MENU\_SELECTED).
52
53 \begin{enumerate}\itemsep=0pt
54 \item Derive a new class from wxMenu and define event table entries using the EVT\_MENU macro.
55 \item Set a new event handler for wxMenu, using an object whose class has EVT\_MENU entries.
56 \item Provide EVT\_MENU handlers in the window which pops up the menu, or in an ancestor of
57 this window.
58 \item Define a callback of type wxFunction, which you pass to the wxMenu constructor.
59 The callback takes a reference to the menu, and a reference to a
60 \helpref{wxCommandEvent}{wxcommandevent}. This method is deprecated and should
61 not be used in the new code, it is provided for backwards compatibility only.
62 \end{enumerate}
63
64 \wxheading{See also}
65
66 \helpref{wxMenuBar}{wxmenubar}, \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu},\rtfsp
67 \helpref{Event handling overview}{eventhandlingoverview}
68
69 \latexignore{\rtfignore{\wxheading{Members}}}
70
71 \membersection{wxMenu::wxMenu}\label{wxmenuconstr}
72
73 \func{}{wxMenu}{\param{const wxString\& }{title = ""}, \param{long}{ style = 0}}
74
75 Constructs a wxMenu object.
76
77 \wxheading{Parameters}
78
79 \docparam{title}{A title for the popup menu: the empty string denotes no title.}
80
81 \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
82
83 \func{}{wxMenu}{\param{long}{ style}}
84
85 Constructs a wxMenu object.
86
87 \wxheading{Parameters}
88
89 \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
90
91 \membersection{wxMenu::\destruct{wxMenu}}
92
93 \func{}{\destruct{wxMenu}}{\void}
94
95 Destructor, destroying the menu.
96
97 Note: under Motif, a popup menu must have a valid parent (the window
98 it was last popped up on) when being destroyed. Therefore, make sure
99 you delete or re-use the popup menu {\it before} destroying the
100 parent window. Re-use in this context means popping up the menu on
101 a different window from last time, which causes an implicit destruction
102 and recreation of internal data structures.
103
104 \membersection{wxMenu::Append}\label{wxmenuappend}
105
106 \func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
107 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
108
109 Adds a string item to the end of the menu.
110
111 \func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
112 \param{const wxString\& }{helpString = ""}}
113
114 Adds a pull-right submenu to the end of the menu. Append the submenu to the parent
115 menu {\it after} you have added your menu items, or accelerators may not be
116 registered properly.
117
118 \func{void}{Append}{\param{wxMenuItem*}{ menuItem}}
119
120 Adds a menu item object. This is the most generic variant of Append() method
121 because it may be used for both items (including separators) and submenus and
122 because you can also specify various extra properties of a menu item this way,
123 such as bitmaps and fonts.
124
125 \wxheading{Parameters}
126
127 \docparam{id}{The menu command identifier.}
128
129 \docparam{item}{The string to appear on the menu item.}
130
131 \docparam{menu}{Pull-right submenu.}
132
133 \docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
134 {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
135
136 \docparam{helpString}{An optional help string associated with the item.
137 By default, \helpref{wxFrame::OnMenuHighlight}{wxframeonmenuhighlight} displays
138 this string in the status line.}
139
140 \docparam{menuItem}{A menuitem object. It will be owned by the wxMenu object after this function
141 is called, so do not delete it yourself.}
142
143 \wxheading{Remarks}
144
145 This command can be used after the menu has been shown, as well as on initial
146 creation of a menu or menubar.
147
148 \wxheading{See also}
149
150 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator},\rtfsp
151 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem},\rtfsp
152 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem},\rtfsp
153 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
154 \helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp
155 \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem}
156
157 \pythonnote{In place of a single overloaded method name, wxPython
158 implements the following methods:\par
159 \indented{2cm}{\begin{twocollist}
160 \twocolitem{{\bf Append(id, string, helpStr="", checkable=FALSE)}}{}
161 \twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")}}{}
162 \twocolitem{{\bf AppendItem(aMenuItem)}}{}
163 \end{twocollist}}
164 }
165
166 \membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem}
167
168 \func{void}{AppendCheckItem}{\param{int}{ id},\rtfsp
169 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
170
171 Adds a checkable item to the end of the menu.
172
173 \wxheading{See also}
174
175 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
176 \helpref{wxMenu::InsertCheckItem}{wxmenuinsertcheckitem}
177
178 \membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem}
179
180 \func{void}{AppendRadioItem}{\param{int}{ id},\rtfsp
181 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
182
183 Adds a radio item to the end of the menu. All consequent radio items form a
184 group and when an item in the group is checked, all the others are
185 automatically unchecked.
186
187 {\bf NB:} Currently only implemented under Windows and GTK, use
188 {\tt\#if wxHAS\_RADIO\_MENU\_ITEMS} to test for availability of this feature.
189
190 \wxheading{See also}
191
192 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
193 \helpref{wxMenu::InsertRadioItem}{wxmenuinsertradioitem}
194
195 \membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
196
197 \func{void}{AppendSeparator}{\void}
198
199 Adds a separator to the end of the menu.
200
201 \wxheading{See also}
202
203 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
204 \helpref{wxMenu::InsertSeparator}{wxmenuinsertseparator}
205
206 \membersection{wxMenu::Break}\label{wxmenubreak}
207
208 \func{void}{Break}{\void}
209
210 Inserts a break in a menu, causing the next appended item to appear in a new column.
211
212 \membersection{wxMenu::Check}\label{wxmenucheck}
213
214 \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
215
216 Checks or unchecks the menu item.
217
218 \wxheading{Parameters}
219
220 \docparam{id}{The menu item identifier.}
221
222 \docparam{check}{If TRUE, the item will be checked, otherwise it will be unchecked.}
223
224 \wxheading{See also}
225
226 \helpref{wxMenu::IsChecked}{wxmenuischecked}
227
228 \membersection{wxMenu::Delete}\label{wxmenudelete}
229
230 \func{void}{Delete}{\param{int }{id}}
231
232 \func{void}{Delete}{\param{wxMenuItem *}{item}}
233
234 Deletes the menu item from the menu. If the item is a submenu, it will
235 {\bf not} be deleted. Use \helpref{Destroy}{wxmenudestroy} if you want to
236 delete a submenu.
237
238 \wxheading{Parameters}
239
240 \docparam{id}{Id of the menu item to be deleted.}
241
242 \docparam{item}{Menu item to be deleted.}
243
244 \wxheading{See also}
245
246 \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
247 \helpref{wxMenu::Destroy}{wxmenudestroy},\rtfsp
248 \helpref{wxMenu::Remove}{wxmenuremove}
249
250 \membersection{wxMenu::Destroy}\label{wxmenudestroy}
251
252 \func{void}{Destroy}{\param{int }{id}}
253
254 \func{void}{Destroy}{\param{wxMenuItem *}{item}}
255
256 Deletes the menu item from the menu. If the item is a submenu, it will
257 be deleted. Use \helpref{Remove}{wxmenuremove} if you want to keep the submenu
258 (for example, to reuse it later).
259
260 \wxheading{Parameters}
261
262 \docparam{id}{Id of the menu item to be deleted.}
263
264 \docparam{item}{Menu item to be deleted.}
265
266 \wxheading{See also}
267
268 \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
269 \helpref{wxMenu::Deletes}{wxmenudelete},\rtfsp
270 \helpref{wxMenu::Remove}{wxmenuremove}
271
272 \membersection{wxMenu::Enable}\label{wxmenuenable}
273
274 \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
275
276 Enables or disables (greys out) a menu item.
277
278 \wxheading{Parameters}
279
280 \docparam{id}{The menu item identifier.}
281
282 \docparam{enable}{TRUE to enable the menu item, FALSE to disable it.}
283
284 \wxheading{See also}
285
286 \helpref{wxMenu::IsEnabled}{wxmenuisenabled}
287
288 \membersection{wxMenu::FindItem}\label{wxmenufinditem}
289
290 \constfunc{int}{FindItem}{\param{const wxString\& }{itemString}}
291
292 Finds the menu item id for a menu item string.
293
294 \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu **}{menu = NULL}}
295
296 Finds the menu item object associated with the given menu item identifier and,
297 optionally, the (sub)menu it belongs to.
298
299 \perlnote{In wxPerl this method takes just the {\tt id} parameter;
300 in scalar context it returns the associated {\tt Wx::MenuItem}, in list
301 context it returns a 2-element list {\tt ( item, submenu )}}
302
303 \wxheading{Parameters}
304
305 \docparam{itemString}{Menu item string to find.}
306
307 \docparam{id}{Menu item identifier.}
308
309 \docparam{menu}{If the pointer is not NULL, it will be filled with the items
310 parent menu (if the item was found)}
311
312 \wxheading{Return value}
313
314 First form: menu item identifier, or wxNOT\_FOUND if none is found.
315
316 Second form: returns the menu item object, or NULL if it is not found.
317
318 \wxheading{Remarks}
319
320 Any special menu codes are stripped out of source and target strings
321 before matching.
322
323 \pythonnote{The name of this method in wxPython is {\tt FindItemById}
324 and it does not support the second parameter.}
325
326 \membersection{wxMenu::GetHelpString}\label{wxmenugethelpstring}
327
328 \constfunc{wxString}{GetHelpString}{\param{int}{ id}}
329
330 Returns the help string associated with a menu item.
331
332 \wxheading{Parameters}
333
334 \docparam{id}{The menu item identifier.}
335
336 \wxheading{Return value}
337
338 The help string, or the empty string if there is no help string or the
339 item was not found.
340
341 \wxheading{See also}
342
343 \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenu::Append}{wxmenuappend}
344
345 \membersection{wxMenu::GetLabel}\label{wxmenugetlabel}
346
347 \constfunc{wxString}{GetLabel}{\param{int}{ id}}
348
349 Returns a menu item label.
350
351 \wxheading{Parameters}
352
353 \docparam{id}{The menu item identifier.}
354
355 \wxheading{Return value}
356
357 The item label, or the empty string if the item was not found.
358
359 \wxheading{See also}
360
361 \helpref{wxMenu::SetLabel}{wxmenusetlabel}
362
363 \membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount}
364
365 \constfunc{size\_t}{GetMenuItemCount}{\void}
366
367 Returns the number of items in the menu.
368
369 \membersection{wxMenu::GetMenuItems}\label{wxmenugetmenuitems}
370
371 \constfunc{wxMenuItemList\&}{GetMenuItems}{\void}
372
373 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
374 list class containing wxMenuItem pointers.
375
376 \membersection{wxMenu::GetTitle}\label{wxmenugettitle}
377
378 \constfunc{wxString}{GetTitle}{\void}
379
380 Returns the title of the menu.
381
382 \wxheading{Remarks}
383
384 This is relevant only to popup menus, use
385 \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop} for the menus in the
386 menubar.
387
388 \wxheading{See also}
389
390 \helpref{wxMenu::SetTitle}{wxmenusettitle}
391
392 \membersection{wxMenu::Insert}\label{wxmenuinsert}
393
394 \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
395
396 \func{void}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
397 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
398 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
399
400 Inserts the given {\it item} before the position {\it pos}. Inserting the item
401 at the position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same
402 as appending it.
403
404 \wxheading{See also}
405
406 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
407 \helpref{wxMenu::Prepend}{wxmenuprepend}
408
409 \membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem}
410
411 \func{void}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
412 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
413
414 Inserts a checkable item at the given position.
415
416 \wxheading{See also}
417
418 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
419 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
420
421 \membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem}
422
423 \func{void}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
424 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
425
426 Inserts a radio item at the given position.
427
428 \wxheading{See also}
429
430 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
431 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
432
433 \membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator}
434
435 \func{void}{InsertSeparator}{\param{size\_t }{pos}}
436
437 Inserts a separator at the given position.
438
439 \wxheading{See also}
440
441 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
442 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
443
444 \membersection{wxMenu::IsChecked}\label{wxmenuischecked}
445
446 \constfunc{bool}{IsChecked}{\param{int}{ id}}
447
448 Determines whether a menu item is checked.
449
450 \wxheading{Parameters}
451
452 \docparam{id}{The menu item identifier.}
453
454 \wxheading{Return value}
455
456 TRUE if the menu item is checked, FALSE otherwise.
457
458 \wxheading{See also}
459
460 \helpref{wxMenu::Check}{wxmenucheck}
461
462 \membersection{wxMenu::IsEnabled}\label{wxmenuisenabled}
463
464 \constfunc{bool}{IsEnabled}{\param{int}{ id}}
465
466 Determines whether a menu item is enabled.
467
468 \wxheading{Parameters}
469
470 \docparam{id}{The menu item identifier.}
471
472 \wxheading{Return value}
473
474 TRUE if the menu item is enabled, FALSE otherwise.
475
476 \wxheading{See also}
477
478 \helpref{wxMenu::Enable}{wxmenuenable}
479
480 \membersection{wxMenu::Prepend}\label{wxmenuprepend}
481
482 \func{bool}{Prepend}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
483
484 \func{void}{Prepend}{\param{int}{ id},\rtfsp
485 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
486 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
487
488 Inserts the given {\it item} at the position $0$.
489
490 \wxheading{See also}
491
492 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
493 \helpref{wxMenu::Inserts}{wxmenuinsert}
494
495 \membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem}
496
497 \func{void}{PrependCheckItem}{\param{int}{ id},\rtfsp
498 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
499
500 Inserts a checkable item at the position $0$.
501
502 \wxheading{See also}
503
504 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
505 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
506
507 \membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem}
508
509 \func{void}{PrependRadioItem}{\param{int}{ id},\rtfsp
510 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
511
512 Inserts a radio item at the position $0$.
513
514 \wxheading{See also}
515
516 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
517 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
518
519 \membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator}
520
521 \func{void}{PrependSeparator}{\param{size\_t }{pos}}
522
523 Inserts a separator at the position $0$.
524
525 \wxheading{See also}
526
527 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
528 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
529
530 \membersection{wxMenu::Remove}\label{wxmenuremove}
531
532 \func{wxMenuItem *}{Remove}{\param{int }{id}}
533
534 \func{wxMenuItem *}{Remove}{\param{wxMenuItem *}{item}}
535
536 Removes the menu item from the menu but doesn't delete the associated C++
537 object. This allows to reuse the same item later by adding it back to the menu
538 (especially useful with submenus).
539
540 \wxheading{Parameters}
541
542 \docparam{id}{The identifier of the menu item to remove.}
543
544 \docparam{item}{The menu item to remove.}
545
546 \wxheading{Return value}
547
548 The item which was detached from the menu.
549
550 \membersection{wxMenu::SetHelpString}\label{wxmenusethelpstring}
551
552 \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
553
554 Sets an item's help string.
555
556 \wxheading{Parameters}
557
558 \docparam{id}{The menu item identifier.}
559
560 \docparam{helpString}{The help string to set.}
561
562 \wxheading{See also}
563
564 \helpref{wxMenu::GetHelpString}{wxmenugethelpstring}
565
566 \membersection{wxMenu::SetLabel}\label{wxmenusetlabel}
567
568 \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
569
570 Sets the label of a menu item.
571
572 \wxheading{Parameters}
573
574 \docparam{id}{The menu item identifier.}
575
576 \docparam{label}{The menu item label to set.}
577
578 \wxheading{See also}
579
580 \helpref{wxMenu::Append}{wxmenuappend}, \helpref{wxMenu::GetLabel}{wxmenugetlabel}
581
582 \membersection{wxMenu::SetTitle}\label{wxmenusettitle}
583
584 \func{void}{SetTitle}{\param{const wxString\& }{title}}
585
586 Sets the title of the menu.
587
588 \wxheading{Parameters}
589
590 \docparam{title}{The title to set.}
591
592 \wxheading{Remarks}
593
594 This is relevant only to popup menus, use
595 \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop} for the menus in the
596 menubar.
597
598 \wxheading{See also}
599
600 \helpref{wxMenu::GetTitle}{wxmenugettitle}
601
602 \membersection{wxMenu::UpdateUI}\label{wxmenuupdateui}
603
604 \constfunc{void}{UpdateUI}{\param{wxEvtHandler*}{ source = NULL}}
605
606 Sends events to {\it source} (or owning window if NULL) to update the
607 menu UI. This is called just before the menu is popped up with \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu}, but
608 the application may call it at other times if required.
609
610 \wxheading{See also}
611
612 \helpref{wxUpdateUIEvent}{wxupdateuievent}
613
614 \section{\class{wxMenuBar}}\label{wxmenubar}
615
616 A menu bar is a series of menus accessible from the top of a frame.
617
618 \wxheading{Derived from}
619
620 \helpref{wxEvtHandler}{wxevthandler}\\
621 \helpref{wxObject}{wxobject}
622
623 \wxheading{Include files}
624
625 <wx/menu.h>
626
627 \wxheading{Event handling}
628
629 To respond to a menu selection, provide a handler for EVT\_MENU, in the frame
630 that contains the menu bar. If you have a toolbar which uses the same identifiers
631 as your EVT\_MENU entries, events from the toolbar will also be processed by your
632 EVT\_MENU event handlers.
633
634 Note that menu commands (and UI update events for menus) are first sent to
635 the focus window within the frame. If no window within the frame has the focus,
636 then the events are sent directly to the frame. This allows command and UI update
637 handling to be processed by specific windows and controls, and not necessarily
638 by the application frame.
639
640 {\bf Tip:} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
641 are not working, check any EVT\_CHAR events you are handling in child windows.
642 If you are not calling {\tt event.Skip()} for events that you don't process in these event handlers,
643 menu shortcuts may cease to work.
644
645 \wxheading{See also}
646
647 \helpref{wxMenu}{wxmenu}, \helpref{Event handling overview}{eventhandlingoverview}
648
649 \latexignore{\rtfignore{\wxheading{Members}}}
650
651 \membersection{wxMenuBar::wxMenuBar}\label{wxmenubarconstr}
652
653 \func{void}{wxMenuBar}{\param{long }{style = 0}}
654
655 Default constructor.
656
657 \func{void}{wxMenuBar}{\param{int}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}}
658
659 Construct a menu bar from arrays of menus and titles.
660
661 \wxheading{Parameters}
662
663 \docparam{n}{The number of menus.}
664
665 \docparam{menus}{An array of menus. Do not use this array again - it now belongs to the
666 menu bar.}
667
668 \docparam{titles}{An array of title strings. Deallocate this array after creating the menu bar.}
669
670 \docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).}
671
672 \pythonnote{Only the default constructor is supported in wxPython.
673 Use wxMenuBar.Append instead.}
674
675 \perlnote{wxPerl only supports the first constructor:
676 use {\tt Append} instead.}
677
678 \membersection{wxMenuBar::\destruct{wxMenuBar}}
679
680 \func{void}{\destruct{wxMenuBar}}{\void}
681
682 Destructor, destroying the menu bar and removing it from the parent frame (if any).
683
684 \membersection{wxMenuBar::Append}\label{wxmenubarappend}
685
686 \func{bool}{Append}{\param{wxMenu *}{menu}, \param{const wxString\& }{title}}
687
688 Adds the item to the end of the menu bar.
689
690 \wxheading{Parameters}
691
692 \docparam{menu}{The menu to add. Do not deallocate this menu after calling {\bf Append}.}
693
694 \docparam{title}{The title of the menu.}
695
696 \wxheading{Return value}
697
698 TRUE on success, FALSE if an error occurred.
699
700 \wxheading{See also}
701
702 \helpref{wxMenuBar::Insert}{wxmenubarinsert}
703
704 \membersection{wxMenuBar::Check}\label{wxmenubarcheck}
705
706 \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
707
708 Checks or unchecks a menu item.
709
710 \wxheading{Parameters}
711
712 \docparam{id}{The menu item identifier.}
713
714 \docparam{check}{If TRUE, checks the menu item, otherwise the item is unchecked.}
715
716 \wxheading{Remarks}
717
718 Only use this when the menu bar has been associated
719 with a frame; otherwise, use the wxMenu equivalent call.
720
721 \membersection{wxMenuBar::Enable}\label{wxmenubarenable}
722
723 \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
724
725 Enables or disables (greys out) a menu item.
726
727 \wxheading{Parameters}
728
729 \docparam{id}{The menu item identifier.}
730
731 \docparam{enable}{TRUE to enable the item, FALSE to disable it.}
732
733 \wxheading{Remarks}
734
735 Only use this when the menu bar has been
736 associated with a frame; otherwise, use the wxMenu equivalent call.
737
738 \membersection{wxMenuBar::EnableTop}\label{wxmenubarenabletop}
739
740 \func{void}{EnableTop}{\param{int}{ pos}, \param{const bool}{ enable}}
741
742 Enables or disables a whole menu.
743
744 \wxheading{Parameters}
745
746 \docparam{pos}{The position of the menu, starting from zero.}
747
748 \docparam{enable}{TRUE to enable the menu, FALSE to disable it.}
749
750 \wxheading{Remarks}
751
752 Only use this when the menu bar has been
753 associated with a frame.
754
755 \membersection{wxMenuBar::FindMenu}\label{wxmenubarfindmenu}
756
757 \constfunc{int}{FindMenu}{\param{const wxString\& }{title}}
758
759 Returns the index of the menu with the given {\it title} or wxNOT\_FOUND if no
760 such menu exists in this menubar. The {\it title} parameter may specify either
761 the menu title (with accelerator characters, i.e. {\tt "\&File"}) or just the
762 menu label ({\tt "File"}) indifferently.
763
764 \membersection{wxMenuBar::FindMenuItem}\label{wxmenubarfindmenuitem}
765
766 \constfunc{int}{FindMenuItem}{\param{const wxString\& }{menuString}, \param{const wxString\& }{itemString}}
767
768 Finds the menu item id for a menu name/menu item string pair.
769
770 \wxheading{Parameters}
771
772 \docparam{menuString}{Menu title to find.}
773
774 \docparam{itemString}{Item to find.}
775
776 \wxheading{Return value}
777
778 The menu item identifier, or wxNOT\_FOUND if none was found.
779
780 \wxheading{Remarks}
781
782 Any special menu codes are stripped out of source and target strings
783 before matching.
784
785 \membersection{wxMenuBar::FindItem}\label{wxmenubarfinditem}
786
787 \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu}{ **menu = NULL}}
788
789 Finds the menu item object associated with the given menu item identifier.
790
791 \wxheading{Parameters}
792
793 \docparam{id}{Menu item identifier.}
794
795 \docparam{menu}{If not NULL, menu will get set to the associated menu.}
796
797 \wxheading{Return value}
798
799 The found menu item object, or NULL if one was not found.
800
801 \membersection{wxMenuBar::GetHelpString}\label{wxmenubargethelpstring}
802
803 \constfunc{wxString}{GetHelpString}{\param{int}{ id}}
804
805 Gets the help string associated with the menu item identifier.
806
807 \wxheading{Parameters}
808
809 \docparam{id}{The menu item identifier.}
810
811 \wxheading{Return value}
812
813 The help string, or the empty string if there was no help string or the menu item
814 was not found.
815
816 \wxheading{See also}
817
818 \helpref{wxMenuBar::SetHelpString}{wxmenubarsethelpstring}
819
820 \membersection{wxMenuBar::GetLabel}\label{wxmenubargetlabel}
821
822 \constfunc{wxString}{GetLabel}{\param{int}{ id}}
823
824 Gets the label associated with a menu item.
825
826 \wxheading{Parameters}
827
828 \docparam{id}{The menu item identifier.}
829
830 \wxheading{Return value}
831
832 The menu item label, or the empty string if the item was not found.
833
834 \wxheading{Remarks}
835
836 Use only after the menubar has been associated with a frame.
837
838 \membersection{wxMenuBar::GetLabelTop}\label{wxmenubargetlabeltop}
839
840 \constfunc{wxString}{GetLabelTop}{\param{int}{ pos}}
841
842 Returns the label of a top-level menu. Note that the returned string does not
843 include the accelerator characters which could have been specified in the menu
844 title string during its construction.
845
846 \wxheading{Parameters}
847
848 \docparam{pos}{Position of the menu on the menu bar, starting from zero.}
849
850 \wxheading{Return value}
851
852 The menu label, or the empty string if the menu was not found.
853
854 \wxheading{Remarks}
855
856 Use only after the menubar has been associated with a frame.
857
858 \wxheading{See also}
859
860 \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop}
861
862 \membersection{wxMenuBar::GetMenu}\label{wxmenubargetmenu}
863
864 \constfunc{wxMenu*}{GetMenu}{\param{int}{ menuIndex}}
865
866 Returns the menu at {\it menuIndex} (zero-based).
867
868 \membersection{wxMenuBar::GetMenuCount}\label{wxmenubargetmenucount}
869
870 \constfunc{int}{GetMenuCount}{\void}
871
872 Returns the number of menus in this menubar.
873
874 \membersection{wxMenuBar::Insert}\label{wxmenubarinsert}
875
876 \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
877
878 Inserts the menu at the given position into the menu bar. Inserting menu at
879 position $0$ will insert it in the very beginning of it, inserting at position
880 \helpref{GetMenuCount()}{wxmenubargetmenucount} is the same as calling
881 \helpref{Append()}{wxmenubarappend}.
882
883 \wxheading{Parameters}
884
885 \docparam{pos}{The position of the new menu in the menu bar}
886
887 \docparam{menu}{The menu to add. wxMenuBar owns the menu and will free it.}
888
889 \docparam{title}{The title of the menu.}
890
891 \wxheading{Return value}
892
893 TRUE on success, FALSE if an error occurred.
894
895 \wxheading{See also}
896
897 \helpref{wxMenuBar::Append}{wxmenubarappend}
898
899 \membersection{wxMenuBar::IsChecked}\label{wxmenubarischecked}
900
901 \constfunc{bool}{IsChecked}{\param{int}{ id}}
902
903 Determines whether an item is checked.
904
905 \wxheading{Parameters}
906
907 \docparam{id}{The menu item identifier.}
908
909 \wxheading{Return value}
910
911 TRUE if the item was found and is checked, FALSE otherwise.
912
913 \membersection{wxMenuBar::IsEnabled}\label{wxmenubarisenabled}
914
915 \constfunc{bool}{IsEnabled}{\param{int}{ id}}
916
917 Determines whether an item is enabled.
918
919 \wxheading{Parameters}
920
921 \docparam{id}{The menu item identifier.}
922
923 \wxheading{Return value}
924
925 TRUE if the item was found and is enabled, FALSE otherwise.
926
927 \membersection{wxMenuBar::Refresh}\label{wxmenubarrefresh}
928
929 \func{void}{Refresh}{\void}
930
931 Redraw the menu bar
932
933 \membersection{wxMenuBar::Remove}\label{wxmenubarremove}
934
935 \func{wxMenu *}{Remove}{\param{size\_t }{pos}}
936
937 Removes the menu from the menu bar and returns the menu object - the caller is
938 responsible for deleting it. This function may be used together with
939 \helpref{wxMenuBar::Insert}{wxmenubarinsert} to change the menubar
940 dynamically.
941
942 \wxheading{See also}
943
944 \helpref{wxMenuBar::Replace}{wxmenubarreplace}
945
946 \membersection{wxMenuBar::Replace}\label{wxmenubarreplace}
947
948 \func{wxMenu *}{Replace}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
949
950 Replaces the menu at the given position with another one.
951
952 \wxheading{Parameters}
953
954 \docparam{pos}{The position of the new menu in the menu bar}
955
956 \docparam{menu}{The menu to add.}
957
958 \docparam{title}{The title of the menu.}
959
960 \wxheading{Return value}
961
962 The menu which was previously at the position {\it pos}. The caller is
963 responsible for deleting it.
964
965 \wxheading{See also}
966
967 \helpref{wxMenuBar::Insert}{wxmenubarinsert},\rtfsp
968 \helpref{wxMenuBar::Remove}{wxmenubarremove}
969
970 \membersection{wxMenuBar::SetHelpString}\label{wxmenubarsethelpstring}
971
972 \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
973
974 Sets the help string associated with a menu item.
975
976 \wxheading{Parameters}
977
978 \docparam{id}{Menu item identifier.}
979
980 \docparam{helpString}{Help string to associate with the menu item.}
981
982 \wxheading{See also}
983
984 \helpref{wxMenuBar::GetHelpString}{wxmenubargethelpstring}
985
986 \membersection{wxMenuBar::SetLabel}\label{wxmenubarsetlabel}
987
988 \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
989
990 Sets the label of a menu item.
991
992 \wxheading{Parameters}
993
994 \docparam{id}{Menu item identifier.}
995
996 \docparam{label}{Menu item label.}
997
998 \wxheading{Remarks}
999
1000 Use only after the menubar has been associated with a frame.
1001
1002 \wxheading{See also}
1003
1004 \helpref{wxMenuBar::GetLabel}{wxmenubargetlabel}
1005
1006 \membersection{wxMenuBar::SetLabelTop}\label{wxmenubarsetlabeltop}
1007
1008 \func{void}{SetLabelTop}{\param{int}{ pos}, \param{const wxString\& }{label}}
1009
1010 Sets the label of a top-level menu.
1011
1012 \wxheading{Parameters}
1013
1014 \docparam{pos}{The position of a menu on the menu bar, starting from zero.}
1015
1016 \docparam{label}{The menu label.}
1017
1018 \wxheading{Remarks}
1019
1020 Use only after the menubar has been associated with a frame.
1021
1022 \wxheading{See also}
1023
1024 \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop}
1025