Kaydet (Commit) ecdaadb7 authored tarafından Jack Jansen's avatar Jack Jansen

Also recognize DragRef as a method-argument.

üst 6a360bd3
...@@ -67,104 +67,41 @@ static void DragObj_dealloc(self) ...@@ -67,104 +67,41 @@ static void DragObj_dealloc(self)
PyMem_DEL(self); PyMem_DEL(self);
} }
static PyMethodDef DragObj_methods[] = { static PyObject *DragObj_DisposeDrag(_self, _args)
{NULL, NULL, 0} DragObjObject *_self;
};
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 *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_err = NewDrag(&theDrag); _err = DisposeDrag(_self->ob_itself);
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); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
_res = Py_None; _res = Py_None;
return _res; return _res;
} }
static PyObject *Drag_AddDragItemFlavor(_self, _args) static PyObject *DragObj_AddDragItemFlavor(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
FlavorType theType; FlavorType theType;
char *dataPtr__in__; char *dataPtr__in__;
long dataPtr__len__; long dataPtr__len__;
int dataPtr__in_len__; int dataPtr__in_len__;
FlavorFlags theFlags; FlavorFlags theFlags;
if (!PyArg_ParseTuple(_args, "O&lO&z#l", if (!PyArg_ParseTuple(_args, "lO&z#l",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
PyMac_GetOSType, &theType, PyMac_GetOSType, &theType,
&dataPtr__in__, &dataPtr__in_len__, &dataPtr__in__, &dataPtr__in_len__,
&theFlags)) &theFlags))
return NULL; return NULL;
dataPtr__len__ = dataPtr__in_len__; dataPtr__len__ = dataPtr__in_len__;
_err = AddDragItemFlavor(theDrag, _err = AddDragItemFlavor(_self->ob_itself,
theItemRef, theItemRef,
theType, theType,
dataPtr__in__, dataPtr__len__, dataPtr__in__, dataPtr__len__,
...@@ -176,28 +113,26 @@ static PyObject *Drag_AddDragItemFlavor(_self, _args) ...@@ -176,28 +113,26 @@ static PyObject *Drag_AddDragItemFlavor(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_SetDragItemFlavorData(_self, _args) static PyObject *DragObj_SetDragItemFlavorData(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
FlavorType theType; FlavorType theType;
char *dataPtr__in__; char *dataPtr__in__;
long dataPtr__len__; long dataPtr__len__;
int dataPtr__in_len__; int dataPtr__in_len__;
UInt32 dataOffset; UInt32 dataOffset;
if (!PyArg_ParseTuple(_args, "O&lO&z#l", if (!PyArg_ParseTuple(_args, "lO&z#l",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
PyMac_GetOSType, &theType, PyMac_GetOSType, &theType,
&dataPtr__in__, &dataPtr__in_len__, &dataPtr__in__, &dataPtr__in_len__,
&dataOffset)) &dataOffset))
return NULL; return NULL;
dataPtr__len__ = dataPtr__in_len__; dataPtr__len__ = dataPtr__in_len__;
_err = SetDragItemFlavorData(theDrag, _err = SetDragItemFlavorData(_self->ob_itself,
theItemRef, theItemRef,
theType, theType,
dataPtr__in__, dataPtr__len__, dataPtr__in__, dataPtr__len__,
...@@ -209,25 +144,23 @@ static PyObject *Drag_SetDragItemFlavorData(_self, _args) ...@@ -209,25 +144,23 @@ static PyObject *Drag_SetDragItemFlavorData(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_SetDragImage(_self, _args) static PyObject *DragObj_SetDragImage(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
PixMapHandle imagePixMap; PixMapHandle imagePixMap;
RgnHandle imageRgn; RgnHandle imageRgn;
Point imageOffsetPt; Point imageOffsetPt;
DragImageFlags theImageFlags; DragImageFlags theImageFlags;
if (!PyArg_ParseTuple(_args, "O&O&O&O&l", if (!PyArg_ParseTuple(_args, "O&O&O&l",
DragObj_Convert, &theDrag,
ResObj_Convert, &imagePixMap, ResObj_Convert, &imagePixMap,
ResObj_Convert, &imageRgn, ResObj_Convert, &imageRgn,
PyMac_GetPoint, &imageOffsetPt, PyMac_GetPoint, &imageOffsetPt,
&theImageFlags)) &theImageFlags))
return NULL; return NULL;
_err = SetDragImage(theDrag, _err = SetDragImage(_self->ob_itself,
imagePixMap, imagePixMap,
imageRgn, imageRgn,
imageOffsetPt, imageOffsetPt,
...@@ -238,21 +171,19 @@ static PyObject *Drag_SetDragImage(_self, _args) ...@@ -238,21 +171,19 @@ static PyObject *Drag_SetDragImage(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_ChangeDragBehaviors(_self, _args) static PyObject *DragObj_ChangeDragBehaviors(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
DragBehaviors inBehaviorsToSet; DragBehaviors inBehaviorsToSet;
DragBehaviors inBehaviorsToClear; DragBehaviors inBehaviorsToClear;
if (!PyArg_ParseTuple(_args, "O&ll", if (!PyArg_ParseTuple(_args, "ll",
DragObj_Convert, &theDrag,
&inBehaviorsToSet, &inBehaviorsToSet,
&inBehaviorsToClear)) &inBehaviorsToClear))
return NULL; return NULL;
_err = ChangeDragBehaviors(theDrag, _err = ChangeDragBehaviors(_self->ob_itself,
inBehaviorsToSet, inBehaviorsToSet,
inBehaviorsToClear); inBehaviorsToClear);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -261,21 +192,19 @@ static PyObject *Drag_ChangeDragBehaviors(_self, _args) ...@@ -261,21 +192,19 @@ static PyObject *Drag_ChangeDragBehaviors(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_TrackDrag(_self, _args) static PyObject *DragObj_TrackDrag(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
EventRecord theEvent; EventRecord theEvent;
RgnHandle theRegion; RgnHandle theRegion;
if (!PyArg_ParseTuple(_args, "O&O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
DragObj_Convert, &theDrag,
PyMac_GetEventRecord, &theEvent, PyMac_GetEventRecord, &theEvent,
ResObj_Convert, &theRegion)) ResObj_Convert, &theRegion))
return NULL; return NULL;
_err = TrackDrag(theDrag, _err = TrackDrag(_self->ob_itself,
&theEvent, &theEvent,
theRegion); theRegion);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -284,18 +213,16 @@ static PyObject *Drag_TrackDrag(_self, _args) ...@@ -284,18 +213,16 @@ static PyObject *Drag_TrackDrag(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_CountDragItems(_self, _args) static PyObject *DragObj_CountDragItems(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
UInt16 numItems; UInt16 numItems;
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, ""))
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = CountDragItems(theDrag, _err = CountDragItems(_self->ob_itself,
&numItems); &numItems);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("H", _res = Py_BuildValue("H",
...@@ -303,20 +230,18 @@ static PyObject *Drag_CountDragItems(_self, _args) ...@@ -303,20 +230,18 @@ static PyObject *Drag_CountDragItems(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDragItemReferenceNumber(_self, _args) static PyObject *DragObj_GetDragItemReferenceNumber(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
UInt16 index; UInt16 index;
ItemReference theItemRef; ItemReference theItemRef;
if (!PyArg_ParseTuple(_args, "O&H", if (!PyArg_ParseTuple(_args, "H",
DragObj_Convert, &theDrag,
&index)) &index))
return NULL; return NULL;
_err = GetDragItemReferenceNumber(theDrag, _err = GetDragItemReferenceNumber(_self->ob_itself,
index, index,
&theItemRef); &theItemRef);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -325,20 +250,18 @@ static PyObject *Drag_GetDragItemReferenceNumber(_self, _args) ...@@ -325,20 +250,18 @@ static PyObject *Drag_GetDragItemReferenceNumber(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_CountDragItemFlavors(_self, _args) static PyObject *DragObj_CountDragItemFlavors(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
UInt16 numFlavors; UInt16 numFlavors;
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "l",
DragObj_Convert, &theDrag,
&theItemRef)) &theItemRef))
return NULL; return NULL;
_err = CountDragItemFlavors(theDrag, _err = CountDragItemFlavors(_self->ob_itself,
theItemRef, theItemRef,
&numFlavors); &numFlavors);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -347,22 +270,20 @@ static PyObject *Drag_CountDragItemFlavors(_self, _args) ...@@ -347,22 +270,20 @@ static PyObject *Drag_CountDragItemFlavors(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetFlavorType(_self, _args) static PyObject *DragObj_GetFlavorType(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
UInt16 index; UInt16 index;
FlavorType theType; FlavorType theType;
if (!PyArg_ParseTuple(_args, "O&lH", if (!PyArg_ParseTuple(_args, "lH",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
&index)) &index))
return NULL; return NULL;
_err = GetFlavorType(theDrag, _err = GetFlavorType(_self->ob_itself,
theItemRef, theItemRef,
index, index,
&theType); &theType);
...@@ -372,22 +293,20 @@ static PyObject *Drag_GetFlavorType(_self, _args) ...@@ -372,22 +293,20 @@ static PyObject *Drag_GetFlavorType(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetFlavorFlags(_self, _args) static PyObject *DragObj_GetFlavorFlags(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
FlavorType theType; FlavorType theType;
FlavorFlags theFlags; FlavorFlags theFlags;
if (!PyArg_ParseTuple(_args, "O&lO&", if (!PyArg_ParseTuple(_args, "lO&",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
PyMac_GetOSType, &theType)) PyMac_GetOSType, &theType))
return NULL; return NULL;
_err = GetFlavorFlags(theDrag, _err = GetFlavorFlags(_self->ob_itself,
theItemRef, theItemRef,
theType, theType,
&theFlags); &theFlags);
...@@ -397,22 +316,20 @@ static PyObject *Drag_GetFlavorFlags(_self, _args) ...@@ -397,22 +316,20 @@ static PyObject *Drag_GetFlavorFlags(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetFlavorDataSize(_self, _args) static PyObject *DragObj_GetFlavorDataSize(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
FlavorType theType; FlavorType theType;
Size dataSize; Size dataSize;
if (!PyArg_ParseTuple(_args, "O&lO&", if (!PyArg_ParseTuple(_args, "lO&",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
PyMac_GetOSType, &theType)) PyMac_GetOSType, &theType))
return NULL; return NULL;
_err = GetFlavorDataSize(theDrag, _err = GetFlavorDataSize(_self->ob_itself,
theItemRef, theItemRef,
theType, theType,
&dataSize); &dataSize);
...@@ -422,21 +339,19 @@ static PyObject *Drag_GetFlavorDataSize(_self, _args) ...@@ -422,21 +339,19 @@ static PyObject *Drag_GetFlavorDataSize(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetFlavorData(_self, _args) static PyObject *DragObj_GetFlavorData(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
FlavorType theType; FlavorType theType;
char *dataPtr__out__; char *dataPtr__out__;
long dataPtr__len__; long dataPtr__len__;
int dataPtr__in_len__; int dataPtr__in_len__;
UInt32 dataOffset; UInt32 dataOffset;
if (!PyArg_ParseTuple(_args, "O&lO&il", if (!PyArg_ParseTuple(_args, "lO&il",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
PyMac_GetOSType, &theType, PyMac_GetOSType, &theType,
&dataPtr__in_len__, &dataPtr__in_len__,
...@@ -448,7 +363,7 @@ static PyObject *Drag_GetFlavorData(_self, _args) ...@@ -448,7 +363,7 @@ static PyObject *Drag_GetFlavorData(_self, _args)
goto dataPtr__error__; goto dataPtr__error__;
} }
dataPtr__len__ = dataPtr__in_len__; dataPtr__len__ = dataPtr__in_len__;
_err = GetFlavorData(theDrag, _err = GetFlavorData(_self->ob_itself,
theItemRef, theItemRef,
theType, theType,
dataPtr__out__, &dataPtr__len__, dataPtr__out__, &dataPtr__len__,
...@@ -461,20 +376,18 @@ static PyObject *Drag_GetFlavorData(_self, _args) ...@@ -461,20 +376,18 @@ static PyObject *Drag_GetFlavorData(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDragItemBounds(_self, _args) static PyObject *DragObj_GetDragItemBounds(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
Rect itemBounds; Rect itemBounds;
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "l",
DragObj_Convert, &theDrag,
&theItemRef)) &theItemRef))
return NULL; return NULL;
_err = GetDragItemBounds(theDrag, _err = GetDragItemBounds(_self->ob_itself,
theItemRef, theItemRef,
&itemBounds); &itemBounds);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -483,21 +396,19 @@ static PyObject *Drag_GetDragItemBounds(_self, _args) ...@@ -483,21 +396,19 @@ static PyObject *Drag_GetDragItemBounds(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_SetDragItemBounds(_self, _args) static PyObject *DragObj_SetDragItemBounds(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
ItemReference theItemRef; ItemReference theItemRef;
Rect itemBounds; Rect itemBounds;
if (!PyArg_ParseTuple(_args, "O&lO&", if (!PyArg_ParseTuple(_args, "lO&",
DragObj_Convert, &theDrag,
&theItemRef, &theItemRef,
PyMac_GetRect, &itemBounds)) PyMac_GetRect, &itemBounds))
return NULL; return NULL;
_err = SetDragItemBounds(theDrag, _err = SetDragItemBounds(_self->ob_itself,
theItemRef, theItemRef,
&itemBounds); &itemBounds);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -506,18 +417,16 @@ static PyObject *Drag_SetDragItemBounds(_self, _args) ...@@ -506,18 +417,16 @@ static PyObject *Drag_SetDragItemBounds(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDropLocation(_self, _args) static PyObject *DragObj_GetDropLocation(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
AEDesc dropLocation; AEDesc dropLocation;
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, ""))
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = GetDropLocation(theDrag, _err = GetDropLocation(_self->ob_itself,
&dropLocation); &dropLocation);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&", _res = Py_BuildValue("O&",
...@@ -525,19 +434,17 @@ static PyObject *Drag_GetDropLocation(_self, _args) ...@@ -525,19 +434,17 @@ static PyObject *Drag_GetDropLocation(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_SetDropLocation(_self, _args) static PyObject *DragObj_SetDropLocation(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
AEDesc dropLocation; AEDesc dropLocation;
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&",
DragObj_Convert, &theDrag,
AEDesc_Convert, &dropLocation)) AEDesc_Convert, &dropLocation))
return NULL; return NULL;
_err = SetDropLocation(theDrag, _err = SetDropLocation(_self->ob_itself,
&dropLocation); &dropLocation);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -545,18 +452,16 @@ static PyObject *Drag_SetDropLocation(_self, _args) ...@@ -545,18 +452,16 @@ static PyObject *Drag_SetDropLocation(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDragAttributes(_self, _args) static PyObject *DragObj_GetDragAttributes(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
DragAttributes flags; DragAttributes flags;
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, ""))
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = GetDragAttributes(theDrag, _err = GetDragAttributes(_self->ob_itself,
&flags); &flags);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("l", _res = Py_BuildValue("l",
...@@ -564,19 +469,17 @@ static PyObject *Drag_GetDragAttributes(_self, _args) ...@@ -564,19 +469,17 @@ static PyObject *Drag_GetDragAttributes(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDragMouse(_self, _args) static PyObject *DragObj_GetDragMouse(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
Point mouse; Point mouse;
Point globalPinnedMouse; Point globalPinnedMouse;
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, ""))
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = GetDragMouse(theDrag, _err = GetDragMouse(_self->ob_itself,
&mouse, &mouse,
&globalPinnedMouse); &globalPinnedMouse);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -586,19 +489,17 @@ static PyObject *Drag_GetDragMouse(_self, _args) ...@@ -586,19 +489,17 @@ static PyObject *Drag_GetDragMouse(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_SetDragMouse(_self, _args) static PyObject *DragObj_SetDragMouse(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
Point globalPinnedMouse; Point globalPinnedMouse;
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&",
DragObj_Convert, &theDrag,
PyMac_GetPoint, &globalPinnedMouse)) PyMac_GetPoint, &globalPinnedMouse))
return NULL; return NULL;
_err = SetDragMouse(theDrag, _err = SetDragMouse(_self->ob_itself,
globalPinnedMouse); globalPinnedMouse);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -606,18 +507,16 @@ static PyObject *Drag_SetDragMouse(_self, _args) ...@@ -606,18 +507,16 @@ static PyObject *Drag_SetDragMouse(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDragOrigin(_self, _args) static PyObject *DragObj_GetDragOrigin(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
Point globalInitialMouse; Point globalInitialMouse;
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, ""))
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = GetDragOrigin(theDrag, _err = GetDragOrigin(_self->ob_itself,
&globalInitialMouse); &globalInitialMouse);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&", _res = Py_BuildValue("O&",
...@@ -625,20 +524,18 @@ static PyObject *Drag_GetDragOrigin(_self, _args) ...@@ -625,20 +524,18 @@ static PyObject *Drag_GetDragOrigin(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_GetDragModifiers(_self, _args) static PyObject *DragObj_GetDragModifiers(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
SInt16 modifiers; SInt16 modifiers;
SInt16 mouseDownModifiers; SInt16 mouseDownModifiers;
SInt16 mouseUpModifiers; SInt16 mouseUpModifiers;
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, ""))
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = GetDragModifiers(theDrag, _err = GetDragModifiers(_self->ob_itself,
&modifiers, &modifiers,
&mouseDownModifiers, &mouseDownModifiers,
&mouseUpModifiers); &mouseUpModifiers);
...@@ -650,21 +547,19 @@ static PyObject *Drag_GetDragModifiers(_self, _args) ...@@ -650,21 +547,19 @@ static PyObject *Drag_GetDragModifiers(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_ShowDragHilite(_self, _args) static PyObject *DragObj_ShowDragHilite(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
RgnHandle hiliteFrame; RgnHandle hiliteFrame;
Boolean inside; Boolean inside;
if (!PyArg_ParseTuple(_args, "O&O&b", if (!PyArg_ParseTuple(_args, "O&b",
DragObj_Convert, &theDrag,
ResObj_Convert, &hiliteFrame, ResObj_Convert, &hiliteFrame,
&inside)) &inside))
return NULL; return NULL;
_err = ShowDragHilite(theDrag, _err = ShowDragHilite(_self->ob_itself,
hiliteFrame, hiliteFrame,
inside); inside);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -673,38 +568,34 @@ static PyObject *Drag_ShowDragHilite(_self, _args) ...@@ -673,38 +568,34 @@ static PyObject *Drag_ShowDragHilite(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_HideDragHilite(_self, _args) static PyObject *DragObj_HideDragHilite(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag; if (!PyArg_ParseTuple(_args, ""))
if (!PyArg_ParseTuple(_args, "O&",
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = HideDragHilite(theDrag); _err = HideDragHilite(_self->ob_itself);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
_res = Py_None; _res = Py_None;
return _res; return _res;
} }
static PyObject *Drag_DragPreScroll(_self, _args) static PyObject *DragObj_DragPreScroll(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
SInt16 dH; SInt16 dH;
SInt16 dV; SInt16 dV;
if (!PyArg_ParseTuple(_args, "O&hh", if (!PyArg_ParseTuple(_args, "hh",
DragObj_Convert, &theDrag,
&dH, &dH,
&dV)) &dV))
return NULL; return NULL;
_err = DragPreScroll(theDrag, _err = DragPreScroll(_self->ob_itself,
dH, dH,
dV); dV);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
...@@ -713,36 +604,32 @@ static PyObject *Drag_DragPreScroll(_self, _args) ...@@ -713,36 +604,32 @@ static PyObject *Drag_DragPreScroll(_self, _args)
return _res; return _res;
} }
static PyObject *Drag_DragPostScroll(_self, _args) static PyObject *DragObj_DragPostScroll(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag; if (!PyArg_ParseTuple(_args, ""))
if (!PyArg_ParseTuple(_args, "O&",
DragObj_Convert, &theDrag))
return NULL; return NULL;
_err = DragPostScroll(theDrag); _err = DragPostScroll(_self->ob_itself);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
_res = Py_None; _res = Py_None;
return _res; return _res;
} }
static PyObject *Drag_UpdateDragHilite(_self, _args) static PyObject *DragObj_UpdateDragHilite(_self, _args)
PyObject *_self; DragObjObject *_self;
PyObject *_args; PyObject *_args;
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSErr _err; OSErr _err;
DragRef theDrag;
RgnHandle updateRgn; RgnHandle updateRgn;
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&",
DragObj_Convert, &theDrag,
ResObj_Convert, &updateRgn)) ResObj_Convert, &updateRgn))
return NULL; return NULL;
_err = UpdateDragHilite(theDrag, _err = UpdateDragHilite(_self->ob_itself,
updateRgn); updateRgn);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -750,6 +637,119 @@ static PyObject *Drag_UpdateDragHilite(_self, _args) ...@@ -750,6 +637,119 @@ static PyObject *Drag_UpdateDragHilite(_self, _args)
return _res; 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"},
{"ChangeDragBehaviors", (PyCFunction)DragObj_ChangeDragBehaviors, 1,
"(DragBehaviors inBehaviorsToSet, DragBehaviors inBehaviorsToClear) -> 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;
DragRef 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) static PyObject *Drag_GetDragHiliteColor(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
...@@ -916,60 +916,6 @@ static PyObject *Drag_RemoveReceiveHandler(_self, _args) ...@@ -916,60 +916,6 @@ static PyObject *Drag_RemoveReceiveHandler(_self, _args)
static PyMethodDef Drag_methods[] = { static PyMethodDef Drag_methods[] = {
{"NewDrag", (PyCFunction)Drag_NewDrag, 1, {"NewDrag", (PyCFunction)Drag_NewDrag, 1,
"() -> (DragRef 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, {"GetDragHiliteColor", (PyCFunction)Drag_GetDragHiliteColor, 1,
"(WindowPtr window) -> (RGBColor color)"}, "(WindowPtr window) -> (RGBColor color)"},
{"WaitMouseMoved", (PyCFunction)Drag_WaitMouseMoved, 1, {"WaitMouseMoved", (PyCFunction)Drag_WaitMouseMoved, 1,
......
...@@ -37,7 +37,7 @@ class MyScanner(Scanner): ...@@ -37,7 +37,7 @@ class MyScanner(Scanner):
listname = "functions" listname = "functions"
if arglist: if arglist:
t, n, m = arglist[0] t, n, m = arglist[0]
if t == 'DragReference' and m == "InMode": if t in ('DragReference', 'DragRef') and m == "InMode":
classname = "Method" classname = "Method"
listname = "methods" listname = "methods"
return classname, listname return classname, listname
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment