Add treectrl

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-03-29 16:59:21 +00:00
parent 63796d6f95
commit 95c5c5f50e
6 changed files with 431 additions and 2 deletions

48
src/treeitemdata.h Normal file
View File

@@ -0,0 +1,48 @@
//--------------------------------------------------------------------------
// Name: treeitemdata.h
// Purpose: This class is used to associate a PyObject with a tree item.
//
// Author: Robin Dunn
//
// Created: 26-Mar-2012
// Copyright: (c) 2012 by Total Control Software
// Licence: wxWindows license
//--------------------------------------------------------------------------
#ifndef TREEITEMDATA_H
#define TREEITEMDATA_H
#include <wx/treebase.h>
// A wxTreeItemData that knows what to do with PyObjects for maintianing the refcount
class TreeItemData : public wxTreeItemData {
public:
TreeItemData(PyObject* obj = NULL) {
if (obj == NULL)
obj = Py_None;
wxPyBLOCK_THREADS( Py_INCREF(obj) );
m_obj = obj;
}
~TreeItemData() {
wxPyBLOCK_THREADS( Py_DECREF(m_obj) );
}
PyObject* GetData() {
wxPyBLOCK_THREADS( Py_INCREF(m_obj) );
return m_obj;
}
void SetData(PyObject* obj) {
wxPyBlock_t blocked = wxPyBeginBlockThreads();
Py_DECREF(m_obj);
m_obj = obj;
Py_INCREF(obj);
wxPyEndBlockThreads(blocked);
}
private:
PyObject* m_obj;
};
#endif

View File

@@ -88,6 +88,9 @@ inline void wxPyEndAllowThreads(PyThreadState* saved) {
wxPyBLOCK_THREADS( PyErr_SetString(PyExc_NotImplementedError, msg) );
// A convenience macro for properly returning Py_None
//#define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
#define RETURN_NONE() { wxPyBLOCK_THREADS(Py_INCREF(Py_None)); return Py_None; }
//--------------------------------------------------------------------------
// The API items whose implementation can not or should not be inline