removed useless spaces
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51911 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
@page validator_overview wxValidator overview
|
||||
|
||||
Classes: #wxValidator, #wxTextValidator,
|
||||
|
||||
Classes: #wxValidator, #wxTextValidator,
|
||||
#wxGenericValidator
|
||||
The aim of the validator concept is to make dialogs very much easier to write.
|
||||
A validator is an object that can be plugged into a control (such as a wxTextCtrl), and
|
||||
@@ -18,27 +18,27 @@
|
||||
and validating it. It also is able to intercept events generated
|
||||
by the control, providing filtering behaviour without the need to derive a new control class.
|
||||
You can use a stock validator, such as #wxTextValidator (which does text
|
||||
control data transfer, validation and filtering) and
|
||||
control data transfer, validation and filtering) and
|
||||
#wxGenericValidator (which does data transfer for a range of controls);
|
||||
or you can write your own.
|
||||
@b Example
|
||||
Here is an example of wxTextValidator usage.
|
||||
|
||||
|
||||
@code
|
||||
wxTextCtrl *txt1 = new wxTextCtrl(this, -1, wxT(""),
|
||||
wxPoint(10, 10), wxSize(100, 80), 0,
|
||||
wxTextValidator(wxFILTER_ALPHA, _data.m_string));
|
||||
@endcode
|
||||
|
||||
|
||||
In this example, the text validator object provides the following functionality:
|
||||
|
||||
|
||||
|
||||
|
||||
It transfers the value of g_data.m_string (a wxString variable) to the wxTextCtrl when
|
||||
the dialog is initialised.
|
||||
It transfers the wxTextCtrl data back to this variable when the dialog is dismissed.
|
||||
It filters input characters so that only alphabetic characters are allowed.
|
||||
|
||||
|
||||
|
||||
|
||||
The validation and filtering of input is accomplished in two ways. When a character is input,
|
||||
wxTextValidator checks the character against the allowed filter flag (wxFILTER_ALPHA in this case). If
|
||||
the character is inappropriate, it is vetoed (does not appear) and a warning beep sounds.
|
||||
@@ -76,11 +76,11 @@
|
||||
function finds all the validators in the window's children and calls the TransferToWindow
|
||||
function for each. Thus, data is transferred from C++ variables to the dialog
|
||||
just as the dialog is being shown.
|
||||
|
||||
|
||||
If you are using a window or panel instead of a dialog, you will need to
|
||||
call wxWindow::InitDialog explicitly before showing the
|
||||
window.
|
||||
|
||||
|
||||
When the user clicks on a button, for example the OK button, the application should
|
||||
first call wxWindow::Validate, which returns @false if
|
||||
any of the child window validators failed to validate the window data. The button handler
|
||||
@@ -90,7 +90,7 @@
|
||||
or Show (if modeless).
|
||||
In fact, wxDialog contains a default command event handler for the wxID_OK button. It goes like
|
||||
this:
|
||||
|
||||
|
||||
@code
|
||||
void wxDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
@@ -106,12 +106,12 @@
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
|
||||
|
||||
So if using validators and a normal OK button, you may not even need to write any
|
||||
code for handling dialog dismissal.
|
||||
If you load your dialog from a resource file, you will need to iterate through the controls
|
||||
setting validators, since validators can't be specified in a dialog resource.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user