+ bool DoSetValue(double val)
+ {
+ wxTextCtrl::SetValue(wxString::Format(m_format.c_str(), val));
+ return true;
+ }
+ void DoSetRange(double min_val, double max_val)
+ {
+ m_min = min_val;
+ m_max = max_val;
+ }
+ void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused
+
+ double m_value;
+ double m_min;
+ double m_max;
+ double m_increment;
+ bool m_snap_to_ticks;
+ wxString m_format;
+};
+
+#endif // wxUSE_SPINBTN/!wxUSE_SPINBTN
+
+#if !defined(wxHAS_NATIVE_SPINCTRL)
+
+//-----------------------------------------------------------------------------
+// wxSpinCtrl
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase
+{
+public:
+ wxSpinCtrl() { Init(); }
+ wxSpinCtrl(wxWindow *parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& value = wxEmptyString,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ int min = 0, int max = 100, int initial = 0,
+ const wxString& name = wxT("wxSpinCtrl"))
+ {
+ Init();
+
+ Create(parent, id, value, pos, size, style, min, max, initial, name);
+ }
+
+ bool Create(wxWindow *parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& value = wxEmptyString,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ int min = 0, int max = 100, int initial = 0,
+ const wxString& name = wxT("wxSpinCtrl"))
+ {
+ return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size,
+ style, min, max, initial, 1, name);
+ }
+
+ // accessors
+ int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue()); }
+ int GetMin() const { return int(m_min); }
+ int GetMax() const { return int(m_max); }
+ int GetIncrement() const { return int(m_increment); }
+
+ // operations
+ void SetValue(const wxString& value)
+ { wxSpinCtrlGenericBase::SetValue(value); }
+ void SetValue( int value ) { DoSetValue(value); }
+ void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); }
+ void SetIncrement(int inc) { DoSetIncrement(inc); }
+
+ virtual int GetBase() const { return m_base; }
+ virtual bool SetBase(int base);
+
+protected:
+ virtual void DoSendEvent();
+
+ virtual bool DoTextToValue(const wxString& text, double *val);
+ virtual wxString DoValueToText(double val);
+
+private:
+ // Common part of all ctors.
+ void Init()
+ {
+ m_base = 10;
+ }
+
+ int m_base;
+
+ DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
+};
+
+#endif // wxHAS_NATIVE_SPINCTRL
+
+//-----------------------------------------------------------------------------
+// wxSpinCtrlDouble
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase
+{
+public:
+ wxSpinCtrlDouble() { Init(); }
+ wxSpinCtrlDouble(wxWindow *parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& value = wxEmptyString,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ double min = 0, double max = 100, double initial = 0,
+ double inc = 1,
+ const wxString& name = wxT("wxSpinCtrlDouble"))
+ {
+ Init();
+
+ Create(parent, id, value, pos, size, style,
+ min, max, initial, inc, name);
+ }
+
+ bool Create(wxWindow *parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& value = wxEmptyString,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ double min = 0, double max = 100, double initial = 0,
+ double inc = 1,
+ const wxString& name = wxT("wxSpinCtrlDouble"))
+ {
+ return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size,
+ style, min, max, initial,
+ inc, name);
+ }
+
+ // accessors
+ double GetValue(wxSPINCTRL_GETVALUE_FIX) const { return DoGetValue(); }
+ double GetMin() const { return m_min; }
+ double GetMax() const { return m_max; }
+ double GetIncrement() const { return m_increment; }
+ unsigned GetDigits() const { return m_digits; }