]> git.saurik.com Git - wxWidgets.git/blame - interface/validate.h
include wx/crt.h to get wxUSE_WXVSNPRINTF
[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
fbec75d0
BP
13 wxValidator is the base class for a family of validator classes that
14 mediate between a class of control, and application data.
7c913512 15
23324ae1 16 A validator has three major roles:
7c913512 17
fbec75d0
BP
18 -# To transfer data from a C++ variable or own storage to and from a
19 control.
20 -# To validate data in a control, and show an appropriate error message.
21 -# To filter events (such as keystrokes), thereby changing the behaviour
22 of the associated control.
7c913512 23
23324ae1 24 Validators can be plugged into controls dynamically.
7c913512 25
fbec75d0 26 To specify a default, "null" validator, use ::wxDefaultValidator.
7c913512 27
d9faa1fe 28 For more information, please see @ref overview_validator.
7c913512 29
d9faa1fe 30 @beginWxPythonOnly
fbec75d0
BP
31 If you wish to create a validator class in wxPython you should derive the
32 class from @c wxPyValidator in order to get Python-aware capabilities for
33 the various virtual methods.
d9faa1fe 34 @endWxPythonOnly
7c913512 35
23324ae1
FM
36 @library{wxcore}
37 @category{validator}
7c913512 38
d9faa1fe
FM
39 @stdobjects
40 ::wxDefaultValidator
41
42 @see @ref overview_validator, wxTextValidator, wxGenericValidator
23324ae1
FM
43*/
44class wxValidator : public wxEvtHandler
45{
46public:
47 /**
48 Constructor.
49 */
50 wxValidator();
51
52 /**
53 Destructor.
54 */
55 ~wxValidator();
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.
78 */
4cc4bfaf 79 void SetBellOnError(bool doIt = true);
23324ae1
FM
80
81 /**
82 Associates a window with the validator.
83 */
84 void SetWindow(wxWindow* window);
85
86 /**
fbec75d0
BP
87 This overridable function is called when the value in the window must
88 be transferred to the validator.
d9faa1fe
FM
89
90 @return @false if there is a problem.
23324ae1 91 */
d9faa1fe 92 virtual bool TransferFromWindow();
23324ae1
FM
93
94 /**
95 This overridable function is called when the value associated with the
d9faa1fe
FM
96 validator must be transferred to the window.
97
98 @return @false if there is a problem.
23324ae1
FM
99 */
100 virtual bool TransferToWindow();
101
102 /**
fbec75d0
BP
103 This overridable function is called when the value in the associated
104 window must be validated.
d9faa1fe 105
fbec75d0
BP
106 @return @false if the value in the window is not valid; you may pop up
107 an error dialog.
23324ae1
FM
108 */
109 virtual bool Validate(wxWindow* parent);
110};
e54c96f1 111
d9faa1fe 112/**
fbec75d0 113 An empty, "null" wxValidator instance.
d9faa1fe
FM
114*/
115wxValidator wxDefaultValidator;
fbec75d0 116