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 11 #ifndef _WX_PROPDLG_H_ 12 #define _WX_PROPDLG_H_ 13 14 #include "wx/defs.h" 15 16 #if wxUSE_BOOKCTRL 17 18 #include "wx/dialog.h" 19 20 class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase; 21 22 //----------------------------------------------------------------------------- 23 // wxPropertySheetDialog 24 // A platform-independent properties dialog with a notebook and standard 25 // buttons. 26 // 27 // To use this class, call Create from your derived class. 28 // Then create pages and add to the book control. Finally call CreateButtons and 29 // LayoutDialog. 30 // 31 // For example: 32 // 33 // MyPropertySheetDialog::Create(...) 34 // { 35 // wxPropertySheetDialog::Create(...); 36 // 37 // // Add page 38 // wxPanel* panel = new wxPanel(GetBookCtrl(), ...); 39 // GetBookCtrl()->AddPage(panel, wxT("General")); 40 // 41 // CreateButtons(); 42 // LayoutDialog(); 43 // } 44 // 45 // Override CreateBookCtrl and AddBookCtrl to create and add a different 46 // kind of book control. 47 //----------------------------------------------------------------------------- 48 49 enum wxPropertySheetDialogFlags 50 { 51 // Use the platform default 52 wxPROPSHEET_DEFAULT = 0x0001, 53 54 // Use a notebook 55 wxPROPSHEET_NOTEBOOK = 0x0002, 56 57 // Use a toolbook 58 wxPROPSHEET_TOOLBOOK = 0x0004, 59 60 // Use a choicebook 61 wxPROPSHEET_CHOICEBOOK = 0x0008, 62 63 // Use a listbook 64 wxPROPSHEET_LISTBOOK = 0x0010, 65 66 // Use a wxButtonToolBar toolbook 67 wxPROPSHEET_BUTTONTOOLBOOK = 0x0020, 68 69 // Use a treebook 70 wxPROPSHEET_TREEBOOK = 0x0040, 71 72 // Shrink dialog to fit current page 73 wxPROPSHEET_SHRINKTOFIT = 0x0100 74 }; 75 76 class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog 77 { 78 public: wxPropertySheetDialog()79 wxPropertySheetDialog() : wxDialog() { Init(); } 80 81 wxPropertySheetDialog(wxWindow* parent, wxWindowID id, 82 const wxString& title, 83 const wxPoint& pos = wxDefaultPosition, 84 const wxSize& sz = wxDefaultSize, 85 long style = wxDEFAULT_DIALOG_STYLE, 86 const wxString& name = wxASCII_STR(wxDialogNameStr)) 87 { 88 Init(); 89 Create(parent, id, title, pos, sz, style, name); 90 } 91 92 bool Create(wxWindow* parent, wxWindowID id, 93 const wxString& title, 94 const wxPoint& pos = wxDefaultPosition, 95 const wxSize& sz = wxDefaultSize, 96 long style = wxDEFAULT_DIALOG_STYLE, 97 const wxString& name = wxASCII_STR(wxDialogNameStr)); 98 99 //// Accessors 100 101 // Set and get the notebook SetBookCtrl(wxBookCtrlBase * book)102 void SetBookCtrl(wxBookCtrlBase* book) { m_bookCtrl = book; } GetBookCtrl()103 wxBookCtrlBase* GetBookCtrl() const { return m_bookCtrl; } 104 105 // Override function in base 106 virtual wxWindow* GetContentWindow() const wxOVERRIDE; 107 108 // Set and get the inner sizer SetInnerSizer(wxSizer * sizer)109 void SetInnerSizer(wxSizer* sizer) { m_innerSizer = sizer; } GetInnerSizer()110 wxSizer* GetInnerSizer() const { return m_innerSizer ; } 111 112 // Set and get the book style SetSheetStyle(long sheetStyle)113 void SetSheetStyle(long sheetStyle) { m_sheetStyle = sheetStyle; } GetSheetStyle()114 long GetSheetStyle() const { return m_sheetStyle ; } 115 116 // Set and get the border around the whole dialog SetSheetOuterBorder(int border)117 void SetSheetOuterBorder(int border) { m_sheetOuterBorder = border; } GetSheetOuterBorder()118 int GetSheetOuterBorder() const { return m_sheetOuterBorder ; } 119 120 // Set and get the border around the book control only SetSheetInnerBorder(int border)121 void SetSheetInnerBorder(int border) { m_sheetInnerBorder = border; } GetSheetInnerBorder()122 int GetSheetInnerBorder() const { return m_sheetInnerBorder ; } 123 124 /// Operations 125 126 // Creates the buttons 127 virtual void CreateButtons(int flags = wxOK|wxCANCEL); 128 129 // Lay out the dialog, to be called after pages have been created 130 virtual void LayoutDialog(int centreFlags = wxBOTH); 131 132 /// Implementation 133 134 // Creates the book control. If you want to use a different kind of 135 // control, override. 136 virtual wxBookCtrlBase* CreateBookCtrl(); 137 138 // Adds the book control to the inner sizer. 139 virtual void AddBookCtrl(wxSizer* sizer); 140 141 // Resize dialog if necessary 142 void OnIdle(wxIdleEvent& event); 143 144 private: 145 void Init(); 146 147 protected: 148 wxBookCtrlBase* m_bookCtrl; 149 wxSizer* m_innerSizer; // sizer for extra space 150 long m_sheetStyle; 151 int m_sheetOuterBorder; 152 int m_sheetInnerBorder; 153 int m_selectedPage; 154 155 wxDECLARE_DYNAMIC_CLASS(wxPropertySheetDialog); 156 wxDECLARE_EVENT_TABLE(); 157 }; 158 159 #endif // wxUSE_BOOKCTRL 160 161 #endif // _WX_PROPDLG_H_ 162 163