Preserve wxSlider value when changing its range in wxOSX too.

This fix is similar to r66368 for wxMSW and preserves the slider value when
its range changes. This is necessary because while the underlying native
control value doesn't change when the range is, the logical value of wxSlider
does change if it must be inversed as this depends on the range.

See #12765.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-12-19 14:08:42 +00:00
parent f74ab0041b
commit 1c7ce07347

View File

@ -166,6 +166,12 @@ void wxSlider::SetValue(int value)
void wxSlider::SetRange(int minValue, int maxValue)
{
// Changing the range preserves the value of the native control but may
// change our logical value if we're inverting the native value to get it
// as ValueInvertOrNot() depends on the range so preserve it before
// changing the range.
const int valueOld = GetValue();
wxString value;
m_rangeMin = minValue;
@ -196,6 +202,9 @@ void wxSlider::SetRange(int minValue, int maxValue)
SetValue(m_rangeMin);
else if(currentValue > m_rangeMax)
SetValue(m_rangeMax);
// Ensure that our value didn't change.
SetValue(valueOld);
}
// For trackbars only