1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/spinctrl.h
3 // Purpose: wxSpinCtrl class
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_SPINCTRL_H_
12 #define _WX_GTK_SPINCTRL_H_
14 //-----------------------------------------------------------------------------
15 // wxSpinCtrlGTKBase - Base class for GTK versions of the wxSpinCtrl[Double]
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 //-----------------------------------------------------------------------------
23 class WXDLLIMPEXP_CORE wxSpinCtrlGTKBase
: public wxSpinCtrlBase
26 bool Create(wxWindow
*parent
,
28 const wxString
& value
,
32 double min
, double max
, double initial
,
34 const wxString
& name
);
36 // wxSpinCtrl(Double) methods call DoXXX functions of the same name
42 // T GetIncrement() const
43 virtual bool GetSnapToTicks() const;
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
);
52 // Select text in the textctrl
53 void SetSelection(long from
, long to
);
55 static wxVisualAttributes
56 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
59 void OnChar( wxKeyEvent
&event
);
62 double DoGetValue() const;
63 double DoGetMin() const;
64 double DoGetMax() const;
65 double DoGetIncrement() const;
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
);
72 void GtkDisableEvents() const;
73 void GtkEnableEvents() const;
75 virtual wxSize
DoGetBestSize() const;
76 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
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; }
82 DECLARE_DYNAMIC_CLASS(wxSpinCtrlGTKBase
)
86 //-----------------------------------------------------------------------------
87 // wxSpinCtrl - An integer valued spin control
88 //-----------------------------------------------------------------------------
90 class WXDLLIMPEXP_CORE wxSpinCtrl
: public wxSpinCtrlGTKBase
94 wxSpinCtrl(wxWindow
*parent
,
95 wxWindowID id
= wxID_ANY
,
96 const wxString
& value
= wxEmptyString
,
97 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxSize
& size
= wxDefaultSize
,
99 long style
= wxSP_ARROW_KEYS
| wxALIGN_RIGHT
,
100 int min
= 0, int max
= 100, int initial
= 0,
101 const wxString
& name
= wxS("wxSpinCtrl"))
103 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
106 bool Create(wxWindow
*parent
,
107 wxWindowID id
= wxID_ANY
,
108 const wxString
& value
= wxEmptyString
,
109 const wxPoint
& pos
= wxDefaultPosition
,
110 const wxSize
& size
= wxDefaultSize
,
111 long style
= wxSP_ARROW_KEYS
| wxALIGN_RIGHT
,
112 int min
= 0, int max
= 100, int initial
= 0,
113 const wxString
& name
= wxS("wxSpinCtrl"))
115 return wxSpinCtrlGTKBase::Create(parent
, id
, value
, pos
, size
,
116 style
, min
, max
, initial
, 1, name
);
120 int GetValue() const { return int(DoGetValue()); }
121 int GetMin() const { return int(DoGetMin()); }
122 int GetMax() const { return int(DoGetMax()); }
123 int GetIncrement() const { return int(DoGetIncrement()); }
126 void SetValue(const wxString
& value
) { wxSpinCtrlGTKBase::SetValue(value
); } // visibility problem w/ gcc
127 void SetValue( int value
) { DoSetValue(value
); }
128 void SetRange( int minVal
, int maxVal
) { DoSetRange(minVal
, maxVal
); }
129 void SetIncrement(int inc
) { DoSetIncrement(inc
); }
131 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
134 //-----------------------------------------------------------------------------
135 // wxSpinCtrlDouble - a double valued spin control
136 //-----------------------------------------------------------------------------
138 class WXDLLIMPEXP_CORE wxSpinCtrlDouble
: public wxSpinCtrlGTKBase
141 wxSpinCtrlDouble() {}
142 wxSpinCtrlDouble(wxWindow
*parent
,
143 wxWindowID id
= wxID_ANY
,
144 const wxString
& value
= wxEmptyString
,
145 const wxPoint
& pos
= wxDefaultPosition
,
146 const wxSize
& size
= wxDefaultSize
,
147 long style
= wxSP_ARROW_KEYS
| wxALIGN_RIGHT
,
148 double min
= 0, double max
= 100, double initial
= 0,
150 const wxString
& name
= wxS("wxSpinCtrlDouble"))
152 Create(parent
, id
, value
, pos
, size
, style
,
153 min
, max
, initial
, inc
, name
);
156 bool Create(wxWindow
*parent
,
157 wxWindowID id
= wxID_ANY
,
158 const wxString
& value
= wxEmptyString
,
159 const wxPoint
& pos
= wxDefaultPosition
,
160 const wxSize
& size
= wxDefaultSize
,
161 long style
= wxSP_ARROW_KEYS
| wxALIGN_RIGHT
,
162 double min
= 0, double max
= 100, double initial
= 0,
164 const wxString
& name
= wxS("wxSpinCtrlDouble"))
166 return wxSpinCtrlGTKBase::Create(parent
, id
, value
, pos
, size
,
167 style
, min
, max
, initial
, inc
, name
);
171 double GetValue() const { return DoGetValue(); }
172 double GetMin() const { return DoGetMin(); }
173 double GetMax() const { return DoGetMax(); }
174 double GetIncrement() const { return DoGetIncrement(); }
175 unsigned GetDigits() const;
178 void SetValue(const wxString
& value
) { wxSpinCtrlGTKBase::SetValue(value
); } // visibility problem w/ gcc
179 void SetValue(double value
) { DoSetValue(value
); }
180 void SetRange(double minVal
, double maxVal
) { DoSetRange(minVal
, maxVal
); }
181 void SetIncrement(double inc
) { DoSetIncrement(inc
); }
182 void SetDigits(unsigned digits
);
184 DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble
)
187 #endif // _WX_GTK_SPINCTRL_H_