]> git.saurik.com Git - wxWidgets.git/blob - interface/spinctrl.h
document GetValue() behaviour when called from an event handler processing change...
[wxWidgets.git] / interface / 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 @wxheader{spinctrl.h}
12
13 wxSpinCtrl combines wxTextCtrl and
14 wxSpinButton in one control.
15
16 @beginStyleTable
17 @style{wxSP_ARROW_KEYS}
18 The user can use arrow keys to change the value.
19 @style{wxSP_WRAP}
20 The value wraps at the minimum and maximum.
21 @endStyleTable
22
23 @library{wxcore}
24 @category{ctrl}
25 <!-- @appearance{spinctrl.png} -->
26
27 @see wxSpinButton, wxControl
28 */
29 class wxSpinCtrl : public wxControl
30 {
31 public:
32 /**
33 Default constructor.
34 */
35 wxSpinCtrl();
36
37 /**
38 Constructor, creating and showing a spin control.
39
40 @param parent
41 Parent window. Must not be @NULL.
42 @param value
43 Default value (as text).
44 @param id
45 Window identifier. The value wxID_ANY indicates a default value.
46 @param pos
47 Window position. If wxDefaultPosition is specified then a default
48 position is chosen.
49 @param size
50 Window size. If wxDefaultSize is specified then a default size
51 is chosen.
52 @param style
53 Window style. See wxSpinButton.
54 @param min
55 Minimal value.
56 @param max
57 Maximal value.
58 @param initial
59 Initial value.
60 @param name
61 Window name.
62
63 @see Create()
64 */
65 wxSpinCtrl(wxWindow* parent, wxWindowID id = -1,
66 const wxString& value = wxEmptyString,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = wxSP_ARROW_KEYS,
70 int min = 0, int max = 100,
71 int initial = 0);
72
73 /**
74 Creation function called by the spin control constructor.
75 See wxSpinCtrl() for details.
76 */
77 bool Create(wxWindow* parent, wxWindowID id = -1,
78 const wxString& value = wxEmptyString,
79 const wxPoint& pos = wxDefaultPosition,
80 const wxSize& size = wxDefaultSize,
81 long style = wxSP_ARROW_KEYS,
82 int min = 0, int max = 100,
83 int initial = 0);
84
85 /**
86 Gets maximal allowable value.
87 */
88 int GetMax() const;
89
90 /**
91 Gets minimal allowable value.
92 */
93 int GetMin() const;
94
95 /**
96 Gets the value of the spin control.
97
98 Notice that if you use this method from a handler processing a change
99 of the control value, it may return the old value, not the new one
100 (because the event handler can veto the change and this prevent the
101 value from changing at all). Use wxSpinEvent::GetValue() to retrieve
102 the new value in this case.
103 */
104 int GetValue() const;
105
106 /**
107 Sets range of allowable values.
108 */
109 void SetRange(int minVal, int maxVal);
110
111 /**
112 Select the text in the text part of the control between positions
113 @a from (inclusive) and @a to (exclusive). This is similar to
114 wxTextCtrl::SetSelection.
115 @note this is currently only implemented for Windows and generic versions
116 of the control.
117 */
118 void SetSelection(long from, long to);
119
120 /**
121 Sets the value of the spin control. Use the variant using int instead.
122 */
123 void SetValue(const wxString& text);
124
125 /**
126 Sets the value of the spin control.
127 */
128 void SetValue(int value);
129 };
130