+ %addmethods {
+ // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
+ // if needed.
+ wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
+ wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
+ if (data == NULL) {
+ data = new wxPyTreeItemData();
+ self->SetItemData(item, data);
+ }
+ return data;
+ }
+
+ void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
+ self->SetItemData(item, data);
+ }
+
+ // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by
+ // automatically creating data classes.
+ PyObject* GetPyData(const wxTreeItemId& item) {
+ wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
+ if (data == NULL) {
+ data = new wxPyTreeItemData();
+ self->SetItemData(item, data);
+ }
+ return data->GetData();
+ }
+
+ void SetPyData(const wxTreeItemId& item, PyObject* obj) {
+ wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
+ if (data == NULL) {
+ data = new wxPyTreeItemData(obj);
+ self->SetItemData(item, data);
+ } else
+ data->SetData(obj);
+ }
+ }
+
+