From 4bf152c5b498705c55a07a827f6b4a8425377ab7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Feb 2011 12:45:24 +0000 Subject: [PATCH] Only use wxBU_EXACTFIT for width calculations in wxMSW wxButton. wxBU_EXACTFIT should affect the width of the button best size but not its height which should be at least the same as the height of a standard button even when wxBU_EXACTFIT is specified, otherwise buttons created with it (like the one in generic wxCollapsiblePane implementation) look completely ugly. This commit restores the old behaviour which was recently changed by wxButton sizing code simplifications. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67045 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/button.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 1a9b4d6ca2..e08d58e3be 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -410,22 +410,27 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size { wxSize sizeBtn(size); - // 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 + // All buttons have at least the standard height and, unless the user + // explicitly wants them to be as small as possible and used wxBU_EXACTFIT + // style to indicate this, of at least the standard width too. + // + // Notice that we really want to make all buttons equally high, otherwise + // they look ugly and the existing code using wxBU_EXACTFIT only uses it to + // control width and not height. + + // The 50x14 button size is documented in the "Recommended sizing and + // spacing" section of MSDN layout article. + // + // Note that we intentionally don't use GetDefaultSize() here, because + // it's inexact -- dialog units depend on this dialog's font. + const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14)); if ( !btn->HasFlag(wxBU_EXACTFIT) ) { - // The 50x14 button size is documented in the "Recommended sizing and - // spacing" section of MSDN layout article. - // - // Note that we intentionally don't use GetDefaultSize() here, because - // it's inexact -- dialog units depend on this dialog's font. - wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14)); if ( sizeBtn.x < sizeDef.x ) sizeBtn.x = sizeDef.x; - if ( sizeBtn.y < sizeDef.y ) - sizeBtn.y = sizeDef.y; } + if ( sizeBtn.y < sizeDef.y ) + sizeBtn.y = sizeDef.y; btn->CacheBestSize(sizeBtn); -- 2.45.2