1
/////////////////////////////////////////////////////////////////////////////
3
// Purpose: SWIG interface file for wxTreeCtrl and related classes
7
// Created: 10-June-1998
8
// RCS-ID: $Id: _treectrl.i 71592 2012-05-30 03:10:49Z RD $
9
// Copyright: (c) 2002 by Total Control Software
10
// Licence: wxWindows license
11
/////////////////////////////////////////////////////////////////////////////
16
//---------------------------------------------------------------------------
19
#include <wx/treectrl.h>
20
#include "wx/wxPython/pytree.h"
23
MAKE_CONST_WXSTRING2(TreeCtrlNameStr, _T("wxTreeCtrl"));
25
//---------------------------------------------------------------------------
39
wxTR_HAS_VARIABLE_ROW_HEIGHT,
45
wxTR_FULL_ROW_HIGHLIGHT,
59
wxTreeItemIcon_Normal, // not selected, not expanded
60
wxTreeItemIcon_Selected, // selected, not expanded
61
wxTreeItemIcon_Expanded, // not selected, expanded
62
wxTreeItemIcon_SelectedExpanded, // selected, expanded
67
wxTREE_ITEMSTATE_NONE, // not state (no display state image)
68
wxTREE_ITEMSTATE_NEXT, // cycle to the next state
69
wxTREE_ITEMSTATE_PREV // cycle to the previous state
72
// constants for HitTest
76
wxTREE_HITTEST_NOWHERE,
77
wxTREE_HITTEST_ONITEMBUTTON,
78
wxTREE_HITTEST_ONITEMICON,
79
wxTREE_HITTEST_ONITEMINDENT,
80
wxTREE_HITTEST_ONITEMLABEL,
81
wxTREE_HITTEST_ONITEMRIGHT,
82
wxTREE_HITTEST_ONITEMSTATEICON,
83
wxTREE_HITTEST_TOLEFT,
84
wxTREE_HITTEST_TORIGHT,
85
wxTREE_HITTEST_ONITEMUPPERPART,
86
wxTREE_HITTEST_ONITEMLOWERPART,
90
//---------------------------------------------------------------------------
94
// wxTreeItemId identifies an element of the tree. In this implementation, it's
95
// just a trivial wrapper around Win32 HTREEITEM or a pointer to some private
96
// data structure in the generic version. It's opaque for the application and
97
// the only method which can be used by user code is IsOk().
103
// is this a valid tree item?
107
bool __eq__(const wxTreeItemId* other) { return other ? (*self == *other) : false; }
108
bool __ne__(const wxTreeItemId* other) { return other ? (*self != *other) : true; }
116
def __nonzero__(self): return self.IsOk() }
122
// wxTreeItemData is some (arbitrary) user data associated with some tree
123
// item. The Python version is just a simple wrapper around a Python object
124
// that knows how to handle references properly. Using this class directly in
125
// Python code should rarely be neccessary. Just use the GetItemPyData and
126
// SetItemPyData tree methods instead of the GetItemData and SetItemData
128
%rename(TreeItemData) wxPyTreeItemData;
129
class wxPyTreeItemData {
131
wxPyTreeItemData(PyObject* obj = NULL);
135
void SetData(PyObject* obj);
137
const wxTreeItemId& GetId();
138
void SetId(const wxTreeItemId& id);
140
%pythonPrepend Destroy "args[0].this.own(False)"
141
%extend { void Destroy() { delete self; } }
143
%property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
144
%property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
149
#if 0 // it's not currently used anywhere...
151
// wxTreeItemAttr: a structure containing the visual attributes of an item
156
//wxTreeItemAttr() { }
157
wxTreeItemAttr(const wxColour& colText = wxNullColour,
158
const wxColour& colBack = wxNullColour,
159
const wxFont& font = wxNullFont);
163
void SetTextColour(const wxColour& colText);
164
void SetBackgroundColour(const wxColour& colBack);
165
void SetFont(const wxFont& font);
168
bool HasTextColour();
169
bool HasBackgroundColour();
172
wxColour GetTextColour();
173
wxColour GetBackgroundColour();
176
%pythonAppend Destroy "args[0].thisown = 0"
177
%extend { void Destroy() { delete self; } }
183
//---------------------------------------------------------------------------
186
/* Tree control event types */
187
%constant wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG;
188
%constant wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG;
189
%constant wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
190
%constant wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT;
191
%constant wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM;
192
%constant wxEventType wxEVT_COMMAND_TREE_GET_INFO;
193
%constant wxEventType wxEVT_COMMAND_TREE_SET_INFO;
194
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED;
195
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING;
196
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED;
197
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING;
198
%constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED;
199
%constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING;
200
%constant wxEventType wxEVT_COMMAND_TREE_KEY_DOWN;
201
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED;
202
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
203
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK;
204
%constant wxEventType wxEVT_COMMAND_TREE_END_DRAG;
205
%constant wxEventType wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK;
206
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP;
207
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_MENU;
210
EVT_TREE_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_DRAG , 1)
211
EVT_TREE_BEGIN_RDRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_RDRAG , 1)
212
EVT_TREE_BEGIN_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT , 1)
213
EVT_TREE_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_TREE_END_LABEL_EDIT , 1)
214
EVT_TREE_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_TREE_DELETE_ITEM , 1)
215
EVT_TREE_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_TREE_GET_INFO , 1)
216
EVT_TREE_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_TREE_SET_INFO , 1)
217
EVT_TREE_ITEM_EXPANDED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_EXPANDED , 1)
218
EVT_TREE_ITEM_EXPANDING = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_EXPANDING , 1)
219
EVT_TREE_ITEM_COLLAPSED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_COLLAPSED , 1)
220
EVT_TREE_ITEM_COLLAPSING = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_COLLAPSING , 1)
221
EVT_TREE_SEL_CHANGED = wx.PyEventBinder(wxEVT_COMMAND_TREE_SEL_CHANGED , 1)
222
EVT_TREE_SEL_CHANGING = wx.PyEventBinder(wxEVT_COMMAND_TREE_SEL_CHANGING , 1)
223
EVT_TREE_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_TREE_KEY_DOWN , 1)
224
EVT_TREE_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_ACTIVATED , 1)
225
EVT_TREE_ITEM_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK , 1)
226
EVT_TREE_ITEM_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, 1)
227
EVT_TREE_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_END_DRAG , 1)
228
EVT_TREE_STATE_IMAGE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK, 1)
229
EVT_TREE_ITEM_GETTOOLTIP = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 1)
230
EVT_TREE_ITEM_MENU = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_MENU, 1)
235
static wxTreeItemId wxNullTreeItemId;
237
wxTreeItemId wxNullTreeItemId;
240
// wxTreeEvent is a special class for all events associated with tree controls
242
// NB: note that not all accessors make sense for all events, see the event
243
// descriptions below
244
class wxTreeEvent : public wxNotifyEvent {
246
%nokwargs wxTreeEvent;
247
wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
248
wxTreeEvent(wxEventType commandType,
250
wxTreeItemId& item = wxNullTreeItemId);
252
// get the item on which the operation was performed or the newly
253
// selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events
254
wxTreeItemId GetItem() const;
255
void SetItem(const wxTreeItemId& item);
257
// for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously
259
wxTreeItemId GetOldItem() const;
260
void SetOldItem(const wxTreeItemId& item);
262
// the point where the mouse was when the drag operation started (for
263
// wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
264
wxPoint GetPoint() const;
265
void SetPoint(const wxPoint& pt);
267
// keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only)
268
const wxKeyEvent& GetKeyEvent() const;
269
int GetKeyCode() const;
270
void SetKeyEvent(const wxKeyEvent& evt);
272
// label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
273
const wxString& GetLabel() const;
274
void SetLabel(const wxString& label);
276
// edit cancel flag (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
277
bool IsEditCancelled() const;
278
void SetEditCanceled(bool editCancelled);
280
// Set the tooltip for the item (for EVT_TREE_ITEM_GETTOOLTIP events)
281
void SetToolTip(const wxString& toolTip);
282
wxString GetToolTip();
284
%property(Item, GetItem, SetItem, doc="See `GetItem` and `SetItem`");
285
%property(KeyCode, GetKeyCode, doc="See `GetKeyCode`");
286
%property(KeyEvent, GetKeyEvent, SetKeyEvent, doc="See `GetKeyEvent` and `SetKeyEvent`");
287
%property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`");
288
%property(OldItem, GetOldItem, SetOldItem, doc="See `GetOldItem` and `SetOldItem`");
289
%property(Point, GetPoint, SetPoint, doc="See `GetPoint` and `SetPoint`");
290
%property(ToolTip, GetToolTip, SetToolTip, doc="See `GetToolTip` and `SetToolTip`");
291
%property(EditCancelled, IsEditCancelled, SetEditCanceled, doc="See `IsEditCancelled` and `SetEditCanceled`");
294
//---------------------------------------------------------------------------
297
%{ // C++ version of Python aware wxTreeCtrl
298
class wxPyTreeCtrl : public wxTreeCtrl {
299
DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl)
301
wxPyTreeCtrl() : wxTreeCtrl() {}
302
wxPyTreeCtrl(wxWindow *parent, wxWindowID id,
306
const wxValidator& validator,
307
const wxString& name) :
308
wxTreeCtrl(parent, id, pos, size, style, validator, name) {}
310
bool Create(wxWindow *parent, wxWindowID id,
314
const wxValidator& validator,
315
const wxString& name) {
316
return wxTreeCtrl::Create(parent, id, pos, size, style, validator, name);
320
int OnCompareItems(const wxTreeItemId& item1,
321
const wxTreeItemId& item2) {
324
wxPyBlock_t blocked = wxPyBeginBlockThreads();
325
if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
326
PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), false);
327
PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), false);
328
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
332
wxPyEndBlockThreads(blocked);
334
rval = wxTreeCtrl::OnCompareItems(item1, item2);
340
IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl);
347
MustHaveApp(wxPyTreeCtrl);
349
%rename(TreeCtrl) wxPyTreeCtrl;
350
class wxPyTreeCtrl : public wxControl {
352
%pythonAppend wxPyTreeCtrl "self._setOORInfo(self);" setCallbackInfo(TreeCtrl)
353
%pythonAppend wxPyTreeCtrl() ""
354
%typemap(out) wxPyTreeCtrl*; // turn off this typemap
356
wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1,
357
const wxPoint& pos = wxDefaultPosition,
358
const wxSize& size = wxDefaultSize,
359
long style = wxTR_DEFAULT_STYLE,
360
const wxValidator& validator = wxDefaultValidator,
361
const wxString& name = wxPyTreeCtrlNameStr);
362
%RenameCtor(PreTreeCtrl, wxPyTreeCtrl());
364
// Turn it back on again
365
%typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
367
bool Create(wxWindow *parent, wxWindowID id = -1,
368
const wxPoint& pos = wxDefaultPosition,
369
const wxSize& size = wxDefaultSize,
370
long style = wxTR_DEFAULT_STYLE,
371
const wxValidator& validator = wxDefaultValidator,
372
const wxString& name = wxPyTreeCtrlNameStr);
374
void _setCallbackInfo(PyObject* self, PyObject* _class);
377
// get the total number of items in the control
378
unsigned int GetCount() const;
380
// indent is the number of pixels the children are indented relative to
381
// the parents position. SetIndent() also redraws the control
383
unsigned int GetIndent() const;
384
void SetIndent(unsigned int indent);
386
// spacing is the number of pixels between the start and the Text
387
// not implemented under wxMSW
388
unsigned int GetSpacing() const;
389
void SetSpacing(unsigned int spacing);
392
// image list: these functions allow to associate an image list with
393
// the control and retrieve it. Note that the control does _not_ delete
394
// the associated image list when it's deleted in order to allow image
395
// lists to be shared between different controls.
397
// The normal image list is for the icons which correspond to the
398
// normal tree item state (whether it is selected or not).
399
// Additionally, the application might choose to show a state icon
400
// which corresponds to an app-defined item state (for example,
401
// checked/unchecked) which are taken from the state image list.
402
wxImageList *GetImageList() const;
403
wxImageList *GetStateImageList() const;
405
void SetImageList(wxImageList *imageList);
406
void SetStateImageList(wxImageList *imageList);
408
%disownarg( wxImageList *imageList );
409
void AssignImageList(wxImageList *imageList);
410
void AssignStateImageList(wxImageList *imageList);
411
%cleardisown( wxImageList *imageList );
414
// retrieve items label
415
wxString GetItemText(const wxTreeItemId& item) const;
417
// get one of the images associated with the item (normal by default)
418
int GetItemImage(const wxTreeItemId& item,
419
wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
422
// get the wxPyTreeItemData associated with the tree item
423
wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
424
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
427
// Get the Python object associated with the tree item
428
PyObject* GetItemPyData(const wxTreeItemId& item) {
429
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
430
return wxPyTreeItemData::SafeGetData(data);
433
%pythoncode { GetPyData = GetItemPyData }
436
// get the item's text colour
437
wxColour GetItemTextColour(const wxTreeItemId& item) const;
439
// get the item's background colour
440
wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
442
// get the item's font
443
wxFont GetItemFont(const wxTreeItemId& item) const;
445
int GetItemState(const wxTreeItemId& item) const;
448
void SetItemText(const wxTreeItemId& item, const wxString& text);
450
// get one of the images associated with the item (normal by default)
451
void SetItemImage(const wxTreeItemId& item, int image,
452
wxTreeItemIcon which = wxTreeItemIcon_Normal);
455
// associate a wxPyTreeItemData with the tree item
456
%disownarg( wxPyTreeItemData* data );
457
void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
458
self->SetItemData(item, data);
460
%cleardisown( wxPyTreeItemData* data );
462
// associate a Python object with the tree item
463
void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
464
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
466
data = new wxPyTreeItemData(obj);
467
self->SetItemData(item, data);
473
%pythoncode { SetPyData = SetItemPyData }
476
// force appearance of [+] button near the item. This is useful to
477
// allow the user to expand the items which don't have any children now
478
// - but instead add them only when needed, thus minimizing memory
479
// usage and loading time.
480
void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
482
// the item will be shown in bold
483
void SetItemBold(const wxTreeItemId& item, bool bold = true);
485
// the item will be shown with a drop highlight
486
void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true);
488
// set the items text colour
489
void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
491
// set the items background colour
492
void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
494
// set the items font (should be of the same height for all items)
495
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
497
void SetItemState(const wxTreeItemId& item, int state);
499
// is the item visible (it might be outside the view or not expanded)?
500
bool IsVisible(const wxTreeItemId& item) const;
502
// does the item has any children?
503
bool ItemHasChildren(const wxTreeItemId& item) const;
505
// is the item expanded (only makes sense if HasChildren())?
506
bool IsExpanded(const wxTreeItemId& item) const;
508
// is this item currently selected (the same as has focus)?
509
bool IsSelected(const wxTreeItemId& item) const;
511
// is item text in bold font?
512
bool IsBold(const wxTreeItemId& item) const;
514
// is the control empty?
515
bool IsEmpty() const;
518
// if 'recursively' is False, only immediate children count, otherwise
519
// the returned number is the number of all items in this branch
520
size_t GetChildrenCount(const wxTreeItemId& item,
521
bool recursively = true) /*const*/;
525
// get the root tree item
526
// wxTreeItemId.IsOk() will return False if there is no such item
527
wxTreeItemId GetRootItem() const;
529
// get the item currently selected
530
// wxTreeItemId.IsOk() will return False if there is no such item
531
wxTreeItemId GetSelection() const;
534
// get the items currently selected, return the number of such item
536
// NB: this operation is expensive and can take a long time for a
537
// control with a lot of items (~ O(number of items)).
538
PyObject* GetSelections() {
539
wxPyBlock_t blocked = wxPyBeginBlockThreads();
540
PyObject* rval = PyList_New(0);
541
wxArrayTreeItemIds array;
543
num = self->GetSelections(array);
544
for (x=0; x < num; x++) {
545
wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
546
PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
547
PyList_Append(rval, item);
550
wxPyEndBlockThreads(blocked);
555
virtual wxTreeItemId GetFocusedItem() const;
556
virtual void ClearFocusedItem();
557
virtual void SetFocusedItem(const wxTreeItemId& item);
559
// get the parent of this item
560
// wxTreeItemId.IsOk() will return False if there is no such item
561
wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
564
// NOTE: These are a copy of the same methods in gizmos.i, be sure to
565
// update both at the same time. (Or find a good way to refactor!)
567
// Get the first child of this item. Returns a wxTreeItemId and an
568
// opaque "cookie" value that should be passed to GetNextChild in
569
// order to continue the search.
570
PyObject* GetFirstChild(const wxTreeItemId& item) {
572
wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
573
wxPyBlock_t blocked = wxPyBeginBlockThreads();
574
PyObject* tup = PyTuple_New(2);
575
PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
576
PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
577
wxPyEndBlockThreads(blocked);
582
// Get the next child of this item. The cookie parameter is the 2nd
583
// value returned from GetFirstChild or the previous GetNextChild.
584
// Returns a wxTreeItemId and an opaque "cookie" value that should be
585
// passed to GetNextChild in order to continue the search.
586
PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
587
wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
588
wxPyBlock_t blocked = wxPyBeginBlockThreads();
589
PyObject* tup = PyTuple_New(2);
590
PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
591
PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
592
wxPyEndBlockThreads(blocked);
597
// get the last child of this item
598
wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
600
// get the next sibling of this item
601
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
603
// get the previous sibling
604
wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
606
// get first visible item
607
wxTreeItemId GetFirstVisibleItem() const;
609
// get the next visible item: item must be visible itself!
610
// see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
611
wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
613
// get the previous visible item: item must be visible itself!
614
wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
617
%disownarg( wxPyTreeItemData* data );
619
// add the root node to the tree
620
wxTreeItemId AddRoot(const wxString& text,
621
int image = -1, int selectedImage = -1,
622
wxPyTreeItemData *data = NULL);
624
// insert a new item in as the first child of the parent
625
wxTreeItemId PrependItem(const wxTreeItemId& parent,
626
const wxString& text,
627
int image = -1, int selectedImage = -1,
628
wxPyTreeItemData *data = NULL);
630
// insert a new item after a given one
631
wxTreeItemId InsertItem(const wxTreeItemId& parent,
632
const wxTreeItemId& idPrevious,
633
const wxString& text,
634
int image = -1, int selectedImage = -1,
635
wxPyTreeItemData *data = NULL);
637
// insert a new item before the one with the given index
638
%Rename(InsertItemBefore,
639
wxTreeItemId, InsertItem(const wxTreeItemId& parent,
641
const wxString& text,
642
int image = -1, int selectedImage = -1,
643
wxPyTreeItemData *data = NULL));
645
// insert a new item in as the last child of the parent
646
wxTreeItemId AppendItem(const wxTreeItemId& parent,
647
const wxString& text,
648
int image = -1, int selectedImage = -1,
649
wxPyTreeItemData *data = NULL);
652
%cleardisown( wxPyTreeItemData* data );
654
// delete this item and associated data if any
655
void Delete(const wxTreeItemId& item);
657
// delete all children (but don't delete the item itself)
658
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
659
void DeleteChildren(const wxTreeItemId& item);
661
// delete all items from the tree
662
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
663
void DeleteAllItems();
667
void Expand(const wxTreeItemId& item);
669
// expand the item and all its childs and thats childs
670
void ExpandAllChildren(const wxTreeItemId& item);
675
// collapse the item without removing its children
676
void Collapse(const wxTreeItemId& item);
678
// collapse the item and all its childs and thats childs
679
void CollapseAllChildren(const wxTreeItemId& item);
681
// collapse all items
684
// collapse the item and remove all children
685
void CollapseAndReset(const wxTreeItemId& item);
687
// toggles the current state
688
void Toggle(const wxTreeItemId& item);
691
// remove the selection from currently selected item (if any)
694
// remove the selection from the given one (multiselect mode only)
695
void UnselectItem(const wxTreeItemId& item);
697
// unselect all items (only makes sense for multiple selection control)
701
void SelectItem(const wxTreeItemId& item, bool select = true);
702
void SelectChildren(const wxTreeItemId& parent);
704
// toggle the item selection
705
void ToggleItemSelection(const wxTreeItemId& item);
708
// make sure this item is visible (expanding the parent item and/or
709
// scrolling to this item if necessary)
710
void EnsureVisible(const wxTreeItemId& item);
712
// scroll to this item (but don't expand its parent)
713
void ScrollTo(const wxTreeItemId& item);
717
// start editing the item label: this (temporarily) replaces the item
718
// with a one line edit control. The item will be selected if it hadn't
720
/**wxTextCtrl* */ void EditLabel(const wxTreeItemId& item);
722
// returns the same pointer as StartEdit() if the item is being edited,
723
// NULL otherwise (it's assumed that no more than one item may be
724
// edited simultaneously)
725
wxTextCtrl* GetEditControl() const;
728
// end editing and accept or discard the changes to item label
729
void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
733
// Sort the children of this item using OnCompareItems, a member function
734
// that is called to compare 2 items and should return -1, 0 or +1 if the
735
// first item is less than, equal to or greater than the second one. The
736
// base class version performs alphabetic comparaison of item labels
738
void SortChildren(const wxTreeItemId& item);
743
wxTreeItemId, HitTest(const wxPoint& point, int& OUTPUT),
744
"HitTest(Point point) -> (item, where)",
745
"Determine which item (if any) belongs the given point. The coordinates
746
specified are relative to the client area of tree ctrl and the where return
747
value is set to a bitmask of wxTREE_HITTEST_xxx constants.
752
// get the bounding rectangle of the item (or of its label only)
753
PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
755
if (self->GetBoundingRect(item, rect, textOnly)) {
756
wxPyBlock_t blocked = wxPyBeginBlockThreads();
757
wxRect* r = new wxRect(rect);
758
PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), true);
759
wxPyEndBlockThreads(blocked);
767
static wxVisualAttributes
768
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
770
void SetQuickBestSize(bool q);
771
bool GetQuickBestSize() const;
773
%property(Count, GetCount, doc="See `GetCount`");
774
%property(EditControl, GetEditControl, doc="See `GetEditControl`");
775
%property(FirstVisibleItem, GetFirstVisibleItem, doc="See `GetFirstVisibleItem`");
776
%property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`");
777
%property(Indent, GetIndent, SetIndent, doc="See `GetIndent` and `SetIndent`");
778
%property(QuickBestSize, GetQuickBestSize, SetQuickBestSize, doc="See `GetQuickBestSize` and `SetQuickBestSize`");
779
%property(RootItem, GetRootItem, doc="See `GetRootItem`");
780
%property(Selection, GetSelection, doc="See `GetSelection`");
781
%property(Selections, GetSelections, doc="See `GetSelections`");
782
%property(Spacing, GetSpacing, SetSpacing, doc="See `GetSpacing` and `SetSpacing`");
783
%property(StateImageList, GetStateImageList, SetStateImageList, doc="See `GetStateImageList` and `SetStateImageList`");
787
//---------------------------------------------------------------------------
789
// Map renamed classes back to their common name for OOR
790
wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData");
791
wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl");
793
//---------------------------------------------------------------------------