X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b37c7e1dcdad16c20d9800d2abaf53cc6b653a64..0c8392cac2d36d0d211432e71d3b24d3d93c22db:/wxPython/src/clip_dnd.i diff --git a/wxPython/src/clip_dnd.i b/wxPython/src/clip_dnd.i index ceb7b053ea..0fe784009d 100644 --- a/wxPython/src/clip_dnd.i +++ b/wxPython/src/clip_dnd.i @@ -13,8 +13,6 @@ %module clip_dnd -#ifndef __WXMAC__ - %{ #include "helpers.h" #include @@ -35,30 +33,36 @@ %pragma(python) code = "import wx" +//--------------------------------------------------------------------------- +%{ + // Put some wx default wxChar* values into wxStrings. + static const wxString wxPyEmptyString(wxT("")); +%} //---------------------------------------------------------------------- enum wxDataFormatId { - wxDF_INVALID = 0, - wxDF_TEXT = 1, /* CF_TEXT */ - wxDF_BITMAP = 2, /* CF_BITMAP */ - wxDF_METAFILE = 3, /* CF_METAFILEPICT */ - wxDF_SYLK = 4, - wxDF_DIF = 5, - wxDF_TIFF = 6, - wxDF_OEMTEXT = 7, /* CF_OEMTEXT */ - wxDF_DIB = 8, /* CF_DIB */ - wxDF_PALETTE = 9, - wxDF_PENDATA = 10, - wxDF_RIFF = 11, - wxDF_WAVE = 12, - wxDF_UNICODETEXT = 13, - wxDF_ENHMETAFILE = 14, - wxDF_FILENAME = 15, /* CF_HDROP */ - wxDF_LOCALE = 16, - wxDF_PRIVATE = 20, - wxDF_MAX + wxDF_INVALID, + wxDF_TEXT, + wxDF_BITMAP, + wxDF_METAFILE, + wxDF_SYLK, + wxDF_DIF, + wxDF_TIFF, + wxDF_OEMTEXT, + wxDF_DIB, + wxDF_PALETTE, + wxDF_PENDATA, + wxDF_RIFF, + wxDF_WAVE, + wxDF_UNICODETEXT, + wxDF_ENHMETAFILE, + wxDF_FILENAME, + wxDF_LOCALE, + wxDF_PRIVATE, + wxDF_HTML, + wxDF_MAX, }; //---------------------------------------------------------------------- @@ -72,7 +76,7 @@ public: wxDataFormatId GetType() const; wxString GetId() const; - void SetId(const char *format); + void SetId(const wxString& format); }; %new wxDataFormat* wxCustomDataFormat(const wxString &id); @@ -107,10 +111,13 @@ public: wxDataFormat GetPreferredFormat(Direction dir = wxDataObject::Get); size_t GetFormatCount(Direction dir = wxDataObject::Get); + + // TODO: Fix these two to be usable from wxPython. void GetAllFormats(wxDataFormat *formats, Direction dir = wxDataObject::Get); - size_t GetDataSize(const wxDataFormat& format); bool GetDataHere(const wxDataFormat& format, void *buf); + + size_t GetDataSize(const wxDataFormat& format); bool SetData(const wxDataFormat& format, size_t len, const void * buf); bool IsSupportedFormat(const wxDataFormat& format); @@ -149,7 +156,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) { // C++ version. bool rval = FALSE; - wxPyTState* state = wxPyBeginBlockThreads(); + wxPyBeginBlockThreads(); if (m_myInst.findCallback("GetDataHere")) { PyObject* ro; ro = m_myInst.callCallbackObj(Py_BuildValue("()")); @@ -160,7 +167,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) { Py_DECREF(ro); } } - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return rval; } @@ -168,13 +175,13 @@ bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) { // 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; } %} @@ -205,7 +212,7 @@ public: class wxTextDataObject : public wxDataObjectSimple { public: - wxTextDataObject(const wxString& text = wxEmptyString); + wxTextDataObject(const wxString& text = wxPyEmptyString); size_t GetTextLength(); wxString GetText(); @@ -217,7 +224,7 @@ public: %{ // 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); @@ -236,7 +243,7 @@ IMP_PYCALLBACK__STRING(wxPyTextDataObject, wxTextDataObject, SetText); // 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)" }; @@ -266,7 +273,7 @@ public: wxBitmap wxPyBitmapDataObject::GetBitmap() { wxBitmap* rval = &wxNullBitmap; - wxPyTState* state = wxPyBeginBlockThreads(); + wxPyBeginBlockThreads(); if (m_myInst.findCallback("GetBitmap")) { PyObject* ro; wxBitmap* ptr; @@ -277,17 +284,18 @@ wxBitmap wxPyBitmapDataObject::GetBitmap() { 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"))); + PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap")); + m_myInst.callCallback(Py_BuildValue("(O)", bo)); + Py_DECREF(bo); } - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); } %} @@ -367,6 +375,25 @@ public: void SetURL(const wxString& url); }; +//---------------------------------------------------------------------- + +#ifndef __WXGTK__ + +%{ +#include +%} + +class wxMetafileDataObject : public wxDataObjectSimple +{ +public: + wxMetafileDataObject(); + + void SetMetafile(const wxMetafile& metafile); + wxMetafile GetMetafile() const; +}; + +#endif + //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -391,17 +418,30 @@ public: void UsePrimarySelection( int primary = FALSE ); }; + +%readonly %{ - // See below in the init function... - wxClipboard* wxPyTheClipboard; +#if 0 +%} +// See also wxPy_ReinitStockObjects in helpers.cpp +extern wxClipboard* wxTheClipboard; +%{ +#endif %} -%readonly -%name(wxTheClipboard) wxClipboard* wxPyTheClipboard; %readwrite //---------------------------------------------------------------------- //---------------------------------------------------------------------- +// flags for wxDropSource::DoDragDrop() +// +enum +{ + wxDrag_CopyOnly = 0, // allow only copying + wxDrag_AllowMove = 1, // allow moving (copying is always allowed) + wxDrag_DefaultMove = 3 // the default operation is move, not copy +}; + enum wxDragResult { wxDragError, // error prevented the d&d operation from completing @@ -418,16 +458,18 @@ bool wxIsDragResultOk(wxDragResult res); %{ class wxPyDropSource : public wxDropSource { public: -#ifdef __WXMSW__ - wxPyDropSource(wxWindow *win = NULL, - const wxCursor &cursorCopy = wxNullCursor, - const wxCursor &cursorMove = wxNullCursor, - const wxCursor &cursorStop = wxNullCursor) - : wxDropSource(win, cursorCopy, cursorMove, cursorStop) {} +#ifndef __WXGTK__ + wxPyDropSource(wxWindow *win = NULL, + const wxCursor © = wxNullCursor, + const wxCursor &move = wxNullCursor, + const wxCursor &none = wxNullCursor) + : wxDropSource(win, copy, move, none) {} #else wxPyDropSource(wxWindow *win = NULL, - const wxIcon &go = wxNullIcon) - : wxDropSource(win, go) {} + const wxIcon& copy = wxNullIcon, + const wxIcon& move = wxNullIcon, + const wxIcon& none = wxNullIcon) + : wxDropSource(win, copy, move, none) {} #endif ~wxPyDropSource() { } @@ -442,14 +484,16 @@ IMP_PYCALLBACK_BOOL_DR(wxPyDropSource, wxDropSource, GiveFeedback); %name(wxDropSource) class wxPyDropSource { public: -#ifdef __WXMSW__ - wxPyDropSource(wxWindow *win = NULL, - const wxCursor &cursorCopy = wxNullCursor, - const wxCursor &cursorMove = wxNullCursor, - const wxCursor &cursorStop = wxNullCursor); +#ifndef __WXGTK__ + wxPyDropSource(wxWindow *win = NULL, + const wxCursor © = wxNullCursor, + const wxCursor &move = wxNullCursor, + const wxCursor &none = wxNullCursor); #else wxPyDropSource(wxWindow *win = NULL, - const wxIcon &go = wxNullIcon); + const wxIcon& copy = wxNullIcon, + const wxIcon& move = wxNullIcon, + const wxIcon& none = wxNullIcon); #endif void _setCallbackInfo(PyObject* self, PyObject* _class, int incref); @@ -459,7 +503,7 @@ public: void SetData(wxDataObject& data); wxDataObject *GetDataObject(); void SetCursor(wxDragResult res, const wxCursor& cursor); - wxDragResult DoDragDrop(int bAllowMove = FALSE); + wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); bool base_GiveFeedback(wxDragResult effect); }; @@ -592,12 +636,13 @@ public: bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) { bool rval = FALSE; - wxPyTState* state = wxPyBeginBlockThreads(); - PyObject* list = wxArrayString2PyList_helper(filenames); - if (m_myInst.findCallback("OnDropFiles")) + wxPyBeginBlockThreads(); + if (m_myInst.findCallback("OnDropFiles")) { + PyObject* list = wxArrayString2PyList_helper(filenames); rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list)); - Py_DECREF(list); - wxPyEndBlockThreads(state); + Py_DECREF(list); + } + wxPyEndBlockThreads(); return rval; } @@ -633,12 +678,11 @@ public: %init %{ - wxPyTheClipboard = wxTheClipboard; wxPyPtrTypeMap_Add("wxDropSource", "wxPyDropSource"); wxPyPtrTypeMap_Add("wxTextDropTarget", "wxPyTextDropTarget"); wxPyPtrTypeMap_Add("wxFileDropTarget", "wxPyFileDropTarget"); %} //---------------------------------------------------------------------- -#endif +