]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: valtext.h | |
e54c96f1 | 3 | // Purpose: interface of wxTextValidator |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxTextValidator | |
11 | @wxheader{valtext.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | wxTextValidator validates text controls, providing a variety of filtering |
14 | behaviours. | |
7c913512 | 15 | |
23324ae1 FM |
16 | For more information, please see @ref overview_validatoroverview "Validator |
17 | overview". | |
7c913512 | 18 | |
23324ae1 FM |
19 | @library{wxcore} |
20 | @category{validator} | |
7c913512 | 21 | |
e54c96f1 | 22 | @see @ref overview_validatoroverview "Validator overview", wxValidator, |
23324ae1 FM |
23 | wxGenericValidator |
24 | */ | |
25 | class wxTextValidator : public wxValidator | |
26 | { | |
27 | public: | |
28 | //@{ | |
29 | /** | |
30 | Constructor, taking a style and optional pointer to a wxString variable. | |
3c4f71cc | 31 | |
7c913512 | 32 | @param style |
4cc4bfaf | 33 | A bitlist of flags, which can be: |
3c4f71cc VS |
34 | |
35 | ||
36 | ||
37 | ||
38 | ||
39 | ||
40 | ||
4cc4bfaf | 41 | wxFILTER_NONE |
3c4f71cc VS |
42 | |
43 | ||
44 | ||
45 | ||
4cc4bfaf | 46 | No filtering takes place. |
3c4f71cc VS |
47 | |
48 | ||
49 | ||
50 | ||
51 | ||
4cc4bfaf | 52 | wxFILTER_ASCII |
3c4f71cc VS |
53 | |
54 | ||
55 | ||
56 | ||
4cc4bfaf | 57 | Non-ASCII characters are filtered out. |
3c4f71cc VS |
58 | |
59 | ||
60 | ||
61 | ||
62 | ||
4cc4bfaf | 63 | wxFILTER_ALPHA |
3c4f71cc VS |
64 | |
65 | ||
66 | ||
67 | ||
4cc4bfaf | 68 | Non-alpha characters are filtered out. |
3c4f71cc VS |
69 | |
70 | ||
71 | ||
72 | ||
73 | ||
4cc4bfaf | 74 | wxFILTER_ALPHANUMERIC |
3c4f71cc VS |
75 | |
76 | ||
77 | ||
78 | ||
4cc4bfaf | 79 | Non-alphanumeric characters are filtered out. |
3c4f71cc VS |
80 | |
81 | ||
82 | ||
83 | ||
84 | ||
4cc4bfaf | 85 | wxFILTER_NUMERIC |
3c4f71cc VS |
86 | |
87 | ||
88 | ||
89 | ||
4cc4bfaf | 90 | Non-numeric characters are filtered out. |
3c4f71cc VS |
91 | |
92 | ||
93 | ||
94 | ||
95 | ||
4cc4bfaf | 96 | wxFILTER_INCLUDE_LIST |
3c4f71cc VS |
97 | |
98 | ||
99 | ||
100 | ||
4cc4bfaf FM |
101 | Use an include list. The validator |
102 | checks if the user input is on the list, complaining if not. See | |
103 | SetIncludes(). | |
3c4f71cc VS |
104 | |
105 | ||
106 | ||
107 | ||
108 | ||
4cc4bfaf | 109 | wxFILTER_EXCLUDE_LIST |
3c4f71cc VS |
110 | |
111 | ||
112 | ||
113 | ||
4cc4bfaf FM |
114 | Use an exclude list. The validator |
115 | checks if the user input is on the list, complaining if it is. See | |
116 | SetExcludes(). | |
3c4f71cc VS |
117 | |
118 | ||
119 | ||
120 | ||
121 | ||
4cc4bfaf | 122 | wxFILTER_INCLUDE_CHAR_LIST |
3c4f71cc VS |
123 | |
124 | ||
125 | ||
126 | ||
4cc4bfaf FM |
127 | Use an include list. The validator |
128 | checks if each input character is in the list (one character per list | |
129 | element), complaining if not. | |
130 | See SetIncludes(). | |
3c4f71cc VS |
131 | |
132 | ||
133 | ||
134 | ||
135 | ||
4cc4bfaf | 136 | wxFILTER_EXCLUDE_CHAR_LIST |
3c4f71cc VS |
137 | |
138 | ||
139 | ||
140 | ||
4cc4bfaf FM |
141 | Use an include list. The validator |
142 | checks if each input character is in the list (one character per list | |
143 | element), complaining if it is. | |
144 | See SetExcludes(). | |
7c913512 | 145 | @param valPtr |
4cc4bfaf FM |
146 | A pointer to a wxString variable that contains the value. This variable |
147 | should have a lifetime equal to or longer than the validator lifetime | |
148 | (which is usually | |
149 | determined by the lifetime of the window). | |
23324ae1 FM |
150 | */ |
151 | wxTextValidator(const wxTextValidator& validator); | |
7c913512 | 152 | wxTextValidator(long style = wxFILTER_NONE, |
4cc4bfaf | 153 | wxString* valPtr = NULL); |
23324ae1 FM |
154 | //@} |
155 | ||
156 | /** | |
157 | Clones the text validator using the copy constructor. | |
158 | */ | |
328f5751 | 159 | virtual wxValidator* Clone() const; |
23324ae1 FM |
160 | |
161 | /** | |
162 | Returns a reference to the exclude list (the list of invalid values). | |
163 | */ | |
328f5751 | 164 | wxArrayString GetExcludes() const; |
23324ae1 FM |
165 | |
166 | /** | |
167 | Returns a reference to the include list (the list of valid values). | |
168 | */ | |
328f5751 | 169 | wxArrayString GetIncludes() const; |
23324ae1 FM |
170 | |
171 | /** | |
172 | Returns the validator style. | |
173 | */ | |
328f5751 | 174 | long GetStyle() const; |
23324ae1 FM |
175 | |
176 | /** | |
177 | Receives character input from the window and filters it according to the | |
178 | current validator style. | |
179 | */ | |
180 | void OnChar(wxKeyEvent& event); | |
181 | ||
182 | /** | |
183 | Sets the exclude list (invalid values for the user input). | |
184 | */ | |
185 | void SetExcludes(const wxArrayString& stringList); | |
186 | ||
187 | /** | |
188 | Sets the include list (valid values for the user input). | |
189 | */ | |
190 | void SetIncludes(const wxArrayString& stringList); | |
191 | ||
192 | /** | |
193 | Sets the validator style. | |
194 | */ | |
195 | void SetStyle(long style); | |
196 | ||
197 | /** | |
198 | Transfers the value in the text control to the string. | |
199 | */ | |
200 | virtual bool TransferFromWindow(); | |
201 | ||
202 | /** | |
203 | Transfers the string value to the text control. | |
204 | */ | |
205 | virtual bool TransferToWindow(); | |
206 | ||
207 | /** | |
208 | Validates the window contents against the include or exclude lists, depending | |
209 | on the validator style. | |
210 | */ | |
211 | virtual bool Validate(wxWindow* parent); | |
212 | }; | |
e54c96f1 | 213 |