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