]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/validate.h
few other fixes for wxChar => wxString
[wxWidgets.git] / interface / wx / validate.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: validate.h
3 // Purpose: interface of wxValidator
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxValidator
11
12 wxValidator is the base class for a family of validator classes that
13 mediate between a class of control, and application data.
14
15 A validator has three major roles:
16
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.
22
23 Validators can be plugged into controls dynamically.
24
25 To specify a default, "null" validator, use ::wxDefaultValidator.
26
27 For more information, please see @ref overview_validator.
28
29 @beginWxPythonOnly
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.
33 @endWxPythonOnly
34
35 @library{wxcore}
36 @category{validator}
37
38 @stdobjects
39 ::wxDefaultValidator
40
41 @see @ref overview_validator, wxTextValidator, wxGenericValidator
42 */
43 class wxValidator : public wxEvtHandler
44 {
45 public:
46 /**
47 Constructor.
48 */
49 wxValidator();
50
51 /**
52 Destructor.
53 */
54 virtual ~wxValidator();
55
56 /**
57 All validator classes must implement the Clone() function, which
58 returns an identical copy of itself.
59
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.
64
65 @return This base function returns @NULL.
66 */
67 virtual wxObject* Clone() const;
68
69 /**
70 Returns the window associated with the validator.
71 */
72 wxWindow* GetWindow() const;
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 */
78 static void SetBellOnError(bool doIt = true);
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
87 be transferred to the validator.
88
89 @return @false if there is a problem.
90 */
91 virtual bool TransferFromWindow();
92
93 /**
94 This overridable function is called when the value associated with the
95 validator must be transferred to the window.
96
97 @return @false if there is a problem.
98 */
99 virtual bool TransferToWindow();
100
101 /**
102 This overridable function is called when the value in the associated
103 window must be validated.
104
105 @return @false if the value in the window is not valid; you may pop up
106 an error dialog.
107 */
108 virtual bool Validate(wxWindow* parent);
109 };
110
111 /**
112 An empty, "null" wxValidator instance.
113 */
114 wxValidator wxDefaultValidator;
115