X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3996031094e28a6936ca1df2d289c9d3baecb27d..33d8353fa58dbc66fc9d22fcd510ded6b26ce719:/samples/validate/validate.h diff --git a/samples/validate/validate.h b/samples/validate/validate.h index 864a926b2f..beb50de15d 100644 --- a/samples/validate/validate.h +++ b/samples/validate/validate.h @@ -1,17 +1,21 @@ ///////////////////////////////////////////////////////////////////////////// // Name: validate.h -// Purpose: wxWindows validation sample +// Purpose: wxWidgets validation sample // Author: Julian Smart // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -// #pragma interface -#endif +#include "wx/app.h" +#include "wx/combobox.h" +#include "wx/dialog.h" +#include "wx/dynarray.h" +#include "wx/frame.h" +#include "wx/listbox.h" +#include "wx/string.h" // Define a new application type class MyApp : public wxApp @@ -24,11 +28,15 @@ public: class MyFrame : public wxFrame { public: - MyFrame(wxFrame *frame, const wxChar *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); - void OnSilent(wxCommandEvent& event); + void OnToggleBell(wxCommandEvent& event); + +private: + wxListBox *m_listbox; + bool m_silent; DECLARE_EVENT_TABLE() }; @@ -36,21 +44,75 @@ public: class MyDialog : public wxDialog { public: - MyDialog(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, + MyDialog(wxWindow *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, const long style = wxDEFAULT_DIALOG_STYLE); + + bool TransferDataToWindow(); + wxTextCtrl *m_text; + wxComboBox *m_combobox; + + wxTextCtrl *m_numericTextInt; + wxTextCtrl *m_numericTextDouble; }; class MyData { public: - wxString m_string; + 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, m_string2; + + // Listboxes may permit multiple selections, so their state + // is transferred to an integer-array class. + wxArrayInt m_listbox_choices; - MyData() { m_string = _T("My string"); } + // Comboboxes differ from listboxes--validators transfer + // the string entered in the combobox's text-edit field. + wxString m_combobox_choice; + + // variables handled by wxNumericTextValidator + int m_intValue; + double m_doubleValue; + + 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; } -#define VALIDATE_TEST_DIALOG 2 -#define VALIDATE_SILENT 3 -#define VALIDATE_TEXT 101 + 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, + VALIDATE_TOGGLE_BELL, + + VALIDATE_TEXT, + VALIDATE_TEXT2, + VALIDATE_LIST, + VALIDATE_CHECK, + VALIDATE_COMBO, + VALIDATE_RADIO +};