diff --git a/interface/wx/spinctrl.h b/interface/wx/spinctrl.h index edb2ac83b6..edec9b6dff 100644 --- a/interface/wx/spinctrl.h +++ b/interface/wx/spinctrl.h @@ -149,8 +149,8 @@ public: the numbers in the specified base when they are changed using the spin control arrows. - @note Under wxMSW setting a base to 16 is allowed only if current range - does not include negative values. + @note Under wxMSW and wxGTK setting a base to 16 is allowed only if + current range does not include negative values. @param base Numeric base, currently only 10 and 16 are supported. @@ -171,8 +171,8 @@ public: it is less than it now. However no @c wxEVT_SPINCTRL event is generated, even if it the value does change. - @note Under wxMSW setting a range including negative values is silently - ignored if current base is set to 16. + @note Under wxMSW and wxGTK setting a range including negative values + is silently ignored if current base is set to 16. */ void SetRange(int minVal, int maxVal); diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 85205b652a..14793ec74c 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -270,6 +270,12 @@ void wxSpinCtrlGTKBase::DoSetRange(double minVal, double maxVal) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); + // Negative values in the range are allowed only if base == 10 + if ( !wxSpinCtrlImpl::IsBaseCompatibleWithRange(minVal, maxVal, GetBase()) ) + { + return; + } + wxSpinCtrlEventDisabler disable(this); gtk_spin_button_set_range( GTK_SPIN_BUTTON(m_widget), minVal, maxVal); @@ -447,6 +453,10 @@ bool wxSpinCtrl::SetBase(int base) if ( base == m_base ) return true; + // For negative values in the range only base == 10 is allowed + if ( !wxSpinCtrlImpl::IsBaseCompatibleWithRange(static_cast(DoGetMin()), static_cast(DoGetMax()), base) ) + return false; + m_base = base; // We need to be able to enter letters for any base greater than 10.