Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members  

FXWizard.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001,2002 by Harry J. Daniel III. All Rights Reserved.         *
00003 ********************************************************************************
00004 * This library is free software; you can redistribute it and/or                *
00005 * modify it under the terms of the GNU Lesser General Public                   *
00006 * License as published by the Free Software Foundation; either                 *
00007 * version 2.1 of the License, or (at your option) any later version.           *
00008 *                                                                              *
00009 * This library is distributed in the hope that it will be useful,              *
00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of               *
00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU            *
00012 * Lesser General Public License for more details.                              *
00013 *                                                                              *
00014 * You should have received a copy of the GNU Lesser General Public             *
00015 * License along with this library; if not, write to the Free Software          *
00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.   *
00017 *******************************************************************************/
00018 
00045 #ifndef _FXWIZARD_H_
00046 #define _FXWIZARD_H_
00047 
00048 #include "fxdefs.h"
00049 
00050 //  the following must be places before includes for FXArray.h and FXElement.h
00051 //  when compiling on MSVC++ 6.0. ... Taken From the FOX FAQ 2/23/02
00052 #include<new.h>                         //fixes error C2660: `new` : function does not 
00053                                                         // take 2 parameters
00054 
00055 #include "FXArray.h"            //needed for FXArray
00056 #include "FXElement.h"          //needed for FXArray
00057 
00067 extern FXImage* FXNullImage;
00072 extern FXImage* FXEmptyImage;
00079 extern FXPoint FXPlacementDefault;              
00080 extern FXPoint FXPlacementVisible;              
00081 extern FXPoint FXPlacementCursor;               
00082 extern FXPoint FXPlacementOwner;                
00083 extern FXPoint FXPlacementScreen;               
00084 extern FXPoint FXPlacementMaximized;    
00085 
00087 // Resources Declared in FXWizard.fxr
00088 //extern const FXuchar FXWizardImage[];
00089 //extern const FXuchar FXWizardImage2[];
00090         
00091 //forward declarations
00092 class FXWizardPage;
00093 class FXTLNode;
00094 
00095 //****************************************************************************/
00096 // FXWizard
00097 //****************************************************************************/
00098 class FXWizard : public FXDialogBox
00099 {
00100         FXDECLARE(FXWizard);
00101 protected:  //protected constructors
00102         FXWizard(){}  //no default constructor allowed.
00103 
00104 public:  //public constructors/destructors
00105 
00121         FXWizard(FXApp *app, const FXString& name, FXImage* image ,
00122                          FXPoint position = FXPlacementScreen, FXint padding = 5);
00123 
00139         FXWizard(FXWindow *owner, const FXString& name, FXImage* image ,
00140                          FXPoint position = FXPlacementScreen, FXint padding = 5);
00141 
00142 public:  //message handlers
00143         // these should not be overridden.
00144 
00146         long onPrevOrNext(FXObject*,FXSelector,void* ptr);
00147 
00149         long onCancel(FXObject*,FXSelector,void* ptr);
00150 
00152         long onHelp(FXObject*,FXSelector,void* ptr);
00153 
00154 public:  //public member data
00155 
00157         enum 
00158         {
00160                 ID_WIZARD_PREV=FXDialogBox::ID_LAST,
00162                 ID_WIZARD_NEXT,
00166                 ID_WIZARD_CANCEL,
00168                 ID_WIZARD_HELP,
00169                 ID_LAST
00170         };
00171 
00178         FXArray<FXWizardPage*> pageArray;
00179 
00180 private:  //private member data
00181         
00182         // the global image to display with the wizard pages. This is the image that will
00183         // be displayed if the current pages' image is set to FXNullImage. If the page
00184         // does not want any image displayed it should use FXEmptyImage.
00185         FXImage* _wizImage;
00186 
00187         // the frame that holds the image.
00188         FXImageFrame* _wizImageFrame;
00189 
00190     // the current page or NULL
00191     FXWizardPage *_page;       
00192 
00193     // wizard dimensions
00194     FXuint       _width,       // the size of the wizard itself
00195                  _height;      // (total width is _width + m_x)
00196 
00197     // the page size requested by user
00198     FXSize _sizePage;
00199 
00200         // the dialog position from the ctor
00201     FXPoint _posWizard;
00202 
00203         // wizard controls
00204     FXButton    *_btnPrev,     // the "<Back" button
00205                 *_btnNext,     // the "Next>" or "Finish" button
00206                                 *_btnCancel;   // the "Cancel" button
00207 
00208         FXHorizontalSeparator *_separator;  //the separator
00209 
00210 public:  //public member functions
00211 
00213         void create();
00214         
00219         int run(FXWizardPage* startPage);
00220 
00224         void move(FXuint x, FXuint y);
00225 
00229         void move(FXPoint pos);
00230 
00234     static void chain(FXWizardPage *first, ...);
00235 
00236 private:  //private member functions
00237 
00238         // Moves the upper right hand corner of all of the FXWizardPage's to a
00239         // specified location in the FXWizard's coordinate space.
00240         void _movePages(FXuint x, FXuint y);
00241 
00242         // Displays the wizard with the currently active FXWizardPage.
00243         FXbool _showPage(FXWizardPage *page, FXbool goingForward);
00244         
00245         // Construct the default controls used in the wizard
00246         void _constructControls();
00247         
00248         // Was the dialog really created?
00249     bool _wasCreated() const { return _btnPrev != NULL; }
00250 
00251         // Routine to find the minimum size required to fully display all
00252         // the pages.
00253         FXSize _getPageSizes();
00254 
00255         // Routine to set the minimum size required to fully display all
00256         // the pages.
00257         void _setPageSizes(FXuint w, FXuint h);
00258         
00259         // Finds the maximum size required by all of the page images.
00260         FXSize _getImageSizes();
00261 
00262 };
00263 
00264 
00265 //****************************************************************************/
00266 // FXWizardPage
00267 //****************************************************************************/
00268 class FXWizardPage : public FXPacker
00269 {
00270         FXDECLARE(FXWizardPage);
00271 
00272 protected:  //protected constructors
00273         FXWizardPage(){}  //no default constructor allowed.
00274 
00275 public:  //public constructors
00276 
00287         FXWizardPage(FXWizard* wizard,
00288                                  FXImage *image = FXNullImage,
00289                                  FXWizardPage *prev = (FXWizardPage *)NULL,
00290                                  FXWizardPage *next = (FXWizardPage *)NULL,
00291                                  FXuint opts = FRAME_NONE
00292                                 );
00293 
00294 public:  //public message handlers
00295 
00299         virtual long onPageChanging(FXObject*,FXSelector,void* ptr) { return 1; }
00300         
00304         virtual long onPageChanged(FXObject*,FXSelector,void* ptr) { return 1; }
00305         
00309         virtual long onPageCancel(FXObject*,FXSelector,void* ptr) { return 1; }
00310         
00314         virtual long onPageHelp(FXObject*,FXSelector,void* ptr) { return 1; }
00315         
00317         long onFocusNext(FXObject* sender,FXSelector sel ,void* ptr);
00318 
00319 protected:  //protected member data
00320 
00322         FXImage*                _pageImage;
00323 
00324 public:  //public member data
00325 
00327         enum 
00328         {
00329                 ID_WIZARDPAGE_CHANGED=FXPacker::ID_LAST,
00330                 ID_WIZARDPAGE_CHANGING,
00331                 ID_LAST
00332         };
00333 
00334 private:  //private member data
00335 
00336     // pointers are private, the derived classes shouldn't mess with them -
00337     // just derive from wxWizardPage directly to implement different behaviour
00338     FXWizardPage        *_prev,
00339                                         *_next;
00340 
00341         // can this page receive focus?
00342         FXbool                  _focusEnabled;
00343 
00344         // parent wizard this page belongs to
00345         FXWizard*               _wizard;
00346 
00347 public:  //public member functions
00348 
00350     void setPrev(FXWizardPage *prev) { _prev = prev; }
00351 
00353     void setNext(FXWizardPage *next) { _next = next; }
00354 
00358         virtual FXWizardPage *getPrev() const { return _prev; }
00359     
00363         virtual FXWizardPage *getNext() const { return _next; }
00364 
00369         virtual bool transferDataFromPage() { return TRUE; }
00370 
00381         virtual FXImage* getImage() { return _pageImage; }
00382 
00384         void    enableFocus() { _focusEnabled = TRUE; }
00385 
00389         void    disableFocus() { _focusEnabled = FALSE; }
00390 
00392         FXbool  canFocus() { return _focusEnabled; }
00393 };
00394 
00395 #endif

Generated on Fri Mar 8 09:33:38 2002 by doxygen1.2.13 written by Dimitri van Heesch, © 1997-2001