Contents Up Previous Next

wxBitmapButton

A bitmap button is a control that contains a bitmap. It may be placed on a dialog box or panel, or indeed almost any other window.

Derived from

wxButton
wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/bmpbuttn.h>

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.

Button states

This class supports bitmaps for several different states:

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.
disabled Bitmap shown when the button is disabled.
selected Bitmap shown when the button is pushed (e.g. while the user keeps the mouse button pressed on it)
focus Bitmap shown when the button has keyboard focus but is not pressed.
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.

Window styles

wxBU_AUTODRAW 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 all provided bitmaps. WIN32 only.
wxBU_LEFT Left-justifies the bitmap label. WIN32 only.
wxBU_TOP Aligns the bitmap label to the top of the button. WIN32 only.
wxBU_RIGHT Right-justifies the bitmap label. WIN32 only.
wxBU_BOTTOM Aligns the bitmap label to the bottom of the button. WIN32 only.

Note that wxBU_EXACTFIT supported by wxButton is not used by this class as bitmap buttons don't have any minimal standard size by default.

See also window styles overview.

Event handling

EVT_BUTTON(id, func) Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked.

See also

wxButton

Members

wxBitmapButton::wxBitmapButton
wxBitmapButton::~wxBitmapButton
wxBitmapButton::Create
wxBitmapButton::GetBitmapDisabled
wxBitmapButton::GetBitmapFocus
wxBitmapButton::GetBitmapHover
wxBitmapButton::GetBitmapLabel
wxBitmapButton::GetBitmapSelected
wxBitmapButton::GetBitmapSelected
wxBitmapButton::SetBitmapDisabled
wxBitmapButton::SetBitmapFocus
wxBitmapButton::SetBitmapHover
wxBitmapButton::SetBitmapLabel
wxBitmapButton::SetBitmapSelected
wxBitmapButton::SetBitmapSelected


wxBitmapButton::wxBitmapButton

wxBitmapButton()

Default constructor.

wxBitmapButton( wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, const wxValidator& validator = wxDefaultValidator, const wxString& name = "button")

Constructor, creating and showing a button.

Parameters

parent

id

bitmap

pos

size

style

validator

name

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 wxBitmapButton::SetBitmapSelected, wxBitmapButton::SetBitmapFocus, wxBitmapButton::SetBitmapDisabled.

Note that the bitmap passed is smaller than the actual button created.

See also

wxBitmapButton::Create, wxValidator


wxBitmapButton::~wxBitmapButton

~wxBitmapButton()

Destructor, destroying the button.


wxBitmapButton::Create

bool Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator, const wxString& name = "button")

Button creation function for two-step creation. For more details, see wxBitmapButton::wxBitmapButton.


wxBitmapButton::GetBitmapDisabled

const wxBitmap& GetBitmapDisabled() const wxBitmap& GetBitmapDisabled()

Returns the bitmap for the disabled state, may be invalid.

Return value

A reference to the disabled state bitmap.

See also

wxBitmapButton::SetBitmapDisabled


wxBitmapButton::GetBitmapFocus

const wxBitmap& GetBitmapFocus() const wxBitmap& GetBitmapFocus()

Returns the bitmap for the focused state, may be invalid.

Return value

A reference to the focused state bitmap.

See also

wxBitmapButton::SetBitmapFocus


wxBitmapButton::GetBitmapHover

const wxBitmap& GetBitmapHover() const wxBitmap& GetBitmapHover()

Returns the bitmap used when the mouse is over the button, may be invalid.

See also

wxBitmapButton::SetBitmapHover


wxBitmapButton::GetBitmapLabel

const wxBitmap& GetBitmapLabel() const wxBitmap& GetBitmapLabel()

Returns the label bitmap (the one passed to the constructor), always valid.

Return value

A reference to the button's label bitmap.

See also

wxBitmapButton::SetBitmapLabel


wxBitmapButton::GetBitmapSelected

wxBitmap& GetBitmapSelected() const wxBitmap& GetBitmapSelected()

Returns the bitmap for the pushed button state, may be invalid.

Return value

A reference to the selected state bitmap.

See also

wxBitmapButton::SetBitmapSelected


wxBitmapButton::GetBitmapSelected

wxBitmap& GetBitmapSelected() const

Returns the bitmap for the selected state.

Return value

A reference to the selected state bitmap.

See also

wxBitmapButton::SetBitmapSelected


wxBitmapButton::SetBitmapDisabled

void SetBitmapDisabled(const wxBitmap& bitmap)

Sets the bitmap for the disabled button appearance.

Parameters

bitmap

See also

wxBitmapButton::GetBitmapDisabled, wxBitmapButton::SetBitmapLabel, wxBitmapButton::SetBitmapSelected, wxBitmapButton::SetBitmapFocus


wxBitmapButton::SetBitmapFocus

void SetBitmapFocus(const wxBitmap& bitmap)

Sets the bitmap for the button appearance when it has the keyboard focus.

Parameters

bitmap

See also

wxBitmapButton::GetBitmapFocus, wxBitmapButton::SetBitmapLabel, wxBitmapButton::SetBitmapSelected, wxBitmapButton::SetBitmapDisabled


wxBitmapButton::SetBitmapHover

void SetBitmapHover(const wxBitmap& bitmap)

Sets the bitmap to be shown when the mouse is over the button.

This function is new since wxWidgets version 2.7.0 and the hover bitmap is currently only supported in wxMSW.

See also

wxBitmapButton::GetBitmapHover


wxBitmapButton::SetBitmapLabel

void SetBitmapLabel(const wxBitmap& bitmap)

Sets the bitmap label for the button.

Parameters

bitmap

Remarks

This is the bitmap used for the unselected state, and for all other states if no other bitmaps are provided.

See also

wxBitmapButton::GetBitmapLabel


wxBitmapButton::SetBitmapSelected

void SetBitmapSelected(const wxBitmap& bitmap)

Sets the bitmap for the selected (depressed) button appearance.

Parameters

bitmap

See also

wxBitmapButton::GetBitmapSelected, wxBitmapButton::SetBitmapLabel, wxBitmapButton::SetBitmapFocus, wxBitmapButton::SetBitmapDisabled


wxBitmapButton::SetBitmapSelected

void SetBitmapSelected(const wxBitmap& bitmap)

Sets the bitmap for the selected (depressed) button appearance.

Parameters

bitmap

See also

wxBitmapButton::GetBitmapSelected, wxBitmapButton::SetBitmapLabel, wxBitmapButton::SetBitmapFocus, wxBitmapButton::SetBitmapDisabled