X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a72f4631fe5ab7ebeefdacf8ec9c826ea962133f..38b2e0de1806b8c5e723cdd04d20ce2b911ed5c4:/wxPython/src/_dnd.i diff --git a/wxPython/src/_dnd.i b/wxPython/src/_dnd.i index dfa264c4ae..01a908c031 100644 --- a/wxPython/src/_dnd.i +++ b/wxPython/src/_dnd.i @@ -55,7 +55,8 @@ IMP_PYCALLBACK_BOOL_DR(wxPyDropSource, wxDropSource, GiveFeedback); %} -%name(DropSource) class wxPyDropSource { +%rename(DropSource) wxPyDropSource; +class wxPyDropSource { public: %pythonAppend wxPyDropSource "self._setCallbackInfo(self, DropSource, 0)" #ifndef __WXGTK__ @@ -83,10 +84,26 @@ public: wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); - bool base_GiveFeedback(wxDragResult effect); + bool GiveFeedback(wxDragResult effect); + %MAKE_BASE_FUNC(DropSource, GiveFeedback); }; +%pythoncode { +def DROP_ICON(filename): + """ + Returns either a `wx.Cursor` or `wx.Icon` created from the image file + ``filename``. This function is useful with the `wx.DropSource` class + which, depending on platform accepts either a icon or a cursor. + """ + img = wx.Image(filename) + if wx.Platform == '__WXGTK__': + return wx.IconFromBitmap(wx.BitmapFromImage(img)) + else: + return wx.CursorFromImage(img) +} + + //--------------------------------------------------------------------------- // wxDropTarget should be associated with a window if it wants to be able to @@ -115,12 +132,14 @@ IMP_PYCALLBACK_BOOL_INTINT(wxPyDropTarget, wxDropTarget, OnDrop); %} -%name(DropTarget) class wxPyDropTarget // : public wxDropTarget +%rename(DropTarget) wxPyDropTarget; +class wxPyDropTarget // : public wxDropTarget { public: %pythonAppend wxPyDropTarget "self._setCallbackInfo(self, DropTarget)" - %apply SWIGTYPE *DISOWN { wxDataObject *dataObject }; + + %disownarg( wxDataObject *dataObject ); wxPyDropTarget(wxDataObject *dataObject = NULL); void _setCallbackInfo(PyObject* self, PyObject* _class); @@ -131,17 +150,32 @@ public: wxDataObject *GetDataObject(); void SetDataObject(wxDataObject *dataObject); - %clear wxDataObject *dataObject; + %cleardisown( wxDataObject *dataObject ); + + wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); + wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); + void OnLeave(); + bool OnDrop(wxCoord x, wxCoord y); - wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); - wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); - void base_OnLeave(); - bool base_OnDrop(wxCoord x, wxCoord y); + %MAKE_BASE_FUNC(DropTarget, OnEnter); + %MAKE_BASE_FUNC(DropTarget, OnDragOver); + %MAKE_BASE_FUNC(DropTarget, OnLeave); + %MAKE_BASE_FUNC(DropTarget, OnDrop); + // may be called *only* from inside OnData() and will fill m_dataObject // with the data from the drop source if it returns True bool GetData(); + // sets the default action for drag and drop: + // use wxDragMove or wxDragCopy to set deafult action to move or copy + // and use wxDragNone (default) to set default action specified by + // initialization of draging (see wxDropSourceBase::DoDragDrop()) + void SetDefaultAction(wxDragResult action); + + // returns default action for drag and drop or + // wxDragNone if this not specified + wxDragResult GetDefaultAction(); }; @@ -178,19 +212,27 @@ IMP_PYCALLBACK_BOOL_INTINT(wxPyTextDropTarget, wxTextDropTarget, OnDrop); %} -%name(TextDropTarget) class wxPyTextDropTarget : public wxPyDropTarget { +%rename(TextDropTarget) wxPyTextDropTarget; +class wxPyTextDropTarget : public wxPyDropTarget { public: %pythonAppend wxPyTextDropTarget "self._setCallbackInfo(self, TextDropTarget)" wxPyTextDropTarget(); void _setCallbackInfo(PyObject* self, PyObject* _class); - //bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0; - wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); - wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); - void base_OnLeave(); - bool base_OnDrop(wxCoord x, wxCoord y); - wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); + bool OnDropText(wxCoord x, wxCoord y, const wxString& text); + wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); + wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); + void OnLeave(); + bool OnDrop(wxCoord x, wxCoord y); + wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); + + %MAKE_BASE_FUNC(TextDropTarget, OnDropText); + %MAKE_BASE_FUNC(TextDropTarget, OnEnter); + %MAKE_BASE_FUNC(TextDropTarget, OnDragOver); + %MAKE_BASE_FUNC(TextDropTarget, OnLeave); + %MAKE_BASE_FUNC(TextDropTarget, OnDrop); + %MAKE_BASE_FUNC(TextDropTarget, OnData); }; //--------------------------------------------------------------------------- @@ -217,7 +259,7 @@ public: bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) { bool rval = false; - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "OnDropFiles")) { PyObject* list = wxArrayString2PyList_helper(filenames); rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",x,y,list)); @@ -238,7 +280,8 @@ IMP_PYCALLBACK_BOOL_INTINT(wxPyFileDropTarget, wxFileDropTarget, OnDrop); %} -%name(FileDropTarget) class wxPyFileDropTarget : public wxPyDropTarget +%rename(FileDropTarget) wxPyFileDropTarget; +class wxPyFileDropTarget : public wxPyDropTarget { public: %pythonAppend wxPyFileDropTarget "self._setCallbackInfo(self, FileDropTarget)" @@ -246,12 +289,19 @@ public: wxPyFileDropTarget(); void _setCallbackInfo(PyObject* self, PyObject* _class); -// bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) = 0; - wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); - wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); - void base_OnLeave(); - bool base_OnDrop(wxCoord x, wxCoord y); - wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); + bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames); + wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); + wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); + void OnLeave(); + bool OnDrop(wxCoord x, wxCoord y); + wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); + + %MAKE_BASE_FUNC(FileDropTarget, OnDropFiles); + %MAKE_BASE_FUNC(FileDropTarget, OnEnter); + %MAKE_BASE_FUNC(FileDropTarget, OnDragOver); + %MAKE_BASE_FUNC(FileDropTarget, OnLeave); + %MAKE_BASE_FUNC(FileDropTarget, OnDrop); + %MAKE_BASE_FUNC(FileDropTarget, OnData); };