]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/validate/validate.h
Correct the name of the XPM file containing the icon in xrc sample.
[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// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/app.h"
13#include "wx/combobox.h"
14#include "wx/dialog.h"
15#include "wx/dynarray.h"
16#include "wx/frame.h"
17#include "wx/listbox.h"
18#include "wx/string.h"
19
20// Define a new application type
21class MyApp : public wxApp
22{
23public:
24 bool OnInit();
25};
26
27// Define a new frame type
28class MyFrame : public wxFrame
29{
30public:
31 MyFrame(wxFrame *frame, const wxString&title, int x, int y, int w, int h);
32
33 void OnQuit(wxCommandEvent& event);
34 void OnTestDialog(wxCommandEvent& event);
35 void OnToggleBell(wxCommandEvent& event);
36
37private:
38 wxListBox *m_listbox;
39 bool m_silent;
40
41 DECLARE_EVENT_TABLE()
42};
43
44class MyDialog : public wxDialog
45{
46public:
47 MyDialog(wxWindow *parent, const wxString& title,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 const long style = wxDEFAULT_DIALOG_STYLE);
51
52 bool TransferDataToWindow();
53 wxTextCtrl *m_text;
54 wxComboBox *m_combobox;
55};
56
57class MyData
58{
59public:
60 MyData();
61
62 // These data members are designed for transfer to and from
63 // controls, via validators. For instance, a text control's
64 // transferred value is a string:
65 wxString m_string, m_string2;
66
67 // Listboxes may permit multiple selections, so their state
68 // is transferred to an integer-array class.
69 wxArrayInt m_listbox_choices;
70
71 // Comboboxes differ from listboxes--validators transfer
72 // the string entered in the combobox's text-edit field.
73 wxString m_combobox_choice;
74
75 bool m_checkbox_state;
76 int m_radiobox_choice;
77};
78
79class MyComboBoxValidator : public wxValidator
80{
81public:
82 MyComboBoxValidator(const MyComboBoxValidator& tocopy) { m_var=tocopy.m_var; }
83 MyComboBoxValidator(wxString* var) { m_var=var; }
84
85 virtual bool Validate(wxWindow* parent);
86 virtual wxObject* Clone() const { return new MyComboBoxValidator(*this); }
87
88 // Called to transfer data to the window
89 virtual bool TransferToWindow();
90
91 // Called to transfer data from the window
92 virtual bool TransferFromWindow();
93
94protected:
95 wxString* m_var;
96};
97
98enum
99{
100 VALIDATE_DIALOG_ID = wxID_HIGHEST,
101
102 VALIDATE_TEST_DIALOG,
103 VALIDATE_TOGGLE_BELL,
104
105 VALIDATE_TEXT,
106 VALIDATE_TEXT2,
107 VALIDATE_LIST,
108 VALIDATE_CHECK,
109 VALIDATE_COMBO,
110 VALIDATE_RADIO
111};