]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/spinctlg.h
Add the options stuff to settings.
[wxWidgets.git] / include / wx / generic / spinctlg.h
CommitLineData
669a6e11
VZ
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
fd88dcbc
GD
15#ifdef __GNUG__
16 #pragma interface "spinctlg.h"
17#endif
18
669a6e11
VZ
19#include "wx/textctrl.h"
20
21// ----------------------------------------------------------------------------
22// generic wxSpinCtrl is just a text control
23// ----------------------------------------------------------------------------
24
25class WXDLLEXPORT wxSpinCtrl : public wxTextCtrl
26{
27public:
c71830c3
VZ
28 wxSpinCtrl() { Init(); }
29
30 wxSpinCtrl(wxWindow *parent,
31 wxWindowID id = -1,
32 const wxString& value = wxEmptyString,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize,
35 long style = wxSP_ARROW_KEYS,
36 int min = 0, int max = 100, int initial = 0,
37 const wxString& name = _T("wxSpinCtrl"))
38 {
39 Create(parent, id, value, pos, size, style, min, max, initial, name);
40 }
41
42 bool Create(wxWindow *parent,
43 wxWindowID id = -1,
44 const wxString& value = wxEmptyString,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = wxSP_ARROW_KEYS,
48 int min = 0, int max = 100, int initial = 0,
49 const wxString& name = _T("wxSpinCtrl"))
50 {
c71830c3
VZ
51 SetRange(min, max);
52
2f5292c3
VZ
53 bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
54 wxDefaultValidator, name);
6adaedf0 55 SetValue(initial);
2f5292c3
VZ
56
57 return ok;
c71830c3 58 }
669a6e11
VZ
59
60 // accessors
c71830c3 61 int GetValue(int WXUNUSED(dummy) = 1) const
669a6e11
VZ
62 {
63 int n;
64 if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n) != 1) )
65 n = INT_MIN;
66
67 return n;
68 }
69
70 int GetMin() const { return m_min; }
71 int GetMax() const { return m_max; }
72
73 // operations
74 void SetValue(const wxString& value) { wxTextCtrl::SetValue(value); }
75 void SetValue(int val) { wxString s; s << val; wxTextCtrl::SetValue(s); }
76 void SetRange(int min, int max) { m_min = min; m_max = max; }
77
78protected:
79 // initialize m_min/max with the default values
80 void Init() { SetRange(0, 100); }
81
82 int m_min;
83 int m_max;
5fde6fcc
GD
84
85private:
86 DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
669a6e11
VZ
87};
88
89#endif // _WX_GENERIC_SPINCTRL_H_
90