]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: bmpbuttn.h | |
e54c96f1 | 3 | // Purpose: interface of wxBitmapButton |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxBitmapButton | |
7c913512 | 11 | |
23324ae1 | 12 | A bitmap button is a control that contains a bitmap. |
8024723d FM |
13 | It may be placed on a wxDialog or a wxPanel, or indeed almost any other window. |
14 | ||
15 | @remarks | |
16 | A bitmap button can be supplied with a single bitmap, and wxWidgets will draw | |
17 | all button states using this bitmap. If the application needs more control, | |
18 | additional bitmaps for the selected state, unpressed focused state, and greyed-out | |
19 | state may be supplied. | |
20 | ||
3a74a290 | 21 | @section bitmapbutton_states Button states |
8024723d | 22 | |
3a74a290 | 23 | This class supports bitmaps for several different states: |
8024723d FM |
24 | @li @b normal: this is the bitmap shown in the default state, it must be always |
25 | valid while all the other bitmaps are optional and don't have to be set. | |
26 | @li @b disabled: bitmap shown when the button is disabled. | |
27 | @li @b selected: bitmap shown when the button is pushed (e.g. while the user | |
28 | keeps the mouse button pressed on it) | |
29 | @li @b focus: bitmap shown when the button has keyboard focus but is not pressed. | |
30 | @li @b hover: bitmap shown when the mouse is over the button (but it is not pressed). | |
31 | Notice that if hover bitmap is not specified but the current platform UI uses | |
32 | hover images for the buttons (such as Windows XP or GTK+), then the focus bitmap | |
33 | is used for hover state as well. This makes it possible to set focus bitmap only | |
34 | to get reasonably good behaviour on all platforms. | |
7c913512 | 35 | |
23324ae1 | 36 | @beginStyleTable |
8c6791e4 | 37 | @style{wxBU_AUTODRAW} |
23324ae1 FM |
38 | If this is specified, the button will be drawn automatically using |
39 | the label bitmap only, providing a 3D-look border. If this style is | |
40 | not specified, the button will be drawn without borders and using | |
8024723d | 41 | all provided bitmaps. Has effect only under MS Windows. |
8c6791e4 | 42 | @style{wxBU_LEFT} |
8024723d | 43 | Left-justifies the bitmap label. Has effect only under MS Windows. |
8c6791e4 | 44 | @style{wxBU_TOP} |
8024723d FM |
45 | Aligns the bitmap label to the top of the button. |
46 | Has effect only under MS Windows. | |
8c6791e4 | 47 | @style{wxBU_RIGHT} |
8024723d | 48 | Right-justifies the bitmap label. Has effect only under MS Windows. |
8c6791e4 | 49 | @style{wxBU_BOTTOM} |
8024723d FM |
50 | Aligns the bitmap label to the bottom of the button. |
51 | Has effect only under MS Windows. | |
23324ae1 | 52 | @endStyleTable |
7c913512 | 53 | |
8024723d FM |
54 | Note that the wxBU_EXACTFIT style supported by wxButton is not used by this |
55 | class as bitmap buttons don't have any minimal standard size by default. | |
56 | ||
1f1d2182 | 57 | @beginEventTable{wxCommandEvent} |
8c6791e4 | 58 | @event{EVT_BUTTON(id, func)} |
8024723d | 59 | Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked. |
23324ae1 | 60 | @endEventTable |
7c913512 | 61 | |
23324ae1 FM |
62 | @library{wxcore} |
63 | @category{ctrl} | |
7e59b885 | 64 | @appearance{bitmapbutton.png} |
7c913512 | 65 | |
e54c96f1 | 66 | @see wxButton |
23324ae1 FM |
67 | */ |
68 | class wxBitmapButton : public wxButton | |
69 | { | |
70 | public: | |
8024723d FM |
71 | /** |
72 | Default ctor. | |
73 | */ | |
74 | wxBitmapButton(); | |
75 | ||
23324ae1 FM |
76 | /** |
77 | Constructor, creating and showing a button. | |
8024723d | 78 | |
7c913512 | 79 | @param parent |
4cc4bfaf | 80 | Parent window. Must not be @NULL. |
7c913512 | 81 | @param id |
4cc4bfaf | 82 | Button identifier. The value wxID_ANY indicates a default value. |
7c913512 | 83 | @param bitmap |
4cc4bfaf | 84 | Bitmap to be displayed. |
7c913512 | 85 | @param pos |
4cc4bfaf | 86 | Button position. |
7c913512 | 87 | @param size |
8024723d | 88 | Button size. If wxDefaultSize is specified then the button is sized |
4cc4bfaf | 89 | appropriately for the bitmap. |
7c913512 | 90 | @param style |
4cc4bfaf | 91 | Window style. See wxBitmapButton. |
7c913512 | 92 | @param validator |
4cc4bfaf | 93 | Window validator. |
7c913512 | 94 | @param name |
4cc4bfaf | 95 | Window name. |
8024723d FM |
96 | |
97 | @remarks The bitmap parameter is normally the only bitmap you need to provide, | |
98 | and wxWidgets will draw the button correctly in its different states. | |
99 | If you want more control, call any of the functions SetBitmapSelected(), | |
100 | SetBitmapFocus(), SetBitmapDisabled(). | |
101 | ||
4cc4bfaf | 102 | @see Create(), wxValidator |
23324ae1 | 103 | */ |
7c913512 FM |
104 | wxBitmapButton(wxWindow* parent, wxWindowID id, |
105 | const wxBitmap& bitmap, | |
106 | const wxPoint& pos = wxDefaultPosition, | |
107 | const wxSize& size = wxDefaultSize, | |
108 | long style = wxBU_AUTODRAW, | |
109 | const wxValidator& validator = wxDefaultValidator, | |
a6052817 | 110 | const wxString& name = wxButtonNameStr); |
23324ae1 FM |
111 | |
112 | /** | |
113 | Destructor, destroying the button. | |
114 | */ | |
d2aa927a | 115 | virtual ~wxBitmapButton(); |
23324ae1 FM |
116 | |
117 | /** | |
8024723d FM |
118 | Button creation function for two-step creation. |
119 | For more details, see wxBitmapButton(). | |
23324ae1 FM |
120 | */ |
121 | bool Create(wxWindow* parent, wxWindowID id, | |
122 | const wxBitmap& bitmap, | |
a6052817 | 123 | const wxPoint& pos = wxDefaultPosition, |
23324ae1 | 124 | const wxSize& size = wxDefaultSize, |
a6052817 FM |
125 | long style = wxBU_AUTODRAW, |
126 | const wxValidator& validator = wxDefaultValidator, | |
127 | const wxString& name = wxButtonNameStr); | |
23324ae1 FM |
128 | |
129 | //@{ | |
130 | /** | |
8024723d FM |
131 | Returns the bitmap for the disabled state, which may be invalid. |
132 | ||
d29a9a8a | 133 | @return A reference to the disabled state bitmap. |
8024723d | 134 | |
4cc4bfaf | 135 | @see SetBitmapDisabled() |
23324ae1 | 136 | */ |
8024723d FM |
137 | const wxBitmap& GetBitmapDisabled() const; |
138 | wxBitmap& GetBitmapDisabled(); | |
23324ae1 FM |
139 | //@} |
140 | ||
141 | //@{ | |
142 | /** | |
8024723d FM |
143 | Returns the bitmap for the focused state, which may be invalid. |
144 | ||
d29a9a8a | 145 | @return A reference to the focused state bitmap. |
8024723d | 146 | |
4cc4bfaf | 147 | @see SetBitmapFocus() |
23324ae1 | 148 | */ |
8024723d FM |
149 | const wxBitmap& GetBitmapFocus() const; |
150 | wxBitmap& GetBitmapFocus(); | |
23324ae1 FM |
151 | //@} |
152 | ||
153 | //@{ | |
154 | /** | |
8024723d FM |
155 | Returns the bitmap used when the mouse is over the button, which may be invalid. |
156 | ||
4cc4bfaf | 157 | @see SetBitmapHover() |
23324ae1 | 158 | */ |
8024723d FM |
159 | const wxBitmap& GetBitmapHover(); |
160 | wxBitmap& GetBitmapHover(); | |
23324ae1 FM |
161 | //@} |
162 | ||
163 | //@{ | |
164 | /** | |
165 | Returns the label bitmap (the one passed to the constructor), always valid. | |
8024723d | 166 | |
d29a9a8a | 167 | @return A reference to the button's label bitmap. |
8024723d | 168 | |
4cc4bfaf | 169 | @see SetBitmapLabel() |
23324ae1 | 170 | */ |
8024723d FM |
171 | const wxBitmap& GetBitmapLabel(); |
172 | wxBitmap& GetBitmapLabel(); | |
23324ae1 FM |
173 | //@} |
174 | ||
175 | /** | |
176 | Returns the bitmap for the selected state. | |
8024723d | 177 | |
d29a9a8a | 178 | @return A reference to the selected state bitmap. |
8024723d | 179 | |
4cc4bfaf | 180 | @see SetBitmapSelected() |
23324ae1 | 181 | */ |
1413ac04 | 182 | const wxBitmap& GetBitmapSelected() const; |
23324ae1 FM |
183 | |
184 | /** | |
185 | Sets the bitmap for the disabled button appearance. | |
8024723d | 186 | |
7c913512 | 187 | @param bitmap |
4cc4bfaf | 188 | The bitmap to set. |
8024723d | 189 | |
4cc4bfaf FM |
190 | @see GetBitmapDisabled(), SetBitmapLabel(), |
191 | SetBitmapSelected(), SetBitmapFocus() | |
23324ae1 | 192 | */ |
d2aa927a | 193 | virtual void SetBitmapDisabled(const wxBitmap& bitmap); |
23324ae1 FM |
194 | |
195 | /** | |
196 | Sets the bitmap for the button appearance when it has the keyboard focus. | |
8024723d | 197 | |
7c913512 | 198 | @param bitmap |
4cc4bfaf | 199 | The bitmap to set. |
8024723d | 200 | |
4cc4bfaf FM |
201 | @see GetBitmapFocus(), SetBitmapLabel(), |
202 | SetBitmapSelected(), SetBitmapDisabled() | |
23324ae1 | 203 | */ |
d2aa927a | 204 | virtual void SetBitmapFocus(const wxBitmap& bitmap); |
23324ae1 FM |
205 | |
206 | /** | |
207 | Sets the bitmap to be shown when the mouse is over the button. | |
8024723d | 208 | |
1e24c2af | 209 | @since 2.7.0 |
8024723d FM |
210 | |
211 | The hover bitmap is currently only supported in wxMSW. | |
212 | ||
4cc4bfaf | 213 | @see GetBitmapHover() |
23324ae1 | 214 | */ |
d2aa927a | 215 | virtual void SetBitmapHover(const wxBitmap& bitmap); |
23324ae1 FM |
216 | |
217 | /** | |
218 | Sets the bitmap label for the button. | |
8024723d | 219 | |
7c913512 | 220 | @param bitmap |
4cc4bfaf | 221 | The bitmap label to set. |
8024723d | 222 | |
23324ae1 | 223 | @remarks This is the bitmap used for the unselected state, and for all |
4cc4bfaf | 224 | other states if no other bitmaps are provided. |
8024723d | 225 | |
4cc4bfaf | 226 | @see GetBitmapLabel() |
23324ae1 | 227 | */ |
d2aa927a | 228 | virtual void SetBitmapLabel(const wxBitmap& bitmap); |
23324ae1 FM |
229 | |
230 | /** | |
231 | Sets the bitmap for the selected (depressed) button appearance. | |
8024723d | 232 | |
7c913512 | 233 | @param bitmap |
4cc4bfaf | 234 | The bitmap to set. |
23324ae1 | 235 | */ |
d2aa927a | 236 | virtual void SetBitmapSelected(const wxBitmap& bitmap); |
23324ae1 | 237 | }; |
e54c96f1 | 238 |