Added wrappers for wxTreeListCtrl, only to wxPython so far but it
could probably go into contrib/gizmos with some more work. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -455,6 +455,11 @@ Added wxPython.lib.mixins.rubberband module from Robb Shecter.
|
|||||||
|
|
||||||
Added wxTimeCtrl from Will Sadkin.
|
Added wxTimeCtrl from Will Sadkin.
|
||||||
|
|
||||||
|
Added wxTreeListCtrl. (Looks like a wxTreeCtrl embedded in a
|
||||||
|
wxListCtrl, but actually is just giving multiple columns to a
|
||||||
|
wxTreeCtrl.)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2.3.2.1
|
2.3.2.1
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,11 @@
|
|||||||
#include <wx/gizmos/editlbox.h>
|
#include <wx/gizmos/editlbox.h>
|
||||||
#include <wx/gizmos/splittree.h>
|
#include <wx/gizmos/splittree.h>
|
||||||
#include <wx/gizmos/ledctrl.h>
|
#include <wx/gizmos/ledctrl.h>
|
||||||
|
|
||||||
|
#include <wx/gizmos/treelistctrl.h>
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include "pytree.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -32,6 +36,8 @@
|
|||||||
%extern _defs.i
|
%extern _defs.i
|
||||||
%extern events.i
|
%extern events.i
|
||||||
%extern controls.i
|
%extern controls.i
|
||||||
|
%extern controls2.i
|
||||||
|
%extern gdi.i
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@@ -40,6 +46,8 @@
|
|||||||
// Put some wx default wxChar* values into wxStrings.
|
// Put some wx default wxChar* values into wxStrings.
|
||||||
static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow"));
|
static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow"));
|
||||||
static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox"));
|
static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox"));
|
||||||
|
static const wxString wxPyTreeListCtrlNameStr(wxT("treelistctrl"));
|
||||||
|
static const wxString wxPyEmptyString(wxT(""));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
///----------------------------------------------------------------------
|
///----------------------------------------------------------------------
|
||||||
@@ -390,6 +398,492 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// wxTreeListCtrl - the multicolumn tree control
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
enum wxTreeListColumnAlign {
|
||||||
|
wxTL_ALIGN_LEFT,
|
||||||
|
wxTL_ALIGN_RIGHT,
|
||||||
|
wxTL_ALIGN_CENTER
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
wxTREE_HITTEST_ONITEMCOLUMN
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxTreeListColumnInfo: public wxObject {
|
||||||
|
public:
|
||||||
|
wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
|
||||||
|
int image = -1,
|
||||||
|
size_t width = 100,
|
||||||
|
wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
|
||||||
|
|
||||||
|
wxTreeListColumnAlign GetAlignment() const;
|
||||||
|
wxString GetText() const;
|
||||||
|
int GetImage() const;
|
||||||
|
int GetSelectedImage() const;
|
||||||
|
size_t GetWidth() const;
|
||||||
|
|
||||||
|
void SetAlignment(wxTreeListColumnAlign alignment);
|
||||||
|
void SetText(const wxString& text);
|
||||||
|
void SetImage(int image);
|
||||||
|
void SetSelectedImage(int image);
|
||||||
|
void SetWidth(size_t with);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%{ // C++ version of Python aware control
|
||||||
|
class wxPyTreeListCtrl : public wxTreeListCtrl {
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
|
||||||
|
public:
|
||||||
|
wxPyTreeListCtrl() : wxTreeListCtrl() {}
|
||||||
|
wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxValidator &validator,
|
||||||
|
const wxString& name) :
|
||||||
|
wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
|
||||||
|
|
||||||
|
int OnCompareItems(const wxTreeItemId& item1,
|
||||||
|
const wxTreeItemId& item2) {
|
||||||
|
int rval = 0;
|
||||||
|
bool found;
|
||||||
|
wxPyBeginBlockThreads();
|
||||||
|
if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
|
||||||
|
PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
|
||||||
|
PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
|
||||||
|
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
|
||||||
|
Py_DECREF(o1);
|
||||||
|
Py_DECREF(o2);
|
||||||
|
}
|
||||||
|
wxPyEndBlockThreads();
|
||||||
|
if (! found)
|
||||||
|
rval = wxTreeListCtrl::OnCompareItems(item1, item2);
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
PYPRIVATE;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// These are for the GetFirstChild/GetNextChild methods below
|
||||||
|
%{
|
||||||
|
static const long longzero = 0;
|
||||||
|
%}
|
||||||
|
%typemap(python, in) long& INOUT = long* INOUT;
|
||||||
|
%typemap(python, argout) long& INOUT = long* INOUT;
|
||||||
|
|
||||||
|
|
||||||
|
%name(wxTreeListCtrl) class wxPyTreeListCtrl : public wxControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxTR_DEFAULT_STYLE,
|
||||||
|
const wxValidator &validator = wxDefaultValidator,
|
||||||
|
const wxString& name = wxPyTreeListCtrlNameStr );
|
||||||
|
%name(wxPreTreeListCtrl)wxPyTreeListCtrl();
|
||||||
|
|
||||||
|
bool Create(wxWindow *parent, wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxTR_DEFAULT_STYLE,
|
||||||
|
const wxValidator &validator = wxDefaultValidator,
|
||||||
|
const wxString& name = wxPyTreeListCtrlNameStr );
|
||||||
|
|
||||||
|
void _setCallbackInfo(PyObject* self, PyObject* _class);
|
||||||
|
%pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeListCtrl)"
|
||||||
|
|
||||||
|
%pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
|
||||||
|
%pragma(python) addtomethod = "wxPreTreeListCtrl:val._setOORInfo(val)"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// get the total number of items in the control
|
||||||
|
size_t GetCount() const;
|
||||||
|
|
||||||
|
// indent is the number of pixels the children are indented relative to
|
||||||
|
// the parents position. SetIndent() also redraws the control
|
||||||
|
// immediately.
|
||||||
|
unsigned int GetIndent() const;
|
||||||
|
void SetIndent(unsigned int indent);
|
||||||
|
|
||||||
|
// spacing is the number of pixels between the start and the Text
|
||||||
|
unsigned int GetSpacing() const;
|
||||||
|
void SetSpacing(unsigned int spacing);
|
||||||
|
|
||||||
|
// image list: these functions allow to associate an image list with
|
||||||
|
// the control and retrieve it. Note that when assigned with
|
||||||
|
// SetImageList, the control does _not_ delete
|
||||||
|
// the associated image list when it's deleted in order to allow image
|
||||||
|
// lists to be shared between different controls. If you use
|
||||||
|
// AssignImageList, the control _does_ delete the image list.
|
||||||
|
//
|
||||||
|
// The normal image list is for the icons which correspond to the
|
||||||
|
// normal tree item state (whether it is selected or not).
|
||||||
|
// Additionally, the application might choose to show a state icon
|
||||||
|
// which corresponds to an app-defined item state (for example,
|
||||||
|
// checked/unchecked) which are taken from the state image list.
|
||||||
|
wxImageList *GetImageList() const;
|
||||||
|
wxImageList *GetStateImageList() const;
|
||||||
|
wxImageList *GetButtonsImageList() const;
|
||||||
|
|
||||||
|
void SetImageList(wxImageList *imageList);
|
||||||
|
void SetStateImageList(wxImageList *imageList);
|
||||||
|
void SetButtonsImageList(wxImageList *imageList);
|
||||||
|
void AssignImageList(wxImageList *imageList);
|
||||||
|
void AssignStateImageList(wxImageList *imageList);
|
||||||
|
void AssignButtonsImageList(wxImageList *imageList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// adds a column
|
||||||
|
void AddColumn(const wxString& text);
|
||||||
|
%name(AddColumnInfo) void AddColumn(const wxTreeListColumnInfo& col);
|
||||||
|
|
||||||
|
// inserts a column before the given one
|
||||||
|
void InsertColumn(size_t before, const wxString& text);
|
||||||
|
%name(InsertColumnInfo) void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
|
||||||
|
|
||||||
|
// deletes the given column - does not delete the corresponding column
|
||||||
|
// of each item
|
||||||
|
void RemoveColumn(size_t column);
|
||||||
|
|
||||||
|
// returns the number of columns in the ctrl
|
||||||
|
size_t GetColumnCount() const;
|
||||||
|
|
||||||
|
void SetColumnWidth(size_t column, size_t width);
|
||||||
|
int GetColumnWidth(size_t column) const;
|
||||||
|
|
||||||
|
// tells which column is the "main" one, i.e. the "threaded" one
|
||||||
|
void SetMainColumn(size_t column);
|
||||||
|
size_t GetMainColumn() const;
|
||||||
|
|
||||||
|
void SetColumnText(size_t column, const wxString& text);
|
||||||
|
wxString GetColumnText(size_t column) const;
|
||||||
|
|
||||||
|
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
||||||
|
wxTreeListColumnInfo& GetColumn(size_t column);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%addmethods {
|
||||||
|
// retrieves item's label of the given column (main column by default)
|
||||||
|
wxString GetItemText(const wxTreeItemId& item, int column = -1) {
|
||||||
|
if (column < 0) column = self->GetMainColumn();
|
||||||
|
return self->GetItemText(item, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get one of the images associated with the item (normal by default)
|
||||||
|
int GetItemImage(const wxTreeItemId& item, int column = -1,
|
||||||
|
wxTreeItemIcon which = wxTreeItemIcon_Normal) {
|
||||||
|
if (column < 0) column = self->GetMainColumn();
|
||||||
|
return self->GetItemImage(item, column, which);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set item's label (main column by default)
|
||||||
|
void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
|
||||||
|
if (column < 0) column = self->GetMainColumn();
|
||||||
|
self->SetItemText(item, column, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set one of the images associated with the item (normal by default)
|
||||||
|
// the which parameter is ignored for all columns but the main one
|
||||||
|
void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
|
||||||
|
wxTreeItemIcon which = wxTreeItemIcon_Normal) {
|
||||||
|
if (column < 0) column = self->GetMainColumn();
|
||||||
|
self->SetItemImage(item, column, image, which);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
|
||||||
|
// if needed.
|
||||||
|
wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
|
||||||
|
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
|
||||||
|
if (data == NULL) {
|
||||||
|
data = new wxPyTreeItemData();
|
||||||
|
data->SetId(item); // set the id
|
||||||
|
self->SetItemData(item, data);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
|
||||||
|
data->SetId(item); // set the id
|
||||||
|
self->SetItemData(item, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by
|
||||||
|
// automatically creating data classes.
|
||||||
|
PyObject* GetPyData(const wxTreeItemId& item) {
|
||||||
|
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
|
||||||
|
if (data == NULL) {
|
||||||
|
data = new wxPyTreeItemData();
|
||||||
|
data->SetId(item); // set the id
|
||||||
|
self->SetItemData(item, data);
|
||||||
|
}
|
||||||
|
return data->GetData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPyData(const wxTreeItemId& item, PyObject* obj) {
|
||||||
|
wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
|
||||||
|
if (data == NULL) {
|
||||||
|
data = new wxPyTreeItemData(obj);
|
||||||
|
data->SetId(item); // set the id
|
||||||
|
self->SetItemData(item, data);
|
||||||
|
} else
|
||||||
|
data->SetData(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// force appearance of [+] button near the item. This is useful to
|
||||||
|
// allow the user to expand the items which don't have any children now
|
||||||
|
// - but instead add them only when needed, thus minimizing memory
|
||||||
|
// usage and loading time.
|
||||||
|
void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
|
||||||
|
|
||||||
|
// the item will be shown in bold
|
||||||
|
void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
|
||||||
|
|
||||||
|
// set the item's text colour
|
||||||
|
void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
|
||||||
|
|
||||||
|
// set the item's background colour
|
||||||
|
void SetItemBackgroundColour(const wxTreeItemId& item,
|
||||||
|
const wxColour& col);
|
||||||
|
|
||||||
|
// set the item's font (should be of the same height for all items)
|
||||||
|
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Where are the Getters for item colour, font, etc?
|
||||||
|
|
||||||
|
|
||||||
|
// is the item visible (it might be outside the view or not expanded)?
|
||||||
|
bool IsVisible(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// does the item has any children?
|
||||||
|
bool ItemHasChildren(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// is the item expanded (only makes sense if HasChildren())?
|
||||||
|
bool IsExpanded(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// is this item currently selected (the same as has focus)?
|
||||||
|
bool IsSelected(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// is item text in bold font?
|
||||||
|
bool IsBold(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// if 'recursively' is FALSE, only immediate children count, otherwise
|
||||||
|
// the returned number is the number of all items in this branch
|
||||||
|
size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
// wxTreeItemId.IsOk() will return FALSE if there is no such item
|
||||||
|
|
||||||
|
// get the root tree item
|
||||||
|
wxTreeItemId GetRootItem() const;
|
||||||
|
|
||||||
|
// get the item currently selected (may return NULL if no selection)
|
||||||
|
wxTreeItemId GetSelection() const;
|
||||||
|
|
||||||
|
// get the items currently selected, return the number of such item
|
||||||
|
size_t GetSelections(wxArrayTreeItemIds&) const;
|
||||||
|
|
||||||
|
// get the parent of this item (may return NULL if root)
|
||||||
|
%name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// for this enumeration function you must pass in a "cookie" parameter
|
||||||
|
// which is opaque for the application but is necessary for the library
|
||||||
|
// to make these functions reentrant (i.e. allow more than one
|
||||||
|
// enumeration on one and the same object simultaneously). Of course,
|
||||||
|
// the "cookie" passed to GetFirstChild() and GetNextChild() should be
|
||||||
|
// the same!
|
||||||
|
|
||||||
|
// get the first child of this item
|
||||||
|
wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT = longzero) const;
|
||||||
|
|
||||||
|
// get the next child
|
||||||
|
wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT) const;
|
||||||
|
|
||||||
|
// get the last child of this item - this method doesn't use cookies
|
||||||
|
wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// get the next sibling of this item
|
||||||
|
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// get the previous sibling
|
||||||
|
wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// get first visible item
|
||||||
|
wxTreeItemId GetFirstVisibleItem() const;
|
||||||
|
|
||||||
|
// get the next visible item: item must be visible itself!
|
||||||
|
// see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
|
||||||
|
wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// get the previous visible item: item must be visible itself!
|
||||||
|
wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// Only for internal use right now, but should probably be public
|
||||||
|
wxTreeItemId GetNext(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
|
||||||
|
// add the root node to the tree
|
||||||
|
wxTreeItemId AddRoot(const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxPyTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item in as the first child of the parent
|
||||||
|
wxTreeItemId PrependItem(const wxTreeItemId& parent,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxPyTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item after a given one
|
||||||
|
wxTreeItemId InsertItem(const wxTreeItemId& parent,
|
||||||
|
const wxTreeItemId& idPrevious,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxPyTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item before the one with the given index
|
||||||
|
%name(InsertItemBefore)
|
||||||
|
wxTreeItemId InsertItem(const wxTreeItemId& parent,
|
||||||
|
size_t index,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxPyTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item in as the last child of the parent
|
||||||
|
wxTreeItemId AppendItem(const wxTreeItemId& parent,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxPyTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// delete this item and associated data if any
|
||||||
|
void Delete(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// delete all children (but don't delete the item itself)
|
||||||
|
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
|
||||||
|
void DeleteChildren(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// delete all items from the tree
|
||||||
|
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
|
||||||
|
void DeleteAllItems();
|
||||||
|
|
||||||
|
// expand this item
|
||||||
|
void Expand(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// expand this item and all subitems recursively
|
||||||
|
void ExpandAll(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// collapse the item without removing its children
|
||||||
|
void Collapse(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// collapse the item and remove all children
|
||||||
|
void CollapseAndReset(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// toggles the current state
|
||||||
|
void Toggle(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// remove the selection from currently selected item (if any)
|
||||||
|
void Unselect();
|
||||||
|
void UnselectAll();
|
||||||
|
|
||||||
|
// select this item
|
||||||
|
void SelectItem(const wxTreeItemId& item, bool unselect_others=TRUE,
|
||||||
|
bool extended_select=FALSE);
|
||||||
|
|
||||||
|
// make sure this item is visible (expanding the parent item and/or
|
||||||
|
// scrolling to this item if necessary)
|
||||||
|
void EnsureVisible(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// scroll to this item (but don't expand its parent)
|
||||||
|
void ScrollTo(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// Returns wxTreeItemId, flags, and column
|
||||||
|
wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
|
||||||
|
|
||||||
|
%addmethods {
|
||||||
|
// get the bounding rectangle of the item (or of its label only)
|
||||||
|
PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = FALSE) {
|
||||||
|
wxRect rect;
|
||||||
|
if (self->GetBoundingRect(item, rect, textOnly)) {
|
||||||
|
wxPyBeginBlockThreads();
|
||||||
|
wxRect* r = new wxRect(rect);
|
||||||
|
PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
|
||||||
|
wxPyEndBlockThreads();
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Start editing the item label: this (temporarily) replaces the item
|
||||||
|
// with a one line edit control. The item will be selected if it hadn't
|
||||||
|
// been before.
|
||||||
|
void EditLabel( const wxTreeItemId& item );
|
||||||
|
void Edit( const wxTreeItemId& item );
|
||||||
|
|
||||||
|
// sort the children of this item using OnCompareItems
|
||||||
|
void SortChildren(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// get the selected item image
|
||||||
|
int GetItemSelectedImage(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// set the selected item image
|
||||||
|
void SetItemSelectedImage(const wxTreeItemId& item, int image);
|
||||||
|
|
||||||
|
|
||||||
|
wxWindow* GetHeaderWindow() const;
|
||||||
|
wxWindow* GetMainWindow() const;
|
||||||
|
|
||||||
|
%pragma(python) addtoclass = "
|
||||||
|
# Redefine some methods that SWIG gets a bit confused on...
|
||||||
|
def GetFirstChild(self, *_args, **_kwargs):
|
||||||
|
val1,val2 = controls2c.wxTreeCtrl_GetFirstChild(self, *_args, **_kwargs)
|
||||||
|
val1 = wxTreeItemIdPtr(val1)
|
||||||
|
val1.thisown = 1
|
||||||
|
return (val1,val2)
|
||||||
|
def GetNextChild(self, *_args, **_kwargs):
|
||||||
|
val1,val2 = controls2c.wxTreeCtrl_GetNextChild(self, *_args, **_kwargs)
|
||||||
|
val1 = wxTreeItemIdPtr(val1)
|
||||||
|
val1.thisown = 1
|
||||||
|
return (val1,val2)
|
||||||
|
def HitTest(self, *_args, **_kwargs):
|
||||||
|
val1, val2, val3 = controls2c.wxTreeCtrl_HitTest(self, *_args, **_kwargs)
|
||||||
|
val1 = wxTreeItemIdPtr(val1)
|
||||||
|
val1.thisown = 1
|
||||||
|
return (val1, val2, val3)
|
||||||
|
"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -399,6 +893,7 @@ public:
|
|||||||
wxClassInfo::InitializeClasses();
|
wxClassInfo::InitializeClasses();
|
||||||
|
|
||||||
wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
|
wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
|
||||||
|
wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -280,6 +280,374 @@ def wxPreLEDNumberCtrl(*_args,**_kwargs):
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
class wxTreeListColumnInfoPtr(wxObjectPtr):
|
||||||
|
def __init__(self,this):
|
||||||
|
self.this = this
|
||||||
|
self.thisown = 0
|
||||||
|
def GetAlignment(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_GetAlignment(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetText(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_GetText(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_GetImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetSelectedImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_GetSelectedImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetWidth(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_GetWidth(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetAlignment(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_SetAlignment(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetText(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_SetText(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_SetImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetSelectedImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_SetSelectedImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetWidth(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListColumnInfo_SetWidth(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s.%s instance; proxy of C++ wxTreeListColumnInfo instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this)
|
||||||
|
class wxTreeListColumnInfo(wxTreeListColumnInfoPtr):
|
||||||
|
def __init__(self,*_args,**_kwargs):
|
||||||
|
self.this = gizmosc.new_wxTreeListColumnInfo(*_args,**_kwargs)
|
||||||
|
self.thisown = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxTreeListCtrlPtr(wxControlPtr):
|
||||||
|
def __init__(self,this):
|
||||||
|
self.this = this
|
||||||
|
self.thisown = 0
|
||||||
|
def Create(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Create(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def _setCallbackInfo(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl__setCallbackInfo(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetCount(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetCount(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetIndent(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetIndent(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetIndent(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetIndent(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetSpacing(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetSpacing(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetSpacing(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetSpacing(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetStateImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetStateImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetButtonsImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetButtonsImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetStateImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetStateImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetButtonsImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetButtonsImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def AssignImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AssignImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def AssignStateImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AssignStateImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def AssignButtonsImageList(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AssignButtonsImageList(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def AddColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AddColumn(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def AddColumnInfo(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AddColumnInfo(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def InsertColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_InsertColumn(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def InsertColumnInfo(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_InsertColumnInfo(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def RemoveColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_RemoveColumn(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetColumnCount(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetColumnCount(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetColumnWidth(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetColumnWidth(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetColumnWidth(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetColumnWidth(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetMainColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetMainColumn(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetMainColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetMainColumn(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetColumnText(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetColumnText(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetColumnText(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetColumnText(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetColumn(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetColumn(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetColumn(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeListColumnInfoPtr(val)
|
||||||
|
return val
|
||||||
|
def GetItemText(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetItemText(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetItemImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetItemImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemText(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemText(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetItemData(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetItemData(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemDataPtr(val)
|
||||||
|
return val
|
||||||
|
def SetItemData(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemData(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetPyData(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetPyData(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetPyData(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetPyData(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemHasChildren(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemHasChildren(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemBold(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemBold(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemTextColour(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemTextColour(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemBackgroundColour(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemBackgroundColour(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemFont(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemFont(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def IsVisible(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_IsVisible(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def ItemHasChildren(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_ItemHasChildren(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def IsExpanded(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_IsExpanded(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def IsSelected(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_IsSelected(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def IsBold(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_IsBold(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetChildrenCount(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetChildrenCount(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetRootItem(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetRootItem(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetSelection(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetSelection(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetSelections(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetSelections(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetItemParent(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetItemParent(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetFirstChild(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetFirstChild(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetNextChild(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetNextChild(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetLastChild(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetLastChild(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetNextSibling(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetNextSibling(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetPrevSibling(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetPrevSibling(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetFirstVisibleItem(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetFirstVisibleItem(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetNextVisible(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetNextVisible(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetPrevVisible(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetPrevVisible(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def GetNext(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetNext(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def AddRoot(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AddRoot(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def PrependItem(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_PrependItem(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def InsertItem(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_InsertItem(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def InsertItemBefore(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_InsertItemBefore(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def AppendItem(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_AppendItem(self, *_args, **_kwargs)
|
||||||
|
if val: val = wxTreeItemIdPtr(val) ; val.thisown = 1
|
||||||
|
return val
|
||||||
|
def Delete(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Delete(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def DeleteChildren(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_DeleteChildren(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def DeleteAllItems(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_DeleteAllItems(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def Expand(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Expand(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def ExpandAll(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_ExpandAll(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def Collapse(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Collapse(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def CollapseAndReset(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_CollapseAndReset(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def Toggle(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Toggle(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def Unselect(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Unselect(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def UnselectAll(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_UnselectAll(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SelectItem(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SelectItem(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def EnsureVisible(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_EnsureVisible(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def ScrollTo(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_ScrollTo(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def HitTest(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_HitTest(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetBoundingRect(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetBoundingRect(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def EditLabel(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_EditLabel(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def Edit(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_Edit(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SortChildren(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SortChildren(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetItemSelectedImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetItemSelectedImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def SetItemSelectedImage(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_SetItemSelectedImage(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetHeaderWindow(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetHeaderWindow(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def GetMainWindow(self, *_args, **_kwargs):
|
||||||
|
val = gizmosc.wxTreeListCtrl_GetMainWindow(self, *_args, **_kwargs)
|
||||||
|
return val
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s.%s instance; proxy of C++ wxTreeListCtrl instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this)
|
||||||
|
|
||||||
|
# Redefine some methods that SWIG gets a bit confused on...
|
||||||
|
def GetFirstChild(self, *_args, **_kwargs):
|
||||||
|
val1,val2 = controls2c.wxTreeCtrl_GetFirstChild(self, *_args, **_kwargs)
|
||||||
|
val1 = wxTreeItemIdPtr(val1)
|
||||||
|
val1.thisown = 1
|
||||||
|
return (val1,val2)
|
||||||
|
def GetNextChild(self, *_args, **_kwargs):
|
||||||
|
val1,val2 = controls2c.wxTreeCtrl_GetNextChild(self, *_args, **_kwargs)
|
||||||
|
val1 = wxTreeItemIdPtr(val1)
|
||||||
|
val1.thisown = 1
|
||||||
|
return (val1,val2)
|
||||||
|
def HitTest(self, *_args, **_kwargs):
|
||||||
|
val1, val2, val3 = controls2c.wxTreeCtrl_HitTest(self, *_args, **_kwargs)
|
||||||
|
val1 = wxTreeItemIdPtr(val1)
|
||||||
|
val1.thisown = 1
|
||||||
|
return (val1, val2, val3)
|
||||||
|
|
||||||
|
class wxTreeListCtrl(wxTreeListCtrlPtr):
|
||||||
|
def __init__(self,*_args,**_kwargs):
|
||||||
|
self.this = gizmosc.new_wxTreeListCtrl(*_args,**_kwargs)
|
||||||
|
self.thisown = 1
|
||||||
|
self._setCallbackInfo(self, wxTreeListCtrl)
|
||||||
|
self._setOORInfo(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def wxPreTreeListCtrl(*_args,**_kwargs):
|
||||||
|
val = wxTreeListCtrlPtr(gizmosc.new_wxPreTreeListCtrl(*_args,**_kwargs))
|
||||||
|
val.thisown = 1
|
||||||
|
val._setOORInfo(val)
|
||||||
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------- FUNCTION WRAPPERS ------------------
|
#-------------- FUNCTION WRAPPERS ------------------
|
||||||
@@ -300,6 +668,10 @@ wxLED_ALIGN_RIGHT = gizmosc.wxLED_ALIGN_RIGHT
|
|||||||
wxLED_ALIGN_CENTER = gizmosc.wxLED_ALIGN_CENTER
|
wxLED_ALIGN_CENTER = gizmosc.wxLED_ALIGN_CENTER
|
||||||
wxLED_ALIGN_MASK = gizmosc.wxLED_ALIGN_MASK
|
wxLED_ALIGN_MASK = gizmosc.wxLED_ALIGN_MASK
|
||||||
wxLED_DRAW_FADED = gizmosc.wxLED_DRAW_FADED
|
wxLED_DRAW_FADED = gizmosc.wxLED_DRAW_FADED
|
||||||
|
wxTL_ALIGN_LEFT = gizmosc.wxTL_ALIGN_LEFT
|
||||||
|
wxTL_ALIGN_RIGHT = gizmosc.wxTL_ALIGN_RIGHT
|
||||||
|
wxTL_ALIGN_CENTER = gizmosc.wxTL_ALIGN_CENTER
|
||||||
|
wxTREE_HITTEST_ONITEMCOLUMN = gizmosc.wxTREE_HITTEST_ONITEMCOLUMN
|
||||||
|
|
||||||
|
|
||||||
#-------------- USER INCLUDE -----------------------
|
#-------------- USER INCLUDE -----------------------
|
||||||
|
4635
wxPython/contrib/gizmos/treelistctrl.cpp
Normal file
4635
wxPython/contrib/gizmos/treelistctrl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
482
wxPython/contrib/gizmos/treelistctrl.h
Normal file
482
wxPython/contrib/gizmos/treelistctrl.h
Normal file
@@ -0,0 +1,482 @@
|
|||||||
|
// -*- C++ -*- //////////////////////////////////////////////////////////////
|
||||||
|
// Name: treelistctrl.h (derived by wx/treectrlg.h)
|
||||||
|
// Purpose: wxTreeListCtrl class
|
||||||
|
// Author: Robert Roebling
|
||||||
|
// Modified by: Alberto Griggio, 2002
|
||||||
|
// Created: 01/02/97
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1997,1998 Robert Roebling
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TREELISRCTRL_H
|
||||||
|
#define TREELISTCTRL_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface "treelistctrl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/control.h>
|
||||||
|
#include <wx/pen.h>
|
||||||
|
#include <wx/listctrl.h> // for wxListEvent
|
||||||
|
|
||||||
|
#ifdef GIZMOISDLL
|
||||||
|
#define GIZMODLLEXPORT WXDLLEXPORT
|
||||||
|
#else
|
||||||
|
#define GIZMODLLEXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
class GIZMODLLEXPORT wxTreeListItem;
|
||||||
|
class GIZMODLLEXPORT wxTreeListHeaderWindow;
|
||||||
|
class GIZMODLLEXPORT wxTreeListMainWindow;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxTreeListColumnAttrs
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
enum wxTreeListColumnAlign {
|
||||||
|
wxTL_ALIGN_LEFT,
|
||||||
|
wxTL_ALIGN_RIGHT,
|
||||||
|
wxTL_ALIGN_CENTER
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class GIZMODLLEXPORT wxTreeListColumnInfo: public wxObject {
|
||||||
|
public:
|
||||||
|
static const size_t DEFAULT_COL_WIDTH = 100;
|
||||||
|
|
||||||
|
wxTreeListColumnInfo(const wxChar* text = wxT(""),
|
||||||
|
int image = -1,
|
||||||
|
size_t width = DEFAULT_COL_WIDTH,
|
||||||
|
wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT)
|
||||||
|
{
|
||||||
|
m_image = image;
|
||||||
|
m_selected_image = -1;
|
||||||
|
m_text = text;
|
||||||
|
m_width = width;
|
||||||
|
m_alignment = alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
// getters
|
||||||
|
wxTreeListColumnAlign GetAlignment() const { return m_alignment; }
|
||||||
|
wxString GetText() const { return m_text; }
|
||||||
|
int GetImage() const { return m_image; }
|
||||||
|
int GetSelectedImage() const { return m_selected_image; }
|
||||||
|
size_t GetWidth() const { return m_width; }
|
||||||
|
|
||||||
|
// setters
|
||||||
|
wxTreeListColumnInfo& SetAlignment(wxTreeListColumnAlign alignment)
|
||||||
|
{ m_alignment = alignment; return *this; }
|
||||||
|
|
||||||
|
wxTreeListColumnInfo& SetText(const wxString& text)
|
||||||
|
{ m_text = text; return *this; }
|
||||||
|
|
||||||
|
wxTreeListColumnInfo& SetImage(int image)
|
||||||
|
{ m_image = image; return *this; }
|
||||||
|
|
||||||
|
wxTreeListColumnInfo& SetSelectedImage(int image)
|
||||||
|
{ m_selected_image = image; return *this; }
|
||||||
|
|
||||||
|
wxTreeListColumnInfo& SetWidth(size_t with)
|
||||||
|
{ m_width = with; return *this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxTreeListColumnAlign m_alignment;
|
||||||
|
wxString m_text;
|
||||||
|
int m_image;
|
||||||
|
int m_selected_image;
|
||||||
|
size_t m_width;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// wxTreeListCtrl - the multicolumn tree control
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// additional flag for HitTest
|
||||||
|
const int wxTREE_HITTEST_ONITEMCOLUMN = 0x2000;
|
||||||
|
extern GIZMODLLEXPORT const wxChar* wxTreeListCtrlNameStr;
|
||||||
|
|
||||||
|
|
||||||
|
class GIZMODLLEXPORT wxTreeListCtrl : public wxControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// creation
|
||||||
|
// --------
|
||||||
|
wxTreeListCtrl() {}
|
||||||
|
|
||||||
|
wxTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxTR_DEFAULT_STYLE,
|
||||||
|
const wxValidator &validator = wxDefaultValidator,
|
||||||
|
const wxString& name = wxTreeListCtrlNameStr )
|
||||||
|
{
|
||||||
|
Create(parent, id, pos, size, style, validator, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wxTreeListCtrl() {}
|
||||||
|
|
||||||
|
bool Create(wxWindow *parent, wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxTR_DEFAULT_STYLE,
|
||||||
|
const wxValidator &validator = wxDefaultValidator,
|
||||||
|
const wxString& name = wxTreeListCtrlNameStr );
|
||||||
|
|
||||||
|
void Refresh(bool erase=TRUE, const wxRect* rect=NULL);
|
||||||
|
void SetFocus();
|
||||||
|
// accessors
|
||||||
|
// ---------
|
||||||
|
|
||||||
|
// get the total number of items in the control
|
||||||
|
size_t GetCount() const;
|
||||||
|
|
||||||
|
// indent is the number of pixels the children are indented relative to
|
||||||
|
// the parents position. SetIndent() also redraws the control
|
||||||
|
// immediately.
|
||||||
|
unsigned int GetIndent() const;
|
||||||
|
void SetIndent(unsigned int indent);
|
||||||
|
|
||||||
|
// spacing is the number of pixels between the start and the Text
|
||||||
|
unsigned int GetSpacing() const;
|
||||||
|
void SetSpacing(unsigned int spacing);
|
||||||
|
|
||||||
|
// image list: these functions allow to associate an image list with
|
||||||
|
// the control and retrieve it. Note that when assigned with
|
||||||
|
// SetImageList, the control does _not_ delete
|
||||||
|
// the associated image list when it's deleted in order to allow image
|
||||||
|
// lists to be shared between different controls. If you use
|
||||||
|
// AssignImageList, the control _does_ delete the image list.
|
||||||
|
//
|
||||||
|
// The normal image list is for the icons which correspond to the
|
||||||
|
// normal tree item state (whether it is selected or not).
|
||||||
|
// Additionally, the application might choose to show a state icon
|
||||||
|
// which corresponds to an app-defined item state (for example,
|
||||||
|
// checked/unchecked) which are taken from the state image list.
|
||||||
|
wxImageList *GetImageList() const;
|
||||||
|
wxImageList *GetStateImageList() const;
|
||||||
|
wxImageList *GetButtonsImageList() const;
|
||||||
|
|
||||||
|
void SetImageList(wxImageList *imageList);
|
||||||
|
void SetStateImageList(wxImageList *imageList);
|
||||||
|
void SetButtonsImageList(wxImageList *imageList);
|
||||||
|
void AssignImageList(wxImageList *imageList);
|
||||||
|
void AssignStateImageList(wxImageList *imageList);
|
||||||
|
void AssignButtonsImageList(wxImageList *imageList);
|
||||||
|
|
||||||
|
|
||||||
|
// Functions to work with tree list ctrl columns
|
||||||
|
|
||||||
|
// adds a column
|
||||||
|
void AddColumn(const wxString& text)
|
||||||
|
{ AddColumn(wxTreeListColumnInfo().SetText(text)); }
|
||||||
|
void AddColumn(const wxTreeListColumnInfo& col);
|
||||||
|
|
||||||
|
// inserts a column before the given one
|
||||||
|
void InsertColumn(size_t before, const wxString& text)
|
||||||
|
{ InsertColumn(before, wxTreeListColumnInfo().SetText(text)); }
|
||||||
|
void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
|
||||||
|
|
||||||
|
// deletes the given column - does not delete the corresponding column
|
||||||
|
// of each item
|
||||||
|
void RemoveColumn(size_t column);
|
||||||
|
|
||||||
|
// returns the number of columns in the ctrl
|
||||||
|
size_t GetColumnCount() const;
|
||||||
|
|
||||||
|
void SetColumnWidth(size_t column, size_t width);
|
||||||
|
int GetColumnWidth(size_t column) const;
|
||||||
|
|
||||||
|
// tells which column is the "main" one, i.e. the "threaded" one
|
||||||
|
void SetMainColumn(size_t column);
|
||||||
|
size_t GetMainColumn() const;
|
||||||
|
|
||||||
|
void SetColumnText(size_t column, const wxString& text);
|
||||||
|
wxString GetColumnText(size_t column) const;
|
||||||
|
|
||||||
|
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
||||||
|
wxTreeListColumnInfo& GetColumn(size_t column);
|
||||||
|
const wxTreeListColumnInfo& GetColumn(size_t column) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Functions to work with tree list ctrl items.
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
// ---------
|
||||||
|
|
||||||
|
// retrieve item's label (of the main column)
|
||||||
|
wxString GetItemText(const wxTreeItemId& item) const
|
||||||
|
{ return GetItemText(item, GetMainColumn()); }
|
||||||
|
// retrieves item's label of the given column
|
||||||
|
wxString GetItemText(const wxTreeItemId& item, size_t column) const;
|
||||||
|
|
||||||
|
// get one of the images associated with the item (normal by default)
|
||||||
|
int GetItemImage(const wxTreeItemId& item,
|
||||||
|
wxTreeItemIcon which = wxTreeItemIcon_Normal) const
|
||||||
|
{ return GetItemImage(item, GetMainColumn(), which); }
|
||||||
|
int GetItemImage(const wxTreeItemId& item, size_t column,
|
||||||
|
wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
|
||||||
|
|
||||||
|
// get the data associated with the item
|
||||||
|
wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// modifiers
|
||||||
|
// ---------
|
||||||
|
|
||||||
|
// set item's label
|
||||||
|
void SetItemText(const wxTreeItemId& item, const wxString& text)
|
||||||
|
{ SetItemText(item, GetMainColumn(), text); }
|
||||||
|
void SetItemText(const wxTreeItemId& item, size_t column,
|
||||||
|
const wxString& text);
|
||||||
|
|
||||||
|
// get one of the images associated with the item (normal by default)
|
||||||
|
void SetItemImage(const wxTreeItemId& item, int image,
|
||||||
|
wxTreeItemIcon which = wxTreeItemIcon_Normal)
|
||||||
|
{ SetItemImage(item, GetMainColumn(), image, which); }
|
||||||
|
// the which parameter is ignored for all columns but the main one
|
||||||
|
void SetItemImage(const wxTreeItemId& item, size_t column, int image,
|
||||||
|
wxTreeItemIcon which = wxTreeItemIcon_Normal);
|
||||||
|
|
||||||
|
// associate some data with the item
|
||||||
|
void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
|
||||||
|
|
||||||
|
// force appearance of [+] button near the item. This is useful to
|
||||||
|
// allow the user to expand the items which don't have any children now
|
||||||
|
// - but instead add them only when needed, thus minimizing memory
|
||||||
|
// usage and loading time.
|
||||||
|
void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
|
||||||
|
|
||||||
|
// the item will be shown in bold
|
||||||
|
void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
|
||||||
|
|
||||||
|
// set the item's text colour
|
||||||
|
void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
|
||||||
|
|
||||||
|
// set the item's background colour
|
||||||
|
void SetItemBackgroundColour(const wxTreeItemId& item,
|
||||||
|
const wxColour& col);
|
||||||
|
|
||||||
|
// set the item's font (should be of the same height for all items)
|
||||||
|
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
||||||
|
|
||||||
|
// set the window font
|
||||||
|
virtual bool SetFont( const wxFont &font );
|
||||||
|
|
||||||
|
// set the styles.
|
||||||
|
void SetWindowStyle(const long styles);
|
||||||
|
long GetWindowStyle() const;
|
||||||
|
long GetWindowStyleFlag() const { return GetWindowStyle(); }
|
||||||
|
|
||||||
|
// item status inquiries
|
||||||
|
// ---------------------
|
||||||
|
|
||||||
|
// is the item visible (it might be outside the view or not expanded)?
|
||||||
|
bool IsVisible(const wxTreeItemId& item) const;
|
||||||
|
// does the item has any children?
|
||||||
|
bool HasChildren(const wxTreeItemId& item) const
|
||||||
|
{ return ItemHasChildren(item); }
|
||||||
|
bool ItemHasChildren(const wxTreeItemId& item) const;
|
||||||
|
// is the item expanded (only makes sense if HasChildren())?
|
||||||
|
bool IsExpanded(const wxTreeItemId& item) const;
|
||||||
|
// is this item currently selected (the same as has focus)?
|
||||||
|
bool IsSelected(const wxTreeItemId& item) const;
|
||||||
|
// is item text in bold font?
|
||||||
|
bool IsBold(const wxTreeItemId& item) const;
|
||||||
|
// does the layout include space for a button?
|
||||||
|
|
||||||
|
// number of children
|
||||||
|
// ------------------
|
||||||
|
|
||||||
|
// if 'recursively' is FALSE, only immediate children count, otherwise
|
||||||
|
// the returned number is the number of all items in this branch
|
||||||
|
size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
|
||||||
|
|
||||||
|
// navigation
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
// wxTreeItemId.IsOk() will return FALSE if there is no such item
|
||||||
|
|
||||||
|
// get the root tree item
|
||||||
|
wxTreeItemId GetRootItem() const;
|
||||||
|
|
||||||
|
// get the item currently selected (may return NULL if no selection)
|
||||||
|
wxTreeItemId GetSelection() const;
|
||||||
|
|
||||||
|
// get the items currently selected, return the number of such item
|
||||||
|
size_t GetSelections(wxArrayTreeItemIds&) const;
|
||||||
|
|
||||||
|
// get the parent of this item (may return NULL if root)
|
||||||
|
wxTreeItemId GetParent(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// for this enumeration function you must pass in a "cookie" parameter
|
||||||
|
// which is opaque for the application but is necessary for the library
|
||||||
|
// to make these functions reentrant (i.e. allow more than one
|
||||||
|
// enumeration on one and the same object simultaneously). Of course,
|
||||||
|
// the "cookie" passed to GetFirstChild() and GetNextChild() should be
|
||||||
|
// the same!
|
||||||
|
|
||||||
|
// get the first child of this item
|
||||||
|
wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const;
|
||||||
|
// get the next child
|
||||||
|
wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const;
|
||||||
|
// get the last child of this item - this method doesn't use cookies
|
||||||
|
wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// get the next sibling of this item
|
||||||
|
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
|
||||||
|
// get the previous sibling
|
||||||
|
wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// get first visible item
|
||||||
|
wxTreeItemId GetFirstVisibleItem() const;
|
||||||
|
// get the next visible item: item must be visible itself!
|
||||||
|
// see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
|
||||||
|
wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
|
||||||
|
// get the previous visible item: item must be visible itself!
|
||||||
|
wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// Only for internal use right now, but should probably be public
|
||||||
|
wxTreeItemId GetNext(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
// operations
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
// add the root node to the tree
|
||||||
|
wxTreeItemId AddRoot(const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item in as the first child of the parent
|
||||||
|
wxTreeItemId PrependItem(const wxTreeItemId& parent,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item after a given one
|
||||||
|
wxTreeItemId InsertItem(const wxTreeItemId& parent,
|
||||||
|
const wxTreeItemId& idPrevious,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item before the one with the given index
|
||||||
|
wxTreeItemId InsertItem(const wxTreeItemId& parent,
|
||||||
|
size_t index,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// insert a new item in as the last child of the parent
|
||||||
|
wxTreeItemId AppendItem(const wxTreeItemId& parent,
|
||||||
|
const wxString& text,
|
||||||
|
int image = -1, int selectedImage = -1,
|
||||||
|
wxTreeItemData *data = NULL);
|
||||||
|
|
||||||
|
// delete this item and associated data if any
|
||||||
|
void Delete(const wxTreeItemId& item);
|
||||||
|
// delete all children (but don't delete the item itself)
|
||||||
|
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
|
||||||
|
void DeleteChildren(const wxTreeItemId& item);
|
||||||
|
// delete all items from the tree
|
||||||
|
// NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
|
||||||
|
void DeleteAllItems();
|
||||||
|
|
||||||
|
// expand this item
|
||||||
|
void Expand(const wxTreeItemId& item);
|
||||||
|
// expand this item and all subitems recursively
|
||||||
|
void ExpandAll(const wxTreeItemId& item);
|
||||||
|
// collapse the item without removing its children
|
||||||
|
void Collapse(const wxTreeItemId& item);
|
||||||
|
// collapse the item and remove all children
|
||||||
|
void CollapseAndReset(const wxTreeItemId& item);
|
||||||
|
// toggles the current state
|
||||||
|
void Toggle(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// remove the selection from currently selected item (if any)
|
||||||
|
void Unselect();
|
||||||
|
void UnselectAll();
|
||||||
|
// select this item
|
||||||
|
void SelectItem(const wxTreeItemId& item, bool unselect_others=TRUE,
|
||||||
|
bool extended_select=FALSE);
|
||||||
|
// make sure this item is visible (expanding the parent item and/or
|
||||||
|
// scrolling to this item if necessary)
|
||||||
|
void EnsureVisible(const wxTreeItemId& item);
|
||||||
|
// scroll to this item (but don't expand its parent)
|
||||||
|
void ScrollTo(const wxTreeItemId& item);
|
||||||
|
//void AdjustMyScrollbars();
|
||||||
|
|
||||||
|
// The first function is more portable (because easier to implement
|
||||||
|
// on other platforms), but the second one returns some extra info.
|
||||||
|
wxTreeItemId HitTest(const wxPoint& point)
|
||||||
|
{ int dummy; return HitTest(point, dummy); }
|
||||||
|
wxTreeItemId HitTest(const wxPoint& point, int& flags)
|
||||||
|
{ int col; return HitTest(point, flags, col); }
|
||||||
|
wxTreeItemId HitTest(const wxPoint& point, int& flags, int& column);
|
||||||
|
|
||||||
|
// get the bounding rectangle of the item (or of its label only)
|
||||||
|
bool GetBoundingRect(const wxTreeItemId& item,
|
||||||
|
wxRect& rect,
|
||||||
|
bool textOnly = FALSE) const;
|
||||||
|
|
||||||
|
// Start editing the item label: this (temporarily) replaces the item
|
||||||
|
// with a one line edit control. The item will be selected if it hadn't
|
||||||
|
// been before.
|
||||||
|
void EditLabel( const wxTreeItemId& item ) { Edit( item ); }
|
||||||
|
void Edit( const wxTreeItemId& item );
|
||||||
|
|
||||||
|
// sorting
|
||||||
|
// this function is called to compare 2 items and should return -1, 0
|
||||||
|
// or +1 if the first item is less than, equal to or greater than the
|
||||||
|
// second one. The base class version performs alphabetic comparaison
|
||||||
|
// of item labels (GetText)
|
||||||
|
virtual int OnCompareItems(const wxTreeItemId& item1,
|
||||||
|
const wxTreeItemId& item2);
|
||||||
|
// sort the children of this item using OnCompareItems
|
||||||
|
//
|
||||||
|
// NB: this function is not reentrant and not MT-safe (FIXME)!
|
||||||
|
void SortChildren(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
// deprecated functions: use Set/GetItemImage directly
|
||||||
|
// get the selected item image
|
||||||
|
int GetItemSelectedImage(const wxTreeItemId& item) const
|
||||||
|
{ return GetItemImage(item, wxTreeItemIcon_Selected); }
|
||||||
|
// set the selected item image
|
||||||
|
void SetItemSelectedImage(const wxTreeItemId& item, int image)
|
||||||
|
{ SetItemImage(item, image, wxTreeItemIcon_Selected); }
|
||||||
|
|
||||||
|
// implementation only from now on
|
||||||
|
|
||||||
|
// overridden base class virtuals
|
||||||
|
virtual bool SetBackgroundColour(const wxColour& colour);
|
||||||
|
virtual bool SetForegroundColour(const wxColour& colour);
|
||||||
|
|
||||||
|
|
||||||
|
wxTreeListHeaderWindow* GetHeaderWindow() const
|
||||||
|
{ return m_header_win; }
|
||||||
|
|
||||||
|
wxTreeListMainWindow* GetMainWindow() const
|
||||||
|
{ return m_main_win; }
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// header window, responsible for column visualization and manipulation
|
||||||
|
wxTreeListHeaderWindow* m_header_win;
|
||||||
|
// main window, the "true" tree ctrl
|
||||||
|
wxTreeListMainWindow* m_main_win;
|
||||||
|
|
||||||
|
// the common part of all ctors
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
void OnSize(wxSizeEvent& event);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxTreeListCtrl)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TREELISTCTRL_H
|
||||||
|
|
@@ -32,6 +32,7 @@ _treeList = [
|
|||||||
'PopupMenu',
|
'PopupMenu',
|
||||||
'AnalogClockWindow',
|
'AnalogClockWindow',
|
||||||
'MaskedEditControls',
|
'MaskedEditControls',
|
||||||
|
'wxTreeListCtrl',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
# managed windows == things with a (optional) caption you can close
|
# managed windows == things with a (optional) caption you can close
|
||||||
@@ -134,6 +135,7 @@ _treeList = [
|
|||||||
'wxStyledTextCtrl_1',
|
'wxStyledTextCtrl_1',
|
||||||
'wxStyledTextCtrl_2',
|
'wxStyledTextCtrl_2',
|
||||||
'wxTimeCtrl',
|
'wxTimeCtrl',
|
||||||
|
'wxTreeListCtrl',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
# How to lay out the controls in a frame/dialog
|
# How to lay out the controls in a frame/dialog
|
||||||
|
102
wxPython/demo/wxTreeListCtrl.py
Normal file
102
wxPython/demo/wxTreeListCtrl.py
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
|
||||||
|
from wxPython.wx import *
|
||||||
|
from wxPython.gizmos import wxTreeListCtrl
|
||||||
|
|
||||||
|
import images
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wxPanel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wxPanel.__init__(self, parent, -1)
|
||||||
|
EVT_SIZE(self, self.OnSize)
|
||||||
|
|
||||||
|
self.tree = wxTreeListCtrl(self, -1, style = wxTR_DEFAULT_STYLE
|
||||||
|
#wxTR_TWIST_BUTTONS
|
||||||
|
)
|
||||||
|
isz = (16,16)
|
||||||
|
il = wxImageList(isz[0], isz[1])
|
||||||
|
fldridx = il.Add(wxArtProvider_GetBitmap(wxART_FOLDER, wxART_OTHER, isz))
|
||||||
|
fldropenidx = il.Add(wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_OTHER, isz))
|
||||||
|
fileidx = il.Add(wxArtProvider_GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, isz))
|
||||||
|
smileidx = il.Add(images.getSmilesBitmap())
|
||||||
|
|
||||||
|
self.tree.SetImageList(il)
|
||||||
|
self.il = il
|
||||||
|
|
||||||
|
# create some columns
|
||||||
|
self.tree.AddColumn("Main column")
|
||||||
|
self.tree.AddColumn("Column 1")
|
||||||
|
self.tree.AddColumn("Column 2")
|
||||||
|
self.tree.SetMainColumn(0) # the one with the tree in it...
|
||||||
|
self.tree.SetColumnWidth(0, 175)
|
||||||
|
|
||||||
|
|
||||||
|
self.root = self.tree.AddRoot("The Root Item")
|
||||||
|
self.tree.SetItemText(self.root, "col 1 root", 1)
|
||||||
|
self.tree.SetItemText(self.root, "col 2 root", 2)
|
||||||
|
self.tree.SetItemImage(self.root, fldridx, which = wxTreeItemIcon_Normal)
|
||||||
|
self.tree.SetItemImage(self.root, fldropenidx, which = wxTreeItemIcon_Expanded)
|
||||||
|
|
||||||
|
|
||||||
|
for x in range(15):
|
||||||
|
txt = "Item %d" % x
|
||||||
|
child = self.tree.AppendItem(self.root, txt)
|
||||||
|
self.tree.SetItemText(child, txt + "(c1)", 1)
|
||||||
|
self.tree.SetItemText(child, txt + "(c2)", 2)
|
||||||
|
self.tree.SetItemImage(child, fldridx, which = wxTreeItemIcon_Normal)
|
||||||
|
self.tree.SetItemImage(child, fldropenidx, which = wxTreeItemIcon_Expanded)
|
||||||
|
|
||||||
|
for y in range(5):
|
||||||
|
txt = "item %d-%s" % (x, chr(ord("a")+y))
|
||||||
|
last = self.tree.AppendItem(child, txt)
|
||||||
|
self.tree.SetItemText(last, txt + "(c1)", 1)
|
||||||
|
self.tree.SetItemText(last, txt + "(c2)", 2)
|
||||||
|
self.tree.SetItemImage(last, fldridx, which = wxTreeItemIcon_Normal)
|
||||||
|
self.tree.SetItemImage(last, fldropenidx, which = wxTreeItemIcon_Expanded)
|
||||||
|
|
||||||
|
for z in range(5):
|
||||||
|
txt = "item %d-%s-%d" % (x, chr(ord("a")+y), z)
|
||||||
|
item = self.tree.AppendItem(last, txt)
|
||||||
|
self.tree.SetItemText(item, txt + "(c1)", 1)
|
||||||
|
self.tree.SetItemText(item, txt + "(c2)", 2)
|
||||||
|
self.tree.SetItemImage(item, fileidx, which = wxTreeItemIcon_Normal)
|
||||||
|
self.tree.SetItemImage(item, smileidx, which = wxTreeItemIcon_Selected)
|
||||||
|
|
||||||
|
|
||||||
|
self.tree.Expand(self.root)
|
||||||
|
|
||||||
|
|
||||||
|
def OnSize(self, evt):
|
||||||
|
self.tree.SetSize(self.GetSize())
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
def runTest(frame, nb, log):
|
||||||
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
overview = """<html><body>
|
||||||
|
<h2><center>wxTreeListCtrl</center></h2>
|
||||||
|
|
||||||
|
The wxTreeListCtrl is essentially a wxTreeCtrl with extra columns,
|
||||||
|
such that the look is similar to a wxListCtrl.
|
||||||
|
|
||||||
|
</body></html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
#raw_input("Press enter...")
|
||||||
|
import sys,os
|
||||||
|
import run
|
||||||
|
run.main(['', os.path.basename(sys.argv[0])])
|
||||||
|
|
@@ -985,9 +985,12 @@ if BUILD_GIZMOS:
|
|||||||
ext = Extension('gizmosc', [
|
ext = Extension('gizmosc', [
|
||||||
'%s/dynamicsash.cpp' % GIZMOLOC,
|
'%s/dynamicsash.cpp' % GIZMOLOC,
|
||||||
'%s/editlbox.cpp' % GIZMOLOC,
|
'%s/editlbox.cpp' % GIZMOLOC,
|
||||||
#'%s/multicell.cpp' % GIZMOLOC,
|
|
||||||
'%s/splittree.cpp' % GIZMOLOC,
|
'%s/splittree.cpp' % GIZMOLOC,
|
||||||
'%s/ledctrl.cpp' % GIZMOLOC,
|
'%s/ledctrl.cpp' % GIZMOLOC,
|
||||||
|
#'%s/multicell.cpp' % GIZMOLOC,
|
||||||
|
|
||||||
|
'%s/treelistctrl.cpp' % location,
|
||||||
|
|
||||||
] + swig_sources,
|
] + swig_sources,
|
||||||
|
|
||||||
include_dirs = gizmos_includes,
|
include_dirs = gizmos_includes,
|
||||||
|
47
wxPython/src/pytree.h
Normal file
47
wxPython/src/pytree.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: pytree.h
|
||||||
|
// Purpose: Common declarations of tree stuff for wxTreeCtrl in the core
|
||||||
|
// and wxTreeListCtrl in gizmos
|
||||||
|
//
|
||||||
|
// Author: Robin Dunn
|
||||||
|
//
|
||||||
|
// Created: 30-April-2003
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2003 by Total Control Software
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxPyTreeItemData : public wxTreeItemData {
|
||||||
|
public:
|
||||||
|
wxPyTreeItemData(PyObject* obj = NULL) {
|
||||||
|
if (obj == NULL)
|
||||||
|
obj = Py_None;
|
||||||
|
Py_INCREF(obj);
|
||||||
|
m_obj = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
~wxPyTreeItemData() {
|
||||||
|
wxPyBeginBlockThreads();
|
||||||
|
Py_DECREF(m_obj);
|
||||||
|
wxPyEndBlockThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* GetData() {
|
||||||
|
Py_INCREF(m_obj);
|
||||||
|
return m_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetData(PyObject* obj) {
|
||||||
|
wxPyBeginBlockThreads();
|
||||||
|
Py_DECREF(m_obj);
|
||||||
|
wxPyEndBlockThreads();
|
||||||
|
m_obj = obj;
|
||||||
|
Py_INCREF(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* m_obj;
|
||||||
|
};
|
||||||
|
|
Reference in New Issue
Block a user