1999-06-21 12:14:26 -03:00
|
|
|
|
|
|
|
/* ========================== Module Drag =========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "macglue.h"
|
2000-07-14 19:16:45 -03:00
|
|
|
#include "pymactoolbox.h"
|
1999-06-21 12:14:26 -03:00
|
|
|
|
|
|
|
#include <Drag.h>
|
|
|
|
|
|
|
|
/* Callback glue routines */
|
|
|
|
DragTrackingHandlerUPP dragglue_TrackingHandlerUPP;
|
|
|
|
DragReceiveHandlerUPP dragglue_ReceiveHandlerUPP;
|
|
|
|
DragSendDataUPP dragglue_SendDataUPP;
|
|
|
|
#if 0
|
|
|
|
DragInputUPP dragglue_InputUPP;
|
|
|
|
DragDrawingUPP dragglue_DrawingUPP;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static PyObject *Drag_Error;
|
|
|
|
|
|
|
|
/* ---------------------- Object type DragObj ----------------------- */
|
|
|
|
|
|
|
|
PyTypeObject DragObj_Type;
|
|
|
|
|
|
|
|
#define DragObj_Check(x) ((x)->ob_type == &DragObj_Type)
|
|
|
|
|
|
|
|
typedef struct DragObjObject {
|
|
|
|
PyObject_HEAD
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef ob_itself;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *sendproc;
|
|
|
|
} DragObjObject;
|
|
|
|
|
|
|
|
PyObject *DragObj_New(itself)
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef itself;
|
1999-06-21 12:14:26 -03:00
|
|
|
{
|
|
|
|
DragObjObject *it;
|
|
|
|
if (itself == NULL) {
|
|
|
|
PyErr_SetString(Drag_Error,"Cannot create null Drag");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
it = PyObject_NEW(DragObjObject, &DragObj_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
|
|
|
it->sendproc = NULL;
|
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
|
|
|
DragObj_Convert(v, p_itself)
|
|
|
|
PyObject *v;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef *p_itself;
|
1999-06-21 12:14:26 -03:00
|
|
|
{
|
|
|
|
if (!DragObj_Check(v))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "DragObj required");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*p_itself = ((DragObjObject *)v)->ob_itself;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DragObj_dealloc(self)
|
|
|
|
DragObjObject *self;
|
|
|
|
{
|
|
|
|
Py_XDECREF(self->sendproc);
|
|
|
|
PyMem_DEL(self);
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
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;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_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);
|
1999-06-21 12:14:26 -03:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_AddDragItemFlavor(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
FlavorType theType;
|
|
|
|
char *dataPtr__in__;
|
|
|
|
long dataPtr__len__;
|
|
|
|
int dataPtr__in_len__;
|
|
|
|
FlavorFlags theFlags;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lO&z#l",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
PyMac_GetOSType, &theType,
|
|
|
|
&dataPtr__in__, &dataPtr__in_len__,
|
|
|
|
&theFlags))
|
|
|
|
return NULL;
|
|
|
|
dataPtr__len__ = dataPtr__in_len__;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = AddDragItemFlavor(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
theType,
|
|
|
|
dataPtr__in__, dataPtr__len__,
|
|
|
|
theFlags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
dataPtr__error__: ;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_SetDragItemFlavorData(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
FlavorType theType;
|
|
|
|
char *dataPtr__in__;
|
|
|
|
long dataPtr__len__;
|
|
|
|
int dataPtr__in_len__;
|
|
|
|
UInt32 dataOffset;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lO&z#l",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
PyMac_GetOSType, &theType,
|
|
|
|
&dataPtr__in__, &dataPtr__in_len__,
|
|
|
|
&dataOffset))
|
|
|
|
return NULL;
|
|
|
|
dataPtr__len__ = dataPtr__in_len__;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = SetDragItemFlavorData(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
theType,
|
|
|
|
dataPtr__in__, dataPtr__len__,
|
|
|
|
dataOffset);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
dataPtr__error__: ;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_SetDragImage(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
PixMapHandle imagePixMap;
|
|
|
|
RgnHandle imageRgn;
|
|
|
|
Point imageOffsetPt;
|
|
|
|
DragImageFlags theImageFlags;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&O&l",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
ResObj_Convert, &imagePixMap,
|
|
|
|
ResObj_Convert, &imageRgn,
|
|
|
|
PyMac_GetPoint, &imageOffsetPt,
|
|
|
|
&theImageFlags))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = SetDragImage(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
imagePixMap,
|
|
|
|
imageRgn,
|
|
|
|
imageOffsetPt,
|
|
|
|
theImageFlags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
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;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
EventRecord theEvent;
|
|
|
|
RgnHandle theRegion;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
PyMac_GetEventRecord, &theEvent,
|
|
|
|
ResObj_Convert, &theRegion))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = TrackDrag(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theEvent,
|
|
|
|
theRegion);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_CountDragItems(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
UInt16 numItems;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = CountDragItems(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&numItems);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
2000-07-07 10:09:35 -03:00
|
|
|
_res = Py_BuildValue("H",
|
1999-06-21 12:14:26 -03:00
|
|
|
numItems);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDragItemReferenceNumber(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
UInt16 index;
|
|
|
|
ItemReference theItemRef;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&H",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&index))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDragItemReferenceNumber(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
index,
|
|
|
|
&theItemRef);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
theItemRef);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_CountDragItemFlavors(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
UInt16 numFlavors;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&l",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = CountDragItemFlavors(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
&numFlavors);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
2000-07-07 10:09:35 -03:00
|
|
|
_res = Py_BuildValue("H",
|
1999-06-21 12:14:26 -03:00
|
|
|
numFlavors);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetFlavorType(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
UInt16 index;
|
|
|
|
FlavorType theType;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lH",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
&index))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetFlavorType(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
index,
|
|
|
|
&theType);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildOSType, theType);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetFlavorFlags(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
FlavorType theType;
|
|
|
|
FlavorFlags theFlags;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lO&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
PyMac_GetOSType, &theType))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetFlavorFlags(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
theType,
|
|
|
|
&theFlags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
theFlags);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetFlavorDataSize(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
FlavorType theType;
|
|
|
|
Size dataSize;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lO&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
PyMac_GetOSType, &theType))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetFlavorDataSize(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
theType,
|
|
|
|
&dataSize);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
dataSize);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetFlavorData(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
FlavorType theType;
|
|
|
|
char *dataPtr__out__;
|
|
|
|
long dataPtr__len__;
|
|
|
|
int dataPtr__in_len__;
|
|
|
|
UInt32 dataOffset;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lO&il",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
PyMac_GetOSType, &theType,
|
|
|
|
&dataPtr__in_len__,
|
|
|
|
&dataOffset))
|
|
|
|
return NULL;
|
|
|
|
if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL)
|
|
|
|
{
|
|
|
|
PyErr_NoMemory();
|
|
|
|
goto dataPtr__error__;
|
|
|
|
}
|
|
|
|
dataPtr__len__ = dataPtr__in_len__;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetFlavorData(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
theType,
|
|
|
|
dataPtr__out__, &dataPtr__len__,
|
|
|
|
dataOffset);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("s#",
|
|
|
|
dataPtr__out__, (int)dataPtr__len__);
|
|
|
|
free(dataPtr__out__);
|
|
|
|
dataPtr__error__: ;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDragItemBounds(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
Rect itemBounds;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&l",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDragItemBounds(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
&itemBounds);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildRect, &itemBounds);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_SetDragItemBounds(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
ItemReference theItemRef;
|
|
|
|
Rect itemBounds;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&lO&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&theItemRef,
|
|
|
|
PyMac_GetRect, &itemBounds))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = SetDragItemBounds(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
theItemRef,
|
|
|
|
&itemBounds);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDropLocation(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
AEDesc dropLocation;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDropLocation(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&dropLocation);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
AEDesc_New, &dropLocation);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_SetDropLocation(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
AEDesc dropLocation;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
AEDesc_Convert, &dropLocation))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = SetDropLocation(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&dropLocation);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDragAttributes(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
DragAttributes flags;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDragAttributes(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&flags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
flags);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDragMouse(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
Point mouse;
|
|
|
|
Point globalPinnedMouse;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDragMouse(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&mouse,
|
|
|
|
&globalPinnedMouse);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&O&",
|
|
|
|
PyMac_BuildPoint, mouse,
|
|
|
|
PyMac_BuildPoint, globalPinnedMouse);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_SetDragMouse(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
Point globalPinnedMouse;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
PyMac_GetPoint, &globalPinnedMouse))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = SetDragMouse(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
globalPinnedMouse);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDragOrigin(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
Point globalInitialMouse;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDragOrigin(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&globalInitialMouse);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildPoint, globalInitialMouse);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_GetDragModifiers(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
SInt16 modifiers;
|
|
|
|
SInt16 mouseDownModifiers;
|
|
|
|
SInt16 mouseUpModifiers;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = GetDragModifiers(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&modifiers,
|
|
|
|
&mouseDownModifiers,
|
|
|
|
&mouseUpModifiers);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("hhh",
|
|
|
|
modifiers,
|
|
|
|
mouseDownModifiers,
|
|
|
|
mouseUpModifiers);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_ShowDragHilite(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
RgnHandle hiliteFrame;
|
|
|
|
Boolean inside;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&b",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
ResObj_Convert, &hiliteFrame,
|
|
|
|
&inside))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = ShowDragHilite(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
hiliteFrame,
|
|
|
|
inside);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_HideDragHilite(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = HideDragHilite(theDrag);
|
1999-06-21 12:14:26 -03:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_DragPreScroll(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
SInt16 dH;
|
|
|
|
SInt16 dV;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&hh",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
&dH,
|
|
|
|
&dV))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = DragPreScroll(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
dH,
|
|
|
|
dV);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_DragPostScroll(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
DragObj_Convert, &theDrag))
|
1999-06-21 12:14:26 -03:00
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = DragPostScroll(theDrag);
|
1999-06-21 12:14:26 -03:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-12-10 19:43:49 -04:00
|
|
|
static PyObject *Drag_UpdateDragHilite(_self, _args)
|
|
|
|
PyObject *_self;
|
1999-06-21 12:14:26 -03:00
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2000-12-10 19:43:49 -04:00
|
|
|
DragRef theDrag;
|
1999-06-21 12:14:26 -03:00
|
|
|
RgnHandle updateRgn;
|
2000-12-10 19:43:49 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
DragObj_Convert, &theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
ResObj_Convert, &updateRgn))
|
|
|
|
return NULL;
|
2000-12-10 19:43:49 -04:00
|
|
|
_err = UpdateDragHilite(theDrag,
|
1999-06-21 12:14:26 -03:00
|
|
|
updateRgn);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_GetDragHiliteColor(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr window;
|
|
|
|
RGBColor color;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &window))
|
|
|
|
return NULL;
|
|
|
|
_err = GetDragHiliteColor(window,
|
|
|
|
&color);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
QdRGB_New, &color);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_WaitMouseMoved(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
Point initialMouse;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetPoint, &initialMouse))
|
|
|
|
return NULL;
|
|
|
|
_rv = WaitMouseMoved(initialMouse);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_ZoomRects(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Rect fromRect;
|
|
|
|
Rect toRect;
|
|
|
|
SInt16 zoomSteps;
|
|
|
|
ZoomAcceleration acceleration;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&hh",
|
|
|
|
PyMac_GetRect, &fromRect,
|
|
|
|
PyMac_GetRect, &toRect,
|
|
|
|
&zoomSteps,
|
|
|
|
&acceleration))
|
|
|
|
return NULL;
|
|
|
|
_err = ZoomRects(&fromRect,
|
|
|
|
&toRect,
|
|
|
|
zoomSteps,
|
|
|
|
acceleration);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_ZoomRegion(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
RgnHandle region;
|
|
|
|
Point zoomDistance;
|
|
|
|
SInt16 zoomSteps;
|
|
|
|
ZoomAcceleration acceleration;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&hh",
|
|
|
|
ResObj_Convert, ®ion,
|
|
|
|
PyMac_GetPoint, &zoomDistance,
|
|
|
|
&zoomSteps,
|
|
|
|
&acceleration))
|
|
|
|
return NULL;
|
|
|
|
_err = ZoomRegion(region,
|
|
|
|
zoomDistance,
|
|
|
|
zoomSteps,
|
|
|
|
acceleration);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_InstallTrackingHandler(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
PyObject *callback;
|
|
|
|
WindowPtr theWindow = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
|
|
|
|
if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) )
|
|
|
|
return NULL;
|
|
|
|
Py_INCREF(callback); /* Cannot decref later, too bad */
|
|
|
|
_err = InstallTrackingHandler(dragglue_TrackingHandlerUPP, theWindow, (void *)callback);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_InstallReceiveHandler(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
PyObject *callback;
|
|
|
|
WindowPtr theWindow = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
|
|
|
|
if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) )
|
|
|
|
return NULL;
|
|
|
|
Py_INCREF(callback); /* Cannot decref later, too bad */
|
|
|
|
_err = InstallReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow, (void *)callback);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_RemoveTrackingHandler(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
WindowPtr theWindow = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
|
|
|
|
if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) )
|
|
|
|
return NULL;
|
|
|
|
_err = RemoveTrackingHandler(dragglue_TrackingHandlerUPP, theWindow);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Drag_RemoveReceiveHandler(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
WindowPtr theWindow = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
|
|
|
|
if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) )
|
|
|
|
return NULL;
|
|
|
|
_err = RemoveReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Drag_methods[] = {
|
|
|
|
{"NewDrag", (PyCFunction)Drag_NewDrag, 1,
|
2000-12-10 19:43:49 -04:00
|
|
|
"() -> (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"},
|
1999-06-21 12:14:26 -03:00
|
|
|
{"GetDragHiliteColor", (PyCFunction)Drag_GetDragHiliteColor, 1,
|
|
|
|
"(WindowPtr window) -> (RGBColor color)"},
|
|
|
|
{"WaitMouseMoved", (PyCFunction)Drag_WaitMouseMoved, 1,
|
|
|
|
"(Point initialMouse) -> (Boolean _rv)"},
|
|
|
|
{"ZoomRects", (PyCFunction)Drag_ZoomRects, 1,
|
|
|
|
"(Rect fromRect, Rect toRect, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None"},
|
|
|
|
{"ZoomRegion", (PyCFunction)Drag_ZoomRegion, 1,
|
|
|
|
"(RgnHandle region, Point zoomDistance, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None"},
|
|
|
|
{"InstallTrackingHandler", (PyCFunction)Drag_InstallTrackingHandler, 1,
|
|
|
|
NULL},
|
|
|
|
{"InstallReceiveHandler", (PyCFunction)Drag_InstallReceiveHandler, 1,
|
|
|
|
NULL},
|
|
|
|
{"RemoveTrackingHandler", (PyCFunction)Drag_RemoveTrackingHandler, 1,
|
|
|
|
NULL},
|
|
|
|
{"RemoveReceiveHandler", (PyCFunction)Drag_RemoveReceiveHandler, 1,
|
|
|
|
NULL},
|
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static pascal OSErr
|
|
|
|
dragglue_TrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
|
|
|
|
void *handlerRefCon, DragReference theDrag)
|
|
|
|
{
|
|
|
|
PyObject *args, *rv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
|
|
|
|
if ( args == NULL )
|
|
|
|
return -1;
|
|
|
|
rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
|
|
|
|
Py_DECREF(args);
|
1999-06-21 13:18:51 -03:00
|
|
|
if ( rv == NULL ) {
|
|
|
|
fprintf(stderr, "Drag: Exception in TrackingHandler\n");
|
1999-06-21 12:14:26 -03:00
|
|
|
return -1;
|
1999-06-21 13:18:51 -03:00
|
|
|
}
|
1999-06-21 12:14:26 -03:00
|
|
|
i = -1;
|
|
|
|
if ( rv == Py_None )
|
|
|
|
i = 0;
|
|
|
|
else
|
|
|
|
PyArg_Parse(rv, "l", &i);
|
|
|
|
Py_DECREF(rv);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal OSErr
|
|
|
|
dragglue_ReceiveHandler(WindowPtr theWindow, void *handlerRefCon,
|
|
|
|
DragReference theDrag)
|
|
|
|
{
|
|
|
|
PyObject *args, *rv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow);
|
|
|
|
if ( args == NULL )
|
|
|
|
return -1;
|
|
|
|
rv = PyEval_CallObject((PyObject *)handlerRefCon, args);
|
|
|
|
Py_DECREF(args);
|
1999-06-21 13:18:51 -03:00
|
|
|
if ( rv == NULL ) {
|
|
|
|
fprintf(stderr, "Drag: Exception in ReceiveHandler\n");
|
1999-06-21 12:14:26 -03:00
|
|
|
return -1;
|
1999-06-21 13:18:51 -03:00
|
|
|
}
|
1999-06-21 12:14:26 -03:00
|
|
|
i = -1;
|
|
|
|
if ( rv == Py_None )
|
|
|
|
i = 0;
|
|
|
|
else
|
|
|
|
PyArg_Parse(rv, "l", &i);
|
|
|
|
Py_DECREF(rv);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal OSErr
|
|
|
|
dragglue_SendData(FlavorType theType, void *dragSendRefCon,
|
|
|
|
ItemReference theItem, DragReference theDrag)
|
|
|
|
{
|
|
|
|
DragObjObject *self = (DragObjObject *)dragSendRefCon;
|
|
|
|
PyObject *args, *rv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( self->sendproc == NULL )
|
|
|
|
return -1;
|
|
|
|
args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem);
|
|
|
|
if ( args == NULL )
|
|
|
|
return -1;
|
|
|
|
rv = PyEval_CallObject(self->sendproc, args);
|
|
|
|
Py_DECREF(args);
|
1999-06-21 13:18:51 -03:00
|
|
|
if ( rv == NULL ) {
|
|
|
|
fprintf(stderr, "Drag: Exception in SendDataHandler\n");
|
1999-06-21 12:14:26 -03:00
|
|
|
return -1;
|
1999-06-21 13:18:51 -03:00
|
|
|
}
|
1999-06-21 12:14:26 -03:00
|
|
|
i = -1;
|
|
|
|
if ( rv == Py_None )
|
|
|
|
i = 0;
|
|
|
|
else
|
|
|
|
PyArg_Parse(rv, "l", &i);
|
|
|
|
Py_DECREF(rv);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static pascal OSErr
|
|
|
|
dragglue_Input(Point *mouse, short *modifiers,
|
|
|
|
void *dragSendRefCon, DragReference theDrag)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal OSErr
|
|
|
|
dragglue_Drawing(xxxx
|
|
|
|
void *dragSendRefCon, DragReference theDrag)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void initDrag()
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m = Py_InitModule("Drag", Drag_methods);
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Drag_Error = PyMac_GetOSErrException();
|
|
|
|
if (Drag_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Drag_Error) != 0)
|
2000-12-10 19:43:49 -04:00
|
|
|
return;
|
1999-06-21 12:14:26 -03:00
|
|
|
DragObj_Type.ob_type = &PyType_Type;
|
|
|
|
Py_INCREF(&DragObj_Type);
|
|
|
|
if (PyDict_SetItemString(d, "DragObjType", (PyObject *)&DragObj_Type) != 0)
|
|
|
|
Py_FatalError("can't initialize DragObjType");
|
|
|
|
|
|
|
|
dragglue_TrackingHandlerUPP = NewDragTrackingHandlerProc(dragglue_TrackingHandler);
|
|
|
|
dragglue_ReceiveHandlerUPP = NewDragReceiveHandlerProc(dragglue_ReceiveHandler);
|
|
|
|
dragglue_SendDataUPP = NewDragSendDataProc(dragglue_SendData);
|
|
|
|
#if 0
|
|
|
|
dragglue_InputUPP = NewDragInputProc(dragglue_Input);
|
|
|
|
dragglue_DrawingUPP = NewDragDrawingProc(dragglue_Drawing);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================== End module Drag ========================= */
|
|
|
|
|