]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: spinctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxSpinCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxSpinCtrl | |
7c913512 | 11 | |
e725ba4f | 12 | wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control. |
7c913512 | 13 | |
23324ae1 | 14 | @beginStyleTable |
8c6791e4 | 15 | @style{wxSP_ARROW_KEYS} |
242ec2f7 | 16 | The user can use arrow keys to change the value. |
8c6791e4 | 17 | @style{wxSP_WRAP} |
242ec2f7 VZ |
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. | |
23324ae1 | 24 | @endStyleTable |
7c913512 | 25 | |
e725ba4f FM |
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 | ||
23324ae1 FM |
40 | @library{wxcore} |
41 | @category{ctrl} | |
0c7fe6f2 | 42 | <!-- @appearance{spinctrl.png} --> |
7c913512 | 43 | |
42561c3c | 44 | @see wxSpinButton, wxSpinCtrlDouble, wxControl |
23324ae1 FM |
45 | */ |
46 | class wxSpinCtrl : public wxControl | |
47 | { | |
48 | public: | |
23324ae1 | 49 | /** |
d930d177 RR |
50 | Default constructor. |
51 | */ | |
52 | wxSpinCtrl(); | |
e725ba4f | 53 | |
d930d177 | 54 | /** |
23324ae1 | 55 | Constructor, creating and showing a spin control. |
3c4f71cc | 56 | |
7c913512 | 57 | @param parent |
4cc4bfaf | 58 | Parent window. Must not be @NULL. |
7c913512 | 59 | @param value |
d930d177 | 60 | Default value (as text). |
7c913512 | 61 | @param id |
4cc4bfaf | 62 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 63 | @param pos |
e725ba4f FM |
64 | Window position. |
65 | If wxDefaultPosition is specified then a default position is chosen. | |
7c913512 | 66 | @param size |
e725ba4f FM |
67 | Window size. |
68 | If wxDefaultSize is specified then a default size is chosen. | |
7c913512 | 69 | @param style |
4cc4bfaf | 70 | Window style. See wxSpinButton. |
7c913512 | 71 | @param min |
4cc4bfaf | 72 | Minimal value. |
7c913512 | 73 | @param max |
4cc4bfaf | 74 | Maximal value. |
7c913512 | 75 | @param initial |
4cc4bfaf | 76 | Initial value. |
7c913512 | 77 | @param name |
4cc4bfaf | 78 | Window name. |
3c4f71cc | 79 | |
4cc4bfaf | 80 | @see Create() |
23324ae1 | 81 | */ |
7c913512 FM |
82 | wxSpinCtrl(wxWindow* parent, wxWindowID id = -1, |
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, | |
42561c3c | 88 | int initial = 0, const wxString& name = _T("wxSpinCtrl")); |
23324ae1 FM |
89 | |
90 | /** | |
23324ae1 | 91 | Creation function called by the spin control constructor. |
23324ae1 FM |
92 | See wxSpinCtrl() for details. |
93 | */ | |
94 | bool Create(wxWindow* parent, wxWindowID id = -1, | |
95 | const wxString& value = wxEmptyString, | |
96 | const wxPoint& pos = wxDefaultPosition, | |
97 | const wxSize& size = wxDefaultSize, | |
98 | long style = wxSP_ARROW_KEYS, | |
99 | int min = 0, int max = 100, | |
42561c3c | 100 | int initial = 0, const wxString& name = _T("wxSpinCtrl")); |
23324ae1 FM |
101 | |
102 | /** | |
103 | Gets maximal allowable value. | |
104 | */ | |
328f5751 | 105 | int GetMax() const; |
23324ae1 FM |
106 | |
107 | /** | |
108 | Gets minimal allowable value. | |
109 | */ | |
328f5751 | 110 | int GetMin() const; |
23324ae1 FM |
111 | |
112 | /** | |
113 | Gets the value of the spin control. | |
114 | */ | |
328f5751 | 115 | int GetValue() const; |
23324ae1 FM |
116 | |
117 | /** | |
118 | Sets range of allowable values. | |
119 | */ | |
120 | void SetRange(int minVal, int maxVal); | |
121 | ||
122 | /** | |
7c913512 | 123 | Select the text in the text part of the control between positions |
e725ba4f FM |
124 | @a from (inclusive) and @a to (exclusive). |
125 | This is similar to wxTextCtrl::SetSelection(). | |
126 | ||
1f1d2182 | 127 | @note this is currently only implemented for Windows and generic versions |
e725ba4f | 128 | of the control. |
23324ae1 FM |
129 | */ |
130 | void SetSelection(long from, long to); | |
131 | ||
23324ae1 | 132 | /** |
d930d177 | 133 | Sets the value of the spin control. Use the variant using int instead. |
23324ae1 | 134 | */ |
adaaa686 | 135 | virtual void SetValue(const wxString& text); |
d930d177 RR |
136 | |
137 | /** | |
138 | Sets the value of the spin control. | |
139 | */ | |
7c913512 | 140 | void SetValue(int value); |
23324ae1 | 141 | }; |
e54c96f1 | 142 |