]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/gizmos/_treelist.i
deprecation fixes, plus some code size reduction and cleanup
[wxWidgets.git] / wxPython / contrib / gizmos / _treelist.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _treelist.i
3 // Purpose: wxTreeListCtrl and helpers
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 12-Sept-2006
8 // RCS-ID: $Id$
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 #include "wx/treelistctrl.h"
20 #include "wx/wxPython/pytree.h"
21
22 %}
23
24 //---------------------------------------------------------------------------
25 %newgroup
26
27
28 MAKE_CONST_WXSTRING2(TreeListCtrlNameStr, wxT("treelistctrl"));
29
30
31 //----------------------------------------------------------------------------
32 // wxTreeListCtrl - the multicolumn tree control
33 //----------------------------------------------------------------------------
34
35
36
37 enum {
38 DEFAULT_COL_WIDTH = 100
39 };
40
41 // modes for navigation
42 enum {
43 wxTL_MODE_NAV_FULLTREE,
44 wxTL_MODE_NAV_EXPANDED,
45 wxTL_MODE_NAV_VISIBLE,
46 wxTL_MODE_NAV_LEVEL
47 };
48
49 // modes for FindItem
50 enum {
51 wxTL_MODE_FIND_EXACT,
52 wxTL_MODE_FIND_PARTIAL,
53 wxTL_MODE_FIND_NOCASE
54 };
55
56 // additional flag for HitTest
57 enum {
58 wxTREE_HITTEST_ONITEMCOLUMN
59 };
60 %pythoncode { wx.TREE_HITTEST_ONITEMCOLUMN = TREE_HITTEST_ONITEMCOLUMN }
61
62
63 // additional style flags
64 enum {
65 wxTR_COLUMN_LINES, // put border around items
66 wxTR_VIRTUAL // The application provides items text on demand.
67 };
68 %pythoncode {
69 wx.TR_COLUMN_LINES = TR_COLUMN_LINES
70 wxTR_VIRTUAL = TR_VIRTUAL
71 }
72
73
74 %pythoncode {
75 %#// Compatibility aliases for old names/values
76 TL_ALIGN_LEFT = wx.ALIGN_LEFT
77 TL_ALIGN_RIGHT = wx.ALIGN_RIGHT
78 TL_ALIGN_CENTER = wx.ALIGN_CENTER
79
80 TL_SEARCH_VISIBLE = TL_MODE_NAV_VISIBLE
81 TL_SEARCH_LEVEL = TL_MODE_NAV_LEVEL
82 TL_SEARCH_FULL = TL_MODE_FIND_EXACT
83 TL_SEARCH_PARTIAL = TL_MODE_FIND_PARTIAL
84 TL_SEARCH_NOCASE = TL_MODE_FIND_NOCASE
85
86 TR_DONT_ADJUST_MAC = 0
87 wx.TR_DONT_ADJUST_MAC = TR_DONT_ADJUST_MAC
88 }
89
90
91
92
93 class wxTreeListColumnInfo: public wxObject {
94 public:
95 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
96 int width = DEFAULT_COL_WIDTH,
97 int flag = wxALIGN_LEFT,
98 int image = -1,
99 bool shown = true,
100 bool edit = false);
101
102 ~wxTreeListColumnInfo();
103
104 int GetAlignment() const;
105 wxString GetText() const;
106 int GetImage() const;
107 int GetSelectedImage() const;
108 size_t GetWidth() const;
109 bool IsEditable() const { return m_edit; }
110 bool IsShown() const { return m_shown; }
111
112 // TODO: These all actually return wxTreeListColumnInfo&, any problem with doing it for Python too?
113 void SetAlignment(int alignment);
114 void SetText(const wxString& text);
115 void SetImage(int image);
116 void SetSelectedImage(int image);
117 void SetWidth(size_t with);
118 void SetEditable (bool edit);
119 void SetShown(bool shown);
120
121 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
122 %property(Image, GetImage, SetImage, doc="See `GetImage` and `SetImage`");
123 %property(SelectedImage, GetSelectedImage, SetSelectedImage, doc="See `GetSelectedImage` and `SetSelectedImage`");
124 %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
125 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
126 %property(Editable, IsEditable, SetEditable);
127 %property(Shown, IsShown, SetShown);
128 };
129
130
131
132
133 %{ // C++ version of Python aware control
134 class wxPyTreeListCtrl : public wxTreeListCtrl {
135 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
136 public:
137 wxPyTreeListCtrl() : wxTreeListCtrl() {}
138 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
139 const wxPoint& pos,
140 const wxSize& size,
141 long style,
142 const wxValidator &validator,
143 const wxString& name) :
144 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
145
146 virtual int OnCompareItems(const wxTreeItemId& item1,
147 const wxTreeItemId& item2) {
148 int rval = 0;
149 bool found;
150 wxPyBlock_t blocked = wxPyBeginBlockThreads();
151 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
152 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
153 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
154 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
155 Py_DECREF(o1);
156 Py_DECREF(o2);
157 }
158 wxPyEndBlockThreads(blocked);
159 if (! found)
160 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
161 return rval;
162 }
163
164 virtual wxString OnGetItemText( wxTreeItemData* item, long column ) const {
165 wxString rval;
166 bool found;
167 wxPyBlock_t blocked = wxPyBeginBlockThreads();
168 if ((found = wxPyCBH_findCallback(m_myInst, "OnGetItemText"))) {
169 PyObject* ro;
170 PyObject* itemo = wxPyConstructObject((void*)&item, wxT("wxTreeItemId"), 0);
171 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)", itemo, column));
172 Py_DECREF(itemo);
173 if (ro) {
174 rval = Py2wxString(ro);
175 Py_DECREF(ro);
176 }
177 }
178 wxPyEndBlockThreads(blocked);
179 if (! found)
180 rval = wxTreeListCtrl::OnGetItemText(item, column);
181 return rval;
182 }
183
184 PYPRIVATE;
185 };
186
187 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
188
189 %}
190
191
192
193
194
195
196 MustHaveApp(wxPyTreeListCtrl);
197
198 %rename(TreeListCtrl) wxPyTreeListCtrl;
199 class wxPyTreeListCtrl : public wxControl
200 {
201 public:
202 %pythonAppend wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
203 %pythonAppend wxPyTreeListCtrl() ""
204
205 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
206 const wxPoint& pos = wxDefaultPosition,
207 const wxSize& size = wxDefaultSize,
208 long style = wxTR_DEFAULT_STYLE,
209 const wxValidator &validator = wxDefaultValidator,
210 const wxString& name = wxPyTreeListCtrlNameStr );
211 %RenameCtor(PreTreeListCtrl, wxPyTreeListCtrl());
212
213 bool Create(wxWindow *parent, wxWindowID id = -1,
214 const wxPoint& pos = wxDefaultPosition,
215 const wxSize& size = wxDefaultSize,
216 long style = wxTR_DEFAULT_STYLE,
217 const wxValidator &validator = wxDefaultValidator,
218 const wxString& name = wxPyTreeListCtrlNameStr );
219
220 void _setCallbackInfo(PyObject* self, PyObject* _class);
221
222
223 // get the total number of items in the control
224 size_t GetCount() const;
225
226 // indent is the number of pixels the children are indented relative to
227 // the parents position. SetIndent() also redraws the control
228 // immediately.
229 unsigned int GetIndent() const;
230 void SetIndent(unsigned int indent);
231
232 // line spacing is the space above and below the text on each line
233 unsigned int GetLineSpacing() const;
234 void SetLineSpacing(unsigned int spacing);
235
236 // image list: these functions allow to associate an image list with
237 // the control and retrieve it. Note that when assigned with
238 // SetImageList, the control does _not_ delete
239 // the associated image list when it's deleted in order to allow image
240 // lists to be shared between different controls. If you use
241 // AssignImageList, the control _does_ delete the image list.
242 //
243 // The normal image list is for the icons which correspond to the
244 // normal tree item state (whether it is selected or not).
245 // Additionally, the application might choose to show a state icon
246 // which corresponds to an app-defined item state (for example,
247 // checked/unchecked) which are taken from the state image list.
248 wxImageList *GetImageList() const;
249 wxImageList *GetStateImageList() const;
250 wxImageList *GetButtonsImageList() const;
251
252 void SetImageList(wxImageList *imageList);
253 void SetStateImageList(wxImageList *imageList);
254 void SetButtonsImageList(wxImageList *imageList);
255
256 %disownarg( wxImageList *imageList );
257 void AssignImageList(wxImageList *imageList);
258 void AssignStateImageList(wxImageList *imageList);
259 void AssignButtonsImageList(wxImageList *imageList);
260 %cleardisown( wxImageList *imageList );
261
262
263 // adds a column
264 void AddColumn (const wxString& text,
265 int width = DEFAULT_COL_WIDTH,
266 int flag = wxALIGN_LEFT,
267 int image = -1,
268 bool shown = true,
269 bool edit = false);
270 %Rename(AddColumnInfo, void, AddColumn(const wxTreeListColumnInfo& col));
271
272 // inserts a column before the given one
273 void InsertColumn (int before,
274 const wxString& text,
275 int width = DEFAULT_COL_WIDTH,
276 int flag = wxALIGN_LEFT,
277 int image = -1,
278 bool shown = true,
279 bool edit = false);
280 %Rename(InsertColumnInfo, void, InsertColumn(size_t before, const wxTreeListColumnInfo& col));
281
282 // deletes the given column - does not delete the corresponding column
283 // of each item
284 void RemoveColumn(size_t column);
285
286 // returns the number of columns in the ctrl
287 size_t GetColumnCount() const;
288
289 // tells which column is the "main" one, i.e. the "threaded" one
290 void SetMainColumn(size_t column);
291 size_t GetMainColumn() const;
292
293 void SetColumn (int column, const wxTreeListColumnInfo& colInfo);
294 wxTreeListColumnInfo& GetColumn (int column);
295
296 void SetColumnText (int column, const wxString& text);
297 wxString GetColumnText (int column) const;
298
299 void SetColumnWidth (int column, int width);
300 int GetColumnWidth (int column) const;
301
302 void SetColumnAlignment (int column, int flag);
303 int GetColumnAlignment (int column) const;
304
305 void SetColumnImage (int column, int image);
306 int GetColumnImage (int column) const;
307
308 void SetColumnShown (int column, bool shown = true);
309 bool IsColumnShown (int column) const;
310 %pythoncode { ShowColumn = SetColumnShown }
311
312 void SetColumnEditable (int column, bool edit = true);
313 bool IsColumnEditable (int column) const;
314
315
316
317
318 %extend {
319 // retrieves item's label of the given column (main column by default)
320 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
321 if (column < 0) column = self->GetMainColumn();
322 return self->GetItemText(item, column);
323 }
324
325 // get one of the images associated with the item (normal by default)
326 int GetItemImage(const wxTreeItemId& item, int column = -1,
327 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
328 if (column < 0) column = self->GetMainColumn();
329 return self->GetItemImage(item, column, which);
330 }
331
332 // set item's label (main column by default)
333 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
334 if (column < 0) column = self->GetMainColumn();
335 self->SetItemText(item, column, text);
336 }
337
338 // set one of the images associated with the item (normal by default)
339 // the which parameter is ignored for all columns but the main one
340 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
341 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
342 if (column < 0) column = self->GetMainColumn();
343 self->SetItemImage(item, column, image, which);
344 }
345
346
347 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
348 // if needed.
349 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
350 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
351 if (data == NULL) {
352 data = new wxPyTreeItemData();
353 data->SetId(item); // set the id
354 self->SetItemData(item, data);
355 }
356 return data;
357 }
358
359 %disownarg( wxPyTreeItemData* data );
360 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
361 data->SetId(item); // set the id
362 self->SetItemData(item, data);
363 }
364 %cleardisown(wxPyTreeItemData* data );
365
366 // [Get|Set]ItemPyData are short-cuts. Also made somewhat crash-proof by
367 // automatically creating data classes.
368 PyObject* GetItemPyData(const wxTreeItemId& item) {
369 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
370 if (data == NULL) {
371 data = new wxPyTreeItemData();
372 data->SetId(item); // set the id
373 self->SetItemData(item, data);
374 }
375 return data->GetData();
376 }
377
378 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
379 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
380 if (data == NULL) {
381 data = new wxPyTreeItemData(obj);
382 data->SetId(item); // set the id
383 self->SetItemData(item, data);
384 } else
385 data->SetData(obj);
386 }
387 }
388 %pythoncode { GetPyData = GetItemPyData }
389 %pythoncode { SetPyData = SetItemPyData }
390
391
392 bool GetItemBold(const wxTreeItemId& item) const;
393 wxColour GetItemTextColour(const wxTreeItemId& item) const;
394 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
395 wxFont GetItemFont(const wxTreeItemId& item) const;
396
397
398 // force appearance of [+] button near the item. This is useful to
399 // allow the user to expand the items which don't have any children now
400 // - but instead add them only when needed, thus minimizing memory
401 // usage and loading time.
402 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
403
404 // the item will be shown in bold
405 void SetItemBold(const wxTreeItemId& item, bool bold = true);
406
407 // set the item's text colour
408 void SetItemTextColour(const wxTreeItemId& item, const wxColour& colour);
409
410 // set the item's background colour
411 void SetItemBackgroundColour(const wxTreeItemId& item,
412 const wxColour& colour);
413
414 // set the item's font (should be of the same height for all items)
415 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
416
417
418
419 // is the item visible (it might be outside the view or not expanded)?
420 bool IsVisible(const wxTreeItemId& item) const;
421
422 // does the item has any children?
423 bool HasChildren(const wxTreeItemId& item) const;
424 %pythoncode { ItemHasChildren = HasChildren }
425
426 // is the item expanded (only makes sense if HasChildren())?
427 bool IsExpanded(const wxTreeItemId& item) const;
428
429 // is this item currently selected (the same as has focus)?
430 bool IsSelected(const wxTreeItemId& item) const;
431
432 // is item text in bold font?
433 bool IsBold(const wxTreeItemId& item) const;
434
435
436 // if 'recursively' is False, only immediate children count, otherwise
437 // the returned number is the number of all items in this branch
438 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true);
439
440
441 // wxTreeItemId.IsOk() will return False if there is no such item
442
443 // get the root tree item
444 wxTreeItemId GetRootItem() const;
445
446 // get the item currently selected (may return NULL if no selection)
447 wxTreeItemId GetSelection() const;
448
449 // get the items currently selected, return the number of such item
450 //size_t GetSelections(wxArrayTreeItemIds&) const;
451 %extend {
452 PyObject* GetSelections() {
453 wxPyBlock_t blocked = wxPyBeginBlockThreads();
454 PyObject* rval = PyList_New(0);
455 wxArrayTreeItemIds array;
456 size_t num, x;
457 num = self->GetSelections(array);
458 for (x=0; x < num; x++) {
459 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
460 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
461 PyList_Append(rval, item);
462 Py_DECREF(item);
463 }
464 wxPyEndBlockThreads(blocked);
465 return rval;
466 }
467 }
468
469
470 // get the parent of this item (may return NULL if root)
471 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
472
473 // for this enumeration function you must pass in a "cookie" parameter
474 // which is opaque for the application but is necessary for the library
475 // to make these functions reentrant (i.e. allow more than one
476 // enumeration on one and the same object simultaneously). Of course,
477 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
478 // the same!
479
480
481 // NOTE: These are a copy of the same methods in _treectrl.i, be sure to
482 // update both at the same time. (Or find a good way to refactor!)
483 %extend {
484 // Get the first child of this item. Returns a wxTreeItemId and an
485 // opaque "cookie" value that should be passed to GetNextChild in
486 // order to continue the search.
487 PyObject* GetFirstChild(const wxTreeItemId& item) {
488 void* cookie = 0;
489 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
490 wxPyBlock_t blocked = wxPyBeginBlockThreads();
491 PyObject* tup = PyTuple_New(2);
492 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
493 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
494 wxPyEndBlockThreads(blocked);
495 return tup;
496 }
497
498
499 // Get the next child of this item. The cookie parameter is the 2nd
500 // value returned from GetFirstChild or the previous GetNextChild.
501 // Returns a wxTreeItemId and an opaque "cookie" value that should be
502 // passed to GetNextChild in order to continue the search.
503 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
504 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
505 wxPyBlock_t blocked = wxPyBeginBlockThreads();
506 PyObject* tup = PyTuple_New(2);
507 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
508 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
509 wxPyEndBlockThreads(blocked);
510 return tup;
511 }
512
513
514 PyObject* GetLastChild(const wxTreeItemId& item) {
515 void* cookie = 0;
516 wxTreeItemId* ritem = new wxTreeItemId(self->GetLastChild(item, cookie));
517 wxPyBlock_t blocked = wxPyBeginBlockThreads();
518 PyObject* tup = PyTuple_New(2);
519 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
520 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
521 wxPyEndBlockThreads(blocked);
522 return tup;
523 }
524
525
526 PyObject* GetPrevChild(const wxTreeItemId& item, void* cookie) {
527 wxTreeItemId* ritem = new wxTreeItemId(self->GetPrevChild(item, cookie));
528 wxPyBlock_t blocked = wxPyBeginBlockThreads();
529 PyObject* tup = PyTuple_New(2);
530 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
531 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
532 wxPyEndBlockThreads(blocked);
533 return tup;
534 }
535 }
536
537
538 // get the next sibling of this item
539 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
540
541 // get the previous sibling
542 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
543
544
545 // get item in the full tree (currently only for internal use)
546 wxTreeItemId GetNext(const wxTreeItemId& item) const;
547 wxTreeItemId GetPrev(const wxTreeItemId& item) const;
548
549 // get expanded item, see IsExpanded()
550 wxTreeItemId GetFirstExpandedItem() const;
551 wxTreeItemId GetNextExpanded(const wxTreeItemId& item) const;
552 wxTreeItemId GetPrevExpanded(const wxTreeItemId& item) const;
553
554 // get visible item, see IsVisible()
555 wxTreeItemId GetFirstVisibleItem(bool fullRow = false) const;
556 wxTreeItemId GetNextVisible(const wxTreeItemId& item, bool fullRow = false) const;
557 wxTreeItemId GetPrevVisible(const wxTreeItemId& item, bool fullRow = false) const;
558
559
560
561 %disownarg( wxPyTreeItemData* data );
562
563 // add the root node to the tree
564 wxTreeItemId AddRoot(const wxString& text,
565 int image = -1, int selectedImage = -1,
566 wxPyTreeItemData *data = NULL);
567
568 // insert a new item in as the first child of the parent
569 wxTreeItemId PrependItem(const wxTreeItemId& parent,
570 const wxString& text,
571 int image = -1, int selectedImage = -1,
572 wxPyTreeItemData *data = NULL);
573
574 // insert a new item after a given one
575 wxTreeItemId InsertItem(const wxTreeItemId& parent,
576 const wxTreeItemId& idPrevious,
577 const wxString& text,
578 int image = -1, int selectedImage = -1,
579 wxPyTreeItemData *data = NULL);
580
581 // insert a new item before the one with the given index
582 %Rename(InsertItemBefore,
583 wxTreeItemId, InsertItem(const wxTreeItemId& parent,
584 size_t index,
585 const wxString& text,
586 int image = -1, int selectedImage = -1,
587 wxPyTreeItemData *data = NULL));
588
589 // insert a new item in as the last child of the parent
590 wxTreeItemId AppendItem(const wxTreeItemId& parent,
591 const wxString& text,
592 int image = -1, int selectedImage = -1,
593 wxPyTreeItemData *data = NULL);
594
595 %cleardisown(wxPyTreeItemData* data );
596
597 // delete this item and associated data if any
598 void Delete(const wxTreeItemId& item);
599
600 // delete all children (but don't delete the item itself)
601 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
602 void DeleteChildren(const wxTreeItemId& item);
603
604 // delete all items from the tree
605 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
606 void DeleteRoot();
607 %pythoncode { DeleteAllItems = DeleteRoot }
608
609
610
611 // expand this item
612 void Expand(const wxTreeItemId& item);
613
614 // expand this item and all subitems recursively
615 void ExpandAll(const wxTreeItemId& item);
616
617 // collapse the item without removing its children
618 void Collapse(const wxTreeItemId& item);
619
620 // collapse the item and remove all children
621 void CollapseAndReset(const wxTreeItemId& item);
622
623 // toggles the current state
624 void Toggle(const wxTreeItemId& item);
625
626 // remove the selection from currently selected item (if any)
627 void Unselect();
628 void UnselectAll();
629
630 // select this item
631 void SelectItem(const wxTreeItemId& item,
632 const wxTreeItemId& last = (wxTreeItemId*)NULL,
633 bool unselect_others=true);
634
635 void SelectAll();
636
637 // make sure this item is visible (expanding the parent item and/or
638 // scrolling to this item if necessary)
639 void EnsureVisible(const wxTreeItemId& item);
640
641 // scroll to this item (but don't expand its parent)
642 void ScrollTo(const wxTreeItemId& item);
643
644 // Returns wxTreeItemId, flags, and column
645 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
646
647 %extend {
648 // get the bounding rectangle of the item (or of its label only)
649 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
650 wxRect rect;
651 if (self->GetBoundingRect(item, rect, textOnly)) {
652 wxPyBlock_t blocked = wxPyBeginBlockThreads();
653 wxRect* r = new wxRect(rect);
654 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
655 wxPyEndBlockThreads(blocked);
656 return val;
657 }
658 else {
659 RETURN_NONE();
660 }
661 }
662 }
663
664
665 %extend {
666 // Start editing the item label: this (temporarily) replaces the item
667 // with a one line edit control. The item will be selected if it hadn't
668 // been before.
669 void EditLabel(const wxTreeItemId& item, int column = -1) {
670 if (column < 0) column = self->GetMainColumn();
671 self->EditLabel(item, column);
672 }
673 }
674 %pythoncode { Edit = EditLabel }
675
676 // sort the children of this item using OnCompareItems
677 void SortChildren(const wxTreeItemId& item);
678
679 // searching
680 wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, int flags = 0);
681
682 // drop over item
683 void SetDragItem (const wxTreeItemId& item = (wxTreeItemId*)NULL);
684
685 wxWindow* GetHeaderWindow() const;
686 wxScrolledWindow* GetMainWindow() const;
687
688 %property(ButtonsImageList, GetButtonsImageList, SetButtonsImageList, doc="See `GetButtonsImageList` and `SetButtonsImageList`");
689 %property(ColumnCount, GetColumnCount, doc="See `GetColumnCount`");
690 %property(Count, GetCount, doc="See `GetCount`");
691 %property(HeaderWindow, GetHeaderWindow, doc="See `GetHeaderWindow`");
692 %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`");
693 %property(Indent, GetIndent, SetIndent, doc="See `GetIndent` and `SetIndent`");
694 %property(LineSpacing, GetLineSpacing, SetLineSpacing, doc="See `GetLineSpacing` and `SetLineSpacing`");
695 %property(MainColumn, GetMainColumn, SetMainColumn, doc="See `GetMainColumn` and `SetMainColumn`");
696 %property(MainWindow, GetMainWindow, doc="See `GetMainWindow`");
697 %property(Next, GetNext, doc="See `GetNext`");
698 %property(RootItem, GetRootItem, doc="See `GetRootItem`");
699 %property(Selection, GetSelection, doc="See `GetSelection`");
700 %property(Selections, GetSelections, doc="See `GetSelections`");
701 %property(StateImageList, GetStateImageList, SetStateImageList, doc="See `GetStateImageList` and `SetStateImageList`");
702 };
703
704 //----------------------------------------------------------------------
705
706 %init %{
707 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
708 %}
709
710 //----------------------------------------------------------------------