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