%module clip_dnd
+#ifndef __WXMAC__
+
%{
#include "helpers.h"
#include <wx/dataobj.h>
%pragma(python) code = "import wx"
+//---------------------------------------------------------------------------
+%{
+ // Put some wx default wxChar* values into wxStrings.
+ static const wxString wxPyEmptyString(wxT(""));
+%}
//----------------------------------------------------------------------
wxDataFormatId GetType() const;
wxString GetId() const;
- void SetId(const char *format);
+ void SetId(const wxString& format);
};
%new wxDataFormat* wxCustomDataFormat(const wxString &id);
// C++ version.
bool rval = FALSE;
- wxPyTState* state = wxPyBeginBlockThreads();
+ wxPyBeginBlockThreads();
if (m_myInst.findCallback("GetDataHere")) {
PyObject* ro;
ro = m_myInst.callCallbackObj(Py_BuildValue("()"));
Py_DECREF(ro);
}
}
- wxPyEndBlockThreads(state);
+ wxPyEndBlockThreads();
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;
- wxPyTState* state = wxPyBeginBlockThreads();
+ wxPyBeginBlockThreads();
if (m_myInst.findCallback("SetData")) {
PyObject* data = PyString_FromStringAndSize((char*)buf, len);
rval = m_myInst.callCallback(Py_BuildValue("(O)", data));
Py_DECREF(data);
}
- wxPyEndBlockThreads(state);
+ wxPyEndBlockThreads();
return rval;
}
%}
class wxTextDataObject : public wxDataObjectSimple {
public:
- wxTextDataObject(const wxString& text = wxEmptyString);
+ wxTextDataObject(const wxString& text = wxPyEmptyString);
size_t GetTextLength();
wxString GetText();
%{ // Create a new class for wxPython to use
class wxPyTextDataObject : public wxTextDataObject {
public:
- wxPyTextDataObject(const wxString& text = wxEmptyString)
+ wxPyTextDataObject(const wxString& text = wxPyEmptyString)
: wxTextDataObject(text) {}
DEC_PYCALLBACK_SIZET_(GetTextLength);
// Now define it for SWIG
class wxPyTextDataObject : public wxTextDataObject {
public:
- wxPyTextDataObject(const wxString& text = wxEmptyString);
+ wxPyTextDataObject(const wxString& text = wxPyEmptyString);
void _setCallbackInfo(PyObject* self, PyObject* _class);
%pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTextDataObject)"
};
wxBitmap wxPyBitmapDataObject::GetBitmap() {
wxBitmap* rval = &wxNullBitmap;
- wxPyTState* state = wxPyBeginBlockThreads();
+ wxPyBeginBlockThreads();
if (m_myInst.findCallback("GetBitmap")) {
PyObject* ro;
wxBitmap* ptr;
Py_DECREF(ro);
}
}
- wxPyEndBlockThreads(state);
+ wxPyEndBlockThreads();
return *rval;
}
void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
- wxPyTState* state = wxPyBeginBlockThreads();
+ wxPyBeginBlockThreads();
if (m_myInst.findCallback("SetBitmap")) {
m_myInst.callCallback(Py_BuildValue("(O)",
wxPyConstructObject((void*)&bitmap, "wxBitmap")));
}
- wxPyEndBlockThreads(state);
+ wxPyEndBlockThreads();
}
%}
%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);
+};
+
+//----------------------------------------------------------------------
+
+#ifndef __WXGTK__
+
+%{
+#include <wx/metafile.h>
+%}
+
+class wxMetafileDataObject : public wxDataObjectSimple
+{
+public:
+ wxMetafileDataObject();
+
+ void SetMetafile(const wxMetafile& metafile);
+ wxMetafile GetMetafile() const;
+};
+
+#endif
//----------------------------------------------------------------------
//----------------------------------------------------------------------
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)
};
bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames) {
bool rval = FALSE;
- wxPyTState* state = wxPyBeginBlockThreads();
- 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);
- }
+ wxPyBeginBlockThreads();
+ PyObject* list = wxArrayString2PyList_helper(filenames);
if (m_myInst.findCallback("OnDropFiles"))
rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list));
Py_DECREF(list);
- wxPyEndBlockThreads(state);
+ wxPyEndBlockThreads();
return rval;
}
%}
//----------------------------------------------------------------------
+#endif