propdlg.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: propdlg.h
  3. // Purpose: interface of wxPropertySheetDialog
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. Values used by wxPropertySheetDialog::SetSheetStyle
  9. */
  10. enum wxPropertySheetDialogFlags
  11. {
  12. /**
  13. Uses the default look and feel for the controller window,
  14. normally a notebook except on Smartphone where a choice control is used.
  15. */
  16. wxPROPSHEET_DEFAULT = 0x0001,
  17. /**
  18. Uses a notebook for the controller window.
  19. */
  20. wxPROPSHEET_NOTEBOOK = 0x0002,
  21. /**
  22. Uses a toolbook for the controller window.
  23. */
  24. wxPROPSHEET_TOOLBOOK = 0x0004,
  25. /**
  26. Uses a choicebook for the controller window.
  27. */
  28. wxPROPSHEET_CHOICEBOOK = 0x0008,
  29. /**
  30. Uses a listbook for the controller window.
  31. */
  32. wxPROPSHEET_LISTBOOK = 0x0010,
  33. /**
  34. Uses a button toolbox for the controller window.
  35. */
  36. wxPROPSHEET_BUTTONTOOLBOOK = 0x0020,
  37. /**
  38. Uses a treebook for the controller window.
  39. */
  40. wxPROPSHEET_TREEBOOK = 0x0040,
  41. /**
  42. Shrinks the dialog window to fit the currently selected page
  43. (common behaviour for property sheets on Mac OS X).
  44. */
  45. wxPROPSHEET_SHRINKTOFIT = 0x0100,
  46. };
  47. /**
  48. @class wxPropertySheetDialog
  49. This class represents a property sheet dialog: a tabbed dialog
  50. for showing settings. It is optimized to show flat tabs
  51. on PocketPC devices, and can be customized to use different
  52. controllers instead of the default notebook style.
  53. To use this class, call Create() from your own Create function.
  54. Then call CreateButtons(), and create pages, adding them to the book control.
  55. Finally call LayoutDialog().
  56. For example:
  57. @code
  58. bool MyPropertySheetDialog::Create(...)
  59. {
  60. if (!wxPropertySheetDialog::Create(...))
  61. return false;
  62. CreateButtons(wxOK|wxCANCEL|wxHELP);
  63. // Add page
  64. wxPanel* panel = new wxPanel(GetBookCtrl(), ...);
  65. GetBookCtrl()->AddPage(panel, "General");
  66. LayoutDialog();
  67. return true;
  68. }
  69. @endcode
  70. If necessary, override CreateBookCtrl() and AddBookCtrl() to create and add a
  71. different kind of book control. You will then need to use two-step construction
  72. for the dialog or change the style of the book control by calling SetSheetStyle()
  73. before calling Create().
  74. The @ref page_samples_dialogs shows this class being used with notebook and toolbook
  75. controllers (for Windows-style and Mac-style settings dialogs).
  76. To make pages of the dialog scroll when the display is too small to fit the
  77. whole dialog, you can switch layout adaptation on globally with
  78. wxDialog::EnableLayoutAdaptation() or per dialog with
  79. wxDialog::SetLayoutAdaptationMode().
  80. For more about layout adaptation, see @ref overview_dialog_autoscrolling.
  81. @library{wxadv}
  82. @category{managedwnd}
  83. */
  84. class wxPropertySheetDialog : public wxDialog
  85. {
  86. public:
  87. /**
  88. Constructor.
  89. */
  90. wxPropertySheetDialog(wxWindow* parent, wxWindowID id,
  91. const wxString& title,
  92. const wxPoint& pos = wxDefaultPosition,
  93. const wxSize& size = wxDefaultSize,
  94. long style = wxDEFAULT_DIALOG_STYLE,
  95. const wxString& name = wxDialogNameStr);
  96. /**
  97. Override this if you wish to add the book control in a way different from the
  98. standard way (for example, using different spacing).
  99. */
  100. virtual void AddBookCtrl(wxSizer* sizer);
  101. /**
  102. Call this from your own Create function, before adding buttons and pages.
  103. */
  104. bool Create(wxWindow* parent, wxWindowID id, const wxString& title,
  105. const wxPoint& pos = wxDefaultPosition,
  106. const wxSize& size = wxDefaultSize,
  107. long style = wxDEFAULT_DIALOG_STYLE,
  108. const wxString& name = wxDialogNameStr);
  109. /**
  110. Override this if you wish to create a different kind of book control; by
  111. default, the value passed to SetSheetStyle() is used to determine the control.
  112. The default behaviour is to create a notebook except on Smartphone, where a
  113. choicebook is used.
  114. */
  115. virtual wxBookCtrlBase* CreateBookCtrl();
  116. /**
  117. Call this to create the buttons for the dialog.
  118. This calls wxDialog::CreateButtonSizer(), and the flags are the same.
  119. @note On PocketPC, no buttons are created.
  120. */
  121. virtual void CreateButtons(int flags = wxOK|wxCANCEL);
  122. /**
  123. Returns the book control that will contain your settings pages.
  124. */
  125. wxBookCtrlBase* GetBookCtrl() const;
  126. /**
  127. Returns the inner sizer that contains the book control and button sizer.
  128. */
  129. wxSizer* GetInnerSizer() const;
  130. /**
  131. Returns the sheet style.
  132. See SetSheetStyle() for allowed values.
  133. */
  134. long GetSheetStyle() const;
  135. /**
  136. Call this to lay out the dialog.
  137. @note On PocketPC, this does nothing, since the dialog will be shown full-screen,
  138. and the layout will be done when the dialog receives a size event.
  139. */
  140. virtual void LayoutDialog(int centreFlags = wxBOTH);
  141. /**
  142. Sets the book control used for the dialog.
  143. You will normally not need to use this.
  144. */
  145. void SetBookCtrl(wxBookCtrlBase* bookCtrl);
  146. /**
  147. You can customize the look and feel of the dialog by setting the sheet style.
  148. It is a bit list of the ::wxPropertySheetDialogFlags values.
  149. */
  150. void SetSheetStyle(long style);
  151. };