]> git.saurik.com Git - wxWidgets.git/blob - interface/validate.h
a0c4ec1ace3be6aed25c21b8eff5d82b7749031f
[wxWidgets.git] / interface / validate.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: validate.h
3 // Purpose: documentation for wxValidator class
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxValidator
11 @wxheader{validate.h}
12
13 wxValidator is the base class for a family of validator classes that mediate
14 between a class of control, and application data.
15
16 A validator has three major roles:
17
18 to transfer data from a C++ variable or own storage to and from a 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 of the
21 associated control.
22
23 Validators can be plugged into controls dynamically.
24
25 To specify a default, 'null' validator, use the symbol @b wxDefaultValidator.
26
27 For more information, please see @ref overview_validatoroverview "Validator
28 overview".
29
30 @b wxPython note: If you wish to create a validator class in wxPython you should
31 derive the class from @c wxPyValidator in order to get Python-aware
32 capabilities for the various virtual methods.
33
34 @library{wxcore}
35 @category{validator}
36
37 @seealso
38 @ref overview_validatoroverview "Validator overview", wxTextValidator,
39 wxGenericValidator,
40 */
41 class wxValidator : public wxEvtHandler
42 {
43 public:
44 /**
45 Constructor.
46 */
47 wxValidator();
48
49 /**
50 Destructor.
51 */
52 ~wxValidator();
53
54 /**
55 All validator classes must implement the @b Clone function, which returns
56 an identical copy of itself. This is because validators are passed to control
57 constructors as references which must be copied. Unlike objects such as pens
58 and brushes, it does not make sense to have a reference counting scheme
59 to do this cloning, because all validators should have separate
60 data.
61 This base function returns @NULL.
62 */
63 virtual wxObject* Clone();
64
65 /**
66 Returns the window associated with the validator.
67 */
68 wxWindow* GetWindow();
69
70 /**
71 This functions switches on or turns off the error sound produced by the
72 validators if an invalid key is pressed.
73 */
74 void SetBellOnError(bool doIt = true);
75
76 /**
77 Associates a window with the validator.
78 */
79 void SetWindow(wxWindow* window);
80
81 /**
82 This overridable function is called when the value in the window must be
83 transferred to the validator. Return @false if there is a problem.
84 */
85 virtual bool TransferToWindow();
86
87 /**
88 This overridable function is called when the value associated with the
89 validator must be
90 transferred to the window. Return @false if there is a problem.
91 */
92 virtual bool TransferToWindow();
93
94 /**
95 This overridable function is called when the value in the associated window
96 must be validated.
97 Return @false if the value in the window is not valid; you may pop up an error
98 dialog.
99 */
100 virtual bool Validate(wxWindow* parent);
101 };