]> git.saurik.com Git - wxWidgets.git/blame - samples/validate/validate.h
Initialize wxImageFileProperty correctly when file is given in the ctor.
[wxWidgets.git] / samples / validate / validate.h
CommitLineData
457814b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: validate.h
be5a51fb 3// Purpose: wxWidgets validation sample
457814b5
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
6aa89a22 7// Copyright: (c) Julian Smart
526954c5 8// Licence: wxWindows licence
457814b5
JS
9/////////////////////////////////////////////////////////////////////////////
10
2b61c41b
VZ
11#include "wx/app.h"
12#include "wx/combobox.h"
13#include "wx/dialog.h"
14#include "wx/dynarray.h"
15#include "wx/frame.h"
16#include "wx/listbox.h"
17#include "wx/string.h"
18
457814b5 19// Define a new application type
a994f81b
VZ
20class MyApp : public wxApp
21{
22public:
23 bool OnInit();
457814b5
JS
24};
25
26// Define a new frame type
a994f81b
VZ
27class MyFrame : public wxFrame
28{
29public:
7df07b10 30 MyFrame(wxFrame *frame, const wxString&title, int x, int y, int w, int h);
a994f81b 31
457814b5
JS
32 void OnQuit(wxCommandEvent& event);
33 void OnTestDialog(wxCommandEvent& event);
2b61c41b
VZ
34 void OnToggleBell(wxCommandEvent& event);
35
36private:
37 wxListBox *m_listbox;
38 bool m_silent;
457814b5 39
a994f81b 40 DECLARE_EVENT_TABLE()
457814b5
JS
41};
42
a994f81b 43class MyDialog : public wxDialog
457814b5
JS
44{
45public:
2b61c41b
VZ
46 MyDialog(wxWindow *parent, const wxString& title,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
a994f81b 49 const long style = wxDEFAULT_DIALOG_STYLE);
2e7a6b03 50
2b61c41b 51 bool TransferDataToWindow();
2e7a6b03
FM
52 wxTextCtrl *m_text;
53 wxComboBox *m_combobox;
a54cf371
VZ
54
55 wxTextCtrl *m_numericTextInt;
56 wxTextCtrl *m_numericTextDouble;
457814b5
JS
57};
58
59class MyData
60{
a994f81b 61public:
2b61c41b 62 MyData();
2e7a6b03 63
2b61c41b
VZ
64 // These data members are designed for transfer to and from
65 // controls, via validators. For instance, a text control's
66 // transferred value is a string:
fcd209b6 67 wxString m_string, m_string2;
2e7a6b03 68
2b61c41b
VZ
69 // Listboxes may permit multiple selections, so their state
70 // is transferred to an integer-array class.
71 wxArrayInt m_listbox_choices;
2e7a6b03 72
2b61c41b
VZ
73 // Comboboxes differ from listboxes--validators transfer
74 // the string entered in the combobox's text-edit field.
75 wxString m_combobox_choice;
2e7a6b03 76
a54cf371
VZ
77 // variables handled by wxNumericTextValidator
78 int m_intValue;
79 double m_doubleValue;
80
2e7a6b03 81 bool m_checkbox_state;
2b61c41b 82 int m_radiobox_choice;
457814b5
JS
83};
84
2e7a6b03
FM
85class MyComboBoxValidator : public wxValidator
86{
87public:
88 MyComboBoxValidator(const MyComboBoxValidator& tocopy) { m_var=tocopy.m_var; }
89 MyComboBoxValidator(wxString* var) { m_var=var; }
90
91 virtual bool Validate(wxWindow* parent);
92 virtual wxObject* Clone() const { return new MyComboBoxValidator(*this); }
93
94 // Called to transfer data to the window
95 virtual bool TransferToWindow();
96
97 // Called to transfer data from the window
98 virtual bool TransferFromWindow();
99
100protected:
101 wxString* m_var;
102};
103
104enum
105{
0bcd4039 106 VALIDATE_DIALOG_ID = wxID_HIGHEST,
457814b5 107
0bcd4039
WS
108 VALIDATE_TEST_DIALOG,
109 VALIDATE_TOGGLE_BELL,
457814b5 110
0bcd4039 111 VALIDATE_TEXT,
fcd209b6 112 VALIDATE_TEXT2,
0bcd4039
WS
113 VALIDATE_LIST,
114 VALIDATE_CHECK,
115 VALIDATE_COMBO,
116 VALIDATE_RADIO
117};