]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/validate.h
Cleanup of wxDataViewCtrl cell activation code.
[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$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
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
a54cf371
VZ
41 @see @ref overview_validator, wxTextValidator, wxGenericValidator,
42 wxIntegerValidator, wxFloatingPointValidator
23324ae1
FM
43*/
44class wxValidator : public wxEvtHandler
45{
46public:
47 /**
48 Constructor.
49 */
50 wxValidator();
51
52 /**
53 Destructor.
54 */
adaaa686 55 virtual ~wxValidator();
23324ae1
FM
56
57 /**
fbec75d0
BP
58 All validator classes must implement the Clone() function, which
59 returns an identical copy of itself.
d9faa1fe 60
fbec75d0
BP
61 This is because validators are passed to control constructors as
62 references which must be copied. Unlike objects such as pens and
63 brushes, it does not make sense to have a reference counting scheme to
64 do this cloning because all validators should have separate data.
d9faa1fe 65
d29a9a8a 66 @return This base function returns @NULL.
23324ae1 67 */
328f5751 68 virtual wxObject* Clone() const;
23324ae1
FM
69
70 /**
71 Returns the window associated with the validator.
72 */
328f5751 73 wxWindow* GetWindow() const;
23324ae1
FM
74
75 /**
76 This functions switches on or turns off the error sound produced by the
77 validators if an invalid key is pressed.
c27181d1
VZ
78
79 @since 2.9.1
80
81 @param suppress
82 If @true, error sound is not played when a validator detects an
83 error. If @false, error sound is enabled.
23324ae1 84 */
c27181d1 85 static void SuppressBellOnError(bool suppress = true);
23324ae1
FM
86
87 /**
88 Associates a window with the validator.
180d62d8
FM
89
90 This function is automatically called by wxWidgets when creating a wxWindow-derived
91 class instance which takes a wxValidator reference.
92
93 E.g.
94 @code
95 new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
96 wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
97 @endcode
98 will automatically link the wxTextValidator instance with the wxTextCtrl
99 instance.
23324ae1
FM
100 */
101 void SetWindow(wxWindow* window);
102
103 /**
fbec75d0
BP
104 This overridable function is called when the value in the window must
105 be transferred to the validator.
d9faa1fe
FM
106
107 @return @false if there is a problem.
23324ae1 108 */
d9faa1fe 109 virtual bool TransferFromWindow();
23324ae1
FM
110
111 /**
112 This overridable function is called when the value associated with the
d9faa1fe
FM
113 validator must be transferred to the window.
114
115 @return @false if there is a problem.
23324ae1
FM
116 */
117 virtual bool TransferToWindow();
118
119 /**
fbec75d0
BP
120 This overridable function is called when the value in the associated
121 window must be validated.
d9faa1fe 122
180d62d8
FM
123 @param parent
124 The parent of the window associated with the validator.
125
fbec75d0
BP
126 @return @false if the value in the window is not valid; you may pop up
127 an error dialog.
23324ae1
FM
128 */
129 virtual bool Validate(wxWindow* parent);
130};
e54c96f1 131
d9faa1fe 132/**
fbec75d0 133 An empty, "null" wxValidator instance.
d9faa1fe 134*/
05b0355a 135const wxValidator wxDefaultValidator;
fbec75d0 136