]>
Commit | Line | Data |
---|---|---|
b1462dfa RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: clip_dnd.i | |
3 | // Purpose: SWIG definitions for the Clipboard and Drag-n-drop classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 31-October-1999 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1999 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module clip_dnd | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/dataobj.h> | |
19 | #include <wx/clipbrd.h> | |
20 | #include <wx/dnd.h> | |
21 | %} | |
22 | ||
23 | //---------------------------------------------------------------------- | |
24 | ||
25 | %include typemaps.i | |
26 | %include my_typemaps.i | |
27 | ||
28 | // Import some definitions of other classes, etc. | |
29 | %import _defs.i | |
30 | %import misc.i | |
31 | %import gdi.i | |
32 | ||
33 | ||
34 | %pragma(python) code = "import wx" | |
35 | ||
137b5242 RD |
36 | //--------------------------------------------------------------------------- |
37 | %{ | |
38 | // Put some wx default wxChar* values into wxStrings. | |
39 | static const wxString wxPyEmptyString(wxT("")); | |
40 | %} | |
b1462dfa RD |
41 | //---------------------------------------------------------------------- |
42 | ||
43 | ||
44 | enum wxDataFormatId | |
45 | { | |
d394edca RD |
46 | wxDF_INVALID, |
47 | wxDF_TEXT, | |
48 | wxDF_BITMAP, | |
49 | wxDF_METAFILE, | |
50 | wxDF_SYLK, | |
51 | wxDF_DIF, | |
52 | wxDF_TIFF, | |
53 | wxDF_OEMTEXT, | |
54 | wxDF_DIB, | |
55 | wxDF_PALETTE, | |
56 | wxDF_PENDATA, | |
57 | wxDF_RIFF, | |
58 | wxDF_WAVE, | |
59 | wxDF_UNICODETEXT, | |
60 | wxDF_ENHMETAFILE, | |
61 | wxDF_FILENAME, | |
62 | wxDF_LOCALE, | |
63 | wxDF_PRIVATE, | |
64 | wxDF_HTML, | |
65 | wxDF_MAX, | |
b1462dfa RD |
66 | }; |
67 | ||
68 | //---------------------------------------------------------------------- | |
69 | ||
70 | class wxDataFormat { | |
71 | public: | |
72 | wxDataFormat( wxDataFormatId type ); | |
73 | ~wxDataFormat(); | |
74 | ||
75 | void SetType(wxDataFormatId format); | |
76 | wxDataFormatId GetType() const; | |
77 | ||
78 | wxString GetId() const; | |
137b5242 | 79 | void SetId(const wxString& format); |
b1462dfa RD |
80 | }; |
81 | ||
82 | %new wxDataFormat* wxCustomDataFormat(const wxString &id); | |
83 | %{ // An alternate constructor... | |
84 | wxDataFormat* wxCustomDataFormat(const wxString &id) { | |
85 | return new wxDataFormat(id); | |
86 | } | |
87 | %} | |
88 | ||
89 | ||
90 | %{ | |
91 | wxDataFormat wxPyFormatInvalid; | |
92 | %} | |
93 | %readonly | |
94 | %name(wxFormatInvalid) wxDataFormat wxPyFormatInvalid; | |
95 | %readwrite | |
96 | ||
97 | ||
98 | //---------------------------------------------------------------------- | |
99 | ||
100 | ||
101 | ||
102 | class wxDataObject { // An abstract base class | |
103 | public: | |
104 | enum Direction { | |
105 | Get = 0x01, // format is supported by GetDataHere() | |
106 | Set = 0x02, // format is supported by SetData() | |
107 | Both = 0x03 // format is supported by both (unused currently) | |
108 | }; | |
109 | ||
110 | ~wxDataObject(); | |
111 | ||
112 | wxDataFormat GetPreferredFormat(Direction dir = wxDataObject::Get); | |
113 | size_t GetFormatCount(Direction dir = wxDataObject::Get); | |
1e4a197e RD |
114 | |
115 | // TODO: Fix these two to be usable from wxPython. | |
b1462dfa RD |
116 | void GetAllFormats(wxDataFormat *formats, |
117 | Direction dir = wxDataObject::Get); | |
b1462dfa | 118 | bool GetDataHere(const wxDataFormat& format, void *buf); |
1e4a197e RD |
119 | |
120 | size_t GetDataSize(const wxDataFormat& format); | |
b1462dfa RD |
121 | bool SetData(const wxDataFormat& format, |
122 | size_t len, const void * buf); | |
123 | bool IsSupportedFormat(const wxDataFormat& format); | |
124 | }; | |
125 | ||
126 | //---------------------------------------------------------------------- | |
127 | ||
128 | class wxDataObjectSimple : public wxDataObject { | |
129 | public: | |
130 | wxDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid); | |
131 | ||
132 | const wxDataFormat& GetFormat(); | |
133 | void SetFormat(const wxDataFormat& format); | |
134 | ||
135 | }; | |
136 | ||
137 | ||
138 | %{ // Create a new class for wxPython to use | |
139 | class wxPyDataObjectSimple : public wxDataObjectSimple { | |
140 | public: | |
141 | wxPyDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid) | |
142 | : wxDataObjectSimple(format) {} | |
143 | ||
144 | DEC_PYCALLBACK_SIZET_(GetDataSize); | |
145 | bool GetDataHere(void *buf); | |
146 | bool SetData(size_t len, const void *buf); | |
147 | PYPRIVATE; | |
148 | }; | |
149 | ||
150 | IMP_PYCALLBACK_SIZET_(wxPyDataObjectSimple, wxDataObjectSimple, GetDataSize); | |
151 | ||
152 | bool wxPyDataObjectSimple::GetDataHere(void *buf) { | |
153 | // We need to get the data for this object and write it to buf. I think | |
154 | // the best way to do this for wxPython is to have the Python method | |
155 | // return either a string or None and then act appropriately with the | |
156 | // C++ version. | |
157 | ||
158 | bool rval = FALSE; | |
4268f798 | 159 | wxPyBeginBlockThreads(); |
b1462dfa RD |
160 | if (m_myInst.findCallback("GetDataHere")) { |
161 | PyObject* ro; | |
162 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); | |
f6bcfd97 BP |
163 | if (ro) { |
164 | rval = (ro != Py_None && PyString_Check(ro)); | |
165 | if (rval) | |
166 | memcpy(buf, PyString_AsString(ro), PyString_Size(ro)); | |
167 | Py_DECREF(ro); | |
168 | } | |
b1462dfa | 169 | } |
4268f798 | 170 | wxPyEndBlockThreads(); |
b1462dfa RD |
171 | return rval; |
172 | } | |
173 | ||
174 | bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) { | |
175 | // For this one we simply need to make a string from buf and len | |
176 | // and send it to the Python method. | |
177 | bool rval = FALSE; | |
4268f798 | 178 | wxPyBeginBlockThreads(); |
b1462dfa RD |
179 | if (m_myInst.findCallback("SetData")) { |
180 | PyObject* data = PyString_FromStringAndSize((char*)buf, len); | |
181 | rval = m_myInst.callCallback(Py_BuildValue("(O)", data)); | |
182 | Py_DECREF(data); | |
183 | } | |
4268f798 | 184 | wxPyEndBlockThreads(); |
b1462dfa RD |
185 | return rval; |
186 | } | |
187 | %} | |
188 | ||
189 | ||
190 | ||
191 | // Now define it for SWIG | |
192 | class wxPyDataObjectSimple : public wxDataObjectSimple { | |
193 | public: | |
194 | wxPyDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid); | |
0122b7e3 RD |
195 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
196 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDataObjectSimple)" | |
b1462dfa RD |
197 | }; |
198 | ||
199 | //---------------------------------------------------------------------- | |
200 | ||
201 | class wxDataObjectComposite : public wxDataObject { | |
202 | public: | |
203 | wxDataObjectComposite(); | |
204 | ||
205 | void Add(wxDataObjectSimple *dataObject, int preferred = FALSE); | |
206 | %pragma(python) addtomethod = "Add:_args[0].thisown = 0" | |
207 | ||
208 | }; | |
209 | ||
210 | ||
211 | //---------------------------------------------------------------------- | |
212 | ||
213 | class wxTextDataObject : public wxDataObjectSimple { | |
214 | public: | |
137b5242 | 215 | wxTextDataObject(const wxString& text = wxPyEmptyString); |
b1462dfa RD |
216 | |
217 | size_t GetTextLength(); | |
218 | wxString GetText(); | |
219 | void SetText(const wxString& text); | |
220 | }; | |
221 | ||
222 | ||
223 | ||
224 | %{ // Create a new class for wxPython to use | |
225 | class wxPyTextDataObject : public wxTextDataObject { | |
226 | public: | |
137b5242 | 227 | wxPyTextDataObject(const wxString& text = wxPyEmptyString) |
b1462dfa RD |
228 | : wxTextDataObject(text) {} |
229 | ||
230 | DEC_PYCALLBACK_SIZET_(GetTextLength); | |
231 | DEC_PYCALLBACK_STRING_(GetText); | |
232 | DEC_PYCALLBACK__STRING(SetText); | |
233 | PYPRIVATE; | |
234 | }; | |
235 | ||
236 | IMP_PYCALLBACK_SIZET_(wxPyTextDataObject, wxTextDataObject, GetTextLength); | |
237 | IMP_PYCALLBACK_STRING_(wxPyTextDataObject, wxTextDataObject, GetText); | |
238 | IMP_PYCALLBACK__STRING(wxPyTextDataObject, wxTextDataObject, SetText); | |
239 | ||
240 | %} | |
241 | ||
242 | ||
243 | // Now define it for SWIG | |
244 | class wxPyTextDataObject : public wxTextDataObject { | |
245 | public: | |
137b5242 | 246 | wxPyTextDataObject(const wxString& text = wxPyEmptyString); |
0122b7e3 RD |
247 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
248 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTextDataObject)" | |
b1462dfa RD |
249 | }; |
250 | ||
251 | //---------------------------------------------------------------------- | |
252 | ||
253 | class wxBitmapDataObject : public wxDataObjectSimple { | |
254 | public: | |
255 | wxBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap); | |
256 | ||
257 | wxBitmap GetBitmap(); | |
258 | void SetBitmap(const wxBitmap& bitmap); | |
259 | }; | |
260 | ||
261 | ||
262 | ||
263 | %{ // Create a new class for wxPython to use | |
264 | class wxPyBitmapDataObject : public wxBitmapDataObject { | |
265 | public: | |
266 | wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap) | |
267 | : wxBitmapDataObject(bitmap) {} | |
268 | ||
269 | wxBitmap GetBitmap(); | |
270 | void SetBitmap(const wxBitmap& bitmap); | |
271 | PYPRIVATE; | |
272 | }; | |
273 | ||
274 | wxBitmap wxPyBitmapDataObject::GetBitmap() { | |
275 | wxBitmap* rval = &wxNullBitmap; | |
4268f798 | 276 | wxPyBeginBlockThreads(); |
b1462dfa RD |
277 | if (m_myInst.findCallback("GetBitmap")) { |
278 | PyObject* ro; | |
279 | wxBitmap* ptr; | |
280 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); | |
f6bcfd97 BP |
281 | if (ro) { |
282 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) | |
283 | rval = ptr; | |
284 | Py_DECREF(ro); | |
285 | } | |
b1462dfa | 286 | } |
4268f798 | 287 | wxPyEndBlockThreads(); |
b1462dfa RD |
288 | return *rval; |
289 | } | |
290 | ||
291 | void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { | |
4268f798 | 292 | wxPyBeginBlockThreads(); |
b1462dfa | 293 | if (m_myInst.findCallback("SetBitmap")) { |
1e4a197e | 294 | PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap")); |
a66212dc RD |
295 | m_myInst.callCallback(Py_BuildValue("(O)", bo)); |
296 | Py_DECREF(bo); | |
b1462dfa | 297 | } |
4268f798 | 298 | wxPyEndBlockThreads(); |
b1462dfa RD |
299 | } |
300 | %} | |
301 | ||
302 | ||
303 | ||
304 | // Now define it for SWIG | |
305 | class wxPyBitmapDataObject : public wxBitmapDataObject { | |
306 | public: | |
307 | wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap); | |
0122b7e3 RD |
308 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
309 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyBitmapDataObject)" | |
b1462dfa RD |
310 | }; |
311 | ||
312 | ||
313 | //---------------------------------------------------------------------- | |
314 | ||
315 | class wxFileDataObject : public wxDataObjectSimple | |
316 | { | |
317 | public: | |
318 | wxFileDataObject(); | |
319 | ||
320 | //const wxArrayString& GetFilenames(); | |
321 | %addmethods { | |
322 | PyObject* GetFilenames() { | |
323 | const wxArrayString& strings = self->GetFilenames(); | |
b37c7e1d | 324 | return wxArrayString2PyList_helper(strings); |
b1462dfa RD |
325 | } |
326 | } | |
3ca6a5f0 BP |
327 | #ifdef __WXMSW__ |
328 | void AddFile(const wxString &filename); | |
329 | #endif | |
b1462dfa RD |
330 | }; |
331 | ||
332 | ||
333 | //---------------------------------------------------------------------- | |
334 | ||
335 | class wxCustomDataObject : public wxDataObjectSimple { | |
336 | public: | |
337 | wxCustomDataObject(const wxDataFormat& format = wxPyFormatInvalid); | |
338 | ||
339 | //void TakeData(size_t size, void *data); | |
340 | //bool SetData(size_t size, const void *buf); | |
341 | %addmethods { | |
342 | void TakeData(PyObject* data) { | |
343 | if (PyString_Check(data)) { | |
344 | self->SetData(PyString_Size(data), PyString_AsString(data)); | |
345 | } | |
346 | } | |
347 | bool SetData(PyObject* data) { | |
348 | if (PyString_Check(data)) { | |
349 | return self->SetData(PyString_Size(data), PyString_AsString(data)); | |
350 | } | |
351 | return FALSE; | |
352 | } | |
353 | } | |
354 | ||
355 | size_t GetSize(); | |
c368d904 | 356 | |
b1462dfa RD |
357 | //void *GetData(); |
358 | %addmethods { | |
359 | PyObject* GetData() { | |
360 | return PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); | |
361 | } | |
362 | } | |
363 | ||
364 | ||
365 | }; | |
366 | ||
367 | ||
c9a1416a RD |
368 | //---------------------------------------------------------------------- |
369 | ||
370 | class wxURLDataObject : public wxDataObjectComposite { | |
371 | public: | |
372 | wxURLDataObject(); | |
373 | ||
374 | wxString GetURL(); | |
375 | void SetURL(const wxString& url); | |
376 | }; | |
b1462dfa | 377 | |
f54a35fe RD |
378 | //---------------------------------------------------------------------- |
379 | ||
380 | #ifndef __WXGTK__ | |
381 | ||
382 | %{ | |
383 | #include <wx/metafile.h> | |
384 | %} | |
385 | ||
386 | class wxMetafileDataObject : public wxDataObjectSimple | |
387 | { | |
388 | public: | |
389 | wxMetafileDataObject(); | |
390 | ||
391 | void SetMetafile(const wxMetafile& metafile); | |
392 | wxMetafile GetMetafile() const; | |
393 | }; | |
394 | ||
395 | #endif | |
396 | ||
b1462dfa RD |
397 | //---------------------------------------------------------------------- |
398 | //---------------------------------------------------------------------- | |
399 | //---------------------------------------------------------------------- | |
400 | ||
9416aa89 | 401 | class wxClipboard : public wxObject { |
b1462dfa RD |
402 | public: |
403 | wxClipboard(); | |
404 | ||
405 | bool Open(); | |
406 | void Close(); | |
407 | bool IsOpened() const; | |
408 | ||
409 | bool AddData( wxDataObject *data ); | |
410 | %pragma(python) addtomethod = "AddData:_args[0].thisown = 0" | |
411 | bool SetData( wxDataObject *data ); | |
412 | %pragma(python) addtomethod = "SetData:_args[0].thisown = 0" | |
413 | ||
414 | bool IsSupported( const wxDataFormat& format ); | |
415 | bool GetData( wxDataObject& data ); | |
416 | void Clear(); | |
417 | bool Flush(); | |
418 | void UsePrimarySelection( int primary = FALSE ); | |
419 | }; | |
420 | ||
dd116e73 | 421 | |
b1462dfa | 422 | %readonly |
18d95cf0 RD |
423 | %{ |
424 | #if 0 | |
425 | %} | |
dd116e73 RD |
426 | // See also wxPy_ReinitStockObjects in helpers.cpp |
427 | extern wxClipboard* wxTheClipboard; | |
18d95cf0 RD |
428 | %{ |
429 | #endif | |
430 | %} | |
b1462dfa RD |
431 | %readwrite |
432 | ||
433 | //---------------------------------------------------------------------- | |
434 | //---------------------------------------------------------------------- | |
435 | ||
3bd1e033 RD |
436 | // flags for wxDropSource::DoDragDrop() |
437 | // | |
438 | enum | |
439 | { | |
440 | wxDrag_CopyOnly = 0, // allow only copying | |
441 | wxDrag_AllowMove = 1, // allow moving (copying is always allowed) | |
442 | wxDrag_DefaultMove = 3 // the default operation is move, not copy | |
443 | }; | |
444 | ||
b1462dfa RD |
445 | enum wxDragResult |
446 | { | |
447 | wxDragError, // error prevented the d&d operation from completing | |
448 | wxDragNone, // drag target didn't accept the data | |
449 | wxDragCopy, // the data was successfully copied | |
450 | wxDragMove, // the data was successfully moved (MSW only) | |
c9a1416a | 451 | wxDragLink, // operation is a drag-link |
b1462dfa RD |
452 | wxDragCancel // the operation was cancelled by user (not an error) |
453 | }; | |
454 | ||
455 | bool wxIsDragResultOk(wxDragResult res); | |
456 | ||
457 | //---------------------------------------------------------------------- | |
458 | %{ | |
459 | class wxPyDropSource : public wxDropSource { | |
460 | public: | |
e0fb15a1 | 461 | #ifndef __WXGTK__ |
1e4a197e RD |
462 | wxPyDropSource(wxWindow *win = NULL, |
463 | const wxCursor © = wxNullCursor, | |
464 | const wxCursor &move = wxNullCursor, | |
465 | const wxCursor &none = wxNullCursor) | |
466 | : wxDropSource(win, copy, move, none) {} | |
4120ef2b RD |
467 | #else |
468 | wxPyDropSource(wxWindow *win = NULL, | |
1e4a197e RD |
469 | const wxIcon& copy = wxNullIcon, |
470 | const wxIcon& move = wxNullIcon, | |
471 | const wxIcon& none = wxNullIcon) | |
472 | : wxDropSource(win, copy, move, none) {} | |
4120ef2b | 473 | #endif |
077def0b | 474 | ~wxPyDropSource() { } |
dafb483b | 475 | |
b1462dfa RD |
476 | DEC_PYCALLBACK_BOOL_DR(GiveFeedback); |
477 | PYPRIVATE; | |
478 | }; | |
479 | ||
480 | IMP_PYCALLBACK_BOOL_DR(wxPyDropSource, wxDropSource, GiveFeedback); | |
481 | ||
482 | %} | |
483 | ||
484 | ||
485 | %name(wxDropSource) class wxPyDropSource { | |
486 | public: | |
e0fb15a1 | 487 | #ifndef __WXGTK__ |
1e4a197e RD |
488 | wxPyDropSource(wxWindow *win = NULL, |
489 | const wxCursor © = wxNullCursor, | |
490 | const wxCursor &move = wxNullCursor, | |
491 | const wxCursor &none = wxNullCursor); | |
4120ef2b RD |
492 | #else |
493 | wxPyDropSource(wxWindow *win = NULL, | |
1e4a197e RD |
494 | const wxIcon& copy = wxNullIcon, |
495 | const wxIcon& move = wxNullIcon, | |
496 | const wxIcon& none = wxNullIcon); | |
4120ef2b RD |
497 | #endif |
498 | ||
0122b7e3 RD |
499 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref); |
500 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxDropSource, 0)" | |
b1462dfa RD |
501 | ~wxPyDropSource(); |
502 | ||
503 | void SetData(wxDataObject& data); | |
504 | wxDataObject *GetDataObject(); | |
505 | void SetCursor(wxDragResult res, const wxCursor& cursor); | |
3bd1e033 | 506 | wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); |
b1462dfa RD |
507 | |
508 | bool base_GiveFeedback(wxDragResult effect); | |
509 | }; | |
510 | ||
511 | //---------------------------------------------------------------------- | |
512 | ||
513 | // Just a place holder for the type system. The real base class for | |
514 | // wxPython is wxPyDropTarget | |
515 | class wxDropTarget { | |
516 | public: | |
517 | }; | |
518 | ||
519 | ||
520 | %{ | |
521 | class wxPyDropTarget : public wxDropTarget { | |
522 | public: | |
523 | wxPyDropTarget(wxDataObject *dataObject = NULL) | |
524 | : wxDropTarget(dataObject) {} | |
525 | ||
526 | // DEC_PYCALLBACK_SIZET_(GetFormatCount); | |
527 | // DEC_PYCALLBACK_DATAFMT_SIZET(GetFormat); | |
528 | ||
529 | DEC_PYCALLBACK__(OnLeave); | |
530 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
531 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
532 | DEC_PYCALLBACK_DR_2WXCDR_pure(OnData); | |
533 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
534 | ||
535 | PYPRIVATE; | |
536 | }; | |
537 | ||
538 | // IMP_PYCALLBACK_SIZET_(wxPyDropTarget, wxDropTarget, GetFormatCount); | |
539 | // IMP__PYCALLBACK_DATAFMT_SIZET(wxPyDropTarget, wxDropTarget, GetFormat); | |
540 | ||
541 | IMP_PYCALLBACK__(wxPyDropTarget, wxDropTarget, OnLeave); | |
542 | IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnEnter); | |
543 | IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnDragOver); | |
544 | IMP_PYCALLBACK_DR_2WXCDR_pure(wxPyDropTarget, wxDropTarget, OnData); | |
545 | IMP_PYCALLBACK_BOOL_INTINT(wxPyDropTarget, wxDropTarget, OnDrop); | |
546 | ||
547 | %} | |
548 | ||
549 | ||
550 | class wxPyDropTarget : public wxDropTarget { | |
551 | public: | |
552 | wxPyDropTarget(wxDataObject *dataObject = NULL); | |
553 | %pragma(python) addtomethod = "__init__:if _args:_args[0].thisown = 0" | |
0122b7e3 RD |
554 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
555 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDropTarget)" | |
b1462dfa RD |
556 | |
557 | ~wxPyDropTarget(); | |
558 | ||
559 | wxDataObject *GetDataObject(); | |
560 | void SetDataObject(wxDataObject *dataObject); | |
561 | %pragma(python) addtomethod = "SetDataObject:if _args:_args[0].thisown = 0" | |
562 | ||
563 | // size_t base_GetFormatCount(); | |
564 | // wxDataFormat base_GetFormat(size_t n); | |
565 | ||
566 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
567 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
568 | void base_OnLeave(); | |
569 | bool base_OnDrop(wxCoord x, wxCoord y); | |
570 | //wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0; | |
571 | ||
572 | // **** not sure about this one | |
573 | bool GetData(); | |
574 | ||
575 | }; | |
576 | ||
577 | ||
578 | //---------------------------------------------------------------------- | |
579 | ||
580 | %{ | |
581 | class wxPyTextDropTarget : public wxTextDropTarget { | |
582 | public: | |
583 | wxPyTextDropTarget() {} | |
584 | ||
585 | DEC_PYCALLBACK_BOOL_INTINTSTR_pure(OnDropText); | |
586 | ||
587 | DEC_PYCALLBACK__(OnLeave); | |
588 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
589 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
590 | DEC_PYCALLBACK_DR_2WXCDR(OnData); | |
591 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
592 | ||
593 | PYPRIVATE; | |
594 | }; | |
595 | ||
596 | IMP_PYCALLBACK_BOOL_INTINTSTR_pure(wxPyTextDropTarget, wxTextDropTarget, OnDropText); | |
597 | IMP_PYCALLBACK__(wxPyTextDropTarget, wxTextDropTarget, OnLeave); | |
598 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnEnter); | |
599 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnDragOver); | |
600 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnData); | |
601 | IMP_PYCALLBACK_BOOL_INTINT(wxPyTextDropTarget, wxTextDropTarget, OnDrop); | |
602 | ||
603 | %} | |
604 | ||
605 | %name(wxTextDropTarget) class wxPyTextDropTarget : public wxPyDropTarget { | |
606 | public: | |
607 | wxPyTextDropTarget(); | |
0122b7e3 RD |
608 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
609 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTextDropTarget)" | |
b1462dfa RD |
610 | |
611 | //bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0; | |
612 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
613 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
614 | void base_OnLeave(); | |
615 | bool base_OnDrop(wxCoord x, wxCoord y); | |
616 | wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); | |
617 | }; | |
618 | ||
619 | //---------------------------------------------------------------------- | |
620 | %{ | |
621 | class wxPyFileDropTarget : public wxFileDropTarget { | |
622 | public: | |
623 | wxPyFileDropTarget() {} | |
624 | ||
625 | virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames); | |
626 | ||
627 | DEC_PYCALLBACK__(OnLeave); | |
628 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
629 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
630 | DEC_PYCALLBACK_DR_2WXCDR(OnData); | |
631 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
632 | ||
633 | PYPRIVATE; | |
634 | }; | |
635 | ||
636 | bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, | |
637 | const wxArrayString& filenames) { | |
638 | bool rval = FALSE; | |
4268f798 | 639 | wxPyBeginBlockThreads(); |
a66212dc RD |
640 | if (m_myInst.findCallback("OnDropFiles")) { |
641 | PyObject* list = wxArrayString2PyList_helper(filenames); | |
b1462dfa | 642 | rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list)); |
a66212dc RD |
643 | Py_DECREF(list); |
644 | } | |
4268f798 | 645 | wxPyEndBlockThreads(); |
b1462dfa RD |
646 | return rval; |
647 | } | |
648 | ||
649 | ||
650 | ||
651 | IMP_PYCALLBACK__(wxPyFileDropTarget, wxFileDropTarget, OnLeave); | |
652 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnEnter); | |
653 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnDragOver); | |
654 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnData); | |
655 | IMP_PYCALLBACK_BOOL_INTINT(wxPyFileDropTarget, wxFileDropTarget, OnDrop); | |
656 | ||
657 | %} | |
658 | ||
659 | ||
660 | %name(wxFileDropTarget) class wxPyFileDropTarget : public wxPyDropTarget | |
661 | { | |
662 | public: | |
663 | wxPyFileDropTarget(); | |
0122b7e3 RD |
664 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
665 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFileDropTarget)" | |
b1462dfa RD |
666 | |
667 | // bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) = 0; | |
668 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
669 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
670 | void base_OnLeave(); | |
671 | bool base_OnDrop(wxCoord x, wxCoord y); | |
672 | wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); | |
673 | }; | |
674 | ||
675 | //---------------------------------------------------------------------- | |
676 | //---------------------------------------------------------------------- | |
677 | //---------------------------------------------------------------------- | |
678 | ||
679 | %init %{ | |
680 | ||
9416aa89 RD |
681 | wxPyPtrTypeMap_Add("wxDropSource", "wxPyDropSource"); |
682 | wxPyPtrTypeMap_Add("wxTextDropTarget", "wxPyTextDropTarget"); | |
683 | wxPyPtrTypeMap_Add("wxFileDropTarget", "wxPyFileDropTarget"); | |
b1462dfa RD |
684 | %} |
685 | ||
686 | //---------------------------------------------------------------------- | |
d18c7c6d | 687 | |
b1462dfa | 688 |