1 \section{\class{wxMenuItem
}}\label{wxmenuitem
}
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.
7 Also please note that the methods related to fonts and bitmaps are currently
8 only implemented for Windows.
10 \wxheading{Derived from
}
12 wxOwnerDrawn (Windows only)\\
13 \helpref{wxObject
}{wxobject
}
15 \wxheading{Include files
}
21 \helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
23 \latexignore{\rtfignore{\wxheading{Members
}}}
26 \membersection{wxMenuItem::wxMenuItem
}\label{wxmenuitemctor
}
28 \func{}{wxMenuItem
}{\param{wxMenu*
}{ parentMenu = NULL
},
\param{int
}{ id = wxID
\_SEPARATOR},
29 \param{const wxString\&
}{text = ""
},
\param{const wxString\&
}{helpString = ""
},
30 \param{wxItemKind
}{kind = wxITEM
\_NORMAL},
\param{wxMenu*
}{ subMenu = NULL
}}
32 Constructs a wxMenuItem object.
34 \wxheading{Parameters
}
36 \docparam{parentMenu
}{Menu that the menu item belongs to.
}
38 \docparam{id
}{Identifier for this menu item, or wxID
\_SEPARATOR to indicate a separator.
}
40 \docparam{text
}{Text for the menu item, as shown on the menu. An accelerator
41 key can be specified using the ampersand '\&' character. In order to embed an
42 ampersand character in the menu item text, the ampersand must be doubled.
}
44 \docparam{helpString
}{Optional help string that will be shown on the status bar.
}
46 \docparam{kind
}{May be
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
47 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}}
49 \docparam{subMenu
}{If non-NULL, indicates that the menu item is a submenu.
}
52 \membersection{wxMenuItem::
\destruct{wxMenuItem
}}\label{wxmenuitemdtor
}
54 \func{}{\destruct{wxMenuItem
}}{\void}
59 \membersection{wxMenuItem::Check
}\label{wxmenuitemcheck
}
61 \func{void
}{Check
}{\param{bool
}{ check = true
}}
63 Checks or unchecks the menu item.
65 Note that this only works when the item is already appended to a menu.
68 \membersection{wxMenuItem::Enable
}\label{wxmenuitemenable
}
70 \func{void
}{Enable
}{\param{bool
}{ enable = true
}}
72 Enables or disables the menu item.
75 \membersection{wxMenuItem::GetBackgroundColour
}\label{wxmenuitemgetbackgroundcolour
}
77 \constfunc{wxColour\&
}{GetBackgroundColour
}{\void}
79 Returns the background colour associated with the menu item (Windows only).
82 \membersection{wxMenuItem::GetBitmap
}\label{wxmenuitemgetbitmap
}
84 \constfunc{wxBitmap\&
}{GetBitmap
}{\param{bool
}{ checked = true
}}
86 Returns the checked or unchecked bitmap (Windows only).
89 \membersection{wxMenuItem::GetFont
}\label{wxmenuitemgetfont
}
91 \constfunc{wxFont\&
}{GetFont
}{\void}
93 Returns the font associated with the menu item (Windows only).
96 \membersection{wxMenuItem::GetHelp
}\label{wxmenuitemgethelp
}
98 \constfunc{wxString
}{GetHelp
}{\void}
100 Returns the help string associated with the menu item.
103 \membersection{wxMenuItem::GetId
}\label{wxmenuitemgetid
}
105 \constfunc{int
}{GetId
}{\void}
107 Returns the menu item identifier.
110 \membersection{wxMenuItem::GetKind
}\label{wxmenuitemgetkind
}
112 \constfunc{wxItemKind
}{GetKind
}{\void}
114 Returns the item kind, one of
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
115 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}.
118 \membersection{wxMenuItem::GetLabel
}\label{wxmenuitemgetlabel
}
120 \constfunc{wxString
}{GetLabel
}{\void}
122 Returns the text associated with the menu item without any accelerator
123 characters it might contain.
127 \helpref{GetText
}{wxmenuitemgettext
},
128 \helpref{GetLabelFromText
}{wxmenuitemgetlabelfromtext
}
131 \membersection{wxMenuItem::GetLabelFromText
}\label{wxmenuitemgetlabelfromtext
}
133 \func{static wxString
}{GetLabelFromText
}{\param{const wxString\&
}{text
}}
135 Strips all accelerator characters and mnemonics from the given
{\it text
}.
139 wxMenuItem::GetLabelFromText("&Hello
\tCtrl-H");
142 will return just
{\tt "Hello"
}.
146 \helpref{GetText
}{wxmenuitemgettext
},
147 \helpref{GetLabel
}{wxmenuitemgetlabel
}
150 \membersection{wxMenuItem::GetMarginWidth
}\label{wxmenuitemgetmarginwidth
}
152 \constfunc{int
}{GetMarginWidth
}{\void}
154 Gets the width of the menu item checkmark bitmap (Windows only).
157 \membersection{wxMenuItem::GetName
}\label{wxmenuitemgetname
}
159 \constfunc{wxString
}{GetName
}{\void}
161 Returns the text associated with the menu item.
163 {\bf NB:
} this function is deprecated, please use
164 \helpref{GetText
}{wxmenuitemgettext
} or
\helpref{GetLabel
}{wxmenuitemgetlabel
}
168 \membersection{wxMenuItem::GetText
}\label{wxmenuitemgettext
}
170 \constfunc{wxString
}{GetText
}{\void}
172 Returns the text associated with the menu item, such as it was passed to the
173 wxMenuItem constructor, i.e. with any accelerator characters it may contain.
177 \helpref{GetLabel
}{wxmenuitemgetlabel
},
178 \helpref{GetLabelFromText
}{wxmenuitemgetlabelfromtext
}
181 \membersection{wxMenuItem::GetSubMenu
}\label{wxmenuitemgetsubmenu
}
183 \constfunc{wxMenu*
}{GetSubMenu
}{\void}
185 Returns the submenu associated with the menu item, or NULL if there isn't one.
188 \membersection{wxMenuItem::GetTextColour
}\label{wxmenuitemgettextcolour
}
190 \constfunc{wxColour\&
}{GetTextColour
}{\void}
192 Returns the text colour associated with the menu item (Windows only).
195 \membersection{wxMenuItem::IsCheckable
}\label{wxmenuitemischeckable
}
197 \constfunc{bool
}{IsCheckable
}{\void}
199 Returns true if the item is checkable.
202 \membersection{wxMenuItem::IsChecked
}\label{wxmenuitemischecked
}
204 \constfunc{bool
}{IsChecked
}{\void}
206 Returns true if the item is checked.
209 \membersection{wxMenuItem::IsEnabled
}\label{wxmenuitemisenabled
}
211 \constfunc{bool
}{IsEnabled
}{\void}
213 Returns true if the item is enabled.
216 \membersection{wxMenuItem::IsSeparator
}\label{wxmenuitemisseparator
}
218 \constfunc{bool
}{IsSeparator
}{\void}
220 Returns true if the item is a separator.
223 \membersection{wxMenuItem::IsSubMenu
}\label{wxmenuitemissubmenu
}
225 \constfunc{bool
}{IsSubMenu
}{\void}
227 Returns true if the item is a submenu.
230 \membersection{wxMenuItem::SetBackgroundColour
}\label{wxmenuitemsetbackgroundcolour
}
232 \constfunc{void
}{SetBackgroundColour
}{\param{const wxColour\&
}{colour
}}
234 Sets the background colour associated with the menu item (Windows only).
237 \membersection{wxMenuItem::SetBitmap
}\label{wxmenuitemsetbitmap
}
239 \constfunc{void
}{SetBitmap
}{\param{const wxBitmap\&
}{bmp
}}
241 Sets the bitmap for the menu item (Windows and GTK+ only). It is
242 equivalent to
\helpref{SetBitmaps
}{wxmenuitemsetbitmaps
}(bmp, wxNullBitmap).
245 \membersection{wxMenuItem::SetBitmaps
}\label{wxmenuitemsetbitmaps
}
247 \constfunc{void
}{SetBitmaps
}{\param{const wxBitmap\&
}{checked
},
248 \param{const wxBitmap\&
}{unchecked = wxNullBitmap
}}
250 Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap
251 is also used as the single bitmap for uncheckable menu items.
254 \membersection{wxMenuItem::SetFont
}\label{wxmenuitemsetfont
}
256 \constfunc{void
}{SetFont
}{\param{const wxFont\&
}{font
}}
258 Sets the font associated with the menu item (Windows only).
261 \membersection{wxMenuItem::SetHelp
}\label{wxmenuitemsethelp
}
263 \constfunc{void
}{SetHelp
}{\param{const wxString\&
}{helpString
}}
265 Sets the help string.
268 \membersection{wxMenuItem::SetMarginWidth
}\label{wxmenuitemsetmarginwidth
}
270 \constfunc{void
}{SetMarginWidth
}{\param{int
}{ width
}}
272 Sets the width of the menu item checkmark bitmap (Windows only).
275 \membersection{wxMenuItem::SetText
}\label{wxmenuitemsettext
}
277 \constfunc{void
}{SetText
}{\param{const wxString\&
}{text
}}
279 Sets the text associated with the menu item.
282 \membersection{wxMenuItem::SetTextColour
}\label{wxmenuitemsettextcolour
}
284 \constfunc{void
}{SetTextColour
}{\param{const wxColour\&
}{colour
}}
286 Sets the text colour associated with the menu item (Windows only).