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