wizard.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:12k
- /*
- * wizard.h
- *
- * Wizard Interactor GUI classes
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: wizard.h,v $
- * Revision 1.3 1999/03/09 08:01:47 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.2 1998/09/23 06:20:13 robertj
- * Added open source copyright license.
- *
- * Revision 1.1 1998/09/15 11:47:22 robertj
- * Initial revision
- *
- */
- #ifndef _WIZARD_H
- #define _WIZARD_H
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PWizardFrame;
- /**An interactor layout that is used within a PWizardFrame class. There is one
- descendant of PWizardPage for each page in the wizard sequence.
- This contitutes the pages contained within the frame. There are 1 or more
- of these pages in a PWizardFrame that are sequentially displayed until a
- "final" page, which then terminates the wizard.
- */
- class PWizardPage : public PInteractorLayout
- {
- PCLASSINFO(PWizardPage, PInteractorLayout);
-
- public:
- /**@name Construction */
- //@{
- /**Create a new empty layout. There are no controls contained within the
- layout and it is expected that these are to added manually by the
- application.
- */
- PWizardPage(
- PInteractor * parent /// Interactor (PWizardFrame) that owns the page.
- );
- /**Create a new layout by loading it from a resource. The resource
- description determines the position, dimensions of the layout as well
- as the position, dimensions, title and other options for all of the
- controls in the layout.
- */
- PWizardPage(
- PInteractor * parent, /// Interactor (PWizardFrame) that owns the page.
- PRESOURCE_ID resID /// Resource identifier for loading controls.
- );
- //@}
- /**@name New functions for class */
- //@{
- /**Get the unique identifier for the page. This defaults to the resource
- ID used to load the layout.
-
- @return
- identifier for page.
- */
- PRESOURCE_ID GetIdentifier() const { return pageIdentifier; }
- /**Get the parent PWizardFrame for the page.
-
- @return
- reference to wizard frame.
- */
- PWizardFrame & GetFrame() const { return *(PWizardFrame *)GetParent(); }
- /**This callback is executed when the PWizardFrame loads the page. It is
- typically only called once per load of the PWizardFrame.
- The usual behaviour is to initialise the dialog member variables to
- values saved in non-volatile storage.
- The default function does nothing.
- */
- virtual void OnInitialisePage();
- /**This callback is executed when the PWizardFrame completes, that is, the
- "Finished" button has been pressed. It is typically only called once per
- run of the PWizardFrame.
- The usual behaviour is to save the dialog member variables to
- non-volatile storage.
- The default function does nothing.
- */
- virtual void OnCompletedPages();
- /**This callback is executed when the PWizardFrame displays the page. This
- may happen multiple times as the user goes forward and backward through
- the page sequence.
- The default function does nothing.
- */
- virtual void OnEnteringPage();
- /**This callback is executed when the PWizardFrame is abbout to display
- another page. This may happen multiple times as the user goes forward
- and backward through the page sequence.
- The usual behaviour is to validate any fields on the page. A value of
- FALSE may be returned to prevent the PWizardFrame from moving to the
- new page.
- The default function does nothing and returns TRUE.
-
- @return
- TRUE if allowed to move on.
- */
- virtual BOOL OnLeavingPage();
- /**This function indicates that this is the final page in the sequence
- used by the PWizardFrame. The PWizardFrame then displays the "Finish"
- button instead of the "Next" button.
- The default function does nothing and returns FALSE.
-
- @return
- TRUE if final page.
- */
- virtual BOOL IsFinalPage() const;
- /**This function indicates the next page in the sequence used by the
- PWizardFrame. This allows different paths to be taken through the
- sequence depending on information entered in this (and other) pages.
- The default function returns zero, indicating that the next page that
- was added to the PWizardFrame is to be used.
-
- @return
- identifier of page to display next.
- */
- virtual PRESOURCE_ID GetNextPage() const;
- //@}
- protected:
- /// Unique ID for page
- PRESOURCE_ID pageIdentifier;
- };
- PDICTIONARY(PWizardPageDict, POrdinalKey, PWizardPage);
- PSTACK(PWizardPageStack, PWizardPage);
- /**An interactor layout that is used to manage a series of pages for the
- gathering of complex information. A single instance of a descendant of
- this class is used to frame a series of PWizardPage descendant layouts.
- It is expected that this layout would be contained within a dialog or main
- window of an application. A resource may be used to define the basics of
- the wizard frame and then the final sizes are adhusted by the AddPage() and
- ConstructEnd() functions to deliver a final layout.
- A typical resource would look like:
- Layout {
- Class MainWizard : PWizardFrame;
- PushButton { Pos 10, 10; Dim 45, 15; Title "< &Back"; Field PWizardFrame::back; Notify PWizardFrame::Back; }
- PushButton { Pos 55, 10; Dim 45, 15; Title "&Next >"; Field PWizardFrame::next; Notify PWizardFrame::Next; Options default; }
- PushButton { Pos 55, 10; Dim 45, 15; Title "&Finish"; Field PWizardFrame::finish; Notify PWizardFrame::Finish; }
- PushButton { Pos 110, 10; Dim 45, 15; Title "Cancel"; Field PWizardFrame::abort; Notify PWizardFrame::Abort; }
- #inline hdr
- void ConstructEnd(PRESOURCE_ID);
- #inline end
- }
- It is usual for the ConstructEnd() function to be overidden and the
- AddPage() function called for each PWizardPage needed. The ancestor
- ConstructEnd() function MUST be called after all of the AddPage() calls.
- */
- class PWizardFrame : public PInteractorLayout
- {
- PCLASSINFO(PWizardFrame, PInteractorLayout);
-
- public:
- /**@name Construction */
- //@{
- /**Create a new empty layout. There are no controls contained within the
- layout and it is expected that these are to added manually by the
- application.
- Note that the parent must be a descendant of PDialog or PTitledWindow.
- */
- PWizardFrame(
- PInteractor * parent /// Interactor that owns the frame.
- );
- /**Create a new layout by loading it from a resource. The resource
- description determines the position, dimensions of the layout as well
- as the position, dimensions, title and other options for all of the
- controls in the layout.
- Note that the parent must be a descendant of PDialog or PTitledWindow.
- */
- PWizardFrame(
- PInteractor * parent, /// Interactor that owns the page.
- PRESOURCE_ID resID /// Resource identifier for loading controls.
- );
- //@}
- /**@name New functions for class */
- //@{
- /**Add a new page to the wizard. The wizard is expanded to allow space for
- the page to fit in the top of the frame.
- */
- void AddPage(
- PWizardPage * page /// New page to add to the wizard.
- );
- /**Get a page that was added using the AddPage() function.
- @return
- page with specified ID, or NULL if none present.
- */
- PWizardPage * GetPage(
- PRESOURCE_ID id /// Identifier of page to obtain.
- ) const { return pages.GetAt(id); }
- /**Get the page that is currently being displayed.
- @return
- pointer to current page.
- */
- PWizardPage * GetCurrentPage() { return currentPage; }
- /**Move to the page specified by the identifier. If the identifier is zero
- then the next page as entered by the AddPage() function is displayed.
- As the current pages OnLeavingPage() function is called, it is possible
- that the specified page is not set, due to validation requirements by
- the current page. In this case FALSE is returned.
- @return
- TRUE if a new page was displayed.
- */
- BOOL SetCurrentPage(PRESOURCE_ID id);
- /**This call back function is executed when the wizard has completed.
- The default behaviour is, if not aborted, to call the OnCompletedPages()
- function on each page and then close the parent window. If the wizard had
- been cancelled then it simply closes the parent window.
- Note that this closes the parent window, not the frame itself. Of course,
- when the parent closes it will in turn close the layout.
- */
- virtual void OnFinished(
- BOOL aborted /// Indicates if the wizard was cancelled
- );
- //@}
- protected:
- // Overrides from class PInteractorLayout
- virtual void ConstructEnd(
- PRESOURCE_ID resID // Resource identifier for loading controls.
- );
- /* Complete construction of an interactor layout. This is primarily used
- by the PWRC resource compiler generated code.
- The behaviour in a PWizardFrame is to resize all of the PWizardPage
- descendants that were added using the AddPage() function and move any
- controls found on the frame out of the way of those pages.
- */
- void Back(class PTextButton &, int);
- // Notifier for Back button
- void Next(class PTextButton &, int);
- // Notifier for Next button
- void Abort(class PTextButton &, int);
- // Notifier for Abort button
- void Finish(class PTextButton &, int);
- // Notifier for Finish button
- // Member variables
- /// The Back button
- PPushButton * back;
- /// The Next button
- PPushButton * next;
- /// The Cancel button
- PPushButton * abort;
- /// The FInish button
- PPushButton * finish;
- /// The active page
- PWizardPage * currentPage;
- /// All pages added via AddPage()
- PWizardPageDict pages;
- /// The pages that have been passed.
- PWizardPageStack pageStack;
- /// Size of layout before AddPage() adjusts it.
- PDim originalSize;
- };
- /**This class is a wrapper around the PWizardFrame that presents a modal
- dialog for the wizard.
- */
- class PWizardDialog : public PModalDialog
- {
- PCLASSINFO(PWizardDialog, PModalDialog);
- public:
- /**Create a dialog with the specified wizard frame contained within it.
- */
- PWizardDialog(
- PInteractor * parent, /// Interactor that owns the frame.
- PWizardFrame * frame /// The wizard frame that the dialog wraps
- );
- };
-
- #endif
- // End Of File ///////////////////////////////////////////////////////////////