]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/treebook.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTreebookEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxTreebookEvent
12 This class represents the events generated by a treebook control: currently,
13 there are four of them. The EVT_TREEBOOK_PAGE_CHANGING() and
14 EVT_TREEBOOK_PAGE_CHANGED() - have exactly the same behaviour as
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().
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.
40 @see wxTreebook, wxNotebookEvent
42 class wxTreebookEvent
: public wxNotifyEvent
48 wxTreebookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
49 int nSel
= wxNOT_FOUND
,
50 int nOldSel
= wxNOT_FOUND
);
53 Returns the page that was selected before the change, @c wxNOT_FOUND if
56 int GetOldSelection() const;
59 Returns the currently selected page, or @c wxNOT_FOUND if none was
62 @see wxNotebookEvent::GetSelection()
64 int GetSelection() const;
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.
77 To use the class simply create it and populate with pages using
78 InsertPage(), InsertSubPage(), AddPage(), AddSubPage().
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.
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.
103 @see wxTreebookEvent, wxNotebook, wxTreeCtrl, wxImageList,
104 @ref overview_bookctrl, @ref page_samples_notebook
106 class wxTreebook
: public wxBookCtrlBase
115 Creates an empty wxTreebook.
118 The parent window. Must be non-@NULL.
120 The window identifier.
126 The window style. See wxNotebook.
128 The name of the control (used only under Motif).
130 wxTreebook(wxWindow
* parent
, wxWindowID id
,
131 const wxPoint
& pos
= wxDefaultPosition
,
132 const wxSize
& size
= wxDefaultSize
,
133 long style
= wxBK_DEFAULT
,
134 const wxString
& name
= wxEmptyString
);
137 Destroys the wxTreebook object. Also deletes all the pages owned by the
138 control (inserted previously into it).
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.
146 bool AddPage(wxWindow
* page
, const wxString
& text
,
147 bool bSelect
= false,
148 int imageId
= wxNOT_FOUND
);
151 Adds a new child-page to the last top-level page. @NULL could be
152 specified for page to create an empty page.
154 bool AddSubPage(wxWindow
* page
, const wxString
& text
,
155 bool bSelect
= false,
156 int imageId
= wxNOT_FOUND
);
159 Sets the image list for the page control and takes ownership of the
162 @see wxImageList, SetImageList()
164 void AssignImageList(wxImageList
* imageList
);
167 Changes the selection for the given page, returning the previous
170 The call to this function does not generate the page changing events.
171 This is the only difference with SetSelection(). See
172 @ref overview_eventhandling_prog for more info.
174 int ChangeSelection(size_t page
);
177 Shortcut for @ref wxTreebook::ExpandNode() "ExpandNode"( @a pageId,
180 bool CollapseNode(size_t pageId
);
183 Creates a treebook control. See wxTreebook::wxTreebook() for the
184 description of the parameters.
186 bool Create(wxWindow
* parent
, wxWindowID id
,
187 const wxPoint
& pos
= wxDefaultPosition
,
188 const wxSize
& size
= wxDefaultSize
,
189 long style
= wxBK_DEFAULT
,
190 const wxString
& name
= wxEmptyString
);
193 Deletes all pages inserted into the treebook. No event is generated.
195 bool DeleteAllPages();
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).
202 bool DeletePage(size_t pagePos
);
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).
209 bool ExpandNode(size_t pageId
, bool expand
= true);
212 Returns the image index for the given page.
214 int GetPageImage(size_t n
) const;
217 Returns the parent page of the given one or @c wxNOT_FOUND if this is a
220 int GetPageParent(size_t page
) const;
223 Returns the string for the given page.
225 wxString
GetPageText(size_t n
) const;
228 Returns the currently selected page, or @c wxNOT_FOUND if none was
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.
236 int GetSelection() const;
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.
243 bool InsertPage(size_t pagePos
, wxWindow
* page
,
244 const wxString
& text
,
245 bool bSelect
= false,
246 int imageId
= wxNOT_FOUND
);
249 Inserts a sub page under the specified page.
251 @NULL could be specified for page to create an empty page.
253 bool InsertSubPage(size_t pagePos
, wxWindow
* page
,
254 const wxString
& text
,
255 bool bSelect
= false,
256 int imageId
= wxNOT_FOUND
);
259 Returns @true if the page represented by @a pageId is expanded.
261 bool IsNodeExpanded(size_t pageId
) const;
264 Sets the image list for the page control. It does not take ownership of
265 the image list, you must delete it yourself.
267 @see wxImageList, AssignImageList()
269 void SetImageList(wxImageList
* imageList
);
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().
275 bool SetPageImage(size_t page
, int imageId
);
278 Sets the @a text for the given @a page.
280 bool SetPageText(size_t page
, const wxString
& text
);
283 @deprecated Please use ChangeSelection() instead.
285 Sets the selection for the given page, returning the previous selection.
287 The call to this function generates page changing events.
289 @see GetSelection(), ChangeSelection()
291 int SetSelection(size_t n
);