Invalidate wxSpinCtrl best size when needed in wxGTK
Also fix the initial min and best size.
This commit is contained in:
committed by
Vadim Zeitlin
parent
f2286fc200
commit
d2776b2fba
@@ -267,6 +267,8 @@ void wxSpinCtrlGTKBase::DoSetRange(double minVal, double maxVal)
|
|||||||
|
|
||||||
wxSpinCtrlEventDisabler disable(this);
|
wxSpinCtrlEventDisabler disable(this);
|
||||||
gtk_spin_button_set_range( GTK_SPIN_BUTTON(m_widget), minVal, maxVal);
|
gtk_spin_button_set_range( GTK_SPIN_BUTTON(m_widget), minVal, maxVal);
|
||||||
|
|
||||||
|
InvalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinCtrlGTKBase::DoSetIncrement(double inc)
|
void wxSpinCtrlGTKBase::DoSetIncrement(double inc)
|
||||||
@@ -354,15 +356,8 @@ GdkWindow *wxSpinCtrlGTKBase::GTKGetWindow(wxArrayGdkWindows& windows) const
|
|||||||
wxSize wxSpinCtrlGTKBase::DoGetBestSize() const
|
wxSize wxSpinCtrlGTKBase::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
const int minVal = static_cast<int>(DoGetMin());
|
const int minVal = static_cast<int>(DoGetMin());
|
||||||
const int lenMin = wxString::Format("%d", minVal).length();
|
|
||||||
|
|
||||||
const int maxVal = static_cast<int>(DoGetMax());
|
const int maxVal = static_cast<int>(DoGetMax());
|
||||||
const int lenMax = wxString::Format("%d", maxVal).length();
|
return wxPrivate::wxSpinCtrlGetBestSize(this, minVal, maxVal, GetBase());
|
||||||
|
|
||||||
wxString longestText(wxMax(lenMin, lenMax), '9');
|
|
||||||
if ( minVal < 0 )
|
|
||||||
longestText.insert(0, "-");
|
|
||||||
return DoGetSizeFromTextSize(GetTextExtent(longestText).x, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const
|
wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const
|
||||||
@@ -477,6 +472,11 @@ bool wxSpinCtrl::SetBase(int base)
|
|||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
|
// Update the displayed text after changing the base it uses.
|
||||||
|
SetValue(GetValue());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user