]>
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 = wxID\_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 wxID\_SEPARATOR to indicate a separator.} | |
38 | ||
39 | \docparam{text}{Text for the menu item, as shown on the menu. An accelerator | |
40 | key can be specified using the ampersand '\&' character. In order to embed an | |
41 | ampersand character in the menu item text, the ampersand must be doubled.} | |
42 | ||
43 | \docparam{helpString}{Optional help string that will be shown on the status bar.} | |
44 | ||
45 | \docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL}, | |
46 | {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}} | |
47 | ||
48 | \docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.} | |
49 | ||
50 | \membersection{wxMenuItem::\destruct{wxMenuItem}} | |
51 | ||
52 | \func{}{\destruct{wxMenuItem}}{\void} | |
53 | ||
54 | Destructor. | |
55 | ||
56 | \membersection{wxMenuItem::Check}\label{wxmenuitemcheck} | |
57 | ||
58 | \func{void}{Check}{\param{bool}{ check}} | |
59 | ||
60 | Checks or unchecks the menu item. | |
61 | ||
62 | \membersection{wxMenuItem::Enable}\label{wxmenuitemenable} | |
63 | ||
64 | \func{void}{Enable}{\param{bool}{ enable}} | |
65 | ||
66 | Enables or disables the menu item. | |
67 | ||
68 | \membersection{wxMenuItem::GetBackgroundColour}\label{wxmenuitemgetbackgroundcolour} | |
69 | ||
70 | \constfunc{wxColour\&}{GetBackgroundColour}{\void} | |
71 | ||
72 | Returns the background colour associated with the menu item (Windows only). | |
73 | ||
74 | \membersection{wxMenuItem::GetBitmap}\label{wxmenuitemgetbitmap} | |
75 | ||
76 | \constfunc{wxBitmap\&}{GetBitmap}{\param{bool}{ checked = true}} | |
77 | ||
78 | Returns the checked or unchecked bitmap (Windows only). | |
79 | ||
80 | \membersection{wxMenuItem::GetFont}\label{wxmenuitemgetfont} | |
81 | ||
82 | \constfunc{wxFont\&}{GetFont}{\void} | |
83 | ||
84 | Returns the font associated with the menu item (Windows only). | |
85 | ||
86 | \membersection{wxMenuItem::GetHelp}\label{wxmenuitemgethelp} | |
87 | ||
88 | \constfunc{wxString}{GetHelp}{\void} | |
89 | ||
90 | Returns the help string associated with the menu item. | |
91 | ||
92 | \membersection{wxMenuItem::GetId}\label{wxmenuitemgetid} | |
93 | ||
94 | \constfunc{int}{GetId}{\void} | |
95 | ||
96 | Returns the menu item identifier. | |
97 | ||
98 | \membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind} | |
99 | ||
100 | \constfunc{wxItemKind}{GetKind}{\void} | |
101 | ||
102 | Returns the item kind, one of {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL}, | |
103 | {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}. | |
104 | ||
105 | \membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel} | |
106 | ||
107 | \constfunc{wxString}{GetLabel}{\void} | |
108 | ||
109 | Returns the text associated with the menu item without any accelerator | |
110 | characters it might contain. | |
111 | ||
112 | \wxheading{See also} | |
113 | ||
114 | \helpref{GetText}{wxmenuitemgettext}, | |
115 | \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext} | |
116 | ||
117 | \membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext} | |
118 | ||
119 | \func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}} | |
120 | ||
121 | Strips all accelerator characters and mnemonics from the given {\it text}. | |
122 | For example, | |
123 | ||
124 | \begin{verbatim} | |
125 | wxMenuItem::GetLabelFromText("&Hello\tCtrl-H"); | |
126 | \end{verbatim} | |
127 | ||
128 | will return just {\tt "Hello"}. | |
129 | ||
130 | \wxheading{See also} | |
131 | ||
132 | \helpref{GetText}{wxmenuitemgettext}, | |
133 | \helpref{GetLabel}{wxmenuitemgetlabel} | |
134 | ||
135 | \membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth} | |
136 | ||
137 | \constfunc{int}{GetMarginWidth}{\void} | |
138 | ||
139 | Gets the width of the menu item checkmark bitmap (Windows only). | |
140 | ||
141 | \membersection{wxMenuItem::GetName}\label{wxmenuitemgetname} | |
142 | ||
143 | \constfunc{wxString}{GetName}{\void} | |
144 | ||
145 | Returns the text associated with the menu item. | |
146 | ||
147 | {\bf NB:} this function is deprecated, please use | |
148 | \helpref{GetText}{wxmenuitemgettext} or \helpref{GetLabel}{wxmenuitemgetlabel} | |
149 | instead. | |
150 | ||
151 | \membersection{wxMenuItem::GetText}\label{wxmenuitemgettext} | |
152 | ||
153 | \constfunc{wxString}{GetText}{\void} | |
154 | ||
155 | Returns the text associated with the menu item, such as it was passed to the | |
156 | wxMenuItem constructor, i.e. with any accelerator characters it may contain. | |
157 | ||
158 | \wxheading{See also} | |
159 | ||
160 | \helpref{GetLabel}{wxmenuitemgetlabel}, | |
161 | \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext} | |
162 | ||
163 | \membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu} | |
164 | ||
165 | \constfunc{wxMenu*}{GetSubMenu}{\void} | |
166 | ||
167 | Returns the submenu associated with the menu item, or NULL if there isn't one. | |
168 | ||
169 | \membersection{wxMenuItem::GetTextColour}\label{wxmenuitemgettextcolour} | |
170 | ||
171 | \constfunc{wxColour\&}{GetTextColour}{\void} | |
172 | ||
173 | Returns the text colour associated with the menu item (Windows only). | |
174 | ||
175 | \membersection{wxMenuItem::IsCheckable}\label{wxmenuitemischeckable} | |
176 | ||
177 | \constfunc{bool}{IsCheckable}{\void} | |
178 | ||
179 | Returns true if the item is checkable. | |
180 | ||
181 | \membersection{wxMenuItem::IsChecked}\label{wxmenuitemischecked} | |
182 | ||
183 | \constfunc{bool}{IsChecked}{\void} | |
184 | ||
185 | Returns true if the item is checked. | |
186 | ||
187 | \membersection{wxMenuItem::IsEnabled}\label{wxmenuitemisenabled} | |
188 | ||
189 | \constfunc{bool}{IsEnabled}{\void} | |
190 | ||
191 | Returns true if the item is enabled. | |
192 | ||
193 | \membersection{wxMenuItem::IsSeparator}\label{wxmenuitemisseparator} | |
194 | ||
195 | \constfunc{bool}{IsSeparator}{\void} | |
196 | ||
197 | Returns true if the item is a separator. | |
198 | ||
199 | \membersection{wxMenuItem::SetBackgroundColour}\label{wxmenuitemsetbackgroundcolour} | |
200 | ||
201 | \constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}} | |
202 | ||
203 | Sets the background colour associated with the menu item (Windows only). | |
204 | ||
205 | \membersection{wxMenuItem::SetBitmap}\label{wxmenuitemsetbitmap} | |
206 | ||
207 | \constfunc{void}{SetBitmap}{\param{const wxBitmap\& }{bmp}} | |
208 | ||
209 | Sets the bitmap for the menu item (Windows and GTK+ only). It is | |
210 | equivalent to \helpref{SetBitmaps}{wxmenuitemsetbitmaps}(bmp, wxNullBitmap). | |
211 | ||
212 | \membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps} | |
213 | ||
214 | \constfunc{void}{SetBitmaps}{\param{const wxBitmap\& }{checked}, | |
215 | \param{const wxBitmap\& }{unchecked = wxNullBitmap}} | |
216 | ||
217 | Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap | |
218 | is also used as the single bitmap for uncheckable menu items. | |
219 | ||
220 | \membersection{wxMenuItem::SetFont}\label{wxmenuitemsetfont} | |
221 | ||
222 | \constfunc{void}{SetFont}{\param{const wxFont\& }{font}} | |
223 | ||
224 | Sets the font associated with the menu item (Windows only). | |
225 | ||
226 | \membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp} | |
227 | ||
228 | \constfunc{void}{SetHelp}{\param{const wxString\& }{helpString}} | |
229 | ||
230 | Sets the help string. | |
231 | ||
232 | \membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth} | |
233 | ||
234 | \constfunc{void}{SetMarginWidth}{\param{int}{ width}} | |
235 | ||
236 | Sets the width of the menu item checkmark bitmap (Windows only). | |
237 | ||
238 | \membersection{wxMenuItem::SetText}\label{wxmenuitemsettext} | |
239 | ||
240 | \constfunc{void}{SetText}{\param{const wxString\& }{text}} | |
241 | ||
242 | Sets the text associated with the menu item. | |
243 | ||
244 | \membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour} | |
245 | ||
246 | \constfunc{void}{SetTextColour}{\param{const wxColour\& }{colour}} | |
247 | ||
248 | Sets the text colour associated with the menu item (Windows only). | |
249 |