]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/spinctlg.h
compile bug fix
[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
15#include "wx/textctrl.h"
16
17// ----------------------------------------------------------------------------
18// generic wxSpinCtrl is just a text control
19// ----------------------------------------------------------------------------
20
21class WXDLLEXPORT wxSpinCtrl : public wxTextCtrl
22{
23public:
c71830c3
VZ
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 {
c71830c3
VZ
47 SetRange(min, max);
48
2f5292c3
VZ
49 bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
50 wxDefaultValidator, name);
6adaedf0 51 SetValue(initial);
2f5292c3
VZ
52
53 return ok;
c71830c3 54 }
669a6e11
VZ
55
56 // accessors
c71830c3 57 int GetValue(int WXUNUSED(dummy) = 1) const
669a6e11
VZ
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
74protected:
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
82#endif // _WX_GENERIC_SPINCTRL_H_
83