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