2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: validate.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxValidator
|
|
|
|
@wxheader{validate.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxValidator is the base class for a family of validator classes that mediate
|
|
|
|
between a class of control, and application data.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A validator has three major roles:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-27 16:54:47 -04:00
|
|
|
@li to transfer data from a C++ variable or own storage to and from a control;
|
|
|
|
@li to validate data in a control, and show an appropriate error message;
|
|
|
|
@li to filter events (such as keystrokes), thereby changing the behaviour of the
|
|
|
|
associated control.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Validators can be plugged into controls dynamically.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-27 16:54:47 -04:00
|
|
|
To specify a default, 'null' validator, use the symbol ::wxDefaultValidator.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-27 16:54:47 -04:00
|
|
|
For more information, please see @ref overview_validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-27 16:54:47 -04:00
|
|
|
@beginWxPythonOnly
|
|
|
|
If you wish to create a validator class in wxPython you should
|
2008-03-08 08:52:38 -05:00
|
|
|
derive the class from @c wxPyValidator in order to get Python-aware
|
|
|
|
capabilities for the various virtual methods.
|
2008-03-27 16:54:47 -04:00
|
|
|
@endWxPythonOnly
|
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-27 16:54:47 -04:00
|
|
|
@stdobjects
|
|
|
|
::wxDefaultValidator
|
|
|
|
|
|
|
|
@see @ref overview_validator, wxTextValidator, wxGenericValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxValidator : public wxEvtHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxValidator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
|
|
|
~wxValidator();
|
|
|
|
|
|
|
|
/**
|
2008-03-27 16:54:47 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
virtual wxObject* Clone() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the window associated with the validator.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxWindow* GetWindow() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This functions switches on or turns off the error sound produced by the
|
|
|
|
validators if an invalid key is pressed.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetBellOnError(bool doIt = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Associates a window with the validator.
|
|
|
|
*/
|
|
|
|
void SetWindow(wxWindow* window);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This overridable function is called when the value in the window must be
|
2008-03-27 16:54:47 -04:00
|
|
|
transferred to the validator.
|
|
|
|
|
|
|
|
@return @false if there is a problem.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-27 16:54:47 -04:00
|
|
|
virtual bool TransferFromWindow();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This overridable function is called when the value associated with the
|
2008-03-27 16:54:47 -04:00
|
|
|
validator must be transferred to the window.
|
|
|
|
|
|
|
|
@return @false if there is a problem.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool TransferToWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This overridable function is called when the value in the associated window
|
|
|
|
must be validated.
|
2008-03-27 16:54:47 -04:00
|
|
|
|
|
|
|
@return @false if the value in the window is not valid; you may pop up an error
|
|
|
|
dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool Validate(wxWindow* parent);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-27 16:54:47 -04:00
|
|
|
/**
|
|
|
|
An empty wxValidator instance.
|
|
|
|
*/
|
|
|
|
wxValidator wxDefaultValidator;
|