]>
git.saurik.com Git - wxWidgets.git/blob - interface/bmpbuttn.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxBitmapButton
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A bitmap button is a control that contains a bitmap.
14 It may be placed on a wxDialog or a wxPanel, or indeed almost any other window.
17 A bitmap button can be supplied with a single bitmap, and wxWidgets will draw
18 all button states using this bitmap. If the application needs more control,
19 additional bitmaps for the selected state, unpressed focused state, and greyed-out
20 state may be supplied.
22 @section wxbitmapbutton_states Button states
23 This class supports bitmaps for several different states:
25 @li @b normal: this is the bitmap shown in the default state, it must be always
26 valid while all the other bitmaps are optional and don't have to be set.
27 @li @b disabled: bitmap shown when the button is disabled.
28 @li @b selected: bitmap shown when the button is pushed (e.g. while the user
29 keeps the mouse button pressed on it)
30 @li @b focus: bitmap shown when the button has keyboard focus but is not pressed.
31 @li @b hover: bitmap shown when the mouse is over the button (but it is not pressed).
32 Notice that if hover bitmap is not specified but the current platform UI uses
33 hover images for the buttons (such as Windows XP or GTK+), then the focus bitmap
34 is used for hover state as well. This makes it possible to set focus bitmap only
35 to get reasonably good behaviour on all platforms.
38 @style{wxBU_AUTODRAW}:
39 If this is specified, the button will be drawn automatically using
40 the label bitmap only, providing a 3D-look border. If this style is
41 not specified, the button will be drawn without borders and using
42 all provided bitmaps. Has effect only under MS Windows.
44 Left-justifies the bitmap label. Has effect only under MS Windows.
46 Aligns the bitmap label to the top of the button.
47 Has effect only under MS Windows.
49 Right-justifies the bitmap label. Has effect only under MS Windows.
51 Aligns the bitmap label to the bottom of the button.
52 Has effect only under MS Windows.
55 Note that the wxBU_EXACTFIT style supported by wxButton is not used by this
56 class as bitmap buttons don't have any minimal standard size by default.
59 @event{EVT_BUTTON(id, func)}:
60 Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked.
65 @appearance{bitmapbutton.png}
69 class wxBitmapButton
: public wxButton
78 Constructor, creating and showing a button.
81 Parent window. Must not be @NULL.
83 Button identifier. The value wxID_ANY indicates a default value.
85 Bitmap to be displayed.
89 Button size. If wxDefaultSize is specified then the button is sized
90 appropriately for the bitmap.
92 Window style. See wxBitmapButton.
98 @remarks The bitmap parameter is normally the only bitmap you need to provide,
99 and wxWidgets will draw the button correctly in its different states.
100 If you want more control, call any of the functions SetBitmapSelected(),
101 SetBitmapFocus(), SetBitmapDisabled().
103 @see Create(), wxValidator
105 wxBitmapButton(wxWindow
* parent
, wxWindowID id
,
106 const wxBitmap
& bitmap
,
107 const wxPoint
& pos
= wxDefaultPosition
,
108 const wxSize
& size
= wxDefaultSize
,
109 long style
= wxBU_AUTODRAW
,
110 const wxValidator
& validator
= wxDefaultValidator
,
111 const wxString
& name
= wxButtonNameStr
);
114 Destructor, destroying the button.
116 virtual ~wxBitmapButton();
119 Button creation function for two-step creation.
120 For more details, see wxBitmapButton().
122 bool Create(wxWindow
* parent
, wxWindowID id
,
123 const wxBitmap
& bitmap
,
124 const wxPoint
& pos
= wxDefaultPosition
,
125 const wxSize
& size
= wxDefaultSize
,
126 long style
= wxBU_AUTODRAW
,
127 const wxValidator
& validator
= wxDefaultValidator
,
128 const wxString
& name
= wxButtonNameStr
);
132 Returns the bitmap for the disabled state, which may be invalid.
134 @returns A reference to the disabled state bitmap.
136 @see SetBitmapDisabled()
138 const wxBitmap
& GetBitmapDisabled() const;
139 wxBitmap
& GetBitmapDisabled();
144 Returns the bitmap for the focused state, which may be invalid.
146 @returns A reference to the focused state bitmap.
148 @see SetBitmapFocus()
150 const wxBitmap
& GetBitmapFocus() const;
151 wxBitmap
& GetBitmapFocus();
156 Returns the bitmap used when the mouse is over the button, which may be invalid.
158 @see SetBitmapHover()
160 const wxBitmap
& GetBitmapHover();
161 wxBitmap
& GetBitmapHover();
166 Returns the label bitmap (the one passed to the constructor), always valid.
168 @returns A reference to the button's label bitmap.
170 @see SetBitmapLabel()
172 const wxBitmap
& GetBitmapLabel();
173 wxBitmap
& GetBitmapLabel();
177 Returns the bitmap for the selected state.
179 @returns A reference to the selected state bitmap.
181 @see SetBitmapSelected()
183 const wxBitmap
& GetBitmapSelected() const;
186 Sets the bitmap for the disabled button appearance.
191 @see GetBitmapDisabled(), SetBitmapLabel(),
192 SetBitmapSelected(), SetBitmapFocus()
194 virtual void SetBitmapDisabled(const wxBitmap
& bitmap
);
197 Sets the bitmap for the button appearance when it has the keyboard focus.
202 @see GetBitmapFocus(), SetBitmapLabel(),
203 SetBitmapSelected(), SetBitmapDisabled()
205 virtual void SetBitmapFocus(const wxBitmap
& bitmap
);
208 Sets the bitmap to be shown when the mouse is over the button.
212 The hover bitmap is currently only supported in wxMSW.
214 @see GetBitmapHover()
216 virtual void SetBitmapHover(const wxBitmap
& bitmap
);
219 Sets the bitmap label for the button.
222 The bitmap label to set.
224 @remarks This is the bitmap used for the unselected state, and for all
225 other states if no other bitmaps are provided.
227 @see GetBitmapLabel()
229 virtual void SetBitmapLabel(const wxBitmap
& bitmap
);
232 Sets the bitmap for the selected (depressed) button appearance.
237 virtual void SetBitmapSelected(const wxBitmap
& bitmap
);