]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/validate.h
minor corrections: document typeDefault, remove text copied from the header (closes...
[wxWidgets.git] / interface / wx / validate.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: validate.h
e54c96f1 3// Purpose: interface of wxValidator
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxValidator
7c913512 11
fbec75d0
BP
12 wxValidator is the base class for a family of validator classes that
13 mediate between a class of control, and application data.
7c913512 14
23324ae1 15 A validator has three major roles:
7c913512 16
fbec75d0
BP
17 -# To transfer data from a C++ variable or own storage to and from a
18 control.
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.
7c913512 22
23324ae1 23 Validators can be plugged into controls dynamically.
7c913512 24
fbec75d0 25 To specify a default, "null" validator, use ::wxDefaultValidator.
7c913512 26
d9faa1fe 27 For more information, please see @ref overview_validator.
7c913512 28
d9faa1fe 29 @beginWxPythonOnly
fbec75d0
BP
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.
d9faa1fe 33 @endWxPythonOnly
7c913512 34
23324ae1
FM
35 @library{wxcore}
36 @category{validator}
7c913512 37
d9faa1fe
FM
38 @stdobjects
39 ::wxDefaultValidator
40
41 @see @ref overview_validator, wxTextValidator, wxGenericValidator
23324ae1
FM
42*/
43class wxValidator : public wxEvtHandler
44{
45public:
46 /**
47 Constructor.
48 */
49 wxValidator();
50
51 /**
52 Destructor.
53 */
adaaa686 54 virtual ~wxValidator();
23324ae1
FM
55
56 /**
fbec75d0
BP
57 All validator classes must implement the Clone() function, which
58 returns an identical copy of itself.
d9faa1fe 59
fbec75d0
BP
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.
d9faa1fe 64
d29a9a8a 65 @return This base function returns @NULL.
23324ae1 66 */
328f5751 67 virtual wxObject* Clone() const;
23324ae1
FM
68
69 /**
70 Returns the window associated with the validator.
71 */
328f5751 72 wxWindow* GetWindow() const;
23324ae1
FM
73
74 /**
75 This functions switches on or turns off the error sound produced by the
76 validators if an invalid key is pressed.
77 */
adaaa686 78 static void SetBellOnError(bool doIt = true);
23324ae1
FM
79
80 /**
81 Associates a window with the validator.
180d62d8
FM
82
83 This function is automatically called by wxWidgets when creating a wxWindow-derived
84 class instance which takes a wxValidator reference.
85
86 E.g.
87 @code
88 new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
89 wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
90 @endcode
91 will automatically link the wxTextValidator instance with the wxTextCtrl
92 instance.
23324ae1
FM
93 */
94 void SetWindow(wxWindow* window);
95
96 /**
fbec75d0
BP
97 This overridable function is called when the value in the window must
98 be transferred to the validator.
d9faa1fe
FM
99
100 @return @false if there is a problem.
23324ae1 101 */
d9faa1fe 102 virtual bool TransferFromWindow();
23324ae1
FM
103
104 /**
105 This overridable function is called when the value associated with the
d9faa1fe
FM
106 validator must be transferred to the window.
107
108 @return @false if there is a problem.
23324ae1
FM
109 */
110 virtual bool TransferToWindow();
111
112 /**
fbec75d0
BP
113 This overridable function is called when the value in the associated
114 window must be validated.
d9faa1fe 115
180d62d8
FM
116 @param parent
117 The parent of the window associated with the validator.
118
fbec75d0
BP
119 @return @false if the value in the window is not valid; you may pop up
120 an error dialog.
23324ae1
FM
121 */
122 virtual bool Validate(wxWindow* parent);
123};
e54c96f1 124
d9faa1fe 125/**
fbec75d0 126 An empty, "null" wxValidator instance.
d9faa1fe
FM
127*/
128wxValidator wxDefaultValidator;
fbec75d0 129