2
/* ========================== Module _Drag ========================== */
9
#include "pymactoolbox.h"
11
/* Macro to test whether a weak-loaded CFM function exists */
12
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13
PyErr_SetString(PyExc_NotImplementedError, \
14
"Not available in this shared library/OS version"); \
19
#include <Carbon/Carbon.h>
21
/* Callback glue routines */
22
DragTrackingHandlerUPP dragglue_TrackingHandlerUPP;
23
DragReceiveHandlerUPP dragglue_ReceiveHandlerUPP;
24
DragSendDataUPP dragglue_SendDataUPP;
26
DragInputUPP dragglue_InputUPP;
27
DragDrawingUPP dragglue_DrawingUPP;
30
#ifdef USE_TOOLBOX_OBJECT_GLUE
31
extern PyObject *_DragObj_New(DragRef);
32
extern int _DragObj_Convert(PyObject *, DragRef *);
34
#define DragObj_New _DragObj_New
35
#define DragObj_Convert _DragObj_Convert
38
static PyObject *Drag_Error;
40
/* ---------------------- Object type DragObj ----------------------- */
42
PyTypeObject DragObj_Type;
44
#define DragObj_Check(x) ((x)->ob_type == &DragObj_Type || PyObject_TypeCheck((x), &DragObj_Type))
46
typedef struct DragObjObject {
52
PyObject *DragObj_New(DragRef itself)
56
PyErr_SetString(Drag_Error,"Cannot create null Drag");
59
it = PyObject_NEW(DragObjObject, &DragObj_Type);
60
if (it == NULL) return NULL;
61
it->ob_itself = itself;
63
return (PyObject *)it;
66
int DragObj_Convert(PyObject *v, DragRef *p_itself)
68
if (!DragObj_Check(v))
70
PyErr_SetString(PyExc_TypeError, "DragObj required");
73
*p_itself = ((DragObjObject *)v)->ob_itself;
77
static void DragObj_dealloc(DragObjObject *self)
79
Py_XDECREF(self->sendproc);
80
self->ob_type->tp_free((PyObject *)self);
83
static PyObject *DragObj_DisposeDrag(DragObjObject *_self, PyObject *_args)
85
PyObject *_res = NULL;
88
PyMac_PRECHECK(DisposeDrag);
90
if (!PyArg_ParseTuple(_args, ""))
92
_err = DisposeDrag(_self->ob_itself);
93
if (_err != noErr) return PyMac_Error(_err);
99
static PyObject *DragObj_AddDragItemFlavor(DragObjObject *_self, PyObject *_args)
101
PyObject *_res = NULL;
103
ItemReference theItemRef;
107
int dataPtr__in_len__;
108
FlavorFlags theFlags;
109
#ifndef AddDragItemFlavor
110
PyMac_PRECHECK(AddDragItemFlavor);
112
if (!PyArg_ParseTuple(_args, "lO&z#l",
114
PyMac_GetOSType, &theType,
115
&dataPtr__in__, &dataPtr__in_len__,
118
dataPtr__len__ = dataPtr__in_len__;
119
_err = AddDragItemFlavor(_self->ob_itself,
122
dataPtr__in__, dataPtr__len__,
124
if (_err != noErr) return PyMac_Error(_err);
130
static PyObject *DragObj_SetDragItemFlavorData(DragObjObject *_self, PyObject *_args)
132
PyObject *_res = NULL;
134
ItemReference theItemRef;
138
int dataPtr__in_len__;
140
#ifndef SetDragItemFlavorData
141
PyMac_PRECHECK(SetDragItemFlavorData);
143
if (!PyArg_ParseTuple(_args, "lO&z#l",
145
PyMac_GetOSType, &theType,
146
&dataPtr__in__, &dataPtr__in_len__,
149
dataPtr__len__ = dataPtr__in_len__;
150
_err = SetDragItemFlavorData(_self->ob_itself,
153
dataPtr__in__, dataPtr__len__,
155
if (_err != noErr) return PyMac_Error(_err);
161
static PyObject *DragObj_SetDragImage(DragObjObject *_self, PyObject *_args)
163
PyObject *_res = NULL;
165
PixMapHandle imagePixMap;
168
DragImageFlags theImageFlags;
170
PyMac_PRECHECK(SetDragImage);
172
if (!PyArg_ParseTuple(_args, "O&O&O&l",
173
ResObj_Convert, &imagePixMap,
174
ResObj_Convert, &imageRgn,
175
PyMac_GetPoint, &imageOffsetPt,
178
_err = SetDragImage(_self->ob_itself,
183
if (_err != noErr) return PyMac_Error(_err);
189
static PyObject *DragObj_ChangeDragBehaviors(DragObjObject *_self, PyObject *_args)
191
PyObject *_res = NULL;
193
DragBehaviors inBehaviorsToSet;
194
DragBehaviors inBehaviorsToClear;
195
#ifndef ChangeDragBehaviors
196
PyMac_PRECHECK(ChangeDragBehaviors);
198
if (!PyArg_ParseTuple(_args, "ll",
200
&inBehaviorsToClear))
202
_err = ChangeDragBehaviors(_self->ob_itself,
205
if (_err != noErr) return PyMac_Error(_err);
211
static PyObject *DragObj_TrackDrag(DragObjObject *_self, PyObject *_args)
213
PyObject *_res = NULL;
215
EventRecord theEvent;
218
PyMac_PRECHECK(TrackDrag);
220
if (!PyArg_ParseTuple(_args, "O&O&",
221
PyMac_GetEventRecord, &theEvent,
222
ResObj_Convert, &theRegion))
224
_err = TrackDrag(_self->ob_itself,
227
if (_err != noErr) return PyMac_Error(_err);
233
static PyObject *DragObj_CountDragItems(DragObjObject *_self, PyObject *_args)
235
PyObject *_res = NULL;
238
#ifndef CountDragItems
239
PyMac_PRECHECK(CountDragItems);
241
if (!PyArg_ParseTuple(_args, ""))
243
_err = CountDragItems(_self->ob_itself,
245
if (_err != noErr) return PyMac_Error(_err);
246
_res = Py_BuildValue("H",
251
static PyObject *DragObj_GetDragItemReferenceNumber(DragObjObject *_self, PyObject *_args)
253
PyObject *_res = NULL;
256
ItemReference theItemRef;
257
#ifndef GetDragItemReferenceNumber
258
PyMac_PRECHECK(GetDragItemReferenceNumber);
260
if (!PyArg_ParseTuple(_args, "H",
263
_err = GetDragItemReferenceNumber(_self->ob_itself,
266
if (_err != noErr) return PyMac_Error(_err);
267
_res = Py_BuildValue("l",
272
static PyObject *DragObj_CountDragItemFlavors(DragObjObject *_self, PyObject *_args)
274
PyObject *_res = NULL;
276
ItemReference theItemRef;
278
#ifndef CountDragItemFlavors
279
PyMac_PRECHECK(CountDragItemFlavors);
281
if (!PyArg_ParseTuple(_args, "l",
284
_err = CountDragItemFlavors(_self->ob_itself,
287
if (_err != noErr) return PyMac_Error(_err);
288
_res = Py_BuildValue("H",
293
static PyObject *DragObj_GetFlavorType(DragObjObject *_self, PyObject *_args)
295
PyObject *_res = NULL;
297
ItemReference theItemRef;
300
#ifndef GetFlavorType
301
PyMac_PRECHECK(GetFlavorType);
303
if (!PyArg_ParseTuple(_args, "lH",
307
_err = GetFlavorType(_self->ob_itself,
311
if (_err != noErr) return PyMac_Error(_err);
312
_res = Py_BuildValue("O&",
313
PyMac_BuildOSType, theType);
317
static PyObject *DragObj_GetFlavorFlags(DragObjObject *_self, PyObject *_args)
319
PyObject *_res = NULL;
321
ItemReference theItemRef;
323
FlavorFlags theFlags;
324
#ifndef GetFlavorFlags
325
PyMac_PRECHECK(GetFlavorFlags);
327
if (!PyArg_ParseTuple(_args, "lO&",
329
PyMac_GetOSType, &theType))
331
_err = GetFlavorFlags(_self->ob_itself,
335
if (_err != noErr) return PyMac_Error(_err);
336
_res = Py_BuildValue("l",
341
static PyObject *DragObj_GetFlavorDataSize(DragObjObject *_self, PyObject *_args)
343
PyObject *_res = NULL;
345
ItemReference theItemRef;
348
#ifndef GetFlavorDataSize
349
PyMac_PRECHECK(GetFlavorDataSize);
351
if (!PyArg_ParseTuple(_args, "lO&",
353
PyMac_GetOSType, &theType))
355
_err = GetFlavorDataSize(_self->ob_itself,
359
if (_err != noErr) return PyMac_Error(_err);
360
_res = Py_BuildValue("l",
365
static PyObject *DragObj_GetFlavorData(DragObjObject *_self, PyObject *_args)
367
PyObject *_res = NULL;
369
ItemReference theItemRef;
371
char *dataPtr__out__;
373
int dataPtr__in_len__;
375
#ifndef GetFlavorData
376
PyMac_PRECHECK(GetFlavorData);
378
if (!PyArg_ParseTuple(_args, "lO&il",
380
PyMac_GetOSType, &theType,
384
if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL)
387
goto dataPtr__error__;
389
dataPtr__len__ = dataPtr__in_len__;
390
_err = GetFlavorData(_self->ob_itself,
393
dataPtr__out__, &dataPtr__len__,
395
if (_err != noErr) return PyMac_Error(_err);
396
_res = Py_BuildValue("s#",
397
dataPtr__out__, (int)dataPtr__len__);
398
free(dataPtr__out__);
403
static PyObject *DragObj_GetDragItemBounds(DragObjObject *_self, PyObject *_args)
405
PyObject *_res = NULL;
407
ItemReference theItemRef;
409
#ifndef GetDragItemBounds
410
PyMac_PRECHECK(GetDragItemBounds);
412
if (!PyArg_ParseTuple(_args, "l",
415
_err = GetDragItemBounds(_self->ob_itself,
418
if (_err != noErr) return PyMac_Error(_err);
419
_res = Py_BuildValue("O&",
420
PyMac_BuildRect, &itemBounds);
424
static PyObject *DragObj_SetDragItemBounds(DragObjObject *_self, PyObject *_args)
426
PyObject *_res = NULL;
428
ItemReference theItemRef;
430
#ifndef SetDragItemBounds
431
PyMac_PRECHECK(SetDragItemBounds);
433
if (!PyArg_ParseTuple(_args, "lO&",
435
PyMac_GetRect, &itemBounds))
437
_err = SetDragItemBounds(_self->ob_itself,
440
if (_err != noErr) return PyMac_Error(_err);
446
static PyObject *DragObj_GetDropLocation(DragObjObject *_self, PyObject *_args)
448
PyObject *_res = NULL;
451
#ifndef GetDropLocation
452
PyMac_PRECHECK(GetDropLocation);
454
if (!PyArg_ParseTuple(_args, ""))
456
_err = GetDropLocation(_self->ob_itself,
458
if (_err != noErr) return PyMac_Error(_err);
459
_res = Py_BuildValue("O&",
460
AEDesc_New, &dropLocation);
464
static PyObject *DragObj_SetDropLocation(DragObjObject *_self, PyObject *_args)
466
PyObject *_res = NULL;
469
#ifndef SetDropLocation
470
PyMac_PRECHECK(SetDropLocation);
472
if (!PyArg_ParseTuple(_args, "O&",
473
AEDesc_Convert, &dropLocation))
475
_err = SetDropLocation(_self->ob_itself,
477
if (_err != noErr) return PyMac_Error(_err);
483
static PyObject *DragObj_GetDragAttributes(DragObjObject *_self, PyObject *_args)
485
PyObject *_res = NULL;
487
DragAttributes flags;
488
#ifndef GetDragAttributes
489
PyMac_PRECHECK(GetDragAttributes);
491
if (!PyArg_ParseTuple(_args, ""))
493
_err = GetDragAttributes(_self->ob_itself,
495
if (_err != noErr) return PyMac_Error(_err);
496
_res = Py_BuildValue("l",
501
static PyObject *DragObj_GetDragMouse(DragObjObject *_self, PyObject *_args)
503
PyObject *_res = NULL;
506
Point globalPinnedMouse;
508
PyMac_PRECHECK(GetDragMouse);
510
if (!PyArg_ParseTuple(_args, ""))
512
_err = GetDragMouse(_self->ob_itself,
515
if (_err != noErr) return PyMac_Error(_err);
516
_res = Py_BuildValue("O&O&",
517
PyMac_BuildPoint, mouse,
518
PyMac_BuildPoint, globalPinnedMouse);
522
static PyObject *DragObj_SetDragMouse(DragObjObject *_self, PyObject *_args)
524
PyObject *_res = NULL;
526
Point globalPinnedMouse;
528
PyMac_PRECHECK(SetDragMouse);
530
if (!PyArg_ParseTuple(_args, "O&",
531
PyMac_GetPoint, &globalPinnedMouse))
533
_err = SetDragMouse(_self->ob_itself,
535
if (_err != noErr) return PyMac_Error(_err);
541
static PyObject *DragObj_GetDragOrigin(DragObjObject *_self, PyObject *_args)
543
PyObject *_res = NULL;
545
Point globalInitialMouse;
546
#ifndef GetDragOrigin
547
PyMac_PRECHECK(GetDragOrigin);
549
if (!PyArg_ParseTuple(_args, ""))
551
_err = GetDragOrigin(_self->ob_itself,
552
&globalInitialMouse);
553
if (_err != noErr) return PyMac_Error(_err);
554
_res = Py_BuildValue("O&",
555
PyMac_BuildPoint, globalInitialMouse);
559
static PyObject *DragObj_GetDragModifiers(DragObjObject *_self, PyObject *_args)
561
PyObject *_res = NULL;
564
SInt16 mouseDownModifiers;
565
SInt16 mouseUpModifiers;
566
#ifndef GetDragModifiers
567
PyMac_PRECHECK(GetDragModifiers);
569
if (!PyArg_ParseTuple(_args, ""))
571
_err = GetDragModifiers(_self->ob_itself,
575
if (_err != noErr) return PyMac_Error(_err);
576
_res = Py_BuildValue("hhh",
583
static PyObject *DragObj_ShowDragHilite(DragObjObject *_self, PyObject *_args)
585
PyObject *_res = NULL;
587
RgnHandle hiliteFrame;
589
#ifndef ShowDragHilite
590
PyMac_PRECHECK(ShowDragHilite);
592
if (!PyArg_ParseTuple(_args, "O&b",
593
ResObj_Convert, &hiliteFrame,
596
_err = ShowDragHilite(_self->ob_itself,
599
if (_err != noErr) return PyMac_Error(_err);
605
static PyObject *DragObj_HideDragHilite(DragObjObject *_self, PyObject *_args)
607
PyObject *_res = NULL;
609
#ifndef HideDragHilite
610
PyMac_PRECHECK(HideDragHilite);
612
if (!PyArg_ParseTuple(_args, ""))
614
_err = HideDragHilite(_self->ob_itself);
615
if (_err != noErr) return PyMac_Error(_err);
621
static PyObject *DragObj_DragPreScroll(DragObjObject *_self, PyObject *_args)
623
PyObject *_res = NULL;
627
#ifndef DragPreScroll
628
PyMac_PRECHECK(DragPreScroll);
630
if (!PyArg_ParseTuple(_args, "hh",
634
_err = DragPreScroll(_self->ob_itself,
637
if (_err != noErr) return PyMac_Error(_err);
643
static PyObject *DragObj_DragPostScroll(DragObjObject *_self, PyObject *_args)
645
PyObject *_res = NULL;
647
#ifndef DragPostScroll
648
PyMac_PRECHECK(DragPostScroll);
650
if (!PyArg_ParseTuple(_args, ""))
652
_err = DragPostScroll(_self->ob_itself);
653
if (_err != noErr) return PyMac_Error(_err);
659
static PyObject *DragObj_UpdateDragHilite(DragObjObject *_self, PyObject *_args)
661
PyObject *_res = NULL;
664
#ifndef UpdateDragHilite
665
PyMac_PRECHECK(UpdateDragHilite);
667
if (!PyArg_ParseTuple(_args, "O&",
668
ResObj_Convert, &updateRgn))
670
_err = UpdateDragHilite(_self->ob_itself,
672
if (_err != noErr) return PyMac_Error(_err);
678
static PyMethodDef DragObj_methods[] = {
679
{"DisposeDrag", (PyCFunction)DragObj_DisposeDrag, 1,
680
PyDoc_STR("() -> None")},
681
{"AddDragItemFlavor", (PyCFunction)DragObj_AddDragItemFlavor, 1,
682
PyDoc_STR("(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, FlavorFlags theFlags) -> None")},
683
{"SetDragItemFlavorData", (PyCFunction)DragObj_SetDragItemFlavorData, 1,
684
PyDoc_STR("(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> None")},
685
{"SetDragImage", (PyCFunction)DragObj_SetDragImage, 1,
686
PyDoc_STR("(PixMapHandle imagePixMap, RgnHandle imageRgn, Point imageOffsetPt, DragImageFlags theImageFlags) -> None")},
687
{"ChangeDragBehaviors", (PyCFunction)DragObj_ChangeDragBehaviors, 1,
688
PyDoc_STR("(DragBehaviors inBehaviorsToSet, DragBehaviors inBehaviorsToClear) -> None")},
689
{"TrackDrag", (PyCFunction)DragObj_TrackDrag, 1,
690
PyDoc_STR("(EventRecord theEvent, RgnHandle theRegion) -> None")},
691
{"CountDragItems", (PyCFunction)DragObj_CountDragItems, 1,
692
PyDoc_STR("() -> (UInt16 numItems)")},
693
{"GetDragItemReferenceNumber", (PyCFunction)DragObj_GetDragItemReferenceNumber, 1,
694
PyDoc_STR("(UInt16 index) -> (ItemReference theItemRef)")},
695
{"CountDragItemFlavors", (PyCFunction)DragObj_CountDragItemFlavors, 1,
696
PyDoc_STR("(ItemReference theItemRef) -> (UInt16 numFlavors)")},
697
{"GetFlavorType", (PyCFunction)DragObj_GetFlavorType, 1,
698
PyDoc_STR("(ItemReference theItemRef, UInt16 index) -> (FlavorType theType)")},
699
{"GetFlavorFlags", (PyCFunction)DragObj_GetFlavorFlags, 1,
700
PyDoc_STR("(ItemReference theItemRef, FlavorType theType) -> (FlavorFlags theFlags)")},
701
{"GetFlavorDataSize", (PyCFunction)DragObj_GetFlavorDataSize, 1,
702
PyDoc_STR("(ItemReference theItemRef, FlavorType theType) -> (Size dataSize)")},
703
{"GetFlavorData", (PyCFunction)DragObj_GetFlavorData, 1,
704
PyDoc_STR("(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> (Buffer dataPtr)")},
705
{"GetDragItemBounds", (PyCFunction)DragObj_GetDragItemBounds, 1,
706
PyDoc_STR("(ItemReference theItemRef) -> (Rect itemBounds)")},
707
{"SetDragItemBounds", (PyCFunction)DragObj_SetDragItemBounds, 1,
708
PyDoc_STR("(ItemReference theItemRef, Rect itemBounds) -> None")},
709
{"GetDropLocation", (PyCFunction)DragObj_GetDropLocation, 1,
710
PyDoc_STR("() -> (AEDesc dropLocation)")},
711
{"SetDropLocation", (PyCFunction)DragObj_SetDropLocation, 1,
712
PyDoc_STR("(AEDesc dropLocation) -> None")},
713
{"GetDragAttributes", (PyCFunction)DragObj_GetDragAttributes, 1,
714
PyDoc_STR("() -> (DragAttributes flags)")},
715
{"GetDragMouse", (PyCFunction)DragObj_GetDragMouse, 1,
716
PyDoc_STR("() -> (Point mouse, Point globalPinnedMouse)")},
717
{"SetDragMouse", (PyCFunction)DragObj_SetDragMouse, 1,
718
PyDoc_STR("(Point globalPinnedMouse) -> None")},
719
{"GetDragOrigin", (PyCFunction)DragObj_GetDragOrigin, 1,
720
PyDoc_STR("() -> (Point globalInitialMouse)")},
721
{"GetDragModifiers", (PyCFunction)DragObj_GetDragModifiers, 1,
722
PyDoc_STR("() -> (SInt16 modifiers, SInt16 mouseDownModifiers, SInt16 mouseUpModifiers)")},
723
{"ShowDragHilite", (PyCFunction)DragObj_ShowDragHilite, 1,
724
PyDoc_STR("(RgnHandle hiliteFrame, Boolean inside) -> None")},
725
{"HideDragHilite", (PyCFunction)DragObj_HideDragHilite, 1,
726
PyDoc_STR("() -> None")},
727
{"DragPreScroll", (PyCFunction)DragObj_DragPreScroll, 1,
728
PyDoc_STR("(SInt16 dH, SInt16 dV) -> None")},
729
{"DragPostScroll", (PyCFunction)DragObj_DragPostScroll, 1,
730
PyDoc_STR("() -> None")},
731
{"UpdateDragHilite", (PyCFunction)DragObj_UpdateDragHilite, 1,
732
PyDoc_STR("(RgnHandle updateRgn) -> None")},
736
#define DragObj_getsetlist NULL
739
#define DragObj_compare NULL
741
#define DragObj_repr NULL
743
#define DragObj_hash NULL
744
#define DragObj_tp_init 0
746
#define DragObj_tp_alloc PyType_GenericAlloc
748
static PyObject *DragObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
752
char *kw[] = {"itself", 0};
754
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DragObj_Convert, &itself)) return NULL;
755
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
756
((DragObjObject *)_self)->ob_itself = itself;
760
#define DragObj_tp_free PyObject_Del
763
PyTypeObject DragObj_Type = {
764
PyObject_HEAD_INIT(NULL)
766
"_Drag.DragObj", /*tp_name*/
767
sizeof(DragObjObject), /*tp_basicsize*/
770
(destructor) DragObj_dealloc, /*tp_dealloc*/
772
(getattrfunc)0, /*tp_getattr*/
773
(setattrfunc)0, /*tp_setattr*/
774
(cmpfunc) DragObj_compare, /*tp_compare*/
775
(reprfunc) DragObj_repr, /*tp_repr*/
776
(PyNumberMethods *)0, /* tp_as_number */
777
(PySequenceMethods *)0, /* tp_as_sequence */
778
(PyMappingMethods *)0, /* tp_as_mapping */
779
(hashfunc) DragObj_hash, /*tp_hash*/
782
PyObject_GenericGetAttr, /*tp_getattro*/
783
PyObject_GenericSetAttr, /*tp_setattro */
785
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
789
0, /*tp_richcompare*/
790
0, /*tp_weaklistoffset*/
793
DragObj_methods, /* tp_methods */
795
DragObj_getsetlist, /*tp_getset*/
801
DragObj_tp_init, /* tp_init */
802
DragObj_tp_alloc, /* tp_alloc */
803
DragObj_tp_new, /* tp_new */
804
DragObj_tp_free, /* tp_free */
807
/* -------------------- End object type DragObj --------------------- */
810
static PyObject *Drag_NewDrag(PyObject *_self, PyObject *_args)
812
PyObject *_res = NULL;
816
PyMac_PRECHECK(NewDrag);
818
if (!PyArg_ParseTuple(_args, ""))
820
_err = NewDrag(&theDrag);
821
if (_err != noErr) return PyMac_Error(_err);
822
_res = Py_BuildValue("O&",
823
DragObj_New, theDrag);
827
static PyObject *Drag_GetDragHiliteColor(PyObject *_self, PyObject *_args)
829
PyObject *_res = NULL;
833
#ifndef GetDragHiliteColor
834
PyMac_PRECHECK(GetDragHiliteColor);
836
if (!PyArg_ParseTuple(_args, "O&",
837
WinObj_Convert, &window))
839
_err = GetDragHiliteColor(window,
841
if (_err != noErr) return PyMac_Error(_err);
842
_res = Py_BuildValue("O&",
847
static PyObject *Drag_WaitMouseMoved(PyObject *_self, PyObject *_args)
849
PyObject *_res = NULL;
852
#ifndef WaitMouseMoved
853
PyMac_PRECHECK(WaitMouseMoved);
855
if (!PyArg_ParseTuple(_args, "O&",
856
PyMac_GetPoint, &initialMouse))
858
_rv = WaitMouseMoved(initialMouse);
859
_res = Py_BuildValue("b",
864
static PyObject *Drag_ZoomRects(PyObject *_self, PyObject *_args)
866
PyObject *_res = NULL;
871
ZoomAcceleration acceleration;
873
PyMac_PRECHECK(ZoomRects);
875
if (!PyArg_ParseTuple(_args, "O&O&hh",
876
PyMac_GetRect, &fromRect,
877
PyMac_GetRect, &toRect,
881
_err = ZoomRects(&fromRect,
885
if (_err != noErr) return PyMac_Error(_err);
891
static PyObject *Drag_ZoomRegion(PyObject *_self, PyObject *_args)
893
PyObject *_res = NULL;
898
ZoomAcceleration acceleration;
900
PyMac_PRECHECK(ZoomRegion);
902
if (!PyArg_ParseTuple(_args, "O&O&hh",
903
ResObj_Convert, ®ion,
904
PyMac_GetPoint, &zoomDistance,
908
_err = ZoomRegion(region,
912
if (_err != noErr) return PyMac_Error(_err);
918
static PyObject *Drag_InstallTrackingHandler(PyObject *_self, PyObject *_args)
920
PyObject *_res = NULL;
923
WindowPtr theWindow = NULL;
926
if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) )
928
Py_INCREF(callback); /* Cannot decref later, too bad */
929
_err = InstallTrackingHandler(dragglue_TrackingHandlerUPP, theWindow, (void *)callback);
930
if (_err != noErr) return PyMac_Error(_err);
937
static PyObject *Drag_InstallReceiveHandler(PyObject *_self, PyObject *_args)
939
PyObject *_res = NULL;
942
WindowPtr theWindow = NULL;
945
if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) )
947
Py_INCREF(callback); /* Cannot decref later, too bad */
948
_err = InstallReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow, (void *)callback);
949
if (_err != noErr) return PyMac_Error(_err);
956
static PyObject *Drag_RemoveTrackingHandler(PyObject *_self, PyObject *_args)
958
PyObject *_res = NULL;
960
WindowPtr theWindow = NULL;
963
if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) )
965
_err = RemoveTrackingHandler(dragglue_TrackingHandlerUPP, theWindow);
966
if (_err != noErr) return PyMac_Error(_err);
973
static PyObject *Drag_RemoveReceiveHandler(PyObject *_self, PyObject *_args)
975
PyObject *_res = NULL;
977
WindowPtr theWindow = NULL;
980
if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) )
982
_err = RemoveReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow);
983
if (_err != noErr) return PyMac_Error(_err);
990
static PyMethodDef Drag_methods[] = {
991
{"NewDrag", (PyCFunction)Drag_NewDrag, 1,
992
PyDoc_STR("() -> (DragRef theDrag)")},
993
{"GetDragHiliteColor", (PyCFunction)Drag_GetDragHiliteColor, 1,
994
PyDoc_STR("(WindowPtr window) -> (RGBColor color)")},
995
{"WaitMouseMoved", (PyCFunction)Drag_WaitMouseMoved, 1,
996
PyDoc_STR("(Point initialMouse) -> (Boolean _rv)")},
997
{"ZoomRects", (PyCFunction)Drag_ZoomRects, 1,
998
PyDoc_STR("(Rect fromRect, Rect toRect, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None")},
999
{"ZoomRegion", (PyCFunction)Drag_ZoomRegion, 1,
1000
PyDoc_STR("(RgnHandle region, Point zoomDistance, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None")},
1001
{"InstallTrackingHandler", (PyCFunction)Drag_InstallTrackingHandler, 1,
1003
{"InstallReceiveHandler", (PyCFunction)Drag_InstallReceiveHandler, 1,
1005
{"RemoveTrackingHandler", (PyCFunction)Drag_RemoveTrackingHandler, 1,
1007
{"RemoveReceiveHandler", (PyCFunction)Drag_RemoveReceiveHandler, 1,
1015
dragglue_TrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
1016
void *handlerRefCon, DragReference theDrag)
1018
PyObject *args, *rv;
1021
args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
1024
rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
1027
PySys_WriteStderr("Drag: Exception in TrackingHandler\n");
1032
if ( rv == Py_None )
1035
PyArg_Parse(rv, "l", &i);
1041
dragglue_ReceiveHandler(WindowPtr theWindow, void *handlerRefCon,
1042
DragReference theDrag)
1044
PyObject *args, *rv;
1047
args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
1050
rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
1053
PySys_WriteStderr("Drag: Exception in ReceiveHandler\n");
1058
if ( rv == Py_None )
1061
PyArg_Parse(rv, "l", &i);
1067
dragglue_SendData(FlavorType theType, void *dragSendRefCon,
1068
ItemReference theItem, DragReference theDrag)
1070
DragObjObject *self = (DragObjObject *)dragSendRefCon;
1071
PyObject *args, *rv;
1074
if ( self->sendproc == NULL )
1076
args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem);
1079
rv = PyEval_CallObject(self->sendproc, args);
1082
PySys_WriteStderr("Drag: Exception in SendDataHandler\n");
1087
if ( rv == Py_None )
1090
PyArg_Parse(rv, "l", &i);
1097
dragglue_Input(Point *mouse, short *modifiers,
1098
void *dragSendRefCon, DragReference theDrag)
1104
dragglue_Drawing(xxxx
1105
void *dragSendRefCon, DragReference theDrag)
1110
#else /* __LP64__ */
1111
static PyMethodDef Drag_methods[] = {
1114
#endif /* __LP64__ */
1117
void init_Drag(void)
1125
PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New);
1126
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert);
1127
#endif /* !__LP64__ */
1130
m = Py_InitModule("_Drag", Drag_methods);
1132
d = PyModule_GetDict(m);
1133
Drag_Error = PyMac_GetOSErrException();
1134
if (Drag_Error == NULL ||
1135
PyDict_SetItemString(d, "Error", Drag_Error) != 0)
1137
DragObj_Type.ob_type = &PyType_Type;
1138
if (PyType_Ready(&DragObj_Type) < 0) return;
1139
Py_INCREF(&DragObj_Type);
1140
PyModule_AddObject(m, "DragObj", (PyObject *)&DragObj_Type);
1141
/* Backward-compatible name */
1142
Py_INCREF(&DragObj_Type);
1143
PyModule_AddObject(m, "DragObjType", (PyObject *)&DragObj_Type);
1145
dragglue_TrackingHandlerUPP = NewDragTrackingHandlerUPP(dragglue_TrackingHandler);
1146
dragglue_ReceiveHandlerUPP = NewDragReceiveHandlerUPP(dragglue_ReceiveHandler);
1147
dragglue_SendDataUPP = NewDragSendDataUPP(dragglue_SendData);
1149
dragglue_InputUPP = NewDragInputUPP(dragglue_Input);
1150
dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing);
1153
#endif /* !__LP64__ */
1157
/* ======================== End module _Drag ======================== */