]>
Commit | Line | Data |
---|---|---|
1 | \section{\class{wxMenuItem}}\label{wxmenuitem} | |
2 | ||
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. | |
9 | ||
10 | \wxheading{Derived from} | |
11 | ||
12 | wxOwnerDrawn (Windows only)\\ | |
13 | \helpref{wxObject}{wxobject} | |
14 | ||
15 | \wxheading{Include files} | |
16 | ||
17 | <wx/menuitem.h> | |
18 | ||
19 | \wxheading{See also} | |
20 | ||
21 | \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu} | |
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 = ""}, | |
29 | \param{wxItemKind }{kind = wxItem\_Normal}, \param{wxMenu*}{ subMenu = NULL}, } | |
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 | ||
43 | \docparam{kind}{May be {\tt wxItem\_Separator}, {\tt wxItem\_Normal}, | |
44 | {\tt wxItem\_Check} or {\tt wxItem\_Radio}} | |
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 | ||
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 | ||
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 | characters it might contain. | |
115 | ||
116 | \wxheading{See also} | |
117 | ||
118 | \helpref{GetText}{wxmenuitemgettext}, | |
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 characters 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 | ||
136 | \helpref{GetText}{wxmenuitemgettext}, | |
137 | \helpref{GetLabel}{wxmenuitemgetlabel} | |
138 | ||
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 | ||
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 | ||
164 | \helpref{GetLabel}{wxmenuitemgetlabel}, | |
165 | \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext} | |
166 | ||
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 | ||
205 | \constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}} | |
206 | ||
207 | Sets the background colour associated with the menu item (Windows only). | |
208 | ||
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 | ||
216 | \membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps} | |
217 | ||
218 | \constfunc{void}{SetBitmaps}{\param{const wxBitmap\& }{checked}, | |
219 | \param{const wxBitmap\& }{unchecked = wxNullBitmap}} | |
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 | ||
226 | \constfunc{void}{SetFont}{\param{const wxFont\& }{font}} | |
227 | ||
228 | Sets the font associated with the menu item (Windows only). | |
229 | ||
230 | \membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp} | |
231 | ||
232 | \constfunc{void}{SetHelp}{\param{const wxString\& }{helpString}} | |
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 | ||
242 | \membersection{wxMenuItem::SetText}\label{wxmenuitemsettext} | |
243 | ||
244 | \constfunc{void}{SetText}{\param{const wxString\& }{text}} | |
245 | ||
246 | Sets the text associated with the menu item. | |
247 | ||
248 | \membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour} | |
249 | ||
250 | \constfunc{void}{SetTextColour}{\param{const wxColour\& }{colour}} | |
251 | ||
252 | Sets the text colour associated with the menu item (Windows only). | |
253 |