| 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 | |
| 15 | |
| 16 | |
| 17 | class wxPyTreeItemData : public wxTreeItemData { |
| 18 | public: |
| 19 | wxPyTreeItemData(PyObject* obj = NULL) { |
| 20 | if (obj == NULL) |
| 21 | obj = Py_None; |
| 22 | Py_INCREF(obj); |
| 23 | m_obj = obj; |
| 24 | } |
| 25 | |
| 26 | ~wxPyTreeItemData() { |
| 27 | wxPyBeginBlockThreads(); |
| 28 | Py_DECREF(m_obj); |
| 29 | wxPyEndBlockThreads(); |
| 30 | } |
| 31 | |
| 32 | PyObject* GetData() { |
| 33 | Py_INCREF(m_obj); |
| 34 | return m_obj; |
| 35 | } |
| 36 | |
| 37 | void SetData(PyObject* obj) { |
| 38 | wxPyBeginBlockThreads(); |
| 39 | Py_DECREF(m_obj); |
| 40 | wxPyEndBlockThreads(); |
| 41 | m_obj = obj; |
| 42 | Py_INCREF(obj); |
| 43 | } |
| 44 | |
| 45 | PyObject* m_obj; |
| 46 | }; |
| 47 | |