2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: valtext.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxTextValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxTextValidator
|
|
|
|
@wxheader{valtext.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxTextValidator validates text controls, providing a variety of filtering
|
|
|
|
behaviours.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
For more information, please see @ref overview_validatoroverview "Validator
|
|
|
|
overview".
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{validator}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see @ref overview_validatoroverview "Validator overview", wxValidator,
|
2008-03-08 08:52:38 -05:00
|
|
|
wxGenericValidator
|
|
|
|
*/
|
|
|
|
class wxTextValidator : public wxValidator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Constructor, taking a style and optional pointer to a wxString variable.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
A bitlist of flags, which can be:
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_NONE
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
No filtering takes place.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_ASCII
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Non-ASCII characters are filtered out.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_ALPHA
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Non-alpha characters are filtered out.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_ALPHANUMERIC
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Non-alphanumeric characters are filtered out.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_NUMERIC
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Non-numeric characters are filtered out.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_INCLUDE_LIST
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Use an include list. The validator
|
|
|
|
checks if the user input is on the list, complaining if not. See
|
|
|
|
SetIncludes().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_EXCLUDE_LIST
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Use an exclude list. The validator
|
|
|
|
checks if the user input is on the list, complaining if it is. See
|
|
|
|
SetExcludes().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_INCLUDE_CHAR_LIST
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Use an include list. The validator
|
|
|
|
checks if each input character is in the list (one character per list
|
|
|
|
element), complaining if not.
|
|
|
|
See SetIncludes().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFILTER_EXCLUDE_CHAR_LIST
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
Use an include list. The validator
|
|
|
|
checks if each input character is in the list (one character per list
|
|
|
|
element), complaining if it is.
|
|
|
|
See SetExcludes().
|
2008-03-08 09:43:31 -05:00
|
|
|
@param valPtr
|
2008-03-09 08:33:59 -04:00
|
|
|
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).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxTextValidator(const wxTextValidator& validator);
|
2008-03-08 09:43:31 -05:00
|
|
|
wxTextValidator(long style = wxFILTER_NONE,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxString* valPtr = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Clones the text validator using the copy constructor.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
virtual wxValidator* Clone() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a reference to the exclude list (the list of invalid values).
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxArrayString GetExcludes() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a reference to the include list (the list of valid values).
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxArrayString GetIncludes() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the validator style.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
long GetStyle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Receives character input from the window and filters it according to the
|
|
|
|
current validator style.
|
|
|
|
*/
|
|
|
|
void OnChar(wxKeyEvent& event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the exclude list (invalid values for the user input).
|
|
|
|
*/
|
|
|
|
void SetExcludes(const wxArrayString& stringList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the include list (valid values for the user input).
|
|
|
|
*/
|
|
|
|
void SetIncludes(const wxArrayString& stringList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the validator style.
|
|
|
|
*/
|
|
|
|
void SetStyle(long style);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Transfers the value in the text control to the string.
|
|
|
|
*/
|
|
|
|
virtual bool TransferFromWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Transfers the string value to the text control.
|
|
|
|
*/
|
|
|
|
virtual bool TransferToWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Validates the window contents against the include or exclude lists, depending
|
|
|
|
on the validator style.
|
|
|
|
*/
|
|
|
|
virtual bool Validate(wxWindow* parent);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|