]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wizard.h
changed format of wxFontMapper entries: facename_encoding instead of encoding as key
[wxWidgets.git] / include / wx / wizard.h
CommitLineData
66cd017c
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wizard.h
3// Purpose: wxWizard class: a GUI control presenting the user with a
4// sequence of dialogs which allows to simply perform some task
5// Author: Vadim Zeitlin (partly based on work by Ron Kuris and Kevin B.
6// Smith)
7// Modified by:
8// Created: 15.08.99
9// RCS-ID: $Id$
10// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
11// Licence: wxWindows license
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_WIZARD_H_
15#define _WX_WIZARD_H_
16
b87654f3 17// ----------------------------------------------------------------------------
74b31181 18// headers and other simple declarations
b87654f3
VZ
19// ----------------------------------------------------------------------------
20
21#ifndef WX_PRECOMP
22 #include "wx/dialog.h" // the base class
23
24 #include "wx/event.h" // wxEVT_XXX constants
25#endif // WX_PRECOMP
26
74b31181
VZ
27// forward declarations
28class WXDLLEXPORT wxWizard;
29
30// ----------------------------------------------------------------------------
31// wxWizardPage is one of the wizards screen: it must know what are the
32// following and preceding pages (which may be NULL for the first/last page).
33//
34// Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
35// used as such (i.e. controls may be placed directly on it &c).
36// ----------------------------------------------------------------------------
37
38class WXDLLEXPORT wxWizardPage : public wxPanel
39{
40public:
41 // ctor: no other parameters are needed because the wizard will resize and
42 // reposition the page anyhow
43 wxWizardPage(wxWizard *parent);
44
45 // these functions are used by the wizard to show another page when the
46 // user chooses "Back" or "Next" button
47 virtual wxWizardPage *GetPrev() const = 0;
48 virtual wxWizardPage *GetNext() const = 0;
49
50private:
51 DECLARE_ABSTRACT_CLASS(wxWizardPage)
52};
53
54// ----------------------------------------------------------------------------
55// wxWizardPageSimple just returns the pointers given to the ctor and is useful
56// to create a simple wizard where the order of pages never changes.
57//
58// OTOH, it is also possible to dynamicly decide which page to return (i.e.
59// depending on the user's choices) as the wizard sample shows - in order to do
60// this, you must derive from wxWizardPage directly.
61// ----------------------------------------------------------------------------
62
63class WXDLLEXPORT wxWizardPageSimple : public wxWizardPage
64{
65public:
66 // ctor takes the previous and next pages
67 wxWizardPageSimple(wxWizard *parent = NULL, // let it be default ctor too
68 wxWizardPage *prev = (wxWizardPage *)NULL,
69 wxWizardPage *next = (wxWizardPage *)NULL)
70 : wxWizardPage(parent)
71 {
72 m_prev = prev;
73 m_next = next;
74 }
75
76 // the pointers may be also set later - but before starting the wizard
77 void SetPrev(wxWizardPage *prev) { m_prev = prev; }
78 void SetNext(wxWizardPage *next) { m_next = next; }
79
80 // a convenience function to make the pages follow each other
81 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second)
82 {
83 wxCHECK_RET( first && second,
223d09f6 84 wxT("NULL passed to wxWizardPageSimple::Chain") );
74b31181
VZ
85
86 first->SetNext(second);
87 second->SetPrev(first);
88 }
89
90 // base class pure virtuals
91 virtual wxWizardPage *GetPrev() const;
92 virtual wxWizardPage *GetNext() const;
93
94private:
95 // pointers are private, the derived classes shouldn't mess with them -
96 // just derive from wxWizardPage directly to implement different behaviour
97 wxWizardPage *m_prev,
98 *m_next;
99
100 DECLARE_DYNAMIC_CLASS(wxWizardPageSimple)
101};
102
66cd017c
VZ
103// ----------------------------------------------------------------------------
104// wxWizard
105// ----------------------------------------------------------------------------
106
74b31181 107class WXDLLEXPORT wxWizardBase : public wxDialog
66cd017c
VZ
108{
109public:
110 // create the wizard control
111 static wxWizard *Create(wxWindow *parent,
112 int id = -1,
113 const wxString& title = wxEmptyString,
114 const wxBitmap& bitmap = wxNullBitmap,
115 const wxPoint& pos = wxDefaultPosition,
116 const wxSize& size = wxDefaultSize);
117
74b31181
VZ
118 // executes the wizard starting from the given page, returns TRUE if it was
119 // successfully finished, FALSE if user cancelled it
120 virtual bool RunWizard(wxWizardPage *firstPage) = 0;
66cd017c
VZ
121
122 // get the current page (NULL if RunWizard() isn't running)
74b31181 123 virtual wxWizardPage *GetCurrentPage() const = 0;
4fe5383d
VZ
124
125 // get the size available for the page: the wizards are not resizeable, so
126 // this size doesn't change
127 virtual wxSize GetPageSize() const = 0;
66cd017c
VZ
128};
129
74b31181
VZ
130// include the real class declaration
131#include "wx/generic/wizard.h"
132
66cd017c 133// ----------------------------------------------------------------------------
74b31181
VZ
134// wxWizardEvent class represents an event generated by the wizard: this event
135// is first sent to the page itself and, if not processed there, goes up the
136// window hierarchy as usual
66cd017c
VZ
137// ----------------------------------------------------------------------------
138
139class WXDLLEXPORT wxWizardEvent : public wxNotifyEvent
140{
141public:
74b31181
VZ
142 wxWizardEvent(wxEventType type = wxEVT_NULL,
143 int id = -1,
144 bool direction = TRUE);
66cd017c 145
74b31181
VZ
146 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
147 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
148 // from the previous page and FALSE if we returned from the next one
149 // (this function doesn't make sense for CANCEL events)
150 bool GetDirection() const { return m_direction; }
66cd017c
VZ
151
152private:
74b31181 153 bool m_direction;
66cd017c
VZ
154
155 DECLARE_DYNAMIC_CLASS(wxWizardEvent)
156};
157
158// ----------------------------------------------------------------------------
159// macros for handling wxWizardEvents
160// ----------------------------------------------------------------------------
161
162typedef void (wxEvtHandler::*wxWizardEventFunction)(wxWizardEvent&);
163
74b31181 164// notifies that the page has just been changed (can't be vetoed)
66cd017c
VZ
165#define EVT_WIZARD_PAGE_CHANGED(id, fn) { wxEVT_WIZARD_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL },
166
167// the user pressed "<Back" or "Next>" button and the page is going to be
168// changed - unless the event handler vetoes the event
169#define EVT_WIZARD_PAGE_CHANGING(id, fn) { wxEVT_WIZARD_PAGE_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL },
170
171// the user pressed "Cancel" button and the wizard is going to be dismissed -
172// unless the event handler vetoes the event
173#define EVT_WIZARD_CANCEL(id, fn) { wxEVT_WIZARD_CANCEL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL },
174
175#endif // _WX_WIZARD_H_