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
}}}
25 \membersection{wxMenuItem::wxMenuItem
}\label{wxmenuitemconstr
}
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
},
}
31 Constructs a wxMenuItem object.
33 \wxheading{Parameters
}
35 \docparam{parentMenu
}{Menu that the menu item belongs to.
}
37 \docparam{id
}{Identifier for this menu item, or ID
\_SEPARATOR to indicate a separator.
}
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.
}
43 \docparam{helpString
}{Optional help string that will be shown on the status bar.
}
45 \docparam{kind
}{May be
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
46 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}}
48 \docparam{subMenu
}{If non-NULL, indicates that the menu item is a submenu.
}
50 \membersection{wxMenuItem::
\destruct{wxMenuItem
}}
52 \func{}{\destruct{wxMenuItem
}}{\void}
56 \membersection{wxMenuItem::Check
}\label{wxmenuitemcheck
}
58 \func{void
}{Check
}{\param{bool
}{ check
}}
60 Checks or unchecks the menu item.
62 \membersection{wxMenuItem::DeleteSubMenu
}\label{wxmenuitemdeletesubmenu
}
64 \func{void
}{DeleteSubMenu
}{\void}
66 Deletes the submenu, if any.
68 \membersection{wxMenuItem::Enable
}\label{wxmenuitemenable
}
70 \func{void
}{Enable
}{\param{bool
}{ enable
}}
72 Enables or disables the menu item.
74 \membersection{wxMenuItem::GetBackgroundColour
}\label{wxmenuitemgetbackgroundcolour
}
76 \constfunc{wxColour\&
}{GetBackgroundColour
}{\void}
78 Returns the background colour associated with the menu item (Windows only).
80 \membersection{wxMenuItem::GetBitmap
}\label{wxmenuitemgetbitmap
}
82 \constfunc{wxBitmap\&
}{GetBitmap
}{\param{bool
}{ checked = true
}}
84 Returns the checked or unchecked bitmap (Windows only).
86 \membersection{wxMenuItem::GetFont
}\label{wxmenuitemgetfont
}
88 \constfunc{wxFont\&
}{GetFont
}{\void}
90 Returns the font associated with the menu item (Windows only).
92 \membersection{wxMenuItem::GetHelp
}\label{wxmenuitemgethelp
}
94 \constfunc{wxString
}{GetHelp
}{\void}
96 Returns the help string associated with the menu item.
98 \membersection{wxMenuItem::GetId
}\label{wxmenuitemgetid
}
100 \constfunc{int
}{GetId
}{\void}
102 Returns the menu item identifier.
104 \membersection{wxMenuItem::GetKind
}\label{wxmenuitemgetkind
}
106 \constfunc{wxItemKind
}{GetKind
}{\void}
108 Returns the item kind, one of
{\tt wxITEM
\_SEPARATOR},
{\tt wxITEM
\_NORMAL},
109 {\tt wxITEM
\_CHECK} or
{\tt wxITEM
\_RADIO}.
111 \membersection{wxMenuItem::GetLabel
}\label{wxmenuitemgetlabel
}
113 \constfunc{wxString
}{GetLabel
}{\void}
115 Returns the text associated with the menu item without any accelerator
116 characters it might contain.
120 \helpref{GetText
}{wxmenuitemgettext
},
121 \helpref{GetLabelFromText
}{wxmenuitemgetlabelfromtext
}
123 \membersection{wxMenuItem::GetLabelFromText
}\label{wxmenuitemgetlabelfromtext
}
125 \func{static wxString
}{GetLabelFromText
}{\param{const wxString\&
}{text
}}
127 Strips all accelerator characters and mnemonics from the given
{\it text
}.
131 wxMenuItem::GetLabelFromText("&Hello
\tCtrl-H");
134 will return just
{\tt "Hello"
}.
138 \helpref{GetText
}{wxmenuitemgettext
},
139 \helpref{GetLabel
}{wxmenuitemgetlabel
}
141 \membersection{wxMenuItem::GetMarginWidth
}\label{wxmenuitemgetmarginwidth
}
143 \constfunc{int
}{GetMarginWidth
}{\void}
145 Gets the width of the menu item checkmark bitmap (Windows only).
147 \membersection{wxMenuItem::GetName
}\label{wxmenuitemgetname
}
149 \constfunc{wxString
}{GetName
}{\void}
151 Returns the text associated with the menu item.
153 {\bf NB:
} this function is deprecated, please use
154 \helpref{GetText
}{wxmenuitemgettext
} or
\helpref{GetLabel
}{wxmenuitemgetlabel
}
157 \membersection{wxMenuItem::GetText
}\label{wxmenuitemgettext
}
159 \constfunc{wxString
}{GetText
}{\void}
161 Returns the text associated with the menu item, such as it was passed to the
162 wxMenuItem constructor, i.e. with any accelerator characters it may contain.
166 \helpref{GetLabel
}{wxmenuitemgetlabel
},
167 \helpref{GetLabelFromText
}{wxmenuitemgetlabelfromtext
}
169 \membersection{wxMenuItem::GetSubMenu
}\label{wxmenuitemgetsubmenu
}
171 \constfunc{wxMenu*
}{GetSubMenu
}{\void}
173 Returns the submenu associated with the menu item, or NULL if there isn't one.
175 \membersection{wxMenuItem::GetTextColour
}\label{wxmenuitemgettextcolour
}
177 \constfunc{wxColour\&
}{GetTextColour
}{\void}
179 Returns the text colour associated with the menu item (Windows only).
181 \membersection{wxMenuItem::IsCheckable
}\label{wxmenuitemischeckable
}
183 \constfunc{bool
}{IsCheckable
}{\void}
185 Returns true if the item is checkable.
187 \membersection{wxMenuItem::IsChecked
}\label{wxmenuitemischecked
}
189 \constfunc{bool
}{IsChecked
}{\void}
191 Returns true if the item is checked.
193 \membersection{wxMenuItem::IsEnabled
}\label{wxmenuitemisenabled
}
195 \constfunc{bool
}{IsEnabled
}{\void}
197 Returns true if the item is enabled.
199 \membersection{wxMenuItem::IsSeparator
}\label{wxmenuitemisseparator
}
201 \constfunc{bool
}{IsSeparator
}{\void}
203 Returns true if the item is a separator.
205 \membersection{wxMenuItem::SetBackgroundColour
}\label{wxmenuitemsetbackgroundcolour
}
207 \constfunc{void
}{SetBackgroundColour
}{\param{const wxColour\&
}{colour
}}
209 Sets the background colour associated with the menu item (Windows only).
211 \membersection{wxMenuItem::SetBitmap
}\label{wxmenuitemsetbitmap
}
213 \constfunc{void
}{SetBitmap
}{\param{const wxBitmap\&
}{bmp
}}
215 Sets the bitmap for the menu item (Windows and GTK+ only). It is
216 equivalent to
\helpref{SetBitmaps
}{wxmenuitemsetbitmaps
}(bmp, wxNullBitmap).
218 \membersection{wxMenuItem::SetBitmaps
}\label{wxmenuitemsetbitmaps
}
220 \constfunc{void
}{SetBitmaps
}{\param{const wxBitmap\&
}{checked
},
221 \param{const wxBitmap\&
}{unchecked = wxNullBitmap
}}
223 Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap
224 is also used as the single bitmap for uncheckable menu items.
226 \membersection{wxMenuItem::SetFont
}\label{wxmenuitemsetfont
}
228 \constfunc{void
}{SetFont
}{\param{const wxFont\&
}{font
}}
230 Sets the font associated with the menu item (Windows only).
232 \membersection{wxMenuItem::SetHelp
}\label{wxmenuitemsethelp
}
234 \constfunc{void
}{SetHelp
}{\param{const wxString\&
}{helpString
}}
236 Sets the help string.
238 \membersection{wxMenuItem::SetMarginWidth
}\label{wxmenuitemsetmarginwidth
}
240 \constfunc{void
}{SetMarginWidth
}{\param{int
}{ width
}}
242 Sets the width of the menu item checkmark bitmap (Windows only).
244 \membersection{wxMenuItem::SetText
}\label{wxmenuitemsettext
}
246 \constfunc{void
}{SetText
}{\param{const wxString\&
}{text
}}
248 Sets the text associated with the menu item.
250 \membersection{wxMenuItem::SetTextColour
}\label{wxmenuitemsettextcolour
}
252 \constfunc{void
}{SetTextColour
}{\param{const wxColour\&
}{colour
}}
254 Sets the text colour associated with the menu item (Windows only).