Don't increase button height in wxMSWButton::GetFittingSize().

This is unnecessary and resulted in too high buttons in some cases for buttons
with images. As we increase the button height to at least the standard value
later in all code using function anyhow, it's not necessary to do anything
with the height inside it.

Now the buttons with an image get the same height whether they have the text
or not.

This change also gets rid of (completely arbitrary) decision to use 11/10 of
the label height when computing the fitting button size and it's always nice
to get rid of dirty hacks like this.

Closes #12924.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-02-14 22:12:16 +00:00
parent 1e43584aa7
commit 738764c0e6

View File

@@ -388,7 +388,6 @@ wxSize wxMSWButton::GetFittingSize(wxWindow *win,
wxSize sizeBtn = sizeLabel; wxSize sizeBtn = sizeLabel;
sizeBtn.x += 3*win->GetCharWidth(); sizeBtn.x += 3*win->GetCharWidth();
sizeBtn.y = 11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(sizeLabel.y)/10;
// account for the shield UAC icon if we have it // account for the shield UAC icon if we have it
if ( flags & Size_AuthNeeded ) if ( flags & Size_AuthNeeded )
@@ -416,7 +415,9 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size
// creating the button // creating the button
if ( !btn->HasFlag(wxBU_EXACTFIT) ) if ( !btn->HasFlag(wxBU_EXACTFIT) )
{ {
// The size of a standard button in the dialog units is 50x14, use it. // 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 // Note that we intentionally don't use GetDefaultSize() here, because
// it's inexact -- dialog units depend on this dialog's font. // it's inexact -- dialog units depend on this dialog's font.
wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14)); wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
@@ -604,10 +605,8 @@ wxSize wxButton::DoGetBestSize() const
wxSize size; wxSize size;
// account for the text part if we have it or if we don't have any image at // Account for the text part if we have it.
// all (buttons initially created with empty label should still have a non if ( ShowsLabel() )
// zero size)
if ( ShowsLabel() || !m_imageData )
{ {
int flags = 0; int flags = 0;
if ( GetAuthNeeded() ) if ( GetAuthNeeded() )