]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/pytree.h
2cd3172e928e2c9374a844e06f33529f8d2d51ce
[wxWidgets.git] / wxPython / include / wx / wxPython / pytree.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pytree.h
3 // Purpose: Common declarations of tree stuff for wxTreeCtrl in the core
4 // and wxTreeListCtrl in gizmos
5 //
6 // Author: Robin Dunn
7 //
8 // Created: 30-April-2003
9 // RCS-ID: $Id$
10 // Copyright: (c) 2003 by Total Control Software
11 // Licence: wxWindows license
12 /////////////////////////////////////////////////////////////////////////////
13
14 #ifndef __pytree_h__
15 #define __pytree_h__
16
17
18 class wxPyTreeItemData : public wxTreeItemData {
19 public:
20 wxPyTreeItemData(PyObject* obj = NULL) {
21 if (obj == NULL)
22 obj = Py_None;
23 Py_INCREF(obj);
24 m_obj = obj;
25 }
26
27 ~wxPyTreeItemData() {
28 bool blocked = wxPyBeginBlockThreads();
29 Py_DECREF(m_obj);
30 wxPyEndBlockThreads(blocked);
31 }
32
33 PyObject* GetData() {
34 Py_INCREF(m_obj);
35 return m_obj;
36 }
37
38 void SetData(PyObject* obj) {
39 bool blocked = wxPyBeginBlockThreads();
40 Py_DECREF(m_obj);
41 wxPyEndBlockThreads(blocked);
42 m_obj = obj;
43 Py_INCREF(obj);
44 }
45
46 PyObject* m_obj;
47 };
48
49
50
51 #endif