]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxMenuItem}}\label{wxmenuitem} |
2 | ||
d65c269b VZ |
3 | A menu item represents an item in a menu. Note that you usually don't have to |
4 | deal with it directly as \helpref{wxMenu}{wxmenu} methods usually construct an | |
5 | object of this class for you. | |
6 | ||
7 | Also please note that the methods related to fonts and bitmaps are currently | |
8 | only implemented for Windows. | |
a660d684 KB |
9 | |
10 | \wxheading{Derived from} | |
11 | ||
12 | wxOwnerDrawn (Windows only)\\ | |
13 | \helpref{wxObject}{wxobject} | |
14 | ||
954b8ae6 JS |
15 | \wxheading{Include files} |
16 | ||
17 | <wx/menuitem.h> | |
18 | ||
a660d684 KB |
19 | \wxheading{See also} |
20 | ||
2432b92d | 21 | \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu} |
a660d684 KB |
22 | |
23 | \latexignore{\rtfignore{\wxheading{Members}}} | |
24 | ||
25 | \membersection{wxMenuItem::wxMenuItem}\label{wxmenuitemconstr} | |
26 | ||
27 | \func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = ID\_SEPARATOR}, | |
28 | \param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""}, | |
d65c269b | 29 | \param{wxItemKind }{kind = wxItem\_Normal}, \param{wxMenu*}{ subMenu = NULL}, } |
a660d684 KB |
30 | |
31 | Constructs a wxMenuItem object. | |
32 | ||
33 | \wxheading{Parameters} | |
34 | ||
35 | \docparam{parentMenu}{Menu that the menu item belongs to.} | |
36 | ||
37 | \docparam{id}{Identifier for this menu item, or ID\_SEPARATOR to indicate a separator.} | |
38 | ||
39 | \docparam{text}{Text for the menu item, as shown on the menu.} | |
40 | ||
41 | \docparam{helpString}{Optional help string that will be shown on the status bar.} | |
42 | ||
d65c269b VZ |
43 | \docparam{kind}{May be {\tt wxItem\_Separator}, {\tt wxItem\_Normal}, |
44 | {\tt wxItem\_Check} or {\tt wxItem\_Radio}} | |
a660d684 KB |
45 | |
46 | \docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.} | |
47 | ||
48 | \membersection{wxMenuItem::\destruct{wxMenuItem}} | |
49 | ||
50 | \func{}{\destruct{wxMenuItem}}{\void} | |
51 | ||
52 | Destructor. | |
53 | ||
54 | \membersection{wxMenuItem::Check}\label{wxmenuitemcheck} | |
55 | ||
56 | \func{void}{Check}{\param{bool}{ check}} | |
57 | ||
58 | Checks or unchecks the menu item. | |
59 | ||
60 | \membersection{wxMenuItem::DeleteSubMenu}\label{wxmenuitemdeletesubmenu} | |
61 | ||
62 | \func{void}{DeleteSubMenu}{\void} | |
63 | ||
64 | Deletes the submenu, if any. | |
65 | ||
66 | \membersection{wxMenuItem::Enable}\label{wxmenuitemenable} | |
67 | ||
68 | \func{void}{Enable}{\param{bool}{ enable}} | |
69 | ||
70 | Enables or disables the menu item. | |
71 | ||
72 | \membersection{wxMenuItem::GetBackgroundColour}\label{wxmenuitemgetbackgroundcolour} | |
73 | ||
74 | \constfunc{wxColour\&}{GetBackgroundColour}{\void} | |
75 | ||
76 | Returns the background colour associated with the menu item (Windows only). | |
77 | ||
78 | \membersection{wxMenuItem::GetBitmap}\label{wxmenuitemgetbitmap} | |
79 | ||
80 | \constfunc{wxBitmap\&}{GetBitmap}{\param{bool}{ checked = TRUE}} | |
81 | ||
82 | Returns the checked or unchecked bitmap (Windows only). | |
83 | ||
84 | \membersection{wxMenuItem::GetFont}\label{wxmenuitemgetfont} | |
85 | ||
86 | \constfunc{wxFont\&}{GetFont}{\void} | |
87 | ||
88 | Returns the font associated with the menu item (Windows only). | |
89 | ||
90 | \membersection{wxMenuItem::GetHelp}\label{wxmenuitemgethelp} | |
91 | ||
92 | \constfunc{wxString}{GetHelp}{\void} | |
93 | ||
94 | Returns the help string associated with the menu item. | |
95 | ||
96 | \membersection{wxMenuItem::GetId}\label{wxmenuitemgetid} | |
97 | ||
98 | \constfunc{int}{GetId}{\void} | |
99 | ||
100 | Returns the menu item identifier. | |
101 | ||
d65c269b VZ |
102 | \membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind} |
103 | ||
104 | \constfunc{wxItemKind}{GetKind}{\void} | |
105 | ||
106 | Returns the item kind, one of {\tt wxItem\_Separator}, {\tt wxItem\_Normal}, | |
107 | {\tt wxItem\_Check} or {\tt wxItem\_Radio}. | |
108 | ||
64a89766 VZ |
109 | \membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel} |
110 | ||
111 | \constfunc{wxString}{GetLabel}{\void} | |
112 | ||
113 | Returns the text associated with the menu item without any accelerator | |
114 | characaters it might contain. | |
115 | ||
116 | \wxheading{See also} | |
117 | ||
fa482912 | 118 | \helpref{GetText}{wxmenuitemgettext}, |
3b59cdbf VZ |
119 | \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext} |
120 | ||
121 | \membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext} | |
122 | ||
123 | \func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}} | |
124 | ||
125 | Strips all accelerator characeters and mnemonics from the given {\it text}. | |
126 | For example, | |
127 | ||
128 | \begin{verbatim} | |
129 | wxMenuItem::GetLabelFromText("&Hello\tCtrl-H"); | |
130 | \end{verbatim} | |
131 | ||
132 | will return just {\tt "Hello"}. | |
133 | ||
134 | \wxheading{See also} | |
135 | ||
fa482912 | 136 | \helpref{GetText}{wxmenuitemgettext}, |
3b59cdbf | 137 | \helpref{GetLabel}{wxmenuitemgetlabel} |
64a89766 | 138 | |
a660d684 KB |
139 | \membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth} |
140 | ||
141 | \constfunc{int}{GetMarginWidth}{\void} | |
142 | ||
143 | Gets the width of the menu item checkmark bitmap (Windows only). | |
144 | ||
145 | \membersection{wxMenuItem::GetName}\label{wxmenuitemgetname} | |
146 | ||
147 | \constfunc{wxString}{GetName}{\void} | |
148 | ||
149 | Returns the text associated with the menu item. | |
150 | ||
64a89766 VZ |
151 | {\bf NB:} this function is deprecated, please use |
152 | \helpref{GetText}{wxmenuitemgettext} or \helpref{GetLabel}{wxmenuitemgetlabel} | |
153 | instead. | |
154 | ||
155 | \membersection{wxMenuItem::GetText}\label{wxmenuitemgettext} | |
156 | ||
157 | \constfunc{wxString}{GetText}{\void} | |
158 | ||
159 | Returns the text associated with the menu item, such as it was passed to the | |
160 | wxMenuItem constructor, i.e. with any accelerator characters it may contain. | |
161 | ||
162 | \wxheading{See also} | |
163 | ||
fa482912 | 164 | \helpref{GetLabel}{wxmenuitemgetlabel}, |
3b59cdbf | 165 | \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext} |
64a89766 | 166 | |
a660d684 KB |
167 | \membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu} |
168 | ||
169 | \constfunc{wxMenu*}{GetSubMenu}{\void} | |
170 | ||
171 | Returns the submenu associated with the menu item, or NULL if there isn't one. | |
172 | ||
173 | \membersection{wxMenuItem::GetTextColour}\label{wxmenuitemgettextcolour} | |
174 | ||
175 | \constfunc{wxColour\&}{GetTextColour}{\void} | |
176 | ||
177 | Returns the text colour associated with the menu item (Windows only). | |
178 | ||
179 | \membersection{wxMenuItem::IsCheckable}\label{wxmenuitemischeckable} | |
180 | ||
181 | \constfunc{bool}{IsCheckable}{\void} | |
182 | ||
183 | Returns TRUE if the item is checkable. | |
184 | ||
185 | \membersection{wxMenuItem::IsChecked}\label{wxmenuitemischecked} | |
186 | ||
187 | \constfunc{bool}{IsChecked}{\void} | |
188 | ||
189 | Returns TRUE if the item is checked. | |
190 | ||
191 | \membersection{wxMenuItem::IsEnabled}\label{wxmenuitemisenabled} | |
192 | ||
193 | \constfunc{bool}{IsEnabled}{\void} | |
194 | ||
195 | Returns TRUE if the item is enabled. | |
196 | ||
197 | \membersection{wxMenuItem::IsSeparator}\label{wxmenuitemisseparator} | |
198 | ||
199 | \constfunc{bool}{IsSeparator}{\void} | |
200 | ||
201 | Returns TRUE if the item is a separator. | |
202 | ||
203 | \membersection{wxMenuItem::SetBackgroundColour}\label{wxmenuitemsetbackgroundcolour} | |
204 | ||
e14dccff | 205 | \constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}} |
a660d684 KB |
206 | |
207 | Sets the background colour associated with the menu item (Windows only). | |
208 | ||
0996d32a VS |
209 | \membersection{wxMenuItem::SetBitmap}\label{wxmenuitemsetbitmap} |
210 | ||
211 | \constfunc{void}{SetBitmap}{\param{const wxBitmap\& }{bmp}} | |
212 | ||
213 | Sets the bitmap for the menu item (Windows and GTK+ only). It is | |
214 | equivalent to \helpref{SetBitmaps}{wxmenuitemsetbitmaps}(bmp, wxNullBitmap). | |
215 | ||
a660d684 KB |
216 | \membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps} |
217 | ||
e14dccff KB |
218 | \constfunc{void}{SetBitmaps}{\param{const wxBitmap\& }{checked}, |
219 | \param{const wxBitmap\& }{unchecked = wxNullBitmap}} | |
a660d684 KB |
220 | |
221 | Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap | |
222 | is also used as the single bitmap for uncheckable menu items. | |
223 | ||
224 | \membersection{wxMenuItem::SetFont}\label{wxmenuitemsetfont} | |
225 | ||
e14dccff | 226 | \constfunc{void}{SetFont}{\param{const wxFont\& }{font}} |
a660d684 KB |
227 | |
228 | Sets the font associated with the menu item (Windows only). | |
229 | ||
230 | \membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp} | |
231 | ||
e14dccff | 232 | \constfunc{void}{SetHelp}{\param{const wxString\& }{helpString}} |
a660d684 KB |
233 | |
234 | Sets the help string. | |
235 | ||
236 | \membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth} | |
237 | ||
238 | \constfunc{void}{SetMarginWidth}{\param{int}{ width}} | |
239 | ||
240 | Sets the width of the menu item checkmark bitmap (Windows only). | |
241 | ||
4e6978c3 | 242 | \membersection{wxMenuItem::SetText}\label{wxmenuitemsettext} |
a660d684 | 243 | |
4e6978c3 | 244 | \constfunc{void}{SetText}{\param{const wxString\& }{text}} |
a660d684 KB |
245 | |
246 | Sets the text associated with the menu item. | |
247 | ||
248 | \membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour} | |
249 | ||
e14dccff | 250 | \constfunc{void}{SetTextColour}{\param{const wxColour\& }{colour}} |
a660d684 KB |
251 | |
252 | Sets the text colour associated with the menu item (Windows only). | |
253 |