2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bmpbuttn.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxBitmapButton
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxBitmapButton
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A bitmap button is a control that contains a bitmap.
|
2008-03-16 20:47:38 -04:00
|
|
|
It may be placed on a wxDialog or a wxPanel, or indeed almost any other window.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
A bitmap button can be supplied with a single bitmap, and wxWidgets will draw
|
|
|
|
all button states using this bitmap. If the application needs more control,
|
|
|
|
additional bitmaps for the selected state, unpressed focused state, and greyed-out
|
|
|
|
state may be supplied.
|
|
|
|
|
2008-10-19 11:30:20 -04:00
|
|
|
@section bitmapbutton_states Button states
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-10-19 11:30:20 -04:00
|
|
|
This class supports bitmaps for several different states:
|
2008-03-16 20:47:38 -04:00
|
|
|
@li @b normal: this is the bitmap shown in the default state, it must be always
|
|
|
|
valid while all the other bitmaps are optional and don't have to be set.
|
|
|
|
@li @b disabled: bitmap shown when the button is disabled.
|
|
|
|
@li @b selected: bitmap shown when the button is pushed (e.g. while the user
|
|
|
|
keeps the mouse button pressed on it)
|
|
|
|
@li @b focus: bitmap shown when the button has keyboard focus but is not pressed.
|
|
|
|
@li @b hover: bitmap shown when the mouse is over the button (but it is not pressed).
|
|
|
|
Notice that if hover bitmap is not specified but the current platform UI uses
|
|
|
|
hover images for the buttons (such as Windows XP or GTK+), then the focus bitmap
|
|
|
|
is used for hover state as well. This makes it possible to set focus bitmap only
|
|
|
|
to get reasonably good behaviour on all platforms.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxBU_AUTODRAW}
|
2008-03-08 08:52:38 -05:00
|
|
|
If this is specified, the button will be drawn automatically using
|
|
|
|
the label bitmap only, providing a 3D-look border. If this style is
|
|
|
|
not specified, the button will be drawn without borders and using
|
2008-03-16 20:47:38 -04:00
|
|
|
all provided bitmaps. Has effect only under MS Windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxBU_LEFT}
|
2008-03-16 20:47:38 -04:00
|
|
|
Left-justifies the bitmap label. Has effect only under MS Windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxBU_TOP}
|
2008-03-16 20:47:38 -04:00
|
|
|
Aligns the bitmap label to the top of the button.
|
|
|
|
Has effect only under MS Windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxBU_RIGHT}
|
2008-03-16 20:47:38 -04:00
|
|
|
Right-justifies the bitmap label. Has effect only under MS Windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxBU_BOTTOM}
|
2008-03-16 20:47:38 -04:00
|
|
|
Aligns the bitmap label to the bottom of the button.
|
|
|
|
Has effect only under MS Windows.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-16 20:47:38 -04:00
|
|
|
Note that the wxBU_EXACTFIT style supported by wxButton is not used by this
|
|
|
|
class as bitmap buttons don't have any minimal standard size by default.
|
|
|
|
|
2008-03-28 12:19:12 -04:00
|
|
|
@beginEventTable{wxCommandEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_BUTTON(id, func)}
|
2008-03-16 20:47:38 -04:00
|
|
|
Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{ctrl}
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{bitmapbutton.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxButton
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxBitmapButton : public wxButton
|
|
|
|
{
|
|
|
|
public:
|
2008-03-16 20:47:38 -04:00
|
|
|
/**
|
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxBitmapButton();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor, creating and showing a button.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Button identifier. The value wxID_ANY indicates a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
Bitmap to be displayed.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Button position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-16 20:47:38 -04:00
|
|
|
Button size. If wxDefaultSize is specified then the button is sized
|
2008-03-09 08:33:59 -04:00
|
|
|
appropriately for the bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style. See wxBitmapButton.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Window validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Window name.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
|
|
|
@remarks The bitmap parameter is normally the only bitmap you need to provide,
|
|
|
|
and wxWidgets will draw the button correctly in its different states.
|
|
|
|
If you want more control, call any of the functions SetBitmapSelected(),
|
|
|
|
SetBitmapFocus(), SetBitmapDisabled().
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Create(), wxValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxBitmapButton(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxBitmap& bitmap,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxBU_AUTODRAW,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-03-25 08:22:08 -04:00
|
|
|
const wxString& name = wxButtonNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor, destroying the button.
|
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual ~wxBitmapButton();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Button creation function for two-step creation.
|
|
|
|
For more details, see wxBitmapButton().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxBitmap& bitmap,
|
2008-03-25 08:22:08 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-03-25 08:22:08 -04:00
|
|
|
long style = wxBU_AUTODRAW,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxButtonNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Returns the bitmap for the disabled state, which may be invalid.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the disabled state bitmap.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetBitmapDisabled()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
const wxBitmap& GetBitmapDisabled() const;
|
|
|
|
wxBitmap& GetBitmapDisabled();
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Returns the bitmap for the focused state, which may be invalid.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the focused state bitmap.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetBitmapFocus()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-16 20:47:38 -04:00
|
|
|
const wxBitmap& GetBitmapFocus() const;
|
2009-01-10 18:44:44 -05:00
|
|
|
wxBitmap& GetBitmapFocus();
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-16 20:47:38 -04:00
|
|
|
Returns the bitmap used when the mouse is over the button, which may be invalid.
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetBitmapHover()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-10 18:44:44 -05:00
|
|
|
const wxBitmap& GetBitmapHover() const;
|
|
|
|
wxBitmap& GetBitmapHover();
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Returns the label bitmap (the one passed to the constructor), always valid.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the button's label bitmap.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetBitmapLabel()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-10 18:44:44 -05:00
|
|
|
const wxBitmap& GetBitmapLabel() const;
|
|
|
|
wxBitmap& GetBitmapLabel();
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the bitmap for the selected state.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the selected state bitmap.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetBitmapSelected()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 18:06:48 -04:00
|
|
|
const wxBitmap& GetBitmapSelected() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the bitmap for the disabled button appearance.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The bitmap to set.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetBitmapDisabled(), SetBitmapLabel(),
|
|
|
|
SetBitmapSelected(), SetBitmapFocus()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual void SetBitmapDisabled(const wxBitmap& bitmap);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the bitmap for the button appearance when it has the keyboard focus.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The bitmap to set.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetBitmapFocus(), SetBitmapLabel(),
|
|
|
|
SetBitmapSelected(), SetBitmapDisabled()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual void SetBitmapFocus(const wxBitmap& bitmap);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the bitmap to be shown when the mouse is over the button.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-04-21 06:34:23 -04:00
|
|
|
@since 2.7.0
|
2008-03-16 20:47:38 -04:00
|
|
|
|
|
|
|
The hover bitmap is currently only supported in wxMSW.
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetBitmapHover()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual void SetBitmapHover(const wxBitmap& bitmap);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the bitmap label for the button.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The bitmap label to set.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks This is the bitmap used for the unselected state, and for all
|
2008-03-09 08:33:59 -04:00
|
|
|
other states if no other bitmaps are provided.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetBitmapLabel()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual void SetBitmapLabel(const wxBitmap& bitmap);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the bitmap for the selected (depressed) button appearance.
|
2008-03-16 20:47:38 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
The bitmap to set.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 18:17:25 -04:00
|
|
|
virtual void SetBitmapSelected(const wxBitmap& bitmap);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|