1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTextValidator
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 Styles used by wxTextValidator.
13 enum wxTextValidatorStyle
15 /// No filtering takes place.
18 /// Non-ASCII characters are filtered out.
21 /// Non-alpha characters are filtered out.
24 /// Non-alphanumeric characters are filtered out.
25 wxFILTER_ALPHANUMERIC
,
27 /// Non-numeric characters are filtered out.
30 /// Use an include list. The validator checks if the user input is on
31 /// the list, complaining if not. See wxTextValidator::SetIncludes().
32 wxFILTER_INCLUDE_LIST
,
34 /// Use an exclude list. The validator checks if the user input is on
35 /// the list, complaining if it is. See wxTextValidator::SetExcludes().
36 wxFILTER_EXCLUDE_LIST
,
38 /// Use an include list. The validator checks if each input character is
39 /// in the list (one character per list element), complaining if not.
40 /// See wxTextValidator::SetIncludes().
41 wxFILTER_INCLUDE_CHAR_LIST
,
43 /// Use an include list. The validator checks if each input character is
44 /// in the list (one character per list element), complaining if it is.
45 /// See wxTextValidator::SetExcludes().
46 wxFILTER_EXCLUDE_CHAR_LIST
50 @class wxTextValidator
52 wxTextValidator validates text controls, providing a variety of filtering
55 For more information, please see @ref overview_validator.
60 @see @ref overview_validator, wxValidator, wxGenericValidator
62 class wxTextValidator
: public wxValidator
68 wxTextValidator(const wxTextValidator
& validator
);
71 Constructor taking a style and optional pointer to a wxString variable.
74 One of the ::wxTextValidatorStyle styles.
76 A pointer to a wxString variable that contains the value. This
77 variable should have a lifetime equal to or longer than the
78 validator lifetime (which is usually determined by the lifetime of
81 wxTextValidator(wxTextValidatorStyle style
= wxFILTER_NONE
, wxString
* valPtr
= NULL
);
84 Clones the text validator using the copy constructor.
86 virtual wxObject
* Clone() const;
89 Returns a reference to the exclude list (the list of invalid values).
91 wxArrayString
& GetExcludes();
94 Returns a reference to the include list (the list of valid values).
96 wxArrayString
& GetIncludes();
99 Returns the validator style.
101 wxTextValidatorStyle
GetStyle() const;
104 Receives character input from the window and filters it according to
105 the current validator style.
107 void OnChar(wxKeyEvent
& event
);
110 Sets the exclude list (invalid values for the user input).
112 void SetExcludes(const wxArrayString
& stringList
);
115 Sets the include list (valid values for the user input).
117 void SetIncludes(const wxArrayString
& stringList
);
120 Sets the validator style.
122 void SetStyle(wxTextValidatorStyle style
);
125 Transfers the value in the text control to the string.
127 virtual bool TransferFromWindow();
130 Transfers the string value to the text control.
132 virtual bool TransferToWindow();
135 Validates the window contents against the include or exclude lists,
136 depending on the validator style.
138 virtual bool Validate(wxWindow
* parent
);