Improve button heights at high DPI on wxMSW

Don't use FromDIP together with ConvertDialogToPixels, because the font height
is already adjusted to the DPI.
Also limit the button height at higher DPI. Because the height determined by
ConvertDialogToPixels is higher than standard buttons use on Windows.

Closes #18528
This commit is contained in:
Maarten Bent 2019-10-11 19:22:07 +02:00
parent a0359a23ff
commit 591136c7bc
2 changed files with 11 additions and 4 deletions

View File

@ -431,8 +431,15 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size
//
// 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(btn->FromDIP(wxSize(50, 14)));
wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
if ( btn->GetContentScaleFactor() > 1.0 )
{
// At higher DPI, the returned height is too big compared to
// standard Windows buttons (like Save, Open, OK). FromDIP(25)
// matches the size of the buttons in standard Windows dialogs, see
// https://trac.wxwidgets.org/ticket/18528 for the discussion.
sizeDef.y = btn->FromDIP(25);
}
sizeBtn.IncTo(sizeDef);
}
else // wxBU_EXACTFIT case

View File

@ -122,9 +122,9 @@ wxSize wxGauge::DoGetBestSize() const
// the smaller one.
if (HasFlag(wxGA_VERTICAL))
return ConvertDialogToPixels(FromDIP(wxSize(8, 107)));
return ConvertDialogToPixels(wxSize(8, 107));
else
return ConvertDialogToPixels(FromDIP(wxSize(107, 8)));
return ConvertDialogToPixels(wxSize(107, 8));
}
// ----------------------------------------------------------------------------