4 * Wizard dialog classes.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
30 * Revision 1.5 2004/04/04 13:24:23 rjongbloed
31 * Changes to support native C++ Run Time Type Information
33 * Revision 1.4 1998/12/20 09:14:48 robertj
34 * Added pragma implementation for GNU compiler.
36 * Revision 1.3 1998/11/30 04:52:21 robertj
37 * New directory structure
39 * Revision 1.2 1998/09/23 06:29:59 robertj
40 * Added open source copyright license.
42 * Revision 1.1 1998/09/15 11:47:20 robertj
48 #pragma implementation "wizard.h"
52 #include <pwclib/wizard.h>
57 //////////////////////////////////////////////////////////////////////////////
60 PWizardPage::PWizardPage(PInteractor
* parent
, PRESOURCE_ID resID
)
61 : PInteractorLayout(parent
, resID
)
63 SetBackgroundColour(owner
->GetButtonBkColour());
64 pageIdentifier
= resID
;
68 void PWizardPage::OnInitialisePage()
73 void PWizardPage::OnCompletedPages()
78 void PWizardPage::OnEnteringPage()
83 BOOL
PWizardPage::OnLeavingPage()
89 BOOL
PWizardPage::IsFinalPage() const
95 PRESOURCE_ID
PWizardPage::GetNextPage() const
97 return 0; // Next page as in AddPage() sequence.
101 //////////////////////////////////////////////////////////////////////////////
104 PWizardFrame::PWizardFrame(PInteractor
* parent
, PRESOURCE_ID resID
)
105 : PInteractorLayout(parent
, resID
),
106 originalSize(GetDimensions(PixelCoords
))
108 pages
.DisallowDeleteObjects();
109 SetBackgroundColour(owner
->GetButtonBkColour());
111 back
= next
= abort
= finish
= NULL
;
115 void PWizardFrame::ConstructEnd(PRESOURCE_ID resID
)
117 PInteractorLayout::ConstructEnd(resID
);
119 PDim dim
= GetDimensions(PixelCoords
);
120 PDim offset
= dim
- originalSize
;
121 dim
.SetHeight(offset
.Height());
124 for (idx
= 0; idx
< children
.GetSize(); idx
++) {
125 PInteractor
& child
= children
[idx
];
127 if (PIsDescendant(&child
, PWizardPage
)) {
128 if (&child
!= currentPage
)
130 child
.SetDimensions(dim
, PixelCoords
);
131 PWizardPage
& page
= (PWizardPage
&)child
;
132 page
.OnInitialisePage();
133 page
.UpdateControls();
136 child
.SetPosition(child
.GetPosition(PixelCoords
)+offset
, TopLeftPixels
, TopLeftPixels
);
149 void PWizardFrame::AddPage(PWizardPage
* page
)
151 if (currentPage
== NULL
)
154 pages
.SetAt(page
->GetIdentifier(), page
);
156 PDim wiz_dim
= GetDimensions(PixelCoords
);
157 wiz_dim
.AddHeight(-(int)originalSize
.Height());
159 PDim page_dim
= page
->GetDimensions(PixelCoords
);
161 if (page_dim
.Width() > wiz_dim
.Width())
162 wiz_dim
.SetWidth(page_dim
.Width());
164 if (page_dim
.Height() > wiz_dim
.Height())
165 wiz_dim
.SetHeight(page_dim
.Height());
167 wiz_dim
.AddHeight(originalSize
.Height());
169 SetDimensions(wiz_dim
, PixelCoords
);
173 void PWizardFrame::Back(class PTextButton
&, int)
175 if (pageStack
.IsEmpty())
178 PAssert(currentPage
!= NULL
, PLogicError
);
181 currentPage
= pageStack
.Pop();
184 if (back
!= NULL
&& pageStack
.IsEmpty())
195 void PWizardFrame::Next(class PTextButton
&, int)
197 PAssert(currentPage
!= NULL
, PLogicError
);
198 SetCurrentPage(currentPage
->GetNextPage());
202 void PWizardFrame::Abort(class PTextButton
&, int)
208 void PWizardFrame::Finish(class PTextButton
&, int)
210 if (currentPage
->OnLeavingPage())
215 void PWizardFrame::OnFinished(BOOL aborted
)
219 for (idx
= 0; idx
< pages
.GetSize(); idx
++)
220 pages
.GetDataAt(idx
).OnCompletedPages();
223 if (PIsDescendant(parent
, PDialog
))
224 ((PDialog
*)parent
)->Close();
225 else if (PIsDescendant(parent
, PTitledWindow
))
226 ((PTitledWindow
*)parent
)->Close();
230 BOOL
PWizardFrame::SetCurrentPage(PRESOURCE_ID nextId
)
232 PAssert(currentPage
!= NULL
, PLogicError
);
234 if (currentPage
->GetIdentifier() == nextId
)
237 if (!currentPage
->OnLeavingPage())
240 PWizardPage
* nextPage
= NULL
;
243 nextPage
= pages
.GetAt(nextId
);
245 PINDEX idx
= children
.GetObjectsIndex(currentPage
);
246 if (idx
!= P_MAX_INDEX
) {
247 while (++idx
< children
.GetSize()) {
248 if (PIsDescendant(&children
[idx
], PWizardPage
)) {
249 nextPage
= (PWizardPage
*)&children
[idx
];
256 if (nextPage
== NULL
)
259 pageStack
.Push(currentPage
);
261 currentPage
= nextPage
;
262 currentPage
->OnEnteringPage();
268 if (!currentPage
->IsFinalPage())
280 //////////////////////////////////////////////////////////////////////////////
283 PWizardDialog::PWizardDialog(PInteractor
* parent
, PWizardFrame
* frame
)
284 : PModalDialog(parent
)
286 SetDimensions(frame
->GetDimensions(PixelCoords
), PixelCoords
);
290 // End Of File ///////////////////////////////////////////////////////////////