]>
Commit | Line | Data |
---|---|---|
1 | \section{\class{wxValidator}}\label{wxvalidator} | |
2 | ||
3 | wxValidator is the base class for a family of validator classes that mediate | |
4 | between a class of control, and application data. | |
5 | ||
6 | A validator has three major roles: | |
7 | ||
8 | \begin{enumerate}\itemsep=0pt | |
9 | \item to transfer data from a C++ variable or own storage to and from a control; | |
10 | \item to validate data in a control, and show an appropriate error message; | |
11 | \item to filter events (such as keystrokes), thereby changing the behaviour of the | |
12 | associated control. | |
13 | \end{enumerate} | |
14 | ||
15 | Validators can be plugged into controls dynamically. | |
16 | ||
17 | To specify a default, `null' validator, use the symbol {\bf wxDefaultValidator}. | |
18 | ||
19 | For more information, please see \helpref{Validator overview}{validatoroverview}. | |
20 | ||
21 | \pythonnote{If you wish to create a validator class in wxPython you should | |
22 | derive the class from {\tt wxPyValidator} in order to get Python-aware | |
23 | capabilities for the various virtual methods.} | |
24 | ||
25 | \wxheading{Derived from} | |
26 | ||
27 | \helpref{wxEvtHandler}{wxevthandler}\\ | |
28 | \helpref{wxObject}{wxobject} | |
29 | ||
30 | \wxheading{Include files} | |
31 | ||
32 | <wx/validate.h> | |
33 | ||
34 | \wxheading{Library} | |
35 | ||
36 | \helpref{wxCore}{librarieslist} | |
37 | ||
38 | \wxheading{See also} | |
39 | ||
40 | \helpref{Validator overview}{validatoroverview}, | |
41 | \helpref{wxTextValidator}{wxtextvalidator}, | |
42 | \helpref{wxGenericValidator}{wxgenericvalidator}, | |
43 | ||
44 | \latexignore{\rtfignore{\wxheading{Members}}} | |
45 | ||
46 | \membersection{wxValidator::wxValidator}\label{wxvalidatorctor} | |
47 | ||
48 | \func{}{wxValidator}{\void} | |
49 | ||
50 | Constructor. | |
51 | ||
52 | \membersection{wxValidator::\destruct{wxValidator}}\label{wxvalidatordtor} | |
53 | ||
54 | \func{}{\destruct{wxValidator}}{\void} | |
55 | ||
56 | Destructor. | |
57 | ||
58 | \membersection{wxValidator::Clone}\label{wxvalidatorclone} | |
59 | ||
60 | \constfunc{virtual wxObject*}{Clone}{\void} | |
61 | ||
62 | All validator classes must implement the {\bf Clone} function, which returns | |
63 | an identical copy of itself. This is because validators are passed to control | |
64 | constructors as references which must be copied. Unlike objects such as pens | |
65 | and brushes, it does not make sense to have a reference counting scheme | |
66 | to do this cloning, because all validators should have separate | |
67 | data. | |
68 | ||
69 | This base function returns NULL. | |
70 | ||
71 | \membersection{wxValidator::GetWindow}\label{wxvalidatorgetwindow} | |
72 | ||
73 | \constfunc{wxWindow*}{GetWindow}{\void} | |
74 | ||
75 | Returns the window associated with the validator. | |
76 | ||
77 | \membersection{wxValidator::SetBellOnError}\label{wxvalidatorsetbellonerror} | |
78 | ||
79 | \func{void}{SetBellOnError}{\param{bool}{ doIt = true}} | |
80 | ||
81 | This functions switches on or turns off the error sound produced by the | |
82 | validators if an invalid key is pressed. | |
83 | ||
84 | \membersection{wxValidator::SetWindow}\label{wxvalidatorsetwindow} | |
85 | ||
86 | \func{void}{SetWindow}{\param{wxWindow*}{ window}} | |
87 | ||
88 | Associates a window with the validator. | |
89 | ||
90 | \membersection{wxValidator::TransferFromWindow}\label{wxvalidatortransferfromwindow} | |
91 | ||
92 | \func{virtual bool}{TransferToWindow}{} | |
93 | ||
94 | This overridable function is called when the value in the window must be | |
95 | transferred to the validator. Return false if there is a problem. | |
96 | ||
97 | \membersection{wxValidator::TransferToWindow}\label{wxvalidatortransfertowindow} | |
98 | ||
99 | \func{virtual bool}{TransferToWindow}{} | |
100 | ||
101 | This overridable function is called when the value associated with the validator must be | |
102 | transferred to the window. Return false if there is a problem. | |
103 | ||
104 | \membersection{wxValidator::Validate}\label{wxvalidatorvalidate} | |
105 | ||
106 | \func{virtual bool}{Validate}{\param{wxWindow*}{ parent}} | |
107 | ||
108 | This overridable function is called when the value in the associated window must be validated. | |
109 | Return false if the value in the window is not valid; you may pop up an error dialog. | |
110 |