]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/spinctlg.h
added a WXDLLEXPORT
[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 SetValue(initial);
48 SetRange(min, max);
49
50 return wxTextCtrl::Create(parent, id, value, pos, size, style,
51 wxDefaultValidator, name);
52 }
53
54 // accessors
55 int GetValue(int WXUNUSED(dummy) = 1) const
56 {
57 int n;
58 if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n) != 1) )
59 n = INT_MIN;
60
61 return n;
62 }
63
64 int GetMin() const { return m_min; }
65 int GetMax() const { return m_max; }
66
67 // operations
68 void SetValue(const wxString& value) { wxTextCtrl::SetValue(value); }
69 void SetValue(int val) { wxString s; s << val; wxTextCtrl::SetValue(s); }
70 void SetRange(int min, int max) { m_min = min; m_max = max; }
71
72 protected:
73 // initialize m_min/max with the default values
74 void Init() { SetRange(0, 100); }
75
76 int m_min;
77 int m_max;
78 };
79
80 #endif // _WX_GENERIC_SPINCTRL_H_
81