#endif // wxHAS_BUTTON_BITMAP
}
+ bool Create(wxWindow *parent,
+ wxWindowID winid,
+ const wxBitmap& bitmap,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+ {
+ // We use wxBU_NOTEXT to let the base class Create() know that we are
+ // not going to show the label: this is a hack needed for wxGTK where
+ // we can show both label and bitmap only with GTK 2.6+ but we always
+ // can show just one of them and this style allows us to choose which
+ // one we need.
+ //
+ // And we also use wxBU_EXACTFIT to avoid being resized up to the
+ // standard button size as this doesn't make sense for bitmap buttons
+ // which are not standard anyhow and should fit their bitmap size.
+ return wxButton::Create(parent, id, pos, size,
+ style | wxBU_NOTEXT | wxBU_EXACTFIT,
+ validator, name);
+ }
+
// set/get the margins around the button
virtual void SetMargins(int x, int y)
{
const wxValidator& validator,
const wxString& name)
{
- if ( !wxBitmapButtonBase::Create(parent, id, "",
- pos, size,
- style | wxBU_NOTEXT,
+ // we use wxBU_NOTEXT to let the base class Create() know that we are not
+ // going to show the label -- this is a hack, but like this it can support
+ // bitmaps with all GTK+ versions, not just 2.6+ which support both labels
+ // and bitmaps
+ //
+ // and we also use wxBU_EXACTFIT to avoid being resized up to the standard
+ // button size as this doesn't make sense for bitmap buttons which are not
+ // standard anyhow
+ if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
validator, name) )
return false;
const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name)
{
- if ( !wxBitmapButtonBase::Create(parent, id, "",
- pos, size,
- style | wxBU_NOTEXT,
+ if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
validator, name) )
return false;
{
m_macIsUserPane = false;
- if ( !wxControl::Create( parent, id, pos, size, style | wxBU_NOTEXT,
- validator, name ) )
+ if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
+ validator, name) )
return false;
if ( style & wxBU_AUTODRAW )
const wxValidator& validator,
const wxString& name)
{
+ // FIXME: this hack is needed because we're called from
+ // wxBitmapButton::Create() with this style and we currently use a
+ // different wxWidgetImpl method (CreateBitmapButton() rather than
+ // CreateButton()) for creating bitmap buttons, but we really ought
+ // to unify the creation of buttons of all kinds and then remove
+ // this check
+ if ( style & wxBU_NOTEXT )
+ {
+ return wxControl::Create(parent, id, lbl, pos, size, style,
+ validator, name);
+ }
+
wxString label(lbl);
if (label.empty() && wxIsStockID(id) && !(id == wxID_HELP))
label = wxGetStockLabel(id);