]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/spinctrl.h
document wxLogLevel, wxTraceMask antypes and wxLogLevelValues enum
[wxWidgets.git] / interface / wx / spinctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: spinctrl.h
3 // Purpose: interface of wxSpinCtrl
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxSpinCtrl
11
12 wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control.
13
14 @beginStyleTable
15 @style{wxSP_ARROW_KEYS}
16 The user can use arrow keys to change the value.
17 @style{wxSP_WRAP}
18 The value wraps at the minimum and maximum.
19 @style{wxTE_PROCESS_ENTER}
20 Indicates that the control should generate wxEVT_COMMAND_TEXT_ENTER
21 events. Using this style will prevent the user from using the Enter key
22 for dialog navigation (e.g. activating the default button in the
23 dialog) under MSW.
24 @endStyleTable
25
26
27 @beginEventTable{wxSpinEvent}
28 @event{EVT_SPINCTRL(id, func)}
29 Generated whenever the numeric value of the spinctrl is updated
30 @endEventTable
31
32 You may also use the wxSpinButton event macros, however the corresponding events
33 will not be generated under all platforms. Finally, if the user modifies the
34 text in the edit part of the spin control directly, the EVT_TEXT is generated,
35 like for the wxTextCtrl. When the use enters text into the text area, the text
36 is not validated until the control loses focus (e.g. by using the TAB key).
37 The value is then adjusted to the range and a wxSpinEvent sent then if the value
38 is different from the last value sent.
39
40 @library{wxcore}
41 @category{ctrl}
42 @appearance{spinctrl.png}
43
44 @see wxSpinButton, wxSpinCtrlDouble, wxControl
45 */
46 class wxSpinCtrl : public wxControl
47 {
48 public:
49 /**
50 Default constructor.
51 */
52 wxSpinCtrl();
53
54 /**
55 Constructor, creating and showing a spin control.
56
57 @param parent
58 Parent window. Must not be @NULL.
59 @param value
60 Default value (as text).
61 @param id
62 Window identifier. The value wxID_ANY indicates a default value.
63 @param pos
64 Window position.
65 If wxDefaultPosition is specified then a default position is chosen.
66 @param size
67 Window size.
68 If wxDefaultSize is specified then a default size is chosen.
69 @param style
70 Window style. See wxSpinButton.
71 @param min
72 Minimal value.
73 @param max
74 Maximal value.
75 @param initial
76 Initial value.
77 @param name
78 Window name.
79
80 @see Create()
81 */
82 wxSpinCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
83 const wxString& value = wxEmptyString,
84 const wxPoint& pos = wxDefaultPosition,
85 const wxSize& size = wxDefaultSize,
86 long style = wxSP_ARROW_KEYS,
87 int min = 0, int max = 100,
88 int initial = 0, const wxString& name = "wxSpinCtrl");
89
90 /**
91 Creation function called by the spin control constructor.
92 See wxSpinCtrl() for details.
93 */
94 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
95 const wxString& value = wxEmptyString,
96 const wxPoint& pos = wxDefaultPosition,
97 const wxSize& size = wxDefaultSize,
98 long style = wxSP_ARROW_KEYS, int min = 0, int max = 100,
99 int initial = 0, const wxString& name = "wxSpinCtrl");
100
101 /**
102 Gets maximal allowable value.
103 */
104 int GetMax() const;
105
106 /**
107 Gets minimal allowable value.
108 */
109 int GetMin() const;
110
111 /**
112 Gets the value of the spin control.
113 */
114 int GetValue() const;
115
116 /**
117 Sets range of allowable values.
118 */
119 void SetRange(int minVal, int maxVal);
120
121 /**
122 Select the text in the text part of the control between positions
123 @a from (inclusive) and @a to (exclusive).
124 This is similar to wxTextCtrl::SetSelection().
125
126 @note this is currently only implemented for Windows and generic versions
127 of the control.
128 */
129 virtual void SetSelection(long from, long to);
130
131 /**
132 Sets the value of the spin control. Use the variant using int instead.
133 */
134 virtual void SetValue(const wxString& text);
135
136 /**
137 Sets the value of the spin control.
138 */
139 void SetValue(int value);
140 };
141