]>
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. | |
31 | ||
7c913512 | 32 | @param style |
4cc4bfaf | 33 | A bitlist of flags, which can be: |
23324ae1 FM |
34 | |
35 | ||
23324ae1 FM |
36 | |
37 | ||
23324ae1 | 38 | |
23324ae1 FM |
39 | |
40 | ||
4cc4bfaf | 41 | wxFILTER_NONE |
23324ae1 | 42 | |
23324ae1 FM |
43 | |
44 | ||
23324ae1 | 45 | |
4cc4bfaf | 46 | No filtering takes place. |
23324ae1 FM |
47 | |
48 | ||
23324ae1 | 49 | |
23324ae1 FM |
50 | |
51 | ||
4cc4bfaf | 52 | wxFILTER_ASCII |
23324ae1 | 53 | |
23324ae1 FM |
54 | |
55 | ||
23324ae1 | 56 | |
4cc4bfaf | 57 | Non-ASCII characters are filtered out. |
23324ae1 FM |
58 | |
59 | ||
23324ae1 | 60 | |
23324ae1 FM |
61 | |
62 | ||
4cc4bfaf | 63 | wxFILTER_ALPHA |
23324ae1 | 64 | |
23324ae1 FM |
65 | |
66 | ||
23324ae1 | 67 | |
4cc4bfaf FM |
68 | Non-alpha characters are filtered out. |
69 | ||
70 | ||
71 | ||
72 | ||
73 | ||
74 | wxFILTER_ALPHANUMERIC | |
75 | ||
76 | ||
77 | ||
78 | ||
79 | Non-alphanumeric characters are filtered out. | |
80 | ||
81 | ||
82 | ||
83 | ||
84 | ||
85 | wxFILTER_NUMERIC | |
86 | ||
87 | ||
88 | ||
89 | ||
90 | Non-numeric characters are filtered out. | |
91 | ||
92 | ||
93 | ||
94 | ||
95 | ||
96 | wxFILTER_INCLUDE_LIST | |
97 | ||
98 | ||
99 | ||
100 | ||
101 | Use an include list. The validator | |
102 | checks if the user input is on the list, complaining if not. See | |
103 | SetIncludes(). | |
104 | ||
105 | ||
106 | ||
107 | ||
108 | ||
109 | wxFILTER_EXCLUDE_LIST | |
110 | ||
111 | ||
112 | ||
113 | ||
114 | Use an exclude list. The validator | |
115 | checks if the user input is on the list, complaining if it is. See | |
116 | SetExcludes(). | |
117 | ||
118 | ||
119 | ||
120 | ||
121 | ||
122 | wxFILTER_INCLUDE_CHAR_LIST | |
123 | ||
124 | ||
125 | ||
126 | ||
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(). | |
131 | ||
132 | ||
133 | ||
134 | ||
135 | ||
136 | wxFILTER_EXCLUDE_CHAR_LIST | |
137 | ||
138 | ||
139 | ||
140 | ||
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 |