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