]>
Commit | Line | Data |
---|---|---|
f135ff73 | 1 | ///////////////////////////////////////////////////////////////////////////// |
cb59313c | 2 | // Name: wx/generic/treectlg.h |
f135ff73 VZ |
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 | |
371a5b4e | 9 | // Licence: wxWindows licence |
f135ff73 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _GENERIC_TREECTRL_H_ | |
13 | #define _GENERIC_TREECTRL_H_ | |
c801d85f | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
233058c7 | 16 | #pragma interface "treectlg.h" |
c801d85f KB |
17 | #endif |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_TREECTRL |
20 | ||
c801d85f | 21 | #include "wx/scrolwin.h" |
ac57418f | 22 | #include "wx/pen.h" |
3cd94a0d | 23 | #include "wx/imaglist.h" |
91b8de8d | 24 | |
f135ff73 VZ |
25 | // ----------------------------------------------------------------------------- |
26 | // forward declaration | |
27 | // ----------------------------------------------------------------------------- | |
c801d85f | 28 | |
e179bd65 | 29 | class WXDLLEXPORT wxGenericTreeItem; |
c801d85f | 30 | |
e179bd65 RR |
31 | class WXDLLEXPORT wxTreeItemData; |
32 | ||
33 | class WXDLLEXPORT wxTreeRenameTimer; | |
cb59313c | 34 | class WXDLLEXPORT wxTreeFindTimer; |
e179bd65 | 35 | class WXDLLEXPORT wxTreeTextCtrl; |
fbb12260 | 36 | class WXDLLEXPORT wxTextCtrl; |
74bedbeb | 37 | |
f135ff73 | 38 | // ----------------------------------------------------------------------------- |
484523cf | 39 | // wxGenericTreeCtrl - the tree control |
f135ff73 | 40 | // ----------------------------------------------------------------------------- |
c801d85f | 41 | |
484523cf | 42 | class WXDLLEXPORT wxGenericTreeCtrl : public wxScrolledWindow |
c801d85f | 43 | { |
a32dd690 | 44 | public: |
f135ff73 VZ |
45 | // creation |
46 | // -------- | |
484523cf | 47 | wxGenericTreeCtrl() { Init(); } |
f135ff73 | 48 | |
484523cf | 49 | wxGenericTreeCtrl(wxWindow *parent, wxWindowID id = -1, |
f135ff73 VZ |
50 | const wxPoint& pos = wxDefaultPosition, |
51 | const wxSize& size = wxDefaultSize, | |
618a5e38 | 52 | long style = wxTR_DEFAULT_STYLE, |
bfc6fde4 | 53 | const wxValidator &validator = wxDefaultValidator, |
62448488 | 54 | const wxString& name = wxTreeCtrlNameStr) |
f135ff73 | 55 | { |
57591e0e | 56 | Init(); |
4f22cf8d | 57 | Create(parent, id, pos, size, style, validator, name); |
f135ff73 VZ |
58 | } |
59 | ||
484523cf | 60 | virtual ~wxGenericTreeCtrl(); |
f135ff73 VZ |
61 | |
62 | bool Create(wxWindow *parent, wxWindowID id = -1, | |
63 | const wxPoint& pos = wxDefaultPosition, | |
64 | const wxSize& size = wxDefaultSize, | |
618a5e38 | 65 | long style = wxTR_DEFAULT_STYLE, |
bfc6fde4 | 66 | const wxValidator &validator = wxDefaultValidator, |
62448488 | 67 | const wxString& name = wxTreeCtrlNameStr); |
f135ff73 VZ |
68 | |
69 | // accessors | |
70 | // --------- | |
71 | ||
72 | // get the total number of items in the control | |
73 | size_t GetCount() const; | |
74 | ||
75 | // indent is the number of pixels the children are indented relative to | |
76 | // the parents position. SetIndent() also redraws the control | |
77 | // immediately. | |
78 | unsigned int GetIndent() const { return m_indent; } | |
79 | void SetIndent(unsigned int indent); | |
80 | ||
9dfbf520 | 81 | // spacing is the number of pixels between the start and the Text |
cf724bce RR |
82 | unsigned int GetSpacing() const { return m_spacing; } |
83 | void SetSpacing(unsigned int spacing); | |
9dfbf520 | 84 | |
f135ff73 | 85 | // image list: these functions allow to associate an image list with |
b771aa29 | 86 | // the control and retrieve it. Note that when assigned with |
46cd520d | 87 | // SetImageList, the control does _not_ delete |
f135ff73 | 88 | // the associated image list when it's deleted in order to allow image |
b771aa29 | 89 | // lists to be shared between different controls. If you use |
46cd520d | 90 | // AssignImageList, the control _does_ delete the image list. |
f135ff73 VZ |
91 | // |
92 | // The normal image list is for the icons which correspond to the | |
93 | // normal tree item state (whether it is selected or not). | |
94 | // Additionally, the application might choose to show a state icon | |
95 | // which corresponds to an app-defined item state (for example, | |
96 | // checked/unchecked) which are taken from the state image list. | |
97 | wxImageList *GetImageList() const; | |
98 | wxImageList *GetStateImageList() const; | |
618a5e38 | 99 | wxImageList *GetButtonsImageList() const; |
f135ff73 VZ |
100 | |
101 | void SetImageList(wxImageList *imageList); | |
102 | void SetStateImageList(wxImageList *imageList); | |
618a5e38 | 103 | void SetButtonsImageList(wxImageList *imageList); |
46cd520d VS |
104 | void AssignImageList(wxImageList *imageList); |
105 | void AssignStateImageList(wxImageList *imageList); | |
618a5e38 | 106 | void AssignButtonsImageList(wxImageList *imageList); |
f135ff73 VZ |
107 | |
108 | // Functions to work with tree ctrl items. | |
109 | ||
110 | // accessors | |
111 | // --------- | |
112 | ||
618a5e38 | 113 | // retrieve item's label |
f135ff73 | 114 | wxString GetItemText(const wxTreeItemId& item) const; |
74b31181 VZ |
115 | // get one of the images associated with the item (normal by default) |
116 | int GetItemImage(const wxTreeItemId& item, | |
117 | wxTreeItemIcon which = wxTreeItemIcon_Normal) const; | |
f135ff73 VZ |
118 | // get the data associated with the item |
119 | wxTreeItemData *GetItemData(const wxTreeItemId& item) const; | |
120 | ||
2b5f62a0 VZ |
121 | // get the item's text colour |
122 | wxColour GetItemTextColour(const wxTreeItemId& item) const; | |
123 | ||
124 | // get the item's background colour | |
125 | wxColour GetItemBackgroundColour(const wxTreeItemId& item) const; | |
126 | ||
127 | // get the item's font | |
128 | wxFont GetItemFont(const wxTreeItemId& item) const; | |
129 | ||
f135ff73 VZ |
130 | // modifiers |
131 | // --------- | |
132 | ||
618a5e38 | 133 | // set item's label |
f135ff73 | 134 | void SetItemText(const wxTreeItemId& item, const wxString& text); |
74b31181 VZ |
135 | // get one of the images associated with the item (normal by default) |
136 | void SetItemImage(const wxTreeItemId& item, int image, | |
8dc99046 | 137 | wxTreeItemIcon which = wxTreeItemIcon_Normal); |
f135ff73 VZ |
138 | // associate some data with the item |
139 | void SetItemData(const wxTreeItemId& item, wxTreeItemData *data); | |
140 | ||
141 | // force appearance of [+] button near the item. This is useful to | |
142 | // allow the user to expand the items which don't have any children now | |
143 | // - but instead add them only when needed, thus minimizing memory | |
144 | // usage and loading time. | |
145 | void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE); | |
146 | ||
ef44a621 VZ |
147 | // the item will be shown in bold |
148 | void SetItemBold(const wxTreeItemId& item, bool bold = TRUE); | |
149 | ||
618a5e38 | 150 | // set the item's text colour |
9ec64fa7 VZ |
151 | void SetItemTextColour(const wxTreeItemId& item, const wxColour& col); |
152 | ||
618a5e38 | 153 | // set the item's background colour |
9ec64fa7 VZ |
154 | void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col); |
155 | ||
618a5e38 | 156 | // set the item's font (should be of the same height for all items) |
9ec64fa7 VZ |
157 | void SetItemFont(const wxTreeItemId& item, const wxFont& font); |
158 | ||
3da2715f JS |
159 | // set the window font |
160 | virtual bool SetFont( const wxFont &font ); | |
161 | ||
618a5e38 RR |
162 | // set the styles. No need to specify a GetWindowStyle here since |
163 | // the base wxWindow member function will do it for us | |
164 | void SetWindowStyle(const long styles); | |
165 | ||
f135ff73 VZ |
166 | // item status inquiries |
167 | // --------------------- | |
168 | ||
169 | // is the item visible (it might be outside the view or not expanded)? | |
170 | bool IsVisible(const wxTreeItemId& item) const; | |
171 | // does the item has any children? | |
6daa0637 RR |
172 | bool HasChildren(const wxTreeItemId& item) const |
173 | { return ItemHasChildren(item); } | |
f135ff73 VZ |
174 | bool ItemHasChildren(const wxTreeItemId& item) const; |
175 | // is the item expanded (only makes sense if HasChildren())? | |
176 | bool IsExpanded(const wxTreeItemId& item) const; | |
177 | // is this item currently selected (the same as has focus)? | |
178 | bool IsSelected(const wxTreeItemId& item) const; | |
ef44a621 VZ |
179 | // is item text in bold font? |
180 | bool IsBold(const wxTreeItemId& item) const; | |
618a5e38 | 181 | // does the layout include space for a button? |
f135ff73 | 182 | |
4832f7c0 VZ |
183 | // number of children |
184 | // ------------------ | |
185 | ||
186 | // if 'recursively' is FALSE, only immediate children count, otherwise | |
187 | // the returned number is the number of all items in this branch | |
df74fdea VZ |
188 | size_t GetChildrenCount(const wxTreeItemId& item, |
189 | bool recursively = TRUE) const; | |
4832f7c0 | 190 | |
f135ff73 VZ |
191 | // navigation |
192 | // ---------- | |
193 | ||
194 | // wxTreeItemId.IsOk() will return FALSE if there is no such item | |
195 | ||
196 | // get the root tree item | |
197 | wxTreeItemId GetRootItem() const { return m_anchor; } | |
198 | ||
199 | // get the item currently selected (may return NULL if no selection) | |
200 | wxTreeItemId GetSelection() const { return m_current; } | |
201 | ||
88ac883a | 202 | // get the items currently selected, return the number of such item |
91b8de8d | 203 | size_t GetSelections(wxArrayTreeItemIds&) const; |
88ac883a | 204 | |
f135ff73 | 205 | // get the parent of this item (may return NULL if root) |
99006e44 RL |
206 | wxTreeItemId GetItemParent(const wxTreeItemId& item) const; |
207 | ||
208 | #if WXWIN_COMPATIBILITY_2_2 | |
209 | // deprecated: Use GetItemParent instead. | |
210 | wxTreeItemId GetParent(const wxTreeItemId& item) const | |
82c23bb5 | 211 | { return GetItemParent( item ); } |
99006e44 | 212 | |
82c23bb5 | 213 | // Expose the base class method hidden by the one above. |
99006e44 RL |
214 | wxWindow *GetParent() const { return wxScrolledWindow::GetParent(); } |
215 | #endif // WXWIN_COMPATIBILITY_2_2 | |
f135ff73 VZ |
216 | |
217 | // for this enumeration function you must pass in a "cookie" parameter | |
218 | // which is opaque for the application but is necessary for the library | |
219 | // to make these functions reentrant (i.e. allow more than one | |
220 | // enumeration on one and the same object simultaneously). Of course, | |
221 | // the "cookie" passed to GetFirstChild() and GetNextChild() should be | |
222 | // the same! | |
223 | ||
224 | // get the first child of this item | |
ee4b2721 VZ |
225 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, |
226 | wxTreeItemIdValue& cookie) const; | |
f135ff73 | 227 | // get the next child |
ee4b2721 VZ |
228 | wxTreeItemId GetNextChild(const wxTreeItemId& item, |
229 | wxTreeItemIdValue& cookie) const; | |
978f38c2 VZ |
230 | // get the last child of this item - this method doesn't use cookies |
231 | wxTreeItemId GetLastChild(const wxTreeItemId& item) const; | |
f135ff73 VZ |
232 | |
233 | // get the next sibling of this item | |
234 | wxTreeItemId GetNextSibling(const wxTreeItemId& item) const; | |
235 | // get the previous sibling | |
236 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const; | |
237 | ||
238 | // get first visible item | |
239 | wxTreeItemId GetFirstVisibleItem() const; | |
240 | // get the next visible item: item must be visible itself! | |
241 | // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem() | |
242 | wxTreeItemId GetNextVisible(const wxTreeItemId& item) const; | |
243 | // get the previous visible item: item must be visible itself! | |
244 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const; | |
245 | ||
1ed01484 JS |
246 | // Only for internal use right now, but should probably be public |
247 | wxTreeItemId GetNext(const wxTreeItemId& item) const; | |
1ed01484 | 248 | |
f135ff73 VZ |
249 | // operations |
250 | // ---------- | |
251 | ||
252 | // add the root node to the tree | |
253 | wxTreeItemId AddRoot(const wxString& text, | |
254 | int image = -1, int selectedImage = -1, | |
255 | wxTreeItemData *data = NULL); | |
256 | ||
257 | // insert a new item in as the first child of the parent | |
258 | wxTreeItemId PrependItem(const wxTreeItemId& parent, | |
259 | const wxString& text, | |
260 | int image = -1, int selectedImage = -1, | |
261 | wxTreeItemData *data = NULL); | |
262 | ||
263 | // insert a new item after a given one | |
264 | wxTreeItemId InsertItem(const wxTreeItemId& parent, | |
265 | const wxTreeItemId& idPrevious, | |
266 | const wxString& text, | |
f2593d0d RR |
267 | int image = -1, int selectedImage = -1, |
268 | wxTreeItemData *data = NULL); | |
269 | ||
2ef31e80 | 270 | // insert a new item before the one with the given index |
f2593d0d | 271 | wxTreeItemId InsertItem(const wxTreeItemId& parent, |
2ef31e80 | 272 | size_t index, |
f2593d0d | 273 | const wxString& text, |
f135ff73 VZ |
274 | int image = -1, int selectedImage = -1, |
275 | wxTreeItemData *data = NULL); | |
276 | ||
277 | // insert a new item in as the last child of the parent | |
278 | wxTreeItemId AppendItem(const wxTreeItemId& parent, | |
279 | const wxString& text, | |
280 | int image = -1, int selectedImage = -1, | |
281 | wxTreeItemData *data = NULL); | |
282 | ||
283 | // delete this item and associated data if any | |
284 | void Delete(const wxTreeItemId& item); | |
372edb9d VZ |
285 | // delete all children (but don't delete the item itself) |
286 | // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events | |
287 | void DeleteChildren(const wxTreeItemId& item); | |
f135ff73 | 288 | // delete all items from the tree |
372edb9d | 289 | // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events |
f135ff73 VZ |
290 | void DeleteAllItems(); |
291 | ||
292 | // expand this item | |
293 | void Expand(const wxTreeItemId& item); | |
f6bcfd97 BP |
294 | // expand this item and all subitems recursively |
295 | void ExpandAll(const wxTreeItemId& item); | |
f135ff73 VZ |
296 | // collapse the item without removing its children |
297 | void Collapse(const wxTreeItemId& item); | |
298 | // collapse the item and remove all children | |
299 | void CollapseAndReset(const wxTreeItemId& item); | |
300 | // toggles the current state | |
301 | void Toggle(const wxTreeItemId& item); | |
302 | ||
303 | // remove the selection from currently selected item (if any) | |
304 | void Unselect(); | |
78f12104 VZ |
305 | // or from the given one (multiselect mode only) |
306 | void UnselectItem(const wxTreeItemId& item) { SelectItem(item, false); } | |
307 | // or from all | |
88ac883a | 308 | void UnselectAll(); |
f135ff73 | 309 | // select this item |
78f12104 VZ |
310 | void SelectItem(const wxTreeItemId& item, bool select = true); |
311 | // toggle the item selection | |
312 | void ToggleItemSelection(const wxTreeItemId& item) | |
313 | { | |
314 | SelectItem(item, !IsSelected(item)); | |
315 | } | |
316 | ||
f135ff73 VZ |
317 | // make sure this item is visible (expanding the parent item and/or |
318 | // scrolling to this item if necessary) | |
319 | void EnsureVisible(const wxTreeItemId& item); | |
320 | // scroll to this item (but don't expand its parent) | |
321 | void ScrollTo(const wxTreeItemId& item); | |
618a5e38 | 322 | void AdjustMyScrollbars(); |
f135ff73 | 323 | |
4f22cf8d RR |
324 | // The first function is more portable (because easier to implement |
325 | // on other platforms), but the second one returns some extra info. | |
326 | wxTreeItemId HitTest(const wxPoint& point) | |
327 | { int dummy; return HitTest(point, dummy); } | |
328 | wxTreeItemId HitTest(const wxPoint& point, int& flags); | |
bfc6fde4 | 329 | |
8fb3bfe2 JS |
330 | // get the bounding rectangle of the item (or of its label only) |
331 | bool GetBoundingRect(const wxTreeItemId& item, | |
332 | wxRect& rect, | |
333 | bool textOnly = FALSE) const; | |
334 | ||
e179bd65 | 335 | // Start editing the item label: this (temporarily) replaces the item |
f135ff73 | 336 | // with a one line edit control. The item will be selected if it hadn't |
e179bd65 RR |
337 | // been before. |
338 | void EditLabel( const wxTreeItemId& item ) { Edit( item ); } | |
339 | void Edit( const wxTreeItemId& item ); | |
fbb12260 JS |
340 | // returns a pointer to the text edit control if the item is being |
341 | // edited, NULL otherwise (it's assumed that no more than one item may | |
342 | // be edited simultaneously) | |
343 | wxTextCtrl* GetEditControl() const; | |
9dfbf520 | 344 | |
e1ee62bd VZ |
345 | // sorting |
346 | // this function is called to compare 2 items and should return -1, 0 | |
347 | // or +1 if the first item is less than, equal to or greater than the | |
348 | // second one. The base class version performs alphabetic comparaison | |
349 | // of item labels (GetText) | |
350 | virtual int OnCompareItems(const wxTreeItemId& item1, | |
351 | const wxTreeItemId& item2); | |
352 | // sort the children of this item using OnCompareItems | |
f135ff73 | 353 | // |
e1ee62bd VZ |
354 | // NB: this function is not reentrant and not MT-safe (FIXME)! |
355 | void SortChildren(const wxTreeItemId& item); | |
f135ff73 | 356 | |
ee4b2721 | 357 | #if WXWIN_COMPATIBILITY_2_4 |
74b31181 | 358 | // deprecated functions: use Set/GetItemImage directly |
74b31181 VZ |
359 | int GetItemSelectedImage(const wxTreeItemId& item) const |
360 | { return GetItemImage(item, wxTreeItemIcon_Selected); } | |
74b31181 VZ |
361 | void SetItemSelectedImage(const wxTreeItemId& item, int image) |
362 | { SetItemImage(item, image, wxTreeItemIcon_Selected); } | |
363 | ||
2d75caaa VZ |
364 | // use the versions taking wxTreeItemIdValue cookies (note that |
365 | // GetNextChild() is not inside wxDEPRECATED on purpose, as otherwise we | |
366 | // get twice as many warnings without any added benefit: it is always used | |
367 | // with GetFirstChild() anyhow) | |
ee4b2721 VZ |
368 | wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item, |
369 | long& cookie) const ); | |
2d75caaa VZ |
370 | wxTreeItemId GetNextChild(const wxTreeItemId& item, |
371 | long& cookie) const; | |
ee4b2721 VZ |
372 | #endif // WXWIN_COMPATIBILITY_2_4 |
373 | ||
d4864e97 | 374 | virtual bool ShouldInheritColours() const { return false; } |
ee4b2721 | 375 | |
3dbeaa52 | 376 | // implementation only from now on |
74b31181 | 377 | |
7009f411 VZ |
378 | // overridden base class virtuals |
379 | virtual bool SetBackgroundColour(const wxColour& colour); | |
380 | virtual bool SetForegroundColour(const wxColour& colour); | |
381 | ||
e1983ab5 VZ |
382 | virtual void Freeze(); |
383 | virtual void Thaw(); | |
384 | ||
a43a4f9d | 385 | // callbacks |
3db7be80 RR |
386 | void OnPaint( wxPaintEvent &event ); |
387 | void OnSetFocus( wxFocusEvent &event ); | |
388 | void OnKillFocus( wxFocusEvent &event ); | |
f135ff73 | 389 | void OnChar( wxKeyEvent &event ); |
3db7be80 | 390 | void OnMouse( wxMouseEvent &event ); |
73bb6776 | 391 | void OnGetToolTip( wxTreeEvent &event ); |
5180055b | 392 | void OnInternalIdle( ); |
f135ff73 | 393 | |
3dbeaa52 | 394 | // implementation helpers |
f135ff73 | 395 | protected: |
91b8de8d | 396 | friend class wxGenericTreeItem; |
e179bd65 | 397 | friend class wxTreeRenameTimer; |
cb59313c | 398 | friend class wxTreeFindTimer; |
e179bd65 | 399 | friend class wxTreeTextCtrl; |
91b8de8d | 400 | |
eff869aa RR |
401 | wxFont m_normalFont; |
402 | wxFont m_boldFont; | |
403 | ||
f135ff73 | 404 | wxGenericTreeItem *m_anchor; |
cb59313c | 405 | wxGenericTreeItem *m_current, |
3e3a7b97 JS |
406 | *m_key_current, |
407 | // A hint to select a parent item after deleting a child | |
408 | *m_select_me; | |
618a5e38 RR |
409 | unsigned short m_indent; |
410 | unsigned short m_spacing; | |
f135ff73 VZ |
411 | int m_lineHeight; |
412 | wxPen m_dottedPen; | |
b771aa29 VZ |
413 | wxBrush *m_hilightBrush, |
414 | *m_hilightUnfocusedBrush; | |
618a5e38 RR |
415 | bool m_hasFocus; |
416 | bool m_dirty; | |
b771aa29 | 417 | bool m_ownsImageListNormal, |
618a5e38 RR |
418 | m_ownsImageListState, |
419 | m_ownsImageListButtons; | |
420 | bool m_isDragging; // true between BEGIN/END drag events | |
618a5e38 RR |
421 | bool m_lastOnSame; // last click on the same item as prev |
422 | wxImageList *m_imageListNormal, | |
423 | *m_imageListState, | |
424 | *m_imageListButtons; | |
3dbeaa52 | 425 | |
e1983ab5 | 426 | int m_freezeCount; |
bbe0af5b | 427 | int m_dragCount; |
fd9811b1 | 428 | wxPoint m_dragStart; |
3dbeaa52 | 429 | wxGenericTreeItem *m_dropTarget; |
943d28e4 VZ |
430 | wxCursor m_oldCursor; // cursor is changed while dragging |
431 | wxGenericTreeItem *m_oldSelection; | |
f8b043e7 | 432 | wxGenericTreeItem *m_underMouse; // for visual effects |
fbb12260 | 433 | wxTreeTextCtrl *m_textCtrl; |
3dbeaa52 | 434 | |
e179bd65 | 435 | wxTimer *m_renameTimer; |
cb59313c | 436 | |
cb59313c VZ |
437 | // incremental search data |
438 | wxString m_findPrefix; | |
439 | wxTimer *m_findTimer; | |
f135ff73 VZ |
440 | |
441 | // the common part of all ctors | |
442 | void Init(); | |
443 | ||
444 | // misc helpers | |
cb59313c VZ |
445 | void SendDeleteEvent(wxGenericTreeItem *itemBeingDeleted); |
446 | ||
447 | void DrawBorder(const wxTreeItemId& item); | |
448 | void DrawLine(const wxTreeItemId& item, bool below); | |
449 | void DrawDropEffect(wxGenericTreeItem *item); | |
450 | ||
78f12104 VZ |
451 | void DoSelectItem(const wxTreeItemId& id, |
452 | bool unselect_others = TRUE, | |
453 | bool extended_select = FALSE); | |
454 | ||
f135ff73 VZ |
455 | wxTreeItemId DoInsertItem(const wxTreeItemId& parent, |
456 | size_t previous, | |
457 | const wxString& text, | |
458 | int image, int selectedImage, | |
459 | wxTreeItemData *data); | |
cb59313c | 460 | |
fbb12260 JS |
461 | // called by wxTextTreeCtrl when it marks itself for deletion |
462 | void ResetTextControl(); | |
463 | ||
cb59313c VZ |
464 | // find the first item starting with the given prefix after the given item |
465 | wxTreeItemId FindItem(const wxTreeItemId& id, const wxString& prefix) const; | |
466 | ||
8fcf6e32 | 467 | bool HasButtons() const { return HasFlag(wxTR_HAS_BUTTONS); } |
f135ff73 | 468 | |
618a5e38 | 469 | void CalculateLineHeight(); |
91b8de8d | 470 | int GetLineHeight(wxGenericTreeItem *item) const; |
ef44a621 VZ |
471 | void PaintLevel( wxGenericTreeItem *item, wxDC& dc, int level, int &y ); |
472 | void PaintItem( wxGenericTreeItem *item, wxDC& dc); | |
f135ff73 VZ |
473 | |
474 | void CalculateLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y ); | |
475 | void CalculatePositions(); | |
91b8de8d | 476 | void CalculateSize( wxGenericTreeItem *item, wxDC &dc ); |
f135ff73 VZ |
477 | |
478 | void RefreshSubtree( wxGenericTreeItem *item ); | |
479 | void RefreshLine( wxGenericTreeItem *item ); | |
9dfbf520 | 480 | |
b771aa29 VZ |
481 | // redraw all selected items |
482 | void RefreshSelected(); | |
483 | ||
484 | // RefreshSelected() recursive helper | |
485 | void RefreshSelectedUnder(wxGenericTreeItem *item); | |
486 | ||
e179bd65 | 487 | void OnRenameTimer(); |
edb8f298 | 488 | bool OnRenameAccept(wxGenericTreeItem *item, const wxString& value); |
dd23c25c | 489 | void OnRenameCancelled(wxGenericTreeItem *item); |
43fa96a8 | 490 | |
91b8de8d | 491 | void FillArray(wxGenericTreeItem*, wxArrayTreeItemIds&) const; |
88ac883a VZ |
492 | void SelectItemRange( wxGenericTreeItem *item1, wxGenericTreeItem *item2 ); |
493 | bool TagAllChildrenUntilLast(wxGenericTreeItem *crt_item, wxGenericTreeItem *last_item, bool select); | |
494 | bool TagNextChildren(wxGenericTreeItem *crt_item, wxGenericTreeItem *last_item, bool select); | |
495 | void UnselectAllChildren( wxGenericTreeItem *item ); | |
496 | ||
a32dd690 | 497 | private: |
f135ff73 | 498 | DECLARE_EVENT_TABLE() |
484523cf | 499 | DECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl) |
22f3361e | 500 | DECLARE_NO_COPY_CLASS(wxGenericTreeCtrl) |
c801d85f KB |
501 | }; |
502 | ||
3a5bcc4d | 503 | #if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) |
233058c7 JS |
504 | /* |
505 | * wxTreeCtrl has to be a real class or we have problems with | |
506 | * the run-time information. | |
507 | */ | |
508 | ||
509 | class WXDLLEXPORT wxTreeCtrl: public wxGenericTreeCtrl | |
510 | { | |
233058c7 JS |
511 | DECLARE_DYNAMIC_CLASS(wxTreeCtrl) |
512 | ||
618a5e38 | 513 | public: |
233058c7 JS |
514 | wxTreeCtrl() {} |
515 | ||
516 | wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, | |
517 | const wxPoint& pos = wxDefaultPosition, | |
518 | const wxSize& size = wxDefaultSize, | |
618a5e38 | 519 | long style = wxTR_DEFAULT_STYLE, |
233058c7 JS |
520 | const wxValidator &validator = wxDefaultValidator, |
521 | const wxString& name = wxTreeCtrlNameStr) | |
618a5e38 | 522 | : wxGenericTreeCtrl(parent, id, pos, size, style, validator, name) |
233058c7 | 523 | { |
233058c7 | 524 | } |
233058c7 | 525 | }; |
3a5bcc4d | 526 | #endif // !__WXMSW__ || __WXUNIVERSAL__ |
233058c7 | 527 | |
1e6feb95 VZ |
528 | #endif // wxUSE_TREECTRL |
529 | ||
f135ff73 VZ |
530 | #endif // _GENERIC_TREECTRL_H_ |
531 |