]> git.saurik.com Git - wxWidgets.git/blob - interface/valtext.h
made wxAcceleratorTable work with buttons in wxGTK too
[wxWidgets.git] / interface / valtext.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: valtext.h
3 // Purpose: interface of wxTextValidator
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxTextValidator
11 @wxheader{valtext.h}
12
13 wxTextValidator validates text controls, providing a variety of filtering
14 behaviours.
15
16 For more information, please see @ref overview_validatoroverview "Validator
17 overview".
18
19 @library{wxcore}
20 @category{validator}
21
22 @see @ref overview_validatoroverview "Validator overview", wxValidator,
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
32 @param style
33 A bitlist of flags, which can be:
34
35
36
37
38
39
40
41 wxFILTER_NONE
42
43
44
45
46 No filtering takes place.
47
48
49
50
51
52 wxFILTER_ASCII
53
54
55
56
57 Non-ASCII characters are filtered out.
58
59
60
61
62
63 wxFILTER_ALPHA
64
65
66
67
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().
145 @param valPtr
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).
150 */
151 wxTextValidator(const wxTextValidator& validator);
152 wxTextValidator(long style = wxFILTER_NONE,
153 wxString* valPtr = NULL);
154 //@}
155
156 /**
157 Clones the text validator using the copy constructor.
158 */
159 virtual wxValidator* Clone() const;
160
161 /**
162 Returns a reference to the exclude list (the list of invalid values).
163 */
164 wxArrayString GetExcludes() const;
165
166 /**
167 Returns a reference to the include list (the list of valid values).
168 */
169 wxArrayString GetIncludes() const;
170
171 /**
172 Returns the validator style.
173 */
174 long GetStyle() const;
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 };
213