]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/validate/validate.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / samples / validate / validate.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: validate.h
3// Purpose: wxWidgets validation sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// Copyright: (c) Julian Smart
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
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
19// Define a new application type
20class MyApp : public wxApp
21{
22public:
23 bool OnInit();
24};
25
26// Define a new frame type
27class MyFrame : public wxFrame
28{
29public:
30 MyFrame(wxFrame *frame, const wxString&title, int x, int y, int w, int h);
31
32 void OnQuit(wxCommandEvent& event);
33 void OnTestDialog(wxCommandEvent& event);
34 void OnToggleBell(wxCommandEvent& event);
35
36private:
37 wxListBox *m_listbox;
38 bool m_silent;
39
40 DECLARE_EVENT_TABLE()
41};
42
43class MyDialog : public wxDialog
44{
45public:
46 MyDialog(wxWindow *parent, const wxString& title,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 const long style = wxDEFAULT_DIALOG_STYLE);
50
51 bool TransferDataToWindow();
52 wxTextCtrl *m_text;
53 wxComboBox *m_combobox;
54
55 wxTextCtrl *m_numericTextInt;
56 wxTextCtrl *m_numericTextDouble;
57};
58
59class MyData
60{
61public:
62 MyData();
63
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:
67 wxString m_string, m_string2;
68
69 // Listboxes may permit multiple selections, so their state
70 // is transferred to an integer-array class.
71 wxArrayInt m_listbox_choices;
72
73 // Comboboxes differ from listboxes--validators transfer
74 // the string entered in the combobox's text-edit field.
75 wxString m_combobox_choice;
76
77 // variables handled by wxNumericTextValidator
78 int m_intValue;
79 double m_doubleValue;
80
81 bool m_checkbox_state;
82 int m_radiobox_choice;
83};
84
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{
106 VALIDATE_DIALOG_ID = wxID_HIGHEST,
107
108 VALIDATE_TEST_DIALOG,
109 VALIDATE_TOGGLE_BELL,
110
111 VALIDATE_TEXT,
112 VALIDATE_TEXT2,
113 VALIDATE_LIST,
114 VALIDATE_CHECK,
115 VALIDATE_COMBO,
116 VALIDATE_RADIO
117};