X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bcd055ae108a30299fa278f3fe774f52414eb3df..5f1d3069010e74475d6b5887a59e242d452f4f2a:/src/motif/bmpbuttn.cpp diff --git a/src/motif/bmpbuttn.cpp b/src/motif/bmpbuttn.cpp index 374b8db63b..54d735b856 100644 --- a/src/motif/bmpbuttn.cpp +++ b/src/motif/bmpbuttn.cpp @@ -17,6 +17,8 @@ #define XtScreen XTSCREEN #endif +#include "wx/defs.h" + #include "wx/bmpbuttn.h" #ifdef __VMS__ @@ -111,7 +113,19 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit (XtPointer) this); SetCanAddEventHandler(TRUE); - AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); + + wxSize newSize = size; + + if (m_buttonBitmap.Ok()) + { + int border = (style & wxNO_BORDER) ? 4 : 10; + if (newSize.x == -1) + newSize.x = m_buttonBitmap.GetWidth()+border; + if (newSize.y == -1) + newSize.y = m_buttonBitmap.GetHeight()+border; + } + + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, newSize.x, newSize.y); return TRUE; } @@ -260,3 +274,23 @@ void wxBitmapButton::ChangeBackgroundColour() // Must reset the bitmaps since the colours have changed. DoSetBitmap(); } + +wxSize wxBitmapButton::DoGetBestSize() const +{ + wxSize ret( 30,30 ); + + if (m_buttonBitmap.Ok()) + { + int border = (GetWindowStyle() & wxNO_BORDER) ? 4 : 10; + ret.x = m_buttonBitmap.GetWidth()+border; + ret.y = m_buttonBitmap.GetHeight()+border; + } + + if (!HasFlag(wxBU_EXACTFIT)) + { + if (ret.x < 80) ret.x = 80; + } + + return ret; +} +