X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e53b3d16de127872e39bf276f7e616b32f161645..345ff9c65b3ef17709785708b224dfcbf5135583:/src/osx/bmpbuttn_osx.cpp diff --git a/src/osx/bmpbuttn_osx.cpp b/src/osx/bmpbuttn_osx.cpp index 195c0ffc79..d22411f27e 100644 --- a/src/osx/bmpbuttn_osx.cpp +++ b/src/osx/bmpbuttn_osx.cpp @@ -27,7 +27,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton) //--------------------------------------------------------------------------- bool wxBitmapButton::Create( wxWindow *parent, - wxWindowID id, const wxBitmap& bitmap, + wxWindowID id, + const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, @@ -36,9 +37,8 @@ bool wxBitmapButton::Create( wxWindow *parent, { m_macIsUserPane = false; - // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create - // essentially creates an additional button - if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) ) + if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style, + validator, name) ) return false; if ( style & wxBU_AUTODRAW ) @@ -52,7 +52,7 @@ bool wxBitmapButton::Create( wxWindow *parent, m_marginY = 0; } - m_bmpNormal = bitmap; + m_bitmaps[State_Normal] = bitmap; m_peer = wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() ); @@ -61,26 +61,29 @@ bool wxBitmapButton::Create( wxWindow *parent, return true; } -void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) -{ - InvalidateBestSize(); - - m_peer->SetBitmap( bitmap ); +void wxBitmapButton::DoSetBitmap(const wxBitmap& bitmap, State which) +{ + wxBitmapButtonBase::DoSetBitmap(bitmap, which); + + // we don't support any other states currently + if ( which == State_Normal ) + { + m_peer->SetBitmap( bitmap ); + } } wxSize wxBitmapButton::DoGetBestSize() const { - wxSize best; + wxSize best(m_marginX, m_marginY); + + best *= 2; - best.x = 2 * m_marginX; - best.y = 2 * m_marginY; - if ( m_bmpNormal.Ok() ) + if ( GetBitmapLabel().IsOk() ) { - best.x += m_bmpNormal.GetWidth(); - best.y += m_bmpNormal.GetHeight(); + best += GetBitmapLabel().GetSize(); } return best; } -#endif +#endif // wxUSE_BMPBUTTON