2 /* ========================== Module Drag =========================== */
9 #include "pymactoolbox.h"
13 /* Callback glue routines */
14 DragTrackingHandlerUPP dragglue_TrackingHandlerUPP
;
15 DragReceiveHandlerUPP dragglue_ReceiveHandlerUPP
;
16 DragSendDataUPP dragglue_SendDataUPP
;
18 DragInputUPP dragglue_InputUPP
;
19 DragDrawingUPP dragglue_DrawingUPP
;
22 static PyObject
*Drag_Error
;
24 /* ---------------------- Object type DragObj ----------------------- */
26 PyTypeObject DragObj_Type
;
28 #define DragObj_Check(x) ((x)->ob_type == &DragObj_Type)
30 typedef struct DragObjObject
{
36 PyObject
*DragObj_New(itself
)
41 PyErr_SetString(Drag_Error
,"Cannot create null Drag");
44 it
= PyObject_NEW(DragObjObject
, &DragObj_Type
);
45 if (it
== NULL
) return NULL
;
46 it
->ob_itself
= itself
;
48 return (PyObject
*)it
;
50 DragObj_Convert(v
, p_itself
)
54 if (!DragObj_Check(v
))
56 PyErr_SetString(PyExc_TypeError
, "DragObj required");
59 *p_itself
= ((DragObjObject
*)v
)->ob_itself
;
63 static void DragObj_dealloc(self
)
66 Py_XDECREF(self
->sendproc
);
70 static PyObject
*DragObj_DisposeDrag(_self
, _args
)
74 PyObject
*_res
= NULL
;
76 if (!PyArg_ParseTuple(_args
, ""))
78 _err
= DisposeDrag(_self
->ob_itself
);
79 if (_err
!= noErr
) return PyMac_Error(_err
);
85 static PyObject
*DragObj_AddDragItemFlavor(_self
, _args
)
89 PyObject
*_res
= NULL
;
91 ItemReference theItemRef
;
95 int dataPtr__in_len__
;
97 if (!PyArg_ParseTuple(_args
, "lO&z#l",
99 PyMac_GetOSType
, &theType
,
100 &dataPtr__in__
, &dataPtr__in_len__
,
103 dataPtr__len__
= dataPtr__in_len__
;
104 _err
= AddDragItemFlavor(_self
->ob_itself
,
107 dataPtr__in__
, dataPtr__len__
,
109 if (_err
!= noErr
) return PyMac_Error(_err
);
116 static PyObject
*DragObj_SetDragItemFlavorData(_self
, _args
)
117 DragObjObject
*_self
;
120 PyObject
*_res
= NULL
;
122 ItemReference theItemRef
;
126 int dataPtr__in_len__
;
128 if (!PyArg_ParseTuple(_args
, "lO&z#l",
130 PyMac_GetOSType
, &theType
,
131 &dataPtr__in__
, &dataPtr__in_len__
,
134 dataPtr__len__
= dataPtr__in_len__
;
135 _err
= SetDragItemFlavorData(_self
->ob_itself
,
138 dataPtr__in__
, dataPtr__len__
,
140 if (_err
!= noErr
) return PyMac_Error(_err
);
147 static PyObject
*DragObj_SetDragImage(_self
, _args
)
148 DragObjObject
*_self
;
151 PyObject
*_res
= NULL
;
153 PixMapHandle imagePixMap
;
156 DragImageFlags theImageFlags
;
157 if (!PyArg_ParseTuple(_args
, "O&O&O&l",
158 ResObj_Convert
, &imagePixMap
,
159 ResObj_Convert
, &imageRgn
,
160 PyMac_GetPoint
, &imageOffsetPt
,
163 _err
= SetDragImage(_self
->ob_itself
,
168 if (_err
!= noErr
) return PyMac_Error(_err
);
174 static PyObject
*DragObj_ChangeDragBehaviors(_self
, _args
)
175 DragObjObject
*_self
;
178 PyObject
*_res
= NULL
;
180 DragBehaviors inBehaviorsToSet
;
181 DragBehaviors inBehaviorsToClear
;
182 if (!PyArg_ParseTuple(_args
, "ll",
184 &inBehaviorsToClear
))
186 _err
= ChangeDragBehaviors(_self
->ob_itself
,
189 if (_err
!= noErr
) return PyMac_Error(_err
);
195 static PyObject
*DragObj_TrackDrag(_self
, _args
)
196 DragObjObject
*_self
;
199 PyObject
*_res
= NULL
;
201 EventRecord theEvent
;
203 if (!PyArg_ParseTuple(_args
, "O&O&",
204 PyMac_GetEventRecord
, &theEvent
,
205 ResObj_Convert
, &theRegion
))
207 _err
= TrackDrag(_self
->ob_itself
,
210 if (_err
!= noErr
) return PyMac_Error(_err
);
216 static PyObject
*DragObj_CountDragItems(_self
, _args
)
217 DragObjObject
*_self
;
220 PyObject
*_res
= NULL
;
223 if (!PyArg_ParseTuple(_args
, ""))
225 _err
= CountDragItems(_self
->ob_itself
,
227 if (_err
!= noErr
) return PyMac_Error(_err
);
228 _res
= Py_BuildValue("H",
233 static PyObject
*DragObj_GetDragItemReferenceNumber(_self
, _args
)
234 DragObjObject
*_self
;
237 PyObject
*_res
= NULL
;
240 ItemReference theItemRef
;
241 if (!PyArg_ParseTuple(_args
, "H",
244 _err
= GetDragItemReferenceNumber(_self
->ob_itself
,
247 if (_err
!= noErr
) return PyMac_Error(_err
);
248 _res
= Py_BuildValue("l",
253 static PyObject
*DragObj_CountDragItemFlavors(_self
, _args
)
254 DragObjObject
*_self
;
257 PyObject
*_res
= NULL
;
259 ItemReference theItemRef
;
261 if (!PyArg_ParseTuple(_args
, "l",
264 _err
= CountDragItemFlavors(_self
->ob_itself
,
267 if (_err
!= noErr
) return PyMac_Error(_err
);
268 _res
= Py_BuildValue("H",
273 static PyObject
*DragObj_GetFlavorType(_self
, _args
)
274 DragObjObject
*_self
;
277 PyObject
*_res
= NULL
;
279 ItemReference theItemRef
;
282 if (!PyArg_ParseTuple(_args
, "lH",
286 _err
= GetFlavorType(_self
->ob_itself
,
290 if (_err
!= noErr
) return PyMac_Error(_err
);
291 _res
= Py_BuildValue("O&",
292 PyMac_BuildOSType
, theType
);
296 static PyObject
*DragObj_GetFlavorFlags(_self
, _args
)
297 DragObjObject
*_self
;
300 PyObject
*_res
= NULL
;
302 ItemReference theItemRef
;
304 FlavorFlags theFlags
;
305 if (!PyArg_ParseTuple(_args
, "lO&",
307 PyMac_GetOSType
, &theType
))
309 _err
= GetFlavorFlags(_self
->ob_itself
,
313 if (_err
!= noErr
) return PyMac_Error(_err
);
314 _res
= Py_BuildValue("l",
319 static PyObject
*DragObj_GetFlavorDataSize(_self
, _args
)
320 DragObjObject
*_self
;
323 PyObject
*_res
= NULL
;
325 ItemReference theItemRef
;
328 if (!PyArg_ParseTuple(_args
, "lO&",
330 PyMac_GetOSType
, &theType
))
332 _err
= GetFlavorDataSize(_self
->ob_itself
,
336 if (_err
!= noErr
) return PyMac_Error(_err
);
337 _res
= Py_BuildValue("l",
342 static PyObject
*DragObj_GetFlavorData(_self
, _args
)
343 DragObjObject
*_self
;
346 PyObject
*_res
= NULL
;
348 ItemReference theItemRef
;
350 char *dataPtr__out__
;
352 int dataPtr__in_len__
;
354 if (!PyArg_ParseTuple(_args
, "lO&il",
356 PyMac_GetOSType
, &theType
,
360 if ((dataPtr__out__
= malloc(dataPtr__in_len__
)) == NULL
)
363 goto dataPtr__error__
;
365 dataPtr__len__
= dataPtr__in_len__
;
366 _err
= GetFlavorData(_self
->ob_itself
,
369 dataPtr__out__
, &dataPtr__len__
,
371 if (_err
!= noErr
) return PyMac_Error(_err
);
372 _res
= Py_BuildValue("s#",
373 dataPtr__out__
, (int)dataPtr__len__
);
374 free(dataPtr__out__
);
379 static PyObject
*DragObj_GetDragItemBounds(_self
, _args
)
380 DragObjObject
*_self
;
383 PyObject
*_res
= NULL
;
385 ItemReference theItemRef
;
387 if (!PyArg_ParseTuple(_args
, "l",
390 _err
= GetDragItemBounds(_self
->ob_itself
,
393 if (_err
!= noErr
) return PyMac_Error(_err
);
394 _res
= Py_BuildValue("O&",
395 PyMac_BuildRect
, &itemBounds
);
399 static PyObject
*DragObj_SetDragItemBounds(_self
, _args
)
400 DragObjObject
*_self
;
403 PyObject
*_res
= NULL
;
405 ItemReference theItemRef
;
407 if (!PyArg_ParseTuple(_args
, "lO&",
409 PyMac_GetRect
, &itemBounds
))
411 _err
= SetDragItemBounds(_self
->ob_itself
,
414 if (_err
!= noErr
) return PyMac_Error(_err
);
420 static PyObject
*DragObj_GetDropLocation(_self
, _args
)
421 DragObjObject
*_self
;
424 PyObject
*_res
= NULL
;
427 if (!PyArg_ParseTuple(_args
, ""))
429 _err
= GetDropLocation(_self
->ob_itself
,
431 if (_err
!= noErr
) return PyMac_Error(_err
);
432 _res
= Py_BuildValue("O&",
433 AEDesc_New
, &dropLocation
);
437 static PyObject
*DragObj_SetDropLocation(_self
, _args
)
438 DragObjObject
*_self
;
441 PyObject
*_res
= NULL
;
444 if (!PyArg_ParseTuple(_args
, "O&",
445 AEDesc_Convert
, &dropLocation
))
447 _err
= SetDropLocation(_self
->ob_itself
,
449 if (_err
!= noErr
) return PyMac_Error(_err
);
455 static PyObject
*DragObj_GetDragAttributes(_self
, _args
)
456 DragObjObject
*_self
;
459 PyObject
*_res
= NULL
;
461 DragAttributes flags
;
462 if (!PyArg_ParseTuple(_args
, ""))
464 _err
= GetDragAttributes(_self
->ob_itself
,
466 if (_err
!= noErr
) return PyMac_Error(_err
);
467 _res
= Py_BuildValue("l",
472 static PyObject
*DragObj_GetDragMouse(_self
, _args
)
473 DragObjObject
*_self
;
476 PyObject
*_res
= NULL
;
479 Point globalPinnedMouse
;
480 if (!PyArg_ParseTuple(_args
, ""))
482 _err
= GetDragMouse(_self
->ob_itself
,
485 if (_err
!= noErr
) return PyMac_Error(_err
);
486 _res
= Py_BuildValue("O&O&",
487 PyMac_BuildPoint
, mouse
,
488 PyMac_BuildPoint
, globalPinnedMouse
);
492 static PyObject
*DragObj_SetDragMouse(_self
, _args
)
493 DragObjObject
*_self
;
496 PyObject
*_res
= NULL
;
498 Point globalPinnedMouse
;
499 if (!PyArg_ParseTuple(_args
, "O&",
500 PyMac_GetPoint
, &globalPinnedMouse
))
502 _err
= SetDragMouse(_self
->ob_itself
,
504 if (_err
!= noErr
) return PyMac_Error(_err
);
510 static PyObject
*DragObj_GetDragOrigin(_self
, _args
)
511 DragObjObject
*_self
;
514 PyObject
*_res
= NULL
;
516 Point globalInitialMouse
;
517 if (!PyArg_ParseTuple(_args
, ""))
519 _err
= GetDragOrigin(_self
->ob_itself
,
520 &globalInitialMouse
);
521 if (_err
!= noErr
) return PyMac_Error(_err
);
522 _res
= Py_BuildValue("O&",
523 PyMac_BuildPoint
, globalInitialMouse
);
527 static PyObject
*DragObj_GetDragModifiers(_self
, _args
)
528 DragObjObject
*_self
;
531 PyObject
*_res
= NULL
;
534 SInt16 mouseDownModifiers
;
535 SInt16 mouseUpModifiers
;
536 if (!PyArg_ParseTuple(_args
, ""))
538 _err
= GetDragModifiers(_self
->ob_itself
,
542 if (_err
!= noErr
) return PyMac_Error(_err
);
543 _res
= Py_BuildValue("hhh",
550 static PyObject
*DragObj_ShowDragHilite(_self
, _args
)
551 DragObjObject
*_self
;
554 PyObject
*_res
= NULL
;
556 RgnHandle hiliteFrame
;
558 if (!PyArg_ParseTuple(_args
, "O&b",
559 ResObj_Convert
, &hiliteFrame
,
562 _err
= ShowDragHilite(_self
->ob_itself
,
565 if (_err
!= noErr
) return PyMac_Error(_err
);
571 static PyObject
*DragObj_HideDragHilite(_self
, _args
)
572 DragObjObject
*_self
;
575 PyObject
*_res
= NULL
;
577 if (!PyArg_ParseTuple(_args
, ""))
579 _err
= HideDragHilite(_self
->ob_itself
);
580 if (_err
!= noErr
) return PyMac_Error(_err
);
586 static PyObject
*DragObj_DragPreScroll(_self
, _args
)
587 DragObjObject
*_self
;
590 PyObject
*_res
= NULL
;
594 if (!PyArg_ParseTuple(_args
, "hh",
598 _err
= DragPreScroll(_self
->ob_itself
,
601 if (_err
!= noErr
) return PyMac_Error(_err
);
607 static PyObject
*DragObj_DragPostScroll(_self
, _args
)
608 DragObjObject
*_self
;
611 PyObject
*_res
= NULL
;
613 if (!PyArg_ParseTuple(_args
, ""))
615 _err
= DragPostScroll(_self
->ob_itself
);
616 if (_err
!= noErr
) return PyMac_Error(_err
);
622 static PyObject
*DragObj_UpdateDragHilite(_self
, _args
)
623 DragObjObject
*_self
;
626 PyObject
*_res
= NULL
;
629 if (!PyArg_ParseTuple(_args
, "O&",
630 ResObj_Convert
, &updateRgn
))
632 _err
= UpdateDragHilite(_self
->ob_itself
,
634 if (_err
!= noErr
) return PyMac_Error(_err
);
640 static PyMethodDef DragObj_methods
[] = {
641 {"DisposeDrag", (PyCFunction
)DragObj_DisposeDrag
, 1,
643 {"AddDragItemFlavor", (PyCFunction
)DragObj_AddDragItemFlavor
, 1,
644 "(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, FlavorFlags theFlags) -> None"},
645 {"SetDragItemFlavorData", (PyCFunction
)DragObj_SetDragItemFlavorData
, 1,
646 "(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> None"},
647 {"SetDragImage", (PyCFunction
)DragObj_SetDragImage
, 1,
648 "(PixMapHandle imagePixMap, RgnHandle imageRgn, Point imageOffsetPt, DragImageFlags theImageFlags) -> None"},
649 {"ChangeDragBehaviors", (PyCFunction
)DragObj_ChangeDragBehaviors
, 1,
650 "(DragBehaviors inBehaviorsToSet, DragBehaviors inBehaviorsToClear) -> None"},
651 {"TrackDrag", (PyCFunction
)DragObj_TrackDrag
, 1,
652 "(EventRecord theEvent, RgnHandle theRegion) -> None"},
653 {"CountDragItems", (PyCFunction
)DragObj_CountDragItems
, 1,
654 "() -> (UInt16 numItems)"},
655 {"GetDragItemReferenceNumber", (PyCFunction
)DragObj_GetDragItemReferenceNumber
, 1,
656 "(UInt16 index) -> (ItemReference theItemRef)"},
657 {"CountDragItemFlavors", (PyCFunction
)DragObj_CountDragItemFlavors
, 1,
658 "(ItemReference theItemRef) -> (UInt16 numFlavors)"},
659 {"GetFlavorType", (PyCFunction
)DragObj_GetFlavorType
, 1,
660 "(ItemReference theItemRef, UInt16 index) -> (FlavorType theType)"},
661 {"GetFlavorFlags", (PyCFunction
)DragObj_GetFlavorFlags
, 1,
662 "(ItemReference theItemRef, FlavorType theType) -> (FlavorFlags theFlags)"},
663 {"GetFlavorDataSize", (PyCFunction
)DragObj_GetFlavorDataSize
, 1,
664 "(ItemReference theItemRef, FlavorType theType) -> (Size dataSize)"},
665 {"GetFlavorData", (PyCFunction
)DragObj_GetFlavorData
, 1,
666 "(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> (Buffer dataPtr)"},
667 {"GetDragItemBounds", (PyCFunction
)DragObj_GetDragItemBounds
, 1,
668 "(ItemReference theItemRef) -> (Rect itemBounds)"},
669 {"SetDragItemBounds", (PyCFunction
)DragObj_SetDragItemBounds
, 1,
670 "(ItemReference theItemRef, Rect itemBounds) -> None"},
671 {"GetDropLocation", (PyCFunction
)DragObj_GetDropLocation
, 1,
672 "() -> (AEDesc dropLocation)"},
673 {"SetDropLocation", (PyCFunction
)DragObj_SetDropLocation
, 1,
674 "(AEDesc dropLocation) -> None"},
675 {"GetDragAttributes", (PyCFunction
)DragObj_GetDragAttributes
, 1,
676 "() -> (DragAttributes flags)"},
677 {"GetDragMouse", (PyCFunction
)DragObj_GetDragMouse
, 1,
678 "() -> (Point mouse, Point globalPinnedMouse)"},
679 {"SetDragMouse", (PyCFunction
)DragObj_SetDragMouse
, 1,
680 "(Point globalPinnedMouse) -> None"},
681 {"GetDragOrigin", (PyCFunction
)DragObj_GetDragOrigin
, 1,
682 "() -> (Point globalInitialMouse)"},
683 {"GetDragModifiers", (PyCFunction
)DragObj_GetDragModifiers
, 1,
684 "() -> (SInt16 modifiers, SInt16 mouseDownModifiers, SInt16 mouseUpModifiers)"},
685 {"ShowDragHilite", (PyCFunction
)DragObj_ShowDragHilite
, 1,
686 "(RgnHandle hiliteFrame, Boolean inside) -> None"},
687 {"HideDragHilite", (PyCFunction
)DragObj_HideDragHilite
, 1,
689 {"DragPreScroll", (PyCFunction
)DragObj_DragPreScroll
, 1,
690 "(SInt16 dH, SInt16 dV) -> None"},
691 {"DragPostScroll", (PyCFunction
)DragObj_DragPostScroll
, 1,
693 {"UpdateDragHilite", (PyCFunction
)DragObj_UpdateDragHilite
, 1,
694 "(RgnHandle updateRgn) -> None"},
698 PyMethodChain DragObj_chain
= { DragObj_methods
, NULL
};
700 static PyObject
*DragObj_getattr(self
, name
)
704 return Py_FindMethodInChain(&DragObj_chain
, (PyObject
*)self
, name
);
707 #define DragObj_setattr NULL
709 #define DragObj_compare NULL
711 #define DragObj_repr NULL
713 #define DragObj_hash NULL
715 PyTypeObject DragObj_Type
= {
716 PyObject_HEAD_INIT(&PyType_Type
)
718 "DragObj", /*tp_name*/
719 sizeof(DragObjObject
), /*tp_basicsize*/
722 (destructor
) DragObj_dealloc
, /*tp_dealloc*/
724 (getattrfunc
) DragObj_getattr
, /*tp_getattr*/
725 (setattrfunc
) DragObj_setattr
, /*tp_setattr*/
726 (cmpfunc
) DragObj_compare
, /*tp_compare*/
727 (reprfunc
) DragObj_repr
, /*tp_repr*/
728 (PyNumberMethods
*)0, /* tp_as_number */
729 (PySequenceMethods
*)0, /* tp_as_sequence */
730 (PyMappingMethods
*)0, /* tp_as_mapping */
731 (hashfunc
) DragObj_hash
, /*tp_hash*/
734 /* -------------------- End object type DragObj --------------------- */
737 static PyObject
*Drag_NewDrag(_self
, _args
)
741 PyObject
*_res
= NULL
;
744 if (!PyArg_ParseTuple(_args
, ""))
746 _err
= NewDrag(&theDrag
);
747 if (_err
!= noErr
) return PyMac_Error(_err
);
748 _res
= Py_BuildValue("O&",
749 DragObj_New
, theDrag
);
753 static PyObject
*Drag_GetDragHiliteColor(_self
, _args
)
757 PyObject
*_res
= NULL
;
761 if (!PyArg_ParseTuple(_args
, "O&",
762 WinObj_Convert
, &window
))
764 _err
= GetDragHiliteColor(window
,
766 if (_err
!= noErr
) return PyMac_Error(_err
);
767 _res
= Py_BuildValue("O&",
772 static PyObject
*Drag_WaitMouseMoved(_self
, _args
)
776 PyObject
*_res
= NULL
;
779 if (!PyArg_ParseTuple(_args
, "O&",
780 PyMac_GetPoint
, &initialMouse
))
782 _rv
= WaitMouseMoved(initialMouse
);
783 _res
= Py_BuildValue("b",
788 static PyObject
*Drag_ZoomRects(_self
, _args
)
792 PyObject
*_res
= NULL
;
797 ZoomAcceleration acceleration
;
798 if (!PyArg_ParseTuple(_args
, "O&O&hh",
799 PyMac_GetRect
, &fromRect
,
800 PyMac_GetRect
, &toRect
,
804 _err
= ZoomRects(&fromRect
,
808 if (_err
!= noErr
) return PyMac_Error(_err
);
814 static PyObject
*Drag_ZoomRegion(_self
, _args
)
818 PyObject
*_res
= NULL
;
823 ZoomAcceleration acceleration
;
824 if (!PyArg_ParseTuple(_args
, "O&O&hh",
825 ResObj_Convert
, ®ion
,
826 PyMac_GetPoint
, &zoomDistance
,
830 _err
= ZoomRegion(region
,
834 if (_err
!= noErr
) return PyMac_Error(_err
);
840 static PyObject
*Drag_InstallTrackingHandler(_self
, _args
)
844 PyObject
*_res
= NULL
;
847 WindowPtr theWindow
= NULL
;
850 if ( !PyArg_ParseTuple(_args
, "O|O&", &callback
, WinObj_Convert
, &theWindow
) )
852 Py_INCREF(callback
); /* Cannot decref later, too bad */
853 _err
= InstallTrackingHandler(dragglue_TrackingHandlerUPP
, theWindow
, (void *)callback
);
854 if (_err
!= noErr
) return PyMac_Error(_err
);
860 static PyObject
*Drag_InstallReceiveHandler(_self
, _args
)
864 PyObject
*_res
= NULL
;
867 WindowPtr theWindow
= NULL
;
870 if ( !PyArg_ParseTuple(_args
, "O|O&", &callback
, WinObj_Convert
, &theWindow
) )
872 Py_INCREF(callback
); /* Cannot decref later, too bad */
873 _err
= InstallReceiveHandler(dragglue_ReceiveHandlerUPP
, theWindow
, (void *)callback
);
874 if (_err
!= noErr
) return PyMac_Error(_err
);
880 static PyObject
*Drag_RemoveTrackingHandler(_self
, _args
)
884 PyObject
*_res
= NULL
;
886 WindowPtr theWindow
= NULL
;
889 if ( !PyArg_ParseTuple(_args
, "|O&", WinObj_Convert
, &theWindow
) )
891 _err
= RemoveTrackingHandler(dragglue_TrackingHandlerUPP
, theWindow
);
892 if (_err
!= noErr
) return PyMac_Error(_err
);
898 static PyObject
*Drag_RemoveReceiveHandler(_self
, _args
)
902 PyObject
*_res
= NULL
;
904 WindowPtr theWindow
= NULL
;
907 if ( !PyArg_ParseTuple(_args
, "|O&", WinObj_Convert
, &theWindow
) )
909 _err
= RemoveReceiveHandler(dragglue_ReceiveHandlerUPP
, theWindow
);
910 if (_err
!= noErr
) return PyMac_Error(_err
);
916 static PyMethodDef Drag_methods
[] = {
917 {"NewDrag", (PyCFunction
)Drag_NewDrag
, 1,
918 "() -> (DragRef theDrag)"},
919 {"GetDragHiliteColor", (PyCFunction
)Drag_GetDragHiliteColor
, 1,
920 "(WindowPtr window) -> (RGBColor color)"},
921 {"WaitMouseMoved", (PyCFunction
)Drag_WaitMouseMoved
, 1,
922 "(Point initialMouse) -> (Boolean _rv)"},
923 {"ZoomRects", (PyCFunction
)Drag_ZoomRects
, 1,
924 "(Rect fromRect, Rect toRect, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None"},
925 {"ZoomRegion", (PyCFunction
)Drag_ZoomRegion
, 1,
926 "(RgnHandle region, Point zoomDistance, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None"},
927 {"InstallTrackingHandler", (PyCFunction
)Drag_InstallTrackingHandler
, 1,
929 {"InstallReceiveHandler", (PyCFunction
)Drag_InstallReceiveHandler
, 1,
931 {"RemoveTrackingHandler", (PyCFunction
)Drag_RemoveTrackingHandler
, 1,
933 {"RemoveReceiveHandler", (PyCFunction
)Drag_RemoveReceiveHandler
, 1,
941 dragglue_TrackingHandler(DragTrackingMessage theMessage
, WindowPtr theWindow
,
942 void *handlerRefCon
, DragReference theDrag
)
947 args
= Py_BuildValue("hO&O&", theMessage
, DragObj_New
, theDrag
, WinObj_WhichWindow
, theWindow
);
950 rv
= PyEval_CallObject((PyObject
*)handlerRefCon
, args
);
953 fprintf(stderr
, "Drag: Exception in TrackingHandler\n");
960 PyArg_Parse(rv
, "l", &i
);
966 dragglue_ReceiveHandler(WindowPtr theWindow
, void *handlerRefCon
,
967 DragReference theDrag
)
972 args
= Py_BuildValue("O&O&", DragObj_New
, theDrag
, WinObj_WhichWindow
, theWindow
);
975 rv
= PyEval_CallObject((PyObject
*)handlerRefCon
, args
);
978 fprintf(stderr
, "Drag: Exception in ReceiveHandler\n");
985 PyArg_Parse(rv
, "l", &i
);
991 dragglue_SendData(FlavorType theType
, void *dragSendRefCon
,
992 ItemReference theItem
, DragReference theDrag
)
994 DragObjObject
*self
= (DragObjObject
*)dragSendRefCon
;
998 if ( self
->sendproc
== NULL
)
1000 args
= Py_BuildValue("O&l", PyMac_BuildOSType
, theType
, theItem
);
1003 rv
= PyEval_CallObject(self
->sendproc
, args
);
1006 fprintf(stderr
, "Drag: Exception in SendDataHandler\n");
1010 if ( rv
== Py_None
)
1013 PyArg_Parse(rv
, "l", &i
);
1020 dragglue_Input(Point
*mouse
, short *modifiers
,
1021 void *dragSendRefCon
, DragReference theDrag
)
1027 dragglue_Drawing(xxxx
1028 void *dragSendRefCon
, DragReference theDrag
)
1044 m
= Py_InitModule("Drag", Drag_methods
);
1045 d
= PyModule_GetDict(m
);
1046 Drag_Error
= PyMac_GetOSErrException();
1047 if (Drag_Error
== NULL
||
1048 PyDict_SetItemString(d
, "Error", Drag_Error
) != 0)
1050 DragObj_Type
.ob_type
= &PyType_Type
;
1051 Py_INCREF(&DragObj_Type
);
1052 if (PyDict_SetItemString(d
, "DragObjType", (PyObject
*)&DragObj_Type
) != 0)
1053 Py_FatalError("can't initialize DragObjType");
1055 dragglue_TrackingHandlerUPP
= NewDragTrackingHandlerProc(dragglue_TrackingHandler
);
1056 dragglue_ReceiveHandlerUPP
= NewDragReceiveHandlerProc(dragglue_ReceiveHandler
);
1057 dragglue_SendDataUPP
= NewDragSendDataProc(dragglue_SendData
);
1059 dragglue_InputUPP
= NewDragInputProc(dragglue_Input
);
1060 dragglue_DrawingUPP
= NewDragDrawingProc(dragglue_Drawing
);
1066 /* ======================== End module Drag ========================= */