X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6aa89a22b8e47000c98bff05c6f545f331f1c353..22015a02243ed14bab25961a28cc3a5f4dcfb0c5:/samples/validate/validate.h diff --git a/samples/validate/validate.h b/samples/validate/validate.h index 3a59f7bb63..9f723097cb 100644 --- a/samples/validate/validate.h +++ b/samples/validate/validate.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: validate.h -// Purpose: wxWindows validation sample +// Purpose: wxWidgets validation sample // Author: Julian Smart // Modified by: // Created: 04/01/98 @@ -9,10 +9,6 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -# pragma interface -#endif - #include "wx/app.h" #include "wx/combobox.h" #include "wx/dialog.h" @@ -32,7 +28,7 @@ public: class MyFrame : public wxFrame { public: - MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h); + MyFrame(wxFrame *frame, const wxString&title, int x, int y, int w, int h); void OnQuit(wxCommandEvent& event); void OnTestDialog(wxCommandEvent& event); @@ -52,37 +48,64 @@ 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; + wxString m_string, m_string2; + // 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; }; -#define VALIDATE_DIALOG_ID 200 +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(); -#define VALIDATE_TEST_DIALOG 2 -#define VALIDATE_TOGGLE_BELL 3 +protected: + wxString* m_var; +}; + +enum +{ + VALIDATE_DIALOG_ID = wxID_HIGHEST, -#define VALIDATE_TEXT 101 -#define VALIDATE_LIST 102 -#define VALIDATE_CHECK 103 -#define VALIDATE_COMBO 105 -#define VALIDATE_RADIO 106 + VALIDATE_TEST_DIALOG, + VALIDATE_TOGGLE_BELL, + VALIDATE_TEXT, + VALIDATE_TEXT2, + VALIDATE_LIST, + VALIDATE_CHECK, + VALIDATE_COMBO, + VALIDATE_RADIO +};