wxTextValidator Class Reference | wxWidgets

| Version: 3.2.11

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
wxTextValidator Class Reference
Class List by Category » Validators

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.2/wxWidgets3.2-3.2.11-1.x86_64/src/wxWidgets-3.2.11/interface/wx/valtext.h>`

Inheritance diagram for wxTextValidator:
[legend]

## Detailed Description

wxTextValidator validates text controls, providing a variety of filtering behaviours.

For more information, please see wxValidator Overview.

##

Library: wxCore
Category: Validators

See also
  wxValidator Overview, wxValidator, wxGenericValidator, wxIntegerValidator, wxFloatingPointValidator

## Public Member Functions
| wxTextValidator (const wxTextValidator &validator)
| Copy constructor.
| wxTextValidator (long style=wxFILTER_NONE, wxString *valPtr=NULL)
| Constructor taking a style and optional pointer to a wxString variable.
virtual wxObject * | Clone () const
| Clones the text validator using the copy constructor.
wxString | GetCharExcludes () const
| Returns a copy of the exclude char list (the list of invalid characters).
wxString | GetCharIncludes () const
| Returns a copy of the include char list (the list of additional valid characters).
const wxArrayString & | GetExcludes () const
| Returns a const reference to the exclude list (the list of invalid values).
const wxArrayString & | GetIncludes () const
| Returns a const reference to the include list (the list of valid values).
long | GetStyle () const
| Returns the validator style.
bool | HasFlag (wxTextValidatorStyle style) const
| Returns true if the given style bit is set in the current style.
void | OnChar (wxKeyEvent &event)
| Receives character input from the window and filters it according to the current validator style.
void | SetExcludes (const wxArrayString &stringList)
| Sets the exclude list (invalid values for the user input).
void | SetCharExcludes (const wxString &chars)
| Sets the exclude char list (invalid characters for the user input).
void | SetIncludes (const wxArrayString &stringList)
| Sets the include list (valid values for the user input).
void | SetCharIncludes (const wxString &chars)
| Sets the include char list (additional valid values for the user input).
void | AddExclude (const wxString &exclude)
| Adds exclude to the list of excluded values.
void | AddInclude (const wxString &include)
| Adds include to the list of included values.
void | AddCharExcludes (const wxString &chars)
| Adds chars to the list of excluded characters.
void | AddCharIncludes (const wxString &chars)
| Adds chars to the list of included characters.
void | SetStyle (long style)
| Sets the validator style which must be a combination of one or more of the wxTextValidatorStyle values.
virtual bool | TransferFromWindow ()
| Transfers the value in the text control to the string.
virtual bool | TransferToWindow ()
| Transfers the string value to the text control.
virtual bool | Validate (wxWindow *parent)
| Validates the window contents against the include or exclude lists, depending on the validator style.
virtual wxString | IsValid (const wxString &val) const
| Returns the error message if the contents of val are invalid or the empty string if val is valid.
Public Member Functions inherited from wxValidator
| wxValidator ()
| Constructor.
virtual | ~wxValidator ()
| Destructor.
wxWindow * | GetWindow () const
| Returns the window associated with the validator.
virtual void | SetWindow (wxWindow *window)
| Associates a window with the validator.
Public Member Functions inherited from wxEvtHandler
| wxEvtHandler ()
| Constructor.
virtual | ~wxEvtHandler ()
| Destructor.
virtual void | QueueEvent (wxEvent *event)
| Queue event for a later processing.
virtual void | AddPendingEvent (const wxEvent &event)
| Post an event to be processed later.
template<typename T, typename T1, ...>
void | CallAfter (void(T::*method)(T1,...), T1 x1,...)
| Asynchronously call the given method.
template<typename T>
void | CallAfter (const T &functor)
| Asynchronously call the given functor.
virtual bool | ProcessEvent (wxEvent &event)
| Processes an event, searching event tables and calling zero or more suitable event handler function(s).
bool | ProcessEventLocally (wxEvent &event)
| Try to process the event in this handler and all those chained to it.
bool | SafelyProcessEvent (wxEvent &event)
| Processes an event by calling ProcessEvent() and handles any exceptions that occur in the process.
void | ProcessPendingEvents ()
| Processes the pending events previously queued using QueueEvent() or AddPendingEvent(); you must call this function only if you are sure there are pending events for this handler, otherwise a `wxCHECK` will fail.
void | DeletePendingEvents ()
| Deletes all events queued on this event handler using QueueEvent() or AddPendingEvent().
void | Connect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| Connects the given function dynamically with the event handler, id and event type.
void | Connect (int id, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
void | Connect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
bool | Disconnect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| Disconnects the given function dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed.
bool | Disconnect (int id=wxID_ANY, wxEventType eventType=wxEVT_NULL, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
bool | Disconnect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
template<typename EventTag, typename Functor>
void | Bind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| Binds the given function, functor or method dynamically with the event.
template<typename EventTag, typename Class, typename EventArg, typename EventHandler>
void | Bind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| See the Bind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info.
template<typename EventTag, typename Functor>
bool | Unbind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| Unbinds the given function, functor or method dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed.
template<typename EventTag, typename Class, typename EventArg, typename EventHandler>
bool | Unbind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| See the Unbind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info.
void * | GetClientData () const
| Returns user-supplied client data.
wxClientData * | GetClientObject () const
| Returns a pointer to the user-supplied client data object.
void | SetClientData (void *data)
| Sets user-supplied client data.
void | SetClientObject (wxClientData *data)
| Set the client data object.
bool | GetEvtHandlerEnabled () const
| Returns true if the event handler is enabled, false otherwise.
wxEvtHandler * | GetNextHandler () const
| Returns the pointer to the next handler in the chain.
wxEvtHandler * | GetPreviousHandler () const
| Returns the pointer to the previous handler in the chain.
void | SetEvtHandlerEnabled (bool enabled)
| Enables or disables the event handler.
virtual void | SetNextHandler (wxEvtHandler *handler)
| Sets the pointer to the next handler.
virtual void | SetPreviousHandler (wxEvtHandler *handler)
| Sets the pointer to the previous handler.
void | Unlink ()
| Unlinks this event handler from the chain it's part of (if any); then links the "previous" event handler to the "next" one (so that the chain won't be interrupted).
bool | IsUnlinked () const
| Returns true if the next and the previous handler pointers of this event handler instance are NULL.
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data.
| wxObject (const wxObject &other)
| Copy ctor.
virtual | ~wxObject ()
| Destructor.
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class.
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj.
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone.
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer.
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data.
void | UnShare ()
| This is the same of AllocExclusive() but this method is public.
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.

## Protected Member Functions
bool | IsCharIncluded (const wxUniChar &c) const
| Returns true if the char c is allowed to be in the user input string.
bool | IsCharExcluded (const wxUniChar &c) const
| Returns true if the char c is not allowed to be in the user input string.
bool | IsIncluded (const wxString &str) const
| Returns true if the string str is one of the includes strings set by SetIncludes() or AddInclude().
bool | IsExcluded (const wxString &str) const
| Returns true if the string str is one of the excludes strings set by SetExcludes() or AddExclude().
bool | IsValidChar (const wxUniChar &c) const
| Returns false if the character c is invalid.
Protected Member Functions inherited from wxEvtHandler
virtual bool | TryBefore (wxEvent &event)
| Method called by ProcessEvent() before examining this object event tables.
virtual bool | TryAfter (wxEvent &event)
| Method called by ProcessEvent() as last resort.
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object.
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.

## Additional Inherited Members
Static Public Member Functions inherited from wxValidator
static void | SuppressBellOnError (bool suppress=true)
| This functions switches on or turns off the error sound produced by the validators if an invalid key is pressed.
static bool | IsSilent ()
| Returns if the error sound is currently disabled.
Static Public Member Functions inherited from wxEvtHandler
static void | AddFilter (wxEventFilter *filter)
| Add an event filter whose FilterEvent() method will be called for each and every event processed by wxWidgets.
static void | RemoveFilter (wxEventFilter *filter)
| Remove a filter previously installed with AddFilter().
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data.

## Constructor & Destructor Documentation

## ◆ wxTextValidator() [1/2]

wxTextValidator::wxTextValidator | ( | const wxTextValidator & | validator | ) |

Copy constructor.

## ◆ wxTextValidator() [2/2]

wxTextValidator::wxTextValidator | ( | long | style = wxFILTER_NONE,
|  | wxString * | valPtr = NULL )

Constructor taking a style and optional pointer to a wxString variable.

Parameters

  style | One or more of the wxTextValidatorStyle styles. See SetStyle().
  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).

## Member Function Documentation

## ◆ AddCharExcludes()

void wxTextValidator::AddCharExcludes | ( | const wxString & | chars | ) |

Adds chars to the list of excluded characters.

Note
  Beware that exclusion takes priority over inclusion.

Since
  3.1.3

## ◆ AddCharIncludes()

void wxTextValidator::AddCharIncludes | ( | const wxString & | chars | ) |

Adds chars to the list of included characters.

Note
  Any explicitly excluded characters will still be excluded even if they're part of chars.

Since
  3.1.3

## ◆ AddExclude()

void wxTextValidator::AddExclude | ( | const wxString & | exclude | ) |

Adds exclude to the list of excluded values.

Note
  Beware that exclusion takes priority over inclusion.

Since
  3.1.3

## ◆ AddInclude()

void wxTextValidator::AddInclude | ( | const wxString & | include | ) |

Adds include to the list of included values.

Note
  Any explicitly excluded characters will still be excluded.

Since
  3.1.3

## ◆ Clone()

virtual wxObject * wxTextValidator::Clone | ( |  | ) | const
| virtual

Clones the text validator using the copy constructor.

Reimplemented from wxValidator.

## ◆ GetCharExcludes()

wxString wxTextValidator::GetCharExcludes | ( |  | ) | const

Returns a copy of the exclude char list (the list of invalid characters).

Since
  3.1.3

## ◆ GetCharIncludes()

wxString wxTextValidator::GetCharIncludes | ( |  | ) | const

Returns a copy of the include char list (the list of additional valid characters).

Since
  3.1.3

## ◆ GetExcludes()

const wxArrayString & wxTextValidator::GetExcludes | ( |  | ) | const

Returns a const reference to the exclude list (the list of invalid values).

## ◆ GetIncludes()

const wxArrayString & wxTextValidator::GetIncludes | ( |  | ) | const

Returns a const reference to the include list (the list of valid values).

## ◆ GetStyle()

long wxTextValidator::GetStyle | ( |  | ) | const

Returns the validator style.

See also
  HasFlag()

## ◆ HasFlag()

bool wxTextValidator::HasFlag | ( | wxTextValidatorStyle | style | ) | const

Returns true if the given style bit is set in the current style.

## ◆ IsCharExcluded()

bool wxTextValidator::IsCharExcluded | ( | const wxUniChar & | c | ) | const
| protected

Returns true if the char c is not allowed to be in the user input string.

(characters set by SetCharExcludes() or AddCharExcludes()).

Since
  3.1.3

## ◆ IsCharIncluded()

bool wxTextValidator::IsCharIncluded | ( | const wxUniChar & | c | ) | const
| protected

Returns true if the char c is allowed to be in the user input string.

Additional characters, set by SetCharIncludes() or AddCharIncludes() are also considered.

Since
  3.1.3

## ◆ IsExcluded()

bool wxTextValidator::IsExcluded | ( | const wxString & | str | ) | const
| protected

Returns true if the string str is one of the excludes strings set by SetExcludes() or AddExclude().

Since
  3.1.3

## ◆ IsIncluded()

bool wxTextValidator::IsIncluded | ( | const wxString & | str | ) | const
| protected

Returns true if the string str is one of the includes strings set by SetIncludes() or AddInclude().

Notice that unless wxFILTER_INCLUDE_LIST is specified (in which case the validator will complain if the user input is not on the list), the list will be ignored and won't participate in the validation process.

Since
  3.1.3

## ◆ IsValid()

virtual wxString wxTextValidator::IsValid | ( | const wxString & | val | ) | const
| virtual

Returns the error message if the contents of val are invalid or the empty string if val is valid.

## ◆ IsValidChar()

bool wxTextValidator::IsValidChar | ( | const wxUniChar & | c | ) | const
| protected

Returns false if the character c is invalid.

## ◆ OnChar()

void wxTextValidator::OnChar | ( | wxKeyEvent & | event | ) |

Receives character input from the window and filters it according to the current validator style.

## ◆ SetCharExcludes()

void wxTextValidator::SetCharExcludes | ( | const wxString & | chars | ) |

Sets the exclude char list (invalid characters for the user input).

Note
  Beware that exclusion takes priority over inclusion.
  This function may cancel the effect of `wxFILTER_SPACE` if the passed in string chars contains the space character.

## ◆ SetCharIncludes()

void wxTextValidator::SetCharIncludes | ( | const wxString & | chars | ) |

Sets the include char list (additional valid values for the user input).

Note
  Any explicitly excluded characters will still be excluded even if they're part of chars.

## ◆ SetExcludes()

void wxTextValidator::SetExcludes | ( | const wxArrayString & | stringList | ) |

Sets the exclude list (invalid values for the user input).

Note
  Beware that exclusion takes priority over inclusion.

## ◆ SetIncludes()

void wxTextValidator::SetIncludes | ( | const wxArrayString & | stringList | ) |

Sets the include list (valid values for the user input).

See also
  IsIncluded()

## ◆ SetStyle()

void wxTextValidator::SetStyle | ( | long | 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, some combinations have shorter and more idiomatic alternative, e.g. `wxFILTER_ALPHANUMERIC` can be used instead of `wxFILTER_ALPHA|wxFILTER_DIGITS`.

## ◆ TransferFromWindow()

virtual bool wxTextValidator::TransferFromWindow | ( |  | ) |
| virtual

Transfers the value in the text control to the string.

Reimplemented from wxValidator.

## ◆ TransferToWindow()

virtual bool wxTextValidator::TransferToWindow | ( |  | ) |
| virtual

Transfers the string value to the text control.

Reimplemented from wxValidator.

## ◆ Validate()

virtual bool wxTextValidator::Validate | ( | wxWindow * | parent | ) |
| virtual

Validates the window contents against the include or exclude lists, depending on the validator style.

Reimplemented from wxValidator.

Reimplemented in wxNumericPropertyValidator.