| 1 | n/a | |
|---|
| 2 | n/a | /* ========================== Module _Drag ========================== */ |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | #include "Python.h" |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | #ifndef __LP64__ |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | |
|---|
| 9 | n/a | #include "pymactoolbox.h" |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | /* Macro to test whether a weak-loaded CFM function exists */ |
|---|
| 12 | n/a | #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ |
|---|
| 13 | n/a | PyErr_SetString(PyExc_NotImplementedError, \ |
|---|
| 14 | n/a | "Not available in this shared library/OS version"); \ |
|---|
| 15 | n/a | return NULL; \ |
|---|
| 16 | n/a | }} while(0) |
|---|
| 17 | n/a | |
|---|
| 18 | n/a | |
|---|
| 19 | n/a | #include <Carbon/Carbon.h> |
|---|
| 20 | n/a | |
|---|
| 21 | n/a | /* Callback glue routines */ |
|---|
| 22 | n/a | DragTrackingHandlerUPP dragglue_TrackingHandlerUPP; |
|---|
| 23 | n/a | DragReceiveHandlerUPP dragglue_ReceiveHandlerUPP; |
|---|
| 24 | n/a | DragSendDataUPP dragglue_SendDataUPP; |
|---|
| 25 | n/a | #if 0 |
|---|
| 26 | n/a | DragInputUPP dragglue_InputUPP; |
|---|
| 27 | n/a | DragDrawingUPP dragglue_DrawingUPP; |
|---|
| 28 | n/a | #endif |
|---|
| 29 | n/a | |
|---|
| 30 | n/a | #ifdef USE_TOOLBOX_OBJECT_GLUE |
|---|
| 31 | n/a | extern PyObject *_DragObj_New(DragRef); |
|---|
| 32 | n/a | extern int _DragObj_Convert(PyObject *, DragRef *); |
|---|
| 33 | n/a | |
|---|
| 34 | n/a | #define DragObj_New _DragObj_New |
|---|
| 35 | n/a | #define DragObj_Convert _DragObj_Convert |
|---|
| 36 | n/a | #endif |
|---|
| 37 | n/a | |
|---|
| 38 | n/a | static PyObject *Drag_Error; |
|---|
| 39 | n/a | |
|---|
| 40 | n/a | /* ---------------------- Object type DragObj ----------------------- */ |
|---|
| 41 | n/a | |
|---|
| 42 | n/a | PyTypeObject DragObj_Type; |
|---|
| 43 | n/a | |
|---|
| 44 | n/a | #define DragObj_Check(x) ((x)->ob_type == &DragObj_Type || PyObject_TypeCheck((x), &DragObj_Type)) |
|---|
| 45 | n/a | |
|---|
| 46 | n/a | typedef struct DragObjObject { |
|---|
| 47 | n/a | PyObject_HEAD |
|---|
| 48 | n/a | DragRef ob_itself; |
|---|
| 49 | n/a | PyObject *sendproc; |
|---|
| 50 | n/a | } DragObjObject; |
|---|
| 51 | n/a | |
|---|
| 52 | n/a | PyObject *DragObj_New(DragRef itself) |
|---|
| 53 | n/a | { |
|---|
| 54 | n/a | DragObjObject *it; |
|---|
| 55 | n/a | if (itself == NULL) { |
|---|
| 56 | n/a | PyErr_SetString(Drag_Error,"Cannot create null Drag"); |
|---|
| 57 | n/a | return NULL; |
|---|
| 58 | n/a | } |
|---|
| 59 | n/a | it = PyObject_NEW(DragObjObject, &DragObj_Type); |
|---|
| 60 | n/a | if (it == NULL) return NULL; |
|---|
| 61 | n/a | it->ob_itself = itself; |
|---|
| 62 | n/a | it->sendproc = NULL; |
|---|
| 63 | n/a | return (PyObject *)it; |
|---|
| 64 | n/a | } |
|---|
| 65 | n/a | |
|---|
| 66 | n/a | int DragObj_Convert(PyObject *v, DragRef *p_itself) |
|---|
| 67 | n/a | { |
|---|
| 68 | n/a | if (!DragObj_Check(v)) |
|---|
| 69 | n/a | { |
|---|
| 70 | n/a | PyErr_SetString(PyExc_TypeError, "DragObj required"); |
|---|
| 71 | n/a | return 0; |
|---|
| 72 | n/a | } |
|---|
| 73 | n/a | *p_itself = ((DragObjObject *)v)->ob_itself; |
|---|
| 74 | n/a | return 1; |
|---|
| 75 | n/a | } |
|---|
| 76 | n/a | |
|---|
| 77 | n/a | static void DragObj_dealloc(DragObjObject *self) |
|---|
| 78 | n/a | { |
|---|
| 79 | n/a | Py_XDECREF(self->sendproc); |
|---|
| 80 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 81 | n/a | } |
|---|
| 82 | n/a | |
|---|
| 83 | n/a | static PyObject *DragObj_DisposeDrag(DragObjObject *_self, PyObject *_args) |
|---|
| 84 | n/a | { |
|---|
| 85 | n/a | PyObject *_res = NULL; |
|---|
| 86 | n/a | OSErr _err; |
|---|
| 87 | n/a | #ifndef DisposeDrag |
|---|
| 88 | n/a | PyMac_PRECHECK(DisposeDrag); |
|---|
| 89 | n/a | #endif |
|---|
| 90 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 91 | n/a | return NULL; |
|---|
| 92 | n/a | _err = DisposeDrag(_self->ob_itself); |
|---|
| 93 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 94 | n/a | Py_INCREF(Py_None); |
|---|
| 95 | n/a | _res = Py_None; |
|---|
| 96 | n/a | return _res; |
|---|
| 97 | n/a | } |
|---|
| 98 | n/a | |
|---|
| 99 | n/a | static PyObject *DragObj_AddDragItemFlavor(DragObjObject *_self, PyObject *_args) |
|---|
| 100 | n/a | { |
|---|
| 101 | n/a | PyObject *_res = NULL; |
|---|
| 102 | n/a | OSErr _err; |
|---|
| 103 | n/a | ItemReference theItemRef; |
|---|
| 104 | n/a | FlavorType theType; |
|---|
| 105 | n/a | char *dataPtr__in__; |
|---|
| 106 | n/a | long dataPtr__len__; |
|---|
| 107 | n/a | int dataPtr__in_len__; |
|---|
| 108 | n/a | FlavorFlags theFlags; |
|---|
| 109 | n/a | #ifndef AddDragItemFlavor |
|---|
| 110 | n/a | PyMac_PRECHECK(AddDragItemFlavor); |
|---|
| 111 | n/a | #endif |
|---|
| 112 | n/a | if (!PyArg_ParseTuple(_args, "lO&z#l", |
|---|
| 113 | n/a | &theItemRef, |
|---|
| 114 | n/a | PyMac_GetOSType, &theType, |
|---|
| 115 | n/a | &dataPtr__in__, &dataPtr__in_len__, |
|---|
| 116 | n/a | &theFlags)) |
|---|
| 117 | n/a | return NULL; |
|---|
| 118 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 119 | n/a | _err = AddDragItemFlavor(_self->ob_itself, |
|---|
| 120 | n/a | theItemRef, |
|---|
| 121 | n/a | theType, |
|---|
| 122 | n/a | dataPtr__in__, dataPtr__len__, |
|---|
| 123 | n/a | theFlags); |
|---|
| 124 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 125 | n/a | Py_INCREF(Py_None); |
|---|
| 126 | n/a | _res = Py_None; |
|---|
| 127 | n/a | return _res; |
|---|
| 128 | n/a | } |
|---|
| 129 | n/a | |
|---|
| 130 | n/a | static PyObject *DragObj_SetDragItemFlavorData(DragObjObject *_self, PyObject *_args) |
|---|
| 131 | n/a | { |
|---|
| 132 | n/a | PyObject *_res = NULL; |
|---|
| 133 | n/a | OSErr _err; |
|---|
| 134 | n/a | ItemReference theItemRef; |
|---|
| 135 | n/a | FlavorType theType; |
|---|
| 136 | n/a | char *dataPtr__in__; |
|---|
| 137 | n/a | long dataPtr__len__; |
|---|
| 138 | n/a | int dataPtr__in_len__; |
|---|
| 139 | n/a | UInt32 dataOffset; |
|---|
| 140 | n/a | #ifndef SetDragItemFlavorData |
|---|
| 141 | n/a | PyMac_PRECHECK(SetDragItemFlavorData); |
|---|
| 142 | n/a | #endif |
|---|
| 143 | n/a | if (!PyArg_ParseTuple(_args, "lO&z#l", |
|---|
| 144 | n/a | &theItemRef, |
|---|
| 145 | n/a | PyMac_GetOSType, &theType, |
|---|
| 146 | n/a | &dataPtr__in__, &dataPtr__in_len__, |
|---|
| 147 | n/a | &dataOffset)) |
|---|
| 148 | n/a | return NULL; |
|---|
| 149 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 150 | n/a | _err = SetDragItemFlavorData(_self->ob_itself, |
|---|
| 151 | n/a | theItemRef, |
|---|
| 152 | n/a | theType, |
|---|
| 153 | n/a | dataPtr__in__, dataPtr__len__, |
|---|
| 154 | n/a | dataOffset); |
|---|
| 155 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 156 | n/a | Py_INCREF(Py_None); |
|---|
| 157 | n/a | _res = Py_None; |
|---|
| 158 | n/a | return _res; |
|---|
| 159 | n/a | } |
|---|
| 160 | n/a | |
|---|
| 161 | n/a | static PyObject *DragObj_SetDragImage(DragObjObject *_self, PyObject *_args) |
|---|
| 162 | n/a | { |
|---|
| 163 | n/a | PyObject *_res = NULL; |
|---|
| 164 | n/a | OSErr _err; |
|---|
| 165 | n/a | PixMapHandle imagePixMap; |
|---|
| 166 | n/a | RgnHandle imageRgn; |
|---|
| 167 | n/a | Point imageOffsetPt; |
|---|
| 168 | n/a | DragImageFlags theImageFlags; |
|---|
| 169 | n/a | #ifndef SetDragImage |
|---|
| 170 | n/a | PyMac_PRECHECK(SetDragImage); |
|---|
| 171 | n/a | #endif |
|---|
| 172 | n/a | if (!PyArg_ParseTuple(_args, "O&O&O&l", |
|---|
| 173 | n/a | ResObj_Convert, &imagePixMap, |
|---|
| 174 | n/a | ResObj_Convert, &imageRgn, |
|---|
| 175 | n/a | PyMac_GetPoint, &imageOffsetPt, |
|---|
| 176 | n/a | &theImageFlags)) |
|---|
| 177 | n/a | return NULL; |
|---|
| 178 | n/a | _err = SetDragImage(_self->ob_itself, |
|---|
| 179 | n/a | imagePixMap, |
|---|
| 180 | n/a | imageRgn, |
|---|
| 181 | n/a | imageOffsetPt, |
|---|
| 182 | n/a | theImageFlags); |
|---|
| 183 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 184 | n/a | Py_INCREF(Py_None); |
|---|
| 185 | n/a | _res = Py_None; |
|---|
| 186 | n/a | return _res; |
|---|
| 187 | n/a | } |
|---|
| 188 | n/a | |
|---|
| 189 | n/a | static PyObject *DragObj_ChangeDragBehaviors(DragObjObject *_self, PyObject *_args) |
|---|
| 190 | n/a | { |
|---|
| 191 | n/a | PyObject *_res = NULL; |
|---|
| 192 | n/a | OSErr _err; |
|---|
| 193 | n/a | DragBehaviors inBehaviorsToSet; |
|---|
| 194 | n/a | DragBehaviors inBehaviorsToClear; |
|---|
| 195 | n/a | #ifndef ChangeDragBehaviors |
|---|
| 196 | n/a | PyMac_PRECHECK(ChangeDragBehaviors); |
|---|
| 197 | n/a | #endif |
|---|
| 198 | n/a | if (!PyArg_ParseTuple(_args, "ll", |
|---|
| 199 | n/a | &inBehaviorsToSet, |
|---|
| 200 | n/a | &inBehaviorsToClear)) |
|---|
| 201 | n/a | return NULL; |
|---|
| 202 | n/a | _err = ChangeDragBehaviors(_self->ob_itself, |
|---|
| 203 | n/a | inBehaviorsToSet, |
|---|
| 204 | n/a | inBehaviorsToClear); |
|---|
| 205 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 206 | n/a | Py_INCREF(Py_None); |
|---|
| 207 | n/a | _res = Py_None; |
|---|
| 208 | n/a | return _res; |
|---|
| 209 | n/a | } |
|---|
| 210 | n/a | |
|---|
| 211 | n/a | static PyObject *DragObj_TrackDrag(DragObjObject *_self, PyObject *_args) |
|---|
| 212 | n/a | { |
|---|
| 213 | n/a | PyObject *_res = NULL; |
|---|
| 214 | n/a | OSErr _err; |
|---|
| 215 | n/a | EventRecord theEvent; |
|---|
| 216 | n/a | RgnHandle theRegion; |
|---|
| 217 | n/a | #ifndef TrackDrag |
|---|
| 218 | n/a | PyMac_PRECHECK(TrackDrag); |
|---|
| 219 | n/a | #endif |
|---|
| 220 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 221 | n/a | PyMac_GetEventRecord, &theEvent, |
|---|
| 222 | n/a | ResObj_Convert, &theRegion)) |
|---|
| 223 | n/a | return NULL; |
|---|
| 224 | n/a | _err = TrackDrag(_self->ob_itself, |
|---|
| 225 | n/a | &theEvent, |
|---|
| 226 | n/a | theRegion); |
|---|
| 227 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 228 | n/a | Py_INCREF(Py_None); |
|---|
| 229 | n/a | _res = Py_None; |
|---|
| 230 | n/a | return _res; |
|---|
| 231 | n/a | } |
|---|
| 232 | n/a | |
|---|
| 233 | n/a | static PyObject *DragObj_CountDragItems(DragObjObject *_self, PyObject *_args) |
|---|
| 234 | n/a | { |
|---|
| 235 | n/a | PyObject *_res = NULL; |
|---|
| 236 | n/a | OSErr _err; |
|---|
| 237 | n/a | UInt16 numItems; |
|---|
| 238 | n/a | #ifndef CountDragItems |
|---|
| 239 | n/a | PyMac_PRECHECK(CountDragItems); |
|---|
| 240 | n/a | #endif |
|---|
| 241 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 242 | n/a | return NULL; |
|---|
| 243 | n/a | _err = CountDragItems(_self->ob_itself, |
|---|
| 244 | n/a | &numItems); |
|---|
| 245 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 246 | n/a | _res = Py_BuildValue("H", |
|---|
| 247 | n/a | numItems); |
|---|
| 248 | n/a | return _res; |
|---|
| 249 | n/a | } |
|---|
| 250 | n/a | |
|---|
| 251 | n/a | static PyObject *DragObj_GetDragItemReferenceNumber(DragObjObject *_self, PyObject *_args) |
|---|
| 252 | n/a | { |
|---|
| 253 | n/a | PyObject *_res = NULL; |
|---|
| 254 | n/a | OSErr _err; |
|---|
| 255 | n/a | UInt16 index; |
|---|
| 256 | n/a | ItemReference theItemRef; |
|---|
| 257 | n/a | #ifndef GetDragItemReferenceNumber |
|---|
| 258 | n/a | PyMac_PRECHECK(GetDragItemReferenceNumber); |
|---|
| 259 | n/a | #endif |
|---|
| 260 | n/a | if (!PyArg_ParseTuple(_args, "H", |
|---|
| 261 | n/a | &index)) |
|---|
| 262 | n/a | return NULL; |
|---|
| 263 | n/a | _err = GetDragItemReferenceNumber(_self->ob_itself, |
|---|
| 264 | n/a | index, |
|---|
| 265 | n/a | &theItemRef); |
|---|
| 266 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 267 | n/a | _res = Py_BuildValue("l", |
|---|
| 268 | n/a | theItemRef); |
|---|
| 269 | n/a | return _res; |
|---|
| 270 | n/a | } |
|---|
| 271 | n/a | |
|---|
| 272 | n/a | static PyObject *DragObj_CountDragItemFlavors(DragObjObject *_self, PyObject *_args) |
|---|
| 273 | n/a | { |
|---|
| 274 | n/a | PyObject *_res = NULL; |
|---|
| 275 | n/a | OSErr _err; |
|---|
| 276 | n/a | ItemReference theItemRef; |
|---|
| 277 | n/a | UInt16 numFlavors; |
|---|
| 278 | n/a | #ifndef CountDragItemFlavors |
|---|
| 279 | n/a | PyMac_PRECHECK(CountDragItemFlavors); |
|---|
| 280 | n/a | #endif |
|---|
| 281 | n/a | if (!PyArg_ParseTuple(_args, "l", |
|---|
| 282 | n/a | &theItemRef)) |
|---|
| 283 | n/a | return NULL; |
|---|
| 284 | n/a | _err = CountDragItemFlavors(_self->ob_itself, |
|---|
| 285 | n/a | theItemRef, |
|---|
| 286 | n/a | &numFlavors); |
|---|
| 287 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 288 | n/a | _res = Py_BuildValue("H", |
|---|
| 289 | n/a | numFlavors); |
|---|
| 290 | n/a | return _res; |
|---|
| 291 | n/a | } |
|---|
| 292 | n/a | |
|---|
| 293 | n/a | static PyObject *DragObj_GetFlavorType(DragObjObject *_self, PyObject *_args) |
|---|
| 294 | n/a | { |
|---|
| 295 | n/a | PyObject *_res = NULL; |
|---|
| 296 | n/a | OSErr _err; |
|---|
| 297 | n/a | ItemReference theItemRef; |
|---|
| 298 | n/a | UInt16 index; |
|---|
| 299 | n/a | FlavorType theType; |
|---|
| 300 | n/a | #ifndef GetFlavorType |
|---|
| 301 | n/a | PyMac_PRECHECK(GetFlavorType); |
|---|
| 302 | n/a | #endif |
|---|
| 303 | n/a | if (!PyArg_ParseTuple(_args, "lH", |
|---|
| 304 | n/a | &theItemRef, |
|---|
| 305 | n/a | &index)) |
|---|
| 306 | n/a | return NULL; |
|---|
| 307 | n/a | _err = GetFlavorType(_self->ob_itself, |
|---|
| 308 | n/a | theItemRef, |
|---|
| 309 | n/a | index, |
|---|
| 310 | n/a | &theType); |
|---|
| 311 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 312 | n/a | _res = Py_BuildValue("O&", |
|---|
| 313 | n/a | PyMac_BuildOSType, theType); |
|---|
| 314 | n/a | return _res; |
|---|
| 315 | n/a | } |
|---|
| 316 | n/a | |
|---|
| 317 | n/a | static PyObject *DragObj_GetFlavorFlags(DragObjObject *_self, PyObject *_args) |
|---|
| 318 | n/a | { |
|---|
| 319 | n/a | PyObject *_res = NULL; |
|---|
| 320 | n/a | OSErr _err; |
|---|
| 321 | n/a | ItemReference theItemRef; |
|---|
| 322 | n/a | FlavorType theType; |
|---|
| 323 | n/a | FlavorFlags theFlags; |
|---|
| 324 | n/a | #ifndef GetFlavorFlags |
|---|
| 325 | n/a | PyMac_PRECHECK(GetFlavorFlags); |
|---|
| 326 | n/a | #endif |
|---|
| 327 | n/a | if (!PyArg_ParseTuple(_args, "lO&", |
|---|
| 328 | n/a | &theItemRef, |
|---|
| 329 | n/a | PyMac_GetOSType, &theType)) |
|---|
| 330 | n/a | return NULL; |
|---|
| 331 | n/a | _err = GetFlavorFlags(_self->ob_itself, |
|---|
| 332 | n/a | theItemRef, |
|---|
| 333 | n/a | theType, |
|---|
| 334 | n/a | &theFlags); |
|---|
| 335 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 336 | n/a | _res = Py_BuildValue("l", |
|---|
| 337 | n/a | theFlags); |
|---|
| 338 | n/a | return _res; |
|---|
| 339 | n/a | } |
|---|
| 340 | n/a | |
|---|
| 341 | n/a | static PyObject *DragObj_GetFlavorDataSize(DragObjObject *_self, PyObject *_args) |
|---|
| 342 | n/a | { |
|---|
| 343 | n/a | PyObject *_res = NULL; |
|---|
| 344 | n/a | OSErr _err; |
|---|
| 345 | n/a | ItemReference theItemRef; |
|---|
| 346 | n/a | FlavorType theType; |
|---|
| 347 | n/a | Size dataSize; |
|---|
| 348 | n/a | #ifndef GetFlavorDataSize |
|---|
| 349 | n/a | PyMac_PRECHECK(GetFlavorDataSize); |
|---|
| 350 | n/a | #endif |
|---|
| 351 | n/a | if (!PyArg_ParseTuple(_args, "lO&", |
|---|
| 352 | n/a | &theItemRef, |
|---|
| 353 | n/a | PyMac_GetOSType, &theType)) |
|---|
| 354 | n/a | return NULL; |
|---|
| 355 | n/a | _err = GetFlavorDataSize(_self->ob_itself, |
|---|
| 356 | n/a | theItemRef, |
|---|
| 357 | n/a | theType, |
|---|
| 358 | n/a | &dataSize); |
|---|
| 359 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 360 | n/a | _res = Py_BuildValue("l", |
|---|
| 361 | n/a | dataSize); |
|---|
| 362 | n/a | return _res; |
|---|
| 363 | n/a | } |
|---|
| 364 | n/a | |
|---|
| 365 | n/a | static PyObject *DragObj_GetFlavorData(DragObjObject *_self, PyObject *_args) |
|---|
| 366 | n/a | { |
|---|
| 367 | n/a | PyObject *_res = NULL; |
|---|
| 368 | n/a | OSErr _err; |
|---|
| 369 | n/a | ItemReference theItemRef; |
|---|
| 370 | n/a | FlavorType theType; |
|---|
| 371 | n/a | char *dataPtr__out__; |
|---|
| 372 | n/a | long dataPtr__len__; |
|---|
| 373 | n/a | int dataPtr__in_len__; |
|---|
| 374 | n/a | UInt32 dataOffset; |
|---|
| 375 | n/a | #ifndef GetFlavorData |
|---|
| 376 | n/a | PyMac_PRECHECK(GetFlavorData); |
|---|
| 377 | n/a | #endif |
|---|
| 378 | n/a | if (!PyArg_ParseTuple(_args, "lO&il", |
|---|
| 379 | n/a | &theItemRef, |
|---|
| 380 | n/a | PyMac_GetOSType, &theType, |
|---|
| 381 | n/a | &dataPtr__in_len__, |
|---|
| 382 | n/a | &dataOffset)) |
|---|
| 383 | n/a | return NULL; |
|---|
| 384 | n/a | if ((dataPtr__out__ = malloc(dataPtr__in_len__)) == NULL) |
|---|
| 385 | n/a | { |
|---|
| 386 | n/a | PyErr_NoMemory(); |
|---|
| 387 | n/a | goto dataPtr__error__; |
|---|
| 388 | n/a | } |
|---|
| 389 | n/a | dataPtr__len__ = dataPtr__in_len__; |
|---|
| 390 | n/a | _err = GetFlavorData(_self->ob_itself, |
|---|
| 391 | n/a | theItemRef, |
|---|
| 392 | n/a | theType, |
|---|
| 393 | n/a | dataPtr__out__, &dataPtr__len__, |
|---|
| 394 | n/a | dataOffset); |
|---|
| 395 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 396 | n/a | _res = Py_BuildValue("s#", |
|---|
| 397 | n/a | dataPtr__out__, (int)dataPtr__len__); |
|---|
| 398 | n/a | free(dataPtr__out__); |
|---|
| 399 | n/a | dataPtr__error__: ; |
|---|
| 400 | n/a | return _res; |
|---|
| 401 | n/a | } |
|---|
| 402 | n/a | |
|---|
| 403 | n/a | static PyObject *DragObj_GetDragItemBounds(DragObjObject *_self, PyObject *_args) |
|---|
| 404 | n/a | { |
|---|
| 405 | n/a | PyObject *_res = NULL; |
|---|
| 406 | n/a | OSErr _err; |
|---|
| 407 | n/a | ItemReference theItemRef; |
|---|
| 408 | n/a | Rect itemBounds; |
|---|
| 409 | n/a | #ifndef GetDragItemBounds |
|---|
| 410 | n/a | PyMac_PRECHECK(GetDragItemBounds); |
|---|
| 411 | n/a | #endif |
|---|
| 412 | n/a | if (!PyArg_ParseTuple(_args, "l", |
|---|
| 413 | n/a | &theItemRef)) |
|---|
| 414 | n/a | return NULL; |
|---|
| 415 | n/a | _err = GetDragItemBounds(_self->ob_itself, |
|---|
| 416 | n/a | theItemRef, |
|---|
| 417 | n/a | &itemBounds); |
|---|
| 418 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 419 | n/a | _res = Py_BuildValue("O&", |
|---|
| 420 | n/a | PyMac_BuildRect, &itemBounds); |
|---|
| 421 | n/a | return _res; |
|---|
| 422 | n/a | } |
|---|
| 423 | n/a | |
|---|
| 424 | n/a | static PyObject *DragObj_SetDragItemBounds(DragObjObject *_self, PyObject *_args) |
|---|
| 425 | n/a | { |
|---|
| 426 | n/a | PyObject *_res = NULL; |
|---|
| 427 | n/a | OSErr _err; |
|---|
| 428 | n/a | ItemReference theItemRef; |
|---|
| 429 | n/a | Rect itemBounds; |
|---|
| 430 | n/a | #ifndef SetDragItemBounds |
|---|
| 431 | n/a | PyMac_PRECHECK(SetDragItemBounds); |
|---|
| 432 | n/a | #endif |
|---|
| 433 | n/a | if (!PyArg_ParseTuple(_args, "lO&", |
|---|
| 434 | n/a | &theItemRef, |
|---|
| 435 | n/a | PyMac_GetRect, &itemBounds)) |
|---|
| 436 | n/a | return NULL; |
|---|
| 437 | n/a | _err = SetDragItemBounds(_self->ob_itself, |
|---|
| 438 | n/a | theItemRef, |
|---|
| 439 | n/a | &itemBounds); |
|---|
| 440 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 441 | n/a | Py_INCREF(Py_None); |
|---|
| 442 | n/a | _res = Py_None; |
|---|
| 443 | n/a | return _res; |
|---|
| 444 | n/a | } |
|---|
| 445 | n/a | |
|---|
| 446 | n/a | static PyObject *DragObj_GetDropLocation(DragObjObject *_self, PyObject *_args) |
|---|
| 447 | n/a | { |
|---|
| 448 | n/a | PyObject *_res = NULL; |
|---|
| 449 | n/a | OSErr _err; |
|---|
| 450 | n/a | AEDesc dropLocation; |
|---|
| 451 | n/a | #ifndef GetDropLocation |
|---|
| 452 | n/a | PyMac_PRECHECK(GetDropLocation); |
|---|
| 453 | n/a | #endif |
|---|
| 454 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 455 | n/a | return NULL; |
|---|
| 456 | n/a | _err = GetDropLocation(_self->ob_itself, |
|---|
| 457 | n/a | &dropLocation); |
|---|
| 458 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 459 | n/a | _res = Py_BuildValue("O&", |
|---|
| 460 | n/a | AEDesc_New, &dropLocation); |
|---|
| 461 | n/a | return _res; |
|---|
| 462 | n/a | } |
|---|
| 463 | n/a | |
|---|
| 464 | n/a | static PyObject *DragObj_SetDropLocation(DragObjObject *_self, PyObject *_args) |
|---|
| 465 | n/a | { |
|---|
| 466 | n/a | PyObject *_res = NULL; |
|---|
| 467 | n/a | OSErr _err; |
|---|
| 468 | n/a | AEDesc dropLocation; |
|---|
| 469 | n/a | #ifndef SetDropLocation |
|---|
| 470 | n/a | PyMac_PRECHECK(SetDropLocation); |
|---|
| 471 | n/a | #endif |
|---|
| 472 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 473 | n/a | AEDesc_Convert, &dropLocation)) |
|---|
| 474 | n/a | return NULL; |
|---|
| 475 | n/a | _err = SetDropLocation(_self->ob_itself, |
|---|
| 476 | n/a | &dropLocation); |
|---|
| 477 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 478 | n/a | Py_INCREF(Py_None); |
|---|
| 479 | n/a | _res = Py_None; |
|---|
| 480 | n/a | return _res; |
|---|
| 481 | n/a | } |
|---|
| 482 | n/a | |
|---|
| 483 | n/a | static PyObject *DragObj_GetDragAttributes(DragObjObject *_self, PyObject *_args) |
|---|
| 484 | n/a | { |
|---|
| 485 | n/a | PyObject *_res = NULL; |
|---|
| 486 | n/a | OSErr _err; |
|---|
| 487 | n/a | DragAttributes flags; |
|---|
| 488 | n/a | #ifndef GetDragAttributes |
|---|
| 489 | n/a | PyMac_PRECHECK(GetDragAttributes); |
|---|
| 490 | n/a | #endif |
|---|
| 491 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 492 | n/a | return NULL; |
|---|
| 493 | n/a | _err = GetDragAttributes(_self->ob_itself, |
|---|
| 494 | n/a | &flags); |
|---|
| 495 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 496 | n/a | _res = Py_BuildValue("l", |
|---|
| 497 | n/a | flags); |
|---|
| 498 | n/a | return _res; |
|---|
| 499 | n/a | } |
|---|
| 500 | n/a | |
|---|
| 501 | n/a | static PyObject *DragObj_GetDragMouse(DragObjObject *_self, PyObject *_args) |
|---|
| 502 | n/a | { |
|---|
| 503 | n/a | PyObject *_res = NULL; |
|---|
| 504 | n/a | OSErr _err; |
|---|
| 505 | n/a | Point mouse; |
|---|
| 506 | n/a | Point globalPinnedMouse; |
|---|
| 507 | n/a | #ifndef GetDragMouse |
|---|
| 508 | n/a | PyMac_PRECHECK(GetDragMouse); |
|---|
| 509 | n/a | #endif |
|---|
| 510 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 511 | n/a | return NULL; |
|---|
| 512 | n/a | _err = GetDragMouse(_self->ob_itself, |
|---|
| 513 | n/a | &mouse, |
|---|
| 514 | n/a | &globalPinnedMouse); |
|---|
| 515 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 516 | n/a | _res = Py_BuildValue("O&O&", |
|---|
| 517 | n/a | PyMac_BuildPoint, mouse, |
|---|
| 518 | n/a | PyMac_BuildPoint, globalPinnedMouse); |
|---|
| 519 | n/a | return _res; |
|---|
| 520 | n/a | } |
|---|
| 521 | n/a | |
|---|
| 522 | n/a | static PyObject *DragObj_SetDragMouse(DragObjObject *_self, PyObject *_args) |
|---|
| 523 | n/a | { |
|---|
| 524 | n/a | PyObject *_res = NULL; |
|---|
| 525 | n/a | OSErr _err; |
|---|
| 526 | n/a | Point globalPinnedMouse; |
|---|
| 527 | n/a | #ifndef SetDragMouse |
|---|
| 528 | n/a | PyMac_PRECHECK(SetDragMouse); |
|---|
| 529 | n/a | #endif |
|---|
| 530 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 531 | n/a | PyMac_GetPoint, &globalPinnedMouse)) |
|---|
| 532 | n/a | return NULL; |
|---|
| 533 | n/a | _err = SetDragMouse(_self->ob_itself, |
|---|
| 534 | n/a | globalPinnedMouse); |
|---|
| 535 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 536 | n/a | Py_INCREF(Py_None); |
|---|
| 537 | n/a | _res = Py_None; |
|---|
| 538 | n/a | return _res; |
|---|
| 539 | n/a | } |
|---|
| 540 | n/a | |
|---|
| 541 | n/a | static PyObject *DragObj_GetDragOrigin(DragObjObject *_self, PyObject *_args) |
|---|
| 542 | n/a | { |
|---|
| 543 | n/a | PyObject *_res = NULL; |
|---|
| 544 | n/a | OSErr _err; |
|---|
| 545 | n/a | Point globalInitialMouse; |
|---|
| 546 | n/a | #ifndef GetDragOrigin |
|---|
| 547 | n/a | PyMac_PRECHECK(GetDragOrigin); |
|---|
| 548 | n/a | #endif |
|---|
| 549 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 550 | n/a | return NULL; |
|---|
| 551 | n/a | _err = GetDragOrigin(_self->ob_itself, |
|---|
| 552 | n/a | &globalInitialMouse); |
|---|
| 553 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 554 | n/a | _res = Py_BuildValue("O&", |
|---|
| 555 | n/a | PyMac_BuildPoint, globalInitialMouse); |
|---|
| 556 | n/a | return _res; |
|---|
| 557 | n/a | } |
|---|
| 558 | n/a | |
|---|
| 559 | n/a | static PyObject *DragObj_GetDragModifiers(DragObjObject *_self, PyObject *_args) |
|---|
| 560 | n/a | { |
|---|
| 561 | n/a | PyObject *_res = NULL; |
|---|
| 562 | n/a | OSErr _err; |
|---|
| 563 | n/a | SInt16 modifiers; |
|---|
| 564 | n/a | SInt16 mouseDownModifiers; |
|---|
| 565 | n/a | SInt16 mouseUpModifiers; |
|---|
| 566 | n/a | #ifndef GetDragModifiers |
|---|
| 567 | n/a | PyMac_PRECHECK(GetDragModifiers); |
|---|
| 568 | n/a | #endif |
|---|
| 569 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 570 | n/a | return NULL; |
|---|
| 571 | n/a | _err = GetDragModifiers(_self->ob_itself, |
|---|
| 572 | n/a | &modifiers, |
|---|
| 573 | n/a | &mouseDownModifiers, |
|---|
| 574 | n/a | &mouseUpModifiers); |
|---|
| 575 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 576 | n/a | _res = Py_BuildValue("hhh", |
|---|
| 577 | n/a | modifiers, |
|---|
| 578 | n/a | mouseDownModifiers, |
|---|
| 579 | n/a | mouseUpModifiers); |
|---|
| 580 | n/a | return _res; |
|---|
| 581 | n/a | } |
|---|
| 582 | n/a | |
|---|
| 583 | n/a | static PyObject *DragObj_ShowDragHilite(DragObjObject *_self, PyObject *_args) |
|---|
| 584 | n/a | { |
|---|
| 585 | n/a | PyObject *_res = NULL; |
|---|
| 586 | n/a | OSErr _err; |
|---|
| 587 | n/a | RgnHandle hiliteFrame; |
|---|
| 588 | n/a | Boolean inside; |
|---|
| 589 | n/a | #ifndef ShowDragHilite |
|---|
| 590 | n/a | PyMac_PRECHECK(ShowDragHilite); |
|---|
| 591 | n/a | #endif |
|---|
| 592 | n/a | if (!PyArg_ParseTuple(_args, "O&b", |
|---|
| 593 | n/a | ResObj_Convert, &hiliteFrame, |
|---|
| 594 | n/a | &inside)) |
|---|
| 595 | n/a | return NULL; |
|---|
| 596 | n/a | _err = ShowDragHilite(_self->ob_itself, |
|---|
| 597 | n/a | hiliteFrame, |
|---|
| 598 | n/a | inside); |
|---|
| 599 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 600 | n/a | Py_INCREF(Py_None); |
|---|
| 601 | n/a | _res = Py_None; |
|---|
| 602 | n/a | return _res; |
|---|
| 603 | n/a | } |
|---|
| 604 | n/a | |
|---|
| 605 | n/a | static PyObject *DragObj_HideDragHilite(DragObjObject *_self, PyObject *_args) |
|---|
| 606 | n/a | { |
|---|
| 607 | n/a | PyObject *_res = NULL; |
|---|
| 608 | n/a | OSErr _err; |
|---|
| 609 | n/a | #ifndef HideDragHilite |
|---|
| 610 | n/a | PyMac_PRECHECK(HideDragHilite); |
|---|
| 611 | n/a | #endif |
|---|
| 612 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 613 | n/a | return NULL; |
|---|
| 614 | n/a | _err = HideDragHilite(_self->ob_itself); |
|---|
| 615 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 616 | n/a | Py_INCREF(Py_None); |
|---|
| 617 | n/a | _res = Py_None; |
|---|
| 618 | n/a | return _res; |
|---|
| 619 | n/a | } |
|---|
| 620 | n/a | |
|---|
| 621 | n/a | static PyObject *DragObj_DragPreScroll(DragObjObject *_self, PyObject *_args) |
|---|
| 622 | n/a | { |
|---|
| 623 | n/a | PyObject *_res = NULL; |
|---|
| 624 | n/a | OSErr _err; |
|---|
| 625 | n/a | SInt16 dH; |
|---|
| 626 | n/a | SInt16 dV; |
|---|
| 627 | n/a | #ifndef DragPreScroll |
|---|
| 628 | n/a | PyMac_PRECHECK(DragPreScroll); |
|---|
| 629 | n/a | #endif |
|---|
| 630 | n/a | if (!PyArg_ParseTuple(_args, "hh", |
|---|
| 631 | n/a | &dH, |
|---|
| 632 | n/a | &dV)) |
|---|
| 633 | n/a | return NULL; |
|---|
| 634 | n/a | _err = DragPreScroll(_self->ob_itself, |
|---|
| 635 | n/a | dH, |
|---|
| 636 | n/a | dV); |
|---|
| 637 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 638 | n/a | Py_INCREF(Py_None); |
|---|
| 639 | n/a | _res = Py_None; |
|---|
| 640 | n/a | return _res; |
|---|
| 641 | n/a | } |
|---|
| 642 | n/a | |
|---|
| 643 | n/a | static PyObject *DragObj_DragPostScroll(DragObjObject *_self, PyObject *_args) |
|---|
| 644 | n/a | { |
|---|
| 645 | n/a | PyObject *_res = NULL; |
|---|
| 646 | n/a | OSErr _err; |
|---|
| 647 | n/a | #ifndef DragPostScroll |
|---|
| 648 | n/a | PyMac_PRECHECK(DragPostScroll); |
|---|
| 649 | n/a | #endif |
|---|
| 650 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 651 | n/a | return NULL; |
|---|
| 652 | n/a | _err = DragPostScroll(_self->ob_itself); |
|---|
| 653 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 654 | n/a | Py_INCREF(Py_None); |
|---|
| 655 | n/a | _res = Py_None; |
|---|
| 656 | n/a | return _res; |
|---|
| 657 | n/a | } |
|---|
| 658 | n/a | |
|---|
| 659 | n/a | static PyObject *DragObj_UpdateDragHilite(DragObjObject *_self, PyObject *_args) |
|---|
| 660 | n/a | { |
|---|
| 661 | n/a | PyObject *_res = NULL; |
|---|
| 662 | n/a | OSErr _err; |
|---|
| 663 | n/a | RgnHandle updateRgn; |
|---|
| 664 | n/a | #ifndef UpdateDragHilite |
|---|
| 665 | n/a | PyMac_PRECHECK(UpdateDragHilite); |
|---|
| 666 | n/a | #endif |
|---|
| 667 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 668 | n/a | ResObj_Convert, &updateRgn)) |
|---|
| 669 | n/a | return NULL; |
|---|
| 670 | n/a | _err = UpdateDragHilite(_self->ob_itself, |
|---|
| 671 | n/a | updateRgn); |
|---|
| 672 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 673 | n/a | Py_INCREF(Py_None); |
|---|
| 674 | n/a | _res = Py_None; |
|---|
| 675 | n/a | return _res; |
|---|
| 676 | n/a | } |
|---|
| 677 | n/a | |
|---|
| 678 | n/a | static PyMethodDef DragObj_methods[] = { |
|---|
| 679 | n/a | {"DisposeDrag", (PyCFunction)DragObj_DisposeDrag, 1, |
|---|
| 680 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 681 | n/a | {"AddDragItemFlavor", (PyCFunction)DragObj_AddDragItemFlavor, 1, |
|---|
| 682 | n/a | PyDoc_STR("(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, FlavorFlags theFlags) -> None")}, |
|---|
| 683 | n/a | {"SetDragItemFlavorData", (PyCFunction)DragObj_SetDragItemFlavorData, 1, |
|---|
| 684 | n/a | PyDoc_STR("(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> None")}, |
|---|
| 685 | n/a | {"SetDragImage", (PyCFunction)DragObj_SetDragImage, 1, |
|---|
| 686 | n/a | PyDoc_STR("(PixMapHandle imagePixMap, RgnHandle imageRgn, Point imageOffsetPt, DragImageFlags theImageFlags) -> None")}, |
|---|
| 687 | n/a | {"ChangeDragBehaviors", (PyCFunction)DragObj_ChangeDragBehaviors, 1, |
|---|
| 688 | n/a | PyDoc_STR("(DragBehaviors inBehaviorsToSet, DragBehaviors inBehaviorsToClear) -> None")}, |
|---|
| 689 | n/a | {"TrackDrag", (PyCFunction)DragObj_TrackDrag, 1, |
|---|
| 690 | n/a | PyDoc_STR("(EventRecord theEvent, RgnHandle theRegion) -> None")}, |
|---|
| 691 | n/a | {"CountDragItems", (PyCFunction)DragObj_CountDragItems, 1, |
|---|
| 692 | n/a | PyDoc_STR("() -> (UInt16 numItems)")}, |
|---|
| 693 | n/a | {"GetDragItemReferenceNumber", (PyCFunction)DragObj_GetDragItemReferenceNumber, 1, |
|---|
| 694 | n/a | PyDoc_STR("(UInt16 index) -> (ItemReference theItemRef)")}, |
|---|
| 695 | n/a | {"CountDragItemFlavors", (PyCFunction)DragObj_CountDragItemFlavors, 1, |
|---|
| 696 | n/a | PyDoc_STR("(ItemReference theItemRef) -> (UInt16 numFlavors)")}, |
|---|
| 697 | n/a | {"GetFlavorType", (PyCFunction)DragObj_GetFlavorType, 1, |
|---|
| 698 | n/a | PyDoc_STR("(ItemReference theItemRef, UInt16 index) -> (FlavorType theType)")}, |
|---|
| 699 | n/a | {"GetFlavorFlags", (PyCFunction)DragObj_GetFlavorFlags, 1, |
|---|
| 700 | n/a | PyDoc_STR("(ItemReference theItemRef, FlavorType theType) -> (FlavorFlags theFlags)")}, |
|---|
| 701 | n/a | {"GetFlavorDataSize", (PyCFunction)DragObj_GetFlavorDataSize, 1, |
|---|
| 702 | n/a | PyDoc_STR("(ItemReference theItemRef, FlavorType theType) -> (Size dataSize)")}, |
|---|
| 703 | n/a | {"GetFlavorData", (PyCFunction)DragObj_GetFlavorData, 1, |
|---|
| 704 | n/a | PyDoc_STR("(ItemReference theItemRef, FlavorType theType, Buffer dataPtr, UInt32 dataOffset) -> (Buffer dataPtr)")}, |
|---|
| 705 | n/a | {"GetDragItemBounds", (PyCFunction)DragObj_GetDragItemBounds, 1, |
|---|
| 706 | n/a | PyDoc_STR("(ItemReference theItemRef) -> (Rect itemBounds)")}, |
|---|
| 707 | n/a | {"SetDragItemBounds", (PyCFunction)DragObj_SetDragItemBounds, 1, |
|---|
| 708 | n/a | PyDoc_STR("(ItemReference theItemRef, Rect itemBounds) -> None")}, |
|---|
| 709 | n/a | {"GetDropLocation", (PyCFunction)DragObj_GetDropLocation, 1, |
|---|
| 710 | n/a | PyDoc_STR("() -> (AEDesc dropLocation)")}, |
|---|
| 711 | n/a | {"SetDropLocation", (PyCFunction)DragObj_SetDropLocation, 1, |
|---|
| 712 | n/a | PyDoc_STR("(AEDesc dropLocation) -> None")}, |
|---|
| 713 | n/a | {"GetDragAttributes", (PyCFunction)DragObj_GetDragAttributes, 1, |
|---|
| 714 | n/a | PyDoc_STR("() -> (DragAttributes flags)")}, |
|---|
| 715 | n/a | {"GetDragMouse", (PyCFunction)DragObj_GetDragMouse, 1, |
|---|
| 716 | n/a | PyDoc_STR("() -> (Point mouse, Point globalPinnedMouse)")}, |
|---|
| 717 | n/a | {"SetDragMouse", (PyCFunction)DragObj_SetDragMouse, 1, |
|---|
| 718 | n/a | PyDoc_STR("(Point globalPinnedMouse) -> None")}, |
|---|
| 719 | n/a | {"GetDragOrigin", (PyCFunction)DragObj_GetDragOrigin, 1, |
|---|
| 720 | n/a | PyDoc_STR("() -> (Point globalInitialMouse)")}, |
|---|
| 721 | n/a | {"GetDragModifiers", (PyCFunction)DragObj_GetDragModifiers, 1, |
|---|
| 722 | n/a | PyDoc_STR("() -> (SInt16 modifiers, SInt16 mouseDownModifiers, SInt16 mouseUpModifiers)")}, |
|---|
| 723 | n/a | {"ShowDragHilite", (PyCFunction)DragObj_ShowDragHilite, 1, |
|---|
| 724 | n/a | PyDoc_STR("(RgnHandle hiliteFrame, Boolean inside) -> None")}, |
|---|
| 725 | n/a | {"HideDragHilite", (PyCFunction)DragObj_HideDragHilite, 1, |
|---|
| 726 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 727 | n/a | {"DragPreScroll", (PyCFunction)DragObj_DragPreScroll, 1, |
|---|
| 728 | n/a | PyDoc_STR("(SInt16 dH, SInt16 dV) -> None")}, |
|---|
| 729 | n/a | {"DragPostScroll", (PyCFunction)DragObj_DragPostScroll, 1, |
|---|
| 730 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 731 | n/a | {"UpdateDragHilite", (PyCFunction)DragObj_UpdateDragHilite, 1, |
|---|
| 732 | n/a | PyDoc_STR("(RgnHandle updateRgn) -> None")}, |
|---|
| 733 | n/a | {NULL, NULL, 0} |
|---|
| 734 | n/a | }; |
|---|
| 735 | n/a | |
|---|
| 736 | n/a | #define DragObj_getsetlist NULL |
|---|
| 737 | n/a | |
|---|
| 738 | n/a | |
|---|
| 739 | n/a | #define DragObj_compare NULL |
|---|
| 740 | n/a | |
|---|
| 741 | n/a | #define DragObj_repr NULL |
|---|
| 742 | n/a | |
|---|
| 743 | n/a | #define DragObj_hash NULL |
|---|
| 744 | n/a | #define DragObj_tp_init 0 |
|---|
| 745 | n/a | |
|---|
| 746 | n/a | #define DragObj_tp_alloc PyType_GenericAlloc |
|---|
| 747 | n/a | |
|---|
| 748 | n/a | static PyObject *DragObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 749 | n/a | { |
|---|
| 750 | n/a | PyObject *_self; |
|---|
| 751 | n/a | DragRef itself; |
|---|
| 752 | n/a | char *kw[] = {"itself", 0}; |
|---|
| 753 | n/a | |
|---|
| 754 | n/a | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DragObj_Convert, &itself)) return NULL; |
|---|
| 755 | n/a | if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 756 | n/a | ((DragObjObject *)_self)->ob_itself = itself; |
|---|
| 757 | n/a | return _self; |
|---|
| 758 | n/a | } |
|---|
| 759 | n/a | |
|---|
| 760 | n/a | #define DragObj_tp_free PyObject_Del |
|---|
| 761 | n/a | |
|---|
| 762 | n/a | |
|---|
| 763 | n/a | PyTypeObject DragObj_Type = { |
|---|
| 764 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 765 | n/a | 0, /*ob_size*/ |
|---|
| 766 | n/a | "_Drag.DragObj", /*tp_name*/ |
|---|
| 767 | n/a | sizeof(DragObjObject), /*tp_basicsize*/ |
|---|
| 768 | n/a | 0, /*tp_itemsize*/ |
|---|
| 769 | n/a | /* methods */ |
|---|
| 770 | n/a | (destructor) DragObj_dealloc, /*tp_dealloc*/ |
|---|
| 771 | n/a | 0, /*tp_print*/ |
|---|
| 772 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 773 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 774 | n/a | (cmpfunc) DragObj_compare, /*tp_compare*/ |
|---|
| 775 | n/a | (reprfunc) DragObj_repr, /*tp_repr*/ |
|---|
| 776 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 777 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 778 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 779 | n/a | (hashfunc) DragObj_hash, /*tp_hash*/ |
|---|
| 780 | n/a | 0, /*tp_call*/ |
|---|
| 781 | n/a | 0, /*tp_str*/ |
|---|
| 782 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 783 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 784 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 785 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 786 | n/a | 0, /*tp_doc*/ |
|---|
| 787 | n/a | 0, /*tp_traverse*/ |
|---|
| 788 | n/a | 0, /*tp_clear*/ |
|---|
| 789 | n/a | 0, /*tp_richcompare*/ |
|---|
| 790 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 791 | n/a | 0, /*tp_iter*/ |
|---|
| 792 | n/a | 0, /*tp_iternext*/ |
|---|
| 793 | n/a | DragObj_methods, /* tp_methods */ |
|---|
| 794 | n/a | 0, /*tp_members*/ |
|---|
| 795 | n/a | DragObj_getsetlist, /*tp_getset*/ |
|---|
| 796 | n/a | 0, /*tp_base*/ |
|---|
| 797 | n/a | 0, /*tp_dict*/ |
|---|
| 798 | n/a | 0, /*tp_descr_get*/ |
|---|
| 799 | n/a | 0, /*tp_descr_set*/ |
|---|
| 800 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 801 | n/a | DragObj_tp_init, /* tp_init */ |
|---|
| 802 | n/a | DragObj_tp_alloc, /* tp_alloc */ |
|---|
| 803 | n/a | DragObj_tp_new, /* tp_new */ |
|---|
| 804 | n/a | DragObj_tp_free, /* tp_free */ |
|---|
| 805 | n/a | }; |
|---|
| 806 | n/a | |
|---|
| 807 | n/a | /* -------------------- End object type DragObj --------------------- */ |
|---|
| 808 | n/a | |
|---|
| 809 | n/a | |
|---|
| 810 | n/a | static PyObject *Drag_NewDrag(PyObject *_self, PyObject *_args) |
|---|
| 811 | n/a | { |
|---|
| 812 | n/a | PyObject *_res = NULL; |
|---|
| 813 | n/a | OSErr _err; |
|---|
| 814 | n/a | DragRef theDrag; |
|---|
| 815 | n/a | #ifndef NewDrag |
|---|
| 816 | n/a | PyMac_PRECHECK(NewDrag); |
|---|
| 817 | n/a | #endif |
|---|
| 818 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 819 | n/a | return NULL; |
|---|
| 820 | n/a | _err = NewDrag(&theDrag); |
|---|
| 821 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 822 | n/a | _res = Py_BuildValue("O&", |
|---|
| 823 | n/a | DragObj_New, theDrag); |
|---|
| 824 | n/a | return _res; |
|---|
| 825 | n/a | } |
|---|
| 826 | n/a | |
|---|
| 827 | n/a | static PyObject *Drag_GetDragHiliteColor(PyObject *_self, PyObject *_args) |
|---|
| 828 | n/a | { |
|---|
| 829 | n/a | PyObject *_res = NULL; |
|---|
| 830 | n/a | OSErr _err; |
|---|
| 831 | n/a | WindowPtr window; |
|---|
| 832 | n/a | RGBColor color; |
|---|
| 833 | n/a | #ifndef GetDragHiliteColor |
|---|
| 834 | n/a | PyMac_PRECHECK(GetDragHiliteColor); |
|---|
| 835 | n/a | #endif |
|---|
| 836 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 837 | n/a | WinObj_Convert, &window)) |
|---|
| 838 | n/a | return NULL; |
|---|
| 839 | n/a | _err = GetDragHiliteColor(window, |
|---|
| 840 | n/a | &color); |
|---|
| 841 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 842 | n/a | _res = Py_BuildValue("O&", |
|---|
| 843 | n/a | QdRGB_New, &color); |
|---|
| 844 | n/a | return _res; |
|---|
| 845 | n/a | } |
|---|
| 846 | n/a | |
|---|
| 847 | n/a | static PyObject *Drag_WaitMouseMoved(PyObject *_self, PyObject *_args) |
|---|
| 848 | n/a | { |
|---|
| 849 | n/a | PyObject *_res = NULL; |
|---|
| 850 | n/a | Boolean _rv; |
|---|
| 851 | n/a | Point initialMouse; |
|---|
| 852 | n/a | #ifndef WaitMouseMoved |
|---|
| 853 | n/a | PyMac_PRECHECK(WaitMouseMoved); |
|---|
| 854 | n/a | #endif |
|---|
| 855 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 856 | n/a | PyMac_GetPoint, &initialMouse)) |
|---|
| 857 | n/a | return NULL; |
|---|
| 858 | n/a | _rv = WaitMouseMoved(initialMouse); |
|---|
| 859 | n/a | _res = Py_BuildValue("b", |
|---|
| 860 | n/a | _rv); |
|---|
| 861 | n/a | return _res; |
|---|
| 862 | n/a | } |
|---|
| 863 | n/a | |
|---|
| 864 | n/a | static PyObject *Drag_ZoomRects(PyObject *_self, PyObject *_args) |
|---|
| 865 | n/a | { |
|---|
| 866 | n/a | PyObject *_res = NULL; |
|---|
| 867 | n/a | OSErr _err; |
|---|
| 868 | n/a | Rect fromRect; |
|---|
| 869 | n/a | Rect toRect; |
|---|
| 870 | n/a | SInt16 zoomSteps; |
|---|
| 871 | n/a | ZoomAcceleration acceleration; |
|---|
| 872 | n/a | #ifndef ZoomRects |
|---|
| 873 | n/a | PyMac_PRECHECK(ZoomRects); |
|---|
| 874 | n/a | #endif |
|---|
| 875 | n/a | if (!PyArg_ParseTuple(_args, "O&O&hh", |
|---|
| 876 | n/a | PyMac_GetRect, &fromRect, |
|---|
| 877 | n/a | PyMac_GetRect, &toRect, |
|---|
| 878 | n/a | &zoomSteps, |
|---|
| 879 | n/a | &acceleration)) |
|---|
| 880 | n/a | return NULL; |
|---|
| 881 | n/a | _err = ZoomRects(&fromRect, |
|---|
| 882 | n/a | &toRect, |
|---|
| 883 | n/a | zoomSteps, |
|---|
| 884 | n/a | acceleration); |
|---|
| 885 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 886 | n/a | Py_INCREF(Py_None); |
|---|
| 887 | n/a | _res = Py_None; |
|---|
| 888 | n/a | return _res; |
|---|
| 889 | n/a | } |
|---|
| 890 | n/a | |
|---|
| 891 | n/a | static PyObject *Drag_ZoomRegion(PyObject *_self, PyObject *_args) |
|---|
| 892 | n/a | { |
|---|
| 893 | n/a | PyObject *_res = NULL; |
|---|
| 894 | n/a | OSErr _err; |
|---|
| 895 | n/a | RgnHandle region; |
|---|
| 896 | n/a | Point zoomDistance; |
|---|
| 897 | n/a | SInt16 zoomSteps; |
|---|
| 898 | n/a | ZoomAcceleration acceleration; |
|---|
| 899 | n/a | #ifndef ZoomRegion |
|---|
| 900 | n/a | PyMac_PRECHECK(ZoomRegion); |
|---|
| 901 | n/a | #endif |
|---|
| 902 | n/a | if (!PyArg_ParseTuple(_args, "O&O&hh", |
|---|
| 903 | n/a | ResObj_Convert, ®ion, |
|---|
| 904 | n/a | PyMac_GetPoint, &zoomDistance, |
|---|
| 905 | n/a | &zoomSteps, |
|---|
| 906 | n/a | &acceleration)) |
|---|
| 907 | n/a | return NULL; |
|---|
| 908 | n/a | _err = ZoomRegion(region, |
|---|
| 909 | n/a | zoomDistance, |
|---|
| 910 | n/a | zoomSteps, |
|---|
| 911 | n/a | acceleration); |
|---|
| 912 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 913 | n/a | Py_INCREF(Py_None); |
|---|
| 914 | n/a | _res = Py_None; |
|---|
| 915 | n/a | return _res; |
|---|
| 916 | n/a | } |
|---|
| 917 | n/a | |
|---|
| 918 | n/a | static PyObject *Drag_InstallTrackingHandler(PyObject *_self, PyObject *_args) |
|---|
| 919 | n/a | { |
|---|
| 920 | n/a | PyObject *_res = NULL; |
|---|
| 921 | n/a | |
|---|
| 922 | n/a | PyObject *callback; |
|---|
| 923 | n/a | WindowPtr theWindow = NULL; |
|---|
| 924 | n/a | OSErr _err; |
|---|
| 925 | n/a | |
|---|
| 926 | n/a | if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) ) |
|---|
| 927 | n/a | return NULL; |
|---|
| 928 | n/a | Py_INCREF(callback); /* Cannot decref later, too bad */ |
|---|
| 929 | n/a | _err = InstallTrackingHandler(dragglue_TrackingHandlerUPP, theWindow, (void *)callback); |
|---|
| 930 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 931 | n/a | Py_INCREF(Py_None); |
|---|
| 932 | n/a | _res = Py_None; |
|---|
| 933 | n/a | return _res; |
|---|
| 934 | n/a | |
|---|
| 935 | n/a | } |
|---|
| 936 | n/a | |
|---|
| 937 | n/a | static PyObject *Drag_InstallReceiveHandler(PyObject *_self, PyObject *_args) |
|---|
| 938 | n/a | { |
|---|
| 939 | n/a | PyObject *_res = NULL; |
|---|
| 940 | n/a | |
|---|
| 941 | n/a | PyObject *callback; |
|---|
| 942 | n/a | WindowPtr theWindow = NULL; |
|---|
| 943 | n/a | OSErr _err; |
|---|
| 944 | n/a | |
|---|
| 945 | n/a | if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) ) |
|---|
| 946 | n/a | return NULL; |
|---|
| 947 | n/a | Py_INCREF(callback); /* Cannot decref later, too bad */ |
|---|
| 948 | n/a | _err = InstallReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow, (void *)callback); |
|---|
| 949 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 950 | n/a | Py_INCREF(Py_None); |
|---|
| 951 | n/a | _res = Py_None; |
|---|
| 952 | n/a | return _res; |
|---|
| 953 | n/a | |
|---|
| 954 | n/a | } |
|---|
| 955 | n/a | |
|---|
| 956 | n/a | static PyObject *Drag_RemoveTrackingHandler(PyObject *_self, PyObject *_args) |
|---|
| 957 | n/a | { |
|---|
| 958 | n/a | PyObject *_res = NULL; |
|---|
| 959 | n/a | |
|---|
| 960 | n/a | WindowPtr theWindow = NULL; |
|---|
| 961 | n/a | OSErr _err; |
|---|
| 962 | n/a | |
|---|
| 963 | n/a | if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) ) |
|---|
| 964 | n/a | return NULL; |
|---|
| 965 | n/a | _err = RemoveTrackingHandler(dragglue_TrackingHandlerUPP, theWindow); |
|---|
| 966 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 967 | n/a | Py_INCREF(Py_None); |
|---|
| 968 | n/a | _res = Py_None; |
|---|
| 969 | n/a | return _res; |
|---|
| 970 | n/a | |
|---|
| 971 | n/a | } |
|---|
| 972 | n/a | |
|---|
| 973 | n/a | static PyObject *Drag_RemoveReceiveHandler(PyObject *_self, PyObject *_args) |
|---|
| 974 | n/a | { |
|---|
| 975 | n/a | PyObject *_res = NULL; |
|---|
| 976 | n/a | |
|---|
| 977 | n/a | WindowPtr theWindow = NULL; |
|---|
| 978 | n/a | OSErr _err; |
|---|
| 979 | n/a | |
|---|
| 980 | n/a | if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) ) |
|---|
| 981 | n/a | return NULL; |
|---|
| 982 | n/a | _err = RemoveReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow); |
|---|
| 983 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 984 | n/a | Py_INCREF(Py_None); |
|---|
| 985 | n/a | _res = Py_None; |
|---|
| 986 | n/a | return _res; |
|---|
| 987 | n/a | |
|---|
| 988 | n/a | } |
|---|
| 989 | n/a | |
|---|
| 990 | n/a | static PyMethodDef Drag_methods[] = { |
|---|
| 991 | n/a | {"NewDrag", (PyCFunction)Drag_NewDrag, 1, |
|---|
| 992 | n/a | PyDoc_STR("() -> (DragRef theDrag)")}, |
|---|
| 993 | n/a | {"GetDragHiliteColor", (PyCFunction)Drag_GetDragHiliteColor, 1, |
|---|
| 994 | n/a | PyDoc_STR("(WindowPtr window) -> (RGBColor color)")}, |
|---|
| 995 | n/a | {"WaitMouseMoved", (PyCFunction)Drag_WaitMouseMoved, 1, |
|---|
| 996 | n/a | PyDoc_STR("(Point initialMouse) -> (Boolean _rv)")}, |
|---|
| 997 | n/a | {"ZoomRects", (PyCFunction)Drag_ZoomRects, 1, |
|---|
| 998 | n/a | PyDoc_STR("(Rect fromRect, Rect toRect, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None")}, |
|---|
| 999 | n/a | {"ZoomRegion", (PyCFunction)Drag_ZoomRegion, 1, |
|---|
| 1000 | n/a | PyDoc_STR("(RgnHandle region, Point zoomDistance, SInt16 zoomSteps, ZoomAcceleration acceleration) -> None")}, |
|---|
| 1001 | n/a | {"InstallTrackingHandler", (PyCFunction)Drag_InstallTrackingHandler, 1, |
|---|
| 1002 | n/a | PyDoc_STR(NULL)}, |
|---|
| 1003 | n/a | {"InstallReceiveHandler", (PyCFunction)Drag_InstallReceiveHandler, 1, |
|---|
| 1004 | n/a | PyDoc_STR(NULL)}, |
|---|
| 1005 | n/a | {"RemoveTrackingHandler", (PyCFunction)Drag_RemoveTrackingHandler, 1, |
|---|
| 1006 | n/a | PyDoc_STR(NULL)}, |
|---|
| 1007 | n/a | {"RemoveReceiveHandler", (PyCFunction)Drag_RemoveReceiveHandler, 1, |
|---|
| 1008 | n/a | PyDoc_STR(NULL)}, |
|---|
| 1009 | n/a | {NULL, NULL, 0} |
|---|
| 1010 | n/a | }; |
|---|
| 1011 | n/a | |
|---|
| 1012 | n/a | |
|---|
| 1013 | n/a | |
|---|
| 1014 | n/a | static pascal OSErr |
|---|
| 1015 | n/a | dragglue_TrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow, |
|---|
| 1016 | n/a | void *handlerRefCon, DragReference theDrag) |
|---|
| 1017 | n/a | { |
|---|
| 1018 | n/a | PyObject *args, *rv; |
|---|
| 1019 | n/a | int i; |
|---|
| 1020 | n/a | |
|---|
| 1021 | n/a | args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow); |
|---|
| 1022 | n/a | if ( args == NULL ) |
|---|
| 1023 | n/a | return -1; |
|---|
| 1024 | n/a | rv = PyEval_CallObject((PyObject *)handlerRefCon, args); |
|---|
| 1025 | n/a | Py_DECREF(args); |
|---|
| 1026 | n/a | if ( rv == NULL ) { |
|---|
| 1027 | n/a | PySys_WriteStderr("Drag: Exception in TrackingHandler\n"); |
|---|
| 1028 | n/a | PyErr_Print(); |
|---|
| 1029 | n/a | return -1; |
|---|
| 1030 | n/a | } |
|---|
| 1031 | n/a | i = -1; |
|---|
| 1032 | n/a | if ( rv == Py_None ) |
|---|
| 1033 | n/a | i = 0; |
|---|
| 1034 | n/a | else |
|---|
| 1035 | n/a | PyArg_Parse(rv, "l", &i); |
|---|
| 1036 | n/a | Py_DECREF(rv); |
|---|
| 1037 | n/a | return i; |
|---|
| 1038 | n/a | } |
|---|
| 1039 | n/a | |
|---|
| 1040 | n/a | static pascal OSErr |
|---|
| 1041 | n/a | dragglue_ReceiveHandler(WindowPtr theWindow, void *handlerRefCon, |
|---|
| 1042 | n/a | DragReference theDrag) |
|---|
| 1043 | n/a | { |
|---|
| 1044 | n/a | PyObject *args, *rv; |
|---|
| 1045 | n/a | int i; |
|---|
| 1046 | n/a | |
|---|
| 1047 | n/a | args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow); |
|---|
| 1048 | n/a | if ( args == NULL ) |
|---|
| 1049 | n/a | return -1; |
|---|
| 1050 | n/a | rv = PyEval_CallObject((PyObject *)handlerRefCon, args); |
|---|
| 1051 | n/a | Py_DECREF(args); |
|---|
| 1052 | n/a | if ( rv == NULL ) { |
|---|
| 1053 | n/a | PySys_WriteStderr("Drag: Exception in ReceiveHandler\n"); |
|---|
| 1054 | n/a | PyErr_Print(); |
|---|
| 1055 | n/a | return -1; |
|---|
| 1056 | n/a | } |
|---|
| 1057 | n/a | i = -1; |
|---|
| 1058 | n/a | if ( rv == Py_None ) |
|---|
| 1059 | n/a | i = 0; |
|---|
| 1060 | n/a | else |
|---|
| 1061 | n/a | PyArg_Parse(rv, "l", &i); |
|---|
| 1062 | n/a | Py_DECREF(rv); |
|---|
| 1063 | n/a | return i; |
|---|
| 1064 | n/a | } |
|---|
| 1065 | n/a | |
|---|
| 1066 | n/a | static pascal OSErr |
|---|
| 1067 | n/a | dragglue_SendData(FlavorType theType, void *dragSendRefCon, |
|---|
| 1068 | n/a | ItemReference theItem, DragReference theDrag) |
|---|
| 1069 | n/a | { |
|---|
| 1070 | n/a | DragObjObject *self = (DragObjObject *)dragSendRefCon; |
|---|
| 1071 | n/a | PyObject *args, *rv; |
|---|
| 1072 | n/a | int i; |
|---|
| 1073 | n/a | |
|---|
| 1074 | n/a | if ( self->sendproc == NULL ) |
|---|
| 1075 | n/a | return -1; |
|---|
| 1076 | n/a | args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem); |
|---|
| 1077 | n/a | if ( args == NULL ) |
|---|
| 1078 | n/a | return -1; |
|---|
| 1079 | n/a | rv = PyEval_CallObject(self->sendproc, args); |
|---|
| 1080 | n/a | Py_DECREF(args); |
|---|
| 1081 | n/a | if ( rv == NULL ) { |
|---|
| 1082 | n/a | PySys_WriteStderr("Drag: Exception in SendDataHandler\n"); |
|---|
| 1083 | n/a | PyErr_Print(); |
|---|
| 1084 | n/a | return -1; |
|---|
| 1085 | n/a | } |
|---|
| 1086 | n/a | i = -1; |
|---|
| 1087 | n/a | if ( rv == Py_None ) |
|---|
| 1088 | n/a | i = 0; |
|---|
| 1089 | n/a | else |
|---|
| 1090 | n/a | PyArg_Parse(rv, "l", &i); |
|---|
| 1091 | n/a | Py_DECREF(rv); |
|---|
| 1092 | n/a | return i; |
|---|
| 1093 | n/a | } |
|---|
| 1094 | n/a | |
|---|
| 1095 | n/a | #if 0 |
|---|
| 1096 | n/a | static pascal OSErr |
|---|
| 1097 | n/a | dragglue_Input(Point *mouse, short *modifiers, |
|---|
| 1098 | n/a | void *dragSendRefCon, DragReference theDrag) |
|---|
| 1099 | n/a | { |
|---|
| 1100 | n/a | return 0; |
|---|
| 1101 | n/a | } |
|---|
| 1102 | n/a | |
|---|
| 1103 | n/a | static pascal OSErr |
|---|
| 1104 | n/a | dragglue_Drawing(xxxx |
|---|
| 1105 | n/a | void *dragSendRefCon, DragReference theDrag) |
|---|
| 1106 | n/a | { |
|---|
| 1107 | n/a | return 0; |
|---|
| 1108 | n/a | } |
|---|
| 1109 | n/a | #endif |
|---|
| 1110 | n/a | #else /* __LP64__ */ |
|---|
| 1111 | n/a | static PyMethodDef Drag_methods[] = { |
|---|
| 1112 | n/a | {NULL, NULL, 0} |
|---|
| 1113 | n/a | }; |
|---|
| 1114 | n/a | #endif /* __LP64__ */ |
|---|
| 1115 | n/a | |
|---|
| 1116 | n/a | |
|---|
| 1117 | n/a | void init_Drag(void) |
|---|
| 1118 | n/a | { |
|---|
| 1119 | n/a | PyObject *m; |
|---|
| 1120 | n/a | #ifndef __LP64__ |
|---|
| 1121 | n/a | PyObject *d; |
|---|
| 1122 | n/a | |
|---|
| 1123 | n/a | |
|---|
| 1124 | n/a | |
|---|
| 1125 | n/a | PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New); |
|---|
| 1126 | n/a | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert); |
|---|
| 1127 | n/a | #endif /* !__LP64__ */ |
|---|
| 1128 | n/a | |
|---|
| 1129 | n/a | |
|---|
| 1130 | n/a | m = Py_InitModule("_Drag", Drag_methods); |
|---|
| 1131 | n/a | #ifndef __LP64__ |
|---|
| 1132 | n/a | d = PyModule_GetDict(m); |
|---|
| 1133 | n/a | Drag_Error = PyMac_GetOSErrException(); |
|---|
| 1134 | n/a | if (Drag_Error == NULL || |
|---|
| 1135 | n/a | PyDict_SetItemString(d, "Error", Drag_Error) != 0) |
|---|
| 1136 | n/a | return; |
|---|
| 1137 | n/a | DragObj_Type.ob_type = &PyType_Type; |
|---|
| 1138 | n/a | if (PyType_Ready(&DragObj_Type) < 0) return; |
|---|
| 1139 | n/a | Py_INCREF(&DragObj_Type); |
|---|
| 1140 | n/a | PyModule_AddObject(m, "DragObj", (PyObject *)&DragObj_Type); |
|---|
| 1141 | n/a | /* Backward-compatible name */ |
|---|
| 1142 | n/a | Py_INCREF(&DragObj_Type); |
|---|
| 1143 | n/a | PyModule_AddObject(m, "DragObjType", (PyObject *)&DragObj_Type); |
|---|
| 1144 | n/a | |
|---|
| 1145 | n/a | dragglue_TrackingHandlerUPP = NewDragTrackingHandlerUPP(dragglue_TrackingHandler); |
|---|
| 1146 | n/a | dragglue_ReceiveHandlerUPP = NewDragReceiveHandlerUPP(dragglue_ReceiveHandler); |
|---|
| 1147 | n/a | dragglue_SendDataUPP = NewDragSendDataUPP(dragglue_SendData); |
|---|
| 1148 | n/a | #if 0 |
|---|
| 1149 | n/a | dragglue_InputUPP = NewDragInputUPP(dragglue_Input); |
|---|
| 1150 | n/a | dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing); |
|---|
| 1151 | n/a | #endif |
|---|
| 1152 | n/a | |
|---|
| 1153 | n/a | #endif /* !__LP64__ */ |
|---|
| 1154 | n/a | |
|---|
| 1155 | n/a | } |
|---|
| 1156 | n/a | |
|---|
| 1157 | n/a | /* ======================== End module _Drag ======================== */ |
|---|
| 1158 | n/a | |
|---|