always use wxBU_NOTEXT and wxBU_EXACTFIT for wxBitmapButton under all platforms (which required some refactoring) (hopefully really closes #10927)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-06-28 16:14:37 +00:00
parent 79e38eaf2a
commit 8e4c291246
5 changed files with 47 additions and 8 deletions

View File

@ -41,6 +41,29 @@ public:
#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)
{

View File

@ -25,9 +25,15 @@ bool wxBitmapButton::Create(wxWindow *parent,
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;

View File

@ -130,9 +130,7 @@ bool wxBitmapButton::Create(wxWindow *parent,
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;

View File

@ -37,8 +37,8 @@ bool wxBitmapButton::Create( wxWindow *parent,
{
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 )

View File

@ -34,6 +34,18 @@ bool wxButton::Create(wxWindow *parent,
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);