]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/treebook.h
added wxTaskBarIcon::IsAvailable
[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 license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxTreebook
11
12 This class is an extension of the wxNotebook class that allows a tree
13 structured set of pages to be shown in a control. A classic example is a
14 netscape preferences dialog that shows a tree of preference sections on
15 the left and select section page on the right.
16
17 To use the class simply create it and populate with pages using
18 InsertPage(), InsertSubPage(), AddPage(), AddSubPage().
19
20 If your tree is no more than 1 level in depth then you could simply use
21 AddPage() and AddSubPage() to sequentially populate your tree by adding at
22 every step a page or a subpage to the end of the tree.
23
24 @beginEventTable{wxBookCtrlEvent}
25 @event{EVT_TREEBOOK_PAGE_CHANGED(id, func)}
26 The page selection was changed. Processes a @c
27 wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED event.
28 @event{EVT_TREEBOOK_PAGE_CHANGING(id, func)}
29 The page selection is about to be changed. Processes a @c
30 wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING event. This event can be @ref
31 wxNotifyEvent::Veto() "vetoed".
32 @event{EVT_TREEBOOK_NODE_COLLAPSED(id, func)}
33 The page node is going to be collapsed. Processes a @c
34 wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED event.
35 @event{EVT_TREEBOOK_NODE_EXPANDED(id, func)}
36 The page node is going to be expanded. Processes a @c
37 wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED event.
38 @endEventTable
39
40 @library{wxcore}
41 @category{miscwnd}
42
43 @see wxBookCtrl, wxBookCtrlEvent, wxNotebook, wxTreeCtrl, wxImageList,
44 @ref overview_bookctrl, @ref page_samples_notebook
45 */
46 class wxTreebook : public wxBookCtrlBase
47 {
48 public:
49 /**
50 Default constructor.
51 */
52 wxTreebook();
53
54 /**
55 Creates an empty wxTreebook.
56
57 @param parent
58 The parent window. Must be non-@NULL.
59 @param id
60 The window identifier.
61 @param pos
62 The window position.
63 @param size
64 The window size.
65 @param style
66 The window style. See wxNotebook.
67 @param name
68 The name of the control (used only under Motif).
69 */
70 wxTreebook(wxWindow* parent, wxWindowID id,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = wxBK_DEFAULT,
74 const wxString& name = wxEmptyString);
75
76 /**
77 Destroys the wxTreebook object. Also deletes all the pages owned by the
78 control (inserted previously into it).
79 */
80 virtual ~wxTreebook();
81
82 /**
83 Adds a new page. The page is placed at the topmost level after all other
84 pages. @NULL could be specified for page to create an empty page.
85 */
86 virtual bool AddPage(wxWindow* page, const wxString& text,
87 bool bSelect = false, int imageId = wxNOT_FOUND);
88
89 /**
90 Adds a new child-page to the last top-level page. @NULL could be
91 specified for page to create an empty page.
92 */
93 virtual bool AddSubPage(wxWindow* page, const wxString& text,
94 bool bSelect = false, int imageId = wxNOT_FOUND);
95
96 /**
97 Sets the image list for the page control and takes ownership of the
98 list.
99
100 @see wxImageList, SetImageList()
101 */
102 virtual void AssignImageList(wxImageList* imageList);
103
104 /**
105 Changes the selection for the given page, returning the previous
106 selection.
107
108 The call to this function does not generate the page changing events.
109 This is the only difference with SetSelection(). See
110 @ref overview_eventhandling_prog for more info.
111 */
112 virtual int ChangeSelection(size_t page);
113
114 /**
115 Shortcut for @ref wxTreebook::ExpandNode() "ExpandNode"( @a pageId,
116 @false ).
117 */
118 bool CollapseNode(size_t pageId);
119
120 /**
121 Creates a treebook control. See wxTreebook::wxTreebook() for the
122 description of the parameters.
123 */
124 bool Create(wxWindow* parent, wxWindowID id,
125 const wxPoint& pos = wxDefaultPosition,
126 const wxSize& size = wxDefaultSize,
127 long style = wxBK_DEFAULT,
128 const wxString& name = wxEmptyString);
129
130 /**
131 Deletes all pages inserted into the treebook. No event is generated.
132 */
133 virtual bool DeleteAllPages();
134
135 /**
136 Deletes the page at the specified position and all its children. Could
137 trigger page selection change in a case when selected page is removed.
138 In that case its parent is selected (or the next page if no parent).
139 */
140 virtual bool DeletePage(size_t pagePos);
141
142 /**
143 Expands (collapses) the @a pageId node. Returns the previous state. May
144 generate page changing events (if selected page is under the collapsed
145 branch, then its parent is autoselected).
146 */
147 virtual bool ExpandNode(size_t pageId, bool expand = true);
148
149 /**
150 Returns the image index for the given page.
151 */
152 virtual int GetPageImage(size_t n) const;
153
154 /**
155 Returns the parent page of the given one or @c wxNOT_FOUND if this is a
156 top-level page.
157 */
158 int GetPageParent(size_t page) const;
159
160 /**
161 Returns the string for the given page.
162 */
163 virtual wxString GetPageText(size_t n) const;
164
165 /**
166 Returns the currently selected page, or @c wxNOT_FOUND if none was
167 selected.
168
169 @note This method may return either the previously or newly selected
170 page when called from the EVT_TREEBOOK_PAGE_CHANGED() handler
171 depending on the platform and so wxBookCtrlEvent::GetSelection()
172 should be used instead in this case.
173 */
174 virtual int GetSelection() const;
175
176 /**
177 Inserts a new page just before the page indicated by @a pagePos. The new
178 page is placed before @a pagePos page and on the same level. @NULL could
179 be specified for page to create an empty page.
180 */
181 virtual bool InsertPage(size_t pagePos, wxWindow* page,
182 const wxString& text, bool bSelect = false,
183 int imageId = wxNOT_FOUND);
184
185 /**
186 Inserts a sub page under the specified page.
187
188 @NULL could be specified for page to create an empty page.
189 */
190 virtual bool InsertSubPage(size_t pagePos, wxWindow* page,
191 const wxString& text, bool bSelect = false,
192 int imageId = wxNOT_FOUND);
193
194 /**
195 Returns @true if the page represented by @a pageId is expanded.
196 */
197 virtual bool IsNodeExpanded(size_t pageId) const;
198
199 /**
200 Sets the image list for the page control. It does not take ownership of
201 the image list, you must delete it yourself.
202
203 @see wxImageList, AssignImageList()
204 */
205 virtual void SetImageList(wxImageList* imageList);
206
207 /**
208 Sets the image index for the given @a page. @a imageId is an index into
209 the image list which was set with SetImageList().
210 */
211 virtual bool SetPageImage(size_t page, int imageId);
212
213 /**
214 Sets the @a text for the given @a page.
215 */
216 virtual bool SetPageText(size_t page, const wxString& text);
217
218 /**
219 @deprecated Please use ChangeSelection() instead.
220
221 Sets the selection for the given page, returning the previous selection.
222
223 The call to this function generates page changing events.
224
225 @see GetSelection(), ChangeSelection()
226 */
227 virtual int SetSelection(size_t n);
228 };
229