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