/usr/include/wx-3.0/wx/wxPython/i_files/_dnd.i is in python-wxgtk3.0-dev 3.0.2.0+dfsg-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | /////////////////////////////////////////////////////////////////////////////
// Name: _dnd.i
// Purpose: SWIG definitions for the Drag-n-drop classes
//
// Author: Robin Dunn
//
// Created: 31-October-1999
// RCS-ID: $Id$
// Copyright: (c) 2003 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Not a %module
//---------------------------------------------------------------------------
#ifndef __WXX11__
%newgroup
// flags for wxDropSource::DoDragDrop()
//
// NB: wxDrag_CopyOnly must be 0 (== False) and wxDrag_AllowMove must be 1
// (== True) for compatibility with the old DoDragDrop(bool) method!
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
};
// result of wxDropSource::DoDragDrop() call
enum wxDragResult
{
wxDragError, // error prevented the d&d operation from completing
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 wxIsDragResultOk(wxDragResult res);
//---------------------------------------------------------------------------
// wxDropSource is the object you need to create (and call DoDragDrop on it)
// to initiate a drag-and-drop operation
%{
IMP_PYCALLBACK_BOOL_DR(wxPyDropSource, wxDropSource, GiveFeedback);
%}
%rename(DropSource) wxPyDropSource;
class wxPyDropSource {
public:
%pythonAppend wxPyDropSource setCallbackInfo(DropSource)
#ifndef __WXGTK__
wxPyDropSource(wxWindow *win,
const wxCursor © = wxNullCursor,
const wxCursor &move = wxNullCursor,
const wxCursor &none = wxNullCursor);
#else
wxPyDropSource(wxWindow *win,
const wxIcon& copy = wxNullIcon,
const wxIcon& move = wxNullIcon,
const wxIcon& none = wxNullIcon);
#endif
void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=0);
~wxPyDropSource();
// set the data which is transfered by drag and drop
void SetData(wxDataObject& data);
wxDataObject *GetDataObject();
// set the icon corresponding to given drag result
void SetCursor(wxDragResult res, const wxCursor& cursor);
wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
bool GiveFeedback(wxDragResult effect);
%MAKE_BASE_FUNC(DropSource, GiveFeedback);
%property(DataObject, GetDataObject, SetData, doc="See `GetDataObject` and `SetData`");
};
%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 an 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
// receive data via drag and drop.
//
// To use this class, you should derive from wxDropTarget and implement
// OnData() pure virtual method. You may also wish to override OnDrop() if you
// want to accept the data only inside some region of the window (this may
// avoid having to copy the data to this application which happens only when
// OnData() is called)
// Just a place holder for the type system. The real base class for
// wxPython is wxPyDropTarget
// class wxDropTarget {
// public:
// };
%{
IMP_PYCALLBACK__(wxPyDropTarget, wxDropTarget, OnLeave);
IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnEnter);
IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnDragOver);
IMP_PYCALLBACK_DR_2WXCDR_pure(wxPyDropTarget, wxDropTarget, OnData);
IMP_PYCALLBACK_BOOL_2COORD(wxPyDropTarget, wxDropTarget, OnDrop);
%}
%rename(DropTarget) wxPyDropTarget;
class wxPyDropTarget // : public wxDropTarget
{
public:
%pythonAppend wxPyDropTarget setCallbackInfo(DropTarget)
%disownarg( wxDataObject *dataObject );
wxPyDropTarget(wxDataObject *dataObject = NULL);
void _setCallbackInfo(PyObject* self, PyObject* _class);
~wxPyDropTarget();
// get/set the associated wxDataObject
wxDataObject *GetDataObject();
void SetDataObject(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);
%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();
%property(DataObject, GetDataObject, SetDataObject, doc="See `GetDataObject` and `SetDataObject`");
%property(DefaultAction, GetDefaultAction, SetDefaultAction, doc="See `GetDefaultAction` and `SetDefaultAction`");
};
%pythoncode { PyDropTarget = DropTarget }
//---------------------------------------------------------------------------
// A simple wxDropTarget derived class for text data: you only need to
// override OnDropText() to get something working
%{
class wxPyTextDropTarget : public wxTextDropTarget {
public:
wxPyTextDropTarget() {}
DEC_PYCALLBACK_BOOL_2COORDSTR_pure(OnDropText);
DEC_PYCALLBACK__(OnLeave);
DEC_PYCALLBACK_DR_2WXCDR(OnEnter);
DEC_PYCALLBACK_DR_2WXCDR(OnDragOver);
DEC_PYCALLBACK_DR_2WXCDR(OnData);
DEC_PYCALLBACK_BOOL_2COORD(OnDrop);
PYPRIVATE;
};
IMP_PYCALLBACK_BOOL_2COORDSTR_pure(wxPyTextDropTarget, wxTextDropTarget, OnDropText);
IMP_PYCALLBACK__(wxPyTextDropTarget, wxTextDropTarget, OnLeave);
IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnEnter);
IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnDragOver);
IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnData);
IMP_PYCALLBACK_BOOL_2COORD(wxPyTextDropTarget, wxTextDropTarget, OnDrop);
%}
%rename(TextDropTarget) wxPyTextDropTarget;
class wxPyTextDropTarget : public wxPyDropTarget {
public:
%pythonAppend wxPyTextDropTarget setCallbackInfo(TextDropTarget)
wxPyTextDropTarget();
void _setCallbackInfo(PyObject* self, PyObject* _class);
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);
};
//---------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
%{
class wxPyFileDropTarget : public wxFileDropTarget {
public:
wxPyFileDropTarget() {}
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
DEC_PYCALLBACK__(OnLeave);
DEC_PYCALLBACK_DR_2WXCDR(OnEnter);
DEC_PYCALLBACK_DR_2WXCDR(OnDragOver);
DEC_PYCALLBACK_DR_2WXCDR(OnData);
DEC_PYCALLBACK_BOOL_2COORD(OnDrop);
PYPRIVATE;
};
bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames) {
bool rval = false;
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));
Py_DECREF(list);
}
wxPyEndBlockThreads(blocked);
return rval;
}
IMP_PYCALLBACK__(wxPyFileDropTarget, wxFileDropTarget, OnLeave);
IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnEnter);
IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnDragOver);
IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnData);
IMP_PYCALLBACK_BOOL_INTINT(wxPyFileDropTarget, wxFileDropTarget, OnDrop);
%}
%rename(FileDropTarget) wxPyFileDropTarget;
class wxPyFileDropTarget : public wxPyDropTarget
{
public:
%pythonAppend wxPyFileDropTarget setCallbackInfo(FileDropTarget)
wxPyFileDropTarget();
void _setCallbackInfo(PyObject* self, PyObject* _class);
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);
};
//---------------------------------------------------------------------------
%init %{
wxPyPtrTypeMap_Add("wxDropSource", "wxPyDropSource");
wxPyPtrTypeMap_Add("wxDropTarget", "wxPyDropTarget");
wxPyPtrTypeMap_Add("wxTextDropTarget", "wxPyTextDropTarget");
wxPyPtrTypeMap_Add("wxFileDropTarget", "wxPyFileDropTarget");
%}
//---------------------------------------------------------------------------
#endif
|