]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
3f7bc32b | 2 | // Name: wx/msw/treectrl.h |
2bda0e17 KB |
3 | // Purpose: wxTreeCtrl class |
4 | // Author: Julian Smart | |
08b7c251 | 5 | // Modified by: Vadim Zeitlin to be less MSW-specific on 10/10/98 |
2bda0e17 KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
371a5b4e | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_TREECTRL_H_ |
13 | #define _WX_TREECTRL_H_ | |
2bda0e17 | 14 | |
08b7c251 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
d427503c | 18 | |
12028905 | 19 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
08b7c251 | 20 | #pragma interface "treectrl.h" |
2bda0e17 KB |
21 | #endif |
22 | ||
1e6feb95 VZ |
23 | #if wxUSE_TREECTRL |
24 | ||
ad5c34f3 | 25 | #include "wx/textctrl.h" |
2899e223 | 26 | #include "wx/dynarray.h" |
484523cf | 27 | #include "wx/treebase.h" |
ee4b2721 | 28 | #include "wx/hashmap.h" |
2bda0e17 | 29 | |
d427503c VZ |
30 | #ifdef __GNUWIN32__ |
31 | // Cygwin windows.h defines these identifiers | |
32 | #undef GetFirstChild | |
33 | #undef GetNextSibling | |
34 | #endif // Cygwin | |
35 | ||
08b7c251 | 36 | // fwd decl |
06e38c8e | 37 | class WXDLLEXPORT wxImageList; |
23f681ec | 38 | class WXDLLEXPORT wxDragImage; |
06e38c8e | 39 | struct WXDLLEXPORT wxTreeViewItem; |
08b7c251 | 40 | |
08b7c251 VZ |
41 | // NB: all the following flags are for compatbility only and will be removed in the |
42 | // next versions | |
43 | ||
ee4b2721 VZ |
44 | // flags for deprecated InsertItem() variant (their values are the same as of |
45 | // TVI_FIRST and TVI_LAST) | |
3197ed26 VZ |
46 | #define wxTREE_INSERT_FIRST 0xFFFF0001 |
47 | #define wxTREE_INSERT_LAST 0xFFFF0002 | |
2bda0e17 | 48 | |
ee4b2721 VZ |
49 | // hash storing attributes for our items |
50 | WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxTreeItemAttr *, wxMapTreeAttr); | |
51 | ||
08b7c251 VZ |
52 | // ---------------------------------------------------------------------------- |
53 | // wxTreeCtrl | |
54 | // ---------------------------------------------------------------------------- | |
ee4b2721 | 55 | |
08b7c251 | 56 | class WXDLLEXPORT wxTreeCtrl : public wxControl |
2bda0e17 | 57 | { |
092bddef | 58 | public: |
092bddef VZ |
59 | // creation |
60 | // -------- | |
08b7c251 VZ |
61 | wxTreeCtrl() { Init(); } |
62 | ||
dabbc6a5 | 63 | wxTreeCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, |
08b7c251 VZ |
64 | const wxPoint& pos = wxDefaultPosition, |
65 | const wxSize& size = wxDefaultSize, | |
66 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, | |
67 | const wxValidator& validator = wxDefaultValidator, | |
2b5f62a0 | 68 | const wxString& name = wxTreeCtrlNameStr) |
092bddef VZ |
69 | { |
70 | Create(parent, id, pos, size, style, validator, name); | |
71 | } | |
08b7c251 VZ |
72 | |
73 | virtual ~wxTreeCtrl(); | |
74 | ||
dabbc6a5 | 75 | bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, |
092bddef VZ |
76 | const wxPoint& pos = wxDefaultPosition, |
77 | const wxSize& size = wxDefaultSize, | |
08b7c251 | 78 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, |
092bddef | 79 | const wxValidator& validator = wxDefaultValidator, |
2b5f62a0 | 80 | const wxString& name = wxTreeCtrlNameStr); |
08b7c251 | 81 | |
092bddef VZ |
82 | // accessors |
83 | // --------- | |
092bddef | 84 | |
08b7c251 VZ |
85 | // get the total number of items in the control |
86 | size_t GetCount() const; | |
87 | ||
88 | // indent is the number of pixels the children are indented relative to | |
89 | // the parents position. SetIndent() also redraws the control | |
90 | // immediately. | |
91 | unsigned int GetIndent() const; | |
92 | void SetIndent(unsigned int indent); | |
93 | ||
74b31181 VZ |
94 | // spacing is the number of pixels between the start and the Text |
95 | // not implemented under wxMSW | |
cf724bce | 96 | unsigned int GetSpacing() const { return 18; } // return wxGTK default |
74b31181 | 97 | void SetSpacing(unsigned int WXUNUSED(spacing)) { } |
cf724bce | 98 | |
08b7c251 VZ |
99 | // image list: these functions allow to associate an image list with |
100 | // the control and retrieve it. Note that the control does _not_ delete | |
101 | // the associated image list when it's deleted in order to allow image | |
102 | // lists to be shared between different controls. | |
103 | // | |
104 | // The normal image list is for the icons which correspond to the | |
105 | // normal tree item state (whether it is selected or not). | |
106 | // Additionally, the application might choose to show a state icon | |
107 | // which corresponds to an app-defined item state (for example, | |
108 | // checked/unchecked) which are taken from the state image list. | |
a78955e3 VS |
109 | virtual wxImageList *GetImageList() const; |
110 | virtual wxImageList *GetStateImageList() const; | |
08b7c251 | 111 | |
a78955e3 VS |
112 | virtual void SetImageList(wxImageList *imageList); |
113 | virtual void SetStateImageList(wxImageList *imageList); | |
114 | virtual void AssignImageList(wxImageList *imageList); | |
115 | virtual void AssignStateImageList(wxImageList *imageList); | |
08b7c251 VZ |
116 | |
117 | // Functions to work with tree ctrl items. Unfortunately, they can _not_ be | |
118 | // member functions of wxTreeItem because they must know the tree the item | |
119 | // belongs to for Windows implementation and storing the pointer to | |
120 | // wxTreeCtrl in each wxTreeItem is just too much waste. | |
121 | ||
122 | // accessors | |
123 | // --------- | |
124 | ||
125 | // retrieve items label | |
126 | wxString GetItemText(const wxTreeItemId& item) const; | |
74b31181 | 127 | // get one of the images associated with the item (normal by default) |
a78955e3 | 128 | virtual int GetItemImage(const wxTreeItemId& item, |
74b31181 | 129 | wxTreeItemIcon which = wxTreeItemIcon_Normal) const; |
08b7c251 VZ |
130 | // get the data associated with the item |
131 | wxTreeItemData *GetItemData(const wxTreeItemId& item) const; | |
132 | ||
2b5f62a0 VZ |
133 | // get the item's text colour |
134 | wxColour GetItemTextColour(const wxTreeItemId& item) const; | |
135 | ||
136 | // get the item's background colour | |
137 | wxColour GetItemBackgroundColour(const wxTreeItemId& item) const; | |
138 | ||
139 | // get the item's font | |
140 | wxFont GetItemFont(const wxTreeItemId& item) const; | |
141 | ||
08b7c251 VZ |
142 | // modifiers |
143 | // --------- | |
144 | ||
145 | // set items label | |
146 | void SetItemText(const wxTreeItemId& item, const wxString& text); | |
74b31181 | 147 | // get one of the images associated with the item (normal by default) |
a78955e3 | 148 | virtual void SetItemImage(const wxTreeItemId& item, int image, |
74b31181 | 149 | wxTreeItemIcon which = wxTreeItemIcon_Normal); |
08b7c251 VZ |
150 | // associate some data with the item |
151 | void SetItemData(const wxTreeItemId& item, wxTreeItemData *data); | |
152 | ||
3a5a2f56 VZ |
153 | // force appearance of [+] button near the item. This is useful to |
154 | // allow the user to expand the items which don't have any children now | |
155 | // - but instead add them only when needed, thus minimizing memory | |
156 | // usage and loading time. | |
dabbc6a5 | 157 | void SetItemHasChildren(const wxTreeItemId& item, bool has = true); |
3a5a2f56 | 158 | |
add28c55 | 159 | // the item will be shown in bold |
dabbc6a5 | 160 | void SetItemBold(const wxTreeItemId& item, bool bold = true); |
add28c55 | 161 | |
58a8ab88 | 162 | // the item will be shown with a drop highlight |
dabbc6a5 | 163 | void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true); |
58a8ab88 | 164 | |
9ec64fa7 VZ |
165 | // set the items text colour |
166 | void SetItemTextColour(const wxTreeItemId& item, const wxColour& col); | |
167 | ||
168 | // set the items background colour | |
169 | void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col); | |
170 | ||
171 | // set the items font (should be of the same height for all items) | |
172 | void SetItemFont(const wxTreeItemId& item, const wxFont& font); | |
173 | ||
08b7c251 VZ |
174 | // item status inquiries |
175 | // --------------------- | |
176 | ||
177 | // is the item visible (it might be outside the view or not expanded)? | |
178 | bool IsVisible(const wxTreeItemId& item) const; | |
179 | // does the item has any children? | |
180 | bool ItemHasChildren(const wxTreeItemId& item) const; | |
181 | // is the item expanded (only makes sense if HasChildren())? | |
182 | bool IsExpanded(const wxTreeItemId& item) const; | |
183 | // is this item currently selected (the same as has focus)? | |
184 | bool IsSelected(const wxTreeItemId& item) const; | |
add28c55 VZ |
185 | // is item text in bold font? |
186 | bool IsBold(const wxTreeItemId& item) const; | |
08b7c251 | 187 | |
4832f7c0 VZ |
188 | // number of children |
189 | // ------------------ | |
190 | ||
dabbc6a5 | 191 | // if 'recursively' is false, only immediate children count, otherwise |
4832f7c0 | 192 | // the returned number is the number of all items in this branch |
9dfbf520 | 193 | size_t GetChildrenCount(const wxTreeItemId& item, |
dabbc6a5 | 194 | bool recursively = true) const; |
4832f7c0 | 195 | |
08b7c251 VZ |
196 | // navigation |
197 | // ---------- | |
198 | ||
dabbc6a5 | 199 | // wxTreeItemId.IsOk() will return false if there is no such item |
08b7c251 VZ |
200 | |
201 | // get the root tree item | |
202 | wxTreeItemId GetRootItem() const; | |
203 | ||
204 | // get the item currently selected (may return NULL if no selection) | |
205 | wxTreeItemId GetSelection() const; | |
206 | ||
9dfbf520 VZ |
207 | // get the items currently selected, return the number of such item |
208 | // | |
209 | // NB: this operation is expensive and can take a long time for a | |
210 | // control with a lot of items (~ O(number of items)). | |
211 | size_t GetSelections(wxArrayTreeItemIds& selections) const; | |
212 | ||
08b7c251 | 213 | // get the parent of this item (may return NULL if root) |
99006e44 RL |
214 | wxTreeItemId GetItemParent(const wxTreeItemId& item) const; |
215 | ||
216 | #if WXWIN_COMPATIBILITY_2_2 | |
217 | // deprecated: Use GetItemParent instead. | |
1729813a | 218 | wxDEPRECATED( wxTreeItemId GetParent(const wxTreeItemId& item) const); |
99006e44 | 219 | |
1729813a | 220 | // Expose the base class method hidden by the one above. Not deprecatable. |
a8853c78 | 221 | wxWindow *GetParent() const { return wxControl::GetParent(); } |
99006e44 | 222 | #endif // WXWIN_COMPATIBILITY_2_2 |
08b7c251 VZ |
223 | |
224 | // for this enumeration function you must pass in a "cookie" parameter | |
225 | // which is opaque for the application but is necessary for the library | |
226 | // to make these functions reentrant (i.e. allow more than one | |
227 | // enumeration on one and the same object simultaneously). Of course, | |
228 | // the "cookie" passed to GetFirstChild() and GetNextChild() should be | |
229 | // the same! | |
230 | ||
231 | // get the first child of this item | |
ee4b2721 VZ |
232 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, |
233 | wxTreeItemIdValue& cookie) const; | |
08b7c251 | 234 | // get the next child |
ee4b2721 VZ |
235 | wxTreeItemId GetNextChild(const wxTreeItemId& item, |
236 | wxTreeItemIdValue& cookie) const; | |
978f38c2 VZ |
237 | // get the last child of this item - this method doesn't use cookies |
238 | wxTreeItemId GetLastChild(const wxTreeItemId& item) const; | |
08b7c251 VZ |
239 | |
240 | // get the next sibling of this item | |
241 | wxTreeItemId GetNextSibling(const wxTreeItemId& item) const; | |
242 | // get the previous sibling | |
243 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const; | |
244 | ||
245 | // get first visible item | |
246 | wxTreeItemId GetFirstVisibleItem() const; | |
247 | // get the next visible item: item must be visible itself! | |
248 | // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem() | |
249 | wxTreeItemId GetNextVisible(const wxTreeItemId& item) const; | |
250 | // get the previous visible item: item must be visible itself! | |
251 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const; | |
252 | ||
092bddef VZ |
253 | // operations |
254 | // ---------- | |
08b7c251 VZ |
255 | |
256 | // add the root node to the tree | |
a78955e3 | 257 | virtual wxTreeItemId AddRoot(const wxString& text, |
08b7c251 VZ |
258 | int image = -1, int selectedImage = -1, |
259 | wxTreeItemData *data = NULL); | |
260 | ||
261 | // insert a new item in as the first child of the parent | |
a78955e3 | 262 | virtual wxTreeItemId PrependItem(const wxTreeItemId& parent, |
08b7c251 VZ |
263 | const wxString& text, |
264 | int image = -1, int selectedImage = -1, | |
265 | wxTreeItemData *data = NULL); | |
266 | ||
267 | // insert a new item after a given one | |
a78955e3 | 268 | virtual wxTreeItemId InsertItem(const wxTreeItemId& parent, |
08b7c251 VZ |
269 | const wxTreeItemId& idPrevious, |
270 | const wxString& text, | |
271 | int image = -1, int selectedImage = -1, | |
272 | wxTreeItemData *data = NULL); | |
273 | ||
2ef31e80 | 274 | // insert a new item before the one with the given index |
a78955e3 | 275 | virtual wxTreeItemId InsertItem(const wxTreeItemId& parent, |
2ef31e80 VZ |
276 | size_t index, |
277 | const wxString& text, | |
278 | int image = -1, int selectedImage = -1, | |
279 | wxTreeItemData *data = NULL); | |
280 | ||
08b7c251 | 281 | // insert a new item in as the last child of the parent |
a78955e3 | 282 | virtual wxTreeItemId AppendItem(const wxTreeItemId& parent, |
08b7c251 VZ |
283 | const wxString& text, |
284 | int image = -1, int selectedImage = -1, | |
285 | wxTreeItemData *data = NULL); | |
286 | ||
287 | // delete this item and associated data if any | |
288 | void Delete(const wxTreeItemId& item); | |
372edb9d VZ |
289 | // delete all children (but don't delete the item itself) |
290 | // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events | |
291 | void DeleteChildren(const wxTreeItemId& item); | |
08b7c251 | 292 | // delete all items from the tree |
372edb9d | 293 | // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events |
08b7c251 VZ |
294 | void DeleteAllItems(); |
295 | ||
296 | // expand this item | |
297 | void Expand(const wxTreeItemId& item); | |
298 | // collapse the item without removing its children | |
299 | void Collapse(const wxTreeItemId& item); | |
300 | // collapse the item and remove all children | |
301 | void CollapseAndReset(const wxTreeItemId& item); | |
302 | // toggles the current state | |
303 | void Toggle(const wxTreeItemId& item); | |
304 | ||
305 | // remove the selection from currently selected item (if any) | |
306 | void Unselect(); | |
9dfbf520 VZ |
307 | // unselect all items (only makes sense for multiple selection control) |
308 | void UnselectAll(); | |
08b7c251 | 309 | // select this item |
3e9af289 VZ |
310 | void SelectItem(const wxTreeItemId& item, bool select = true); |
311 | // unselect this item | |
312 | void UnselectItem(const wxTreeItemId& item); | |
313 | // toggle item selection | |
314 | void ToggleItemSelection(const wxTreeItemId& item); | |
315 | ||
08b7c251 VZ |
316 | // make sure this item is visible (expanding the parent item and/or |
317 | // scrolling to this item if necessary) | |
318 | void EnsureVisible(const wxTreeItemId& item); | |
319 | // scroll to this item (but don't expand its parent) | |
320 | void ScrollTo(const wxTreeItemId& item); | |
321 | ||
322 | // start editing the item label: this (temporarily) replaces the item | |
323 | // with a one line edit control. The item will be selected if it hadn't | |
324 | // been before. textCtrlClass parameter allows you to create an edit | |
325 | // control of arbitrary user-defined class deriving from wxTextCtrl. | |
326 | wxTextCtrl* EditLabel(const wxTreeItemId& item, | |
327 | wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)); | |
328 | // returns the same pointer as StartEdit() if the item is being edited, | |
329 | // NULL otherwise (it's assumed that no more than one item may be | |
330 | // edited simultaneously) | |
331 | wxTextCtrl* GetEditControl() const; | |
332 | // end editing and accept or discard the changes to item label | |
d35dce3a VZ |
333 | void EndEditLabel(const wxTreeItemId& WXUNUSED(item), |
334 | bool discardChanges = false) | |
335 | { | |
336 | DoEndEditLabel(discardChanges); | |
337 | } | |
08b7c251 | 338 | |
95aabccc VZ |
339 | // sorting |
340 | // this function is called to compare 2 items and should return -1, 0 | |
341 | // or +1 if the first item is less than, equal to or greater than the | |
342 | // second one. The base class version performs alphabetic comparaison | |
343 | // of item labels (GetText) | |
344 | virtual int OnCompareItems(const wxTreeItemId& item1, | |
345 | const wxTreeItemId& item2); | |
346 | // sort the children of this item using OnCompareItems | |
08b7c251 | 347 | // |
95aabccc VZ |
348 | // NB: this function is not reentrant and not MT-safe (FIXME)! |
349 | void SortChildren(const wxTreeItemId& item); | |
08b7c251 VZ |
350 | |
351 | // helpers | |
352 | // ------- | |
353 | ||
add28c55 VZ |
354 | // determine to which item (if any) belongs the given point (the |
355 | // coordinates specified are relative to the client area of tree ctrl) | |
356 | // and fill the flags parameter with a bitmask of wxTREE_HITTEST_xxx | |
357 | // constants. | |
358 | // | |
359 | // The first function is more portable (because easier to implement | |
360 | // on other platforms), but the second one returns some extra info. | |
361 | wxTreeItemId HitTest(const wxPoint& point) | |
362 | { int dummy; return HitTest(point, dummy); } | |
363 | wxTreeItemId HitTest(const wxPoint& point, int& flags); | |
08b7c251 VZ |
364 | |
365 | // get the bounding rectangle of the item (or of its label only) | |
f7c832a7 | 366 | bool GetBoundingRect(const wxTreeItemId& item, |
16e93305 | 367 | wxRect& rect, |
dabbc6a5 | 368 | bool textOnly = false) const; |
08b7c251 | 369 | |
08b7c251 VZ |
370 | // deprecated |
371 | // ---------- | |
372 | ||
ee4b2721 | 373 | #if WXWIN_COMPATIBILITY_2_4 |
08b7c251 | 374 | // these methods are deprecated and will be removed in future versions of |
77ffb593 | 375 | // wxWidgets, they're here for compatibility only, don't use them in new |
08b7c251 VZ |
376 | // code (the comments indicate why these methods are now useless and how to |
377 | // replace them) | |
378 | ||
379 | // use Expand, Collapse, CollapseAndReset or Toggle | |
ee4b2721 | 380 | wxDEPRECATED( void ExpandItem(const wxTreeItemId& item, int action) ); |
08b7c251 VZ |
381 | |
382 | // use AddRoot, PrependItem or AppendItem | |
ee4b2721 | 383 | wxDEPRECATED( wxTreeItemId InsertItem(const wxTreeItemId& parent, |
08b7c251 VZ |
384 | const wxString& text, |
385 | int image = -1, int selImage = -1, | |
ee4b2721 | 386 | long insertAfter = wxTREE_INSERT_LAST) ); |
08b7c251 VZ |
387 | |
388 | // use Set/GetImageList and Set/GetStateImageList | |
a6fb8636 WS |
389 | wxDEPRECATED( wxImageList *GetImageList(int) const ); |
390 | wxDEPRECATED( void SetImageList(wxImageList *imageList, int) ); | |
08b7c251 | 391 | |
74b31181 | 392 | // use Set/GetItemImage directly |
a6fb8636 WS |
393 | wxDEPRECATED( int GetItemSelectedImage(const wxTreeItemId& item) const ); |
394 | wxDEPRECATED( void SetItemSelectedImage(const wxTreeItemId& item, int image) ); | |
74b31181 | 395 | |
ee4b2721 VZ |
396 | // use the versions taking wxTreeItemIdValue cookies |
397 | wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item, | |
398 | long& cookie) const ); | |
399 | wxDEPRECATED( wxTreeItemId GetNextChild(const wxTreeItemId& item, | |
400 | long& cookie) const ); | |
401 | #endif // WXWIN_COMPATIBILITY_2_4 | |
402 | ||
d4864e97 | 403 | |
08b7c251 VZ |
404 | // implementation |
405 | // -------------- | |
3f7bc32b | 406 | |
39c7a53c VZ |
407 | virtual bool ShouldInheritColours() const { return false; } |
408 | ||
409 | virtual wxVisualAttributes GetDefaultAttributes() const | |
410 | { | |
411 | return GetClassDefaultAttributes(GetWindowVariant()); | |
412 | } | |
413 | ||
414 | static wxVisualAttributes | |
415 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
416 | ||
417 | ||
c140b7e7 | 418 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
fbd8ac52 | 419 | virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
fd3f686c | 420 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
a23fd0e1 | 421 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
08b7c251 | 422 | |
bb448552 VZ |
423 | // override some base class virtuals |
424 | virtual bool SetBackgroundColour(const wxColour &colour); | |
425 | virtual bool SetForegroundColour(const wxColour &colour); | |
426 | ||
9dfbf520 VZ |
427 | // get/set the check state for the item (only for wxTR_MULTIPLE) |
428 | bool IsItemChecked(const wxTreeItemId& item) const; | |
dabbc6a5 | 429 | void SetItemCheck(const wxTreeItemId& item, bool check = true); |
9dfbf520 | 430 | |
8a000b6b VZ |
431 | // set/get the item state.image (state == -1 means cycle to the next one) |
432 | void SetState(const wxTreeItemId& node, int state); | |
433 | int GetState(const wxTreeItemId& node); | |
434 | ||
2bda0e17 | 435 | protected: |
08b7c251 VZ |
436 | // SetImageList helper |
437 | void SetAnyImageList(wxImageList *imageList, int which); | |
438 | ||
d00407b2 VZ |
439 | // refresh a single item |
440 | void RefreshItem(const wxTreeItemId& item); | |
441 | ||
d35dce3a VZ |
442 | // end edit label |
443 | void DoEndEditLabel(bool discardChanges = false); | |
444 | ||
445 | ||
329eeca9 VZ |
446 | // data used only while editing the item label: |
447 | wxTextCtrl *m_textCtrl; // text control in which it is edited | |
448 | wxTreeItemId m_idEdited; // the item being edited | |
449 | ||
08b7c251 VZ |
450 | wxImageList *m_imageListNormal, // images for tree elements |
451 | *m_imageListState; // special images for app defined states | |
329eeca9 VZ |
452 | bool m_ownsImageListNormal, |
453 | m_ownsImageListState; | |
08b7c251 VZ |
454 | |
455 | private: | |
456 | // the common part of all ctors | |
457 | void Init(); | |
458 | ||
459 | // helper functions | |
460 | inline bool DoGetItem(wxTreeViewItem *tvItem) const; | |
461 | inline void DoSetItem(wxTreeViewItem *tvItem); | |
462 | ||
463 | inline void DoExpand(const wxTreeItemId& item, int flag); | |
464 | ||
465 | wxTreeItemId DoInsertItem(const wxTreeItemId& parent, | |
466 | wxTreeItemId hInsertAfter, | |
467 | const wxString& text, | |
468 | int image, int selectedImage, | |
469 | wxTreeItemData *data); | |
470 | ||
74b31181 VZ |
471 | int DoGetItemImageFromData(const wxTreeItemId& item, |
472 | wxTreeItemIcon which) const; | |
473 | void DoSetItemImageFromData(const wxTreeItemId& item, | |
474 | int image, | |
475 | wxTreeItemIcon which) const; | |
9dfbf520 VZ |
476 | void DoSetItemImages(const wxTreeItemId& item, int image, int imageSel); |
477 | ||
08b7c251 | 478 | void DeleteTextCtrl(); |
092bddef | 479 | |
502a2b18 VZ |
480 | // support for additional item images which we implement using |
481 | // wxTreeItemIndirectData technique - see the comments in msw/treectrl.cpp | |
74b31181 | 482 | void SetIndirectItemData(const wxTreeItemId& item, |
502a2b18 | 483 | class wxTreeItemIndirectData *data); |
74b31181 | 484 | bool HasIndirectData(const wxTreeItemId& item) const; |
502a2b18 | 485 | bool IsDataIndirect(wxTreeItemData *data) const |
8b4a9377 | 486 | { return data && data->GetId().m_pItem == 0; } |
74b31181 | 487 | |
ee4b2721 VZ |
488 | // the hash storing the items attributes (indexed by item ids) |
489 | wxMapTreeAttr m_attrs; | |
696e1ea0 | 490 | |
dabbc6a5 | 491 | // true if the hash above is not empty |
696e1ea0 VZ |
492 | bool m_hasAnyAttr; |
493 | ||
23f681ec VZ |
494 | // used for dragging |
495 | wxDragImage *m_dragImage; | |
496 | ||
a9c1265f VZ |
497 | // Virtual root item, if wxTR_HIDE_ROOT is set. |
498 | void* m_pVirtualRoot; | |
499 | ||
3f7bc32b | 500 | // the starting item for selection with Shift |
e3ad5702 JS |
501 | wxTreeItemId m_htSelStart, m_htClickedItem; |
502 | wxPoint m_ptClick; | |
3f7bc32b | 503 | |
502a2b18 VZ |
504 | friend class wxTreeItemIndirectData; |
505 | friend class wxTreeSortHelper; | |
506 | ||
092bddef | 507 | DECLARE_DYNAMIC_CLASS(wxTreeCtrl) |
22f3361e | 508 | DECLARE_NO_COPY_CLASS(wxTreeCtrl) |
2bda0e17 KB |
509 | }; |
510 | ||
1e6feb95 VZ |
511 | #endif // wxUSE_TREECTRL |
512 | ||
2bda0e17 | 513 | #endif |
bbcdf8bc | 514 | // _WX_TREECTRL_H_ |