Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members

FXWizardPage.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001,2002 by H. 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 #ifndef FXWIZARDPAGE_H
00019 #define FXWIZARDPAGE_H
00020 
00021 #ifndef FXPACKER_H
00022 #include <fox/FXPacker.h>
00023 using namespace FX;
00024 #endif
00025 namespace FXEX {
00026 class FXWizardDialog;
00027 class FXWizardPage;
00028 
00029 /**
00030  * FXWizardPage : One of the screens in an FXWizard dialog.
00031  *
00032  * FXWizardPage is one of the screens in an FXWizardDialog: it must know what are 
00033  * the  following and preceding pages (which may be NULL for the first/last 
00034  * page). Except for this extra knowledge, FXWizardPage is just a FXPacker, so
00035  * the controls may be placed directly on it in the usual way.
00036 */
00037 
00038 
00039 // Instantiate class FXArray<FXWizardPage*>
00040 // This does not create an object. It only forces the generation of all
00041 // of the members of class FXArray<FXWizardPage*>. It exports
00042 // them from the DLL and imports them into a .exe file.
00043 //FIXME FXEXTERN template class FXAPI FXArray<FXWizardPage*>;
00044 
00045 
00046 //****************************************************************************/
00047 // FXWizardPage
00048 //****************************************************************************/
00049 class FXAPI FXWizardPage : public FXPacker {
00050   FXDECLARE(FXWizardPage)
00051 
00052 private:
00053   // FIXME swap ordering of underscores
00054   FXWizardPage     *_prev;        // previous page
00055   FXWizardPage     *_next;        // next page
00056   FXbool           _focusEnabled; // can this page receive focus?
00057   FXWizardDialog*  _wizard;       // parent wizard this page belongs to
00058 
00059 protected:
00060   FXWizardPage(){}  //no default constructor allowed.
00061 
00062 public:
00063   /// Override this before the current page is changed.
00064   virtual long onPageChanging(FXObject*,FXSelector,void* ptr) { return 1; }
00065   
00066   /// Override this after the current page has changed.
00067   virtual long onPageChanged(FXObject*,FXSelector,void* ptr) { return 1; }
00068   
00069   /// Override this when the user attemps to cancel the wizard 
00070   virtual long onPageCancel(FXObject*,FXSelector,void* ptr) { return 1; }
00071   
00072   /// Override this when the <HELP> button is pressed.
00073   virtual long onPageHelp(FXObject*,FXSelector,void* ptr) { return 1; }
00074   
00075   /// Used to enable focus only for the current page. Not overridable.
00076   long onFocusNext(FXObject* sender,FXSelector sel ,void* ptr);
00077   
00078   /// child pages should return foxus to the wizard
00079   long onFocusIn(FXObject*,FXSelector,void*);
00080 
00081 protected:
00082   /// image displayed to the left of this page when current.
00083   FXImage* _pageImage;
00084 
00085 public:
00086   /// FXWizardPage Selector Types
00087   enum {
00088     ID_WIZARDPAGE_CHANGED=FXPacker::ID_LAST,
00089     ID_WIZARDPAGE_CHANGING,
00090     ID_LAST
00091     };
00092 
00093 public:
00094   /*! Constructor for a FXWizardPage.
00095    * \param wizard The FXWizardDialog to which this page will belong.
00096    * \param image The image to display on the left of the page. This
00097    *              should be a user image or one the @link DefaultImageGroup 
00098    *              default image types@endlink.
00099    * \param prev The FXWizardPage that is to be shown if the <PREV> button
00100    *             on the wizard is pressed when this page is active.
00101    * \param next The FXWizardPage that is to be shown if the <NEXT> button
00102    *             on the wizard is pressed when this page is active.
00103    */  
00104   FXWizardPage(FXWizardDialog* wizard,FXImage *image=NULL,FXWizardPage *prev=NULL,FXWizardPage *next=NULL,FXuint opts=FRAME_NONE);
00105 
00106   /// Sets the previous page.
00107   void setPrev(FXWizardPage *prev) { _prev = prev; }
00108 
00109   /// Sets the next page.
00110   void setNext(FXWizardPage *next) { _next = next; }
00111 
00112   /// Get the page which should be shown when the user chooses the "Prev" button.
00113   virtual FXWizardPage *getPrev() const { return _prev; }
00114     
00115   /// Get the page which should be shown when the user chooses the "Next" button.
00116   virtual FXWizardPage *getNext() const { return _next; }
00117 
00118   /** Used to test the validity of the user input. By default, it just 
00119    *  returns TRUE. You should normally override this function in your own 
00120    *  code if validity checking is required.
00121    */
00122   virtual bool transferDataFromPage() { return TRUE; }
00123 
00124   /** This method is called by FXWizardDialog to get the image to display alongside
00125    *  the page. 
00126    *
00127    *  If the image was not explicitly set (i.e. if FXNullImage is returned),
00128    *  the default image for the wizard should be used. If FXEmptyImage is
00129    *  returned, then no image should be displayed for the page.
00130    *
00131    *  The only cases when you would want to override this function is if the
00132    *  page image depends dynamically on the user choices, i.e. almost never.
00133    */
00134   virtual FXImage* getImage() { return _pageImage; }
00135 
00136   /// Used by the wizard to enable the controls on this page to receive focus
00137   void  enableFocus() { _focusEnabled = TRUE; }
00138 
00139   /** Used by the wizard to disable the controls on this page from receiving
00140    *  focus. Normally done when the page is not the current one being displayed.
00141    */
00142   void  disableFocus() { _focusEnabled = FALSE; }
00143 
00144   /// returns whether the controls on this page can receive focus or not
00145   FXbool  canFocus() { return _focusEnabled; }
00146 
00147   /// dtor
00148   virtual ~FXWizardPage() { _pageImage=(FXImage*)-1; }
00149   };
00150 
00151 } // namespace FXEX
00152 #endif // FXWizardPage