Update font of wxSpinCtrl when DPI changes
Fix position of spin control in wxSpinCtrlDouble after DPI change The old size of the control was used to determine the position. Use GetBestSize instead, which will return the correct size.
This commit is contained in:
@@ -131,6 +131,7 @@ protected:
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wxOVERRIDE;
|
||||
virtual bool MSWOnScroll(int orientation, WXWORD wParam,
|
||||
WXWORD pos, WXHWND control) wxOVERRIDE;
|
||||
virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE;
|
||||
|
||||
// handle processing of special keys
|
||||
void OnChar(wxKeyEvent& event);
|
||||
|
@@ -298,7 +298,14 @@ void wxSpinCtrlGenericBase::DoMoveWindow(int x, int y, int width, int height)
|
||||
wxControl::DoMoveWindow(x, y, width, height);
|
||||
|
||||
// position the subcontrols inside the client area
|
||||
wxSize sizeBtn = m_spinButton->GetSize();
|
||||
|
||||
// Use GetBestSize instead of GetSize to get the size of the spin control.
|
||||
// This fixes a problem on wxMSW when the size is set after a DPI change.
|
||||
// GetSize returns the old, invalid, size. GetBestSize will return the size
|
||||
// that the control should be. Normally, GetBestSize and GetSize should
|
||||
// always return the same value because the size of the spinButton never
|
||||
// changes.
|
||||
wxSize sizeBtn = m_spinButton->GetBestSize();
|
||||
|
||||
wxCoord wText = width - sizeBtn.x - MARGIN;
|
||||
m_textCtrl->SetSize(0, 0, wText, height);
|
||||
|
@@ -223,6 +223,14 @@ void wxSpinCtrl::OnKillFocus(wxFocusEvent& event)
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxSpinCtrl::MSWUpdateFontOnDPIChange(const wxSize& newDPI)
|
||||
{
|
||||
wxSpinButton::MSWUpdateFontOnDPIChange(newDPI);
|
||||
|
||||
if ( m_font.IsOk() )
|
||||
wxSetWindowFont(GetBuddyHwnd(), m_font);
|
||||
}
|
||||
|
||||
void wxSpinCtrl::OnSetFocus(wxFocusEvent& event)
|
||||
{
|
||||
// when we get focus, give it to our buddy window as it needs it more than
|
||||
@@ -577,7 +585,8 @@ bool wxSpinCtrl::SetFont(const wxFont& font)
|
||||
return false;
|
||||
}
|
||||
|
||||
wxSetWindowFont(GetBuddyHwnd(), GetFont());
|
||||
if ( m_font.IsOk() )
|
||||
wxSetWindowFont(GetBuddyHwnd(), m_font);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user