A programmer creating a new validator class should provide the following functionality.
A validator constructor is responsible for allowing the programmer to specify the kind of validation required, and perhaps
a pointer to a C++ variable that is used for storing the data for the control. If such a variable address is not supplied by
the user, then the validator should store the data internally.
The wxValidator::Validate member function should return true if the data in the control (not the C++ variable) is valid.
It should also show an appropriate message if data was not valid.
The wxValidator::TransferToWindow member function should transfer the data from the validator or associated C++ variable to
the control.
The wxValidator::TransferFromWindow member function should transfer the data from the control to the validator or associated
C++ variable.
There should be a copy constructor, and a wxValidator::Clone function which returns a copy of the validator object. This is
important because validators are passed by reference to window constructors, and must therefore be cloned internally.
You can optionally define event handlers for the validator, to implement filtering. These handlers will capture events before
the control itself does.
For an example implementation, see the valtext.h and valtext.cpp files in the wxWidgets library.
July 21th Tuesday (七月 二十一日 火曜日)
最新推荐文章于 2023-03-31 19:14:47 发布