X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8cd6a9ad50c00a94e62558a3b55e814028d81100..8e77fd8bca165aab9709649d79a7cbc6a172d4e1:/include/wx/gtk/spinctrl.h?ds=inline diff --git a/include/wx/gtk/spinctrl.h b/include/wx/gtk/spinctrl.h index da0fd6c8ce..8890030a4b 100644 --- a/include/wx/gtk/spinctrl.h +++ b/include/wx/gtk/spinctrl.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: spinctrl.h +// Name: wx/gtk/spinctrl.h // Purpose: wxSpinCtrl class // Author: Robert Roebling // Modified by: @@ -23,16 +23,15 @@ class WXDLLIMPEXP_CORE wxSpinCtrlGTKBase : public wxSpinCtrlBase { public: - wxSpinCtrlGTKBase() : m_value(0) {} - 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, - double min = 0, double max = 100, double initial = 0, double inc = 1, - const wxString& name = _T("wxSpinCtrlGTKBase")); + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + long style, + double min, double max, double initial, + double inc, + const wxString& name); // wxSpinCtrl(Double) methods call DoXXX functions of the same name @@ -59,10 +58,7 @@ public: // implementation void OnChar( wxKeyEvent &event ); - double m_value; // public for GTK callback function - protected: - double DoGetValue() const; double DoGetMin() const; double DoGetMax() const; @@ -77,14 +73,13 @@ protected: void GtkEnableEvents() const; virtual wxSize DoGetBestSize() const; + virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; // Widgets that use the style->base colour for the BG colour should // override this and return true. virtual bool UseGTKStyleBase() const { return true; } -private: - DECLARE_DYNAMIC_CLASS(wxSpinCtrlGTKBase) DECLARE_EVENT_TABLE() }; @@ -95,16 +90,18 @@ private: class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGTKBase { public: - wxSpinCtrl() {} + 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, + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, - const wxString& name = _T("wxSpinCtrl")) + const wxString& name = wxS("wxSpinCtrl")) { + Init(); + Create(parent, id, value, pos, size, style, min, max, initial, name); } @@ -113,26 +110,38 @@ public: const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, - const wxString& name = _T("wxSpinCtrl")) + const wxString& name = wxS("wxSpinCtrl")) { - return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, style, min, max, initial, 1, name); + return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, + style, min, max, initial, 1, name); } // accessors - int GetValue() const { return int(DoGetValue() + 0.5); } - int GetMin() const { return int(DoGetMin() + 0.5); } - int GetMax() const { return int(DoGetMax() + 0.5); } - int GetIncrement() const { return int(DoGetIncrement() + 0.5); } + int GetValue() const { return int(DoGetValue()); } + int GetMin() const { return int(DoGetMin()); } + int GetMax() const { return int(DoGetMax()); } + int GetIncrement() const { return int(DoGetIncrement()); } // operations void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc void SetValue( int value ) { DoSetValue(value); } void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } - void SetIncrement( double inc ) { DoSetIncrement(inc); } + void SetIncrement(int inc) { DoSetIncrement(inc); } + + virtual int GetBase() const { return m_base; } + virtual bool SetBase(int base); private: + // Common part of all ctors. + void Init() + { + m_base = 10; + } + + int m_base; + DECLARE_DYNAMIC_CLASS(wxSpinCtrl) }; @@ -149,11 +158,13 @@ public: const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, - double min = 0, double max = 100, double initial = 0, double inc = 1, - const wxString& name = _T("wxSpinCtrlDouble")) + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + double min = 0, double max = 100, double initial = 0, + double inc = 1, + const wxString& name = wxS("wxSpinCtrlDouble")) { - Create(parent, id, value, pos, size, style, min, max, initial, inc, name); + Create(parent, id, value, pos, size, style, + min, max, initial, inc, name); } bool Create(wxWindow *parent, @@ -161,11 +172,13 @@ public: const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, - double min = 0, double max = 100, double initial = 0, double inc = 1, - const wxString& name = _T("wxSpinCtrlDouble")) + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + double min = 0, double max = 100, double initial = 0, + double inc = 1, + const wxString& name = wxS("wxSpinCtrlDouble")) { - return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, style, min, max, initial, inc, name); + return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, + style, min, max, initial, inc, name); } // accessors @@ -182,7 +195,9 @@ public: void SetIncrement(double inc) { DoSetIncrement(inc); } void SetDigits(unsigned digits); -private: + virtual int GetBase() const { return 10; } + virtual bool SetBase(int WXUNUSED(base)) { return false; } + DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble) };