Remove obsolete VisualAge-related files.
[wxWidgets.git] / interface / wx / validate.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: validate.h
3 // Purpose: interface of wxValidator
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
7
8 /**
9 @class wxValidator
10
11 wxValidator is the base class for a family of validator classes that
12 mediate between a class of control, and application data.
13
14 A validator has three major roles:
15
16 -# To transfer data from a C++ variable or own storage to and from a
17 control.
18 -# To validate data in a control, and show an appropriate error message.
19 -# To filter events (such as keystrokes), thereby changing the behaviour
20 of the associated control.
21
22 Validators can be plugged into controls dynamically.
23
24 To specify a default, "null" validator, use ::wxDefaultValidator.
25
26 For more information, please see @ref overview_validator.
27
28 @library{wxcore}
29 @category{validator}
30
31 @stdobjects
32 ::wxDefaultValidator
33
34 @see @ref overview_validator, wxTextValidator, wxGenericValidator,
35 wxIntegerValidator, wxFloatingPointValidator
36 */
37 class wxValidator : public wxEvtHandler
38 {
39 public:
40 /**
41 Constructor.
42 */
43 wxValidator();
44
45 /**
46 Destructor.
47 */
48 virtual ~wxValidator();
49
50 /**
51 All validator classes must implement the Clone() function, which
52 returns an identical copy of itself.
53
54 This is because validators are passed to control constructors as
55 references which must be copied. Unlike objects such as pens and
56 brushes, it does not make sense to have a reference counting scheme to
57 do this cloning because all validators should have separate data.
58
59 @return This base function returns @NULL.
60 */
61 virtual wxObject* Clone() const;
62
63 /**
64 Returns the window associated with the validator.
65 */
66 wxWindow* GetWindow() const;
67
68 /**
69 This functions switches on or turns off the error sound produced by the
70 validators if an invalid key is pressed.
71
72 @since 2.9.1
73
74 @param suppress
75 If @true, error sound is not played when a validator detects an
76 error. If @false, error sound is enabled.
77 */
78 static void SuppressBellOnError(bool suppress = true);
79
80 /**
81 Returns if the error sound is currently disabled.
82 */
83 static bool IsSilent();
84
85 /**
86 Associates a window with the validator.
87
88 This function is automatically called by wxWidgets when creating a wxWindow-derived
89 class instance which takes a wxValidator reference.
90
91 E.g.
92 @code
93 new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
94 wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
95 @endcode
96 will automatically link the wxTextValidator instance with the wxTextCtrl
97 instance.
98 */
99 void SetWindow(wxWindow* window);
100
101 /**
102 This overridable function is called when the value in the window must
103 be transferred to the validator.
104
105 @return @false if there is a problem.
106 */
107 virtual bool TransferFromWindow();
108
109 /**
110 This overridable function is called when the value associated with the
111 validator must be transferred to the window.
112
113 @return @false if there is a problem.
114 */
115 virtual bool TransferToWindow();
116
117 /**
118 This overridable function is called when the value in the associated
119 window must be validated.
120
121 @param parent
122 The parent of the window associated with the validator.
123
124 @return @false if the value in the window is not valid; you may pop up
125 an error dialog.
126 */
127 virtual bool Validate(wxWindow* parent);
128 };
129
130 /**
131 An empty, "null" wxValidator instance.
132 */
133 const wxValidator wxDefaultValidator;
134