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