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