Fix best size of wxMSW wxSpinCtrl with non-default font

This has been broken by dce65bed1c after
which the actual font used for the control was not taken into account
any longer. Fix this by ensuring the wxTextCtrl used for size
calculation uses the same font as wxSpinCtrl itself.

See #12297, #18391.

Closes #18427.
This commit is contained in:
Vadim Zeitlin
2019-07-02 11:43:06 +02:00
parent 2ff910de4f
commit 3e728170b2

View File

@@ -739,6 +739,11 @@ wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
wxTextCtrl text;
TempHWNDSetter set(&text, m_hwndBuddy);
// It's unnecessary to actually change the font used by the buddy control,
// but we do need to ensure that the helper wxTextCtrl wxFont matches what
// it is used as GetSizeFromTextSize() uses the current font.
text.wxWindowBase::SetFont(GetFont());
// Increase the width to accommodate the button, which should fit inside
// the text control while taking account of the overlap.
return text.GetSizeFromTextSize(xlen + sizeBtn.x - GetOverlap(), ylen);