From bd388e9827c004a55bc971a32350523320ae7919 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Jun 2016 03:19:51 +0200 Subject: [PATCH] Make wxBU_EXACTFIT buttons less tall in wxMSW The ellipsis buttons of wxFilePickerCtrl (and similar controls) with wxFLP_SMALL style looked too big because their min height was greater than that of the accompanying text control. Fix this by making the buttons as tall as text controls and not as tall as standard buttons, this seems to be more aesthetically pleasing. --- src/msw/anybutton.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index f5767b089e..034dbce424 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -414,7 +414,7 @@ wxSize wxMSWButton::GetFittingSize(wxWindow *win, { // We still need some margin or the text would be overwritten, just // make it as small as possible. - sizeBtn.x += (3*win->GetCharWidth()); + sizeBtn.x += 2*win->GetCharWidth(); } else { @@ -443,30 +443,23 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size { wxSize sizeBtn(size); - // 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)); - - // All buttons should have at least the standard size, unless the user - // explicitly wants them to be as small as possible and used wxBU_EXACTFIT - // style to indicate this. - const bool incToStdSize = !btn->HasFlag(wxBU_EXACTFIT); - if ( incToStdSize ) + // By default all buttons have at least the standard size. + if ( !btn->HasFlag(wxBU_EXACTFIT) ) { - if ( sizeBtn.x < sizeDef.x ) - sizeBtn.x = sizeDef.x; + // 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)); + + sizeBtn.IncTo(sizeDef); } - - // Notice that we really want to make all buttons with text label equally - // high, otherwise they look ugly and the existing code using wxBU_EXACTFIT - // only uses it to control width and not height. - if ( incToStdSize || !btn->GetLabel().empty() ) + else // wxBU_EXACTFIT case { - if ( sizeBtn.y < sizeDef.y ) - sizeBtn.y = sizeDef.y; + // Such buttons are typically used alongside a text control or similar, + // so make them as high as it. + sizeBtn.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(size.y); } btn->CacheBestSize(sizeBtn);