+void wxSpinCtrlGenericBase::SetValue(const wxString& text)
+{
+ wxCHECK_RET( m_textCtrl, _T("invalid call to wxSpinCtrl::SetValue") );
+
+ double val;
+ if ( text.ToDouble(&val) && InRange(val) )
+ {
+ DoSetValue(val);
+ }
+ else // not a number at all or out of range
+ {
+ m_textCtrl->SetValue(text);
+ m_textCtrl->SetSelection(0, -1);
+ }
+}
+
+bool wxSpinCtrlGenericBase::DoSetValue(double val)
+{
+ wxCHECK_MSG( m_textCtrl, false, _T("invalid call to wxSpinCtrl::SetValue") );
+
+ if (!InRange(val))
+ return false;
+
+ if ( m_snap_to_ticks && (m_increment != 0) )
+ {
+ double snap_value = val / m_increment;
+
+ if (wxFinite(snap_value)) // FIXME what to do about a failure?
+ {
+ if ((snap_value - floor(snap_value)) < (ceil(snap_value) - snap_value))
+ val = floor(snap_value) * m_increment;
+ else
+ val = ceil(snap_value) * m_increment;
+ }
+ }
+
+ wxString str(wxString::Format(m_format.c_str(), val));
+
+ if ((val != m_value) || (str != m_textCtrl->GetValue()))
+ {
+ m_value = val;
+ str.ToDouble( &m_value ); // wysiwyg for textctrl
+ m_textCtrl->SetValue( str );
+ m_textCtrl->DiscardEdits();
+ return true;
+ }
+
+ return false;
+}
+
+double wxSpinCtrlGenericBase::AdjustToFitInRange(double value) const