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