mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-27 14:10:07 +01:00
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:
48
src/treeitemdata.h
Normal file
48
src/treeitemdata.h
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user