1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxValidator
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 wxValidator is the base class for a family of validator classes that
13 mediate between a class of control, and application data.
15 A validator has three major roles:
17 -# To transfer data from a C++ variable or own storage to and from a
19 -# To validate data in a control, and show an appropriate error message.
20 -# To filter events (such as keystrokes), thereby changing the behaviour
21 of the associated control.
23 Validators can be plugged into controls dynamically.
25 To specify a default, "null" validator, use ::wxDefaultValidator.
27 For more information, please see @ref overview_validator.
30 If you wish to create a validator class in wxPython you should derive the
31 class from @c wxPyValidator in order to get Python-aware capabilities for
32 the various virtual methods.
41 @see @ref overview_validator, wxTextValidator, wxGenericValidator
43 class wxValidator
: public wxEvtHandler
54 virtual ~wxValidator();
57 All validator classes must implement the Clone() function, which
58 returns an identical copy of itself.
60 This is because validators are passed to control constructors as
61 references which must be copied. Unlike objects such as pens and
62 brushes, it does not make sense to have a reference counting scheme to
63 do this cloning because all validators should have separate data.
65 @return This base function returns @NULL.
67 virtual wxObject
* Clone() const;
70 Returns the window associated with the validator.
72 wxWindow
* GetWindow() const;
75 This functions switches on or turns off the error sound produced by the
76 validators if an invalid key is pressed.
81 If @true, error sound is not played when a validator detects an
82 error. If @false, error sound is enabled.
84 static void SuppressBellOnError(bool suppress
= true);
87 Associates a window with the validator.
89 This function is automatically called by wxWidgets when creating a wxWindow-derived
90 class instance which takes a wxValidator reference.
94 new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
95 wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
97 will automatically link the wxTextValidator instance with the wxTextCtrl
100 void SetWindow(wxWindow
* window
);
103 This overridable function is called when the value in the window must
104 be transferred to the validator.
106 @return @false if there is a problem.
108 virtual bool TransferFromWindow();
111 This overridable function is called when the value associated with the
112 validator must be transferred to the window.
114 @return @false if there is a problem.
116 virtual bool TransferToWindow();
119 This overridable function is called when the value in the associated
120 window must be validated.
123 The parent of the window associated with the validator.
125 @return @false if the value in the window is not valid; you may pop up
128 virtual bool Validate(wxWindow
* parent
);
132 An empty, "null" wxValidator instance.
134 wxValidator wxDefaultValidator
;