]> git.saurik.com Git - wxWidgets.git/blame - interface/validate.h
replace @b Note with @note; replace '' with "
[wxWidgets.git] / interface / 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
11 @wxheader{validate.h}
7c913512 12
23324ae1
FM
13 wxValidator is the base class for a family of validator classes that mediate
14 between a class of control, and application data.
7c913512 15
23324ae1 16 A validator has three major roles:
7c913512 17
d9faa1fe
FM
18 @li to transfer data from a C++ variable or own storage to and from a control;
19 @li to validate data in a control, and show an appropriate error message;
20 @li to filter events (such as keystrokes), thereby changing the behaviour of the
21 associated control.
7c913512 22
23324ae1 23 Validators can be plugged into controls dynamically.
7c913512 24
d9faa1fe 25 To specify a default, 'null' validator, use the symbol ::wxDefaultValidator.
7c913512 26
d9faa1fe 27 For more information, please see @ref overview_validator.
7c913512 28
d9faa1fe
FM
29 @beginWxPythonOnly
30 If you wish to create a validator class in wxPython you should
23324ae1
FM
31 derive the class from @c wxPyValidator in order to get Python-aware
32 capabilities for 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 */
54 ~wxValidator();
55
56 /**
d9faa1fe
FM
57 All validator classes must implement the Clone() function, which returns
58 an identical copy of itself.
59
60 This is because validators are passed to control constructors as references
61 which must be copied. Unlike objects such as pens and brushes, it does not
62 make sense to have a reference counting scheme to do this cloning, because
63 all validators should have separate data.
64
65 @returns 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 */
4cc4bfaf 78 void SetBellOnError(bool doIt = true);
23324ae1
FM
79
80 /**
81 Associates a window with the validator.
82 */
83 void SetWindow(wxWindow* window);
84
85 /**
86 This overridable function is called when the value in the window must be
d9faa1fe
FM
87 transferred to the validator.
88
89 @return @false if there is a problem.
23324ae1 90 */
d9faa1fe 91 virtual bool TransferFromWindow();
23324ae1
FM
92
93 /**
94 This overridable function is called when the value associated with the
d9faa1fe
FM
95 validator must be transferred to the window.
96
97 @return @false if there is a problem.
23324ae1
FM
98 */
99 virtual bool TransferToWindow();
100
101 /**
102 This overridable function is called when the value in the associated window
103 must be validated.
d9faa1fe
FM
104
105 @return @false if the value in the window is not valid; you may pop up an error
106 dialog.
23324ae1
FM
107 */
108 virtual bool Validate(wxWindow* parent);
109};
e54c96f1 110
d9faa1fe
FM
111/**
112 An empty wxValidator instance.
113*/
114wxValidator wxDefaultValidator;