]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/spinctlg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/spinctlg.h
3 // Purpose: generic wxSpinCtrl class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_SPINCTRL_H_
13 #define _WX_GENERIC_SPINCTRL_H_
15 #include "wx/textctrl.h"
17 // ----------------------------------------------------------------------------
18 // generic wxSpinCtrl is just a text control
19 // ----------------------------------------------------------------------------
21 class WXDLLEXPORT wxSpinCtrl
: public wxTextCtrl
24 wxSpinCtrl() { Init(); }
26 wxSpinCtrl(wxWindow
*parent
,
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"))
35 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
38 bool Create(wxWindow
*parent
,
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"))
50 return wxTextCtrl::Create(parent
, id
, value
, pos
, size
, style
,
51 wxDefaultValidator
, name
);
55 int GetValue(int WXUNUSED(dummy
) = 1) const
58 if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n
) != 1) )
64 int GetMin() const { return m_min
; }
65 int GetMax() const { return m_max
; }
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
; }
73 // initialize m_min/max with the default values
74 void Init() { SetRange(0, 100); }
80 #endif // _WX_GENERIC_SPINCTRL_H_