]> git.saurik.com Git - wxWidgets.git/blob - samples/wizard/wiztest.cpp
wxWizard added
[wxWidgets.git] / samples / wizard / wiztest.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wiztest.cpp
3 // Purpose: wxWindows sample demonstrating wxWizard control
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 15.08.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "wiztest.cpp"
22 #pragma interface "wiztest.cpp"
23 #endif
24
25 // For compilers that support precompilation, includes "wx/wx.h".
26 #include "wx/wxprec.h"
27
28 #ifdef __BORLANDC__
29 #pragma hdrstop
30 #endif
31
32 // for all others, include the necessary headers (this file is usually all you
33 // need because it includes almost all "standard" wxWindows headers
34 #ifndef WX_PRECOMP
35 #include "wx/wx.h"
36 #endif
37
38 #include "wx/wizard.h"
39
40 #ifndef __WXMSW__
41 #include "wiztest.xpm"
42 #endif
43
44 // ----------------------------------------------------------------------------
45 // private classes
46 // ----------------------------------------------------------------------------
47
48 // Define a new application type, each program should derive a class from wxApp
49 class MyApp : public wxApp
50 {
51 public:
52 // override base class virtuals
53 virtual bool OnInit();
54 };
55
56 IMPLEMENT_APP(MyApp)
57
58 // ----------------------------------------------------------------------------
59 // some pages for our wizard
60 // ----------------------------------------------------------------------------
61
62 // this shows how to simply control the validity of the user input by just
63 // overriding TransferDataFromWindow() - of course, in a real program, the
64 // check wouldn't be so trivial and the data will be probably saved somewhere
65 // too
66 class wxCheckboxPage : public wxPanel
67 {
68 public:
69 wxCheckboxPage(wxWizard *parent) : wxPanel(parent)
70 {
71 m_checkbox = new wxCheckBox(this, -1, "Check me", wxPoint(20, 20));
72 }
73
74 virtual bool TransferDataFromWindow()
75 {
76 if ( m_checkbox->GetValue() )
77 {
78 wxMessageBox("Clear the checkbox first", "No way",
79 wxICON_WARNING | wxOK, this);
80
81 return FALSE;
82 }
83
84 return TRUE;
85 }
86
87 private:
88 wxCheckBox *m_checkbox;
89 };
90
91 // ============================================================================
92 // implementation
93 // ============================================================================
94
95 // ----------------------------------------------------------------------------
96 // the application class
97 // ----------------------------------------------------------------------------
98
99 // `Main program' equivalent: the program execution "starts" here
100 bool MyApp::OnInit()
101 {
102 #ifdef __WXMSW__
103 wxBitmap bmpWizard("wiztest.bmp", wxBITMAP_TYPE_BMP);
104 #else
105 wxBitmap bmpWizard(wizimage);
106 #endif
107
108 wxWizard *wizard = wxWizard::Create(NULL, -1,
109 "Absolutely Useless Wizard",
110 bmpWizard);
111
112 wxPanel *panel = new wxPanel(wizard);
113 (void)new wxStaticText(panel, -1,
114 "This wizard doesn't help you to do anything at "
115 "all.\n"
116 "\n"
117 "The next pages will present you with more useless "
118 "controls.");
119 wizard->AddPage(panel);
120
121 wizard->AddPage(new wxCheckboxPage(wizard));
122
123 if ( wizard->RunWizard() )
124 {
125 wxMessageBox("The wizard successfully completed", "That's all",
126 wxICON_INFORMATION | wxOK);
127 }
128
129 wizard->Destroy();
130
131 // we're done
132 return FALSE;
133 }