]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: treebook.h | |
3e97a905 | 3 | // Purpose: interface of wxTreebook |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
e1b7217e | 8 | |
ce7fe42e VZ |
9 | wxEventType wxEVT_TREEBOOK_PAGE_CHANGED; |
10 | wxEventType wxEVT_TREEBOOK_PAGE_CHANGING; | |
11 | wxEventType wxEVT_TREEBOOK_NODE_COLLAPSED; | |
12 | wxEventType wxEVT_TREEBOOK_NODE_EXPANDED; | |
e1b7217e | 13 | |
23324ae1 FM |
14 | /** |
15 | @class wxTreebook | |
7c913512 | 16 | |
7977b62a BP |
17 | This class is an extension of the wxNotebook class that allows a tree |
18 | structured set of pages to be shown in a control. A classic example is a | |
19 | netscape preferences dialog that shows a tree of preference sections on | |
20 | the left and select section page on the right. | |
7c913512 | 21 | |
23324ae1 | 22 | To use the class simply create it and populate with pages using |
7977b62a BP |
23 | InsertPage(), InsertSubPage(), AddPage(), AddSubPage(). |
24 | ||
25 | If your tree is no more than 1 level in depth then you could simply use | |
26 | AddPage() and AddSubPage() to sequentially populate your tree by adding at | |
27 | every step a page or a subpage to the end of the tree. | |
28 | ||
3051a44a | 29 | @beginEventEmissionTable{wxBookCtrlEvent} |
7977b62a | 30 | @event{EVT_TREEBOOK_PAGE_CHANGED(id, func)} |
340e9651 | 31 | The page selection was changed. |
ce7fe42e | 32 | Processes a @c wxEVT_TREEBOOK_PAGE_CHANGED event. |
7977b62a | 33 | @event{EVT_TREEBOOK_PAGE_CHANGING(id, func)} |
340e9651 | 34 | The page selection is about to be changed. |
ce7fe42e | 35 | Processes a @c wxEVT_TREEBOOK_PAGE_CHANGING event. |
340e9651 | 36 | This event can be @ref wxNotifyEvent::Veto() "vetoed". |
7977b62a | 37 | @event{EVT_TREEBOOK_NODE_COLLAPSED(id, func)} |
340e9651 | 38 | The page node is going to be collapsed. |
ce7fe42e | 39 | Processes a @c wxEVT_TREEBOOK_NODE_COLLAPSED event. |
7977b62a | 40 | @event{EVT_TREEBOOK_NODE_EXPANDED(id, func)} |
340e9651 | 41 | The page node is going to be expanded. |
ce7fe42e | 42 | Processes a @c wxEVT_TREEBOOK_NODE_EXPANDED event. |
7977b62a | 43 | @endEventTable |
7c913512 | 44 | |
23324ae1 | 45 | @library{wxcore} |
3c99e2fd | 46 | @category{bookctrl} |
7c913512 | 47 | |
3e97a905 | 48 | @see wxBookCtrl, wxBookCtrlEvent, wxNotebook, wxTreeCtrl, wxImageList, |
7977b62a | 49 | @ref overview_bookctrl, @ref page_samples_notebook |
23324ae1 | 50 | */ |
7977b62a | 51 | class wxTreebook : public wxBookCtrlBase |
23324ae1 FM |
52 | { |
53 | public: | |
23324ae1 | 54 | /** |
7977b62a BP |
55 | Default constructor. |
56 | */ | |
57 | wxTreebook(); | |
58 | ||
59 | /** | |
60 | Creates an empty wxTreebook. | |
3c4f71cc | 61 | |
7c913512 | 62 | @param parent |
4cc4bfaf | 63 | The parent window. Must be non-@NULL. |
7c913512 | 64 | @param id |
4cc4bfaf | 65 | The window identifier. |
7c913512 | 66 | @param pos |
4cc4bfaf | 67 | The window position. |
7c913512 | 68 | @param size |
4cc4bfaf | 69 | The window size. |
7c913512 | 70 | @param style |
4cc4bfaf | 71 | The window style. See wxNotebook. |
7c913512 | 72 | @param name |
4cc4bfaf | 73 | The name of the control (used only under Motif). |
23324ae1 | 74 | */ |
7c913512 FM |
75 | wxTreebook(wxWindow* parent, wxWindowID id, |
76 | const wxPoint& pos = wxDefaultPosition, | |
77 | const wxSize& size = wxDefaultSize, | |
bfb6fde3 | 78 | long style = wxBK_DEFAULT, |
7c913512 | 79 | const wxString& name = wxEmptyString); |
23324ae1 FM |
80 | |
81 | /** | |
340e9651 FM |
82 | Destroys the wxTreebook object. |
83 | Also deletes all the pages owned by the control (inserted previously into it). | |
23324ae1 | 84 | */ |
adaaa686 | 85 | virtual ~wxTreebook(); |
23324ae1 FM |
86 | |
87 | /** | |
7977b62a BP |
88 | Adds a new page. The page is placed at the topmost level after all other |
89 | pages. @NULL could be specified for page to create an empty page. | |
23324ae1 | 90 | */ |
adaaa686 FM |
91 | virtual bool AddPage(wxWindow* page, const wxString& text, |
92 | bool bSelect = false, int imageId = wxNOT_FOUND); | |
23324ae1 FM |
93 | |
94 | /** | |
7977b62a BP |
95 | Adds a new child-page to the last top-level page. @NULL could be |
96 | specified for page to create an empty page. | |
23324ae1 | 97 | */ |
adaaa686 FM |
98 | virtual bool AddSubPage(wxWindow* page, const wxString& text, |
99 | bool bSelect = false, int imageId = wxNOT_FOUND); | |
23324ae1 | 100 | |
23324ae1 FM |
101 | |
102 | /** | |
7977b62a BP |
103 | Shortcut for @ref wxTreebook::ExpandNode() "ExpandNode"( @a pageId, |
104 | @false ). | |
23324ae1 FM |
105 | */ |
106 | bool CollapseNode(size_t pageId); | |
107 | ||
108 | /** | |
7977b62a BP |
109 | Creates a treebook control. See wxTreebook::wxTreebook() for the |
110 | description of the parameters. | |
23324ae1 FM |
111 | */ |
112 | bool Create(wxWindow* parent, wxWindowID id, | |
113 | const wxPoint& pos = wxDefaultPosition, | |
114 | const wxSize& size = wxDefaultSize, | |
bfb6fde3 | 115 | long style = wxBK_DEFAULT, |
23324ae1 FM |
116 | const wxString& name = wxEmptyString); |
117 | ||
118 | /** | |
340e9651 FM |
119 | Deletes the page at the specified position and all its children. |
120 | Could trigger page selection change in a case when selected page is removed. | |
7977b62a | 121 | In that case its parent is selected (or the next page if no parent). |
23324ae1 | 122 | */ |
adaaa686 | 123 | virtual bool DeletePage(size_t pagePos); |
23324ae1 FM |
124 | |
125 | /** | |
340e9651 FM |
126 | Expands (collapses) the @a pageId node. Returns the previous state. |
127 | May generate page changing events (if selected page is under the collapsed | |
7977b62a | 128 | branch, then its parent is autoselected). |
23324ae1 | 129 | */ |
adaaa686 | 130 | virtual bool ExpandNode(size_t pageId, bool expand = true); |
23324ae1 | 131 | |
23324ae1 FM |
132 | /** |
133 | Returns the parent page of the given one or @c wxNOT_FOUND if this is a | |
134 | top-level page. | |
135 | */ | |
328f5751 | 136 | int GetPageParent(size_t page) const; |
23324ae1 FM |
137 | |
138 | /** | |
340e9651 | 139 | Returns the currently selected page, or @c wxNOT_FOUND if none was selected. |
7977b62a BP |
140 | |
141 | @note This method may return either the previously or newly selected | |
340e9651 FM |
142 | page when called from the EVT_TREEBOOK_PAGE_CHANGED() handler |
143 | depending on the platform and so wxBookCtrlEvent::GetSelection() | |
144 | should be used instead in this case. | |
23324ae1 | 145 | */ |
adaaa686 | 146 | virtual int GetSelection() const; |
23324ae1 FM |
147 | |
148 | /** | |
340e9651 FM |
149 | Inserts a new page just before the page indicated by @a pagePos. |
150 | The new page is placed before @a pagePos page and on the same level. | |
151 | @NULL could be specified for page to create an empty page. | |
23324ae1 | 152 | */ |
adaaa686 FM |
153 | virtual bool InsertPage(size_t pagePos, wxWindow* page, |
154 | const wxString& text, bool bSelect = false, | |
155 | int imageId = wxNOT_FOUND); | |
23324ae1 FM |
156 | |
157 | /** | |
158 | Inserts a sub page under the specified page. | |
7977b62a | 159 | |
23324ae1 FM |
160 | @NULL could be specified for page to create an empty page. |
161 | */ | |
adaaa686 FM |
162 | virtual bool InsertSubPage(size_t pagePos, wxWindow* page, |
163 | const wxString& text, bool bSelect = false, | |
164 | int imageId = wxNOT_FOUND); | |
23324ae1 FM |
165 | |
166 | /** | |
7977b62a | 167 | Returns @true if the page represented by @a pageId is expanded. |
23324ae1 | 168 | */ |
adaaa686 | 169 | virtual bool IsNodeExpanded(size_t pageId) const; |
23324ae1 | 170 | }; |
e54c96f1 | 171 |