Changeset 391 for python/trunk/Mac/Modules/dlg
- 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/dlg/_Dlgmodule.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 … … 36 36 short *itemHit) 37 37 { 38 Boolean rv; 39 PyObject *args, *res; 40 PyObject *callback = Dlg_FilterProc_callback; 41 if (callback == NULL) 42 return 0; /* Default behavior */ 43 Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ 44 args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event); 45 if (args == NULL) 46 res = NULL; 47 else { 48 res = PyEval_CallObject(callback, args); 49 Py_DECREF(args); 38 Boolean rv; 39 PyObject *args, *res; 40 PyObject *callback = Dlg_FilterProc_callback; 41 if (callback == NULL) 42 return 0; /* Default behavior */ 43 Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ 44 args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event); 45 if (args == NULL) 46 res = NULL; 47 else { 48 res = PyEval_CallObject(callback, args); 49 Py_DECREF(args); 50 } 51 if (res == NULL) { 52 PySys_WriteStderr("Exception in Dialog Filter\n"); 53 PyErr_Print(); 54 *itemHit = -1; /* Fake return item */ 55 return 1; /* We handled it */ 56 } 57 else { 58 Dlg_FilterProc_callback = callback; 59 if (PyInt_Check(res)) { 60 *itemHit = PyInt_AsLong(res); 61 rv = 1; 50 62 } 51 if (res == NULL) { 52 PySys_WriteStderr("Exception in Dialog Filter\n"); 53 PyErr_Print(); 54 *itemHit = -1; /* Fake return item */ 55 return 1; /* We handled it */ 56 } 57 else { 58 Dlg_FilterProc_callback = callback; 59 if (PyInt_Check(res)) { 60 *itemHit = PyInt_AsLong(res); 61 rv = 1; 62 } 63 else 64 rv = PyObject_IsTrue(res); 65 } 66 Py_DECREF(res); 67 return rv; 63 else 64 rv = PyObject_IsTrue(res); 65 } 66 Py_DECREF(res); 67 return rv; 68 68 } 69 69 … … 71 71 Dlg_PassFilterProc(PyObject *callback) 72 72 { 73 PyObject *tmp = Dlg_FilterProc_callback; 74 static ModalFilterUPP UnivFilterUpp = NULL; 75 76 Dlg_FilterProc_callback = NULL; 77 if (callback == Py_None) { 78 Py_XDECREF(tmp); 79 return NULL; 80 } 81 Py_INCREF(callback); 82 Dlg_FilterProc_callback = callback; 73 PyObject *tmp = Dlg_FilterProc_callback; 74 static ModalFilterUPP UnivFilterUpp = NULL; 75 76 Dlg_FilterProc_callback = NULL; 77 if (callback == Py_None) { 83 78 Py_XDECREF(tmp); 84 if ( UnivFilterUpp == NULL ) 85 UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc); 86 return UnivFilterUpp; 79 return NULL; 80 } 81 Py_INCREF(callback); 82 Dlg_FilterProc_callback = callback; 83 Py_XDECREF(tmp); 84 if ( UnivFilterUpp == NULL ) 85 UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc); 86 return UnivFilterUpp; 87 87 } 88 88 … … 92 92 short item) 93 93 { 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 94 PyObject *args, *res; 95 96 if (Dlg_UserItemProc_callback == NULL) 97 return; /* Default behavior */ 98 Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ 99 args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item); 100 if (args == NULL) 101 res = NULL; 102 else { 103 res = PyEval_CallObject(Dlg_UserItemProc_callback, args); 104 Py_DECREF(args); 105 } 106 if (res == NULL) { 107 PySys_WriteStderr("Exception in Dialog UserItem proc\n"); 108 PyErr_Print(); 109 } 110 Py_XDECREF(res); 111 return; 112 112 } 113 113 … … 134 134 135 135 typedef struct DialogObject { 136 137 136 PyObject_HEAD 137 DialogPtr ob_itself; 138 138 } DialogObject; 139 139 140 140 PyObject *DlgObj_New(DialogPtr itself) 141 141 { 142 143 144 145 146 147 148 142 DialogObject *it; 143 if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } 144 it = PyObject_NEW(DialogObject, &Dialog_Type); 145 if (it == NULL) return NULL; 146 it->ob_itself = itself; 147 SetWRefCon(GetDialogWindow(itself), (long)it); 148 return (PyObject *)it; 149 149 } 150 150 151 151 int DlgObj_Convert(PyObject *v, DialogPtr *p_itself) 152 152 { 153 154 155 156 157 158 159 160 161 162 153 if (v == Py_None) { *p_itself = NULL; return 1; } 154 if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v); 155 return 1; } 156 if (!DlgObj_Check(v)) 157 { 158 PyErr_SetString(PyExc_TypeError, "Dialog required"); 159 return 0; 160 } 161 *p_itself = ((DialogObject *)v)->ob_itself; 162 return 1; 163 163 } 164 164 165 165 static void DlgObj_dealloc(DialogObject *self) 166 166 { 167 168 167 DisposeDialog(self->ob_itself); 168 self->ob_type->tp_free((PyObject *)self); 169 169 } 170 170 171 171 static PyObject *DlgObj_DrawDialog(DialogObject *_self, PyObject *_args) 172 172 { 173 173 PyObject *_res = NULL; 174 174 #ifndef DrawDialog 175 176 #endif 177 178 179 180 181 182 175 PyMac_PRECHECK(DrawDialog); 176 #endif 177 if (!PyArg_ParseTuple(_args, "")) 178 return NULL; 179 DrawDialog(_self->ob_itself); 180 Py_INCREF(Py_None); 181 _res = Py_None; 182 return _res; 183 183 } 184 184 185 185 static PyObject *DlgObj_UpdateDialog(DialogObject *_self, PyObject *_args) 186 186 { 187 188 187 PyObject *_res = NULL; 188 RgnHandle updateRgn; 189 189 #ifndef UpdateDialog 190 191 #endif 192 193 194 195 196 197 198 199 190 PyMac_PRECHECK(UpdateDialog); 191 #endif 192 if (!PyArg_ParseTuple(_args, "O&", 193 ResObj_Convert, &updateRgn)) 194 return NULL; 195 UpdateDialog(_self->ob_itself, 196 updateRgn); 197 Py_INCREF(Py_None); 198 _res = Py_None; 199 return _res; 200 200 } 201 201 202 202 static PyObject *DlgObj_HideDialogItem(DialogObject *_self, PyObject *_args) 203 203 { 204 205 204 PyObject *_res = NULL; 205 DialogItemIndex itemNo; 206 206 #ifndef HideDialogItem 207 208 #endif 209 210 211 212 213 214 215 216 207 PyMac_PRECHECK(HideDialogItem); 208 #endif 209 if (!PyArg_ParseTuple(_args, "h", 210 &itemNo)) 211 return NULL; 212 HideDialogItem(_self->ob_itself, 213 itemNo); 214 Py_INCREF(Py_None); 215 _res = Py_None; 216 return _res; 217 217 } 218 218 219 219 static PyObject *DlgObj_ShowDialogItem(DialogObject *_self, PyObject *_args) 220 220 { 221 222 221 PyObject *_res = NULL; 222 DialogItemIndex itemNo; 223 223 #ifndef ShowDialogItem 224 225 #endif 226 227 228 229 230 231 232 233 224 PyMac_PRECHECK(ShowDialogItem); 225 #endif 226 if (!PyArg_ParseTuple(_args, "h", 227 &itemNo)) 228 return NULL; 229 ShowDialogItem(_self->ob_itself, 230 itemNo); 231 Py_INCREF(Py_None); 232 _res = Py_None; 233 return _res; 234 234 } 235 235 236 236 static PyObject *DlgObj_FindDialogItem(DialogObject *_self, PyObject *_args) 237 237 { 238 239 240 238 PyObject *_res = NULL; 239 DialogItemIndexZeroBased _rv; 240 Point thePt; 241 241 #ifndef FindDialogItem 242 243 #endif 244 245 246 247 248 249 250 251 242 PyMac_PRECHECK(FindDialogItem); 243 #endif 244 if (!PyArg_ParseTuple(_args, "O&", 245 PyMac_GetPoint, &thePt)) 246 return NULL; 247 _rv = FindDialogItem(_self->ob_itself, 248 thePt); 249 _res = Py_BuildValue("h", 250 _rv); 251 return _res; 252 252 } 253 253 254 254 static PyObject *DlgObj_DialogCut(DialogObject *_self, PyObject *_args) 255 255 { 256 256 PyObject *_res = NULL; 257 257 #ifndef DialogCut 258 259 #endif 260 261 262 263 264 265 258 PyMac_PRECHECK(DialogCut); 259 #endif 260 if (!PyArg_ParseTuple(_args, "")) 261 return NULL; 262 DialogCut(_self->ob_itself); 263 Py_INCREF(Py_None); 264 _res = Py_None; 265 return _res; 266 266 } 267 267 268 268 static PyObject *DlgObj_DialogPaste(DialogObject *_self, PyObject *_args) 269 269 { 270 270 PyObject *_res = NULL; 271 271 #ifndef DialogPaste 272 273 #endif 274 275 276 277 278 279 272 PyMac_PRECHECK(DialogPaste); 273 #endif 274 if (!PyArg_ParseTuple(_args, "")) 275 return NULL; 276 DialogPaste(_self->ob_itself); 277 Py_INCREF(Py_None); 278 _res = Py_None; 279 return _res; 280 280 } 281 281 282 282 static PyObject *DlgObj_DialogCopy(DialogObject *_self, PyObject *_args) 283 283 { 284 284 PyObject *_res = NULL; 285 285 #ifndef DialogCopy 286 287 #endif 288 289 290 291 292 293 286 PyMac_PRECHECK(DialogCopy); 287 #endif 288 if (!PyArg_ParseTuple(_args, "")) 289 return NULL; 290 DialogCopy(_self->ob_itself); 291 Py_INCREF(Py_None); 292 _res = Py_None; 293 return _res; 294 294 } 295 295 296 296 static PyObject *DlgObj_DialogDelete(DialogObject *_self, PyObject *_args) 297 297 { 298 298 PyObject *_res = NULL; 299 299 #ifndef DialogDelete 300 301 #endif 302 303 304 305 306 307 300 PyMac_PRECHECK(DialogDelete); 301 #endif 302 if (!PyArg_ParseTuple(_args, "")) 303 return NULL; 304 DialogDelete(_self->ob_itself); 305 Py_INCREF(Py_None); 306 _res = Py_None; 307 return _res; 308 308 } 309 309 310 310 static PyObject *DlgObj_GetDialogItem(DialogObject *_self, PyObject *_args) 311 311 { 312 313 314 315 316 312 PyObject *_res = NULL; 313 DialogItemIndex itemNo; 314 DialogItemType itemType; 315 Handle item; 316 Rect box; 317 317 #ifndef GetDialogItem 318 319 #endif 320 321 322 323 324 325 326 327 328 329 330 331 332 318 PyMac_PRECHECK(GetDialogItem); 319 #endif 320 if (!PyArg_ParseTuple(_args, "h", 321 &itemNo)) 322 return NULL; 323 GetDialogItem(_self->ob_itself, 324 itemNo, 325 &itemType, 326 &item, 327 &box); 328 _res = Py_BuildValue("hO&O&", 329 itemType, 330 OptResObj_New, item, 331 PyMac_BuildRect, &box); 332 return _res; 333 333 } 334 334 335 335 static PyObject *DlgObj_SetDialogItem(DialogObject *_self, PyObject *_args) 336 336 { 337 338 339 340 341 337 PyObject *_res = NULL; 338 DialogItemIndex itemNo; 339 DialogItemType itemType; 340 Handle item; 341 Rect box; 342 342 #ifndef SetDialogItem 343 344 #endif 345 346 347 348 349 350 351 352 353 354 355 356 357 358 343 PyMac_PRECHECK(SetDialogItem); 344 #endif 345 if (!PyArg_ParseTuple(_args, "hhO&O&", 346 &itemNo, 347 &itemType, 348 ResObj_Convert, &item, 349 PyMac_GetRect, &box)) 350 return NULL; 351 SetDialogItem(_self->ob_itself, 352 itemNo, 353 itemType, 354 item, 355 &box); 356 Py_INCREF(Py_None); 357 _res = Py_None; 358 return _res; 359 359 } 360 360 361 361 static PyObject *DlgObj_SelectDialogItemText(DialogObject *_self, PyObject *_args) 362 362 { 363 364 365 366 363 PyObject *_res = NULL; 364 DialogItemIndex itemNo; 365 SInt16 strtSel; 366 SInt16 endSel; 367 367 #ifndef SelectDialogItemText 368 369 #endif 370 371 372 373 374 375 376 377 378 379 380 381 368 PyMac_PRECHECK(SelectDialogItemText); 369 #endif 370 if (!PyArg_ParseTuple(_args, "hhh", 371 &itemNo, 372 &strtSel, 373 &endSel)) 374 return NULL; 375 SelectDialogItemText(_self->ob_itself, 376 itemNo, 377 strtSel, 378 endSel); 379 Py_INCREF(Py_None); 380 _res = Py_None; 381 return _res; 382 382 } 383 383 384 384 static PyObject *DlgObj_AppendDITL(DialogObject *_self, PyObject *_args) 385 385 { 386 387 388 386 PyObject *_res = NULL; 387 Handle theHandle; 388 DITLMethod method; 389 389 #ifndef AppendDITL 390 391 #endif 392 393 394 395 396 397 398 399 400 401 390 PyMac_PRECHECK(AppendDITL); 391 #endif 392 if (!PyArg_ParseTuple(_args, "O&h", 393 ResObj_Convert, &theHandle, 394 &method)) 395 return NULL; 396 AppendDITL(_self->ob_itself, 397 theHandle, 398 method); 399 Py_INCREF(Py_None); 400 _res = Py_None; 401 return _res; 402 402 } 403 403 404 404 static PyObject *DlgObj_CountDITL(DialogObject *_self, PyObject *_args) 405 405 { 406 407 406 PyObject *_res = NULL; 407 DialogItemIndex _rv; 408 408 #ifndef CountDITL 409 410 #endif 411 412 413 414 415 416 409 PyMac_PRECHECK(CountDITL); 410 #endif 411 if (!PyArg_ParseTuple(_args, "")) 412 return NULL; 413 _rv = CountDITL(_self->ob_itself); 414 _res = Py_BuildValue("h", 415 _rv); 416 return _res; 417 417 } 418 418 419 419 static PyObject *DlgObj_ShortenDITL(DialogObject *_self, PyObject *_args) 420 420 { 421 422 421 PyObject *_res = NULL; 422 DialogItemIndex numberItems; 423 423 #ifndef ShortenDITL 424 425 #endif 426 427 428 429 430 431 432 433 424 PyMac_PRECHECK(ShortenDITL); 425 #endif 426 if (!PyArg_ParseTuple(_args, "h", 427 &numberItems)) 428 return NULL; 429 ShortenDITL(_self->ob_itself, 430 numberItems); 431 Py_INCREF(Py_None); 432 _res = Py_None; 433 return _res; 434 434 } 435 435 436 436 static PyObject *DlgObj_InsertDialogItem(DialogObject *_self, PyObject *_args) 437 437 { 438 439 440 441 442 443 438 PyObject *_res = NULL; 439 OSStatus _err; 440 DialogItemIndex afterItem; 441 DialogItemType itemType; 442 Handle itemHandle; 443 Rect box; 444 444 #ifndef InsertDialogItem 445 446 #endif 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 445 PyMac_PRECHECK(InsertDialogItem); 446 #endif 447 if (!PyArg_ParseTuple(_args, "hhO&O&", 448 &afterItem, 449 &itemType, 450 ResObj_Convert, &itemHandle, 451 PyMac_GetRect, &box)) 452 return NULL; 453 _err = InsertDialogItem(_self->ob_itself, 454 afterItem, 455 itemType, 456 itemHandle, 457 &box); 458 if (_err != noErr) return PyMac_Error(_err); 459 Py_INCREF(Py_None); 460 _res = Py_None; 461 return _res; 462 462 } 463 463 464 464 static PyObject *DlgObj_RemoveDialogItems(DialogObject *_self, PyObject *_args) 465 465 { 466 467 468 469 470 466 PyObject *_res = NULL; 467 OSStatus _err; 468 DialogItemIndex itemNo; 469 DialogItemIndex amountToRemove; 470 Boolean disposeItemData; 471 471 #ifndef RemoveDialogItems 472 473 #endif 474 475 476 477 478 479 480 481 482 483 484 485 486 472 PyMac_PRECHECK(RemoveDialogItems); 473 #endif 474 if (!PyArg_ParseTuple(_args, "hhb", 475 &itemNo, 476 &amountToRemove, 477 &disposeItemData)) 478 return NULL; 479 _err = RemoveDialogItems(_self->ob_itself, 480 itemNo, 481 amountToRemove, 482 disposeItemData); 483 if (_err != noErr) return PyMac_Error(_err); 484 Py_INCREF(Py_None); 485 _res = Py_None; 486 return _res; 487 487 } 488 488 489 489 static PyObject *DlgObj_StdFilterProc(DialogObject *_self, PyObject *_args) 490 490 { 491 492 493 494 491 PyObject *_res = NULL; 492 Boolean _rv; 493 EventRecord event; 494 DialogItemIndex itemHit; 495 495 #ifndef StdFilterProc 496 497 #endif 498 499 500 501 502 503 504 505 506 507 508 509 496 PyMac_PRECHECK(StdFilterProc); 497 #endif 498 if (!PyArg_ParseTuple(_args, "O&h", 499 PyMac_GetEventRecord, &event, 500 &itemHit)) 501 return NULL; 502 _rv = StdFilterProc(_self->ob_itself, 503 &event, 504 &itemHit); 505 _res = Py_BuildValue("bO&h", 506 _rv, 507 PyMac_BuildEventRecord, &event, 508 itemHit); 509 return _res; 510 510 } 511 511 512 512 static PyObject *DlgObj_SetDialogDefaultItem(DialogObject *_self, PyObject *_args) 513 513 { 514 515 516 514 PyObject *_res = NULL; 515 OSErr _err; 516 DialogItemIndex newItem; 517 517 #ifndef SetDialogDefaultItem 518 519 #endif 520 521 522 523 524 525 526 527 528 518 PyMac_PRECHECK(SetDialogDefaultItem); 519 #endif 520 if (!PyArg_ParseTuple(_args, "h", 521 &newItem)) 522 return NULL; 523 _err = SetDialogDefaultItem(_self->ob_itself, 524 newItem); 525 if (_err != noErr) return PyMac_Error(_err); 526 Py_INCREF(Py_None); 527 _res = Py_None; 528 return _res; 529 529 } 530 530 531 531 static PyObject *DlgObj_SetDialogCancelItem(DialogObject *_self, PyObject *_args) 532 532 { 533 534 535 533 PyObject *_res = NULL; 534 OSErr _err; 535 DialogItemIndex newItem; 536 536 #ifndef SetDialogCancelItem 537 538 #endif 539 540 541 542 543 544 545 546 547 537 PyMac_PRECHECK(SetDialogCancelItem); 538 #endif 539 if (!PyArg_ParseTuple(_args, "h", 540 &newItem)) 541 return NULL; 542 _err = SetDialogCancelItem(_self->ob_itself, 543 newItem); 544 if (_err != noErr) return PyMac_Error(_err); 545 Py_INCREF(Py_None); 546 _res = Py_None; 547 return _res; 548 548 } 549 549 550 550 static PyObject *DlgObj_SetDialogTracksCursor(DialogObject *_self, PyObject *_args) 551 551 { 552 553 554 552 PyObject *_res = NULL; 553 OSErr _err; 554 Boolean tracks; 555 555 #ifndef SetDialogTracksCursor 556 557 #endif 558 559 560 561 562 563 564 565 566 556 PyMac_PRECHECK(SetDialogTracksCursor); 557 #endif 558 if (!PyArg_ParseTuple(_args, "b", 559 &tracks)) 560 return NULL; 561 _err = SetDialogTracksCursor(_self->ob_itself, 562 tracks); 563 if (_err != noErr) return PyMac_Error(_err); 564 Py_INCREF(Py_None); 565 _res = Py_None; 566 return _res; 567 567 } 568 568 569 569 static PyObject *DlgObj_AutoSizeDialog(DialogObject *_self, PyObject *_args) 570 570 { 571 572 571 PyObject *_res = NULL; 572 OSErr _err; 573 573 #ifndef AutoSizeDialog 574 575 #endif 576 577 578 579 580 581 582 574 PyMac_PRECHECK(AutoSizeDialog); 575 #endif 576 if (!PyArg_ParseTuple(_args, "")) 577 return NULL; 578 _err = AutoSizeDialog(_self->ob_itself); 579 if (_err != noErr) return PyMac_Error(_err); 580 Py_INCREF(Py_None); 581 _res = Py_None; 582 return _res; 583 583 } 584 584 585 585 static PyObject *DlgObj_GetDialogItemAsControl(DialogObject *_self, PyObject *_args) 586 586 { 587 588 589 590 587 PyObject *_res = NULL; 588 OSErr _err; 589 SInt16 inItemNo; 590 ControlHandle outControl; 591 591 #ifndef GetDialogItemAsControl 592 593 #endif 594 595 596 597 598 599 600 601 602 603 592 PyMac_PRECHECK(GetDialogItemAsControl); 593 #endif 594 if (!PyArg_ParseTuple(_args, "h", 595 &inItemNo)) 596 return NULL; 597 _err = GetDialogItemAsControl(_self->ob_itself, 598 inItemNo, 599 &outControl); 600 if (_err != noErr) return PyMac_Error(_err); 601 _res = Py_BuildValue("O&", 602 CtlObj_New, outControl); 603 return _res; 604 604 } 605 605 606 606 static PyObject *DlgObj_MoveDialogItem(DialogObject *_self, PyObject *_args) 607 607 { 608 609 610 611 612 608 PyObject *_res = NULL; 609 OSErr _err; 610 SInt16 inItemNo; 611 SInt16 inHoriz; 612 SInt16 inVert; 613 613 #ifndef MoveDialogItem 614 615 #endif 616 617 618 619 620 621 622 623 624 625 626 627 628 614 PyMac_PRECHECK(MoveDialogItem); 615 #endif 616 if (!PyArg_ParseTuple(_args, "hhh", 617 &inItemNo, 618 &inHoriz, 619 &inVert)) 620 return NULL; 621 _err = MoveDialogItem(_self->ob_itself, 622 inItemNo, 623 inHoriz, 624 inVert); 625 if (_err != noErr) return PyMac_Error(_err); 626 Py_INCREF(Py_None); 627 _res = Py_None; 628 return _res; 629 629 } 630 630 631 631 static PyObject *DlgObj_SizeDialogItem(DialogObject *_self, PyObject *_args) 632 632 { 633 634 635 636 637 633 PyObject *_res = NULL; 634 OSErr _err; 635 SInt16 inItemNo; 636 SInt16 inWidth; 637 SInt16 inHeight; 638 638 #ifndef SizeDialogItem 639 640 #endif 641 642 643 644 645 646 647 648 649 650 651 652 653 639 PyMac_PRECHECK(SizeDialogItem); 640 #endif 641 if (!PyArg_ParseTuple(_args, "hhh", 642 &inItemNo, 643 &inWidth, 644 &inHeight)) 645 return NULL; 646 _err = SizeDialogItem(_self->ob_itself, 647 inItemNo, 648 inWidth, 649 inHeight); 650 if (_err != noErr) return PyMac_Error(_err); 651 Py_INCREF(Py_None); 652 _res = Py_None; 653 return _res; 654 654 } 655 655 656 656 static PyObject *DlgObj_AppendDialogItemList(DialogObject *_self, PyObject *_args) 657 657 { 658 659 660 661 658 PyObject *_res = NULL; 659 OSErr _err; 660 SInt16 ditlID; 661 DITLMethod method; 662 662 #ifndef AppendDialogItemList 663 664 #endif 665 666 667 668 669 670 671 672 673 674 675 663 PyMac_PRECHECK(AppendDialogItemList); 664 #endif 665 if (!PyArg_ParseTuple(_args, "hh", 666 &ditlID, 667 &method)) 668 return NULL; 669 _err = AppendDialogItemList(_self->ob_itself, 670 ditlID, 671 method); 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 PyObject *DlgObj_SetDialogTimeout(DialogObject *_self, PyObject *_args) 679 679 { 680 681 682 683 680 PyObject *_res = NULL; 681 OSStatus _err; 682 SInt16 inButtonToPress; 683 UInt32 inSecondsToWait; 684 684 #ifndef SetDialogTimeout 685 686 #endif 687 688 689 690 691 692 693 694 695 696 697 685 PyMac_PRECHECK(SetDialogTimeout); 686 #endif 687 if (!PyArg_ParseTuple(_args, "hl", 688 &inButtonToPress, 689 &inSecondsToWait)) 690 return NULL; 691 _err = SetDialogTimeout(_self->ob_itself, 692 inButtonToPress, 693 inSecondsToWait); 694 if (_err != noErr) return PyMac_Error(_err); 695 Py_INCREF(Py_None); 696 _res = Py_None; 697 return _res; 698 698 } 699 699 700 700 static PyObject *DlgObj_GetDialogTimeout(DialogObject *_self, PyObject *_args) 701 701 { 702 703 704 705 706 702 PyObject *_res = NULL; 703 OSStatus _err; 704 SInt16 outButtonToPress; 705 UInt32 outSecondsToWait; 706 UInt32 outSecondsRemaining; 707 707 #ifndef GetDialogTimeout 708 709 #endif 710 711 712 713 714 715 716 717 718 719 720 721 708 PyMac_PRECHECK(GetDialogTimeout); 709 #endif 710 if (!PyArg_ParseTuple(_args, "")) 711 return NULL; 712 _err = GetDialogTimeout(_self->ob_itself, 713 &outButtonToPress, 714 &outSecondsToWait, 715 &outSecondsRemaining); 716 if (_err != noErr) return PyMac_Error(_err); 717 _res = Py_BuildValue("hll", 718 outButtonToPress, 719 outSecondsToWait, 720 outSecondsRemaining); 721 return _res; 722 722 } 723 723 724 724 static PyObject *DlgObj_SetModalDialogEventMask(DialogObject *_self, PyObject *_args) 725 725 { 726 727 728 726 PyObject *_res = NULL; 727 OSStatus _err; 728 EventMask inMask; 729 729 #ifndef SetModalDialogEventMask 730 731 #endif 732 733 734 735 736 737 738 739 740 730 PyMac_PRECHECK(SetModalDialogEventMask); 731 #endif 732 if (!PyArg_ParseTuple(_args, "H", 733 &inMask)) 734 return NULL; 735 _err = SetModalDialogEventMask(_self->ob_itself, 736 inMask); 737 if (_err != noErr) return PyMac_Error(_err); 738 Py_INCREF(Py_None); 739 _res = Py_None; 740 return _res; 741 741 } 742 742 743 743 static PyObject *DlgObj_GetModalDialogEventMask(DialogObject *_self, PyObject *_args) 744 744 { 745 746 747 745 PyObject *_res = NULL; 746 OSStatus _err; 747 EventMask outMask; 748 748 #ifndef GetModalDialogEventMask 749 750 #endif 751 752 753 754 755 756 757 758 749 PyMac_PRECHECK(GetModalDialogEventMask); 750 #endif 751 if (!PyArg_ParseTuple(_args, "")) 752 return NULL; 753 _err = GetModalDialogEventMask(_self->ob_itself, 754 &outMask); 755 if (_err != noErr) return PyMac_Error(_err); 756 _res = Py_BuildValue("H", 757 outMask); 758 return _res; 759 759 } 760 760 761 761 static PyObject *DlgObj_GetDialogWindow(DialogObject *_self, PyObject *_args) 762 762 { 763 764 763 PyObject *_res = NULL; 764 WindowPtr _rv; 765 765 #ifndef GetDialogWindow 766 767 #endif 768 769 770 771 772 773 766 PyMac_PRECHECK(GetDialogWindow); 767 #endif 768 if (!PyArg_ParseTuple(_args, "")) 769 return NULL; 770 _rv = GetDialogWindow(_self->ob_itself); 771 _res = Py_BuildValue("O&", 772 WinObj_New, _rv); 773 return _res; 774 774 } 775 775 776 776 static PyObject *DlgObj_GetDialogTextEditHandle(DialogObject *_self, PyObject *_args) 777 777 { 778 779 778 PyObject *_res = NULL; 779 TEHandle _rv; 780 780 #ifndef GetDialogTextEditHandle 781 782 #endif 783 784 785 786 787 788 781 PyMac_PRECHECK(GetDialogTextEditHandle); 782 #endif 783 if (!PyArg_ParseTuple(_args, "")) 784 return NULL; 785 _rv = GetDialogTextEditHandle(_self->ob_itself); 786 _res = Py_BuildValue("O&", 787 ResObj_New, _rv); 788 return _res; 789 789 } 790 790 791 791 static PyObject *DlgObj_GetDialogDefaultItem(DialogObject *_self, PyObject *_args) 792 792 { 793 794 793 PyObject *_res = NULL; 794 SInt16 _rv; 795 795 #ifndef GetDialogDefaultItem 796 797 #endif 798 799 800 801 802 803 796 PyMac_PRECHECK(GetDialogDefaultItem); 797 #endif 798 if (!PyArg_ParseTuple(_args, "")) 799 return NULL; 800 _rv = GetDialogDefaultItem(_self->ob_itself); 801 _res = Py_BuildValue("h", 802 _rv); 803 return _res; 804 804 } 805 805 806 806 static PyObject *DlgObj_GetDialogCancelItem(DialogObject *_self, PyObject *_args) 807 807 { 808 809 808 PyObject *_res = NULL; 809 SInt16 _rv; 810 810 #ifndef GetDialogCancelItem 811 812 #endif 813 814 815 816 817 818 811 PyMac_PRECHECK(GetDialogCancelItem); 812 #endif 813 if (!PyArg_ParseTuple(_args, "")) 814 return NULL; 815 _rv = GetDialogCancelItem(_self->ob_itself); 816 _res = Py_BuildValue("h", 817 _rv); 818 return _res; 819 819 } 820 820 821 821 static PyObject *DlgObj_GetDialogKeyboardFocusItem(DialogObject *_self, PyObject *_args) 822 822 { 823 824 823 PyObject *_res = NULL; 824 SInt16 _rv; 825 825 #ifndef GetDialogKeyboardFocusItem 826 827 #endif 828 829 830 831 832 833 826 PyMac_PRECHECK(GetDialogKeyboardFocusItem); 827 #endif 828 if (!PyArg_ParseTuple(_args, "")) 829 return NULL; 830 _rv = GetDialogKeyboardFocusItem(_self->ob_itself); 831 _res = Py_BuildValue("h", 832 _rv); 833 return _res; 834 834 } 835 835 836 836 static PyObject *DlgObj_SetPortDialogPort(DialogObject *_self, PyObject *_args) 837 837 { 838 838 PyObject *_res = NULL; 839 839 #ifndef SetPortDialogPort 840 841 #endif 842 843 844 845 846 847 840 PyMac_PRECHECK(SetPortDialogPort); 841 #endif 842 if (!PyArg_ParseTuple(_args, "")) 843 return NULL; 844 SetPortDialogPort(_self->ob_itself); 845 Py_INCREF(Py_None); 846 _res = Py_None; 847 return _res; 848 848 } 849 849 850 850 static PyObject *DlgObj_GetDialogPort(DialogObject *_self, PyObject *_args) 851 851 { 852 853 852 PyObject *_res = NULL; 853 CGrafPtr _rv; 854 854 #ifndef GetDialogPort 855 856 #endif 857 858 859 860 861 862 855 PyMac_PRECHECK(GetDialogPort); 856 #endif 857 if (!PyArg_ParseTuple(_args, "")) 858 return NULL; 859 _rv = GetDialogPort(_self->ob_itself); 860 _res = Py_BuildValue("O&", 861 GrafObj_New, _rv); 862 return _res; 863 863 } 864 864 865 865 static PyMethodDef DlgObj_methods[] = { 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 866 {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1, 867 PyDoc_STR("() -> None")}, 868 {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1, 869 PyDoc_STR("(RgnHandle updateRgn) -> None")}, 870 {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1, 871 PyDoc_STR("(DialogItemIndex itemNo) -> None")}, 872 {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1, 873 PyDoc_STR("(DialogItemIndex itemNo) -> None")}, 874 {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1, 875 PyDoc_STR("(Point thePt) -> (DialogItemIndexZeroBased _rv)")}, 876 {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1, 877 PyDoc_STR("() -> None")}, 878 {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1, 879 PyDoc_STR("() -> None")}, 880 {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1, 881 PyDoc_STR("() -> None")}, 882 {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1, 883 PyDoc_STR("() -> None")}, 884 {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1, 885 PyDoc_STR("(DialogItemIndex itemNo) -> (DialogItemType itemType, Handle item, Rect box)")}, 886 {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1, 887 PyDoc_STR("(DialogItemIndex itemNo, DialogItemType itemType, Handle item, Rect box) -> None")}, 888 {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1, 889 PyDoc_STR("(DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel) -> None")}, 890 {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1, 891 PyDoc_STR("(Handle theHandle, DITLMethod method) -> None")}, 892 {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1, 893 PyDoc_STR("() -> (DialogItemIndex _rv)")}, 894 {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, 895 PyDoc_STR("(DialogItemIndex numberItems) -> None")}, 896 {"InsertDialogItem", (PyCFunction)DlgObj_InsertDialogItem, 1, 897 PyDoc_STR("(DialogItemIndex afterItem, DialogItemType itemType, Handle itemHandle, Rect box) -> None")}, 898 {"RemoveDialogItems", (PyCFunction)DlgObj_RemoveDialogItems, 1, 899 PyDoc_STR("(DialogItemIndex itemNo, DialogItemIndex amountToRemove, Boolean disposeItemData) -> None")}, 900 {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1, 901 PyDoc_STR("(EventRecord event, DialogItemIndex itemHit) -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)")}, 902 {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, 903 PyDoc_STR("(DialogItemIndex newItem) -> None")}, 904 {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1, 905 PyDoc_STR("(DialogItemIndex newItem) -> None")}, 906 {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1, 907 PyDoc_STR("(Boolean tracks) -> None")}, 908 {"AutoSizeDialog", (PyCFunction)DlgObj_AutoSizeDialog, 1, 909 PyDoc_STR("() -> None")}, 910 {"GetDialogItemAsControl", (PyCFunction)DlgObj_GetDialogItemAsControl, 1, 911 PyDoc_STR("(SInt16 inItemNo) -> (ControlHandle outControl)")}, 912 {"MoveDialogItem", (PyCFunction)DlgObj_MoveDialogItem, 1, 913 PyDoc_STR("(SInt16 inItemNo, SInt16 inHoriz, SInt16 inVert) -> None")}, 914 {"SizeDialogItem", (PyCFunction)DlgObj_SizeDialogItem, 1, 915 PyDoc_STR("(SInt16 inItemNo, SInt16 inWidth, SInt16 inHeight) -> None")}, 916 {"AppendDialogItemList", (PyCFunction)DlgObj_AppendDialogItemList, 1, 917 PyDoc_STR("(SInt16 ditlID, DITLMethod method) -> None")}, 918 {"SetDialogTimeout", (PyCFunction)DlgObj_SetDialogTimeout, 1, 919 PyDoc_STR("(SInt16 inButtonToPress, UInt32 inSecondsToWait) -> None")}, 920 {"GetDialogTimeout", (PyCFunction)DlgObj_GetDialogTimeout, 1, 921 PyDoc_STR("() -> (SInt16 outButtonToPress, UInt32 outSecondsToWait, UInt32 outSecondsRemaining)")}, 922 {"SetModalDialogEventMask", (PyCFunction)DlgObj_SetModalDialogEventMask, 1, 923 PyDoc_STR("(EventMask inMask) -> None")}, 924 {"GetModalDialogEventMask", (PyCFunction)DlgObj_GetModalDialogEventMask, 1, 925 PyDoc_STR("() -> (EventMask outMask)")}, 926 {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1, 927 PyDoc_STR("() -> (WindowPtr _rv)")}, 928 {"GetDialogTextEditHandle", (PyCFunction)DlgObj_GetDialogTextEditHandle, 1, 929 PyDoc_STR("() -> (TEHandle _rv)")}, 930 {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1, 931 PyDoc_STR("() -> (SInt16 _rv)")}, 932 {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1, 933 PyDoc_STR("() -> (SInt16 _rv)")}, 934 {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1, 935 PyDoc_STR("() -> (SInt16 _rv)")}, 936 {"SetPortDialogPort", (PyCFunction)DlgObj_SetPortDialogPort, 1, 937 PyDoc_STR("() -> None")}, 938 {"GetDialogPort", (PyCFunction)DlgObj_GetDialogPort, 1, 939 PyDoc_STR("() -> (CGrafPtr _rv)")}, 940 {NULL, NULL, 0} 941 941 }; 942 942 … … 946 946 static int DlgObj_compare(DialogObject *self, DialogObject *other) 947 947 { 948 949 950 948 if ( self->ob_itself > other->ob_itself ) return 1; 949 if ( self->ob_itself < other->ob_itself ) return -1; 950 return 0; 951 951 } 952 952 … … 955 955 static int DlgObj_hash(DialogObject *self) 956 956 { 957 957 return (int)self->ob_itself; 958 958 } 959 959 #define DlgObj_tp_init 0 … … 963 963 static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 964 964 { 965 966 967 968 969 970 971 972 965 PyObject *_self; 966 DialogPtr itself; 967 char *kw[] = {"itself", 0}; 968 969 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL; 970 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; 971 ((DialogObject *)_self)->ob_itself = itself; 972 return _self; 973 973 } 974 974 … … 977 977 978 978 PyTypeObject Dialog_Type = { 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 979 PyObject_HEAD_INIT(NULL) 980 0, /*ob_size*/ 981 "_Dlg.Dialog", /*tp_name*/ 982 sizeof(DialogObject), /*tp_basicsize*/ 983 0, /*tp_itemsize*/ 984 /* methods */ 985 (destructor) DlgObj_dealloc, /*tp_dealloc*/ 986 0, /*tp_print*/ 987 (getattrfunc)0, /*tp_getattr*/ 988 (setattrfunc)0, /*tp_setattr*/ 989 (cmpfunc) DlgObj_compare, /*tp_compare*/ 990 (reprfunc) DlgObj_repr, /*tp_repr*/ 991 (PyNumberMethods *)0, /* tp_as_number */ 992 (PySequenceMethods *)0, /* tp_as_sequence */ 993 (PyMappingMethods *)0, /* tp_as_mapping */ 994 (hashfunc) DlgObj_hash, /*tp_hash*/ 995 0, /*tp_call*/ 996 0, /*tp_str*/ 997 PyObject_GenericGetAttr, /*tp_getattro*/ 998 PyObject_GenericSetAttr, /*tp_setattro */ 999 0, /*tp_as_buffer*/ 1000 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ 1001 0, /*tp_doc*/ 1002 0, /*tp_traverse*/ 1003 0, /*tp_clear*/ 1004 0, /*tp_richcompare*/ 1005 0, /*tp_weaklistoffset*/ 1006 0, /*tp_iter*/ 1007 0, /*tp_iternext*/ 1008 DlgObj_methods, /* tp_methods */ 1009 0, /*tp_members*/ 1010 DlgObj_getsetlist, /*tp_getset*/ 1011 0, /*tp_base*/ 1012 0, /*tp_dict*/ 1013 0, /*tp_descr_get*/ 1014 0, /*tp_descr_set*/ 1015 0, /*tp_dictoffset*/ 1016 DlgObj_tp_init, /* tp_init */ 1017 DlgObj_tp_alloc, /* tp_alloc */ 1018 DlgObj_tp_new, /* tp_new */ 1019 DlgObj_tp_free, /* tp_free */ 1020 1020 }; 1021 1021 … … 1025 1025 static PyObject *Dlg_NewDialog(PyObject *_self, PyObject *_args) 1026 1026 { 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1027 PyObject *_res = NULL; 1028 DialogPtr _rv; 1029 Rect boundsRect; 1030 Str255 title; 1031 Boolean visible; 1032 SInt16 procID; 1033 WindowPtr behind; 1034 Boolean goAwayFlag; 1035 SInt32 refCon; 1036 Handle items; 1037 1037 #ifndef NewDialog 1038 1039 #endif 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1038 PyMac_PRECHECK(NewDialog); 1039 #endif 1040 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", 1041 PyMac_GetRect, &boundsRect, 1042 PyMac_GetStr255, title, 1043 &visible, 1044 &procID, 1045 WinObj_Convert, &behind, 1046 &goAwayFlag, 1047 &refCon, 1048 ResObj_Convert, &items)) 1049 return NULL; 1050 _rv = NewDialog((void *)0, 1051 &boundsRect, 1052 title, 1053 visible, 1054 procID, 1055 behind, 1056 goAwayFlag, 1057 refCon, 1058 items); 1059 _res = Py_BuildValue("O&", 1060 DlgObj_New, _rv); 1061 return _res; 1062 1062 } 1063 1063 1064 1064 static PyObject *Dlg_GetNewDialog(PyObject *_self, PyObject *_args) 1065 1065 { 1066 1067 1068 1069 1066 PyObject *_res = NULL; 1067 DialogPtr _rv; 1068 SInt16 dialogID; 1069 WindowPtr behind; 1070 1070 #ifndef GetNewDialog 1071 1072 #endif 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1071 PyMac_PRECHECK(GetNewDialog); 1072 #endif 1073 if (!PyArg_ParseTuple(_args, "hO&", 1074 &dialogID, 1075 WinObj_Convert, &behind)) 1076 return NULL; 1077 _rv = GetNewDialog(dialogID, 1078 (void *)0, 1079 behind); 1080 _res = Py_BuildValue("O&", 1081 DlgObj_New, _rv); 1082 return _res; 1083 1083 } 1084 1084 1085 1085 static PyObject *Dlg_NewColorDialog(PyObject *_self, PyObject *_args) 1086 1086 { 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1087 PyObject *_res = NULL; 1088 DialogPtr _rv; 1089 Rect boundsRect; 1090 Str255 title; 1091 Boolean visible; 1092 SInt16 procID; 1093 WindowPtr behind; 1094 Boolean goAwayFlag; 1095 SInt32 refCon; 1096 Handle items; 1097 1097 #ifndef NewColorDialog 1098 1099 #endif 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1098 PyMac_PRECHECK(NewColorDialog); 1099 #endif 1100 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", 1101 PyMac_GetRect, &boundsRect, 1102 PyMac_GetStr255, title, 1103 &visible, 1104 &procID, 1105 WinObj_Convert, &behind, 1106 &goAwayFlag, 1107 &refCon, 1108 ResObj_Convert, &items)) 1109 return NULL; 1110 _rv = NewColorDialog((void *)0, 1111 &boundsRect, 1112 title, 1113 visible, 1114 procID, 1115 behind, 1116 goAwayFlag, 1117 refCon, 1118 items); 1119 _res = Py_BuildValue("O&", 1120 DlgObj_New, _rv); 1121 return _res; 1122 1122 } 1123 1123 1124 1124 static PyObject *Dlg_ModalDialog(PyObject *_self, PyObject *_args) 1125 1125 { 1126 1127 1128 1126 PyObject *_res = NULL; 1127 PyObject* modalFilter; 1128 DialogItemIndex itemHit; 1129 1129 #ifndef ModalDialog 1130 1131 #endif 1132 1133 1134 1135 1136 1137 1138 1139 1130 PyMac_PRECHECK(ModalDialog); 1131 #endif 1132 if (!PyArg_ParseTuple(_args, "O", 1133 &modalFilter)) 1134 return NULL; 1135 ModalDialog(Dlg_PassFilterProc(modalFilter), 1136 &itemHit); 1137 _res = Py_BuildValue("h", 1138 itemHit); 1139 return _res; 1140 1140 } 1141 1141 1142 1142 static PyObject *Dlg_IsDialogEvent(PyObject *_self, PyObject *_args) 1143 1143 { 1144 1145 1146 1144 PyObject *_res = NULL; 1145 Boolean _rv; 1146 EventRecord theEvent; 1147 1147 #ifndef IsDialogEvent 1148 1149 #endif 1150 1151 1152 1153 1154 1155 1156 1148 PyMac_PRECHECK(IsDialogEvent); 1149 #endif 1150 if (!PyArg_ParseTuple(_args, "O&", 1151 PyMac_GetEventRecord, &theEvent)) 1152 return NULL; 1153 _rv = IsDialogEvent(&theEvent); 1154 _res = Py_BuildValue("b", 1155 _rv); 1156 return _res; 1157 1157 } 1158 1158 1159 1159 static PyObject *Dlg_DialogSelect(PyObject *_self, PyObject *_args) 1160 1160 { 1161 1162 1163 1164 1165 1161 PyObject *_res = NULL; 1162 Boolean _rv; 1163 EventRecord theEvent; 1164 DialogPtr theDialog; 1165 DialogItemIndex itemHit; 1166 1166 #ifndef DialogSelect 1167 1168 #endif 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1167 PyMac_PRECHECK(DialogSelect); 1168 #endif 1169 if (!PyArg_ParseTuple(_args, "O&", 1170 PyMac_GetEventRecord, &theEvent)) 1171 return NULL; 1172 _rv = DialogSelect(&theEvent, 1173 &theDialog, 1174 &itemHit); 1175 _res = Py_BuildValue("bO&h", 1176 _rv, 1177 DlgObj_WhichDialog, theDialog, 1178 itemHit); 1179 return _res; 1180 1180 } 1181 1181 1182 1182 static PyObject *Dlg_Alert(PyObject *_self, PyObject *_args) 1183 1183 { 1184 1185 1186 1187 1184 PyObject *_res = NULL; 1185 DialogItemIndex _rv; 1186 SInt16 alertID; 1187 PyObject* modalFilter; 1188 1188 #ifndef Alert 1189 1190 #endif 1191 1192 1193 1194 1195 1196 1197 1198 1199 1189 PyMac_PRECHECK(Alert); 1190 #endif 1191 if (!PyArg_ParseTuple(_args, "hO", 1192 &alertID, 1193 &modalFilter)) 1194 return NULL; 1195 _rv = Alert(alertID, 1196 Dlg_PassFilterProc(modalFilter)); 1197 _res = Py_BuildValue("h", 1198 _rv); 1199 return _res; 1200 1200 } 1201 1201 1202 1202 static PyObject *Dlg_StopAlert(PyObject *_self, PyObject *_args) 1203 1203 { 1204 1205 1206 1207 1204 PyObject *_res = NULL; 1205 DialogItemIndex _rv; 1206 SInt16 alertID; 1207 PyObject* modalFilter; 1208 1208 #ifndef StopAlert 1209 1210 #endif 1211 1212 1213 1214 1215 1216 1217 1218 1219 1209 PyMac_PRECHECK(StopAlert); 1210 #endif 1211 if (!PyArg_ParseTuple(_args, "hO", 1212 &alertID, 1213 &modalFilter)) 1214 return NULL; 1215 _rv = StopAlert(alertID, 1216 Dlg_PassFilterProc(modalFilter)); 1217 _res = Py_BuildValue("h", 1218 _rv); 1219 return _res; 1220 1220 } 1221 1221 1222 1222 static PyObject *Dlg_NoteAlert(PyObject *_self, PyObject *_args) 1223 1223 { 1224 1225 1226 1227 1224 PyObject *_res = NULL; 1225 DialogItemIndex _rv; 1226 SInt16 alertID; 1227 PyObject* modalFilter; 1228 1228 #ifndef NoteAlert 1229 1230 #endif 1231 1232 1233 1234 1235 1236 1237 1238 1239 1229 PyMac_PRECHECK(NoteAlert); 1230 #endif 1231 if (!PyArg_ParseTuple(_args, "hO", 1232 &alertID, 1233 &modalFilter)) 1234 return NULL; 1235 _rv = NoteAlert(alertID, 1236 Dlg_PassFilterProc(modalFilter)); 1237 _res = Py_BuildValue("h", 1238 _rv); 1239 return _res; 1240 1240 } 1241 1241 1242 1242 static PyObject *Dlg_CautionAlert(PyObject *_self, PyObject *_args) 1243 1243 { 1244 1245 1246 1247 1244 PyObject *_res = NULL; 1245 DialogItemIndex _rv; 1246 SInt16 alertID; 1247 PyObject* modalFilter; 1248 1248 #ifndef CautionAlert 1249 1250 #endif 1251 1252 1253 1254 1255 1256 1257 1258 1259 1249 PyMac_PRECHECK(CautionAlert); 1250 #endif 1251 if (!PyArg_ParseTuple(_args, "hO", 1252 &alertID, 1253 &modalFilter)) 1254 return NULL; 1255 _rv = CautionAlert(alertID, 1256 Dlg_PassFilterProc(modalFilter)); 1257 _res = Py_BuildValue("h", 1258 _rv); 1259 return _res; 1260 1260 } 1261 1261 1262 1262 static PyObject *Dlg_ParamText(PyObject *_self, PyObject *_args) 1263 1263 { 1264 1265 1266 1267 1268 1264 PyObject *_res = NULL; 1265 Str255 param0; 1266 Str255 param1; 1267 Str255 param2; 1268 Str255 param3; 1269 1269 #ifndef ParamText 1270 1271 #endif 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1270 PyMac_PRECHECK(ParamText); 1271 #endif 1272 if (!PyArg_ParseTuple(_args, "O&O&O&O&", 1273 PyMac_GetStr255, param0, 1274 PyMac_GetStr255, param1, 1275 PyMac_GetStr255, param2, 1276 PyMac_GetStr255, param3)) 1277 return NULL; 1278 ParamText(param0, 1279 param1, 1280 param2, 1281 param3); 1282 Py_INCREF(Py_None); 1283 _res = Py_None; 1284 return _res; 1285 1285 } 1286 1286 1287 1287 static PyObject *Dlg_GetDialogItemText(PyObject *_self, PyObject *_args) 1288 1288 { 1289 1290 1291 1289 PyObject *_res = NULL; 1290 Handle item; 1291 Str255 text; 1292 1292 #ifndef GetDialogItemText 1293 1294 #endif 1295 1296 1297 1298 1299 1300 1301 1302 1293 PyMac_PRECHECK(GetDialogItemText); 1294 #endif 1295 if (!PyArg_ParseTuple(_args, "O&", 1296 ResObj_Convert, &item)) 1297 return NULL; 1298 GetDialogItemText(item, 1299 text); 1300 _res = Py_BuildValue("O&", 1301 PyMac_BuildStr255, text); 1302 return _res; 1303 1303 } 1304 1304 1305 1305 static PyObject *Dlg_SetDialogItemText(PyObject *_self, PyObject *_args) 1306 1306 { 1307 1308 1309 1307 PyObject *_res = NULL; 1308 Handle item; 1309 Str255 text; 1310 1310 #ifndef SetDialogItemText 1311 1312 #endif 1313 1314 1315 1316 1317 1318 1319 1320 1321 1311 PyMac_PRECHECK(SetDialogItemText); 1312 #endif 1313 if (!PyArg_ParseTuple(_args, "O&O&", 1314 ResObj_Convert, &item, 1315 PyMac_GetStr255, text)) 1316 return NULL; 1317 SetDialogItemText(item, 1318 text); 1319 Py_INCREF(Py_None); 1320 _res = Py_None; 1321 return _res; 1322 1322 } 1323 1323 1324 1324 static PyObject *Dlg_GetAlertStage(PyObject *_self, PyObject *_args) 1325 1325 { 1326 1327 1326 PyObject *_res = NULL; 1327 SInt16 _rv; 1328 1328 #ifndef GetAlertStage 1329 1330 #endif 1331 1332 1333 1334 1335 1336 1329 PyMac_PRECHECK(GetAlertStage); 1330 #endif 1331 if (!PyArg_ParseTuple(_args, "")) 1332 return NULL; 1333 _rv = GetAlertStage(); 1334 _res = Py_BuildValue("h", 1335 _rv); 1336 return _res; 1337 1337 } 1338 1338 1339 1339 static PyObject *Dlg_SetDialogFont(PyObject *_self, PyObject *_args) 1340 1340 { 1341 1342 1341 PyObject *_res = NULL; 1342 SInt16 fontNum; 1343 1343 #ifndef SetDialogFont 1344 1345 #endif 1346 1347 1348 1349 1350 1351 1352 1344 PyMac_PRECHECK(SetDialogFont); 1345 #endif 1346 if (!PyArg_ParseTuple(_args, "h", 1347 &fontNum)) 1348 return NULL; 1349 SetDialogFont(fontNum); 1350 Py_INCREF(Py_None); 1351 _res = Py_None; 1352 return _res; 1353 1353 } 1354 1354 1355 1355 static PyObject *Dlg_ResetAlertStage(PyObject *_self, PyObject *_args) 1356 1356 { 1357 1357 PyObject *_res = NULL; 1358 1358 #ifndef ResetAlertStage 1359 1360 #endif 1361 1362 1363 1364 1365 1366 1359 PyMac_PRECHECK(ResetAlertStage); 1360 #endif 1361 if (!PyArg_ParseTuple(_args, "")) 1362 return NULL; 1363 ResetAlertStage(); 1364 Py_INCREF(Py_None); 1365 _res = Py_None; 1366 return _res; 1367 1367 } 1368 1368 1369 1369 static PyObject *Dlg_GetParamText(PyObject *_self, PyObject *_args) 1370 1370 { 1371 1372 1373 1374 1375 1371 PyObject *_res = NULL; 1372 Str255 param0; 1373 Str255 param1; 1374 Str255 param2; 1375 Str255 param3; 1376 1376 #ifndef GetParamText 1377 1378 #endif 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1377 PyMac_PRECHECK(GetParamText); 1378 #endif 1379 if (!PyArg_ParseTuple(_args, "O&O&O&O&", 1380 PyMac_GetStr255, param0, 1381 PyMac_GetStr255, param1, 1382 PyMac_GetStr255, param2, 1383 PyMac_GetStr255, param3)) 1384 return NULL; 1385 GetParamText(param0, 1386 param1, 1387 param2, 1388 param3); 1389 Py_INCREF(Py_None); 1390 _res = Py_None; 1391 return _res; 1392 1392 } 1393 1393 1394 1394 static PyObject *Dlg_NewFeaturesDialog(PyObject *_self, PyObject *_args) 1395 1395 { 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1396 PyObject *_res = NULL; 1397 DialogPtr _rv; 1398 Rect inBoundsRect; 1399 Str255 inTitle; 1400 Boolean inIsVisible; 1401 SInt16 inProcID; 1402 WindowPtr inBehind; 1403 Boolean inGoAwayFlag; 1404 SInt32 inRefCon; 1405 Handle inItemListHandle; 1406 UInt32 inFlags; 1407 1407 #ifndef NewFeaturesDialog 1408 1409 #endif 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1408 PyMac_PRECHECK(NewFeaturesDialog); 1409 #endif 1410 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&l", 1411 PyMac_GetRect, &inBoundsRect, 1412 PyMac_GetStr255, inTitle, 1413 &inIsVisible, 1414 &inProcID, 1415 WinObj_Convert, &inBehind, 1416 &inGoAwayFlag, 1417 &inRefCon, 1418 ResObj_Convert, &inItemListHandle, 1419 &inFlags)) 1420 return NULL; 1421 _rv = NewFeaturesDialog((void *)0, 1422 &inBoundsRect, 1423 inTitle, 1424 inIsVisible, 1425 inProcID, 1426 inBehind, 1427 inGoAwayFlag, 1428 inRefCon, 1429 inItemListHandle, 1430 inFlags); 1431 _res = Py_BuildValue("O&", 1432 DlgObj_New, _rv); 1433 return _res; 1434 1434 } 1435 1435 1436 1436 static PyObject *Dlg_GetDialogFromWindow(PyObject *_self, PyObject *_args) 1437 1437 { 1438 1439 1440 1438 PyObject *_res = NULL; 1439 DialogPtr _rv; 1440 WindowPtr window; 1441 1441 #ifndef GetDialogFromWindow 1442 1443 #endif 1444 1445 1446 1447 1448 1449 1450 1442 PyMac_PRECHECK(GetDialogFromWindow); 1443 #endif 1444 if (!PyArg_ParseTuple(_args, "O&", 1445 WinObj_Convert, &window)) 1446 return NULL; 1447 _rv = GetDialogFromWindow(window); 1448 _res = Py_BuildValue("O&", 1449 DlgObj_New, _rv); 1450 return _res; 1451 1451 } 1452 1452 1453 1453 static PyObject *Dlg_SetUserItemHandler(PyObject *_self, PyObject *_args) 1454 1454 { 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1455 PyObject *_res = NULL; 1456 1457 PyObject *new = NULL; 1458 1459 1460 if (!PyArg_ParseTuple(_args, "|O", &new)) 1461 return NULL; 1462 1463 if (Dlg_UserItemProc_callback && new && new != Py_None) { 1464 PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed"); 1465 return NULL; 1466 } 1467 1468 if (new == NULL || new == Py_None) { 1469 new = NULL; 1470 _res = Py_None; 1471 Py_INCREF(Py_None); 1472 } else { 1473 Py_INCREF(new); 1474 _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc)); 1475 } 1476 1477 Dlg_UserItemProc_callback = new; 1478 return _res; 1479 1479 1480 1480 } 1481 1481 1482 1482 static PyMethodDef Dlg_methods[] = { 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1483 {"NewDialog", (PyCFunction)Dlg_NewDialog, 1, 1484 PyDoc_STR("(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)")}, 1485 {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1, 1486 PyDoc_STR("(SInt16 dialogID, WindowPtr behind) -> (DialogPtr _rv)")}, 1487 {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1, 1488 PyDoc_STR("(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)")}, 1489 {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1, 1490 PyDoc_STR("(PyObject* modalFilter) -> (DialogItemIndex itemHit)")}, 1491 {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1, 1492 PyDoc_STR("(EventRecord theEvent) -> (Boolean _rv)")}, 1493 {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1, 1494 PyDoc_STR("(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, DialogItemIndex itemHit)")}, 1495 {"Alert", (PyCFunction)Dlg_Alert, 1, 1496 PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")}, 1497 {"StopAlert", (PyCFunction)Dlg_StopAlert, 1, 1498 PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")}, 1499 {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1, 1500 PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")}, 1501 {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1, 1502 PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")}, 1503 {"ParamText", (PyCFunction)Dlg_ParamText, 1, 1504 PyDoc_STR("(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None")}, 1505 {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1, 1506 PyDoc_STR("(Handle item) -> (Str255 text)")}, 1507 {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1, 1508 PyDoc_STR("(Handle item, Str255 text) -> None")}, 1509 {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1, 1510 PyDoc_STR("() -> (SInt16 _rv)")}, 1511 {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1, 1512 PyDoc_STR("(SInt16 fontNum) -> None")}, 1513 {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, 1514 PyDoc_STR("() -> None")}, 1515 {"GetParamText", (PyCFunction)Dlg_GetParamText, 1, 1516 PyDoc_STR("(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None")}, 1517 {"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1, 1518 PyDoc_STR("(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)")}, 1519 {"GetDialogFromWindow", (PyCFunction)Dlg_GetDialogFromWindow, 1, 1520 PyDoc_STR("(WindowPtr window) -> (DialogPtr _rv)")}, 1521 {"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1, 1522 PyDoc_STR(NULL)}, 1523 {NULL, NULL, 0} 1524 1524 }; 1525 1525 … … 1531 1531 DlgObj_ConvertToWindow(PyObject *self) 1532 1532 { 1533 1534 1535 1533 if ( DlgObj_Check(self) ) 1534 return GetDialogWindow(((DialogObject *)self)->ob_itself); 1535 return NULL; 1536 1536 } 1537 1537 #endif … … 1541 1541 DlgObj_WhichDialog(DialogPtr d) 1542 1542 { 1543 PyObject *it; 1544 1545 if (d == NULL) { 1546 it = Py_None; 1547 Py_INCREF(it); 1543 PyObject *it; 1544 1545 if (d == NULL) { 1546 it = Py_None; 1547 Py_INCREF(it); 1548 } else { 1549 WindowPtr w = GetDialogWindow(d); 1550 1551 it = (PyObject *) GetWRefCon(w); 1552 if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) { 1553 #if 0 1554 /* Should do this, but we don't have an ob_freeit for dialogs yet. */ 1555 it = WinObj_New(w); 1556 ((WindowObject *)it)->ob_freeit = NULL; 1557 #else 1558 it = Py_None; 1559 Py_INCREF(it); 1560 #endif 1548 1561 } else { 1549 WindowPtr w = GetDialogWindow(d); 1550 1551 it = (PyObject *) GetWRefCon(w); 1552 if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) { 1553 #if 0 1554 /* Should do this, but we don't have an ob_freeit for dialogs yet. */ 1555 it = WinObj_New(w); 1556 ((WindowObject *)it)->ob_freeit = NULL; 1557 #else 1558 it = Py_None; 1559 Py_INCREF(it); 1560 #endif 1561 } else { 1562 Py_INCREF(it); 1563 } 1562 Py_INCREF(it); 1564 1563 } 1565 return it; 1564 } 1565 return it; 1566 1566 } 1567 1567 … … 1569 1569 1570 1570 static PyMethodDef Dlg_methods[] = { 1571 1571 {NULL, NULL, 0} 1572 1572 }; 1573 1573 … … 1577 1577 void init_Dlg(void) 1578 1578 { 1579 1579 PyObject *m; 1580 1580 #ifndef __LP64__ 1581 1582 1583 1584 1585 1586 1587 1581 PyObject *d; 1582 1583 1584 1585 PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New); 1586 PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog); 1587 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert); 1588 1588 #endif /* !__LP64__ */ 1589 1589 1590 1590 m = Py_InitModule("_Dlg", Dlg_methods); 1591 1591 1592 1592 #ifndef __LP64__ 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1593 d = PyModule_GetDict(m); 1594 Dlg_Error = PyMac_GetOSErrException(); 1595 if (Dlg_Error == NULL || 1596 PyDict_SetItemString(d, "Error", Dlg_Error) != 0) 1597 return; 1598 Dialog_Type.ob_type = &PyType_Type; 1599 if (PyType_Ready(&Dialog_Type) < 0) return; 1600 Py_INCREF(&Dialog_Type); 1601 PyModule_AddObject(m, "Dialog", (PyObject *)&Dialog_Type); 1602 /* Backward-compatible name */ 1603 Py_INCREF(&Dialog_Type); 1604 PyModule_AddObject(m, "DialogType", (PyObject *)&Dialog_Type); 1605 1605 #endif /* !__LP64__ */ 1606 1606 }
Note:
See TracChangeset
for help on using the changeset viewer.