]>
Commit | Line | Data |
---|---|---|
f135ff73 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: treectrl.h | |
3 | // Purpose: wxTreeCtrl class | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1997,1998 Robert Roebling | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _GENERIC_TREECTRL_H_ | |
13 | #define _GENERIC_TREECTRL_H_ | |
c801d85f KB |
14 | |
15 | #ifdef __GNUG__ | |
f135ff73 | 16 | #pragma interface "treectrl.h" |
c801d85f KB |
17 | #endif |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/string.h" | |
f135ff73 | 21 | #include "wx/object.h" |
c801d85f | 22 | #include "wx/event.h" |
c801d85f | 23 | #include "wx/scrolwin.h" |
f135ff73 | 24 | #include "wx/textctrl.h" |
c801d85f | 25 | |
4f22cf8d RR |
26 | // ----------------------------------------------------------------------------- |
27 | // constants | |
28 | // ----------------------------------------------------------------------------- | |
29 | ||
30 | // values for the `flags' parameter of wxTreeCtrl::HitTest() which determine | |
31 | // where exactly the specified point is situated: | |
32 | static const int wxTREE_HITTEST_NOWHERE = 0x0004; | |
33 | // on the bitmap associated with an item. | |
34 | static const int wxTREE_HITTEST_ONITEMICON = 0x0020; | |
35 | // on the label (string) associated with an item. | |
36 | static const int wxTREE_HITTEST_ONITEMLABEL = 0x0080; | |
37 | // anywhere on the item | |
38 | static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON | | |
39 | wxTREE_HITTEST_ONITEMLABEL; | |
40 | ||
f135ff73 VZ |
41 | // ----------------------------------------------------------------------------- |
42 | // forward declaration | |
43 | // ----------------------------------------------------------------------------- | |
c801d85f | 44 | |
f135ff73 | 45 | class wxImageList; |
c801d85f | 46 | class wxGenericTreeItem; |
c801d85f | 47 | |
f135ff73 | 48 | class wxTreeItemData; |
74bedbeb | 49 | |
f135ff73 VZ |
50 | // ----------------------------------------------------------------------------- |
51 | // wxTreeItemId - unique identifier of a tree element | |
52 | // ----------------------------------------------------------------------------- | |
c801d85f | 53 | |
f135ff73 VZ |
54 | class WXDLLEXPORT wxTreeItemId |
55 | { | |
56 | friend class wxTreeCtrl; | |
57 | friend class wxTreeEvent; | |
58 | public: | |
59 | // ctors | |
60 | // 0 is invalid value for HTREEITEM | |
61 | wxTreeItemId() { m_pItem = 0; } | |
62 | ||
63 | // default copy ctor/assignment operator are ok for us | |
64 | ||
65 | // accessors | |
66 | // is this a valid tree item? | |
67 | bool IsOk() const { return m_pItem != 0; } | |
c801d85f | 68 | |
f135ff73 VZ |
69 | // deprecated: only for compatibility |
70 | wxTreeItemId(long itemId) { m_pItem = (wxGenericTreeItem *)itemId; } | |
71 | operator long() const { return (long)m_pItem; } | |
72 | ||
6daa0637 | 73 | //protected: // not for gcc |
f135ff73 VZ |
74 | // for wxTreeCtrl usage only |
75 | wxTreeItemId(wxGenericTreeItem *pItem) { m_pItem = pItem; } | |
ef44a621 | 76 | |
f135ff73 | 77 | wxGenericTreeItem *m_pItem; |
c801d85f KB |
78 | }; |
79 | ||
f135ff73 VZ |
80 | // ---------------------------------------------------------------------------- |
81 | // wxTreeItemData is some (arbitrary) user class associated with some item. | |
82 | // | |
83 | // Because the objects of this class are deleted by the tree, they should | |
84 | // always be allocated on the heap! | |
85 | // ---------------------------------------------------------------------------- | |
fd0eed64 | 86 | class WXDLLEXPORT wxTreeItemData: public wxClientData |
c801d85f | 87 | { |
f135ff73 | 88 | friend class wxTreeCtrl; |
a32dd690 | 89 | public: |
f135ff73 VZ |
90 | // creation/destruction |
91 | // -------------------- | |
92 | // default ctor | |
93 | wxTreeItemData() { } | |
94 | ||
95 | // default copy ctor/assignment operator are ok | |
96 | ||
f135ff73 VZ |
97 | // accessor: get the item associated with us |
98 | const wxTreeItemId& GetId() const { return m_pItem; } | |
99 | void SetId(const wxTreeItemId& id) { m_pItem = id; } | |
c801d85f | 100 | |
f135ff73 VZ |
101 | protected: |
102 | wxTreeItemId m_pItem; | |
103 | }; | |
104 | ||
105 | // ----------------------------------------------------------------------------- | |
106 | // wxTreeEvent - the event generated by the tree control | |
107 | // ----------------------------------------------------------------------------- | |
92976ab6 | 108 | class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent |
c801d85f | 109 | { |
f135ff73 VZ |
110 | friend class wxTreeCtrl; |
111 | public: | |
112 | wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0); | |
113 | ||
114 | // accessors | |
115 | // get the item on which the operation was performed or the newly | |
116 | // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events | |
117 | wxTreeItemId GetItem() const { return m_item; } | |
c801d85f | 118 | |
f135ff73 VZ |
119 | // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously |
120 | // selected item | |
121 | wxTreeItemId GetOldItem() const { return m_itemOld; } | |
c801d85f | 122 | |
f135ff73 VZ |
123 | // the point where the mouse was when the drag operation started (for |
124 | // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) | |
125 | wxPoint GetPoint() const { return m_pointDrag; } | |
64693098 | 126 | |
f135ff73 VZ |
127 | // keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only) |
128 | int GetCode() const { return m_code; } | |
129 | ||
130 | // set return code for wxEVT_COMMAND_TREE_ITEM_{EXPAND|COLLAPS}ING events | |
131 | // call this to forbid the change in item status | |
132 | void Veto() { m_code = TRUE; } | |
133 | ||
134 | // for implementation usage only | |
135 | bool WasVetoed() const { return m_code; } | |
136 | ||
137 | private: | |
138 | // @@ we could save some space by using union here | |
139 | int m_code; | |
140 | wxTreeItemId m_item, | |
141 | m_itemOld; | |
142 | wxPoint m_pointDrag; | |
143 | ||
144 | DECLARE_DYNAMIC_CLASS(wxTreeEvent) | |
c801d85f KB |
145 | }; |
146 | ||
147 | typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&); | |
148 | ||
f135ff73 VZ |
149 | // ---------------------------------------------------------------------------- |
150 | // macros for handling tree control events | |
151 | // ---------------------------------------------------------------------------- | |
152 | ||
153 | // GetItem() returns the item being dragged, GetPoint() the mouse coords | |
c67daf87 UR |
154 | #define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, |
155 | #define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
f135ff73 VZ |
156 | |
157 | // GetItem() returns the itme whose label is being edited | |
c67daf87 UR |
158 | #define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, |
159 | #define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
f135ff73 VZ |
160 | |
161 | // provide/update information about GetItem() item | |
c67daf87 UR |
162 | #define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, |
163 | #define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
f135ff73 | 164 | |
ef44a621 | 165 | // GetItem() is the item being expanded/collapsed, the "ING" versions can use |
c67daf87 UR |
166 | #define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, |
167 | #define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
168 | #define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
f135ff73 | 169 | #define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, |
c801d85f | 170 | |
f135ff73 VZ |
171 | // GetOldItem() is the item which had the selection previously, GetItem() is |
172 | // the item which acquires selection | |
173 | #define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
174 | #define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
c801d85f | 175 | |
f135ff73 VZ |
176 | // GetCode() returns the key code |
177 | // NB: this is the only message for which GetItem() is invalid (you may get the | |
178 | // item from GetSelection()) | |
179 | #define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
c801d85f | 180 | |
f135ff73 VZ |
181 | // GetItem() returns the item being deleted, the associated data (if any) will |
182 | // be deleted just after the return of this event handler (if any) | |
183 | #define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
184 | ||
435fe83e RR |
185 | // GetItem() returns the item that was activated (double click, enter, space) |
186 | #define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
187 | ||
f135ff73 VZ |
188 | // ----------------------------------------------------------------------------- |
189 | // wxTreeCtrl - the tree control | |
190 | // ----------------------------------------------------------------------------- | |
c801d85f | 191 | |
f135ff73 | 192 | class WXDLLEXPORT wxTreeCtrl : public wxScrolledWindow |
c801d85f | 193 | { |
a32dd690 | 194 | public: |
f135ff73 VZ |
195 | // creation |
196 | // -------- | |
197 | wxTreeCtrl() { Init(); } | |
198 | ||
199 | wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, | |
200 | const wxPoint& pos = wxDefaultPosition, | |
201 | const wxSize& size = wxDefaultSize, | |
202 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, | |
4f22cf8d | 203 | const wxValidator &validator = wxDefaultValidator, |
f135ff73 VZ |
204 | const wxString& name = "wxTreeCtrl") |
205 | { | |
4f22cf8d | 206 | Create(parent, id, pos, size, style, validator, name); |
f135ff73 VZ |
207 | } |
208 | ||
209 | virtual ~wxTreeCtrl(); | |
210 | ||
211 | bool Create(wxWindow *parent, wxWindowID id = -1, | |
212 | const wxPoint& pos = wxDefaultPosition, | |
213 | const wxSize& size = wxDefaultSize, | |
214 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, | |
4f22cf8d | 215 | const wxValidator &validator = wxDefaultValidator, |
f135ff73 VZ |
216 | const wxString& name = "wxTreeCtrl"); |
217 | ||
218 | // accessors | |
219 | // --------- | |
220 | ||
221 | // get the total number of items in the control | |
222 | size_t GetCount() const; | |
223 | ||
224 | // indent is the number of pixels the children are indented relative to | |
225 | // the parents position. SetIndent() also redraws the control | |
226 | // immediately. | |
227 | unsigned int GetIndent() const { return m_indent; } | |
228 | void SetIndent(unsigned int indent); | |
229 | ||
230 | // image list: these functions allow to associate an image list with | |
231 | // the control and retrieve it. Note that the control does _not_ delete | |
232 | // the associated image list when it's deleted in order to allow image | |
233 | // lists to be shared between different controls. | |
234 | // | |
235 | // The normal image list is for the icons which correspond to the | |
236 | // normal tree item state (whether it is selected or not). | |
237 | // Additionally, the application might choose to show a state icon | |
238 | // which corresponds to an app-defined item state (for example, | |
239 | // checked/unchecked) which are taken from the state image list. | |
240 | wxImageList *GetImageList() const; | |
241 | wxImageList *GetStateImageList() const; | |
242 | ||
243 | void SetImageList(wxImageList *imageList); | |
244 | void SetStateImageList(wxImageList *imageList); | |
245 | ||
246 | // Functions to work with tree ctrl items. | |
247 | ||
248 | // accessors | |
249 | // --------- | |
250 | ||
251 | // retrieve items label | |
252 | wxString GetItemText(const wxTreeItemId& item) const; | |
253 | // get the normal item image | |
254 | int GetItemImage(const wxTreeItemId& item) const; | |
255 | // get the selected item image | |
256 | int GetItemSelectedImage(const wxTreeItemId& item) const; | |
257 | // get the data associated with the item | |
258 | wxTreeItemData *GetItemData(const wxTreeItemId& item) const; | |
259 | ||
260 | // modifiers | |
261 | // --------- | |
262 | ||
263 | // set items label | |
264 | void SetItemText(const wxTreeItemId& item, const wxString& text); | |
265 | // set the normal item image | |
266 | void SetItemImage(const wxTreeItemId& item, int image); | |
267 | // set the selected item image | |
268 | void SetItemSelectedImage(const wxTreeItemId& item, int image); | |
269 | // associate some data with the item | |
270 | void SetItemData(const wxTreeItemId& item, wxTreeItemData *data); | |
271 | ||
272 | // force appearance of [+] button near the item. This is useful to | |
273 | // allow the user to expand the items which don't have any children now | |
274 | // - but instead add them only when needed, thus minimizing memory | |
275 | // usage and loading time. | |
276 | void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE); | |
277 | ||
ef44a621 VZ |
278 | // the item will be shown in bold |
279 | void SetItemBold(const wxTreeItemId& item, bool bold = TRUE); | |
280 | ||
f135ff73 VZ |
281 | // item status inquiries |
282 | // --------------------- | |
283 | ||
284 | // is the item visible (it might be outside the view or not expanded)? | |
285 | bool IsVisible(const wxTreeItemId& item) const; | |
286 | // does the item has any children? | |
6daa0637 RR |
287 | bool HasChildren(const wxTreeItemId& item) const |
288 | { return ItemHasChildren(item); } | |
f135ff73 VZ |
289 | bool ItemHasChildren(const wxTreeItemId& item) const; |
290 | // is the item expanded (only makes sense if HasChildren())? | |
291 | bool IsExpanded(const wxTreeItemId& item) const; | |
292 | // is this item currently selected (the same as has focus)? | |
293 | bool IsSelected(const wxTreeItemId& item) const; | |
ef44a621 VZ |
294 | // is item text in bold font? |
295 | bool IsBold(const wxTreeItemId& item) const; | |
f135ff73 | 296 | |
4832f7c0 VZ |
297 | // number of children |
298 | // ------------------ | |
299 | ||
300 | // if 'recursively' is FALSE, only immediate children count, otherwise | |
301 | // the returned number is the number of all items in this branch | |
302 | size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); | |
303 | ||
f135ff73 VZ |
304 | // navigation |
305 | // ---------- | |
306 | ||
307 | // wxTreeItemId.IsOk() will return FALSE if there is no such item | |
308 | ||
309 | // get the root tree item | |
310 | wxTreeItemId GetRootItem() const { return m_anchor; } | |
311 | ||
312 | // get the item currently selected (may return NULL if no selection) | |
313 | wxTreeItemId GetSelection() const { return m_current; } | |
314 | ||
315 | // get the parent of this item (may return NULL if root) | |
316 | wxTreeItemId GetParent(const wxTreeItemId& item) const; | |
317 | ||
318 | // for this enumeration function you must pass in a "cookie" parameter | |
319 | // which is opaque for the application but is necessary for the library | |
320 | // to make these functions reentrant (i.e. allow more than one | |
321 | // enumeration on one and the same object simultaneously). Of course, | |
322 | // the "cookie" passed to GetFirstChild() and GetNextChild() should be | |
323 | // the same! | |
324 | ||
325 | // get the first child of this item | |
326 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const; | |
327 | // get the next child | |
328 | wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const; | |
329 | ||
330 | // get the next sibling of this item | |
331 | wxTreeItemId GetNextSibling(const wxTreeItemId& item) const; | |
332 | // get the previous sibling | |
333 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const; | |
334 | ||
335 | // get first visible item | |
336 | wxTreeItemId GetFirstVisibleItem() const; | |
337 | // get the next visible item: item must be visible itself! | |
338 | // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem() | |
339 | wxTreeItemId GetNextVisible(const wxTreeItemId& item) const; | |
340 | // get the previous visible item: item must be visible itself! | |
341 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const; | |
342 | ||
343 | // operations | |
344 | // ---------- | |
345 | ||
346 | // add the root node to the tree | |
347 | wxTreeItemId AddRoot(const wxString& text, | |
348 | int image = -1, int selectedImage = -1, | |
349 | wxTreeItemData *data = NULL); | |
350 | ||
351 | // insert a new item in as the first child of the parent | |
352 | wxTreeItemId PrependItem(const wxTreeItemId& parent, | |
353 | const wxString& text, | |
354 | int image = -1, int selectedImage = -1, | |
355 | wxTreeItemData *data = NULL); | |
356 | ||
357 | // insert a new item after a given one | |
358 | wxTreeItemId InsertItem(const wxTreeItemId& parent, | |
359 | const wxTreeItemId& idPrevious, | |
360 | const wxString& text, | |
361 | int image = -1, int selectedImage = -1, | |
362 | wxTreeItemData *data = NULL); | |
363 | ||
364 | // insert a new item in as the last child of the parent | |
365 | wxTreeItemId AppendItem(const wxTreeItemId& parent, | |
366 | const wxString& text, | |
367 | int image = -1, int selectedImage = -1, | |
368 | wxTreeItemData *data = NULL); | |
369 | ||
370 | // delete this item and associated data if any | |
371 | void Delete(const wxTreeItemId& item); | |
372edb9d VZ |
372 | // delete all children (but don't delete the item itself) |
373 | // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events | |
374 | void DeleteChildren(const wxTreeItemId& item); | |
f135ff73 | 375 | // delete all items from the tree |
372edb9d | 376 | // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events |
f135ff73 VZ |
377 | void DeleteAllItems(); |
378 | ||
379 | // expand this item | |
380 | void Expand(const wxTreeItemId& item); | |
381 | // collapse the item without removing its children | |
382 | void Collapse(const wxTreeItemId& item); | |
383 | // collapse the item and remove all children | |
384 | void CollapseAndReset(const wxTreeItemId& item); | |
385 | // toggles the current state | |
386 | void Toggle(const wxTreeItemId& item); | |
387 | ||
388 | // remove the selection from currently selected item (if any) | |
389 | void Unselect(); | |
390 | // select this item | |
391 | void SelectItem(const wxTreeItemId& item); | |
392 | // make sure this item is visible (expanding the parent item and/or | |
393 | // scrolling to this item if necessary) | |
394 | void EnsureVisible(const wxTreeItemId& item); | |
395 | // scroll to this item (but don't expand its parent) | |
396 | void ScrollTo(const wxTreeItemId& item); | |
397 | ||
4f22cf8d RR |
398 | // The first function is more portable (because easier to implement |
399 | // on other platforms), but the second one returns some extra info. | |
400 | wxTreeItemId HitTest(const wxPoint& point) | |
401 | { int dummy; return HitTest(point, dummy); } | |
402 | wxTreeItemId HitTest(const wxPoint& point, int& flags); | |
403 | ||
f135ff73 VZ |
404 | // start editing the item label: this (temporarily) replaces the item |
405 | // with a one line edit control. The item will be selected if it hadn't | |
406 | // been before. textCtrlClass parameter allows you to create an edit | |
407 | // control of arbitrary user-defined class deriving from wxTextCtrl. | |
408 | wxTextCtrl* EditLabel(const wxTreeItemId& item, | |
409 | wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)); | |
410 | // returns the same pointer as StartEdit() if the item is being edited, | |
411 | // NULL otherwise (it's assumed that no more than one item may be | |
412 | // edited simultaneously) | |
413 | wxTextCtrl* GetEditControl() const; | |
414 | // end editing and accept or discard the changes to item label | |
415 | void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE); | |
416 | ||
e1ee62bd VZ |
417 | // sorting |
418 | // this function is called to compare 2 items and should return -1, 0 | |
419 | // or +1 if the first item is less than, equal to or greater than the | |
420 | // second one. The base class version performs alphabetic comparaison | |
421 | // of item labels (GetText) | |
422 | virtual int OnCompareItems(const wxTreeItemId& item1, | |
423 | const wxTreeItemId& item2); | |
424 | // sort the children of this item using OnCompareItems | |
f135ff73 | 425 | // |
e1ee62bd VZ |
426 | // NB: this function is not reentrant and not MT-safe (FIXME)! |
427 | void SortChildren(const wxTreeItemId& item); | |
f135ff73 | 428 | |
a43a4f9d | 429 | // callbacks |
3db7be80 RR |
430 | void OnPaint( wxPaintEvent &event ); |
431 | void OnSetFocus( wxFocusEvent &event ); | |
432 | void OnKillFocus( wxFocusEvent &event ); | |
f135ff73 | 433 | void OnChar( wxKeyEvent &event ); |
3db7be80 RR |
434 | void OnMouse( wxMouseEvent &event ); |
435 | void OnIdle( wxIdleEvent &event ); | |
f135ff73 | 436 | |
a43a4f9d VZ |
437 | // implementation |
438 | void SendDeleteEvent(wxGenericTreeItem *itemBeingDeleted); | |
439 | ||
f135ff73 VZ |
440 | protected: |
441 | wxGenericTreeItem *m_anchor; | |
442 | wxGenericTreeItem *m_current; | |
443 | bool m_hasFocus; | |
3db7be80 | 444 | bool m_dirty; |
f135ff73 VZ |
445 | int m_xScroll,m_yScroll; |
446 | unsigned int m_indent; | |
447 | int m_lineHeight; | |
448 | wxPen m_dottedPen; | |
449 | wxBrush *m_hilightBrush; | |
450 | wxImageList *m_imageListNormal, | |
451 | *m_imageListState; | |
452 | ||
453 | // the common part of all ctors | |
454 | void Init(); | |
455 | ||
456 | // misc helpers | |
457 | wxTreeItemId DoInsertItem(const wxTreeItemId& parent, | |
458 | size_t previous, | |
459 | const wxString& text, | |
460 | int image, int selectedImage, | |
461 | wxTreeItemData *data); | |
462 | ||
463 | void AdjustMyScrollbars(); | |
ef44a621 VZ |
464 | void PaintLevel( wxGenericTreeItem *item, wxDC& dc, int level, int &y ); |
465 | void PaintItem( wxGenericTreeItem *item, wxDC& dc); | |
f135ff73 VZ |
466 | |
467 | void CalculateLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y ); | |
468 | void CalculatePositions(); | |
469 | ||
470 | void RefreshSubtree( wxGenericTreeItem *item ); | |
471 | void RefreshLine( wxGenericTreeItem *item ); | |
43fa96a8 | 472 | |
a32dd690 | 473 | private: |
f135ff73 VZ |
474 | DECLARE_EVENT_TABLE() |
475 | DECLARE_DYNAMIC_CLASS(wxTreeCtrl) | |
c801d85f KB |
476 | }; |
477 | ||
f135ff73 VZ |
478 | #endif // _GENERIC_TREECTRL_H_ |
479 |