%module clip_dnd
+#ifndef __WXMAC__
+
%{
#include "helpers.h"
#include <wx/dataobj.h>
// C++ version.
bool rval = FALSE;
- bool doSave = wxPyRestoreThread();
+ wxPyTState* state = wxPyBeginBlockThreads();
if (m_myInst.findCallback("GetDataHere")) {
PyObject* ro;
ro = m_myInst.callCallbackObj(Py_BuildValue("()"));
Py_DECREF(ro);
}
}
- wxPySaveThread(doSave);
+ wxPyEndBlockThreads(state);
return rval;
}
// For this one we simply need to make a string from buf and len
// and send it to the Python method.
bool rval = FALSE;
- bool doSave = wxPyRestoreThread();
+ wxPyTState* state = wxPyBeginBlockThreads();
if (m_myInst.findCallback("SetData")) {
PyObject* data = PyString_FromStringAndSize((char*)buf, len);
rval = m_myInst.callCallback(Py_BuildValue("(O)", data));
Py_DECREF(data);
}
- wxPySaveThread(doSave);
+ wxPyEndBlockThreads(state);
return rval;
}
%}
class wxPyDataObjectSimple : public wxDataObjectSimple {
public:
wxPyDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid);
- void _setSelf(PyObject* self, PyObject* _class);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyDataObjectSimple)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDataObjectSimple)"
};
//----------------------------------------------------------------------
class wxPyTextDataObject : public wxTextDataObject {
public:
wxPyTextDataObject(const wxString& text = wxEmptyString);
- void _setSelf(PyObject* self, PyObject* _class);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyTextDataObject)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTextDataObject)"
};
//----------------------------------------------------------------------
wxBitmap wxPyBitmapDataObject::GetBitmap() {
wxBitmap* rval = &wxNullBitmap;
- bool doSave = wxPyRestoreThread();
+ wxPyTState* state = wxPyBeginBlockThreads();
if (m_myInst.findCallback("GetBitmap")) {
PyObject* ro;
wxBitmap* ptr;
Py_DECREF(ro);
}
}
- wxPySaveThread(doSave);
+ wxPyEndBlockThreads(state);
return *rval;
}
void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
- bool doSave = wxPyRestoreThread();
+ wxPyTState* state = wxPyBeginBlockThreads();
if (m_myInst.findCallback("SetBitmap")) {
m_myInst.callCallback(Py_BuildValue("(O)",
wxPyConstructObject((void*)&bitmap, "wxBitmap")));
}
- wxPySaveThread(doSave);
+ wxPyEndBlockThreads(state);
}
%}
class wxPyBitmapDataObject : public wxBitmapDataObject {
public:
wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
- void _setSelf(PyObject* self, PyObject* _class);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyBitmapDataObject)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyBitmapDataObject)"
};
%addmethods {
PyObject* GetFilenames() {
const wxArrayString& strings = self->GetFilenames();
- PyObject* list = PyList_New(0);
- for (size_t x=0; x<strings.GetCount(); x++)
- PyList_Append(list, PyString_FromString(strings[x]));
- return list;
+ return wxArrayString2PyList_helper(strings);
}
}
#ifdef __WXMSW__
};
+//----------------------------------------------------------------------
+
+class wxURLDataObject : public wxDataObjectComposite {
+public:
+ wxURLDataObject();
+
+ wxString GetURL();
+ void SetURL(const wxString& url);
+};
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
-class wxClipboard {
+class wxClipboard : public wxObject {
public:
wxClipboard();
wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved (MSW only)
+ wxDragLink, // operation is a drag-link
wxDragCancel // the operation was cancelled by user (not an error)
};
const wxIcon &go = wxNullIcon);
#endif
- void _setSelf(PyObject* self, PyObject* _class, int incref);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxDropSource, 0)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class, int incref);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxDropSource, 0)"
~wxPyDropSource();
void SetData(wxDataObject& data);
public:
wxPyDropTarget(wxDataObject *dataObject = NULL);
%pragma(python) addtomethod = "__init__:if _args:_args[0].thisown = 0"
- void _setSelf(PyObject* self, PyObject* _class);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyDropTarget)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDropTarget)"
~wxPyDropTarget();
%name(wxTextDropTarget) class wxPyTextDropTarget : public wxPyDropTarget {
public:
wxPyTextDropTarget();
- void _setSelf(PyObject* self, PyObject* _class);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxTextDropTarget)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTextDropTarget)"
//bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def);
bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames) {
bool rval = FALSE;
- bool doSave = wxPyRestoreThread();
- PyObject* list = PyList_New(0);
- for (size_t i=0; i<filenames.GetCount(); i++) {
- PyObject* str = PyString_FromString(filenames[i].c_str());
- PyList_Append(list, str);
- }
+ wxPyTState* state = wxPyBeginBlockThreads();
+ PyObject* list = wxArrayString2PyList_helper(filenames);
if (m_myInst.findCallback("OnDropFiles"))
rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list));
Py_DECREF(list);
- wxPySaveThread(doSave);
+ wxPyEndBlockThreads(state);
return rval;
}
{
public:
wxPyFileDropTarget();
- void _setSelf(PyObject* self, PyObject* _class);
- %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFileDropTarget)"
+ void _setCallbackInfo(PyObject* self, PyObject* _class);
+ %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFileDropTarget)"
// bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) = 0;
wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def);
%init %{
wxPyTheClipboard = wxTheClipboard;
-
+ wxPyPtrTypeMap_Add("wxDropSource", "wxPyDropSource");
+ wxPyPtrTypeMap_Add("wxTextDropTarget", "wxPyTextDropTarget");
+ wxPyPtrTypeMap_Add("wxFileDropTarget", "wxPyFileDropTarget");
%}
//----------------------------------------------------------------------
+#endif