diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-10 23:43:49 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-10 23:43:49 (GMT) |
commit | f7d5aa61d34cb7816ead2757860e5a66f7da0dcb (patch) | |
tree | faba3f23c2f0fdfa74a156d441f6fa8945c337f8 /Mac/Modules/drag | |
parent | c6c283840316dec54244b311657511e95e742eb0 (diff) | |
download | cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.zip cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.tar.gz cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.tar.bz2 |
Adapted to Universal Headers 3.3.2. More to follow.
Diffstat (limited to 'Mac/Modules/drag')
-rw-r--r-- | Mac/Modules/drag/Dragmodule.c | 515 | ||||
-rw-r--r-- | Mac/Modules/drag/dragsupport.py | 24 |
2 files changed, 303 insertions, 236 deletions
diff --git a/Mac/Modules/drag/Dragmodule.c b/Mac/Modules/drag/Dragmodule.c index 716d2d5..e3801b6 100644 --- a/Mac/Modules/drag/Dragmodule.c +++ b/Mac/Modules/drag/Dragmodule.c @@ -29,12 +29,12 @@ PyTypeObject DragObj_Type; typedef struct DragObjObject { PyObject_HEAD - DragReference ob_itself; + DragRef ob_itself; PyObject *sendproc; } DragObjObject; PyObject *DragObj_New(itself) - DragReference itself; + DragRef itself; { DragObjObject *it; if (itself == NULL) { @@ -49,7 +49,7 @@ PyObject *DragObj_New(itself) } DragObj_Convert(v, p_itself) PyObject *v; - DragReference *p_itself; + DragRef *p_itself; { if (!DragObj_Check(v)) { @@ -67,41 +67,104 @@ static void DragObj_dealloc(self) PyMem_DEL(self); } -static PyObject *DragObj_DisposeDrag(_self, _args) - DragObjObject *_self; +static PyMethodDef DragObj_methods[] = { + {NULL, NULL, 0} +}; + +PyMethodChain DragObj_chain = { DragObj_methods, NULL }; + +static PyObject *DragObj_getattr(self, name) + DragObjObject *self; + char *name; +{ + return Py_FindMethodInChain(&DragObj_chain, (PyObject *)self, name); +} + +#define DragObj_setattr NULL + +#define DragObj_compare NULL + +#define DragObj_repr NULL + +#define DragObj_hash NULL + +PyTypeObject DragObj_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + "DragObj", /*tp_name*/ + sizeof(DragObjObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor) DragObj_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + (getattrfunc) DragObj_getattr, /*tp_getattr*/ + (setattrfunc) DragObj_setattr, /*tp_setattr*/ + (cmpfunc) DragObj_compare, /*tp_compare*/ + (reprfunc) DragObj_repr, /*tp_repr*/ + (PyNumberMethods *)0, /* tp_as_number */ + (PySequenceMethods *)0, /* tp_as_sequence */ + (PyMappingMethods *)0, /* tp_as_mapping */ + (hashfunc) DragObj_hash, /*tp_hash*/ +}; + +/* -------------------- End object type DragObj --------------------- */ + + +static PyObject *Drag_NewDrag(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; if (!PyArg_ParseTuple(_args, "")) return NULL; - _err = DisposeDrag(_self->ob_itself); + _err = NewDrag(&theDrag); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + DragObj_New, theDrag); + return _res; +} + +static PyObject *Drag_DisposeDrag(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + DragRef theDrag; + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) + return NULL; + _err = DisposeDrag(theDrag); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *DragObj_AddDragItemFlavor(_self, _args) - DragObjObject *_self; +static PyObject *Drag_AddDragItemFlavor(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; FlavorType theType; char *dataPtr__in__; long dataPtr__len__; int dataPtr__in_len__; FlavorFlags theFlags; - if (!PyArg_ParseTuple(_args, "lO&z#l", + if (!PyArg_ParseTuple(_args, "O&lO&z#l", + DragObj_Convert, &theDrag, &theItemRef, PyMac_GetOSType, &theType, &dataPtr__in__, &dataPtr__in_len__, &theFlags)) return NULL; dataPtr__len__ = dataPtr__in_len__; - _err = AddDragItemFlavor(_self->ob_itself, + _err = AddDragItemFlavor(theDrag, theItemRef, theType, dataPtr__in__, dataPtr__len__, @@ -113,26 +176,28 @@ static PyObject *DragObj_AddDragItemFlavor(_self, _args) return _res; } -static PyObject *DragObj_SetDragItemFlavorData(_self, _args) - DragObjObject *_self; +static PyObject *Drag_SetDragItemFlavorData(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; FlavorType theType; char *dataPtr__in__; long dataPtr__len__; int dataPtr__in_len__; UInt32 dataOffset; - if (!PyArg_ParseTuple(_args, "lO&z#l", + if (!PyArg_ParseTuple(_args, "O&lO&z#l", + DragObj_Convert, &theDrag, &theItemRef, PyMac_GetOSType, &theType, &dataPtr__in__, &dataPtr__in_len__, &dataOffset)) return NULL; dataPtr__len__ = dataPtr__in_len__; - _err = SetDragItemFlavorData(_self->ob_itself, + _err = SetDragItemFlavorData(theDrag, theItemRef, theType, dataPtr__in__, dataPtr__len__, @@ -144,23 +209,25 @@ static PyObject *DragObj_SetDragItemFlavorData(_self, _args) return _res; } -static PyObject *DragObj_SetDragImage(_self, _args) - DragObjObject *_self; +static PyObject *Drag_SetDragImage(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; PixMapHandle imagePixMap; RgnHandle imageRgn; Point imageOffsetPt; DragImageFlags theImageFlags; - if (!PyArg_ParseTuple(_args, "O&O&O&l", + if (!PyArg_ParseTuple(_args, "O&O&O&O&l", + DragObj_Convert, &theDrag, ResObj_Convert, &imagePixMap, ResObj_Convert, &imageRgn, PyMac_GetPoint, &imageOffsetPt, &theImageFlags)) return NULL; - _err = SetDragImage(_self->ob_itself, + _err = SetDragImage(theDrag, imagePixMap, imageRgn, imageOffsetPt, @@ -171,19 +238,44 @@ static PyObject *DragObj_SetDragImage(_self, _args) return _res; } -static PyObject *DragObj_TrackDrag(_self, _args) - DragObjObject *_self; +static PyObject *Drag_ChangeDragBehaviors(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + DragRef theDrag; + DragBehaviors inBehaviorsToSet; + DragBehaviors inBehaviorsToClear; + if (!PyArg_ParseTuple(_args, "O&ll", + DragObj_Convert, &theDrag, + &inBehaviorsToSet, + &inBehaviorsToClear)) + return NULL; + _err = ChangeDragBehaviors(theDrag, + inBehaviorsToSet, + inBehaviorsToClear); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Drag_TrackDrag(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; EventRecord theEvent; RgnHandle theRegion; - if (!PyArg_ParseTuple(_args, "O&O&", + if (!PyArg_ParseTuple(_args, "O&O&O&", + DragObj_Convert, &theDrag, PyMac_GetEventRecord, &theEvent, ResObj_Convert, &theRegion)) return NULL; - _err = TrackDrag(_self->ob_itself, + _err = TrackDrag(theDrag, &theEvent, theRegion); if (_err != noErr) return PyMac_Error(_err); @@ -192,16 +284,18 @@ static PyObject *DragObj_TrackDrag(_self, _args) return _res; } -static PyObject *DragObj_CountDragItems(_self, _args) - DragObjObject *_self; +static PyObject *Drag_CountDragItems(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; UInt16 numItems; - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = CountDragItems(_self->ob_itself, + _err = CountDragItems(theDrag, &numItems); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("H", @@ -209,18 +303,20 @@ static PyObject *DragObj_CountDragItems(_self, _args) return _res; } -static PyObject *DragObj_GetDragItemReferenceNumber(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDragItemReferenceNumber(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; UInt16 index; ItemReference theItemRef; - if (!PyArg_ParseTuple(_args, "H", + if (!PyArg_ParseTuple(_args, "O&H", + DragObj_Convert, &theDrag, &index)) return NULL; - _err = GetDragItemReferenceNumber(_self->ob_itself, + _err = GetDragItemReferenceNumber(theDrag, index, &theItemRef); if (_err != noErr) return PyMac_Error(_err); @@ -229,18 +325,20 @@ static PyObject *DragObj_GetDragItemReferenceNumber(_self, _args) return _res; } -static PyObject *DragObj_CountDragItemFlavors(_self, _args) - DragObjObject *_self; +static PyObject *Drag_CountDragItemFlavors(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; UInt16 numFlavors; - if (!PyArg_ParseTuple(_args, "l", + if (!PyArg_ParseTuple(_args, "O&l", + DragObj_Convert, &theDrag, &theItemRef)) return NULL; - _err = CountDragItemFlavors(_self->ob_itself, + _err = CountDragItemFlavors(theDrag, theItemRef, &numFlavors); if (_err != noErr) return PyMac_Error(_err); @@ -249,20 +347,22 @@ static PyObject *DragObj_CountDragItemFlavors(_self, _args) return _res; } -static PyObject *DragObj_GetFlavorType(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetFlavorType(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; UInt16 index; FlavorType theType; - if (!PyArg_ParseTuple(_args, "lH", + if (!PyArg_ParseTuple(_args, "O&lH", + DragObj_Convert, &theDrag, &theItemRef, &index)) return NULL; - _err = GetFlavorType(_self->ob_itself, + _err = GetFlavorType(theDrag, theItemRef, index, &theType); @@ -272,20 +372,22 @@ static PyObject *DragObj_GetFlavorType(_self, _args) return _res; } -static PyObject *DragObj_GetFlavorFlags(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetFlavorFlags(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; FlavorType theType; FlavorFlags theFlags; - if (!PyArg_ParseTuple(_args, "lO&", + if (!PyArg_ParseTuple(_args, "O&lO&", + DragObj_Convert, &theDrag, &theItemRef, PyMac_GetOSType, &theType)) return NULL; - _err = GetFlavorFlags(_self->ob_itself, + _err = GetFlavorFlags(theDrag, theItemRef, theType, &theFlags); @@ -295,20 +397,22 @@ static PyObject *DragObj_GetFlavorFlags(_self, _args) return _res; } -static PyObject *DragObj_GetFlavorDataSize(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetFlavorDataSize(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; FlavorType theType; Size dataSize; - if (!PyArg_ParseTuple(_args, "lO&", + if (!PyArg_ParseTuple(_args, "O&lO&", + DragObj_Convert, &theDrag, &theItemRef, PyMac_GetOSType, &theType)) return NULL; - _err = GetFlavorDataSize(_self->ob_itself, + _err = GetFlavorDataSize(theDrag, theItemRef, theType, &dataSize); @@ -318,19 +422,21 @@ static PyObject *DragObj_GetFlavorDataSize(_self, _args) return _res; } -static PyObject *DragObj_GetFlavorData(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetFlavorData(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; FlavorType theType; char *dataPtr__out__; long dataPtr__len__; int dataPtr__in_len__; UInt32 dataOffset; - if (!PyArg_ParseTuple(_args, "lO&il", + if (!PyArg_ParseTuple(_args, "O&lO&il", + DragObj_Convert, &theDrag, &theItemRef, PyMac_GetOSType, &theType, &dataPtr__in_len__, @@ -342,7 +448,7 @@ static PyObject *DragObj_GetFlavorData(_self, _args) goto dataPtr__error__; } dataPtr__len__ = dataPtr__in_len__; - _err = GetFlavorData(_self->ob_itself, + _err = GetFlavorData(theDrag, theItemRef, theType, dataPtr__out__, &dataPtr__len__, @@ -355,18 +461,20 @@ static PyObject *DragObj_GetFlavorData(_self, _args) return _res; } -static PyObject *DragObj_GetDragItemBounds(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDragItemBounds(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; Rect itemBounds; - if (!PyArg_ParseTuple(_args, "l", + if (!PyArg_ParseTuple(_args, "O&l", + DragObj_Convert, &theDrag, &theItemRef)) return NULL; - _err = GetDragItemBounds(_self->ob_itself, + _err = GetDragItemBounds(theDrag, theItemRef, &itemBounds); if (_err != noErr) return PyMac_Error(_err); @@ -375,19 +483,21 @@ static PyObject *DragObj_GetDragItemBounds(_self, _args) return _res; } -static PyObject *DragObj_SetDragItemBounds(_self, _args) - DragObjObject *_self; +static PyObject *Drag_SetDragItemBounds(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; ItemReference theItemRef; Rect itemBounds; - if (!PyArg_ParseTuple(_args, "lO&", + if (!PyArg_ParseTuple(_args, "O&lO&", + DragObj_Convert, &theDrag, &theItemRef, PyMac_GetRect, &itemBounds)) return NULL; - _err = SetDragItemBounds(_self->ob_itself, + _err = SetDragItemBounds(theDrag, theItemRef, &itemBounds); if (_err != noErr) return PyMac_Error(_err); @@ -396,16 +506,18 @@ static PyObject *DragObj_SetDragItemBounds(_self, _args) return _res; } -static PyObject *DragObj_GetDropLocation(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDropLocation(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; AEDesc dropLocation; - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = GetDropLocation(_self->ob_itself, + _err = GetDropLocation(theDrag, &dropLocation); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", @@ -413,17 +525,19 @@ static PyObject *DragObj_GetDropLocation(_self, _args) return _res; } -static PyObject *DragObj_SetDropLocation(_self, _args) - DragObjObject *_self; +static PyObject *Drag_SetDropLocation(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; AEDesc dropLocation; - if (!PyArg_ParseTuple(_args, "O&", + if (!PyArg_ParseTuple(_args, "O&O&", + DragObj_Convert, &theDrag, AEDesc_Convert, &dropLocation)) return NULL; - _err = SetDropLocation(_self->ob_itself, + _err = SetDropLocation(theDrag, &dropLocation); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); @@ -431,16 +545,18 @@ static PyObject *DragObj_SetDropLocation(_self, _args) return _res; } -static PyObject *DragObj_GetDragAttributes(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDragAttributes(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; DragAttributes flags; - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = GetDragAttributes(_self->ob_itself, + _err = GetDragAttributes(theDrag, &flags); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("l", @@ -448,17 +564,19 @@ static PyObject *DragObj_GetDragAttributes(_self, _args) return _res; } -static PyObject *DragObj_GetDragMouse(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDragMouse(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; Point mouse; Point globalPinnedMouse; - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = GetDragMouse(_self->ob_itself, + _err = GetDragMouse(theDrag, &mouse, &globalPinnedMouse); if (_err != noErr) return PyMac_Error(_err); @@ -468,17 +586,19 @@ static PyObject *DragObj_GetDragMouse(_self, _args) return _res; } -static PyObject *DragObj_SetDragMouse(_self, _args) - DragObjObject *_self; +static PyObject *Drag_SetDragMouse(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; Point globalPinnedMouse; - if (!PyArg_ParseTuple(_args, "O&", + if (!PyArg_ParseTuple(_args, "O&O&", + DragObj_Convert, &theDrag, PyMac_GetPoint, &globalPinnedMouse)) return NULL; - _err = SetDragMouse(_self->ob_itself, + _err = SetDragMouse(theDrag, globalPinnedMouse); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); @@ -486,16 +606,18 @@ static PyObject *DragObj_SetDragMouse(_self, _args) return _res; } -static PyObject *DragObj_GetDragOrigin(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDragOrigin(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; Point globalInitialMouse; - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = GetDragOrigin(_self->ob_itself, + _err = GetDragOrigin(theDrag, &globalInitialMouse); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", @@ -503,18 +625,20 @@ static PyObject *DragObj_GetDragOrigin(_self, _args) return _res; } -static PyObject *DragObj_GetDragModifiers(_self, _args) - DragObjObject *_self; +static PyObject *Drag_GetDragModifiers(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; SInt16 modifiers; SInt16 mouseDownModifiers; SInt16 mouseUpModifiers; - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = GetDragModifiers(_self->ob_itself, + _err = GetDragModifiers(theDrag, &modifiers, &mouseDownModifiers, &mouseUpModifiers); @@ -526,19 +650,21 @@ static PyObject *DragObj_GetDragModifiers(_self, _args) return _res; } -static PyObject *DragObj_ShowDragHilite(_self, _args) - DragObjObject *_self; +static PyObject *Drag_ShowDragHilite(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; RgnHandle hiliteFrame; Boolean inside; - if (!PyArg_ParseTuple(_args, "O&b", + if (!PyArg_ParseTuple(_args, "O&O&b", + DragObj_Convert, &theDrag, ResObj_Convert, &hiliteFrame, &inside)) return NULL; - _err = ShowDragHilite(_self->ob_itself, + _err = ShowDragHilite(theDrag, hiliteFrame, inside); if (_err != noErr) return PyMac_Error(_err); @@ -547,34 +673,38 @@ static PyObject *DragObj_ShowDragHilite(_self, _args) return _res; } -static PyObject *DragObj_HideDragHilite(_self, _args) - DragObjObject *_self; +static PyObject *Drag_HideDragHilite(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; - if (!PyArg_ParseTuple(_args, "")) + DragRef theDrag; + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = HideDragHilite(_self->ob_itself); + _err = HideDragHilite(theDrag); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *DragObj_DragPreScroll(_self, _args) - DragObjObject *_self; +static PyObject *Drag_DragPreScroll(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; SInt16 dH; SInt16 dV; - if (!PyArg_ParseTuple(_args, "hh", + if (!PyArg_ParseTuple(_args, "O&hh", + DragObj_Convert, &theDrag, &dH, &dV)) return NULL; - _err = DragPreScroll(_self->ob_itself, + _err = DragPreScroll(theDrag, dH, dV); if (_err != noErr) return PyMac_Error(_err); @@ -583,32 +713,36 @@ static PyObject *DragObj_DragPreScroll(_self, _args) return _res; } -static PyObject *DragObj_DragPostScroll(_self, _args) - DragObjObject *_self; +static PyObject *Drag_DragPostScroll(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; - if (!PyArg_ParseTuple(_args, "")) + DragRef theDrag; + if (!PyArg_ParseTuple(_args, "O&", + DragObj_Convert, &theDrag)) return NULL; - _err = DragPostScroll(_self->ob_itself); + _err = DragPostScroll(theDrag); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *DragObj_UpdateDragHilite(_self, _args) - DragObjObject *_self; +static PyObject *Drag_UpdateDragHilite(_self, _args) + PyObject *_self; PyObject *_args; { PyObject *_res = NULL; OSErr _err; + DragRef theDrag; RgnHandle updateRgn; - if (!PyArg_ParseTuple(_args, "O&", + if (!PyArg_ParseTuple(_args, "O&O&", + DragObj_Convert, &theDrag, ResObj_Convert, &updateRgn)) return NULL; - _err = UpdateDragHilite(_self->ob_itself, + _err = UpdateDragHilite(theDrag, updateRgn); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); @@ -616,117 +750,6 @@ static PyObject *DragObj_UpdateDragHilite(_self, _args) return _res; } -static PyMethodDef DragObj_methods[] = { - {"DisposeDrag", (PyCFunction)DragObj_DisposeDrag, 1, - "() -> None"}, - {"AddDragItemFlavor", (PyCFunction)DragObj_AddDragItemFlavor, 1, - "(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, FlavorFlags theFlags) -> None"}, - {"SetDragItemFlavorData", (PyCFunction)DragObj_SetDragItemFlavorData, 1, - "(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> None"}, - {"SetDragImage", (PyCFunction)DragObj_SetDragImage, 1, - "(PixMapHandle imagePixMap, RgnHandle imageRgn, Point imageOffsetPt, DragImageFlags theImageFlags) -> None"}, - {"TrackDrag", (PyCFunction)DragObj_TrackDrag, 1, - "(EventRecord theEvent, RgnHandle theRegion) -> None"}, - {"CountDragItems", (PyCFunction)DragObj_CountDragItems, 1, - "() -> (UInt16 numItems)"}, - {"GetDragItemReferenceNumber", (PyCFunction)DragObj_GetDragItemReferenceNumber, 1, - "(UInt16 index) -> (ItemReference theItemRef)"}, - {"CountDragItemFlavors", (PyCFunction)DragObj_CountDragItemFlavors, 1, - "(ItemReference theItemRef) -> (UInt16 numFlavors)"}, - {"GetFlavorType", (PyCFunction)DragObj_GetFlavorType, 1, - "(ItemReference theItemRef, UInt16 index) -> (FlavorType theType)"}, - {"GetFlavorFlags", (PyCFunction)DragObj_GetFlavorFlags, 1, - "(ItemReference theItemRef, FlavorType theType) -> (FlavorFlags theFlags)"}, - {"GetFlavorDataSize", (PyCFunction)DragObj_GetFlavorDataSize, 1, - "(ItemReference theItemRef, FlavorType theType) -> (Size dataSize)"}, - {"GetFlavorData", (PyCFunction)DragObj_GetFlavorData, 1, - "(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> (Buffer dataPtr)"}, - {"GetDragItemBounds", (PyCFunction)DragObj_GetDragItemBounds, 1, - "(ItemReference theItemRef) -> (Rect itemBounds)"}, - {"SetDragItemBounds", (PyCFunction)DragObj_SetDragItemBounds, 1, - "(ItemReference theItemRef, Rect itemBounds) -> None"}, - {"GetDropLocation", (PyCFunction)DragObj_GetDropLocation, 1, - "() -> (AEDesc dropLocation)"}, - {"SetDropLocation", (PyCFunction)DragObj_SetDropLocation, 1, - "(AEDesc dropLocation) -> None"}, - {"GetDragAttributes", (PyCFunction)DragObj_GetDragAttributes, 1, - "() -> (DragAttributes flags)"}, - {"GetDragMouse", (PyCFunction)DragObj_GetDragMouse, 1, - "() -> (Point mouse, Point globalPinnedMouse)"}, - {"SetDragMouse", (PyCFunction)DragObj_SetDragMouse, 1, - "(Point globalPinnedMouse) -> None"}, - {"GetDragOrigin", (PyCFunction)DragObj_GetDragOrigin, 1, - "() -> (Point globalInitialMouse)"}, - {"GetDragModifiers", (PyCFunction)DragObj_GetDragModifiers, 1, - "() -> (SInt16 modifiers, SInt16 mouseDownModifiers, SInt16 mouseUpModifiers)"}, - {"ShowDragHilite", (PyCFunction)DragObj_ShowDragHilite, 1, - "(RgnHandle hiliteFrame, Boolean inside) -> None"}, - {"HideDragHilite", (PyCFunction)DragObj_HideDragHilite, 1, - "() -> None"}, - {"DragPreScroll", (PyCFunction)DragObj_DragPreScroll, 1, - "(SInt16 dH, SInt16 dV) -> None"}, - {"DragPostScroll", (PyCFunction)DragObj_DragPostScroll, 1, - "() -> None"}, - {"UpdateDragHilite", (PyCFunction)DragObj_UpdateDragHilite, 1, - "(RgnHandle updateRgn) -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain DragObj_chain = { DragObj_methods, NULL }; - -static PyObject *DragObj_getattr(self, name) - DragObjObject *self; - char *name; -{ - return Py_FindMethodInChain(&DragObj_chain, (PyObject *)self, name); -} - -#define DragObj_setattr NULL - -#define DragObj_compare NULL - -#define DragObj_repr NULL - -#define DragObj_hash NULL - -PyTypeObject DragObj_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "DragObj", /*tp_name*/ - sizeof(DragObjObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) DragObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) DragObj_getattr, /*tp_getattr*/ - (setattrfunc) DragObj_setattr, /*tp_setattr*/ - (cmpfunc) DragObj_compare, /*tp_compare*/ - (reprfunc) DragObj_repr, /*tp_repr*/ - (PyNumberMethods *)0, /* tp_as_number */ - (PySequenceMethods *)0, /* tp_as_sequence */ - (PyMappingMethods *)0, /* tp_as_mapping */ - (hashfunc) DragObj_hash, /*tp_hash*/ -}; - -/* -------------------- End object type DragObj --------------------- */ - - -static PyObject *Drag_NewDrag(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSErr _err; - DragReference theDrag; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = NewDrag(&theDrag); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - DragObj_New, theDrag); - return _res; -} - static PyObject *Drag_GetDragHiliteColor(_self, _args) PyObject *_self; PyObject *_args; @@ -892,7 +915,61 @@ static PyObject *Drag_RemoveReceiveHandler(_self, _args) static PyMethodDef Drag_methods[] = { {"NewDrag", (PyCFunction)Drag_NewDrag, 1, - "() -> (DragReference theDrag)"}, + "() -> (DragRef theDrag)"}, + {"DisposeDrag", (PyCFunction)Drag_DisposeDrag, 1, + "(DragRef theDrag) -> None"}, + {"AddDragItemFlavor", (PyCFunction)Drag_AddDragItemFlavor, 1, + "(DragRef theDrag, ItemReference theItemRef, FlavorType theType, Buffer dataPtr, FlavorFlags theFlags) -> None"}, + {"SetDragItemFlavorData", (PyCFunction)Drag_SetDragItemFlavorData, 1, + "(DragRef theDrag, ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> None"}, + {"SetDragImage", (PyCFunction)Drag_SetDragImage, 1, + "(DragRef theDrag, PixMapHandle imagePixMap, RgnHandle imageRgn, Point imageOffsetPt, DragImageFlags theImageFlags) -> None"}, + {"ChangeDragBehaviors", (PyCFunction)Drag_ChangeDragBehaviors, 1, + "(DragRef theDrag, DragBehaviors inBehaviorsToSet, DragBehaviors inBehaviorsToClear) -> None"}, + {"TrackDrag", (PyCFunction)Drag_TrackDrag, 1, + "(DragRef theDrag, EventRecord theEvent, RgnHandle theRegion) -> None"}, + {"CountDragItems", (PyCFunction)Drag_CountDragItems, 1, + "(DragRef theDrag) -> (UInt16 numItems)"}, + {"GetDragItemReferenceNumber", (PyCFunction)Drag_GetDragItemReferenceNumber, 1, + "(DragRef theDrag, UInt16 index) -> (ItemReference theItemRef)"}, + {"CountDragItemFlavors", (PyCFunction)Drag_CountDragItemFlavors, 1, + "(DragRef theDrag, ItemReference theItemRef) -> (UInt16 numFlavors)"}, + {"GetFlavorType", (PyCFunction)Drag_GetFlavorType, 1, + "(DragRef theDrag, ItemReference theItemRef, UInt16 index) -> (FlavorType theType)"}, + {"GetFlavorFlags", (PyCFunction)Drag_GetFlavorFlags, 1, + "(DragRef theDrag, ItemReference theItemRef, FlavorType theType) -> (FlavorFlags theFlags)"}, + {"GetFlavorDataSize", (PyCFunction)Drag_GetFlavorDataSize, 1, + "(DragRef theDrag, ItemReference theItemRef, FlavorType theType) -> (Size dataSize)"}, + {"GetFlavorData", (PyCFunction)Drag_GetFlavorData, 1, + "(DragRef theDrag, ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> (Buffer dataPtr)"}, + {"GetDragItemBounds", (PyCFunction)Drag_GetDragItemBounds, 1, + "(DragRef theDrag, ItemReference theItemRef) -> (Rect itemBounds)"}, + {"SetDragItemBounds", (PyCFunction)Drag_SetDragItemBounds, 1, + "(DragRef theDrag, ItemReference theItemRef, Rect itemBounds) -> None"}, + {"GetDropLocation", (PyCFunction)Drag_GetDropLocation, 1, + "(DragRef theDrag) -> (AEDesc dropLocation)"}, + {"SetDropLocation", (PyCFunction)Drag_SetDropLocation, 1, + "(DragRef theDrag, AEDesc dropLocation) -> None"}, + {"GetDragAttributes", (PyCFunction)Drag_GetDragAttributes, 1, + "(DragRef theDrag) -> (DragAttributes flags)"}, + {"GetDragMouse", (PyCFunction)Drag_GetDragMouse, 1, + "(DragRef theDrag) -> (Point mouse, Point globalPinnedMouse)"}, + {"SetDragMouse", (PyCFunction)Drag_SetDragMouse, 1, + "(DragRef theDrag, Point globalPinnedMouse) -> None"}, + {"GetDragOrigin", (PyCFunction)Drag_GetDragOrigin, 1, + "(DragRef theDrag) -> (Point globalInitialMouse)"}, + {"GetDragModifiers", (PyCFunction)Drag_GetDragModifiers, 1, + "(DragRef theDrag) -> (SInt16 modifiers, SInt16 mouseDownModifiers, SInt16 mouseUpModifiers)"}, + {"ShowDragHilite", (PyCFunction)Drag_ShowDragHilite, 1, + "(DragRef theDrag, RgnHandle hiliteFrame, Boolean inside) -> None"}, + {"HideDragHilite", (PyCFunction)Drag_HideDragHilite, 1, + "(DragRef theDrag) -> None"}, + {"DragPreScroll", (PyCFunction)Drag_DragPreScroll, 1, + "(DragRef theDrag, SInt16 dH, SInt16 dV) -> None"}, + {"DragPostScroll", (PyCFunction)Drag_DragPostScroll, 1, + "(DragRef theDrag) -> None"}, + {"UpdateDragHilite", (PyCFunction)Drag_UpdateDragHilite, 1, + "(DragRef theDrag, RgnHandle updateRgn) -> None"}, {"GetDragHiliteColor", (PyCFunction)Drag_GetDragHiliteColor, 1, "(WindowPtr window) -> (RGBColor color)"}, {"WaitMouseMoved", (PyCFunction)Drag_WaitMouseMoved, 1, @@ -1023,7 +1100,7 @@ void initDrag() Drag_Error = PyMac_GetOSErrException(); if (Drag_Error == NULL || PyDict_SetItemString(d, "Error", Drag_Error) != 0) - Py_FatalError("can't initialize Drag.Error"); + return; DragObj_Type.ob_type = &PyType_Type; Py_INCREF(&DragObj_Type); if (PyDict_SetItemString(d, "DragObjType", (PyObject *)&DragObj_Type) != 0) diff --git a/Mac/Modules/drag/dragsupport.py b/Mac/Modules/drag/dragsupport.py index af8a255..d90acc9 100644 --- a/Mac/Modules/drag/dragsupport.py +++ b/Mac/Modules/drag/dragsupport.py @@ -12,7 +12,7 @@ OBJECTNAME = 'DragObj' # The basic name of the objects used here # The following is *usually* unchanged but may still require tuning MODPREFIX = MODNAME # The prefix for module-wide routines -OBJECTTYPE = 'DragReference' # The C type used to represent them +OBJECTTYPE = 'DragRef' # The C type used to represent them OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner OUTPUTFILE = MODNAME + "module.c" # The file generated by this program @@ -21,31 +21,21 @@ from macsupport import * # Create the type objects -DragReference = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) +DragRef = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) +DragItemRef = Type("ItemReference", "l") +# Old names +DragReference = DragRef +ItemReference = DragItemRef -##CCTabHandle = OpaqueByValueType("CCTabHandle", "ResObj") -##AuxCtlHandle = OpaqueByValueType("AuxCtlHandle", "ResObj") -##ControlPartCode = Type("ControlPartCode", "h") -##DragConstraint = Type("DragConstraint", "h") -##ControlVariant = Type("ControlVariant", "h") -##IconTransformType = Type("IconTransformType", "h") -##ControlButtonGraphicAlignment = Type("ControlButtonGraphicAlignment", "h") -##ControlButtonTextAlignment = Type("ControlButtonTextAlignment", "h") -##ControlButtonTextPlacement = Type("ControlButtonTextPlacement", "h") -##ControlContentType = Type("ControlContentType", "h") -##ControlFocusPart = Type("ControlFocusPart", "h") -## -##ControlFontStyleRec = OpaqueType('ControlFontStyleRec', 'ControlFontStyle') -##ControlFontStyleRec_ptr = ControlFontStyleRec PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj") RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") AEDesc = OpaqueType('AEDesc') AEDesc_ptr = AEDesc RGBColor = OpaqueType("RGBColor", "QdRGB") -ItemReference = Type("ItemReference", "l") FlavorType = OSTypeType("FlavorType") DragAttributes = Type("DragAttributes", "l") +DragBehaviors = Type("DragBehaviors", "l") DragImageFlags = Type("DragImageFlags", "l") DragImageTranslucency = Type("DragImageTranslucency", "l") DragRegionMessage = Type("DragRegionMessage", "h") |