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.4 1998/12/20 09:14:48 robertj
31 * Added pragma implementation for GNU compiler.
33 * Revision 1.3 1998/11/30 04:52:21 robertj
34 * New directory structure
36 * Revision 1.2 1998/09/23 06:29:59 robertj
37 * Added open source copyright license.
39 * Revision 1.1 1998/09/15 11:47:20 robertj
45 #pragma implementation "wizard.h"
49 #include <pwclib/wizard.h>
54 //////////////////////////////////////////////////////////////////////////////
57 PWizardPage::PWizardPage(PInteractor
* parent
, PRESOURCE_ID resID
)
58 : PInteractorLayout(parent
, resID
)
60 SetBackgroundColour(owner
->GetButtonBkColour());
61 pageIdentifier
= resID
;
65 void PWizardPage::OnInitialisePage()
70 void PWizardPage::OnCompletedPages()
75 void PWizardPage::OnEnteringPage()
80 BOOL
PWizardPage::OnLeavingPage()
86 BOOL
PWizardPage::IsFinalPage() const
92 PRESOURCE_ID
PWizardPage::GetNextPage() const
94 return 0; // Next page as in AddPage() sequence.
98 //////////////////////////////////////////////////////////////////////////////
101 PWizardFrame::PWizardFrame(PInteractor
* parent
, PRESOURCE_ID resID
)
102 : PInteractorLayout(parent
, resID
),
103 originalSize(GetDimensions(PixelCoords
))
105 pages
.DisallowDeleteObjects();
106 SetBackgroundColour(owner
->GetButtonBkColour());
108 back
= next
= abort
= finish
= NULL
;
112 void PWizardFrame::ConstructEnd(PRESOURCE_ID resID
)
114 PInteractorLayout::ConstructEnd(resID
);
116 PDim dim
= GetDimensions(PixelCoords
);
117 PDim offset
= dim
- originalSize
;
118 dim
.SetHeight(offset
.Height());
121 for (idx
= 0; idx
< children
.GetSize(); idx
++) {
122 PInteractor
& child
= children
[idx
];
124 if (child
.IsDescendant(PWizardPage::Class())) {
125 if (&child
!= currentPage
)
127 child
.SetDimensions(dim
, PixelCoords
);
128 PWizardPage
& page
= (PWizardPage
&)child
;
129 page
.OnInitialisePage();
130 page
.UpdateControls();
133 child
.SetPosition(child
.GetPosition(PixelCoords
)+offset
, TopLeftPixels
, TopLeftPixels
);
146 void PWizardFrame::AddPage(PWizardPage
* page
)
148 if (currentPage
== NULL
)
151 pages
.SetAt(page
->GetIdentifier(), page
);
153 PDim wiz_dim
= GetDimensions(PixelCoords
);
154 wiz_dim
.AddHeight(-(int)originalSize
.Height());
156 PDim page_dim
= page
->GetDimensions(PixelCoords
);
158 if (page_dim
.Width() > wiz_dim
.Width())
159 wiz_dim
.SetWidth(page_dim
.Width());
161 if (page_dim
.Height() > wiz_dim
.Height())
162 wiz_dim
.SetHeight(page_dim
.Height());
164 wiz_dim
.AddHeight(originalSize
.Height());
166 SetDimensions(wiz_dim
, PixelCoords
);
170 void PWizardFrame::Back(class PTextButton
&, int)
172 if (pageStack
.IsEmpty())
175 PAssert(currentPage
!= NULL
, PLogicError
);
178 currentPage
= pageStack
.Pop();
181 if (back
!= NULL
&& pageStack
.IsEmpty())
192 void PWizardFrame::Next(class PTextButton
&, int)
194 PAssert(currentPage
!= NULL
, PLogicError
);
195 SetCurrentPage(currentPage
->GetNextPage());
199 void PWizardFrame::Abort(class PTextButton
&, int)
205 void PWizardFrame::Finish(class PTextButton
&, int)
207 if (currentPage
->OnLeavingPage())
212 void PWizardFrame::OnFinished(BOOL aborted
)
216 for (idx
= 0; idx
< pages
.GetSize(); idx
++)
217 pages
.GetDataAt(idx
).OnCompletedPages();
220 if (parent
->IsDescendant(PDialog::Class()))
221 ((PDialog
*)parent
)->Close();
222 else if (parent
->IsDescendant(PTitledWindow::Class()))
223 ((PTitledWindow
*)parent
)->Close();
227 BOOL
PWizardFrame::SetCurrentPage(PRESOURCE_ID nextId
)
229 PAssert(currentPage
!= NULL
, PLogicError
);
231 if (currentPage
->GetIdentifier() == nextId
)
234 if (!currentPage
->OnLeavingPage())
237 PWizardPage
* nextPage
= NULL
;
240 nextPage
= pages
.GetAt(nextId
);
242 PINDEX idx
= children
.GetObjectsIndex(currentPage
);
243 if (idx
!= P_MAX_INDEX
) {
244 while (++idx
< children
.GetSize()) {
245 if (children
[idx
].IsDescendant(PWizardPage::Class())) {
246 nextPage
= (PWizardPage
*)&children
[idx
];
253 if (nextPage
== NULL
)
256 pageStack
.Push(currentPage
);
258 currentPage
= nextPage
;
259 currentPage
->OnEnteringPage();
265 if (!currentPage
->IsFinalPage())
277 //////////////////////////////////////////////////////////////////////////////
280 PWizardDialog::PWizardDialog(PInteractor
* parent
, PWizardFrame
* frame
)
281 : PModalDialog(parent
)
283 SetDimensions(frame
->GetDimensions(PixelCoords
), PixelCoords
);
287 // End Of File ///////////////////////////////////////////////////////////////