]> git.saurik.com Git - wxWidgets.git/blob - samples/wizard/wiztest.cpp
wxWizard draft
[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 // ----------------------------------------------------------------------------
41 // private classes
42 // ----------------------------------------------------------------------------
43
44 // Define a new application type, each program should derive a class from wxApp
45 class MyApp : public wxApp
46 {
47 public:
48 // override base class virtuals
49 virtual bool OnInit();
50 };
51
52 IMPLEMENT_APP(MyApp)
53
54 // ----------------------------------------------------------------------------
55 // some pages for our wizard
56 // ----------------------------------------------------------------------------
57
58 // this shows how to simply control the validity of the user input by just
59 // overriding TransferDataFromWindow() - of course, in a real program, the
60 // check wouldn't be so trivial and the data will be probably saved somewhere
61 // too
62 class wxCheckboxPage : public wxPanel
63 {
64 public:
65 wxCheckboxPage(wxWizard *parent) : wxPanel(parent)
66 {
67 m_checkbox = new wxCheckBox(this, -1, "Check me", wxPoint(20, 20));
68 }
69
70 virtual bool TransferDataFromWindow()
71 {
72 if ( m_checkbox->GetValue() )
73 {
74 wxMessageBox("Clear the checkbox first", "No way",
75 wxICON_WARNING, this);
76
77 return FALSE;
78 }
79
80 return TRUE;
81 }
82
83 private:
84 wxCheckBox *m_checkbox;
85 };
86
87 // ============================================================================
88 // implementation
89 // ============================================================================
90
91 // ----------------------------------------------------------------------------
92 // the application class
93 // ----------------------------------------------------------------------------
94
95 // `Main program' equivalent: the program execution "starts" here
96 bool MyApp::OnInit()
97 {
98 wxBitmap bmpWizard("wiztest.bmp", wxBITMAP_TYPE_BMP);
99
100 wxWizard *wizard = wxWizard::Create(NULL, -1,
101 "Absolutely Useless Wizard",
102 bmpWizard);
103
104 wxPanel *panel = new wxPanel(wizard);
105 (void)new wxStaticText(panel, -1,
106 "This wizard doesn't help you to do anything at "
107 "all.\n"
108 "\n"
109 "The next pages will present you with more useless "
110 "controls.");
111 wizard->AddPage(panel);
112
113 wizard->AddPage(new wxCheckboxPage(wizard));
114
115 if ( wizard->RunWizard() )
116 {
117 wxMessageBox("The wizard successfully completed", "That's all",
118 wxICON_INFORMATION);
119 }
120
121 wizard->Destroy();
122
123 // we're done
124 return FALSE;
125 }