]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxBitmapButton}}\label{wxbitmapbutton} |
2 | ||
3 | A bitmap button is a control that contains a bitmap. | |
4 | It may be placed on a \helpref{dialog box}{wxdialog} or \helpref{panel}{wxpanel}, or indeed | |
5 | almost any other window. | |
6 | ||
1fdc16ad | 7 | |
a660d684 KB |
8 | \wxheading{Derived from} |
9 | ||
10 | \helpref{wxButton}{wxbutton}\\ | |
11 | \helpref{wxControl}{wxcontrol}\\ | |
12 | \helpref{wxWindow}{wxwindow}\\ | |
13 | \helpref{wxEvtHandler}{wxevthandler}\\ | |
14 | \helpref{wxObject}{wxobject} | |
15 | ||
1fdc16ad | 16 | |
954b8ae6 JS |
17 | \wxheading{Include files} |
18 | ||
19 | <wx/bmpbuttn.h> | |
20 | ||
1fdc16ad | 21 | |
a660d684 KB |
22 | \wxheading{Remarks} |
23 | ||
fc2171bd | 24 | A bitmap button can be supplied with a single bitmap, and wxWidgets will draw |
a660d684 | 25 | all button states using this bitmap. If the application needs more control, additional bitmaps for |
f6bcfd97 | 26 | the selected state, unpressed focused state, and greyed-out state may be supplied. |
a660d684 | 27 | |
1fdc16ad VZ |
28 | |
29 | \wxheading{Button states} | |
30 | ||
31 | This class supports bitmaps for several different states: | |
32 | ||
33 | \twocolwidtha{5cm} | |
34 | \twocolitem{\windowstyle{normal}}{This is the bitmap shown in the default state, | |
35 | it must be always valid while all the other bitmaps are optional and don't have | |
36 | to be set.} | |
37 | \twocolitem{\windowstyle{disabled}}{Bitmap shown when the button is disabled.} | |
38 | \twocolitem{\windowstyle{selected}}{Bitmap shown when the button is pushed | |
39 | (e.g. while the user keeps the mouse button pressed on it)} | |
40 | \twocolitem{\windowstyle{focus}}{Bitmap shown when the button has keyboard | |
41 | focus but is not pressed.} | |
42 | \twocolitem{\windowstyle{hover}}{Bitmap shown when the mouse is over the | |
43 | button (but it is not pressed).} | |
44 | \end{twocollist} | |
45 | ||
46 | ||
a660d684 KB |
47 | \wxheading{Window styles} |
48 | ||
49 | \twocolwidtha{5cm} | |
50 | \begin{twocollist}\itemsep=0pt | |
51 | \twocolitem{\windowstyle{wxBU\_AUTODRAW}}{If | |
52 | this is specified, the button will be drawn automatically using the label bitmap only, providing | |
53 | a 3D-look border. If this style is not specified, the button will be drawn without borders and using all | |
f6bcfd97 BP |
54 | provided bitmaps. WIN32 only.} |
55 | \twocolitem{\windowstyle{wxBU\_LEFT}}{Left-justifies the bitmap label. WIN32 only.} | |
56 | \twocolitem{\windowstyle{wxBU\_TOP}}{Aligns the bitmap label to the top of the button. WIN32 only.} | |
57 | \twocolitem{\windowstyle{wxBU\_RIGHT}}{Right-justifies the bitmap label. WIN32 only.} | |
58 | \twocolitem{\windowstyle{wxBU\_BOTTOM}}{Aligns the bitmap label to the bottom of the button. WIN32 only.} | |
a660d684 KB |
59 | \end{twocollist} |
60 | ||
9266e0ec VZ |
61 | Note that \windowstyle{wxBU\_EXACTFIT} supported by |
62 | \helpref{wxButton}{wxbutton} is \emph{not} used by this class as bitmap buttons | |
63 | don't have any minimal standard size by default. | |
64 | ||
a660d684 KB |
65 | See also \helpref{window styles overview}{windowstyles}. |
66 | ||
1fdc16ad | 67 | |
5de76427 JS |
68 | \wxheading{Event handling} |
69 | ||
70 | \twocolwidtha{7cm} | |
71 | \begin{twocollist}\itemsep=0pt | |
72 | \twocolitem{{\bf EVT\_BUTTON(id, func)}}{Process a wxEVT\_COMMAND\_BUTTON\_CLICKED event, | |
73 | when the button is clicked.} | |
74 | \end{twocollist} | |
75 | ||
1fdc16ad | 76 | |
a660d684 KB |
77 | \wxheading{See also} |
78 | ||
79 | \helpref{wxButton}{wxbutton} | |
80 | ||
1fdc16ad VZ |
81 | |
82 | ||
a660d684 KB |
83 | \latexignore{\rtfignore{\wxheading{Members}}} |
84 | ||
1fdc16ad | 85 | |
f510b7b2 | 86 | \membersection{wxBitmapButton::wxBitmapButton}\label{wxbitmapbuttonctor} |
a660d684 KB |
87 | |
88 | \func{}{wxBitmapButton}{\void} | |
89 | ||
90 | Default constructor. | |
91 | ||
2e76d519 SB |
92 | \func{}{wxBitmapButton}{ |
93 | \param{wxWindow* }{parent}, | |
94 | \param{wxWindowID }{id}, | |
95 | \param{const wxBitmap\& }{bitmap},\rtfsp | |
96 | \param{const wxPoint\& }{pos = wxDefaultPosition}, | |
97 | \param{const wxSize\& }{size = wxDefaultSize},\rtfsp | |
98 | \param{long }{style = wxBU\_AUTODRAW}, | |
99 | \param{const wxValidator\& }{validator = wxDefaultValidator}, | |
100 | \param{const wxString\& }{name = ``button"}} | |
a660d684 KB |
101 | |
102 | Constructor, creating and showing a button. | |
103 | ||
104 | \wxheading{Parameters} | |
105 | ||
106 | \docparam{parent}{Parent window. Must not be NULL.} | |
107 | ||
108 | \docparam{id}{Button identifier. A value of -1 indicates a default value.} | |
109 | ||
110 | \docparam{bitmap}{Bitmap to be displayed.} | |
111 | ||
112 | \docparam{pos}{Button position.} | |
113 | ||
114 | \docparam{size}{Button size. If the default size (-1, -1) is specified then the button is sized | |
115 | appropriately for the bitmap.} | |
116 | ||
117 | \docparam{style}{Window style. See \helpref{wxBitmapButton}{wxbitmapbutton}.} | |
118 | ||
119 | \docparam{validator}{Window validator.} | |
120 | ||
121 | \docparam{name}{Window name.} | |
122 | ||
123 | \wxheading{Remarks} | |
124 | ||
fc2171bd | 125 | The {\it bitmap} parameter is normally the only bitmap you need to provide, and wxWidgets will |
a660d684 KB |
126 | draw the button correctly in its different states. If you want more control, call |
127 | any of the functions \helpref{wxBitmapButton::SetBitmapSelected}{wxbitmapbuttonsetbitmapselected},\rtfsp | |
128 | \helpref{wxBitmapButton::SetBitmapFocus}{wxbitmapbuttonsetbitmapfocus},\rtfsp | |
129 | \helpref{wxBitmapButton::SetBitmapDisabled}{wxbitmapbuttonsetbitmapdisabled}. | |
130 | ||
131 | Note that the bitmap passed is smaller than the actual button created. | |
132 | ||
133 | \wxheading{See also} | |
134 | ||
135 | \helpref{wxBitmapButton::Create}{wxbitmapbuttoncreate}, \helpref{wxValidator}{wxvalidator} | |
136 | ||
1fdc16ad | 137 | |
f510b7b2 | 138 | \membersection{wxBitmapButton::\destruct{wxBitmapButton}}\label{wxbitmapbuttondtor} |
a660d684 KB |
139 | |
140 | \func{}{\destruct{wxBitmapButton}}{\void} | |
141 | ||
142 | Destructor, destroying the button. | |
143 | ||
1fdc16ad | 144 | |
a660d684 KB |
145 | \membersection{wxBitmapButton::Create}\label{wxbitmapbuttoncreate} |
146 | ||
eaaa6a06 | 147 | \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxBitmap\& }{bitmap},\rtfsp |
a660d684 | 148 | \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp |
eaaa6a06 | 149 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}} |
a660d684 | 150 | |
f510b7b2 | 151 | Button creation function for two-step creation. For more details, see \helpref{wxBitmapButton::wxBitmapButton}{wxbitmapbuttonctor}. |
a660d684 | 152 | |
1fdc16ad | 153 | |
a660d684 KB |
154 | \membersection{wxBitmapButton::GetBitmapDisabled}\label{wxbitmapbuttongetbitmapdisabled} |
155 | ||
1fdc16ad VZ |
156 | \constfunc{const wxBitmap\&}{GetBitmapDisabled}{\void} |
157 | \func{wxBitmap\&}{GetBitmapDisabled}{\void} | |
a660d684 | 158 | |
1fdc16ad | 159 | Returns the bitmap for the disabled state, may be invalid. |
a660d684 KB |
160 | |
161 | \wxheading{Return value} | |
162 | ||
163 | A reference to the disabled state bitmap. | |
164 | ||
165 | \wxheading{See also} | |
166 | ||
167 | \helpref{wxBitmapButton::SetBitmapDisabled}{wxbitmapbuttonsetbitmapdisabled} | |
168 | ||
1fdc16ad | 169 | |
a660d684 KB |
170 | \membersection{wxBitmapButton::GetBitmapFocus}\label{wxbitmapbuttongetbitmapfocus} |
171 | ||
1fdc16ad VZ |
172 | \constfunc{const wxBitmap\&}{GetBitmapFocus}{\void} |
173 | \func{wxBitmap\&}{GetBitmapFocus}{\void} | |
a660d684 | 174 | |
1fdc16ad | 175 | Returns the bitmap for the focused state, may be invalid. |
a660d684 KB |
176 | |
177 | \wxheading{Return value} | |
178 | ||
f6bcfd97 | 179 | A reference to the focused state bitmap. |
a660d684 KB |
180 | |
181 | \wxheading{See also} | |
182 | ||
183 | \helpref{wxBitmapButton::SetBitmapFocus}{wxbitmapbuttonsetbitmapfocus} | |
184 | ||
1fdc16ad VZ |
185 | |
186 | \membersection{wxBitmapButton::GetBitmapHover}\label{wxbitmapbuttongetbitmaphover} | |
187 | ||
188 | \constfunc{const wxBitmap\&}{GetBitmapHover}{\void} | |
189 | \func{wxBitmap\&}{GetBitmapHover}{\void} | |
190 | ||
191 | Returns the bitmap used when the mouse is over the button, may be invalid. | |
192 | ||
193 | \wxheading{See also} | |
194 | ||
195 | \helpref{wxBitmapButton::SetBitmapHover}{wxbitmapbuttonsetbitmaphover} | |
196 | ||
197 | ||
a660d684 KB |
198 | \membersection{wxBitmapButton::GetBitmapLabel}\label{wxbitmapbuttongetbitmaplabel} |
199 | ||
1fdc16ad VZ |
200 | \constfunc{const wxBitmap\&}{GetBitmapLabel}{\void} |
201 | \func{wxBitmap\&}{GetBitmapLabel}{\void} | |
a660d684 | 202 | |
1fdc16ad | 203 | Returns the label bitmap (the one passed to the constructor), always valid. |
a660d684 KB |
204 | |
205 | \wxheading{Return value} | |
206 | ||
207 | A reference to the button's label bitmap. | |
208 | ||
209 | \wxheading{See also} | |
210 | ||
211 | \helpref{wxBitmapButton::SetBitmapLabel}{wxbitmapbuttonsetbitmaplabel} | |
212 | ||
1fdc16ad | 213 | |
a660d684 KB |
214 | \membersection{wxBitmapButton::GetBitmapSelected}\label{wxbitmapbuttongetbitmapselected} |
215 | ||
216 | \constfunc{wxBitmap\&}{GetBitmapSelected}{\void} | |
1fdc16ad | 217 | \func{wxBitmap\&}{GetBitmapSelected}{\void} |
a660d684 | 218 | |
1fdc16ad | 219 | Returns the bitmap for the pushed button state, may be invalid. |
a660d684 KB |
220 | |
221 | \wxheading{Return value} | |
222 | ||
223 | A reference to the selected state bitmap. | |
224 | ||
225 | \wxheading{See also} | |
226 | ||
227 | \helpref{wxBitmapButton::SetBitmapSelected}{wxbitmapbuttonsetbitmapselected} | |
228 | ||
1fdc16ad | 229 | |
a660d684 KB |
230 | \membersection{wxBitmapButton::SetBitmapDisabled}\label{wxbitmapbuttonsetbitmapdisabled} |
231 | ||
232 | \func{void}{SetBitmapDisabled}{\param{const wxBitmap\& }{bitmap}} | |
233 | ||
234 | Sets the bitmap for the disabled button appearance. | |
235 | ||
236 | \wxheading{Parameters} | |
237 | ||
238 | \docparam{bitmap}{The bitmap to set.} | |
239 | ||
240 | \wxheading{See also} | |
241 | ||
242 | \helpref{wxBitmapButton::GetBitmapDisabled}{wxbitmapbuttongetbitmapdisabled},\rtfsp | |
243 | \helpref{wxBitmapButton::SetBitmapLabel}{wxbitmapbuttonsetbitmaplabel},\rtfsp | |
244 | \helpref{wxBitmapButton::SetBitmapSelected}{wxbitmapbuttonsetbitmapselected},\rtfsp | |
245 | \helpref{wxBitmapButton::SetBitmapFocus}{wxbitmapbuttonsetbitmapfocus} | |
246 | ||
1fdc16ad | 247 | |
a660d684 KB |
248 | \membersection{wxBitmapButton::SetBitmapFocus}\label{wxbitmapbuttonsetbitmapfocus} |
249 | ||
250 | \func{void}{SetBitmapFocus}{\param{const wxBitmap\& }{bitmap}} | |
251 | ||
252 | Sets the bitmap for the button appearance when it has the keyboard focus. | |
253 | ||
254 | \wxheading{Parameters} | |
255 | ||
256 | \docparam{bitmap}{The bitmap to set.} | |
257 | ||
258 | \wxheading{See also} | |
259 | ||
260 | \helpref{wxBitmapButton::GetBitmapFocus}{wxbitmapbuttongetbitmapfocus},\rtfsp | |
261 | \helpref{wxBitmapButton::SetBitmapLabel}{wxbitmapbuttonsetbitmaplabel},\rtfsp | |
262 | \helpref{wxBitmapButton::SetBitmapSelected}{wxbitmapbuttonsetbitmapselected},\rtfsp | |
263 | \helpref{wxBitmapButton::SetBitmapDisabled}{wxbitmapbuttonsetbitmapdisabled} | |
264 | ||
1fdc16ad VZ |
265 | |
266 | \membersection{wxBitmapButton::SetBitmapHover}\label{wxbitmapbuttonsetbitmaphover} | |
267 | ||
268 | \func{void}{SetBitmapHover}{\param{const wxBitmap\& }{bitmap}} | |
269 | ||
270 | Sets the bitmap to be shown when the mouse is over the button. | |
271 | ||
272 | \newsince{2.7.0} and the hover bitmap is currently only supported in wxMSW. | |
273 | ||
274 | \wxheading{See also} | |
275 | ||
276 | \helpref{wxBitmapButton::GetBitmapHover}{wxbitmapbuttongetbitmaphover} | |
277 | ||
a660d684 KB |
278 | \membersection{wxBitmapButton::SetBitmapLabel}\label{wxbitmapbuttonsetbitmaplabel} |
279 | ||
280 | \func{void}{SetBitmapLabel}{\param{const wxBitmap\& }{bitmap}} | |
281 | ||
282 | Sets the bitmap label for the button. | |
283 | ||
284 | \wxheading{Parameters} | |
285 | ||
286 | \docparam{bitmap}{The bitmap label to set.} | |
287 | ||
288 | \wxheading{Remarks} | |
289 | ||
290 | This is the bitmap used for the unselected state, and for all other states | |
291 | if no other bitmaps are provided. | |
292 | ||
293 | \wxheading{See also} | |
294 | ||
295 | \helpref{wxBitmapButton::GetBitmapLabel}{wxbitmapbuttongetbitmaplabel} | |
296 | ||
1fdc16ad | 297 | |
a660d684 KB |
298 | \membersection{wxBitmapButton::SetBitmapSelected}\label{wxbitmapbuttonsetbitmapselected} |
299 | ||
300 | \func{void}{SetBitmapSelected}{\param{const wxBitmap\& }{bitmap}} | |
301 | ||
302 | Sets the bitmap for the selected (depressed) button appearance. | |
303 | ||
304 | \wxheading{Parameters} | |
305 | ||
306 | \docparam{bitmap}{The bitmap to set.} | |
307 | ||
308 | \wxheading{See also} | |
309 | ||
310 | \helpref{wxBitmapButton::GetBitmapSelected}{wxbitmapbuttongetbitmapselected},\rtfsp | |
311 | \helpref{wxBitmapButton::SetBitmapLabel}{wxbitmapbuttonsetbitmaplabel},\rtfsp | |
312 | \helpref{wxBitmapButton::SetBitmapFocus}{wxbitmapbuttonsetbitmapfocus},\rtfsp | |
313 | \helpref{wxBitmapButton::SetBitmapDisabled}{wxbitmapbuttonsetbitmapdisabled} | |
314 |