]>
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"))
49 bool ok
= wxTextCtrl::Create(parent
, id
, value
, pos
, size
, style
,
50 wxDefaultValidator
, name
);
57 int GetValue(int WXUNUSED(dummy
) = 1) const
60 if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n
) != 1) )
66 int GetMin() const { return m_min
; }
67 int GetMax() const { return m_max
; }
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
; }
75 // initialize m_min/max with the default values
76 void Init() { SetRange(0, 100); }
82 #endif // _WX_GENERIC_SPINCTRL_H_