add an example of a custom wxValidator-derived class; cleanup a bit the dialog layout

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58566 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-01-31 21:21:08 +00:00
parent cbec0f401a
commit 2e7a6b030c
2 changed files with 114 additions and 23 deletions

View File

@@ -48,30 +48,55 @@ public:
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const long style = wxDEFAULT_DIALOG_STYLE);
bool TransferDataToWindow();
wxTextCtrl *text;
wxComboBox *combobox;
wxTextCtrl *m_text;
wxComboBox *m_combobox;
};
class MyData
{
public:
MyData();
// These data members are designed for transfer to and from
// controls, via validators. For instance, a text control's
// transferred value is a string:
wxString m_string;
// Listboxes may permit multiple selections, so their state
// is transferred to an integer-array class.
wxArrayInt m_listbox_choices;
bool m_checkbox_state;
// Comboboxes differ from listboxes--validators transfer
// the string entered in the combobox's text-edit field.
wxString m_combobox_choice;
bool m_checkbox_state;
int m_radiobox_choice;
};
enum {
class MyComboBoxValidator : public wxValidator
{
public:
MyComboBoxValidator(const MyComboBoxValidator& tocopy) { m_var=tocopy.m_var; }
MyComboBoxValidator(wxString* var) { m_var=var; }
virtual bool Validate(wxWindow* parent);
virtual wxObject* Clone() const { return new MyComboBoxValidator(*this); }
// Called to transfer data to the window
virtual bool TransferToWindow();
// Called to transfer data from the window
virtual bool TransferFromWindow();
protected:
wxString* m_var;
};
enum
{
VALIDATE_DIALOG_ID = wxID_HIGHEST,
VALIDATE_TEST_DIALOG,