include/uiutils/scrollingwizard.h

Go to the documentation of this file.
00001 
00002 // Name:        wx/generic/wizard.h
00003 // Purpose:     declaration of generic wxWizard class
00004 // Author:      Vadim Zeitlin
00005 // Modified by: Robert Vazan (sizers)
00006 // Created:     28.09.99
00007 // RCS-ID:      $Id: scrollingwizard.h,v 1.1 2008/01/06 13:57:34 anthemion Exp $
00008 // Copyright:   (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
00009 // Licence:     wxWindows licence
00010 // Licence:     New BSD License
00012 
00013 /*
00014 
00015 To change in wxWizard in 2.9:
00016 
00017   - References to wxWizard in wxWizardPage should be changed to wxWizardBase
00018   - It should be possible to derive from wxWizard and reimplement some functionality:
00019     add accessors change private to protected.
00020 
00021 Problem: page size is calculated using a bitmap that may not be the full width.
00022 
00023  */
00024 
00025 #ifndef _WX_SCROLLING_WIZARD_H_
00026 #define _WX_SCROLLING_WIZARD_H_
00027 
00028 #include "wx/wizard.h"
00029 
00030 #include "uiutils/scrollingdialog.h"
00031 
00032 // ----------------------------------------------------------------------------
00033 // wxWizard
00034 // ----------------------------------------------------------------------------
00035 
00036 class WXDLLIMPEXP_FWD_CORE wxButton;
00037 class WXDLLIMPEXP_FWD_CORE wxStaticBitmap;
00038 class WXDLLIMPEXP_FWD_ADV wxWizardEvent;
00039 class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
00040 class wxScrollingWizardSizer;
00041 
00042 // Placement flags
00043 #define wxWIZARD_VALIGN_TOP       0x01
00044 #define wxWIZARD_VALIGN_CENTRE    0x02
00045 #define wxWIZARD_VALIGN_BOTTOM    0x04
00046 #define wxWIZARD_HALIGN_LEFT      0x08
00047 #define wxWIZARD_HALIGN_CENTRE    0x10
00048 #define wxWIZARD_HALIGN_RIGHT     0x20
00049 #define wxWIZARD_TILE             0x40
00050 
00051 class wxScrollingWizard : public wxWizard, public wxDialogHelper
00052 {
00053 public:
00054     // ctor
00055     wxScrollingWizard() { Init(); }
00056     wxScrollingWizard(wxWindow *parent,
00057              int id = wxID_ANY,
00058              const wxString& title = wxEmptyString,
00059              const wxBitmap& bitmap = wxNullBitmap,
00060              const wxPoint& pos = wxDefaultPosition,
00061              long style = wxDEFAULT_DIALOG_STYLE)
00062     {
00063         Init();
00064         Create(parent, id, title, bitmap, pos, style);
00065     }
00066     bool Create(wxWindow *parent,
00067              int id = wxID_ANY,
00068              const wxString& title = wxEmptyString,
00069              const wxBitmap& bitmap = wxNullBitmap,
00070              const wxPoint& pos = wxDefaultPosition,
00071              long style = wxDEFAULT_DIALOG_STYLE);
00072     void Init();
00073     virtual ~wxScrollingWizard();
00074 
00075     // implement base class pure virtuals
00076     virtual bool RunWizard(wxWizardPage *firstPage);
00077     virtual wxWizardPage *GetCurrentPage() const;
00078     virtual void SetPageSize(const wxSize& size);
00079     virtual wxSize GetPageSize() const;
00080     virtual void FitToPage(const wxWizardPage *firstPage);
00081     virtual wxSizer *GetPageAreaSizer() const;
00082     virtual void SetBorder(int border);
00083 
00085     const wxBitmap& GetBitmap() const { return m_bitmap; }
00086     void SetBitmap(const wxBitmap& bitmap);
00087 
00088     // implementation only from now on
00089     // -------------------------------
00090 
00091     // is the wizard running?
00092     bool IsRunning() const { return m_page != NULL; }
00093 
00094     // show the prev/next page, but call TransferDataFromWindow on the current
00095     // page first and return false without changing the page if
00096     // TransferDataFromWindow() returns false - otherwise, returns true
00097     bool ShowPage(wxWizardPage *page, bool goingForward = true);
00098 
00099     // do fill the dialog with controls
00100     // this is app-overridable to, for example, set help and tooltip text
00101     virtual void DoCreateControls();
00102 
00104     virtual bool DoLayoutAdaptation();
00105 
00107     void SetBitmapBackgroundColour(const wxColour& colour) { m_bitmapBackgroundColour = colour; }
00108     const wxColour& GetBitmapBackgroundColour() const { return m_bitmapBackgroundColour; }
00109 
00111     void SetBitmapPlacement(int placement) { m_bitmapPlacement = placement; }
00112     int GetBitmapPlacement() const { return m_bitmapPlacement; }
00113 
00115     void SetMinimumBitmapWidth(int w) { m_bitmapMinimumWidth = w; }
00116     int GetMinimumBitmapWidth() const { return m_bitmapMinimumWidth; }
00117 
00119     static bool TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap);
00120 
00121 protected:
00122     // for compatibility only, doesn't do anything any more
00123     void FinishLayout() { }
00124 
00126     virtual void DoWizardLayout();
00127 
00129     virtual bool ResizeBitmap(wxBitmap& bmp);
00130 
00131     // was the dialog really created?
00132     bool WasCreated() const { return m_btnPrev != NULL; }
00133 
00134     // event handlers
00135     void OnCancel(wxCommandEvent& event);
00136     void OnBackOrNext(wxCommandEvent& event);
00137     void OnHelp(wxCommandEvent& event);
00138 
00139     void OnWizEvent(wxWizardEvent& event);
00140 
00141     void AddBitmapRow(wxBoxSizer *mainColumn);
00142     void AddStaticLine(wxBoxSizer *mainColumn);
00143     void AddBackNextPair(wxBoxSizer *buttonRow);
00144     void AddButtonRow(wxBoxSizer *mainColumn);
00145 
00146     // the page size requested by user
00147     wxSize m_sizePage;
00148 
00149     // the dialog position from the ctor
00150     wxPoint m_posWizard;
00151 
00152     // wizard state
00153     wxWizardPage *m_page;       // the current page or NULL
00154     wxBitmap      m_bitmap;     // the default bitmap to show
00155 
00156     // wizard controls
00157     wxButton    *m_btnPrev,     // the "<Back" button
00158                 *m_btnNext;     // the "Next>" or "Finish" button
00159     wxStaticBitmap *m_statbmp;  // the control for the bitmap
00160 
00161     // Border around page area sizer requested using SetBorder()
00162     int m_border;
00163 
00164     // Whether RunWizard() was called
00165     bool m_started;
00166 
00167     // Whether was modal (modeless has to be destroyed on finish or cancel)
00168     bool m_wasModal;
00169 
00170     // True if pages are laid out using the sizer
00171     bool m_usingSizer;
00172 
00173     // Page area sizer will be inserted here with padding
00174     wxBoxSizer *m_sizerBmpAndPage;
00175 
00176     // Actual position and size of pages
00177     wxScrollingWizardSizer *m_sizerPage;
00178 
00179     wxColour    m_bitmapBackgroundColour;
00180     int         m_bitmapPlacement;
00181     int         m_bitmapMinimumWidth;
00182 
00183     friend class wxScrollingWizardSizer;
00184 
00185     DECLARE_DYNAMIC_CLASS(wxScrollingWizard)
00186     DECLARE_EVENT_TABLE()
00187     DECLARE_NO_COPY_CLASS(wxScrollingWizard)
00188 };
00189 
00190 // ----------------------------------------------------------------------------
00191 // wxWizardSizer
00192 // ----------------------------------------------------------------------------
00193 
00194 class wxScrollingWizardSizer : public wxSizer
00195 {
00196 public:
00197     wxScrollingWizardSizer(wxScrollingWizard *owner);
00198 
00199     virtual wxSizerItem *Insert(size_t index, wxSizerItem *item);
00200 
00201     virtual void RecalcSizes();
00202     virtual wxSize CalcMin();
00203 
00204     // get the max size of all wizard pages
00205     wxSize GetMaxChildSize();
00206 
00207     // return the border which can be either set using wxWizard::SetBorder() or
00208     // have default value
00209     int GetBorder() const;
00210 
00211     // hide the pages which we temporarily "show" when they're added to this
00212     // sizer (see Insert())
00213     void HidePages();
00214 
00215 private:
00216     wxSize SiblingSize(wxSizerItem *child);
00217 
00218     wxScrollingWizard *m_owner;
00219     wxSize m_childSize;
00220 };
00221 
00222 
00223 #endif // _WX_SCROLLING_WIZARD_H_

Generated on Wed May 6 19:20:19 2009 for AxTk by  doxygen 1.5.1