diff --git a/include/wx/gtk/spinctrl.h b/include/wx/gtk/spinctrl.h index 267bd94de5..5fb19b4162 100644 --- a/include/wx/gtk/spinctrl.h +++ b/include/wx/gtk/spinctrl.h @@ -243,7 +243,7 @@ public: void SetValue(const wxString& value) wxOVERRIDE { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc void SetValue(double value) { DoSetValue(value); } void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } - void SetIncrement(double inc) { DoSetIncrement(inc); } + void SetIncrement(double inc); void SetDigits(unsigned digits); virtual int GetBase() const wxOVERRIDE { return 10; } diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 637fb60592..c327734e8a 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -643,6 +643,18 @@ void wxSpinCtrlDouble::GtkSetEntryWidth() gtk_entry_set_width_chars(GTK_ENTRY(m_widget), wxMax(lenMin, lenMax)); } +void wxSpinCtrlDouble::SetIncrement(double inc) +{ + DoSetIncrement(inc); + + const unsigned digits = wxSpinCtrlImpl::DetermineDigits(inc); + + // Increase the number of digits, if necessary, to show all numbers that + // can be obtained by using the new increment without loss of precision. + if ( digits > GetDigits() ) + SetDigits(digits); +} + unsigned wxSpinCtrlDouble::GetDigits() const { wxCHECK_MSG( m_widget, 0, "invalid spin button" );