wxValidator Class Reference | wxWidgets

| Version: 3.2.11

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
wxValidator 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/validate.h>`

Inheritance diagram for wxValidator:
[legend]

## Detailed Description

wxValidator is the base class for a family of validator classes that mediate between a class of control, and application data.

A validator has three major roles:

1. To transfer data from a C++ variable or own storage to and from a control.
2. To validate data in a control, and show an appropriate error message.
3. To filter events (such as keystrokes), thereby changing the behaviour of the associated control.

Validators can be plugged into controls dynamically.

To specify a default, "null" validator, use wxDefaultValidator.

For more information, please see wxValidator Overview.

##

Library: wxCore
Category: Validators

Predefined objects/pointers: wxDefaultValidator

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

## Public Member Functions
| wxValidator ()
| Constructor.
virtual | ~wxValidator ()
| Destructor.
virtual wxObject * | Clone () const
| All validator classes must implement the Clone() function, which returns an identical copy of itself.
wxWindow * | GetWindow () const
| Returns the window associated with the validator.
virtual void | SetWindow (wxWindow *window)
| Associates a window with the validator.
virtual bool | TransferFromWindow ()
| This overridable function is called when the value in the window must be transferred to the validator.
virtual bool | TransferToWindow ()
| This overridable function is called when the value associated with the validator must be transferred to the window.
virtual bool | Validate (wxWindow *parent)
| This overridable function is called when the value in the associated window must be validated.
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.

## Static Public Member Functions
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().

## Additional Inherited Members
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.
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data.

## Constructor & Destructor Documentation

## ◆ wxValidator()

wxValidator::wxValidator | ( |  | ) |

Constructor.

## ◆ ~wxValidator()

virtual wxValidator::~wxValidator | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ Clone()

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

All validator classes must implement the Clone() function, which returns an identical copy of itself.

This is because validators are passed to control constructors as references which must be copied. Unlike objects such as pens and brushes, it does not make sense to have a reference counting scheme to do this cloning because all validators should have separate data.

Returns
  This base function returns NULL.

Reimplemented in wxGenericValidator, and wxTextValidator.

## ◆ GetWindow()

wxWindow * wxValidator::GetWindow | ( |  | ) | const

Returns the window associated with the validator.

## ◆ IsSilent()

bool wxValidator::IsSilent | ( |  | ) |
| static

Returns if the error sound is currently disabled.

## ◆ SetWindow()

virtual void wxValidator::SetWindow | ( | wxWindow * | window | ) |
| virtual

Associates a window with the validator.

This function is automatically called by wxWidgets when creating a wxWindow-derived class instance which takes a wxValidator reference. Since wxWidgets 3.1.1, it can be overridden in custom validators in order to perform any one-time initialization or checks of the window when the validator is associated with it.

E.g.

new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
wxTextCtrl
A text control allows text to be displayed and edited.
Definition textctrl.h:1436
wxTextValidator
wxTextValidator validates text controls, providing a variety of filtering behaviours.
Definition valtext.h:105
wxID_ANY
@ wxID_ANY
Any id: means that we don't care about the id, whether when installing an event handler or when creat...
Definition defs.h:597
wxDefaultSize
const wxSize wxDefaultSize
Global instance of a wxSize object initialized to (-1,-1).
Definition gdicmn.h:1106
wxDefaultPosition
const wxPoint wxDefaultPosition
Global instance of a wxPoint initialized with values (-1,-1).
Definition gdicmn.h:780
wxEmptyString
wxString wxEmptyString
The global wxString instance of an empty string.
Definition string.h:1977
wxFILTER_ALPHA
@ wxFILTER_ALPHA
Non-alpha characters are filtered out.
Definition valtext.h:34

will automatically link the wxTextValidator instance with the wxTextCtrl instance and call SetWindow() method on the wxTextValidator object.

## ◆ SuppressBellOnError()

void wxValidator::SuppressBellOnError | ( | bool | suppress = true | ) |
| static

This functions switches on or turns off the error sound produced by the validators if an invalid key is pressed.

Since
  2.9.1

Parameters

  suppress | If true, error sound is not played when a validator detects an error. If false, error sound is enabled.

## ◆ TransferFromWindow()

virtual bool wxValidator::TransferFromWindow | ( |  | ) |
| virtual

This overridable function is called when the value in the window must be transferred to the validator.

Returns
  false if there is a problem.

Reimplemented in wxGenericValidator, wxNumValidator< T >, and wxTextValidator.

## ◆ TransferToWindow()

virtual bool wxValidator::TransferToWindow | ( |  | ) |
| virtual

This overridable function is called when the value associated with the validator must be transferred to the window.

Returns
  false if there is a problem.

Reimplemented in wxGenericValidator, wxNumValidator< T >, and wxTextValidator.

## ◆ Validate()

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

This overridable function is called when the value in the associated window must be validated.

Parameters

  parent | The parent of the window associated with the validator.

Returns
  false if the value in the window is not valid; you may pop up an error dialog.

Reimplemented in wxNumericPropertyValidator, and wxTextValidator.