+ 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;
+ }
+ }