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