wizard.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/wizard.h
  3. // Purpose: declaration of generic wxWizard class
  4. // Author: Vadim Zeitlin
  5. // Modified by: Robert Vazan (sizers)
  6. // Created: 28.09.99
  7. // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GENERIC_WIZARD_H_
  11. #define _WX_GENERIC_WIZARD_H_
  12. // ----------------------------------------------------------------------------
  13. // wxWizard
  14. // ----------------------------------------------------------------------------
  15. class WXDLLIMPEXP_FWD_CORE wxButton;
  16. class WXDLLIMPEXP_FWD_CORE wxStaticBitmap;
  17. class WXDLLIMPEXP_FWD_ADV wxWizardEvent;
  18. class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
  19. class WXDLLIMPEXP_FWD_ADV wxWizardSizer;
  20. class WXDLLIMPEXP_ADV wxWizard : public wxWizardBase
  21. {
  22. public:
  23. // ctor
  24. wxWizard() { Init(); }
  25. wxWizard(wxWindow *parent,
  26. int id = wxID_ANY,
  27. const wxString& title = wxEmptyString,
  28. const wxBitmap& bitmap = wxNullBitmap,
  29. const wxPoint& pos = wxDefaultPosition,
  30. long style = wxDEFAULT_DIALOG_STYLE)
  31. {
  32. Init();
  33. Create(parent, id, title, bitmap, pos, style);
  34. }
  35. bool Create(wxWindow *parent,
  36. int id = wxID_ANY,
  37. const wxString& title = wxEmptyString,
  38. const wxBitmap& bitmap = wxNullBitmap,
  39. const wxPoint& pos = wxDefaultPosition,
  40. long style = wxDEFAULT_DIALOG_STYLE);
  41. void Init();
  42. virtual ~wxWizard();
  43. // implement base class pure virtuals
  44. virtual bool RunWizard(wxWizardPage *firstPage);
  45. virtual wxWizardPage *GetCurrentPage() const;
  46. virtual void SetPageSize(const wxSize& size);
  47. virtual wxSize GetPageSize() const;
  48. virtual void FitToPage(const wxWizardPage *firstPage);
  49. virtual wxSizer *GetPageAreaSizer() const;
  50. virtual void SetBorder(int border);
  51. /// set/get bitmap
  52. const wxBitmap& GetBitmap() const { return m_bitmap; }
  53. void SetBitmap(const wxBitmap& bitmap);
  54. // implementation only from now on
  55. // -------------------------------
  56. // is the wizard running?
  57. bool IsRunning() const { return m_page != NULL; }
  58. // show the prev/next page, but call TransferDataFromWindow on the current
  59. // page first and return false without changing the page if
  60. // TransferDataFromWindow() returns false - otherwise, returns true
  61. virtual bool ShowPage(wxWizardPage *page, bool goingForward = true);
  62. // do fill the dialog with controls
  63. // this is app-overridable to, for example, set help and tooltip text
  64. virtual void DoCreateControls();
  65. // Do the adaptation
  66. virtual bool DoLayoutAdaptation();
  67. // Set/get bitmap background colour
  68. void SetBitmapBackgroundColour(const wxColour& colour) { m_bitmapBackgroundColour = colour; }
  69. const wxColour& GetBitmapBackgroundColour() const { return m_bitmapBackgroundColour; }
  70. // Set/get bitmap placement (centred, tiled etc.)
  71. void SetBitmapPlacement(int placement) { m_bitmapPlacement = placement; }
  72. int GetBitmapPlacement() const { return m_bitmapPlacement; }
  73. // Set/get minimum bitmap width
  74. void SetMinimumBitmapWidth(int w) { m_bitmapMinimumWidth = w; }
  75. int GetMinimumBitmapWidth() const { return m_bitmapMinimumWidth; }
  76. // Tile bitmap
  77. static bool TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap);
  78. protected:
  79. // for compatibility only, doesn't do anything any more
  80. void FinishLayout() { }
  81. // Do fit, and adjust to screen size if necessary
  82. virtual void DoWizardLayout();
  83. // Resize bitmap if necessary
  84. virtual bool ResizeBitmap(wxBitmap& bmp);
  85. // was the dialog really created?
  86. bool WasCreated() const { return m_btnPrev != NULL; }
  87. // event handlers
  88. void OnCancel(wxCommandEvent& event);
  89. void OnBackOrNext(wxCommandEvent& event);
  90. void OnHelp(wxCommandEvent& event);
  91. void OnWizEvent(wxWizardEvent& event);
  92. void AddBitmapRow(wxBoxSizer *mainColumn);
  93. void AddStaticLine(wxBoxSizer *mainColumn);
  94. void AddBackNextPair(wxBoxSizer *buttonRow);
  95. void AddButtonRow(wxBoxSizer *mainColumn);
  96. // the page size requested by user
  97. wxSize m_sizePage;
  98. // the dialog position from the ctor
  99. wxPoint m_posWizard;
  100. // wizard state
  101. wxWizardPage *m_page; // the current page or NULL
  102. wxBitmap m_bitmap; // the default bitmap to show
  103. // wizard controls
  104. wxButton *m_btnPrev, // the "<Back" button
  105. *m_btnNext; // the "Next>" or "Finish" button
  106. wxStaticBitmap *m_statbmp; // the control for the bitmap
  107. // Border around page area sizer requested using SetBorder()
  108. int m_border;
  109. // Whether RunWizard() was called
  110. bool m_started;
  111. // Whether was modal (modeless has to be destroyed on finish or cancel)
  112. bool m_wasModal;
  113. // True if pages are laid out using the sizer
  114. bool m_usingSizer;
  115. // Page area sizer will be inserted here with padding
  116. wxBoxSizer *m_sizerBmpAndPage;
  117. // Actual position and size of pages
  118. wxWizardSizer *m_sizerPage;
  119. // Bitmap background colour if resizing bitmap
  120. wxColour m_bitmapBackgroundColour;
  121. // Bitmap placement flags
  122. int m_bitmapPlacement;
  123. // Minimum bitmap width
  124. int m_bitmapMinimumWidth;
  125. friend class wxWizardSizer;
  126. DECLARE_DYNAMIC_CLASS(wxWizard)
  127. DECLARE_EVENT_TABLE()
  128. wxDECLARE_NO_COPY_CLASS(wxWizard);
  129. };
  130. #endif // _WX_GENERIC_WIZARD_H_