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