X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8fb50b7945492de005090f5f5b2bf9941a34071..d07f2e19181bc5caf29eb2338ce513be6fa42405:/include/wx/generic/spinctlg.h diff --git a/include/wx/generic/spinctlg.h b/include/wx/generic/spinctlg.h index a8dad8de5c..61c38b6a56 100644 --- a/include/wx/generic/spinctlg.h +++ b/include/wx/generic/spinctlg.h @@ -129,6 +129,10 @@ protected: // Send the correct event type virtual void DoSendEvent() = 0; + // Convert the text to/from the corresponding value. + virtual bool DoTextToValue(const wxString& text, double *val) = 0; + virtual wxString DoValueToText(double val) = 0; + // check if the value is in range bool InRange(double n) const { return (n >= m_min) && (n <= m_max); } @@ -141,7 +145,6 @@ protected: double m_max; double m_increment; bool m_snap_to_ticks; - wxString m_format; int m_spin_value; @@ -257,7 +260,7 @@ protected: class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase { public: - wxSpinCtrl() {} + wxSpinCtrl() { Init(); } wxSpinCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, @@ -267,6 +270,8 @@ public: 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); } @@ -296,9 +301,24 @@ public: 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) }; @@ -311,7 +331,7 @@ protected: class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase { public: - wxSpinCtrlDouble() : m_digits(0) { } + wxSpinCtrlDouble() { Init(); } wxSpinCtrlDouble(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, @@ -322,7 +342,8 @@ public: double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { - m_digits = 0; + Init(); + Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } @@ -357,11 +378,29 @@ public: void SetIncrement(double inc) { DoSetIncrement(inc); } void SetDigits(unsigned digits); + // We don't implement bases support for floating point numbers, this is not + // very useful in practice. + virtual int GetBase() const { return 10; } + virtual bool SetBase(int WXUNUSED(base)) { return 0; } + protected: virtual void DoSendEvent(); + virtual bool DoTextToValue(const wxString& text, double *val); + virtual wxString DoValueToText(double val); + unsigned m_digits; +private: + // Common part of all ctors. + void Init() + { + m_digits = 0; + m_format = wxS("%g"); + } + + wxString m_format; + DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble) };