X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fcd209b6a20b41e7ddf9acf837311ac6779ea41f..92c0fc34c104c8d7c12d6a3b78ea232690fc23f4:/interface/wx/valtext.h?ds=inline diff --git a/interface/wx/valtext.h b/interface/wx/valtext.h index 17aba3a2ad..0102328ad4 100644 --- a/interface/wx/valtext.h +++ b/interface/wx/valtext.h @@ -2,19 +2,26 @@ // Name: valtext.h // Purpose: interface of wxTextValidator // Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** Styles used by wxTextValidator. + + Note that when you specify more styles in wxTextValidator the validation checks + are performed in the order in which the styles of this enumeration are defined. */ enum wxTextValidatorStyle { /// No filtering takes place. wxFILTER_NONE, + /// Empty strings are filtered out. + /// If this style is not specified then empty strings are accepted + /// only if they pass the other checks (if you use more than one wxTextValidatorStyle). + wxFILTER_EMPTY, + /// Non-ASCII characters are filtered out. See wxString::IsAscii. wxFILTER_ASCII, @@ -31,10 +38,10 @@ enum wxTextValidatorStyle /// Non-numeric characters are filtered out. /// Uses the wxWidgets wrapper for the standard CRT function @c isdigit /// (which is locale-dependent) on all characters of the string. - wxFILTER_SIMPLE_NUMBER, + wxFILTER_DIGITS, /// Non-numeric characters are filtered out. - /// Works like @c wxFILTER_SIMPLE_NUMBER but allows also decimal points, + /// Works like @c wxFILTER_DIGITS but allows also decimal points, /// minus/plus signs and the 'e' or 'E' character to input exponents. /// Note that this is not the same behaviour of wxString::IsNumber(). wxFILTER_NUMERIC, @@ -43,15 +50,15 @@ enum wxTextValidatorStyle /// the list, complaining if not. See wxTextValidator::SetIncludes(). wxFILTER_INCLUDE_LIST, - /// Use an exclude list. The validator checks if the user input is on - /// the list, complaining if it is. See wxTextValidator::SetExcludes(). - wxFILTER_EXCLUDE_LIST, - /// Use an include list. The validator checks if each input character is /// in the list (one character per list element), complaining if not. /// See wxTextValidator::SetCharIncludes(). wxFILTER_INCLUDE_CHAR_LIST, + /// Use an exclude list. The validator checks if the user input is on + /// the list, complaining if it is. See wxTextValidator::SetExcludes(). + wxFILTER_EXCLUDE_LIST, + /// Use an exclude list. The validator checks if each input character is /// in the list (one character per list element), complaining if it is. /// See wxTextValidator::SetCharExcludes(). @@ -69,7 +76,8 @@ enum wxTextValidatorStyle @library{wxcore} @category{validator} - @see @ref overview_validator, wxValidator, wxGenericValidator + @see @ref overview_validator, wxValidator, wxGenericValidator, + wxIntegerValidator, wxFloatingPointValidator */ class wxTextValidator : public wxValidator { @@ -83,14 +91,14 @@ public: Constructor taking a style and optional pointer to a wxString variable. @param style - One of the ::wxTextValidatorStyle styles. + One or more of the ::wxTextValidatorStyle styles. See SetStyle(). @param valPtr A pointer to a wxString variable that contains the value. This variable should have a lifetime equal to or longer than the validator lifetime (which is usually determined by the lifetime of the window). */ - wxTextValidator(wxTextValidatorStyle style = wxFILTER_NONE, wxString* valPtr = NULL); + wxTextValidator(long style = wxFILTER_NONE, wxString* valPtr = NULL); /** Clones the text validator using the copy constructor. @@ -109,8 +117,15 @@ public: /** Returns the validator style. + + @see HasFlag() + */ + long GetStyle() const; + + /** + Returns @true if the given @a style bit is set in the current style. */ - wxTextValidatorStyle GetStyle() const; + bool HasFlag(wxTextValidatorStyle style) const; /** Receives character input from the window and filters it according to @@ -147,9 +162,16 @@ public: void SetCharIncludes(const wxString& chars); /** - Sets the validator style. + Sets the validator style which must be a combination of one or more + of the ::wxTextValidatorStyle values. + + Note that not all possible combinations make sense! + Also note that the order in which the checks are performed is important, + in case you specify more than a single style. + wxTextValidator will perform the checks in the same definition order + used in the ::wxTextValidatorStyle enumeration. */ - void SetStyle(wxTextValidatorStyle style); + void SetStyle(long style); /** Transfers the value in the text control to the string. @@ -166,5 +188,25 @@ public: depending on the validator style. */ virtual bool Validate(wxWindow* parent); + +protected: + + /** + Returns @true if all the characters of the given @a val string + are present in the include list (set by SetIncludes() or SetCharIncludes()). + */ + bool ContainsOnlyIncludedCharacters(const wxString& val) const; + + /** + Returns true if at least one character of the given @a val string + is present in the exclude list (set by SetExcludes() or SetCharExcludes()). + */ + bool ContainsExcludedCharacters(const wxString& val) const; + + /** + Returns the error message if the contents of @a val are invalid + or the empty string if @a val is valid. + */ + virtual wxString IsValid(const wxString& val) const; };