]>
Commit | Line | Data |
---|---|---|
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 | ||
36 | //--------------------------------------------------------------------------- | |
37 | %{ | |
38 | // Put some wx default wxChar* values into wxStrings. | |
39 | static const wxString wxPyEmptyString(wxT("")); | |
40 | %} | |
41 | //---------------------------------------------------------------------- | |
42 | ||
43 | ||
44 | enum wxDataFormatId | |
45 | { | |
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, | |
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; | |
79 | void SetId(const wxString& format); | |
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); | |
114 | void GetAllFormats(wxDataFormat *formats, | |
115 | Direction dir = wxDataObject::Get); | |
116 | size_t GetDataSize(const wxDataFormat& format); | |
117 | bool GetDataHere(const wxDataFormat& format, void *buf); | |
118 | bool SetData(const wxDataFormat& format, | |
119 | size_t len, const void * buf); | |
120 | bool IsSupportedFormat(const wxDataFormat& format); | |
121 | }; | |
122 | ||
123 | //---------------------------------------------------------------------- | |
124 | ||
125 | class wxDataObjectSimple : public wxDataObject { | |
126 | public: | |
127 | wxDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid); | |
128 | ||
129 | const wxDataFormat& GetFormat(); | |
130 | void SetFormat(const wxDataFormat& format); | |
131 | ||
132 | }; | |
133 | ||
134 | ||
135 | %{ // Create a new class for wxPython to use | |
136 | class wxPyDataObjectSimple : public wxDataObjectSimple { | |
137 | public: | |
138 | wxPyDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid) | |
139 | : wxDataObjectSimple(format) {} | |
140 | ||
141 | DEC_PYCALLBACK_SIZET_(GetDataSize); | |
142 | bool GetDataHere(void *buf); | |
143 | bool SetData(size_t len, const void *buf); | |
144 | PYPRIVATE; | |
145 | }; | |
146 | ||
147 | IMP_PYCALLBACK_SIZET_(wxPyDataObjectSimple, wxDataObjectSimple, GetDataSize); | |
148 | ||
149 | bool wxPyDataObjectSimple::GetDataHere(void *buf) { | |
150 | // We need to get the data for this object and write it to buf. I think | |
151 | // the best way to do this for wxPython is to have the Python method | |
152 | // return either a string or None and then act appropriately with the | |
153 | // C++ version. | |
154 | ||
155 | bool rval = FALSE; | |
156 | wxPyBeginBlockThreads(); | |
157 | if (m_myInst.findCallback("GetDataHere")) { | |
158 | PyObject* ro; | |
159 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); | |
160 | if (ro) { | |
161 | rval = (ro != Py_None && PyString_Check(ro)); | |
162 | if (rval) | |
163 | memcpy(buf, PyString_AsString(ro), PyString_Size(ro)); | |
164 | Py_DECREF(ro); | |
165 | } | |
166 | } | |
167 | wxPyEndBlockThreads(); | |
168 | return rval; | |
169 | } | |
170 | ||
171 | bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) { | |
172 | // For this one we simply need to make a string from buf and len | |
173 | // and send it to the Python method. | |
174 | bool rval = FALSE; | |
175 | wxPyBeginBlockThreads(); | |
176 | if (m_myInst.findCallback("SetData")) { | |
177 | PyObject* data = PyString_FromStringAndSize((char*)buf, len); | |
178 | rval = m_myInst.callCallback(Py_BuildValue("(O)", data)); | |
179 | Py_DECREF(data); | |
180 | } | |
181 | wxPyEndBlockThreads(); | |
182 | return rval; | |
183 | } | |
184 | %} | |
185 | ||
186 | ||
187 | ||
188 | // Now define it for SWIG | |
189 | class wxPyDataObjectSimple : public wxDataObjectSimple { | |
190 | public: | |
191 | wxPyDataObjectSimple(const wxDataFormat& format = wxPyFormatInvalid); | |
192 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
193 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDataObjectSimple)" | |
194 | }; | |
195 | ||
196 | //---------------------------------------------------------------------- | |
197 | ||
198 | class wxDataObjectComposite : public wxDataObject { | |
199 | public: | |
200 | wxDataObjectComposite(); | |
201 | ||
202 | void Add(wxDataObjectSimple *dataObject, int preferred = FALSE); | |
203 | %pragma(python) addtomethod = "Add:_args[0].thisown = 0" | |
204 | ||
205 | }; | |
206 | ||
207 | ||
208 | //---------------------------------------------------------------------- | |
209 | ||
210 | class wxTextDataObject : public wxDataObjectSimple { | |
211 | public: | |
212 | wxTextDataObject(const wxString& text = wxPyEmptyString); | |
213 | ||
214 | size_t GetTextLength(); | |
215 | wxString GetText(); | |
216 | void SetText(const wxString& text); | |
217 | }; | |
218 | ||
219 | ||
220 | ||
221 | %{ // Create a new class for wxPython to use | |
222 | class wxPyTextDataObject : public wxTextDataObject { | |
223 | public: | |
224 | wxPyTextDataObject(const wxString& text = wxPyEmptyString) | |
225 | : wxTextDataObject(text) {} | |
226 | ||
227 | DEC_PYCALLBACK_SIZET_(GetTextLength); | |
228 | DEC_PYCALLBACK_STRING_(GetText); | |
229 | DEC_PYCALLBACK__STRING(SetText); | |
230 | PYPRIVATE; | |
231 | }; | |
232 | ||
233 | IMP_PYCALLBACK_SIZET_(wxPyTextDataObject, wxTextDataObject, GetTextLength); | |
234 | IMP_PYCALLBACK_STRING_(wxPyTextDataObject, wxTextDataObject, GetText); | |
235 | IMP_PYCALLBACK__STRING(wxPyTextDataObject, wxTextDataObject, SetText); | |
236 | ||
237 | %} | |
238 | ||
239 | ||
240 | // Now define it for SWIG | |
241 | class wxPyTextDataObject : public wxTextDataObject { | |
242 | public: | |
243 | wxPyTextDataObject(const wxString& text = wxPyEmptyString); | |
244 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
245 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTextDataObject)" | |
246 | }; | |
247 | ||
248 | //---------------------------------------------------------------------- | |
249 | ||
250 | class wxBitmapDataObject : public wxDataObjectSimple { | |
251 | public: | |
252 | wxBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap); | |
253 | ||
254 | wxBitmap GetBitmap(); | |
255 | void SetBitmap(const wxBitmap& bitmap); | |
256 | }; | |
257 | ||
258 | ||
259 | ||
260 | %{ // Create a new class for wxPython to use | |
261 | class wxPyBitmapDataObject : public wxBitmapDataObject { | |
262 | public: | |
263 | wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap) | |
264 | : wxBitmapDataObject(bitmap) {} | |
265 | ||
266 | wxBitmap GetBitmap(); | |
267 | void SetBitmap(const wxBitmap& bitmap); | |
268 | PYPRIVATE; | |
269 | }; | |
270 | ||
271 | wxBitmap wxPyBitmapDataObject::GetBitmap() { | |
272 | wxBitmap* rval = &wxNullBitmap; | |
273 | wxPyBeginBlockThreads(); | |
274 | if (m_myInst.findCallback("GetBitmap")) { | |
275 | PyObject* ro; | |
276 | wxBitmap* ptr; | |
277 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); | |
278 | if (ro) { | |
279 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) | |
280 | rval = ptr; | |
281 | Py_DECREF(ro); | |
282 | } | |
283 | } | |
284 | wxPyEndBlockThreads(); | |
285 | return *rval; | |
286 | } | |
287 | ||
288 | void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { | |
289 | wxPyBeginBlockThreads(); | |
290 | if (m_myInst.findCallback("SetBitmap")) { | |
291 | PyObject* bo = wxPyConstructObject((void*)&bitmap, "wxBitmap"); | |
292 | m_myInst.callCallback(Py_BuildValue("(O)", bo)); | |
293 | Py_DECREF(bo); | |
294 | } | |
295 | wxPyEndBlockThreads(); | |
296 | } | |
297 | %} | |
298 | ||
299 | ||
300 | ||
301 | // Now define it for SWIG | |
302 | class wxPyBitmapDataObject : public wxBitmapDataObject { | |
303 | public: | |
304 | wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap); | |
305 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
306 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyBitmapDataObject)" | |
307 | }; | |
308 | ||
309 | ||
310 | //---------------------------------------------------------------------- | |
311 | ||
312 | class wxFileDataObject : public wxDataObjectSimple | |
313 | { | |
314 | public: | |
315 | wxFileDataObject(); | |
316 | ||
317 | //const wxArrayString& GetFilenames(); | |
318 | %addmethods { | |
319 | PyObject* GetFilenames() { | |
320 | const wxArrayString& strings = self->GetFilenames(); | |
321 | return wxArrayString2PyList_helper(strings); | |
322 | } | |
323 | } | |
324 | #ifdef __WXMSW__ | |
325 | void AddFile(const wxString &filename); | |
326 | #endif | |
327 | }; | |
328 | ||
329 | ||
330 | //---------------------------------------------------------------------- | |
331 | ||
332 | class wxCustomDataObject : public wxDataObjectSimple { | |
333 | public: | |
334 | wxCustomDataObject(const wxDataFormat& format = wxPyFormatInvalid); | |
335 | ||
336 | //void TakeData(size_t size, void *data); | |
337 | //bool SetData(size_t size, const void *buf); | |
338 | %addmethods { | |
339 | void TakeData(PyObject* data) { | |
340 | if (PyString_Check(data)) { | |
341 | self->SetData(PyString_Size(data), PyString_AsString(data)); | |
342 | } | |
343 | } | |
344 | bool SetData(PyObject* data) { | |
345 | if (PyString_Check(data)) { | |
346 | return self->SetData(PyString_Size(data), PyString_AsString(data)); | |
347 | } | |
348 | return FALSE; | |
349 | } | |
350 | } | |
351 | ||
352 | size_t GetSize(); | |
353 | ||
354 | //void *GetData(); | |
355 | %addmethods { | |
356 | PyObject* GetData() { | |
357 | return PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); | |
358 | } | |
359 | } | |
360 | ||
361 | ||
362 | }; | |
363 | ||
364 | ||
365 | //---------------------------------------------------------------------- | |
366 | ||
367 | class wxURLDataObject : public wxDataObjectComposite { | |
368 | public: | |
369 | wxURLDataObject(); | |
370 | ||
371 | wxString GetURL(); | |
372 | void SetURL(const wxString& url); | |
373 | }; | |
374 | ||
375 | //---------------------------------------------------------------------- | |
376 | ||
377 | #ifndef __WXGTK__ | |
378 | ||
379 | %{ | |
380 | #include <wx/metafile.h> | |
381 | %} | |
382 | ||
383 | class wxMetafileDataObject : public wxDataObjectSimple | |
384 | { | |
385 | public: | |
386 | wxMetafileDataObject(); | |
387 | ||
388 | void SetMetafile(const wxMetafile& metafile); | |
389 | wxMetafile GetMetafile() const; | |
390 | }; | |
391 | ||
392 | #endif | |
393 | ||
394 | //---------------------------------------------------------------------- | |
395 | //---------------------------------------------------------------------- | |
396 | //---------------------------------------------------------------------- | |
397 | ||
398 | class wxClipboard : public wxObject { | |
399 | public: | |
400 | wxClipboard(); | |
401 | ||
402 | bool Open(); | |
403 | void Close(); | |
404 | bool IsOpened() const; | |
405 | ||
406 | bool AddData( wxDataObject *data ); | |
407 | %pragma(python) addtomethod = "AddData:_args[0].thisown = 0" | |
408 | bool SetData( wxDataObject *data ); | |
409 | %pragma(python) addtomethod = "SetData:_args[0].thisown = 0" | |
410 | ||
411 | bool IsSupported( const wxDataFormat& format ); | |
412 | bool GetData( wxDataObject& data ); | |
413 | void Clear(); | |
414 | bool Flush(); | |
415 | void UsePrimarySelection( int primary = FALSE ); | |
416 | }; | |
417 | ||
418 | %{ | |
419 | // See below in the init function... | |
420 | wxClipboard* wxPyTheClipboard; | |
421 | %} | |
422 | %readonly | |
423 | %name(wxTheClipboard) wxClipboard* wxPyTheClipboard; | |
424 | %readwrite | |
425 | ||
426 | //---------------------------------------------------------------------- | |
427 | //---------------------------------------------------------------------- | |
428 | ||
429 | // flags for wxDropSource::DoDragDrop() | |
430 | // | |
431 | enum | |
432 | { | |
433 | wxDrag_CopyOnly = 0, // allow only copying | |
434 | wxDrag_AllowMove = 1, // allow moving (copying is always allowed) | |
435 | wxDrag_DefaultMove = 3 // the default operation is move, not copy | |
436 | }; | |
437 | ||
438 | enum wxDragResult | |
439 | { | |
440 | wxDragError, // error prevented the d&d operation from completing | |
441 | wxDragNone, // drag target didn't accept the data | |
442 | wxDragCopy, // the data was successfully copied | |
443 | wxDragMove, // the data was successfully moved (MSW only) | |
444 | wxDragLink, // operation is a drag-link | |
445 | wxDragCancel // the operation was cancelled by user (not an error) | |
446 | }; | |
447 | ||
448 | bool wxIsDragResultOk(wxDragResult res); | |
449 | ||
450 | //---------------------------------------------------------------------- | |
451 | %{ | |
452 | class wxPyDropSource : public wxDropSource { | |
453 | public: | |
454 | #ifdef __WXMSW__ | |
455 | wxPyDropSource(wxWindow *win = NULL, | |
456 | const wxCursor &cursorCopy = wxNullCursor, | |
457 | const wxCursor &cursorMove = wxNullCursor, | |
458 | const wxCursor &cursorStop = wxNullCursor) | |
459 | : wxDropSource(win, cursorCopy, cursorMove, cursorStop) {} | |
460 | #else | |
461 | wxPyDropSource(wxWindow *win = NULL, | |
462 | const wxIcon &go = wxNullIcon) | |
463 | : wxDropSource(win, go) {} | |
464 | #endif | |
465 | ~wxPyDropSource() { } | |
466 | ||
467 | DEC_PYCALLBACK_BOOL_DR(GiveFeedback); | |
468 | PYPRIVATE; | |
469 | }; | |
470 | ||
471 | IMP_PYCALLBACK_BOOL_DR(wxPyDropSource, wxDropSource, GiveFeedback); | |
472 | ||
473 | %} | |
474 | ||
475 | ||
476 | %name(wxDropSource) class wxPyDropSource { | |
477 | public: | |
478 | #ifdef __WXMSW__ | |
479 | wxPyDropSource(wxWindow *win = NULL, | |
480 | const wxCursor &cursorCopy = wxNullCursor, | |
481 | const wxCursor &cursorMove = wxNullCursor, | |
482 | const wxCursor &cursorStop = wxNullCursor); | |
483 | #else | |
484 | wxPyDropSource(wxWindow *win = NULL, | |
485 | const wxIcon &go = wxNullIcon); | |
486 | #endif | |
487 | ||
488 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref); | |
489 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxDropSource, 0)" | |
490 | ~wxPyDropSource(); | |
491 | ||
492 | void SetData(wxDataObject& data); | |
493 | wxDataObject *GetDataObject(); | |
494 | void SetCursor(wxDragResult res, const wxCursor& cursor); | |
495 | wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); | |
496 | ||
497 | bool base_GiveFeedback(wxDragResult effect); | |
498 | }; | |
499 | ||
500 | //---------------------------------------------------------------------- | |
501 | ||
502 | // Just a place holder for the type system. The real base class for | |
503 | // wxPython is wxPyDropTarget | |
504 | class wxDropTarget { | |
505 | public: | |
506 | }; | |
507 | ||
508 | ||
509 | %{ | |
510 | class wxPyDropTarget : public wxDropTarget { | |
511 | public: | |
512 | wxPyDropTarget(wxDataObject *dataObject = NULL) | |
513 | : wxDropTarget(dataObject) {} | |
514 | ||
515 | // DEC_PYCALLBACK_SIZET_(GetFormatCount); | |
516 | // DEC_PYCALLBACK_DATAFMT_SIZET(GetFormat); | |
517 | ||
518 | DEC_PYCALLBACK__(OnLeave); | |
519 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
520 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
521 | DEC_PYCALLBACK_DR_2WXCDR_pure(OnData); | |
522 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
523 | ||
524 | PYPRIVATE; | |
525 | }; | |
526 | ||
527 | // IMP_PYCALLBACK_SIZET_(wxPyDropTarget, wxDropTarget, GetFormatCount); | |
528 | // IMP__PYCALLBACK_DATAFMT_SIZET(wxPyDropTarget, wxDropTarget, GetFormat); | |
529 | ||
530 | IMP_PYCALLBACK__(wxPyDropTarget, wxDropTarget, OnLeave); | |
531 | IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnEnter); | |
532 | IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnDragOver); | |
533 | IMP_PYCALLBACK_DR_2WXCDR_pure(wxPyDropTarget, wxDropTarget, OnData); | |
534 | IMP_PYCALLBACK_BOOL_INTINT(wxPyDropTarget, wxDropTarget, OnDrop); | |
535 | ||
536 | %} | |
537 | ||
538 | ||
539 | class wxPyDropTarget : public wxDropTarget { | |
540 | public: | |
541 | wxPyDropTarget(wxDataObject *dataObject = NULL); | |
542 | %pragma(python) addtomethod = "__init__:if _args:_args[0].thisown = 0" | |
543 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
544 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDropTarget)" | |
545 | ||
546 | ~wxPyDropTarget(); | |
547 | ||
548 | wxDataObject *GetDataObject(); | |
549 | void SetDataObject(wxDataObject *dataObject); | |
550 | %pragma(python) addtomethod = "SetDataObject:if _args:_args[0].thisown = 0" | |
551 | ||
552 | // size_t base_GetFormatCount(); | |
553 | // wxDataFormat base_GetFormat(size_t n); | |
554 | ||
555 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
556 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
557 | void base_OnLeave(); | |
558 | bool base_OnDrop(wxCoord x, wxCoord y); | |
559 | //wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0; | |
560 | ||
561 | // **** not sure about this one | |
562 | bool GetData(); | |
563 | ||
564 | }; | |
565 | ||
566 | ||
567 | //---------------------------------------------------------------------- | |
568 | ||
569 | %{ | |
570 | class wxPyTextDropTarget : public wxTextDropTarget { | |
571 | public: | |
572 | wxPyTextDropTarget() {} | |
573 | ||
574 | DEC_PYCALLBACK_BOOL_INTINTSTR_pure(OnDropText); | |
575 | ||
576 | DEC_PYCALLBACK__(OnLeave); | |
577 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
578 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
579 | DEC_PYCALLBACK_DR_2WXCDR(OnData); | |
580 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
581 | ||
582 | PYPRIVATE; | |
583 | }; | |
584 | ||
585 | IMP_PYCALLBACK_BOOL_INTINTSTR_pure(wxPyTextDropTarget, wxTextDropTarget, OnDropText); | |
586 | IMP_PYCALLBACK__(wxPyTextDropTarget, wxTextDropTarget, OnLeave); | |
587 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnEnter); | |
588 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnDragOver); | |
589 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnData); | |
590 | IMP_PYCALLBACK_BOOL_INTINT(wxPyTextDropTarget, wxTextDropTarget, OnDrop); | |
591 | ||
592 | %} | |
593 | ||
594 | %name(wxTextDropTarget) class wxPyTextDropTarget : public wxPyDropTarget { | |
595 | public: | |
596 | wxPyTextDropTarget(); | |
597 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
598 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTextDropTarget)" | |
599 | ||
600 | //bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0; | |
601 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
602 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
603 | void base_OnLeave(); | |
604 | bool base_OnDrop(wxCoord x, wxCoord y); | |
605 | wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); | |
606 | }; | |
607 | ||
608 | //---------------------------------------------------------------------- | |
609 | %{ | |
610 | class wxPyFileDropTarget : public wxFileDropTarget { | |
611 | public: | |
612 | wxPyFileDropTarget() {} | |
613 | ||
614 | virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames); | |
615 | ||
616 | DEC_PYCALLBACK__(OnLeave); | |
617 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
618 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
619 | DEC_PYCALLBACK_DR_2WXCDR(OnData); | |
620 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
621 | ||
622 | PYPRIVATE; | |
623 | }; | |
624 | ||
625 | bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, | |
626 | const wxArrayString& filenames) { | |
627 | bool rval = FALSE; | |
628 | wxPyBeginBlockThreads(); | |
629 | if (m_myInst.findCallback("OnDropFiles")) { | |
630 | PyObject* list = wxArrayString2PyList_helper(filenames); | |
631 | rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list)); | |
632 | Py_DECREF(list); | |
633 | } | |
634 | wxPyEndBlockThreads(); | |
635 | return rval; | |
636 | } | |
637 | ||
638 | ||
639 | ||
640 | IMP_PYCALLBACK__(wxPyFileDropTarget, wxFileDropTarget, OnLeave); | |
641 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnEnter); | |
642 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnDragOver); | |
643 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnData); | |
644 | IMP_PYCALLBACK_BOOL_INTINT(wxPyFileDropTarget, wxFileDropTarget, OnDrop); | |
645 | ||
646 | %} | |
647 | ||
648 | ||
649 | %name(wxFileDropTarget) class wxPyFileDropTarget : public wxPyDropTarget | |
650 | { | |
651 | public: | |
652 | wxPyFileDropTarget(); | |
653 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
654 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFileDropTarget)" | |
655 | ||
656 | // bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) = 0; | |
657 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
658 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
659 | void base_OnLeave(); | |
660 | bool base_OnDrop(wxCoord x, wxCoord y); | |
661 | wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); | |
662 | }; | |
663 | ||
664 | //---------------------------------------------------------------------- | |
665 | //---------------------------------------------------------------------- | |
666 | //---------------------------------------------------------------------- | |
667 | ||
668 | %init %{ | |
669 | ||
670 | wxPyTheClipboard = wxTheClipboard; | |
671 | wxPyPtrTypeMap_Add("wxDropSource", "wxPyDropSource"); | |
672 | wxPyPtrTypeMap_Add("wxTextDropTarget", "wxPyTextDropTarget"); | |
673 | wxPyPtrTypeMap_Add("wxFileDropTarget", "wxPyFileDropTarget"); | |
674 | %} | |
675 | ||
676 | //---------------------------------------------------------------------- | |
677 | ||
678 |