X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a265d21aad8c8bd7d7b35a45f97f2eb7f32c2ac2..fdec2c055413ed1b39bd2df9979c6c04aa94fe28:/src/msw/bmpbuttn.cpp diff --git a/src/msw/bmpbuttn.cpp b/src/msw/bmpbuttn.cpp index 9821e4a385..bb2e787838 100644 --- a/src/msw/bmpbuttn.cpp +++ b/src/msw/bmpbuttn.cpp @@ -76,7 +76,7 @@ wxEND_FLAGS( wxBitmapButtonStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxBitmapButton, wxButton,"wx/bmpbuttn.h") wxBEGIN_PROPERTIES_TABLE(wxBitmapButton) - wxPROPERTY_FLAGS( WindowStyle , wxBitmapButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style + wxPROPERTY_FLAGS( WindowStyle , wxBitmapButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style wxEND_PROPERTIES_TABLE() wxBEGIN_HANDLERS_TABLE(wxBitmapButton) @@ -136,11 +136,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - 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; + } long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD | BS_OWNERDRAW ; @@ -455,4 +458,29 @@ void wxBitmapButton::SetDefault() wxButton::SetDefault(); } +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; + } + + // all buttons have at least the standard size unless the user explicitly + // wants them to be of smaller size and used wxBU_EXACTFIT style when + // creating the button + if ( !HasFlag(wxBU_EXACTFIT) ) + { + wxSize sz = GetDefaultSize(); + if (best.x > sz.x) + sz.x = best.x; + if (best.y > sz.y) + sz.y = best.y; + } + + return best; +} + #endif // wxUSE_BMPBUTTON +