]>
Commit | Line | Data |
---|---|---|
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 | |
23324ae1 FM |
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. | |
7c913512 | 22 | |
23324ae1 | 23 | Validators can be plugged into controls dynamically. |
7c913512 | 24 | |
23324ae1 | 25 | To specify a default, 'null' validator, use the symbol @b wxDefaultValidator. |
7c913512 | 26 | |
23324ae1 FM |
27 | For more information, please see @ref overview_validatoroverview "Validator |
28 | overview". | |
7c913512 | 29 | |
23324ae1 FM |
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. | |
7c913512 | 33 | |
23324ae1 FM |
34 | @library{wxcore} |
35 | @category{validator} | |
7c913512 | 36 | |
e54c96f1 | 37 | @see @ref overview_validatoroverview "Validator overview", wxTextValidator, |
23324ae1 FM |
38 | wxGenericValidator, |
39 | */ | |
40 | class wxValidator : public wxEvtHandler | |
41 | { | |
42 | public: | |
43 | /** | |
44 | Constructor. | |
45 | */ | |
46 | wxValidator(); | |
47 | ||
48 | /** | |
49 | Destructor. | |
50 | */ | |
51 | ~wxValidator(); | |
52 | ||
53 | /** | |
54 | All validator classes must implement the @b Clone function, which returns | |
55 | an identical copy of itself. This is because validators are passed to control | |
56 | constructors as references which must be copied. Unlike objects such as pens | |
57 | and brushes, it does not make sense to have a reference counting scheme | |
58 | to do this cloning, because all validators should have separate | |
59 | data. | |
23324ae1 FM |
60 | This base function returns @NULL. |
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. | |
72 | */ | |
4cc4bfaf | 73 | void SetBellOnError(bool doIt = true); |
23324ae1 FM |
74 | |
75 | /** | |
76 | Associates a window with the validator. | |
77 | */ | |
78 | void SetWindow(wxWindow* window); | |
79 | ||
80 | /** | |
81 | This overridable function is called when the value in the window must be | |
82 | transferred to the validator. Return @false if there is a problem. | |
83 | */ | |
84 | virtual bool TransferToWindow(); | |
85 | ||
86 | /** | |
87 | This overridable function is called when the value associated with the | |
88 | validator must be | |
89 | transferred to the window. Return @false if there is a problem. | |
90 | */ | |
91 | virtual bool TransferToWindow(); | |
92 | ||
93 | /** | |
94 | This overridable function is called when the value in the associated window | |
95 | must be validated. | |
96 | Return @false if the value in the window is not valid; you may pop up an error | |
97 | dialog. | |
98 | */ | |
99 | virtual bool Validate(wxWindow* parent); | |
100 | }; | |
e54c96f1 | 101 |