propdlg.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/propdlg.h
  3. // Purpose: wxPropertySheetDialog
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 2005-03-12
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_PROPDLG_H_
  11. #define _WX_PROPDLG_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_BOOKCTRL
  14. #include "wx/dialog.h"
  15. class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;
  16. //-----------------------------------------------------------------------------
  17. // wxPropertySheetDialog
  18. // A platform-independent properties dialog.
  19. //
  20. // * on PocketPC, a flat-look 'property sheet' notebook will be used, with
  21. // no OK/Cancel/Help buttons
  22. // * on other platforms, a normal notebook will be used, with standard buttons
  23. //
  24. // To use this class, call Create from your derived class.
  25. // Then create pages and add to the book control. Finally call CreateButtons and
  26. // LayoutDialog.
  27. //
  28. // For example:
  29. //
  30. // MyPropertySheetDialog::Create(...)
  31. // {
  32. // wxPropertySheetDialog::Create(...);
  33. //
  34. // // Add page
  35. // wxPanel* panel = new wxPanel(GetBookCtrl(), ...);
  36. // GetBookCtrl()->AddPage(panel, wxT("General"));
  37. //
  38. // CreateButtons();
  39. // LayoutDialog();
  40. // }
  41. //
  42. // Override CreateBookCtrl and AddBookCtrl to create and add a different
  43. // kind of book control.
  44. //-----------------------------------------------------------------------------
  45. enum wxPropertySheetDialogFlags
  46. {
  47. // Use the platform default
  48. wxPROPSHEET_DEFAULT = 0x0001,
  49. // Use a notebook
  50. wxPROPSHEET_NOTEBOOK = 0x0002,
  51. // Use a toolbook
  52. wxPROPSHEET_TOOLBOOK = 0x0004,
  53. // Use a choicebook
  54. wxPROPSHEET_CHOICEBOOK = 0x0008,
  55. // Use a listbook
  56. wxPROPSHEET_LISTBOOK = 0x0010,
  57. // Use a wxButtonToolBar toolbook
  58. wxPROPSHEET_BUTTONTOOLBOOK = 0x0020,
  59. // Use a treebook
  60. wxPROPSHEET_TREEBOOK = 0x0040,
  61. // Shrink dialog to fit current page
  62. wxPROPSHEET_SHRINKTOFIT = 0x0100
  63. };
  64. class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog
  65. {
  66. public:
  67. wxPropertySheetDialog() : wxDialog() { Init(); }
  68. wxPropertySheetDialog(wxWindow* parent, wxWindowID id,
  69. const wxString& title,
  70. const wxPoint& pos = wxDefaultPosition,
  71. const wxSize& sz = wxDefaultSize,
  72. long style = wxDEFAULT_DIALOG_STYLE,
  73. const wxString& name = wxDialogNameStr)
  74. {
  75. Init();
  76. Create(parent, id, title, pos, sz, style, name);
  77. }
  78. bool Create(wxWindow* parent, wxWindowID id,
  79. const wxString& title,
  80. const wxPoint& pos = wxDefaultPosition,
  81. const wxSize& sz = wxDefaultSize,
  82. long style = wxDEFAULT_DIALOG_STYLE,
  83. const wxString& name = wxDialogNameStr);
  84. //// Accessors
  85. // Set and get the notebook
  86. void SetBookCtrl(wxBookCtrlBase* book) { m_bookCtrl = book; }
  87. wxBookCtrlBase* GetBookCtrl() const { return m_bookCtrl; }
  88. // Override function in base
  89. virtual wxWindow* GetContentWindow() const;
  90. // Set and get the inner sizer
  91. void SetInnerSize(wxSizer* sizer) { m_innerSizer = sizer; }
  92. wxSizer* GetInnerSizer() const { return m_innerSizer ; }
  93. // Set and get the book style
  94. void SetSheetStyle(long sheetStyle) { m_sheetStyle = sheetStyle; }
  95. long GetSheetStyle() const { return m_sheetStyle ; }
  96. // Set and get the border around the whole dialog
  97. void SetSheetOuterBorder(int border) { m_sheetOuterBorder = border; }
  98. int GetSheetOuterBorder() const { return m_sheetOuterBorder ; }
  99. // Set and get the border around the book control only
  100. void SetSheetInnerBorder(int border) { m_sheetInnerBorder = border; }
  101. int GetSheetInnerBorder() const { return m_sheetInnerBorder ; }
  102. /// Operations
  103. // Creates the buttons (none on PocketPC)
  104. virtual void CreateButtons(int flags = wxOK|wxCANCEL);
  105. // Lay out the dialog, to be called after pages have been created
  106. virtual void LayoutDialog(int centreFlags = wxBOTH);
  107. /// Implementation
  108. // Creates the book control. If you want to use a different kind of
  109. // control, override.
  110. virtual wxBookCtrlBase* CreateBookCtrl();
  111. // Adds the book control to the inner sizer.
  112. virtual void AddBookCtrl(wxSizer* sizer);
  113. // Set the focus
  114. void OnActivate(wxActivateEvent& event);
  115. // Resize dialog if necessary
  116. void OnIdle(wxIdleEvent& event);
  117. private:
  118. void Init();
  119. protected:
  120. wxBookCtrlBase* m_bookCtrl;
  121. wxSizer* m_innerSizer; // sizer for extra space
  122. long m_sheetStyle;
  123. int m_sheetOuterBorder;
  124. int m_sheetInnerBorder;
  125. int m_selectedPage;
  126. DECLARE_DYNAMIC_CLASS(wxPropertySheetDialog)
  127. DECLARE_EVENT_TABLE()
  128. };
  129. #endif // wxUSE_BOOKCTRL
  130. #endif // _WX_PROPDLG_H_