1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: menuitem.tex
%% Purpose: wxMenuItem documentation
%% Author: wxWidgets Team
%% Modified by:
%% Created:
%% RCS-ID: $Id: menuitem.tex 48054 2007-08-13 17:18:08Z JS $
%% Copyright: (c) wxWidgets Team
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxMenuItem}}\label{wxmenuitem}
A menu item represents an item in a menu. Note that you usually don't have to
deal with it directly as \helpref{wxMenu}{wxmenu} methods usually construct an
object of this class for you.
Also please note that the methods related to fonts and bitmaps are currently
only implemented for Windows and GTK+.
\wxheading{Derived from}
% add wxOwnerDrawn once it is documented
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/menuitem.h>
\wxheading{See also}
\helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxMenuItem::wxMenuItem}\label{wxmenuitemctor}
\func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = wxID\_SEPARATOR},
\param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""},
\param{wxItemKind }{kind = wxITEM\_NORMAL}, \param{wxMenu*}{ subMenu = NULL}}
Constructs a wxMenuItem object.
Menu items can be standard, or ``stock menu items'', or custom. For the
standard menu items (such as commands to open a file, exit the program and so
on, see \helpref{stock items}{stockitems} for the full list) it is enough to
specify just the stock ID and leave \arg{text} and \arg{helpString} empty. In
fact, leaving at least \arg{text} empty for the stock menu items is strongly
recommended as they will have appearance and keyboard interface (including
standard accelerators) familiar to the user.
For the custom (non-stock) menu items, \arg{text} must be specified and while
\arg{helpString} may be left empty, it's recommended to pass the item
description (which is automatically shown by the library in the status bar when
the menu item is selected) in this parameter.
Finally note that you can e.g. use a stock menu label without using its stock
help string:
\begin{verbatim}
// use all stock properties:
helpMenu->Append(wxID_ABOUT);
// use the stock label and the stock accelerator but not the stock help string:
helpMenu->Append(wxID_ABOUT, wxEmptyString, wxT("My custom help string"));
// use all stock properties except for the bitmap:
wxMenuItem *mymenu = new wxMenuItem(helpMenu, wxID_ABOUT);
mymenu->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING));
helpMenu->Append(mymenu);
\end{verbatim}
that is, stock properties are set independently one from the other.
\wxheading{Parameters}
\docparam{parentMenu}{Menu that the menu item belongs to.}
\docparam{id}{Identifier for this menu item, or wxID\_SEPARATOR to indicate a separator.}
\docparam{text}{Text for the menu item, as shown on the menu. An accelerator
key can be specified using the ampersand '\&' character. In order to embed an
ampersand character in the menu item text, the ampersand must be doubled.}
\docparam{helpString}{Optional help string that will be shown on the status bar.}
\docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
\docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.}
\membersection{wxMenuItem::\destruct{wxMenuItem}}\label{wxmenuitemdtor}
\func{}{\destruct{wxMenuItem}}{\void}
Destructor.
\membersection{wxMenuItem::Check}\label{wxmenuitemcheck}
\func{void}{Check}{\param{bool}{ check = true}}
Checks or unchecks the menu item.
Note that this only works when the item is already appended to a menu.
\membersection{wxMenuItem::Enable}\label{wxmenuitemenable}
\func{void}{Enable}{\param{bool}{ enable = true}}
Enables or disables the menu item.
\membersection{wxMenuItem::GetBackgroundColour}\label{wxmenuitemgetbackgroundcolour}
\constfunc{wxColour\&}{GetBackgroundColour}{\void}
Returns the background colour associated with the menu item (Windows only).
\membersection{wxMenuItem::GetBitmap}\label{wxmenuitemgetbitmap}
\constfunc{wxBitmap\&}{GetBitmap}{\param{bool}{ checked = true}}
Returns the checked or unchecked bitmap (Windows only).
\membersection{wxMenuItem::GetFont}\label{wxmenuitemgetfont}
\constfunc{wxFont\&}{GetFont}{\void}
Returns the font associated with the menu item (Windows only).
\membersection{wxMenuItem::GetHelp}\label{wxmenuitemgethelp}
\constfunc{wxString}{GetHelp}{\void}
Returns the help string associated with the menu item.
\membersection{wxMenuItem::GetId}\label{wxmenuitemgetid}
\constfunc{int}{GetId}{\void}
Returns the menu item identifier.
\membersection{wxMenuItem::GetItemLabel}\label{wxmenuitemgetitemlabel}
\constfunc{wxString}{GetItemLabel}{\void}
Returns the text associated with the menu item including any accelerator
characters that were passed to the constructor or SetItemLabel.
\wxheading{See also}
\helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext},
\helpref{GetLabelText}{wxmenuitemgetlabeltext}
\membersection{wxMenuItem::GetItemLabelText}\label{wxmenuitemgetitemlabeltext}
\constfunc{wxString}{GetItemLabelText}{\void}
Returns the text associated with the menu item, without any accelerator
characters.
\wxheading{See also}
\helpref{GetItemLabel}{wxmenuitemgetitemlabel},
\helpref{GetLabelText}{wxmenuitemgetlabeltext}
\membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind}
\constfunc{wxItemKind}{GetKind}{\void}
Returns the item kind, one of {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}.
\membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel}
\constfunc{wxString}{GetLabel}{\void}
Returns the text associated with the menu item without any accelerator
characters it might contain.
This function is deprecated in favour of \helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext}.
\wxheading{See also}
\helpref{GetText}{wxmenuitemgettext},
\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
\membersection{wxMenuItem::GetLabelText}\label{wxmenuitemgetlabeltext}
\func{static wxString}{GetLabelText}{\param{const wxString\& }{text}}
Strips all accelerator characters and mnemonics from the given {\it text}.
For example,
\begin{verbatim}
wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
\end{verbatim}
will return just {\tt "Hello"}.
\wxheading{See also}
\helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext},
\helpref{GetItemLabel}{wxmenuitemgetitemlabel}
\membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext}
\func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}}
Strips all accelerator characters and mnemonics from the given {\it text}.
For example,
\begin{verbatim}
wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
\end{verbatim}
will return just {\tt "Hello"}.
This function is deprecated; please use \helpref{wxMenuItem::GetLabelText}{wxmenuitemgetlabeltext} instead.
\wxheading{See also}
\helpref{GetText}{wxmenuitemgettext},
\helpref{GetLabel}{wxmenuitemgetlabel}
\membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth}
\constfunc{int}{GetMarginWidth}{\void}
Gets the width of the menu item checkmark bitmap (Windows only).
\membersection{wxMenuItem::GetMenu}\label{wxmenuitemgetmenu}
\constfunc{wxMenu*}{GetMenu}{\void}
Returns the menu this menu item is in, or NULL if this menu item is not attached.
\membersection{wxMenuItem::GetName}\label{wxmenuitemgetname}
\constfunc{wxString}{GetName}{\void}
Returns the text associated with the menu item.
{\bf NB:} this function is deprecated, please use
\helpref{GetItemLabel}{wxmenuitemgetitemlabel} or \helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext}
instead.
\membersection{wxMenuItem::GetText}\label{wxmenuitemgettext}
\constfunc{wxString}{GetText}{\void}
Returns the text associated with the menu item, such as it was passed to the
wxMenuItem constructor, i.e. with any accelerator characters it may contain.
This function is deprecated in favour of \helpref{GetItemLabel}{wxmenuitemgetitemlabel}.
\wxheading{See also}
\helpref{GetLabel}{wxmenuitemgetlabel},
\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
\membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu}
\constfunc{wxMenu*}{GetSubMenu}{\void}
Returns the submenu associated with the menu item, or NULL if there isn't one.
\membersection{wxMenuItem::GetTextColour}\label{wxmenuitemgettextcolour}
\constfunc{wxColour\&}{GetTextColour}{\void}
Returns the text colour associated with the menu item (Windows only).
\membersection{wxMenuItem::IsCheckable}\label{wxmenuitemischeckable}
\constfunc{bool}{IsCheckable}{\void}
Returns true if the item is checkable.
\membersection{wxMenuItem::IsChecked}\label{wxmenuitemischecked}
\constfunc{bool}{IsChecked}{\void}
Returns true if the item is checked.
\membersection{wxMenuItem::IsEnabled}\label{wxmenuitemisenabled}
\constfunc{bool}{IsEnabled}{\void}
Returns true if the item is enabled.
\membersection{wxMenuItem::IsSeparator}\label{wxmenuitemisseparator}
\constfunc{bool}{IsSeparator}{\void}
Returns true if the item is a separator.
\membersection{wxMenuItem::IsSubMenu}\label{wxmenuitemissubmenu}
\constfunc{bool}{IsSubMenu}{\void}
Returns true if the item is a submenu.
\membersection{wxMenuItem::SetBackgroundColour}\label{wxmenuitemsetbackgroundcolour}
\constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}}
Sets the background colour associated with the menu item (Windows only).
\membersection{wxMenuItem::SetBitmap}\label{wxmenuitemsetbitmap}
\func{void}{SetBitmap}{\param{const wxBitmap\& }{bmp}}
Sets the bitmap for the menu item (Windows and GTK+ only). It is
equivalent to \helpref{SetBitmaps}{wxmenuitemsetbitmaps}(bmp, wxNullBitmap).
\membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps}
\func{void}{SetBitmaps}{\param{const wxBitmap\& }{checked},
\param{const wxBitmap\& }{unchecked = wxNullBitmap}}
Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap
is also used as the single bitmap for uncheckable menu items.
\membersection{wxMenuItem::SetFont}\label{wxmenuitemsetfont}
\func{void}{SetFont}{\param{const wxFont\& }{font}}
Sets the font associated with the menu item (Windows only).
\membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp}
\func{void}{SetHelp}{\param{const wxString\& }{helpString}}
Sets the help string.
\membersection{wxMenuItem::SetItemLabel}\label{wxmenuitemsetitemlabel}
\func{void}{SetItemLabel}{\param{const wxString\& }{label}}
Sets the label associated with the menu item.
\membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth}
\constfunc{void}{SetMarginWidth}{\param{int}{ width}}
Sets the width of the menu item checkmark bitmap (Windows only).
\membersection{wxMenuItem::SetMenu}\label{wxmenuitemsetmenu}
\func{void}{SetMenu}{\param{const wxMenu*}{menu}}
Sets the parent menu which will contain this menu item.
\membersection{wxMenuItem::SetSubMenu}\label{wxmenuitemsetsubmenu}
\func{void}{SetSubMenu}{\param{const wxMenu*}{menu}}
Sets the submenu of this menu item.
\membersection{wxMenuItem::SetText}\label{wxmenuitemsettext}
\func{void}{SetText}{\param{const wxString\& }{text}}
Sets the text associated with the menu item.
This function is deprecated in favour of \helpref{SetItemLabel}{wxmenuitemsetitemlabel}.
\membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour}
\func{void}{SetTextColour}{\param{const wxColour\& }{colour}}
Sets the text colour associated with the menu item (Windows only).
|