]>
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); | |
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; | |
4268f798 | 156 | wxPyBeginBlockThreads(); |
b1462dfa RD |
157 | if (m_myInst.findCallback("GetDataHere")) { |
158 | PyObject* ro; | |
159 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); | |
f6bcfd97 BP |
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 | } | |
b1462dfa | 166 | } |
4268f798 | 167 | wxPyEndBlockThreads(); |
b1462dfa RD |
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; | |
4268f798 | 175 | wxPyBeginBlockThreads(); |
b1462dfa RD |
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 | } | |
4268f798 | 181 | wxPyEndBlockThreads(); |
b1462dfa RD |
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); | |
0122b7e3 RD |
192 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
193 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDataObjectSimple)" | |
b1462dfa RD |
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: | |
137b5242 | 212 | wxTextDataObject(const wxString& text = wxPyEmptyString); |
b1462dfa RD |
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: | |
137b5242 | 224 | wxPyTextDataObject(const wxString& text = wxPyEmptyString) |
b1462dfa RD |
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: | |
137b5242 | 243 | wxPyTextDataObject(const wxString& text = wxPyEmptyString); |
0122b7e3 RD |
244 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
245 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTextDataObject)" | |
b1462dfa RD |
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; | |
4268f798 | 273 | wxPyBeginBlockThreads(); |
b1462dfa RD |
274 | if (m_myInst.findCallback("GetBitmap")) { |
275 | PyObject* ro; | |
276 | wxBitmap* ptr; | |
277 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); | |
f6bcfd97 BP |
278 | if (ro) { |
279 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) | |
280 | rval = ptr; | |
281 | Py_DECREF(ro); | |
282 | } | |
b1462dfa | 283 | } |
4268f798 | 284 | wxPyEndBlockThreads(); |
b1462dfa RD |
285 | return *rval; |
286 | } | |
287 | ||
288 | void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { | |
4268f798 | 289 | wxPyBeginBlockThreads(); |
b1462dfa RD |
290 | if (m_myInst.findCallback("SetBitmap")) { |
291 | m_myInst.callCallback(Py_BuildValue("(O)", | |
292 | wxPyConstructObject((void*)&bitmap, "wxBitmap"))); | |
293 | } | |
4268f798 | 294 | wxPyEndBlockThreads(); |
b1462dfa RD |
295 | } |
296 | %} | |
297 | ||
298 | ||
299 | ||
300 | // Now define it for SWIG | |
301 | class wxPyBitmapDataObject : public wxBitmapDataObject { | |
302 | public: | |
303 | wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap); | |
0122b7e3 RD |
304 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
305 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyBitmapDataObject)" | |
b1462dfa RD |
306 | }; |
307 | ||
308 | ||
309 | //---------------------------------------------------------------------- | |
310 | ||
311 | class wxFileDataObject : public wxDataObjectSimple | |
312 | { | |
313 | public: | |
314 | wxFileDataObject(); | |
315 | ||
316 | //const wxArrayString& GetFilenames(); | |
317 | %addmethods { | |
318 | PyObject* GetFilenames() { | |
319 | const wxArrayString& strings = self->GetFilenames(); | |
b37c7e1d | 320 | return wxArrayString2PyList_helper(strings); |
b1462dfa RD |
321 | } |
322 | } | |
3ca6a5f0 BP |
323 | #ifdef __WXMSW__ |
324 | void AddFile(const wxString &filename); | |
325 | #endif | |
b1462dfa RD |
326 | }; |
327 | ||
328 | ||
329 | //---------------------------------------------------------------------- | |
330 | ||
331 | class wxCustomDataObject : public wxDataObjectSimple { | |
332 | public: | |
333 | wxCustomDataObject(const wxDataFormat& format = wxPyFormatInvalid); | |
334 | ||
335 | //void TakeData(size_t size, void *data); | |
336 | //bool SetData(size_t size, const void *buf); | |
337 | %addmethods { | |
338 | void TakeData(PyObject* data) { | |
339 | if (PyString_Check(data)) { | |
340 | self->SetData(PyString_Size(data), PyString_AsString(data)); | |
341 | } | |
342 | } | |
343 | bool SetData(PyObject* data) { | |
344 | if (PyString_Check(data)) { | |
345 | return self->SetData(PyString_Size(data), PyString_AsString(data)); | |
346 | } | |
347 | return FALSE; | |
348 | } | |
349 | } | |
350 | ||
351 | size_t GetSize(); | |
c368d904 | 352 | |
b1462dfa RD |
353 | //void *GetData(); |
354 | %addmethods { | |
355 | PyObject* GetData() { | |
356 | return PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); | |
357 | } | |
358 | } | |
359 | ||
360 | ||
361 | }; | |
362 | ||
363 | ||
c9a1416a RD |
364 | //---------------------------------------------------------------------- |
365 | ||
366 | class wxURLDataObject : public wxDataObjectComposite { | |
367 | public: | |
368 | wxURLDataObject(); | |
369 | ||
370 | wxString GetURL(); | |
371 | void SetURL(const wxString& url); | |
372 | }; | |
b1462dfa | 373 | |
f54a35fe RD |
374 | //---------------------------------------------------------------------- |
375 | ||
376 | #ifndef __WXGTK__ | |
377 | ||
378 | %{ | |
379 | #include <wx/metafile.h> | |
380 | %} | |
381 | ||
382 | class wxMetafileDataObject : public wxDataObjectSimple | |
383 | { | |
384 | public: | |
385 | wxMetafileDataObject(); | |
386 | ||
387 | void SetMetafile(const wxMetafile& metafile); | |
388 | wxMetafile GetMetafile() const; | |
389 | }; | |
390 | ||
391 | #endif | |
392 | ||
b1462dfa RD |
393 | //---------------------------------------------------------------------- |
394 | //---------------------------------------------------------------------- | |
395 | //---------------------------------------------------------------------- | |
396 | ||
9416aa89 | 397 | class wxClipboard : public wxObject { |
b1462dfa RD |
398 | public: |
399 | wxClipboard(); | |
400 | ||
401 | bool Open(); | |
402 | void Close(); | |
403 | bool IsOpened() const; | |
404 | ||
405 | bool AddData( wxDataObject *data ); | |
406 | %pragma(python) addtomethod = "AddData:_args[0].thisown = 0" | |
407 | bool SetData( wxDataObject *data ); | |
408 | %pragma(python) addtomethod = "SetData:_args[0].thisown = 0" | |
409 | ||
410 | bool IsSupported( const wxDataFormat& format ); | |
411 | bool GetData( wxDataObject& data ); | |
412 | void Clear(); | |
413 | bool Flush(); | |
414 | void UsePrimarySelection( int primary = FALSE ); | |
415 | }; | |
416 | ||
417 | %{ | |
6999b0d8 | 418 | // See below in the init function... |
b1462dfa RD |
419 | wxClipboard* wxPyTheClipboard; |
420 | %} | |
421 | %readonly | |
422 | %name(wxTheClipboard) wxClipboard* wxPyTheClipboard; | |
423 | %readwrite | |
424 | ||
425 | //---------------------------------------------------------------------- | |
426 | //---------------------------------------------------------------------- | |
427 | ||
3bd1e033 RD |
428 | // flags for wxDropSource::DoDragDrop() |
429 | // | |
430 | enum | |
431 | { | |
432 | wxDrag_CopyOnly = 0, // allow only copying | |
433 | wxDrag_AllowMove = 1, // allow moving (copying is always allowed) | |
434 | wxDrag_DefaultMove = 3 // the default operation is move, not copy | |
435 | }; | |
436 | ||
b1462dfa RD |
437 | enum wxDragResult |
438 | { | |
439 | wxDragError, // error prevented the d&d operation from completing | |
440 | wxDragNone, // drag target didn't accept the data | |
441 | wxDragCopy, // the data was successfully copied | |
442 | wxDragMove, // the data was successfully moved (MSW only) | |
c9a1416a | 443 | wxDragLink, // operation is a drag-link |
b1462dfa RD |
444 | wxDragCancel // the operation was cancelled by user (not an error) |
445 | }; | |
446 | ||
447 | bool wxIsDragResultOk(wxDragResult res); | |
448 | ||
449 | //---------------------------------------------------------------------- | |
450 | %{ | |
451 | class wxPyDropSource : public wxDropSource { | |
452 | public: | |
4120ef2b | 453 | #ifdef __WXMSW__ |
b1462dfa RD |
454 | wxPyDropSource(wxWindow *win = NULL, |
455 | const wxCursor &cursorCopy = wxNullCursor, | |
456 | const wxCursor &cursorMove = wxNullCursor, | |
457 | const wxCursor &cursorStop = wxNullCursor) | |
458 | : wxDropSource(win, cursorCopy, cursorMove, cursorStop) {} | |
4120ef2b RD |
459 | #else |
460 | wxPyDropSource(wxWindow *win = NULL, | |
461 | const wxIcon &go = wxNullIcon) | |
462 | : wxDropSource(win, go) {} | |
463 | #endif | |
077def0b | 464 | ~wxPyDropSource() { } |
dafb483b | 465 | |
b1462dfa RD |
466 | DEC_PYCALLBACK_BOOL_DR(GiveFeedback); |
467 | PYPRIVATE; | |
468 | }; | |
469 | ||
470 | IMP_PYCALLBACK_BOOL_DR(wxPyDropSource, wxDropSource, GiveFeedback); | |
471 | ||
472 | %} | |
473 | ||
474 | ||
475 | %name(wxDropSource) class wxPyDropSource { | |
476 | public: | |
4120ef2b | 477 | #ifdef __WXMSW__ |
b1462dfa RD |
478 | wxPyDropSource(wxWindow *win = NULL, |
479 | const wxCursor &cursorCopy = wxNullCursor, | |
480 | const wxCursor &cursorMove = wxNullCursor, | |
481 | const wxCursor &cursorStop = wxNullCursor); | |
4120ef2b RD |
482 | #else |
483 | wxPyDropSource(wxWindow *win = NULL, | |
484 | const wxIcon &go = wxNullIcon); | |
485 | #endif | |
486 | ||
0122b7e3 RD |
487 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref); |
488 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxDropSource, 0)" | |
b1462dfa RD |
489 | ~wxPyDropSource(); |
490 | ||
491 | void SetData(wxDataObject& data); | |
492 | wxDataObject *GetDataObject(); | |
493 | void SetCursor(wxDragResult res, const wxCursor& cursor); | |
3bd1e033 | 494 | wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); |
b1462dfa RD |
495 | |
496 | bool base_GiveFeedback(wxDragResult effect); | |
497 | }; | |
498 | ||
499 | //---------------------------------------------------------------------- | |
500 | ||
501 | // Just a place holder for the type system. The real base class for | |
502 | // wxPython is wxPyDropTarget | |
503 | class wxDropTarget { | |
504 | public: | |
505 | }; | |
506 | ||
507 | ||
508 | %{ | |
509 | class wxPyDropTarget : public wxDropTarget { | |
510 | public: | |
511 | wxPyDropTarget(wxDataObject *dataObject = NULL) | |
512 | : wxDropTarget(dataObject) {} | |
513 | ||
514 | // DEC_PYCALLBACK_SIZET_(GetFormatCount); | |
515 | // DEC_PYCALLBACK_DATAFMT_SIZET(GetFormat); | |
516 | ||
517 | DEC_PYCALLBACK__(OnLeave); | |
518 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
519 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
520 | DEC_PYCALLBACK_DR_2WXCDR_pure(OnData); | |
521 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
522 | ||
523 | PYPRIVATE; | |
524 | }; | |
525 | ||
526 | // IMP_PYCALLBACK_SIZET_(wxPyDropTarget, wxDropTarget, GetFormatCount); | |
527 | // IMP__PYCALLBACK_DATAFMT_SIZET(wxPyDropTarget, wxDropTarget, GetFormat); | |
528 | ||
529 | IMP_PYCALLBACK__(wxPyDropTarget, wxDropTarget, OnLeave); | |
530 | IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnEnter); | |
531 | IMP_PYCALLBACK_DR_2WXCDR(wxPyDropTarget, wxDropTarget, OnDragOver); | |
532 | IMP_PYCALLBACK_DR_2WXCDR_pure(wxPyDropTarget, wxDropTarget, OnData); | |
533 | IMP_PYCALLBACK_BOOL_INTINT(wxPyDropTarget, wxDropTarget, OnDrop); | |
534 | ||
535 | %} | |
536 | ||
537 | ||
538 | class wxPyDropTarget : public wxDropTarget { | |
539 | public: | |
540 | wxPyDropTarget(wxDataObject *dataObject = NULL); | |
541 | %pragma(python) addtomethod = "__init__:if _args:_args[0].thisown = 0" | |
0122b7e3 RD |
542 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
543 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyDropTarget)" | |
b1462dfa RD |
544 | |
545 | ~wxPyDropTarget(); | |
546 | ||
547 | wxDataObject *GetDataObject(); | |
548 | void SetDataObject(wxDataObject *dataObject); | |
549 | %pragma(python) addtomethod = "SetDataObject:if _args:_args[0].thisown = 0" | |
550 | ||
551 | // size_t base_GetFormatCount(); | |
552 | // wxDataFormat base_GetFormat(size_t n); | |
553 | ||
554 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
555 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
556 | void base_OnLeave(); | |
557 | bool base_OnDrop(wxCoord x, wxCoord y); | |
558 | //wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0; | |
559 | ||
560 | // **** not sure about this one | |
561 | bool GetData(); | |
562 | ||
563 | }; | |
564 | ||
565 | ||
566 | //---------------------------------------------------------------------- | |
567 | ||
568 | %{ | |
569 | class wxPyTextDropTarget : public wxTextDropTarget { | |
570 | public: | |
571 | wxPyTextDropTarget() {} | |
572 | ||
573 | DEC_PYCALLBACK_BOOL_INTINTSTR_pure(OnDropText); | |
574 | ||
575 | DEC_PYCALLBACK__(OnLeave); | |
576 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
577 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
578 | DEC_PYCALLBACK_DR_2WXCDR(OnData); | |
579 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
580 | ||
581 | PYPRIVATE; | |
582 | }; | |
583 | ||
584 | IMP_PYCALLBACK_BOOL_INTINTSTR_pure(wxPyTextDropTarget, wxTextDropTarget, OnDropText); | |
585 | IMP_PYCALLBACK__(wxPyTextDropTarget, wxTextDropTarget, OnLeave); | |
586 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnEnter); | |
587 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnDragOver); | |
588 | IMP_PYCALLBACK_DR_2WXCDR(wxPyTextDropTarget, wxTextDropTarget, OnData); | |
589 | IMP_PYCALLBACK_BOOL_INTINT(wxPyTextDropTarget, wxTextDropTarget, OnDrop); | |
590 | ||
591 | %} | |
592 | ||
593 | %name(wxTextDropTarget) class wxPyTextDropTarget : public wxPyDropTarget { | |
594 | public: | |
595 | wxPyTextDropTarget(); | |
0122b7e3 RD |
596 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
597 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTextDropTarget)" | |
b1462dfa RD |
598 | |
599 | //bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0; | |
600 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
601 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
602 | void base_OnLeave(); | |
603 | bool base_OnDrop(wxCoord x, wxCoord y); | |
604 | wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); | |
605 | }; | |
606 | ||
607 | //---------------------------------------------------------------------- | |
608 | %{ | |
609 | class wxPyFileDropTarget : public wxFileDropTarget { | |
610 | public: | |
611 | wxPyFileDropTarget() {} | |
612 | ||
613 | virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames); | |
614 | ||
615 | DEC_PYCALLBACK__(OnLeave); | |
616 | DEC_PYCALLBACK_DR_2WXCDR(OnEnter); | |
617 | DEC_PYCALLBACK_DR_2WXCDR(OnDragOver); | |
618 | DEC_PYCALLBACK_DR_2WXCDR(OnData); | |
619 | DEC_PYCALLBACK_BOOL_INTINT(OnDrop); | |
620 | ||
621 | PYPRIVATE; | |
622 | }; | |
623 | ||
624 | bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, | |
625 | const wxArrayString& filenames) { | |
626 | bool rval = FALSE; | |
4268f798 | 627 | wxPyBeginBlockThreads(); |
b37c7e1d | 628 | PyObject* list = wxArrayString2PyList_helper(filenames); |
b1462dfa RD |
629 | if (m_myInst.findCallback("OnDropFiles")) |
630 | rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list)); | |
631 | Py_DECREF(list); | |
4268f798 | 632 | wxPyEndBlockThreads(); |
b1462dfa RD |
633 | return rval; |
634 | } | |
635 | ||
636 | ||
637 | ||
638 | IMP_PYCALLBACK__(wxPyFileDropTarget, wxFileDropTarget, OnLeave); | |
639 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnEnter); | |
640 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnDragOver); | |
641 | IMP_PYCALLBACK_DR_2WXCDR(wxPyFileDropTarget, wxFileDropTarget, OnData); | |
642 | IMP_PYCALLBACK_BOOL_INTINT(wxPyFileDropTarget, wxFileDropTarget, OnDrop); | |
643 | ||
644 | %} | |
645 | ||
646 | ||
647 | %name(wxFileDropTarget) class wxPyFileDropTarget : public wxPyDropTarget | |
648 | { | |
649 | public: | |
650 | wxPyFileDropTarget(); | |
0122b7e3 RD |
651 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
652 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFileDropTarget)" | |
b1462dfa RD |
653 | |
654 | // bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) = 0; | |
655 | wxDragResult base_OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
656 | wxDragResult base_OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
657 | void base_OnLeave(); | |
658 | bool base_OnDrop(wxCoord x, wxCoord y); | |
659 | wxDragResult base_OnData(wxCoord x, wxCoord y, wxDragResult def); | |
660 | }; | |
661 | ||
662 | //---------------------------------------------------------------------- | |
663 | //---------------------------------------------------------------------- | |
664 | //---------------------------------------------------------------------- | |
665 | ||
666 | %init %{ | |
667 | ||
668 | wxPyTheClipboard = wxTheClipboard; | |
9416aa89 RD |
669 | wxPyPtrTypeMap_Add("wxDropSource", "wxPyDropSource"); |
670 | wxPyPtrTypeMap_Add("wxTextDropTarget", "wxPyTextDropTarget"); | |
671 | wxPyPtrTypeMap_Add("wxFileDropTarget", "wxPyFileDropTarget"); | |
b1462dfa RD |
672 | %} |
673 | ||
674 | //---------------------------------------------------------------------- | |
d18c7c6d | 675 | |
b1462dfa | 676 |