mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-11 14:27:09 +01:00
so IDs pointing to the same item will compare as equal and have the same hash values. This enables TreeItemIDs to be dictionary keys in Py3.
52 lines
1.4 KiB
Plaintext
52 lines
1.4 KiB
Plaintext
//--------------------------------------------------------------------------
|
|
// Name: treeitemdata.sip
|
|
// Purpose: A MappedType for wxTreeItemData that handles containing
|
|
// arbitrary PyObjects, dealing with their refcounts, etc.
|
|
//
|
|
// Author: Robin Dunn
|
|
//
|
|
// Created: 28-Mar-2012
|
|
// Copyright: (c) 2012-2017 by Total Control Software
|
|
// Licence: wxWindows license
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
%ModuleHeaderCode
|
|
#include <wx/treebase.h>
|
|
|
|
// A wxTreeItemData that knows what to do with PyObjects for maintaining the refcount
|
|
class wxPyTreeItemData : public wxPyUserDataHelper<wxTreeItemData>
|
|
{
|
|
public:
|
|
wxPyTreeItemData(PyObject* obj = NULL)
|
|
: wxPyUserDataHelper<wxTreeItemData>(obj)
|
|
{ }
|
|
};
|
|
|
|
%End
|
|
|
|
|
|
%MappedType wxTreeItemData
|
|
{
|
|
%ConvertToTypeCode
|
|
// Code to test a PyObject for compatibility
|
|
if (!sipIsErr) {
|
|
return TRUE; // any python object is valid
|
|
}
|
|
|
|
// Code to create a new wxTreeItemData from the PyObject
|
|
wxPyTreeItemData* data = new wxPyTreeItemData(sipPy);
|
|
*sipCppPtr = data;
|
|
return sipGetState(sipTransferObj);
|
|
%End
|
|
|
|
|
|
%ConvertFromTypeCode
|
|
// Code to convert a wxPyTreeItemData back to the PyObject.
|
|
PyObject* obj;
|
|
obj = wxPyTreeItemData::SafeGetData(static_cast<wxPyTreeItemData*>(sipCpp));
|
|
return obj;
|
|
%End
|
|
|
|
};
|