]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/validate.h
Implement setFont on the iOS port of wxStaticText.
[wxWidgets.git] / interface / wx / validate.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: validate.h
e54c96f1 3// Purpose: interface of wxValidator
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxValidator
7c913512 10
fbec75d0
BP
11 wxValidator is the base class for a family of validator classes that
12 mediate between a class of control, and application data.
7c913512 13
23324ae1 14 A validator has three major roles:
7c913512 15
fbec75d0
BP
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.
7c913512 21
23324ae1 22 Validators can be plugged into controls dynamically.
7c913512 23
fbec75d0 24 To specify a default, "null" validator, use ::wxDefaultValidator.
7c913512 25
d9faa1fe 26 For more information, please see @ref overview_validator.
7c913512 27
23324ae1
FM
28 @library{wxcore}
29 @category{validator}
7c913512 30
d9faa1fe
FM
31 @stdobjects
32 ::wxDefaultValidator
33
a54cf371
VZ
34 @see @ref overview_validator, wxTextValidator, wxGenericValidator,
35 wxIntegerValidator, wxFloatingPointValidator
23324ae1
FM
36*/
37class wxValidator : public wxEvtHandler
38{
39public:
40 /**
41 Constructor.
42 */
43 wxValidator();
44
45 /**
46 Destructor.
47 */
adaaa686 48 virtual ~wxValidator();
23324ae1
FM
49
50 /**
fbec75d0
BP
51 All validator classes must implement the Clone() function, which
52 returns an identical copy of itself.
d9faa1fe 53
fbec75d0
BP
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.
d9faa1fe 58
d29a9a8a 59 @return This base function returns @NULL.
23324ae1 60 */
328f5751 61 virtual wxObject* Clone() const;
23324ae1
FM
62
63 /**
64 Returns the window associated with the validator.
65 */
328f5751 66 wxWindow* GetWindow() const;
23324ae1
FM
67
68 /**
69 This functions switches on or turns off the error sound produced by the
70 validators if an invalid key is pressed.
c27181d1
VZ
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.
23324ae1 77 */
c27181d1 78 static void SuppressBellOnError(bool suppress = true);
23324ae1 79
0c3140ca
RD
80 /**
81 Returns if the error sound is currently disabled.
82 */
83 static bool IsSilent();
84
23324ae1
FM
85 /**
86 Associates a window with the validator.
180d62d8
FM
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.
23324ae1
FM
98 */
99 void SetWindow(wxWindow* window);
100
101 /**
fbec75d0
BP
102 This overridable function is called when the value in the window must
103 be transferred to the validator.
d9faa1fe
FM
104
105 @return @false if there is a problem.
23324ae1 106 */
d9faa1fe 107 virtual bool TransferFromWindow();
23324ae1
FM
108
109 /**
110 This overridable function is called when the value associated with the
d9faa1fe
FM
111 validator must be transferred to the window.
112
113 @return @false if there is a problem.
23324ae1
FM
114 */
115 virtual bool TransferToWindow();
116
117 /**
fbec75d0
BP
118 This overridable function is called when the value in the associated
119 window must be validated.
d9faa1fe 120
180d62d8
FM
121 @param parent
122 The parent of the window associated with the validator.
123
fbec75d0
BP
124 @return @false if the value in the window is not valid; you may pop up
125 an error dialog.
23324ae1
FM
126 */
127 virtual bool Validate(wxWindow* parent);
128};
e54c96f1 129
d9faa1fe 130/**
fbec75d0 131 An empty, "null" wxValidator instance.
d9faa1fe 132*/
05b0355a 133const wxValidator wxDefaultValidator;
fbec75d0 134