X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bf19e3f6531cd2b0612ff1a59c1edf773a8f9402..6dc863c78f4a4949579efa184d847f0fe41095c8:/src/mac/bmpbuttn.cpp diff --git a/src/mac/bmpbuttn.cpp b/src/mac/bmpbuttn.cpp index 4f06731513..f6ce4dd00c 100644 --- a/src/mac/bmpbuttn.cpp +++ b/src/mac/bmpbuttn.cpp @@ -51,11 +51,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit int width = size.x; int height = size.y; - if ( width == -1 && bitmap.Ok()) - width = bitmap.GetWidth() + 2*m_marginX; - - if ( height == -1 && bitmap.Ok()) - height = bitmap.GetHeight() + 2*m_marginY; + if ( bitmap.Ok() ) + { + wxSize newSize = DoGetBestSize(); + if ( width == -1 ) + width = newSize.x; + if ( height == -1 ) + height = newSize.y; + } Rect bounds ; Str255 title ; @@ -97,3 +100,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap) } } + +wxSize wxBitmapButton::DoGetBestSize() const +{ + wxSize best; + if (m_bmpNormal.Ok()) + { + best.x = m_bmpNormal.GetWidth() + 2*m_marginX; + best.y = m_bmpNormal.GetHeight() + 2*m_marginY; + } + return best; +}