]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: treebook.h | |
e54c96f1 | 3 | // Purpose: interface of wxTreebookEvent |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxTreebookEvent | |
7c913512 | 11 | |
23324ae1 | 12 | This class represents the events generated by a treebook control: currently, |
7977b62a BP |
13 | there are four of them. The EVT_TREEBOOK_PAGE_CHANGING() and |
14 | EVT_TREEBOOK_PAGE_CHANGED() - have exactly the same behaviour as | |
15 | wxNotebookEvent. | |
16 | ||
17 | The other two EVT_TREEBOOK_NODE_COLLAPSED() and EVT_TREEBOOK_NODE_EXPANDED() | |
18 | are triggered when page node in the tree control is collapsed/expanded. The | |
19 | page index could be retreived by calling GetSelection(). | |
20 | ||
21 | @beginEventTable{wxTreebookEvent} | |
22 | @event{EVT_TREEBOOK_PAGE_CHANGED(id, func)} | |
23 | The page selection was changed. Processes a @c | |
24 | wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED event. | |
25 | @event{EVT_TREEBOOK_PAGE_CHANGING(id, func)} | |
26 | The page selection is about to be changed. Processes a @c | |
27 | wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING event. This event can be @ref | |
28 | wxNotifyEvent::Veto() "vetoed". | |
29 | @event{EVT_TREEBOOK_NODE_COLLAPSED(id, func)} | |
30 | The page node is going to be collapsed. Processes a @c | |
31 | wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED event. | |
32 | @event{EVT_TREEBOOK_NODE_EXPANDED(id, func)} | |
33 | The page node is going to be expanded. Processes a @c | |
34 | wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED event. | |
35 | @endEventTable | |
36 | ||
23324ae1 FM |
37 | @library{wxcore} |
38 | @category{events} | |
7c913512 | 39 | |
7977b62a | 40 | @see wxTreebook, wxNotebookEvent |
23324ae1 FM |
41 | */ |
42 | class wxTreebookEvent : public wxNotifyEvent | |
43 | { | |
44 | public: | |
45 | /** | |
4cc4bfaf | 46 | @see wxNotebookEvent |
23324ae1 | 47 | */ |
4cc4bfaf | 48 | wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
23324ae1 FM |
49 | int nSel = wxNOT_FOUND, |
50 | int nOldSel = wxNOT_FOUND); | |
51 | ||
52 | /** | |
7977b62a BP |
53 | Returns the page that was selected before the change, @c wxNOT_FOUND if |
54 | none was selected. | |
23324ae1 | 55 | */ |
328f5751 | 56 | int GetOldSelection() const; |
23324ae1 FM |
57 | |
58 | /** | |
7977b62a BP |
59 | Returns the currently selected page, or @c wxNOT_FOUND if none was |
60 | selected. | |
61 | ||
62 | @see wxNotebookEvent::GetSelection() | |
23324ae1 | 63 | */ |
328f5751 | 64 | int GetSelection() const; |
23324ae1 FM |
65 | }; |
66 | ||
67 | ||
e54c96f1 | 68 | |
23324ae1 FM |
69 | /** |
70 | @class wxTreebook | |
7c913512 | 71 | |
7977b62a BP |
72 | This class is an extension of the wxNotebook class that allows a tree |
73 | structured set of pages to be shown in a control. A classic example is a | |
74 | netscape preferences dialog that shows a tree of preference sections on | |
75 | the left and select section page on the right. | |
7c913512 | 76 | |
23324ae1 | 77 | To use the class simply create it and populate with pages using |
7977b62a BP |
78 | InsertPage(), InsertSubPage(), AddPage(), AddSubPage(). |
79 | ||
80 | If your tree is no more than 1 level in depth then you could simply use | |
81 | AddPage() and AddSubPage() to sequentially populate your tree by adding at | |
82 | every step a page or a subpage to the end of the tree. | |
83 | ||
84 | @beginEventTable{wxTreebookEvent} | |
85 | @event{EVT_TREEBOOK_PAGE_CHANGED(id, func)} | |
86 | The page selection was changed. Processes a @c | |
87 | wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED event. | |
88 | @event{EVT_TREEBOOK_PAGE_CHANGING(id, func)} | |
89 | The page selection is about to be changed. Processes a @c | |
90 | wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING event. This event can be @ref | |
91 | wxNotifyEvent::Veto() "vetoed". | |
92 | @event{EVT_TREEBOOK_NODE_COLLAPSED(id, func)} | |
93 | The page node is going to be collapsed. Processes a @c | |
94 | wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED event. | |
95 | @event{EVT_TREEBOOK_NODE_EXPANDED(id, func)} | |
96 | The page node is going to be expanded. Processes a @c | |
97 | wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED event. | |
98 | @endEventTable | |
7c913512 | 99 | |
23324ae1 FM |
100 | @library{wxcore} |
101 | @category{miscwnd} | |
7c913512 | 102 | |
7977b62a BP |
103 | @see wxTreebookEvent, wxNotebook, wxTreeCtrl, wxImageList, |
104 | @ref overview_bookctrl, @ref page_samples_notebook | |
23324ae1 | 105 | */ |
7977b62a | 106 | class wxTreebook : public wxBookCtrlBase |
23324ae1 FM |
107 | { |
108 | public: | |
23324ae1 | 109 | /** |
7977b62a BP |
110 | Default constructor. |
111 | */ | |
112 | wxTreebook(); | |
113 | ||
114 | /** | |
115 | Creates an empty wxTreebook. | |
3c4f71cc | 116 | |
7c913512 | 117 | @param parent |
4cc4bfaf | 118 | The parent window. Must be non-@NULL. |
7c913512 | 119 | @param id |
4cc4bfaf | 120 | The window identifier. |
7c913512 | 121 | @param pos |
4cc4bfaf | 122 | The window position. |
7c913512 | 123 | @param size |
4cc4bfaf | 124 | The window size. |
7c913512 | 125 | @param style |
4cc4bfaf | 126 | The window style. See wxNotebook. |
7c913512 | 127 | @param name |
4cc4bfaf | 128 | The name of the control (used only under Motif). |
23324ae1 | 129 | */ |
7c913512 FM |
130 | wxTreebook(wxWindow* parent, wxWindowID id, |
131 | const wxPoint& pos = wxDefaultPosition, | |
132 | const wxSize& size = wxDefaultSize, | |
bfb6fde3 | 133 | long style = wxBK_DEFAULT, |
7c913512 | 134 | const wxString& name = wxEmptyString); |
23324ae1 FM |
135 | |
136 | /** | |
7977b62a BP |
137 | Destroys the wxTreebook object. Also deletes all the pages owned by the |
138 | control (inserted previously into it). | |
23324ae1 FM |
139 | */ |
140 | ~wxTreebook(); | |
141 | ||
142 | /** | |
7977b62a BP |
143 | Adds a new page. The page is placed at the topmost level after all other |
144 | pages. @NULL could be specified for page to create an empty page. | |
23324ae1 FM |
145 | */ |
146 | bool AddPage(wxWindow* page, const wxString& text, | |
4cc4bfaf | 147 | bool bSelect = false, |
23324ae1 FM |
148 | int imageId = wxNOT_FOUND); |
149 | ||
150 | /** | |
7977b62a BP |
151 | Adds a new child-page to the last top-level page. @NULL could be |
152 | specified for page to create an empty page. | |
23324ae1 FM |
153 | */ |
154 | bool AddSubPage(wxWindow* page, const wxString& text, | |
4cc4bfaf | 155 | bool bSelect = false, |
23324ae1 FM |
156 | int imageId = wxNOT_FOUND); |
157 | ||
158 | /** | |
7977b62a BP |
159 | Sets the image list for the page control and takes ownership of the |
160 | list. | |
3c4f71cc | 161 | |
4cc4bfaf | 162 | @see wxImageList, SetImageList() |
23324ae1 FM |
163 | */ |
164 | void AssignImageList(wxImageList* imageList); | |
165 | ||
166 | /** | |
7977b62a BP |
167 | Changes the selection for the given page, returning the previous |
168 | selection. | |
169 | ||
23324ae1 | 170 | The call to this function does not generate the page changing events. |
7977b62a BP |
171 | This is the only difference with SetSelection(). See |
172 | @ref overview_eventhandling_prog for more info. | |
23324ae1 FM |
173 | */ |
174 | int ChangeSelection(size_t page); | |
175 | ||
176 | /** | |
7977b62a BP |
177 | Shortcut for @ref wxTreebook::ExpandNode() "ExpandNode"( @a pageId, |
178 | @false ). | |
23324ae1 FM |
179 | */ |
180 | bool CollapseNode(size_t pageId); | |
181 | ||
182 | /** | |
7977b62a BP |
183 | Creates a treebook control. See wxTreebook::wxTreebook() for the |
184 | description of the parameters. | |
23324ae1 FM |
185 | */ |
186 | bool Create(wxWindow* parent, wxWindowID id, | |
187 | const wxPoint& pos = wxDefaultPosition, | |
188 | const wxSize& size = wxDefaultSize, | |
bfb6fde3 | 189 | long style = wxBK_DEFAULT, |
23324ae1 FM |
190 | const wxString& name = wxEmptyString); |
191 | ||
192 | /** | |
193 | Deletes all pages inserted into the treebook. No event is generated. | |
194 | */ | |
195 | bool DeleteAllPages(); | |
196 | ||
197 | /** | |
7977b62a BP |
198 | Deletes the page at the specified position and all its children. Could |
199 | trigger page selection change in a case when selected page is removed. | |
200 | In that case its parent is selected (or the next page if no parent). | |
23324ae1 FM |
201 | */ |
202 | bool DeletePage(size_t pagePos); | |
203 | ||
204 | /** | |
7977b62a BP |
205 | Expands (collapses) the @a pageId node. Returns the previous state. May |
206 | generate page changing events (if selected page is under the collapsed | |
207 | branch, then its parent is autoselected). | |
23324ae1 | 208 | */ |
4cc4bfaf | 209 | bool ExpandNode(size_t pageId, bool expand = true); |
23324ae1 FM |
210 | |
211 | /** | |
212 | Returns the image index for the given page. | |
213 | */ | |
328f5751 | 214 | int GetPageImage(size_t n) const; |
23324ae1 FM |
215 | |
216 | /** | |
217 | Returns the parent page of the given one or @c wxNOT_FOUND if this is a | |
218 | top-level page. | |
219 | */ | |
328f5751 | 220 | int GetPageParent(size_t page) const; |
23324ae1 FM |
221 | |
222 | /** | |
223 | Returns the string for the given page. | |
224 | */ | |
328f5751 | 225 | wxString GetPageText(size_t n) const; |
23324ae1 FM |
226 | |
227 | /** | |
7977b62a BP |
228 | Returns the currently selected page, or @c wxNOT_FOUND if none was |
229 | selected. | |
230 | ||
231 | @note This method may return either the previously or newly selected | |
232 | page when called from the EVT_TREEBOOK_PAGE_CHANGED() handler | |
233 | depending on the platform and so wxTreebookEvent::GetSelection() | |
234 | should be used instead in this case. | |
23324ae1 | 235 | */ |
328f5751 | 236 | int GetSelection() const; |
23324ae1 FM |
237 | |
238 | /** | |
7977b62a BP |
239 | Inserts a new page just before the page indicated by @a pagePos. The new |
240 | page is placed before @a pagePos page and on the same level. @NULL could | |
241 | be specified for page to create an empty page. | |
23324ae1 FM |
242 | */ |
243 | bool InsertPage(size_t pagePos, wxWindow* page, | |
244 | const wxString& text, | |
4cc4bfaf | 245 | bool bSelect = false, |
23324ae1 FM |
246 | int imageId = wxNOT_FOUND); |
247 | ||
248 | /** | |
249 | Inserts a sub page under the specified page. | |
7977b62a | 250 | |
23324ae1 FM |
251 | @NULL could be specified for page to create an empty page. |
252 | */ | |
253 | bool InsertSubPage(size_t pagePos, wxWindow* page, | |
254 | const wxString& text, | |
4cc4bfaf | 255 | bool bSelect = false, |
23324ae1 FM |
256 | int imageId = wxNOT_FOUND); |
257 | ||
258 | /** | |
7977b62a | 259 | Returns @true if the page represented by @a pageId is expanded. |
23324ae1 | 260 | */ |
328f5751 | 261 | bool IsNodeExpanded(size_t pageId) const; |
23324ae1 FM |
262 | |
263 | /** | |
7977b62a BP |
264 | Sets the image list for the page control. It does not take ownership of |
265 | the image list, you must delete it yourself. | |
3c4f71cc | 266 | |
4cc4bfaf | 267 | @see wxImageList, AssignImageList() |
23324ae1 FM |
268 | */ |
269 | void SetImageList(wxImageList* imageList); | |
270 | ||
271 | /** | |
7977b62a BP |
272 | Sets the image index for the given @a page. @a imageId is an index into |
273 | the image list which was set with SetImageList(). | |
23324ae1 FM |
274 | */ |
275 | bool SetPageImage(size_t page, int imageId); | |
276 | ||
277 | /** | |
7977b62a | 278 | Sets the @a text for the given @a page. |
23324ae1 FM |
279 | */ |
280 | bool SetPageText(size_t page, const wxString& text); | |
281 | ||
282 | /** | |
7977b62a BP |
283 | @deprecated Please use ChangeSelection() instead. |
284 | ||
23324ae1 | 285 | Sets the selection for the given page, returning the previous selection. |
3c4f71cc | 286 | |
7977b62a BP |
287 | The call to this function generates page changing events. |
288 | ||
289 | @see GetSelection(), ChangeSelection() | |
23324ae1 FM |
290 | */ |
291 | int SetSelection(size_t n); | |
292 | }; | |
e54c96f1 | 293 |