]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/spinctlg.h
corrections for final release of Mac OS X
[wxWidgets.git] / include / wx / generic / spinctlg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/spinctlg.h
3 // Purpose: generic wxSpinCtrl class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 28.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GENERIC_SPINCTRL_H_
13 #define _WX_GENERIC_SPINCTRL_H_
14
15 #include "wx/textctrl.h"
16
17 // ----------------------------------------------------------------------------
18 // generic wxSpinCtrl is just a text control
19 // ----------------------------------------------------------------------------
20
21 class WXDLLEXPORT wxSpinCtrl : public wxTextCtrl
22 {
23 public:
24 wxSpinCtrl() { Init(); }
25
26 wxSpinCtrl(wxWindow *parent,
27 wxWindowID id = -1,
28 const wxString& value = wxEmptyString,
29 const wxPoint& pos = wxDefaultPosition,
30 const wxSize& size = wxDefaultSize,
31 long style = wxSP_ARROW_KEYS,
32 int min = 0, int max = 100, int initial = 0,
33 const wxString& name = _T("wxSpinCtrl"))
34 {
35 Create(parent, id, value, pos, size, style, min, max, initial, name);
36 }
37
38 bool Create(wxWindow *parent,
39 wxWindowID id = -1,
40 const wxString& value = wxEmptyString,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxSP_ARROW_KEYS,
44 int min = 0, int max = 100, int initial = 0,
45 const wxString& name = _T("wxSpinCtrl"))
46 {
47 SetRange(min, max);
48
49 bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
50 wxDefaultValidator, name);
51 SetValue(initial);
52
53 return ok;
54 }
55
56 // accessors
57 int GetValue(int WXUNUSED(dummy) = 1) const
58 {
59 int n;
60 if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n) != 1) )
61 n = INT_MIN;
62
63 return n;
64 }
65
66 int GetMin() const { return m_min; }
67 int GetMax() const { return m_max; }
68
69 // operations
70 void SetValue(const wxString& value) { wxTextCtrl::SetValue(value); }
71 void SetValue(int val) { wxString s; s << val; wxTextCtrl::SetValue(s); }
72 void SetRange(int min, int max) { m_min = min; m_max = max; }
73
74 protected:
75 // initialize m_min/max with the default values
76 void Init() { SetRange(0, 100); }
77
78 int m_min;
79 int m_max;
80
81 private:
82 DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
83 };
84
85 #endif // _WX_GENERIC_SPINCTRL_H_
86