+ wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100),
+ m_increment(1), m_snap_to_ticks(false),
+ m_format(wxT("%g")) { }
+
+ 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("wxSpinCtrl"))
+ {
+ m_min = min;
+ m_max = max;
+ m_value = initial;
+ m_increment = inc;
+
+ bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
+ wxDefaultValidator, name);
+ DoSetValue(initial);
+
+ return ok;
+ }
+
+ // accessors
+ // T GetValue() const
+ // T GetMin() const
+ // T GetMax() const
+ // T GetIncrement() const
+ virtual bool GetSnapToTicks() const { return m_snap_to_ticks; }
+ // unsigned GetDigits() const - wxSpinCtrlDouble only
+
+ // operations
+ virtual void SetValue(const wxString& text) { wxTextCtrl::SetValue(text); }
+ // void SetValue(T val)
+ // void SetRange(T minVal, T maxVal)
+ // void SetIncrement(T inc)
+ virtual void SetSnapToTicks(bool snap_to_ticks)
+ { m_snap_to_ticks = snap_to_ticks; }
+ // void SetDigits(unsigned digits) - wxSpinCtrlDouble only
+
+ // Select text in the textctrl
+ //void SetSelection(long from, long to);
+
+protected:
+ // generic double valued
+ double DoGetValue() const
+ {
+ double n;
+ if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%lf"), &n) != 1) )
+ n = INT_MIN;
+
+ return n;
+ }
+
+ 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;
+};