]>
Commit | Line | Data |
---|---|---|
738f9e5a | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/gtk/spinctrl.h |
738f9e5a RR |
3 | // Purpose: wxSpinCtrl class |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) Robert Roebling | |
65571936 | 8 | // Licence: wxWindows licence |
738f9e5a RR |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
0416c418 PC |
11 | #ifndef _WX_GTK_SPINCTRL_H_ |
12 | #define _WX_GTK_SPINCTRL_H_ | |
a075e27b | 13 | |
738f9e5a | 14 | //----------------------------------------------------------------------------- |
8cd6a9ad VZ |
15 | // wxSpinCtrlGTKBase - Base class for GTK versions of the wxSpinCtrl[Double] |
16 | // | |
17 | // This class manages a double valued GTK spinctrl through the DoGet/SetXXX | |
18 | // functions that are made public as Get/SetXXX functions for int or double | |
19 | // for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid | |
20 | // function ambiguity. | |
738f9e5a RR |
21 | //----------------------------------------------------------------------------- |
22 | ||
8cd6a9ad | 23 | class WXDLLIMPEXP_CORE wxSpinCtrlGTKBase : public wxSpinCtrlBase |
738f9e5a RR |
24 | { |
25 | public: | |
738f9e5a | 26 | bool Create(wxWindow *parent, |
845a6bbf PC |
27 | wxWindowID id, |
28 | const wxString& value, | |
29 | const wxPoint& pos, | |
30 | const wxSize& size, | |
31 | long style, | |
32 | double min, double max, double initial, | |
33 | double inc, | |
34 | const wxString& name); | |
738f9e5a | 35 | |
8cd6a9ad VZ |
36 | // wxSpinCtrl(Double) methods call DoXXX functions of the same name |
37 | ||
38 | // accessors | |
39 | // T GetValue() const | |
40 | // T GetMin() const | |
41 | // T GetMax() const | |
42 | // T GetIncrement() const | |
43 | virtual bool GetSnapToTicks() const; | |
ce89fdd2 | 44 | |
8cd6a9ad VZ |
45 | // operations |
46 | virtual void SetValue(const wxString& value); | |
47 | // void SetValue(T val) | |
48 | // void SetRange(T minVal, T maxVal) | |
49 | // void SetIncrement(T inc) | |
50 | void SetSnapToTicks( bool snap_to_ticks ); | |
51 | ||
52 | // Select text in the textctrl | |
53 | void SetSelection(long from, long to); | |
738f9e5a | 54 | |
9d522606 RD |
55 | static wxVisualAttributes |
56 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
8cd6a9ad | 57 | |
ce89fdd2 | 58 | // implementation |
da048e3d | 59 | void OnChar( wxKeyEvent &event ); |
8cd6a9ad | 60 | |
9d9b7755 | 61 | protected: |
8cd6a9ad VZ |
62 | double DoGetValue() const; |
63 | double DoGetMin() const; | |
64 | double DoGetMax() const; | |
65 | double DoGetIncrement() const; | |
66 | ||
67 | void DoSetValue(double val); | |
68 | void DoSetValue(const wxString& strValue); | |
69 | void DoSetRange(double min_val, double max_val); | |
70 | void DoSetIncrement(double inc); | |
71 | ||
28529e37 RR |
72 | void GtkDisableEvents() const; |
73 | void GtkEnableEvents() const; | |
74 | ||
9d9b7755 | 75 | virtual wxSize DoGetBestSize() const; |
ef5c70f9 | 76 | virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; |
9d9b7755 | 77 | |
9d522606 RD |
78 | // Widgets that use the style->base colour for the BG colour should |
79 | // override this and return true. | |
80 | virtual bool UseGTKStyleBase() const { return true; } | |
81 | ||
da048e3d | 82 | DECLARE_EVENT_TABLE() |
738f9e5a RR |
83 | }; |
84 | ||
8cd6a9ad VZ |
85 | //----------------------------------------------------------------------------- |
86 | // wxSpinCtrl - An integer valued spin control | |
87 | //----------------------------------------------------------------------------- | |
88 | ||
89 | class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGTKBase | |
90 | { | |
91 | public: | |
92 | wxSpinCtrl() {} | |
93 | wxSpinCtrl(wxWindow *parent, | |
94 | wxWindowID id = wxID_ANY, | |
95 | const wxString& value = wxEmptyString, | |
96 | const wxPoint& pos = wxDefaultPosition, | |
97 | const wxSize& size = wxDefaultSize, | |
99e788d5 | 98 | long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, |
8cd6a9ad | 99 | int min = 0, int max = 100, int initial = 0, |
845a6bbf | 100 | const wxString& name = wxS("wxSpinCtrl")) |
8cd6a9ad VZ |
101 | { |
102 | Create(parent, id, value, pos, size, style, min, max, initial, name); | |
103 | } | |
104 | ||
105 | bool Create(wxWindow *parent, | |
106 | wxWindowID id = wxID_ANY, | |
107 | const wxString& value = wxEmptyString, | |
108 | const wxPoint& pos = wxDefaultPosition, | |
109 | const wxSize& size = wxDefaultSize, | |
99e788d5 | 110 | long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, |
8cd6a9ad | 111 | int min = 0, int max = 100, int initial = 0, |
845a6bbf | 112 | const wxString& name = wxS("wxSpinCtrl")) |
8cd6a9ad | 113 | { |
99e788d5 VZ |
114 | return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, |
115 | style, min, max, initial, 1, name); | |
8cd6a9ad VZ |
116 | } |
117 | ||
118 | // accessors | |
f0368d28 PC |
119 | int GetValue() const { return int(DoGetValue()); } |
120 | int GetMin() const { return int(DoGetMin()); } | |
121 | int GetMax() const { return int(DoGetMax()); } | |
122 | int GetIncrement() const { return int(DoGetIncrement()); } | |
8cd6a9ad VZ |
123 | |
124 | // operations | |
125 | void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc | |
126 | void SetValue( int value ) { DoSetValue(value); } | |
127 | void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } | |
92e164ff | 128 | void SetIncrement(int inc) { DoSetIncrement(inc); } |
8cd6a9ad | 129 | |
8cd6a9ad VZ |
130 | DECLARE_DYNAMIC_CLASS(wxSpinCtrl) |
131 | }; | |
132 | ||
133 | //----------------------------------------------------------------------------- | |
134 | // wxSpinCtrlDouble - a double valued spin control | |
135 | //----------------------------------------------------------------------------- | |
136 | ||
137 | class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGTKBase | |
138 | { | |
139 | public: | |
140 | wxSpinCtrlDouble() {} | |
141 | wxSpinCtrlDouble(wxWindow *parent, | |
142 | wxWindowID id = wxID_ANY, | |
143 | const wxString& value = wxEmptyString, | |
144 | const wxPoint& pos = wxDefaultPosition, | |
145 | const wxSize& size = wxDefaultSize, | |
99e788d5 VZ |
146 | long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, |
147 | double min = 0, double max = 100, double initial = 0, | |
148 | double inc = 1, | |
845a6bbf | 149 | const wxString& name = wxS("wxSpinCtrlDouble")) |
8cd6a9ad | 150 | { |
99e788d5 VZ |
151 | Create(parent, id, value, pos, size, style, |
152 | min, max, initial, inc, name); | |
8cd6a9ad VZ |
153 | } |
154 | ||
155 | bool Create(wxWindow *parent, | |
156 | wxWindowID id = wxID_ANY, | |
157 | const wxString& value = wxEmptyString, | |
158 | const wxPoint& pos = wxDefaultPosition, | |
159 | const wxSize& size = wxDefaultSize, | |
99e788d5 VZ |
160 | long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, |
161 | double min = 0, double max = 100, double initial = 0, | |
162 | double inc = 1, | |
845a6bbf | 163 | const wxString& name = wxS("wxSpinCtrlDouble")) |
8cd6a9ad | 164 | { |
99e788d5 VZ |
165 | return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, |
166 | style, min, max, initial, inc, name); | |
8cd6a9ad VZ |
167 | } |
168 | ||
169 | // accessors | |
170 | double GetValue() const { return DoGetValue(); } | |
171 | double GetMin() const { return DoGetMin(); } | |
172 | double GetMax() const { return DoGetMax(); } | |
173 | double GetIncrement() const { return DoGetIncrement(); } | |
174 | unsigned GetDigits() const; | |
175 | ||
176 | // operations | |
177 | void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc | |
178 | void SetValue(double value) { DoSetValue(value); } | |
179 | void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } | |
180 | void SetIncrement(double inc) { DoSetIncrement(inc); } | |
181 | void SetDigits(unsigned digits); | |
182 | ||
8cd6a9ad VZ |
183 | DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble) |
184 | }; | |
185 | ||
0416c418 | 186 | #endif // _WX_GTK_SPINCTRL_H_ |