]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/menu.tex
Added wxDataViewTreeCtrl
[wxWidgets.git] / docs / latex / wx / menu.tex
... / ...
CommitLineData
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
14A menu is a popup (or pull down) list of items, one of which may be
15selected before the menu goes away (clicking elsewhere dismisses the
16menu). Menus may be used to construct either menu bars or popup menus.
17
18A menu item has an integer ID associated with it which can be used to
19identify the selection, or to change the menu item in some way. A menu item
20with a special identifier $-1$ is a separator item and doesn't have an
21associated 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
24predefined by wxWidgets and have a special meaning since entries
25using these IDs will be taken out of the normal menus under MacOS X
26and will be inserted into the system menu (following the appropriate
27MacOS X interface guideline). On PalmOS {\it wxID\_EXIT} is disabled according
28to Palm OS Companion guidelines.
29
30Menu items may be either normal items, check items or radio items. Normal items
31don't have any special properties while the check items have a boolean flag
32associated to them and they show a checkmark in the menu when the flag is set.
33wxWidgets automatically toggles the flag value when the item is clicked and its
34value may be retrieved using either \helpref{IsChecked}{wxmenuischecked} method
35of wxMenu or wxMenuBar itself or by using
36\helpref{wxEvent::IsChecked}{wxcommandeventischecked} when you get the menu
37notification for the item in question.
38
39The radio items are similar to the check items except that all the other items
40in the same radio group are unchecked when a radio item is checked. The radio
41group is formed by a contiguous range of radio items, i.e. it starts at the
42first item of this kind and ends with the first item of a different kind (or
43the end of the menu). Notice that because the radio groups are defined in terms
44of the item positions inserting or removing the items in the menu containing
45the radio items risks to not work correctly. Finally note that radio items
46are not supported under Motif.
47
48\wxheading{Allocation strategy}
49
50All menus except the popup ones must be created on the heap. All menus
51attached to a menubar or to another menu will be deleted by their parent when
52it is deleted. As the frame menubar is deleted by the frame itself, it means
53that 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{Library}
65
66\helpref{wxCore}{librarieslist}
67
68\wxheading{Event handling}
69
70If the menu is part of a menubar, then \helpref{wxMenuBar}{wxmenubar} event processing is used.
71
72With a popup menu, there is a variety of ways to handle a menu selection event
73(wxEVT\_COMMAND\_MENU\_SELECTED).
74
75\begin{enumerate}\itemsep=0pt
76\item Derive a new class from wxMenu and define event table entries using the EVT\_MENU macro.
77\item Set a new event handler for wxMenu, using an object whose class has EVT\_MENU entries.
78\item Provide EVT\_MENU handlers in the window which pops up the menu, or in an ancestor of
79this window.
80\end{enumerate}
81
82\wxheading{See also}
83
84\helpref{wxMenuBar}{wxmenubar}, \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu},\rtfsp
85\helpref{Event handling overview}{eventhandlingoverview},\rtfsp
86\helpref{wxFileHistory (most recently used files menu)}{wxfilehistory}
87
88
89
90\latexignore{\rtfignore{\wxheading{Members}}}
91
92
93\membersection{wxMenu::wxMenu}\label{wxmenuctor}
94
95\func{}{wxMenu}{\param{const wxString\& }{title = ""}, \param{long}{ style = 0}}
96
97Constructs a wxMenu object.
98
99\wxheading{Parameters}
100
101\docparam{title}{A title for the popup menu: the empty string denotes no title.}
102
103\docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
104
105\func{}{wxMenu}{\param{long}{ style}}
106
107Constructs a wxMenu object.
108
109\wxheading{Parameters}
110
111\docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
112
113
114\membersection{wxMenu::\destruct{wxMenu}}\label{wxmenudtor}
115
116\func{}{\destruct{wxMenu}}{\void}
117
118Destructor, destroying the menu.
119
120Note: under Motif, a popup menu must have a valid parent (the window
121it was last popped up on) when being destroyed. Therefore, make sure
122you delete or re-use the popup menu {\it before} destroying the
123parent window. Re-use in this context means popping up the menu on
124a different window from last time, which causes an implicit destruction
125and recreation of internal data structures.
126
127
128\membersection{wxMenu::Append}\label{wxmenuappend}
129
130\func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item = ""}, \param{const wxString\& }{helpString = ""},\rtfsp
131\param{wxItemKind}{ kind = wxITEM\_NORMAL}}
132
133Adds a string item to the end of the menu.
134
135\func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
136\param{const wxString\& }{helpString = ""}}
137
138Adds a pull-right submenu to the end of the menu. Append the submenu to the parent
139menu {\it after} you have added your menu items, or accelerators may not be
140registered properly.
141
142\func{wxMenuItem*}{Append}{\param{wxMenuItem*}{ menuItem}}
143
144Adds a menu item object. This is the most generic variant of Append() method
145because it may be used for both items (including separators) and submenus and
146because you can also specify various extra properties of a menu item this way,
147such 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
157\docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
158{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
159
160\docparam{helpString}{An optional help string associated with the item.
161By default, the handler for the wxEVT\_MENU\_HIGHLIGHT event displays
162this string in the status line.}
163
164\docparam{menuItem}{A menuitem object. It will be owned by the wxMenu object after this function
165is called, so do not delete it yourself.}
166
167\wxheading{Remarks}
168
169This command can be used after the menu has been shown, as well as on initial
170creation of a menu or menubar.
171
172The {\it item} string for the normal menu items (not submenus or separators)
173may include the accelerator which can be used to activate the menu item
174from keyboard. The accelerator string follows the item label and is separated
175from it by a {\tt TAB} character ({\tt '$\backslash$t'}). Its general syntax is
176any combination of {\tt "CTRL"}, {\tt "ALT"} and {\tt "SHIFT"} strings (case
177doesn't matter) separated by either {\tt '-'} or {\tt '+'} characters and
178followed by the accelerator itself. The accelerator may be any alphanumeric
179character, any function key (from {\tt F1} to {\tt F12}) or one of the special
180characters listed in the table below (again, case doesn't matter):
181
182\begin{twocollist}\itemsep=0pt
183\twocolitem{{\tt DEL} or {\tt DELETE}}{Delete key}
184\twocolitem{{\tt INS} or {\tt INSERT}}{Insert key}
185\twocolitem{{\tt ENTER} or {\tt RETURN}}{Enter key}
186\twocolitem{{\tt PGUP}}{PageUp key}
187\twocolitem{{\tt PGDN}}{PageDown key}
188\twocolitem{{\tt LEFT}}{Left cursor arrow key}
189\twocolitem{{\tt RIGHT}}{Right cursor arrow key}
190\twocolitem{{\tt UP}}{Up cursor arrow key}
191\twocolitem{{\tt DOWN}}{Down cursor arrow key}
192\twocolitem{{\tt HOME}}{Home key}
193\twocolitem{{\tt END}}{End key}
194\twocolitem{{\tt SPACE}}{Space}
195\twocolitem{{\tt TAB}}{Tab key}
196\twocolitem{{\tt ESC} or {\tt ESCAPE}}{Escape key (Windows only)}
197\end{twocollist}
198
199\wxheading{See also}
200
201\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator},\rtfsp
202\helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem},\rtfsp
203\helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem},\rtfsp
204\helpref{wxMenu::AppendSubMenu}{wxmenuappendsubmenu},\rtfsp
205\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
206\helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp
207\helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem}
208
209\pythonnote{In place of a single overloaded method name, wxPython
210implements the following methods:
211
212\indented{2cm}{\begin{twocollist}
213\twocolitem{{\bf Append(id, string, helpStr="", checkable=false)}}{}
214\twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")}}{}
215\twocolitem{{\bf AppendItem(aMenuItem)}}{}
216\end{twocollist}}
217}
218
219
220\membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem}
221
222\func{wxMenuItem*}{AppendCheckItem}{\param{int}{ id},\rtfsp
223\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
224
225Adds 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
232
233\membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem}
234
235\func{wxMenuItem*}{AppendRadioItem}{\param{int}{ id},\rtfsp
236\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
237
238Adds a radio item to the end of the menu. All consequent radio items form a
239group and when an item in the group is checked, all the others are
240automatically unchecked.
241
242\wxheading{See also}
243
244\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
245\helpref{wxMenu::InsertRadioItem}{wxmenuinsertradioitem}
246
247
248\membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
249
250\func{wxMenuItem*}{AppendSeparator}{\void}
251
252Adds a separator to the end of the menu.
253
254\wxheading{See also}
255
256\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
257\helpref{wxMenu::InsertSeparator}{wxmenuinsertseparator}
258
259
260\membersection{wxMenu::AppendSubMenu}\label{wxmenuappendsubmenu}
261
262\func{wxMenuItem *}{AppendSubMenu}{\param{wxMenu *}{submenu}, \param{const wxString\& }{text}, \param{const wxString\& }{help = wxEmptyString}}
263
264Adds the given \arg{submenu} to this menu. \arg{text} is the text shown in the
265menu for it and \arg{help} is the help string shown in the status bar when the
266submenu item is selected.
267
268
269\membersection{wxMenu::Break}\label{wxmenubreak}
270
271\func{void}{Break}{\void}
272
273Inserts a break in a menu, causing the next appended item to appear in a new column.
274
275
276\membersection{wxMenu::Check}\label{wxmenucheck}
277
278\func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
279
280Checks or unchecks the menu item.
281
282\wxheading{Parameters}
283
284\docparam{id}{The menu item identifier.}
285
286\docparam{check}{If true, the item will be checked, otherwise it will be unchecked.}
287
288\wxheading{See also}
289
290\helpref{wxMenu::IsChecked}{wxmenuischecked}
291
292
293\membersection{wxMenu::Delete}\label{wxmenudelete}
294
295\func{void}{Delete}{\param{int }{id}}
296
297\func{void}{Delete}{\param{wxMenuItem *}{item}}
298
299Deletes the menu item from the menu. If the item is a submenu, it will
300{\bf not} be deleted. Use \helpref{Destroy}{wxmenudestroy} if you want to
301delete a submenu.
302
303\wxheading{Parameters}
304
305\docparam{id}{Id of the menu item to be deleted.}
306
307\docparam{item}{Menu item to be deleted.}
308
309\wxheading{See also}
310
311\helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
312\helpref{wxMenu::Destroy}{wxmenudestroy},\rtfsp
313\helpref{wxMenu::Remove}{wxmenuremove}
314
315
316\membersection{wxMenu::Destroy}\label{wxmenudestroy}
317
318\func{void}{Destroy}{\param{int }{id}}
319
320\func{void}{Destroy}{\param{wxMenuItem *}{item}}
321
322Deletes the menu item from the menu. If the item is a submenu, it will
323be deleted. Use \helpref{Remove}{wxmenuremove} if you want to keep the submenu
324(for example, to reuse it later).
325
326\wxheading{Parameters}
327
328\docparam{id}{Id of the menu item to be deleted.}
329
330\docparam{item}{Menu item to be deleted.}
331
332\wxheading{See also}
333
334\helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
335\helpref{wxMenu::Deletes}{wxmenudelete},\rtfsp
336\helpref{wxMenu::Remove}{wxmenuremove}
337
338
339\membersection{wxMenu::Enable}\label{wxmenuenable}
340
341\func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
342
343Enables or disables (greys out) a menu item.
344
345\wxheading{Parameters}
346
347\docparam{id}{The menu item identifier.}
348
349\docparam{enable}{true to enable the menu item, false to disable it.}
350
351\wxheading{See also}
352
353\helpref{wxMenu::IsEnabled}{wxmenuisenabled}
354
355
356\membersection{wxMenu::FindItem}\label{wxmenufinditem}
357
358\constfunc{int}{FindItem}{\param{const wxString\& }{itemString}}
359
360Finds the menu item id for a menu item string.
361
362\constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu **}{menu = NULL}}
363
364Finds the menu item object associated with the given menu item identifier and,
365optionally, the (sub)menu it belongs to.
366
367\perlnote{In wxPerl this method takes just the {\tt id} parameter;
368in scalar context it returns the associated {\tt Wx::MenuItem}, in list
369context it returns a 2-element list {\tt ( item, submenu )}}
370
371\wxheading{Parameters}
372
373\docparam{itemString}{Menu item string to find.}
374
375\docparam{id}{Menu item identifier.}
376
377\docparam{menu}{If the pointer is not NULL, it will be filled with the item's
378parent menu (if the item was found)}
379
380\wxheading{Return value}
381
382First form: menu item identifier, or {\tt wxNOT\_FOUND} if none is found.
383
384Second form: returns the menu item object, or NULL if it is not found.
385
386\wxheading{Remarks}
387
388Any special menu codes are stripped out of source and target strings
389before matching.
390
391\pythonnote{The name of this method in wxPython is {\tt FindItemById}
392and it does not support the second parameter.}
393
394
395\membersection{wxMenu::FindItemByPosition}\label{wxmenufinditembyposition}
396
397\constfunc{wxMenuItem*}{FindItemByPosition}{\param{size\_t }{position}}
398
399Returns the wxMenuItem given a position in the menu.
400
401
402\membersection{wxMenu::GetHelpString}\label{wxmenugethelpstring}
403
404\constfunc{wxString}{GetHelpString}{\param{int}{ id}}
405
406Returns the help string associated with a menu item.
407
408\wxheading{Parameters}
409
410\docparam{id}{The menu item identifier.}
411
412\wxheading{Return value}
413
414The help string, or the empty string if there is no help string or the
415item was not found.
416
417\wxheading{See also}
418
419\helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenu::Append}{wxmenuappend}
420
421
422\membersection{wxMenu::GetLabel}\label{wxmenugetlabel}
423
424\constfunc{wxString}{GetLabel}{\param{int}{ id}}
425
426Returns a menu item label.
427
428\wxheading{Parameters}
429
430\docparam{id}{The menu item identifier.}
431
432\wxheading{Return value}
433
434The item label, or the empty string if the item was not found.
435
436\wxheading{See also}
437
438\helpref{wxMenu::GetLabelText}{wxmenugetlabeltext}, \helpref{wxMenu::SetLabel}{wxmenusetlabel}
439
440
441\membersection{wxMenu::GetLabelText}\label{wxmenugetlabeltext}
442
443\constfunc{wxString}{GetLabelText}{\param{int}{ id}}
444
445Returns a menu item label, without any of the original mnemonics and accelerators.
446
447\wxheading{Parameters}
448
449\docparam{id}{The menu item identifier.}
450
451\wxheading{Return value}
452
453The item label, or the empty string if the item was not found.
454
455\wxheading{See also}
456
457\helpref{wxMenu::GetLabel}{wxmenugetlabel}, \helpref{wxMenu::SetLabel}{wxmenusetlabel}
458
459\membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount}
460
461\constfunc{size\_t}{GetMenuItemCount}{\void}
462
463Returns the number of items in the menu.
464
465
466\membersection{wxMenu::GetMenuItems}\label{wxmenugetmenuitems}
467
468\constfunc{wxMenuItemList\&}{GetMenuItems}{\void}
469
470Returns the list of items in the menu. wxMenuItemList is a pseudo-template
471list class containing wxMenuItem pointers, see \helpref{wxList}{wxlist}.
472
473
474\membersection{wxMenu::GetTitle}\label{wxmenugettitle}
475
476\constfunc{wxString}{GetTitle}{\void}
477
478Returns the title of the menu.
479
480\wxheading{Remarks}
481
482This is relevant only to popup menus, use
483\helpref{wxMenuBar::GetMenuLabel}{wxmenubargetmenulabel} for the menus in the
484menubar.
485
486\wxheading{See also}
487
488\helpref{wxMenu::SetTitle}{wxmenusettitle}
489
490
491\membersection{wxMenu::Insert}\label{wxmenuinsert}
492
493\func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
494
495\func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
496\param{const wxString\& }{ item = ""}, \param{const wxString\& }{helpString = ""},\rtfsp
497\param{wxItemKind}{ kind = wxITEM\_NORMAL}}
498
499Inserts the given {\it item} before the position {\it pos}. Inserting the item
500at position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same
501as appending it.
502
503\wxheading{See also}
504
505\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
506\helpref{wxMenu::Prepend}{wxmenuprepend}
507
508
509\membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem}
510
511\func{wxMenuItem*}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
512\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
513
514Inserts a checkable item at the given position.
515
516\wxheading{See also}
517
518\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
519\helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
520
521
522\membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem}
523
524\func{wxMenuItem*}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
525\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
526
527Inserts a radio item at the given position.
528
529\wxheading{See also}
530
531\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
532\helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
533
534
535\membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator}
536
537\func{wxMenuItem*}{InsertSeparator}{\param{size\_t }{pos}}
538
539Inserts a separator at the given position.
540
541\wxheading{See also}
542
543\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
544\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
545
546
547\membersection{wxMenu::IsChecked}\label{wxmenuischecked}
548
549\constfunc{bool}{IsChecked}{\param{int}{ id}}
550
551Determines whether a menu item is checked.
552
553\wxheading{Parameters}
554
555\docparam{id}{The menu item identifier.}
556
557\wxheading{Return value}
558
559true if the menu item is checked, false otherwise.
560
561\wxheading{See also}
562
563\helpref{wxMenu::Check}{wxmenucheck}
564
565
566\membersection{wxMenu::IsEnabled}\label{wxmenuisenabled}
567
568\constfunc{bool}{IsEnabled}{\param{int}{ id}}
569
570Determines whether a menu item is enabled.
571
572\wxheading{Parameters}
573
574\docparam{id}{The menu item identifier.}
575
576\wxheading{Return value}
577
578true if the menu item is enabled, false otherwise.
579
580\wxheading{See also}
581
582\helpref{wxMenu::Enable}{wxmenuenable}
583
584
585\membersection{wxMenu::Prepend}\label{wxmenuprepend}
586
587\func{wxMenuItem*}{Prepend}{\param{wxMenuItem *}{item}}
588
589\func{wxMenuItem*}{Prepend}{\param{int}{ id},\rtfsp
590\param{const wxString\& }{ item = ""}, \param{const wxString\& }{helpString = ""},\rtfsp
591\param{wxItemKind}{ kind = wxITEM\_NORMAL}}
592
593Inserts the given {\it item} at position $0$, i.e. before all the other
594existing items.
595
596\wxheading{See also}
597
598\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
599\helpref{wxMenu::Insert}{wxmenuinsert}
600
601
602\membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem}
603
604\func{wxMenuItem*}{PrependCheckItem}{\param{int}{ id},\rtfsp
605\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
606
607Inserts a checkable item at position $0$.
608
609\wxheading{See also}
610
611\helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
612\helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
613
614
615\membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem}
616
617\func{wxMenuItem*}{PrependRadioItem}{\param{int}{ id},\rtfsp
618\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
619
620Inserts a radio item at position $0$.
621
622\wxheading{See also}
623
624\helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
625\helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
626
627
628\membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator}
629
630\func{wxMenuItem*}{PrependSeparator}{\void}
631
632Inserts a separator at position $0$.
633
634\wxheading{See also}
635
636\helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
637\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
638
639
640\membersection{wxMenu::Remove}\label{wxmenuremove}
641
642\func{wxMenuItem *}{Remove}{\param{int }{id}}
643
644\func{wxMenuItem *}{Remove}{\param{wxMenuItem *}{item}}
645
646Removes the menu item from the menu but doesn't delete the associated C++
647object. This allows to reuse the same item later by adding it back to the menu
648(especially useful with submenus).
649
650\wxheading{Parameters}
651
652\docparam{id}{The identifier of the menu item to remove.}
653
654\docparam{item}{The menu item to remove.}
655
656\wxheading{Return value}
657
658The item which was detached from the menu.
659
660
661\membersection{wxMenu::SetHelpString}\label{wxmenusethelpstring}
662
663\func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
664
665Sets an item's help string.
666
667\wxheading{Parameters}
668
669\docparam{id}{The menu item identifier.}
670
671\docparam{helpString}{The help string to set.}
672
673\wxheading{See also}
674
675\helpref{wxMenu::GetHelpString}{wxmenugethelpstring}
676
677
678\membersection{wxMenu::SetLabel}\label{wxmenusetlabel}
679
680\func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
681
682Sets the label of a menu item.
683
684\wxheading{Parameters}
685
686\docparam{id}{The menu item identifier.}
687
688\docparam{label}{The menu item label to set.}
689
690\wxheading{See also}
691
692\helpref{wxMenu::Append}{wxmenuappend}, \helpref{wxMenu::GetLabel}{wxmenugetlabel}
693
694
695\membersection{wxMenu::SetTitle}\label{wxmenusettitle}
696
697\func{void}{SetTitle}{\param{const wxString\& }{title}}
698
699Sets the title of the menu.
700
701\wxheading{Parameters}
702
703\docparam{title}{The title to set.}
704
705\wxheading{Remarks}
706
707This is relevant only to popup menus, use
708\helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop} for the menus in the
709menubar.
710
711\wxheading{See also}
712
713\helpref{wxMenu::GetTitle}{wxmenugettitle}
714
715
716\membersection{wxMenu::UpdateUI}\label{wxmenuupdateui}
717
718\constfunc{void}{UpdateUI}{\param{wxEvtHandler*}{ source = NULL}}
719
720Sends events to {\it source} (or owning window if NULL) to update the
721menu UI. This is called just before the menu is popped up with \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu}, but
722the application may call it at other times if required.
723
724\wxheading{See also}
725
726\helpref{wxUpdateUIEvent}{wxupdateuievent}
727
728\section{\class{wxMenuBar}}\label{wxmenubar}
729
730A menu bar is a series of menus accessible from the top of a frame.
731
732\wxheading{Derived from}
733
734\helpref{wxWindow}{wxwindow}\\
735\helpref{wxEvtHandler}{wxevthandler}\\
736\helpref{wxObject}{wxobject}
737
738\wxheading{Include files}
739
740<wx/menu.h>
741
742\wxheading{Library}
743
744\helpref{wxCore}{librarieslist}
745
746\wxheading{Event handling}
747
748To respond to a menu selection, provide a handler for EVT\_MENU, in the frame
749that contains the menu bar. If you have a toolbar which uses the same identifiers
750as your EVT\_MENU entries, events from the toolbar will also be processed by your
751EVT\_MENU event handlers.
752
753{\bf Tip:} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
754are not working, check any EVT\_CHAR events you are handling in child windows.
755If you are not calling {\tt event.Skip()} for events that you don't process in these event handlers,
756menu shortcuts may cease to work.
757
758\wxheading{See also}
759
760\helpref{wxMenu}{wxmenu}, \helpref{Event handling overview}{eventhandlingoverview}
761
762\latexignore{\rtfignore{\wxheading{Members}}}
763
764
765\membersection{wxMenuBar::wxMenuBar}\label{wxmenubarctor}
766
767\func{}{wxMenuBar}{\param{long }{style = 0}}
768
769Default constructor.
770
771\func{}{wxMenuBar}{\param{size\_t}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}, \param{long }{style = 0}}
772
773Construct a menu bar from arrays of menus and titles.
774
775\wxheading{Parameters}
776
777\docparam{n}{The number of menus.}
778
779\docparam{menus}{An array of menus. Do not use this array again - it now belongs to the
780menu bar.}
781
782\docparam{titles}{An array of title strings. Deallocate this array after creating the menu bar.}
783
784\docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).}
785
786\pythonnote{Only the default constructor is supported in wxPython.
787Use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
788
789\perlnote{wxPerl only supports the first constructor:
790use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
791
792
793\membersection{wxMenuBar::\destruct{wxMenuBar}}\label{wxmenubardtor}
794
795\func{void}{\destruct{wxMenuBar}}{\void}
796
797Destructor, destroying the menu bar and removing it from the parent frame (if any).
798
799
800\membersection{wxMenuBar::Append}\label{wxmenubarappend}
801
802\func{bool}{Append}{\param{wxMenu *}{menu}, \param{const wxString\& }{title}}
803
804Adds the item to the end of the menu bar.
805
806\wxheading{Parameters}
807
808\docparam{menu}{The menu to add. Do not deallocate this menu after calling {\bf Append}.}
809
810\docparam{title}{The title of the menu.}
811
812\wxheading{Return value}
813
814true on success, false if an error occurred.
815
816\wxheading{See also}
817
818\helpref{wxMenuBar::Insert}{wxmenubarinsert}
819
820
821\membersection{wxMenuBar::Check}\label{wxmenubarcheck}
822
823\func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
824
825Checks or unchecks a menu item.
826
827\wxheading{Parameters}
828
829\docparam{id}{The menu item identifier.}
830
831\docparam{check}{If true, checks the menu item, otherwise the item is unchecked.}
832
833\wxheading{Remarks}
834
835Only use this when the menu bar has been associated
836with a frame; otherwise, use the wxMenu equivalent call.
837
838
839\membersection{wxMenuBar::Enable}\label{wxmenubarenable}
840
841\func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
842
843Enables or disables (greys out) a menu item.
844
845\wxheading{Parameters}
846
847\docparam{id}{The menu item identifier.}
848
849\docparam{enable}{true to enable the item, false to disable it.}
850
851\wxheading{Remarks}
852
853Only use this when the menu bar has been
854associated with a frame; otherwise, use the wxMenu equivalent call.
855
856
857\membersection{wxMenuBar::EnableTop}\label{wxmenubarenabletop}
858
859\func{void}{EnableTop}{\param{int}{ pos}, \param{const bool}{ enable}}
860
861Enables or disables a whole menu.
862
863\wxheading{Parameters}
864
865\docparam{pos}{The position of the menu, starting from zero.}
866
867\docparam{enable}{true to enable the menu, false to disable it.}
868
869\wxheading{Remarks}
870
871Only use this when the menu bar has been
872associated with a frame.
873
874
875\membersection{wxMenuBar::FindMenu}\label{wxmenubarfindmenu}
876
877\constfunc{int}{FindMenu}{\param{const wxString\& }{title}}
878
879Returns the index of the menu with the given {\it title} or {\tt wxNOT\_FOUND} if no
880such menu exists in this menubar. The {\it title} parameter may specify either
881the menu title (with accelerator characters, i.e. {\tt "\&File"}) or just the
882menu label ({\tt "File"}) indifferently.
883
884
885\membersection{wxMenuBar::FindMenuItem}\label{wxmenubarfindmenuitem}
886
887\constfunc{int}{FindMenuItem}{\param{const wxString\& }{menuString}, \param{const wxString\& }{itemString}}
888
889Finds the menu item id for a menu name/menu item string pair.
890
891\wxheading{Parameters}
892
893\docparam{menuString}{Menu title to find.}
894
895\docparam{itemString}{Item to find.}
896
897\wxheading{Return value}
898
899The menu item identifier, or {\tt wxNOT\_FOUND} if none was found.
900
901\wxheading{Remarks}
902
903Any special menu codes are stripped out of source and target strings
904before matching.
905
906
907\membersection{wxMenuBar::FindItem}\label{wxmenubarfinditem}
908
909\constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu}{ **menu = NULL}}
910
911Finds the menu item object associated with the given menu item identifier.
912
913\wxheading{Parameters}
914
915\docparam{id}{Menu item identifier.}
916
917\docparam{menu}{If not NULL, menu will get set to the associated menu.}
918
919\wxheading{Return value}
920
921The found menu item object, or NULL if one was not found.
922
923
924\membersection{wxMenuBar::GetHelpString}\label{wxmenubargethelpstring}
925
926\constfunc{wxString}{GetHelpString}{\param{int}{ id}}
927
928Gets the help string associated with the menu item identifier.
929
930\wxheading{Parameters}
931
932\docparam{id}{The menu item identifier.}
933
934\wxheading{Return value}
935
936The help string, or the empty string if there was no help string or the menu item
937was not found.
938
939\wxheading{See also}
940
941\helpref{wxMenuBar::SetHelpString}{wxmenubarsethelpstring}
942
943
944\membersection{wxMenuBar::GetLabel}\label{wxmenubargetlabel}
945
946\constfunc{wxString}{GetLabel}{\param{int}{ id}}
947
948Gets the label associated with a menu item.
949
950\wxheading{Parameters}
951
952\docparam{id}{The menu item identifier.}
953
954\wxheading{Return value}
955
956The menu item label, or the empty string if the item was not found.
957
958\wxheading{Remarks}
959
960Use only after the menubar has been associated with a frame.
961
962
963\membersection{wxMenuBar::GetLabelTop}\label{wxmenubargetlabeltop}
964
965\constfunc{wxString}{GetLabelTop}{\param{int}{ pos}}
966
967Returns the label of a top-level menu. Note that the returned string does not
968include the accelerator characters which could have been specified in the menu
969title string during its construction.
970
971\wxheading{Parameters}
972
973\docparam{pos}{Position of the menu on the menu bar, starting from zero.}
974
975\wxheading{Return value}
976
977The menu label, or the empty string if the menu was not found.
978
979\wxheading{Remarks}
980
981Use only after the menubar has been associated with a frame.
982
983This function is deprecated in favour of \helpref{GetMenuLabel}{wxmenubargetmenulabel} and \helpref{GetMenuLabelText}{wxmenubargetmenulabeltext}.
984
985\wxheading{See also}
986
987\helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop}
988
989
990\membersection{wxMenuBar::GetMenu}\label{wxmenubargetmenu}
991
992\constfunc{wxMenu*}{GetMenu}{\param{int}{ menuIndex}}
993
994Returns the menu at {\it menuIndex} (zero-based).
995
996
997\membersection{wxMenuBar::GetMenuCount}\label{wxmenubargetmenucount}
998
999\constfunc{size\_t}{GetMenuCount}{\void}
1000
1001Returns the number of menus in this menubar.
1002
1003
1004\membersection{wxMenuBar::GetMenuLabel}\label{wxmenubargetmenulabel}
1005
1006\constfunc{wxString}{GetMenuLabel}{\param{int}{ pos}}
1007
1008Returns the label of a top-level menu. Note that the returned string
1009includes the accelerator characters that have been specified in the menu
1010title string during its construction.
1011
1012\wxheading{Parameters}
1013
1014\docparam{pos}{Position of the menu on the menu bar, starting from zero.}
1015
1016\wxheading{Return value}
1017
1018The menu label, or the empty string if the menu was not found.
1019
1020\wxheading{Remarks}
1021
1022Use only after the menubar has been associated with a frame.
1023
1024\wxheading{See also}
1025
1026\helpref{wxMenuBar::GetMenuLabelText}{wxmenubargetmenulabeltext}, \helpref{wxMenuBar::SetMenuLabel}{wxmenubarsetmenulabel}
1027
1028
1029\membersection{wxMenuBar::GetMenuLabelText}\label{wxmenubargetmenulabeltext}
1030
1031\constfunc{wxString}{GetMenuLabelText}{\param{int}{ pos}}
1032
1033Returns the label of a top-level menu. Note that the returned string does not
1034include any accelerator characters that may have been specified in the menu
1035title string during its construction.
1036
1037\wxheading{Parameters}
1038
1039\docparam{pos}{Position of the menu on the menu bar, starting from zero.}
1040
1041\wxheading{Return value}
1042
1043The menu label, or the empty string if the menu was not found.
1044
1045\wxheading{Remarks}
1046
1047Use only after the menubar has been associated with a frame.
1048
1049\wxheading{See also}
1050
1051\helpref{wxMenuBar::GetMenuLabel}{wxmenubargetmenulabel}, \helpref{wxMenuBar::SetMenuLabel}{wxmenubarsetmenulabel}
1052
1053
1054\membersection{wxMenuBar::Insert}\label{wxmenubarinsert}
1055
1056\func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
1057
1058Inserts the menu at the given position into the menu bar. Inserting menu at
1059position $0$ will insert it in the very beginning of it, inserting at position
1060\helpref{GetMenuCount()}{wxmenubargetmenucount} is the same as calling
1061\helpref{Append()}{wxmenubarappend}.
1062
1063\wxheading{Parameters}
1064
1065\docparam{pos}{The position of the new menu in the menu bar}
1066
1067\docparam{menu}{The menu to add. wxMenuBar owns the menu and will free it.}
1068
1069\docparam{title}{The title of the menu.}
1070
1071\wxheading{Return value}
1072
1073true on success, false if an error occurred.
1074
1075\wxheading{See also}
1076
1077\helpref{wxMenuBar::Append}{wxmenubarappend}
1078
1079
1080\membersection{wxMenuBar::IsChecked}\label{wxmenubarischecked}
1081
1082\constfunc{bool}{IsChecked}{\param{int}{ id}}
1083
1084Determines whether an item is checked.
1085
1086\wxheading{Parameters}
1087
1088\docparam{id}{The menu item identifier.}
1089
1090\wxheading{Return value}
1091
1092true if the item was found and is checked, false otherwise.
1093
1094
1095\membersection{wxMenuBar::IsEnabled}\label{wxmenubarisenabled}
1096
1097\constfunc{bool}{IsEnabled}{\param{int}{ id}}
1098
1099Determines whether an item is enabled.
1100
1101\wxheading{Parameters}
1102
1103\docparam{id}{The menu item identifier.}
1104
1105\wxheading{Return value}
1106
1107true if the item was found and is enabled, false otherwise.
1108
1109
1110\membersection{wxMenuBar::Refresh}\label{wxmenubarrefresh}
1111
1112\func{void}{Refresh}{\void}
1113
1114Redraw the menu bar
1115
1116
1117\membersection{wxMenuBar::Remove}\label{wxmenubarremove}
1118
1119\func{wxMenu *}{Remove}{\param{size\_t }{pos}}
1120
1121Removes the menu from the menu bar and returns the menu object - the caller is
1122responsible for deleting it. This function may be used together with
1123\helpref{wxMenuBar::Insert}{wxmenubarinsert} to change the menubar
1124dynamically.
1125
1126\wxheading{See also}
1127
1128\helpref{wxMenuBar::Replace}{wxmenubarreplace}
1129
1130
1131\membersection{wxMenuBar::Replace}\label{wxmenubarreplace}
1132
1133\func{wxMenu *}{Replace}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
1134
1135Replaces the menu at the given position with another one.
1136
1137\wxheading{Parameters}
1138
1139\docparam{pos}{The position of the new menu in the menu bar}
1140
1141\docparam{menu}{The menu to add.}
1142
1143\docparam{title}{The title of the menu.}
1144
1145\wxheading{Return value}
1146
1147The menu which was previously at position {\it pos}. The caller is
1148responsible for deleting it.
1149
1150\wxheading{See also}
1151
1152\helpref{wxMenuBar::Insert}{wxmenubarinsert},\rtfsp
1153\helpref{wxMenuBar::Remove}{wxmenubarremove}
1154
1155
1156\membersection{wxMenuBar::SetHelpString}\label{wxmenubarsethelpstring}
1157
1158\func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
1159
1160Sets the help string associated with a menu item.
1161
1162\wxheading{Parameters}
1163
1164\docparam{id}{Menu item identifier.}
1165
1166\docparam{helpString}{Help string to associate with the menu item.}
1167
1168\wxheading{See also}
1169
1170\helpref{wxMenuBar::GetHelpString}{wxmenubargethelpstring}
1171
1172
1173\membersection{wxMenuBar::SetLabel}\label{wxmenubarsetlabel}
1174
1175\func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
1176
1177Sets the label of a menu item.
1178
1179\wxheading{Parameters}
1180
1181\docparam{id}{Menu item identifier.}
1182
1183\docparam{label}{Menu item label.}
1184
1185\wxheading{Remarks}
1186
1187Use only after the menubar has been associated with a frame.
1188
1189\wxheading{See also}
1190
1191\helpref{wxMenuBar::GetLabel}{wxmenubargetlabel}
1192
1193
1194\membersection{wxMenuBar::SetLabelTop}\label{wxmenubarsetlabeltop}
1195
1196\func{void}{SetLabelTop}{\param{int}{ pos}, \param{const wxString\& }{label}}
1197
1198Sets the label of a top-level menu.
1199
1200\wxheading{Parameters}
1201
1202\docparam{pos}{The position of a menu on the menu bar, starting from zero.}
1203
1204\docparam{label}{The menu label.}
1205
1206\wxheading{Remarks}
1207
1208Use only after the menubar has been associated with a frame.
1209
1210This function has been deprecated in favour of \helpref{SetMenuLabel}{wxmenubarsetmenulabel}.
1211
1212\wxheading{See also}
1213
1214\helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop}
1215
1216
1217\membersection{wxMenuBar::SetMenuLabel}\label{wxmenubarsetmenulabel}
1218
1219\func{void}{SetMenuLabel}{\param{int}{ pos}, \param{const wxString\& }{label}}
1220
1221Sets the label of a top-level menu.
1222
1223\wxheading{Parameters}
1224
1225\docparam{pos}{The position of a menu on the menu bar, starting from zero.}
1226
1227\docparam{label}{The menu label.}
1228
1229\wxheading{Remarks}
1230
1231Use only after the menubar has been associated with a frame.
1232
1233\wxheading{See also}
1234
1235\helpref{wxMenuBar::GetMenuLabel}{wxmenubargetmenulabel}, \helpref{wxMenuBar::GetMenuLabelText}{wxmenubargetmenulabeltext}
1236