Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1 | |
| 2 | /* ========================== Module waste ========================== */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
| 8 | #define SystemSevenOrLater 1 |
| 9 | |
| 10 | #include "macglue.h" |
| 11 | #include <Memory.h> |
| 12 | #include <Dialogs.h> |
| 13 | #include <Menus.h> |
| 14 | #include <Controls.h> |
| 15 | |
| 16 | extern PyObject *ResObj_New(Handle); |
| 17 | extern int ResObj_Convert(PyObject *, Handle *); |
| 18 | extern PyObject *OptResObj_New(Handle); |
| 19 | extern int OptResObj_Convert(PyObject *, Handle *); |
| 20 | |
| 21 | extern PyObject *WinObj_New(WindowPtr); |
| 22 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
| 23 | extern PyTypeObject Window_Type; |
| 24 | #define WinObj_Check(x) ((x)->ob_type == &Window_Type) |
| 25 | |
| 26 | extern PyObject *DlgObj_New(DialogPtr); |
| 27 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
| 28 | extern PyTypeObject Dialog_Type; |
| 29 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 30 | |
| 31 | extern PyObject *MenuObj_New(MenuHandle); |
| 32 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
| 33 | |
| 34 | extern PyObject *CtlObj_New(ControlHandle); |
| 35 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
| 36 | |
| 37 | extern PyObject *GrafObj_New(GrafPtr); |
| 38 | extern int GrafObj_Convert(PyObject *, GrafPtr *); |
| 39 | |
| 40 | extern PyObject *BMObj_New(BitMapPtr); |
| 41 | extern int BMObj_Convert(PyObject *, BitMapPtr *); |
| 42 | |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 43 | extern PyObject *WinObj_WhichWindow(WindowPtr); |
| 44 | |
| 45 | #include <WASTE.h> |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 46 | #include <WEObjectHandlers.h> |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 47 | |
| 48 | /* Exported by Qdmodule.c: */ |
| 49 | extern PyObject *QdRGB_New(RGBColor *); |
| 50 | extern int QdRGB_Convert(PyObject *, RGBColor *); |
| 51 | |
| 52 | /* Forward declaration */ |
| 53 | staticforward PyObject *WEOObj_New(WEObjectReference); |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 54 | staticforward PyObject *ExistingwasteObj_New(WEReference); |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 55 | |
| 56 | /* |
| 57 | ** Parse/generate TextStyle records |
| 58 | */ |
| 59 | static |
| 60 | PyObject *TextStyle_New(itself) |
| 61 | TextStylePtr itself; |
| 62 | { |
| 63 | |
| 64 | return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, |
| 65 | &itself->tsColor); |
| 66 | } |
| 67 | |
| 68 | static |
| 69 | TextStyle_Convert(v, p_itself) |
| 70 | PyObject *v; |
| 71 | TextStylePtr p_itself; |
| 72 | { |
| 73 | long font, face, size; |
| 74 | |
| 75 | if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) |
| 76 | return 0; |
| 77 | p_itself->tsFont = (short)font; |
| 78 | p_itself->tsFace = (Style)face; |
| 79 | p_itself->tsSize = (short)size; |
| 80 | return 1; |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | ** Parse/generate RunInfo records |
| 85 | */ |
| 86 | static |
| 87 | PyObject *RunInfo_New(itself) |
| 88 | WERunInfo *itself; |
| 89 | { |
| 90 | |
| 91 | return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight, |
| 92 | itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject); |
| 93 | } |
| 94 | |
| 95 | /* Conversion of long points and rects */ |
| 96 | int |
| 97 | LongRect_Convert(PyObject *v, LongRect *r) |
| 98 | { |
| 99 | return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom); |
| 100 | } |
| 101 | |
| 102 | PyObject * |
| 103 | LongRect_New(LongRect *r) |
| 104 | { |
| 105 | return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom); |
| 106 | } |
| 107 | |
| 108 | |
| 109 | LongPt_Convert(PyObject *v, LongPt *p) |
| 110 | { |
| 111 | return PyArg_Parse(v, "(ll)", &p->h, &p->v); |
| 112 | } |
| 113 | |
| 114 | PyObject * |
| 115 | LongPt_New(LongPt *p) |
| 116 | { |
| 117 | return Py_BuildValue("(ll)", p->h, p->v); |
| 118 | } |
| 119 | |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 120 | /* Stuff for the callbacks: */ |
| 121 | static PyObject *callbackdict; |
| 122 | UniversalProcPtr upp_new_handler, upp_dispose_handler, upp_draw_handler, upp_click_handler; |
| 123 | |
| 124 | static OSErr |
| 125 | any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv) |
| 126 | { |
| 127 | FlavorType tp; |
| 128 | PyObject *key, *func; |
| 129 | |
| 130 | if ( args == NULL ) return errAECorruptData; |
| 131 | |
| 132 | tp = WEGetObjectType(who); |
| 133 | |
| 134 | if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL) |
| 135 | return errAECorruptData; |
| 136 | if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) { |
| 137 | Py_DECREF(key); |
| 138 | return errAEHandlerNotFound; |
| 139 | } |
| 140 | Py_INCREF(func); |
| 141 | *rv = PyEval_CallObject(func, args); |
| 142 | Py_DECREF(func); |
| 143 | Py_DECREF(key); |
| 144 | if ( *rv == NULL ) { |
| 145 | fprintf(stderr, "--Exception in callback: "); |
| 146 | PyErr_Print(); |
| 147 | return errAEReplyNotArrived; |
| 148 | } |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | static pascal OSErr |
| 153 | my_new_handler(Point *objectSize, WEObjectReference objref) |
| 154 | { |
| 155 | PyObject *args=NULL, *rv=NULL; |
| 156 | OSErr err; |
| 157 | |
| 158 | args=Py_BuildValue("(O&)", WEOObj_New, objref); |
| 159 | err = any_handler(weNewHandler, objref, args, &rv); |
| 160 | if (!err) { |
| 161 | if (!PyMac_GetPoint(rv, objectSize) ) |
| 162 | err = errAECoercionFail; |
| 163 | } |
| 164 | if ( args ) Py_DECREF(args); |
| 165 | if ( rv ) Py_DECREF(rv); |
| 166 | return err; |
| 167 | } |
| 168 | |
| 169 | static pascal OSErr |
| 170 | my_dispose_handler(WEObjectReference objref) |
| 171 | { |
| 172 | PyObject *args=NULL, *rv=NULL; |
| 173 | OSErr err; |
| 174 | |
| 175 | args=Py_BuildValue("(O&)", WEOObj_New, objref); |
| 176 | err = any_handler(weDisposeHandler, objref, args, &rv); |
| 177 | if ( args ) Py_DECREF(args); |
| 178 | if ( rv ) Py_DECREF(rv); |
| 179 | return err; |
| 180 | } |
| 181 | |
| 182 | static pascal OSErr |
| 183 | my_draw_handler(Rect *destRect, WEObjectReference objref) |
| 184 | { |
| 185 | PyObject *args=NULL, *rv=NULL; |
| 186 | OSErr err; |
| 187 | |
| 188 | args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref); |
| 189 | err = any_handler(weDrawHandler, objref, args, &rv); |
| 190 | if ( args ) Py_DECREF(args); |
| 191 | if ( rv ) Py_DECREF(rv); |
| 192 | return err; |
| 193 | } |
| 194 | |
| 195 | static pascal Boolean |
| 196 | my_click_handler(Point hitPt, EventModifiers modifiers, |
| 197 | unsigned long clickTime, WEObjectReference objref) |
| 198 | { |
| 199 | PyObject *args=NULL, *rv=NULL; |
| 200 | int retvalue; |
| 201 | OSErr err; |
| 202 | |
| 203 | args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt, |
| 204 | (long)modifiers, (long)clickTime, WEOObj_New, objref); |
| 205 | err = any_handler(weClickHandler, objref, args, &rv); |
| 206 | if (!err) |
| 207 | retvalue = PyInt_AsLong(rv); |
| 208 | else |
| 209 | retvalue = 0; |
| 210 | if ( args ) Py_DECREF(args); |
| 211 | if ( rv ) Py_DECREF(rv); |
| 212 | return retvalue; |
| 213 | } |
| 214 | |
| 215 | |
| 216 | |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 217 | static PyObject *waste_Error; |
| 218 | |
| 219 | /* ------------------------ Object type WEO ------------------------- */ |
| 220 | |
| 221 | PyTypeObject WEO_Type; |
| 222 | |
| 223 | #define WEOObj_Check(x) ((x)->ob_type == &WEO_Type) |
| 224 | |
| 225 | typedef struct WEOObject { |
| 226 | PyObject_HEAD |
| 227 | WEObjectReference ob_itself; |
| 228 | } WEOObject; |
| 229 | |
| 230 | PyObject *WEOObj_New(itself) |
| 231 | WEObjectReference itself; |
| 232 | { |
| 233 | WEOObject *it; |
| 234 | if (itself == NULL) { |
| 235 | Py_INCREF(Py_None); |
| 236 | return Py_None; |
| 237 | } |
| 238 | it = PyObject_NEW(WEOObject, &WEO_Type); |
| 239 | if (it == NULL) return NULL; |
| 240 | it->ob_itself = itself; |
| 241 | return (PyObject *)it; |
| 242 | } |
| 243 | WEOObj_Convert(v, p_itself) |
| 244 | PyObject *v; |
| 245 | WEObjectReference *p_itself; |
| 246 | { |
| 247 | if (!WEOObj_Check(v)) |
| 248 | { |
| 249 | PyErr_SetString(PyExc_TypeError, "WEO required"); |
| 250 | return 0; |
| 251 | } |
| 252 | *p_itself = ((WEOObject *)v)->ob_itself; |
| 253 | return 1; |
| 254 | } |
| 255 | |
| 256 | static void WEOObj_dealloc(self) |
| 257 | WEOObject *self; |
| 258 | { |
| 259 | /* Cleanup of self->ob_itself goes here */ |
| 260 | PyMem_DEL(self); |
| 261 | } |
| 262 | |
| 263 | static PyObject *WEOObj_WEGetObjectType(_self, _args) |
| 264 | WEOObject *_self; |
| 265 | PyObject *_args; |
| 266 | { |
| 267 | PyObject *_res = NULL; |
| 268 | FlavorType _rv; |
| 269 | if (!PyArg_ParseTuple(_args, "")) |
| 270 | return NULL; |
| 271 | _rv = WEGetObjectType(_self->ob_itself); |
| 272 | _res = Py_BuildValue("O&", |
| 273 | PyMac_BuildOSType, _rv); |
| 274 | return _res; |
| 275 | } |
| 276 | |
| 277 | static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args) |
| 278 | WEOObject *_self; |
| 279 | PyObject *_args; |
| 280 | { |
| 281 | PyObject *_res = NULL; |
| 282 | Handle _rv; |
| 283 | if (!PyArg_ParseTuple(_args, "")) |
| 284 | return NULL; |
| 285 | _rv = WEGetObjectDataHandle(_self->ob_itself); |
| 286 | _res = Py_BuildValue("O&", |
| 287 | ResObj_New, _rv); |
| 288 | return _res; |
| 289 | } |
| 290 | |
| 291 | static PyObject *WEOObj_WEGetObjectSize(_self, _args) |
| 292 | WEOObject *_self; |
| 293 | PyObject *_args; |
| 294 | { |
| 295 | PyObject *_res = NULL; |
| 296 | Point _rv; |
| 297 | if (!PyArg_ParseTuple(_args, "")) |
| 298 | return NULL; |
| 299 | _rv = WEGetObjectSize(_self->ob_itself); |
| 300 | _res = Py_BuildValue("O&", |
| 301 | PyMac_BuildPoint, _rv); |
| 302 | return _res; |
| 303 | } |
| 304 | |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 305 | static PyObject *WEOObj_WEGetObjectOwner(_self, _args) |
| 306 | WEOObject *_self; |
| 307 | PyObject *_args; |
| 308 | { |
| 309 | PyObject *_res = NULL; |
| 310 | WEReference _rv; |
| 311 | if (!PyArg_ParseTuple(_args, "")) |
| 312 | return NULL; |
| 313 | _rv = WEGetObjectOwner(_self->ob_itself); |
| 314 | _res = Py_BuildValue("O&", |
| 315 | ExistingwasteObj_New, _rv); |
| 316 | return _res; |
| 317 | } |
| 318 | |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 319 | static PyObject *WEOObj_WEGetObjectRefCon(_self, _args) |
| 320 | WEOObject *_self; |
| 321 | PyObject *_args; |
| 322 | { |
| 323 | PyObject *_res = NULL; |
| 324 | long _rv; |
| 325 | if (!PyArg_ParseTuple(_args, "")) |
| 326 | return NULL; |
| 327 | _rv = WEGetObjectRefCon(_self->ob_itself); |
| 328 | _res = Py_BuildValue("l", |
| 329 | _rv); |
| 330 | return _res; |
| 331 | } |
| 332 | |
| 333 | static PyObject *WEOObj_WESetObjectRefCon(_self, _args) |
| 334 | WEOObject *_self; |
| 335 | PyObject *_args; |
| 336 | { |
| 337 | PyObject *_res = NULL; |
| 338 | long refCon; |
| 339 | if (!PyArg_ParseTuple(_args, "l", |
| 340 | &refCon)) |
| 341 | return NULL; |
| 342 | WESetObjectRefCon(_self->ob_itself, |
| 343 | refCon); |
| 344 | Py_INCREF(Py_None); |
| 345 | _res = Py_None; |
| 346 | return _res; |
| 347 | } |
| 348 | |
| 349 | static PyMethodDef WEOObj_methods[] = { |
| 350 | {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1, |
| 351 | "() -> (FlavorType _rv)"}, |
| 352 | {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1, |
| 353 | "() -> (Handle _rv)"}, |
| 354 | {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1, |
| 355 | "() -> (Point _rv)"}, |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 356 | {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1, |
| 357 | "() -> (WEReference _rv)"}, |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 358 | {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1, |
| 359 | "() -> (long _rv)"}, |
| 360 | {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1, |
| 361 | "(long refCon) -> None"}, |
| 362 | {NULL, NULL, 0} |
| 363 | }; |
| 364 | |
| 365 | PyMethodChain WEOObj_chain = { WEOObj_methods, NULL }; |
| 366 | |
| 367 | static PyObject *WEOObj_getattr(self, name) |
| 368 | WEOObject *self; |
| 369 | char *name; |
| 370 | { |
| 371 | return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name); |
| 372 | } |
| 373 | |
| 374 | #define WEOObj_setattr NULL |
| 375 | |
| 376 | PyTypeObject WEO_Type = { |
| 377 | PyObject_HEAD_INIT(&PyType_Type) |
| 378 | 0, /*ob_size*/ |
| 379 | "WEO", /*tp_name*/ |
| 380 | sizeof(WEOObject), /*tp_basicsize*/ |
| 381 | 0, /*tp_itemsize*/ |
| 382 | /* methods */ |
| 383 | (destructor) WEOObj_dealloc, /*tp_dealloc*/ |
| 384 | 0, /*tp_print*/ |
| 385 | (getattrfunc) WEOObj_getattr, /*tp_getattr*/ |
| 386 | (setattrfunc) WEOObj_setattr, /*tp_setattr*/ |
| 387 | }; |
| 388 | |
| 389 | /* ---------------------- End object type WEO ----------------------- */ |
| 390 | |
| 391 | |
| 392 | /* ----------------------- Object type waste ------------------------ */ |
| 393 | |
| 394 | PyTypeObject waste_Type; |
| 395 | |
| 396 | #define wasteObj_Check(x) ((x)->ob_type == &waste_Type) |
| 397 | |
| 398 | typedef struct wasteObject { |
| 399 | PyObject_HEAD |
| 400 | WEReference ob_itself; |
| 401 | } wasteObject; |
| 402 | |
| 403 | PyObject *wasteObj_New(itself) |
| 404 | WEReference itself; |
| 405 | { |
| 406 | wasteObject *it; |
| 407 | if (itself == NULL) { |
| 408 | PyErr_SetString(waste_Error,"Cannot create null WE"); |
| 409 | return NULL; |
| 410 | } |
| 411 | it = PyObject_NEW(wasteObject, &waste_Type); |
| 412 | if (it == NULL) return NULL; |
| 413 | it->ob_itself = itself; |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 414 | WESetInfo(weRefCon, (void *)&it, itself); |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 415 | return (PyObject *)it; |
| 416 | } |
| 417 | wasteObj_Convert(v, p_itself) |
| 418 | PyObject *v; |
| 419 | WEReference *p_itself; |
| 420 | { |
| 421 | if (!wasteObj_Check(v)) |
| 422 | { |
| 423 | PyErr_SetString(PyExc_TypeError, "waste required"); |
| 424 | return 0; |
| 425 | } |
| 426 | *p_itself = ((wasteObject *)v)->ob_itself; |
| 427 | return 1; |
| 428 | } |
| 429 | |
| 430 | static void wasteObj_dealloc(self) |
| 431 | wasteObject *self; |
| 432 | { |
| 433 | WEDispose(self->ob_itself); |
| 434 | PyMem_DEL(self); |
| 435 | } |
| 436 | |
| 437 | static PyObject *wasteObj_WEGetText(_self, _args) |
| 438 | wasteObject *_self; |
| 439 | PyObject *_args; |
| 440 | { |
| 441 | PyObject *_res = NULL; |
| 442 | Handle _rv; |
| 443 | if (!PyArg_ParseTuple(_args, "")) |
| 444 | return NULL; |
| 445 | _rv = WEGetText(_self->ob_itself); |
| 446 | _res = Py_BuildValue("O&", |
| 447 | ResObj_New, _rv); |
| 448 | return _res; |
| 449 | } |
| 450 | |
| 451 | static PyObject *wasteObj_WEGetChar(_self, _args) |
| 452 | wasteObject *_self; |
| 453 | PyObject *_args; |
| 454 | { |
| 455 | PyObject *_res = NULL; |
| 456 | short _rv; |
| 457 | long offset; |
| 458 | if (!PyArg_ParseTuple(_args, "l", |
| 459 | &offset)) |
| 460 | return NULL; |
| 461 | _rv = WEGetChar(offset, |
| 462 | _self->ob_itself); |
| 463 | _res = Py_BuildValue("h", |
| 464 | _rv); |
| 465 | return _res; |
| 466 | } |
| 467 | |
| 468 | static PyObject *wasteObj_WEGetTextLength(_self, _args) |
| 469 | wasteObject *_self; |
| 470 | PyObject *_args; |
| 471 | { |
| 472 | PyObject *_res = NULL; |
| 473 | long _rv; |
| 474 | if (!PyArg_ParseTuple(_args, "")) |
| 475 | return NULL; |
| 476 | _rv = WEGetTextLength(_self->ob_itself); |
| 477 | _res = Py_BuildValue("l", |
| 478 | _rv); |
| 479 | return _res; |
| 480 | } |
| 481 | |
| 482 | static PyObject *wasteObj_WECountLines(_self, _args) |
| 483 | wasteObject *_self; |
| 484 | PyObject *_args; |
| 485 | { |
| 486 | PyObject *_res = NULL; |
| 487 | long _rv; |
| 488 | if (!PyArg_ParseTuple(_args, "")) |
| 489 | return NULL; |
| 490 | _rv = WECountLines(_self->ob_itself); |
| 491 | _res = Py_BuildValue("l", |
| 492 | _rv); |
| 493 | return _res; |
| 494 | } |
| 495 | |
| 496 | static PyObject *wasteObj_WEGetHeight(_self, _args) |
| 497 | wasteObject *_self; |
| 498 | PyObject *_args; |
| 499 | { |
| 500 | PyObject *_res = NULL; |
| 501 | long _rv; |
| 502 | long startLine; |
| 503 | long endLine; |
| 504 | if (!PyArg_ParseTuple(_args, "ll", |
| 505 | &startLine, |
| 506 | &endLine)) |
| 507 | return NULL; |
| 508 | _rv = WEGetHeight(startLine, |
| 509 | endLine, |
| 510 | _self->ob_itself); |
| 511 | _res = Py_BuildValue("l", |
| 512 | _rv); |
| 513 | return _res; |
| 514 | } |
| 515 | |
| 516 | static PyObject *wasteObj_WEGetSelection(_self, _args) |
| 517 | wasteObject *_self; |
| 518 | PyObject *_args; |
| 519 | { |
| 520 | PyObject *_res = NULL; |
| 521 | long selStart; |
| 522 | long selEnd; |
| 523 | if (!PyArg_ParseTuple(_args, "")) |
| 524 | return NULL; |
| 525 | WEGetSelection(&selStart, |
| 526 | &selEnd, |
| 527 | _self->ob_itself); |
| 528 | _res = Py_BuildValue("ll", |
| 529 | selStart, |
| 530 | selEnd); |
| 531 | return _res; |
| 532 | } |
| 533 | |
| 534 | static PyObject *wasteObj_WEGetDestRect(_self, _args) |
| 535 | wasteObject *_self; |
| 536 | PyObject *_args; |
| 537 | { |
| 538 | PyObject *_res = NULL; |
| 539 | LongRect destRect; |
| 540 | if (!PyArg_ParseTuple(_args, "")) |
| 541 | return NULL; |
| 542 | WEGetDestRect(&destRect, |
| 543 | _self->ob_itself); |
| 544 | _res = Py_BuildValue("O&", |
| 545 | LongRect_New, &destRect); |
| 546 | return _res; |
| 547 | } |
| 548 | |
| 549 | static PyObject *wasteObj_WEGetViewRect(_self, _args) |
| 550 | wasteObject *_self; |
| 551 | PyObject *_args; |
| 552 | { |
| 553 | PyObject *_res = NULL; |
| 554 | LongRect viewRect; |
| 555 | if (!PyArg_ParseTuple(_args, "")) |
| 556 | return NULL; |
| 557 | WEGetViewRect(&viewRect, |
| 558 | _self->ob_itself); |
| 559 | _res = Py_BuildValue("O&", |
| 560 | LongRect_New, &viewRect); |
| 561 | return _res; |
| 562 | } |
| 563 | |
| 564 | static PyObject *wasteObj_WEIsActive(_self, _args) |
| 565 | wasteObject *_self; |
| 566 | PyObject *_args; |
| 567 | { |
| 568 | PyObject *_res = NULL; |
| 569 | Boolean _rv; |
| 570 | if (!PyArg_ParseTuple(_args, "")) |
| 571 | return NULL; |
| 572 | _rv = WEIsActive(_self->ob_itself); |
| 573 | _res = Py_BuildValue("b", |
| 574 | _rv); |
| 575 | return _res; |
| 576 | } |
| 577 | |
| 578 | static PyObject *wasteObj_WEOffsetToLine(_self, _args) |
| 579 | wasteObject *_self; |
| 580 | PyObject *_args; |
| 581 | { |
| 582 | PyObject *_res = NULL; |
| 583 | long _rv; |
| 584 | long offset; |
| 585 | if (!PyArg_ParseTuple(_args, "l", |
| 586 | &offset)) |
| 587 | return NULL; |
| 588 | _rv = WEOffsetToLine(offset, |
| 589 | _self->ob_itself); |
| 590 | _res = Py_BuildValue("l", |
| 591 | _rv); |
| 592 | return _res; |
| 593 | } |
| 594 | |
| 595 | static PyObject *wasteObj_WEGetLineRange(_self, _args) |
| 596 | wasteObject *_self; |
| 597 | PyObject *_args; |
| 598 | { |
| 599 | PyObject *_res = NULL; |
| 600 | long lineNo; |
| 601 | long lineStart; |
| 602 | long lineEnd; |
| 603 | if (!PyArg_ParseTuple(_args, "l", |
| 604 | &lineNo)) |
| 605 | return NULL; |
| 606 | WEGetLineRange(lineNo, |
| 607 | &lineStart, |
| 608 | &lineEnd, |
| 609 | _self->ob_itself); |
| 610 | _res = Py_BuildValue("ll", |
| 611 | lineStart, |
| 612 | lineEnd); |
| 613 | return _res; |
| 614 | } |
| 615 | |
| 616 | static PyObject *wasteObj_WESetSelection(_self, _args) |
| 617 | wasteObject *_self; |
| 618 | PyObject *_args; |
| 619 | { |
| 620 | PyObject *_res = NULL; |
| 621 | long selStart; |
| 622 | long selEnd; |
| 623 | if (!PyArg_ParseTuple(_args, "ll", |
| 624 | &selStart, |
| 625 | &selEnd)) |
| 626 | return NULL; |
| 627 | WESetSelection(selStart, |
| 628 | selEnd, |
| 629 | _self->ob_itself); |
| 630 | Py_INCREF(Py_None); |
| 631 | _res = Py_None; |
| 632 | return _res; |
| 633 | } |
| 634 | |
| 635 | static PyObject *wasteObj_WESetDestRect(_self, _args) |
| 636 | wasteObject *_self; |
| 637 | PyObject *_args; |
| 638 | { |
| 639 | PyObject *_res = NULL; |
| 640 | LongRect destRect; |
| 641 | if (!PyArg_ParseTuple(_args, "O&", |
| 642 | LongRect_Convert, &destRect)) |
| 643 | return NULL; |
| 644 | WESetDestRect(&destRect, |
| 645 | _self->ob_itself); |
| 646 | Py_INCREF(Py_None); |
| 647 | _res = Py_None; |
| 648 | return _res; |
| 649 | } |
| 650 | |
| 651 | static PyObject *wasteObj_WESetViewRect(_self, _args) |
| 652 | wasteObject *_self; |
| 653 | PyObject *_args; |
| 654 | { |
| 655 | PyObject *_res = NULL; |
| 656 | LongRect viewRect; |
| 657 | if (!PyArg_ParseTuple(_args, "O&", |
| 658 | LongRect_Convert, &viewRect)) |
| 659 | return NULL; |
| 660 | WESetViewRect(&viewRect, |
| 661 | _self->ob_itself); |
| 662 | Py_INCREF(Py_None); |
| 663 | _res = Py_None; |
| 664 | return _res; |
| 665 | } |
| 666 | |
| 667 | static PyObject *wasteObj_WEContinuousStyle(_self, _args) |
| 668 | wasteObject *_self; |
| 669 | PyObject *_args; |
| 670 | { |
| 671 | PyObject *_res = NULL; |
| 672 | Boolean _rv; |
| 673 | WEStyleMode mode; |
| 674 | TextStyle ts; |
Jack Jansen | 8ae8e4f | 1996-04-23 16:17:08 +0000 | [diff] [blame] | 675 | if (!PyArg_ParseTuple(_args, "h", |
| 676 | &mode)) |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 677 | return NULL; |
| 678 | _rv = WEContinuousStyle(&mode, |
| 679 | &ts, |
| 680 | _self->ob_itself); |
| 681 | _res = Py_BuildValue("bhO&", |
| 682 | _rv, |
| 683 | mode, |
| 684 | TextStyle_New, &ts); |
| 685 | return _res; |
| 686 | } |
| 687 | |
| 688 | static PyObject *wasteObj_WEGetRunInfo(_self, _args) |
| 689 | wasteObject *_self; |
| 690 | PyObject *_args; |
| 691 | { |
| 692 | PyObject *_res = NULL; |
| 693 | long offset; |
| 694 | WERunInfo runInfo; |
| 695 | if (!PyArg_ParseTuple(_args, "l", |
| 696 | &offset)) |
| 697 | return NULL; |
| 698 | WEGetRunInfo(offset, |
| 699 | &runInfo, |
| 700 | _self->ob_itself); |
| 701 | _res = Py_BuildValue("O&", |
| 702 | RunInfo_New, &runInfo); |
| 703 | return _res; |
| 704 | } |
| 705 | |
| 706 | static PyObject *wasteObj_WEGetOffset(_self, _args) |
| 707 | wasteObject *_self; |
| 708 | PyObject *_args; |
| 709 | { |
| 710 | PyObject *_res = NULL; |
| 711 | long _rv; |
| 712 | LongPt thePoint; |
| 713 | char edge; |
| 714 | if (!PyArg_ParseTuple(_args, "O&", |
| 715 | LongPt_Convert, &thePoint)) |
| 716 | return NULL; |
| 717 | _rv = WEGetOffset(&thePoint, |
| 718 | &edge, |
| 719 | _self->ob_itself); |
| 720 | _res = Py_BuildValue("lc", |
| 721 | _rv, |
| 722 | edge); |
| 723 | return _res; |
| 724 | } |
| 725 | |
| 726 | static PyObject *wasteObj_WEGetPoint(_self, _args) |
| 727 | wasteObject *_self; |
| 728 | PyObject *_args; |
| 729 | { |
| 730 | PyObject *_res = NULL; |
| 731 | long offset; |
| 732 | LongPt thePoint; |
| 733 | short lineHeight; |
| 734 | if (!PyArg_ParseTuple(_args, "l", |
| 735 | &offset)) |
| 736 | return NULL; |
| 737 | WEGetPoint(offset, |
| 738 | &thePoint, |
| 739 | &lineHeight, |
| 740 | _self->ob_itself); |
| 741 | _res = Py_BuildValue("O&h", |
| 742 | LongPt_New, &thePoint, |
| 743 | lineHeight); |
| 744 | return _res; |
| 745 | } |
| 746 | |
| 747 | static PyObject *wasteObj_WEFindWord(_self, _args) |
| 748 | wasteObject *_self; |
| 749 | PyObject *_args; |
| 750 | { |
| 751 | PyObject *_res = NULL; |
| 752 | long offset; |
| 753 | char edge; |
| 754 | long wordStart; |
| 755 | long wordEnd; |
| 756 | if (!PyArg_ParseTuple(_args, "lc", |
| 757 | &offset, |
| 758 | &edge)) |
| 759 | return NULL; |
| 760 | WEFindWord(offset, |
| 761 | edge, |
| 762 | &wordStart, |
| 763 | &wordEnd, |
| 764 | _self->ob_itself); |
| 765 | _res = Py_BuildValue("ll", |
| 766 | wordStart, |
| 767 | wordEnd); |
| 768 | return _res; |
| 769 | } |
| 770 | |
| 771 | static PyObject *wasteObj_WEFindLine(_self, _args) |
| 772 | wasteObject *_self; |
| 773 | PyObject *_args; |
| 774 | { |
| 775 | PyObject *_res = NULL; |
| 776 | long offset; |
| 777 | char edge; |
| 778 | long lineStart; |
| 779 | long lineEnd; |
| 780 | if (!PyArg_ParseTuple(_args, "lc", |
| 781 | &offset, |
| 782 | &edge)) |
| 783 | return NULL; |
| 784 | WEFindLine(offset, |
| 785 | edge, |
| 786 | &lineStart, |
| 787 | &lineEnd, |
| 788 | _self->ob_itself); |
| 789 | _res = Py_BuildValue("ll", |
| 790 | lineStart, |
| 791 | lineEnd); |
| 792 | return _res; |
| 793 | } |
| 794 | |
| 795 | static PyObject *wasteObj_WECopyRange(_self, _args) |
| 796 | wasteObject *_self; |
| 797 | PyObject *_args; |
| 798 | { |
| 799 | PyObject *_res = NULL; |
| 800 | OSErr _err; |
| 801 | long rangeStart; |
| 802 | long rangeEnd; |
| 803 | Handle hText; |
| 804 | StScrpHandle hStyles; |
| 805 | WESoupHandle hSoup; |
| 806 | if (!PyArg_ParseTuple(_args, "llO&O&O&", |
| 807 | &rangeStart, |
| 808 | &rangeEnd, |
Jack Jansen | 8ae8e4f | 1996-04-23 16:17:08 +0000 | [diff] [blame] | 809 | OptResObj_Convert, &hText, |
| 810 | OptResObj_Convert, &hStyles, |
| 811 | OptResObj_Convert, &hSoup)) |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 812 | return NULL; |
| 813 | _err = WECopyRange(rangeStart, |
| 814 | rangeEnd, |
| 815 | hText, |
| 816 | hStyles, |
| 817 | hSoup, |
| 818 | _self->ob_itself); |
| 819 | if (_err != noErr) return PyMac_Error(_err); |
| 820 | Py_INCREF(Py_None); |
| 821 | _res = Py_None; |
| 822 | return _res; |
| 823 | } |
| 824 | |
| 825 | static PyObject *wasteObj_WEGetAlignment(_self, _args) |
| 826 | wasteObject *_self; |
| 827 | PyObject *_args; |
| 828 | { |
| 829 | PyObject *_res = NULL; |
| 830 | WEAlignment _rv; |
| 831 | if (!PyArg_ParseTuple(_args, "")) |
| 832 | return NULL; |
| 833 | _rv = WEGetAlignment(_self->ob_itself); |
| 834 | _res = Py_BuildValue("b", |
| 835 | _rv); |
| 836 | return _res; |
| 837 | } |
| 838 | |
| 839 | static PyObject *wasteObj_WESetAlignment(_self, _args) |
| 840 | wasteObject *_self; |
| 841 | PyObject *_args; |
| 842 | { |
| 843 | PyObject *_res = NULL; |
| 844 | WEAlignment alignment; |
| 845 | if (!PyArg_ParseTuple(_args, "b", |
| 846 | &alignment)) |
| 847 | return NULL; |
| 848 | WESetAlignment(alignment, |
| 849 | _self->ob_itself); |
| 850 | Py_INCREF(Py_None); |
| 851 | _res = Py_None; |
| 852 | return _res; |
| 853 | } |
| 854 | |
| 855 | static PyObject *wasteObj_WECalText(_self, _args) |
| 856 | wasteObject *_self; |
| 857 | PyObject *_args; |
| 858 | { |
| 859 | PyObject *_res = NULL; |
| 860 | OSErr _err; |
| 861 | if (!PyArg_ParseTuple(_args, "")) |
| 862 | return NULL; |
| 863 | _err = WECalText(_self->ob_itself); |
| 864 | if (_err != noErr) return PyMac_Error(_err); |
| 865 | Py_INCREF(Py_None); |
| 866 | _res = Py_None; |
| 867 | return _res; |
| 868 | } |
| 869 | |
| 870 | static PyObject *wasteObj_WEUpdate(_self, _args) |
| 871 | wasteObject *_self; |
| 872 | PyObject *_args; |
| 873 | { |
| 874 | PyObject *_res = NULL; |
| 875 | RgnHandle updateRgn; |
| 876 | if (!PyArg_ParseTuple(_args, "O&", |
| 877 | ResObj_Convert, &updateRgn)) |
| 878 | return NULL; |
| 879 | WEUpdate(updateRgn, |
| 880 | _self->ob_itself); |
| 881 | Py_INCREF(Py_None); |
| 882 | _res = Py_None; |
| 883 | return _res; |
| 884 | } |
| 885 | |
| 886 | static PyObject *wasteObj_WEScroll(_self, _args) |
| 887 | wasteObject *_self; |
| 888 | PyObject *_args; |
| 889 | { |
| 890 | PyObject *_res = NULL; |
| 891 | long hOffset; |
| 892 | long vOffset; |
| 893 | if (!PyArg_ParseTuple(_args, "ll", |
| 894 | &hOffset, |
| 895 | &vOffset)) |
| 896 | return NULL; |
| 897 | WEScroll(hOffset, |
| 898 | vOffset, |
| 899 | _self->ob_itself); |
| 900 | Py_INCREF(Py_None); |
| 901 | _res = Py_None; |
| 902 | return _res; |
| 903 | } |
| 904 | |
| 905 | static PyObject *wasteObj_WESelView(_self, _args) |
| 906 | wasteObject *_self; |
| 907 | PyObject *_args; |
| 908 | { |
| 909 | PyObject *_res = NULL; |
| 910 | if (!PyArg_ParseTuple(_args, "")) |
| 911 | return NULL; |
| 912 | WESelView(_self->ob_itself); |
| 913 | Py_INCREF(Py_None); |
| 914 | _res = Py_None; |
| 915 | return _res; |
| 916 | } |
| 917 | |
| 918 | static PyObject *wasteObj_WEActivate(_self, _args) |
| 919 | wasteObject *_self; |
| 920 | PyObject *_args; |
| 921 | { |
| 922 | PyObject *_res = NULL; |
| 923 | if (!PyArg_ParseTuple(_args, "")) |
| 924 | return NULL; |
| 925 | WEActivate(_self->ob_itself); |
| 926 | Py_INCREF(Py_None); |
| 927 | _res = Py_None; |
| 928 | return _res; |
| 929 | } |
| 930 | |
| 931 | static PyObject *wasteObj_WEDeactivate(_self, _args) |
| 932 | wasteObject *_self; |
| 933 | PyObject *_args; |
| 934 | { |
| 935 | PyObject *_res = NULL; |
| 936 | if (!PyArg_ParseTuple(_args, "")) |
| 937 | return NULL; |
| 938 | WEDeactivate(_self->ob_itself); |
| 939 | Py_INCREF(Py_None); |
| 940 | _res = Py_None; |
| 941 | return _res; |
| 942 | } |
| 943 | |
| 944 | static PyObject *wasteObj_WEKey(_self, _args) |
| 945 | wasteObject *_self; |
| 946 | PyObject *_args; |
| 947 | { |
| 948 | PyObject *_res = NULL; |
| 949 | short key; |
| 950 | EventModifiers modifiers; |
| 951 | if (!PyArg_ParseTuple(_args, "hh", |
| 952 | &key, |
| 953 | &modifiers)) |
| 954 | return NULL; |
| 955 | WEKey(key, |
| 956 | modifiers, |
| 957 | _self->ob_itself); |
| 958 | Py_INCREF(Py_None); |
| 959 | _res = Py_None; |
| 960 | return _res; |
| 961 | } |
| 962 | |
| 963 | static PyObject *wasteObj_WEClick(_self, _args) |
| 964 | wasteObject *_self; |
| 965 | PyObject *_args; |
| 966 | { |
| 967 | PyObject *_res = NULL; |
| 968 | Point hitPt; |
| 969 | EventModifiers modifiers; |
| 970 | unsigned long clickTime; |
| 971 | if (!PyArg_ParseTuple(_args, "O&hl", |
| 972 | PyMac_GetPoint, &hitPt, |
| 973 | &modifiers, |
| 974 | &clickTime)) |
| 975 | return NULL; |
| 976 | WEClick(hitPt, |
| 977 | modifiers, |
| 978 | clickTime, |
| 979 | _self->ob_itself); |
| 980 | Py_INCREF(Py_None); |
| 981 | _res = Py_None; |
| 982 | return _res; |
| 983 | } |
| 984 | |
| 985 | static PyObject *wasteObj_WEAdjustCursor(_self, _args) |
| 986 | wasteObject *_self; |
| 987 | PyObject *_args; |
| 988 | { |
| 989 | PyObject *_res = NULL; |
| 990 | Boolean _rv; |
| 991 | Point mouseLoc; |
| 992 | RgnHandle mouseRgn; |
| 993 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 994 | PyMac_GetPoint, &mouseLoc, |
| 995 | ResObj_Convert, &mouseRgn)) |
| 996 | return NULL; |
| 997 | _rv = WEAdjustCursor(mouseLoc, |
| 998 | mouseRgn, |
| 999 | _self->ob_itself); |
| 1000 | _res = Py_BuildValue("b", |
| 1001 | _rv); |
| 1002 | return _res; |
| 1003 | } |
| 1004 | |
| 1005 | static PyObject *wasteObj_WEIdle(_self, _args) |
| 1006 | wasteObject *_self; |
| 1007 | PyObject *_args; |
| 1008 | { |
| 1009 | PyObject *_res = NULL; |
| 1010 | unsigned long maxSleep; |
| 1011 | if (!PyArg_ParseTuple(_args, "")) |
| 1012 | return NULL; |
| 1013 | WEIdle(&maxSleep, |
| 1014 | _self->ob_itself); |
| 1015 | _res = Py_BuildValue("l", |
| 1016 | maxSleep); |
| 1017 | return _res; |
| 1018 | } |
| 1019 | |
| 1020 | static PyObject *wasteObj_WEInsert(_self, _args) |
| 1021 | wasteObject *_self; |
| 1022 | PyObject *_args; |
| 1023 | { |
| 1024 | PyObject *_res = NULL; |
| 1025 | OSErr _err; |
| 1026 | char *pText__in__; |
| 1027 | long pText__len__; |
| 1028 | int pText__in_len__; |
| 1029 | StScrpHandle hStyles; |
| 1030 | WESoupHandle hSoup; |
| 1031 | if (!PyArg_ParseTuple(_args, "s#O&O&", |
| 1032 | &pText__in__, &pText__in_len__, |
Jack Jansen | 8ae8e4f | 1996-04-23 16:17:08 +0000 | [diff] [blame] | 1033 | OptResObj_Convert, &hStyles, |
| 1034 | OptResObj_Convert, &hSoup)) |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1035 | return NULL; |
| 1036 | pText__len__ = pText__in_len__; |
| 1037 | _err = WEInsert(pText__in__, pText__len__, |
| 1038 | hStyles, |
| 1039 | hSoup, |
| 1040 | _self->ob_itself); |
| 1041 | if (_err != noErr) return PyMac_Error(_err); |
| 1042 | Py_INCREF(Py_None); |
| 1043 | _res = Py_None; |
| 1044 | pText__error__: ; |
| 1045 | return _res; |
| 1046 | } |
| 1047 | |
| 1048 | static PyObject *wasteObj_WEDelete(_self, _args) |
| 1049 | wasteObject *_self; |
| 1050 | PyObject *_args; |
| 1051 | { |
| 1052 | PyObject *_res = NULL; |
| 1053 | OSErr _err; |
| 1054 | if (!PyArg_ParseTuple(_args, "")) |
| 1055 | return NULL; |
| 1056 | _err = WEDelete(_self->ob_itself); |
| 1057 | if (_err != noErr) return PyMac_Error(_err); |
| 1058 | Py_INCREF(Py_None); |
| 1059 | _res = Py_None; |
| 1060 | return _res; |
| 1061 | } |
| 1062 | |
| 1063 | static PyObject *wasteObj_WESetStyle(_self, _args) |
| 1064 | wasteObject *_self; |
| 1065 | PyObject *_args; |
| 1066 | { |
| 1067 | PyObject *_res = NULL; |
| 1068 | OSErr _err; |
| 1069 | WEStyleMode mode; |
| 1070 | TextStyle ts; |
| 1071 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1072 | &mode, |
| 1073 | TextStyle_Convert, &ts)) |
| 1074 | return NULL; |
| 1075 | _err = WESetStyle(mode, |
| 1076 | &ts, |
| 1077 | _self->ob_itself); |
| 1078 | if (_err != noErr) return PyMac_Error(_err); |
| 1079 | Py_INCREF(Py_None); |
| 1080 | _res = Py_None; |
| 1081 | return _res; |
| 1082 | } |
| 1083 | |
| 1084 | static PyObject *wasteObj_WEUseStyleScrap(_self, _args) |
| 1085 | wasteObject *_self; |
| 1086 | PyObject *_args; |
| 1087 | { |
| 1088 | PyObject *_res = NULL; |
| 1089 | OSErr _err; |
| 1090 | StScrpHandle hStyles; |
| 1091 | if (!PyArg_ParseTuple(_args, "O&", |
| 1092 | ResObj_Convert, &hStyles)) |
| 1093 | return NULL; |
| 1094 | _err = WEUseStyleScrap(hStyles, |
| 1095 | _self->ob_itself); |
| 1096 | if (_err != noErr) return PyMac_Error(_err); |
| 1097 | Py_INCREF(Py_None); |
| 1098 | _res = Py_None; |
| 1099 | return _res; |
| 1100 | } |
| 1101 | |
| 1102 | static PyObject *wasteObj_WEUseText(_self, _args) |
| 1103 | wasteObject *_self; |
| 1104 | PyObject *_args; |
| 1105 | { |
| 1106 | PyObject *_res = NULL; |
| 1107 | OSErr _err; |
| 1108 | Handle hText; |
| 1109 | if (!PyArg_ParseTuple(_args, "O&", |
| 1110 | ResObj_Convert, &hText)) |
| 1111 | return NULL; |
| 1112 | _err = WEUseText(hText, |
| 1113 | _self->ob_itself); |
| 1114 | if (_err != noErr) return PyMac_Error(_err); |
| 1115 | Py_INCREF(Py_None); |
| 1116 | _res = Py_None; |
| 1117 | return _res; |
| 1118 | } |
| 1119 | |
| 1120 | static PyObject *wasteObj_WEUndo(_self, _args) |
| 1121 | wasteObject *_self; |
| 1122 | PyObject *_args; |
| 1123 | { |
| 1124 | PyObject *_res = NULL; |
| 1125 | OSErr _err; |
| 1126 | if (!PyArg_ParseTuple(_args, "")) |
| 1127 | return NULL; |
| 1128 | _err = WEUndo(_self->ob_itself); |
| 1129 | if (_err != noErr) return PyMac_Error(_err); |
| 1130 | Py_INCREF(Py_None); |
| 1131 | _res = Py_None; |
| 1132 | return _res; |
| 1133 | } |
| 1134 | |
| 1135 | static PyObject *wasteObj_WEClearUndo(_self, _args) |
| 1136 | wasteObject *_self; |
| 1137 | PyObject *_args; |
| 1138 | { |
| 1139 | PyObject *_res = NULL; |
| 1140 | if (!PyArg_ParseTuple(_args, "")) |
| 1141 | return NULL; |
| 1142 | WEClearUndo(_self->ob_itself); |
| 1143 | Py_INCREF(Py_None); |
| 1144 | _res = Py_None; |
| 1145 | return _res; |
| 1146 | } |
| 1147 | |
| 1148 | static PyObject *wasteObj_WEGetUndoInfo(_self, _args) |
| 1149 | wasteObject *_self; |
| 1150 | PyObject *_args; |
| 1151 | { |
| 1152 | PyObject *_res = NULL; |
| 1153 | WEActionKind _rv; |
| 1154 | Boolean redoFlag; |
| 1155 | if (!PyArg_ParseTuple(_args, "")) |
| 1156 | return NULL; |
| 1157 | _rv = WEGetUndoInfo(&redoFlag, |
| 1158 | _self->ob_itself); |
| 1159 | _res = Py_BuildValue("hb", |
| 1160 | _rv, |
| 1161 | redoFlag); |
| 1162 | return _res; |
| 1163 | } |
| 1164 | |
| 1165 | static PyObject *wasteObj_WEIsTyping(_self, _args) |
| 1166 | wasteObject *_self; |
| 1167 | PyObject *_args; |
| 1168 | { |
| 1169 | PyObject *_res = NULL; |
| 1170 | Boolean _rv; |
| 1171 | if (!PyArg_ParseTuple(_args, "")) |
| 1172 | return NULL; |
| 1173 | _rv = WEIsTyping(_self->ob_itself); |
| 1174 | _res = Py_BuildValue("b", |
| 1175 | _rv); |
| 1176 | return _res; |
| 1177 | } |
| 1178 | |
| 1179 | static PyObject *wasteObj_WEGetModCount(_self, _args) |
| 1180 | wasteObject *_self; |
| 1181 | PyObject *_args; |
| 1182 | { |
| 1183 | PyObject *_res = NULL; |
| 1184 | unsigned long _rv; |
| 1185 | if (!PyArg_ParseTuple(_args, "")) |
| 1186 | return NULL; |
| 1187 | _rv = WEGetModCount(_self->ob_itself); |
| 1188 | _res = Py_BuildValue("l", |
| 1189 | _rv); |
| 1190 | return _res; |
| 1191 | } |
| 1192 | |
| 1193 | static PyObject *wasteObj_WEResetModCount(_self, _args) |
| 1194 | wasteObject *_self; |
| 1195 | PyObject *_args; |
| 1196 | { |
| 1197 | PyObject *_res = NULL; |
| 1198 | if (!PyArg_ParseTuple(_args, "")) |
| 1199 | return NULL; |
| 1200 | WEResetModCount(_self->ob_itself); |
| 1201 | Py_INCREF(Py_None); |
| 1202 | _res = Py_None; |
| 1203 | return _res; |
| 1204 | } |
| 1205 | |
| 1206 | static PyObject *wasteObj_WEInsertObject(_self, _args) |
| 1207 | wasteObject *_self; |
| 1208 | PyObject *_args; |
| 1209 | { |
| 1210 | PyObject *_res = NULL; |
| 1211 | OSErr _err; |
| 1212 | FlavorType objectType; |
| 1213 | Handle objectDataHandle; |
| 1214 | Point objectSize; |
| 1215 | if (!PyArg_ParseTuple(_args, "O&O&O&", |
| 1216 | PyMac_GetOSType, &objectType, |
| 1217 | ResObj_Convert, &objectDataHandle, |
| 1218 | PyMac_GetPoint, &objectSize)) |
| 1219 | return NULL; |
| 1220 | _err = WEInsertObject(objectType, |
| 1221 | objectDataHandle, |
| 1222 | objectSize, |
| 1223 | _self->ob_itself); |
| 1224 | if (_err != noErr) return PyMac_Error(_err); |
| 1225 | Py_INCREF(Py_None); |
| 1226 | _res = Py_None; |
| 1227 | return _res; |
| 1228 | } |
| 1229 | |
| 1230 | static PyObject *wasteObj_WEGetSelectedObject(_self, _args) |
| 1231 | wasteObject *_self; |
| 1232 | PyObject *_args; |
| 1233 | { |
| 1234 | PyObject *_res = NULL; |
| 1235 | OSErr _err; |
| 1236 | WEObjectReference obj; |
| 1237 | if (!PyArg_ParseTuple(_args, "")) |
| 1238 | return NULL; |
| 1239 | _err = WEGetSelectedObject(&obj, |
| 1240 | _self->ob_itself); |
| 1241 | if (_err != noErr) return PyMac_Error(_err); |
| 1242 | _res = Py_BuildValue("O&", |
| 1243 | WEOObj_New, obj); |
| 1244 | return _res; |
| 1245 | } |
| 1246 | |
| 1247 | static PyObject *wasteObj_WEFindNextObject(_self, _args) |
| 1248 | wasteObject *_self; |
| 1249 | PyObject *_args; |
| 1250 | { |
| 1251 | PyObject *_res = NULL; |
| 1252 | long _rv; |
| 1253 | long offset; |
| 1254 | WEObjectReference obj; |
| 1255 | if (!PyArg_ParseTuple(_args, "l", |
| 1256 | &offset)) |
| 1257 | return NULL; |
| 1258 | _rv = WEFindNextObject(offset, |
| 1259 | &obj, |
| 1260 | _self->ob_itself); |
| 1261 | _res = Py_BuildValue("lO&", |
| 1262 | _rv, |
| 1263 | WEOObj_New, obj); |
| 1264 | return _res; |
| 1265 | } |
| 1266 | |
| 1267 | static PyObject *wasteObj_WEUseSoup(_self, _args) |
| 1268 | wasteObject *_self; |
| 1269 | PyObject *_args; |
| 1270 | { |
| 1271 | PyObject *_res = NULL; |
| 1272 | OSErr _err; |
| 1273 | WESoupHandle hSoup; |
| 1274 | if (!PyArg_ParseTuple(_args, "O&", |
| 1275 | ResObj_Convert, &hSoup)) |
| 1276 | return NULL; |
| 1277 | _err = WEUseSoup(hSoup, |
| 1278 | _self->ob_itself); |
| 1279 | if (_err != noErr) return PyMac_Error(_err); |
| 1280 | Py_INCREF(Py_None); |
| 1281 | _res = Py_None; |
| 1282 | return _res; |
| 1283 | } |
| 1284 | |
| 1285 | static PyObject *wasteObj_WECut(_self, _args) |
| 1286 | wasteObject *_self; |
| 1287 | PyObject *_args; |
| 1288 | { |
| 1289 | PyObject *_res = NULL; |
| 1290 | OSErr _err; |
| 1291 | if (!PyArg_ParseTuple(_args, "")) |
| 1292 | return NULL; |
| 1293 | _err = WECut(_self->ob_itself); |
| 1294 | if (_err != noErr) return PyMac_Error(_err); |
| 1295 | Py_INCREF(Py_None); |
| 1296 | _res = Py_None; |
| 1297 | return _res; |
| 1298 | } |
| 1299 | |
| 1300 | static PyObject *wasteObj_WECopy(_self, _args) |
| 1301 | wasteObject *_self; |
| 1302 | PyObject *_args; |
| 1303 | { |
| 1304 | PyObject *_res = NULL; |
| 1305 | OSErr _err; |
| 1306 | if (!PyArg_ParseTuple(_args, "")) |
| 1307 | return NULL; |
| 1308 | _err = WECopy(_self->ob_itself); |
| 1309 | if (_err != noErr) return PyMac_Error(_err); |
| 1310 | Py_INCREF(Py_None); |
| 1311 | _res = Py_None; |
| 1312 | return _res; |
| 1313 | } |
| 1314 | |
| 1315 | static PyObject *wasteObj_WEPaste(_self, _args) |
| 1316 | wasteObject *_self; |
| 1317 | PyObject *_args; |
| 1318 | { |
| 1319 | PyObject *_res = NULL; |
| 1320 | OSErr _err; |
| 1321 | if (!PyArg_ParseTuple(_args, "")) |
| 1322 | return NULL; |
| 1323 | _err = WEPaste(_self->ob_itself); |
| 1324 | if (_err != noErr) return PyMac_Error(_err); |
| 1325 | Py_INCREF(Py_None); |
| 1326 | _res = Py_None; |
| 1327 | return _res; |
| 1328 | } |
| 1329 | |
| 1330 | static PyObject *wasteObj_WECanPaste(_self, _args) |
| 1331 | wasteObject *_self; |
| 1332 | PyObject *_args; |
| 1333 | { |
| 1334 | PyObject *_res = NULL; |
| 1335 | Boolean _rv; |
| 1336 | if (!PyArg_ParseTuple(_args, "")) |
| 1337 | return NULL; |
| 1338 | _rv = WECanPaste(_self->ob_itself); |
| 1339 | _res = Py_BuildValue("b", |
| 1340 | _rv); |
| 1341 | return _res; |
| 1342 | } |
| 1343 | |
| 1344 | static PyObject *wasteObj_WEGetHiliteRgn(_self, _args) |
| 1345 | wasteObject *_self; |
| 1346 | PyObject *_args; |
| 1347 | { |
| 1348 | PyObject *_res = NULL; |
| 1349 | RgnHandle _rv; |
| 1350 | long rangeStart; |
| 1351 | long rangeEnd; |
| 1352 | if (!PyArg_ParseTuple(_args, "ll", |
| 1353 | &rangeStart, |
| 1354 | &rangeEnd)) |
| 1355 | return NULL; |
| 1356 | _rv = WEGetHiliteRgn(rangeStart, |
| 1357 | rangeEnd, |
| 1358 | _self->ob_itself); |
| 1359 | _res = Py_BuildValue("O&", |
| 1360 | ResObj_New, _rv); |
| 1361 | return _res; |
| 1362 | } |
| 1363 | |
| 1364 | static PyObject *wasteObj_WECharByte(_self, _args) |
| 1365 | wasteObject *_self; |
| 1366 | PyObject *_args; |
| 1367 | { |
| 1368 | PyObject *_res = NULL; |
| 1369 | short _rv; |
| 1370 | long offset; |
| 1371 | if (!PyArg_ParseTuple(_args, "l", |
| 1372 | &offset)) |
| 1373 | return NULL; |
| 1374 | _rv = WECharByte(offset, |
| 1375 | _self->ob_itself); |
| 1376 | _res = Py_BuildValue("h", |
| 1377 | _rv); |
| 1378 | return _res; |
| 1379 | } |
| 1380 | |
| 1381 | static PyObject *wasteObj_WECharType(_self, _args) |
| 1382 | wasteObject *_self; |
| 1383 | PyObject *_args; |
| 1384 | { |
| 1385 | PyObject *_res = NULL; |
| 1386 | short _rv; |
| 1387 | long offset; |
| 1388 | if (!PyArg_ParseTuple(_args, "l", |
| 1389 | &offset)) |
| 1390 | return NULL; |
| 1391 | _rv = WECharType(offset, |
| 1392 | _self->ob_itself); |
| 1393 | _res = Py_BuildValue("h", |
| 1394 | _rv); |
| 1395 | return _res; |
| 1396 | } |
| 1397 | |
| 1398 | static PyObject *wasteObj_WEStopInlineSession(_self, _args) |
| 1399 | wasteObject *_self; |
| 1400 | PyObject *_args; |
| 1401 | { |
| 1402 | PyObject *_res = NULL; |
| 1403 | if (!PyArg_ParseTuple(_args, "")) |
| 1404 | return NULL; |
| 1405 | WEStopInlineSession(_self->ob_itself); |
| 1406 | Py_INCREF(Py_None); |
| 1407 | _res = Py_None; |
| 1408 | return _res; |
| 1409 | } |
| 1410 | |
| 1411 | static PyObject *wasteObj_WEFeatureFlag(_self, _args) |
| 1412 | wasteObject *_self; |
| 1413 | PyObject *_args; |
| 1414 | { |
| 1415 | PyObject *_res = NULL; |
| 1416 | short _rv; |
| 1417 | short feature; |
| 1418 | short action; |
| 1419 | if (!PyArg_ParseTuple(_args, "hh", |
| 1420 | &feature, |
| 1421 | &action)) |
| 1422 | return NULL; |
| 1423 | _rv = WEFeatureFlag(feature, |
| 1424 | action, |
| 1425 | _self->ob_itself); |
| 1426 | _res = Py_BuildValue("h", |
| 1427 | _rv); |
| 1428 | return _res; |
| 1429 | } |
| 1430 | |
| 1431 | static PyMethodDef wasteObj_methods[] = { |
| 1432 | {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1, |
| 1433 | "() -> (Handle _rv)"}, |
| 1434 | {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1, |
| 1435 | "(long offset) -> (short _rv)"}, |
| 1436 | {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1, |
| 1437 | "() -> (long _rv)"}, |
| 1438 | {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1, |
| 1439 | "() -> (long _rv)"}, |
| 1440 | {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1, |
| 1441 | "(long startLine, long endLine) -> (long _rv)"}, |
| 1442 | {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1, |
| 1443 | "() -> (long selStart, long selEnd)"}, |
| 1444 | {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1, |
| 1445 | "() -> (LongRect destRect)"}, |
| 1446 | {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1, |
| 1447 | "() -> (LongRect viewRect)"}, |
| 1448 | {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1, |
| 1449 | "() -> (Boolean _rv)"}, |
| 1450 | {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1, |
| 1451 | "(long offset) -> (long _rv)"}, |
| 1452 | {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1, |
| 1453 | "(long lineNo) -> (long lineStart, long lineEnd)"}, |
| 1454 | {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1, |
| 1455 | "(long selStart, long selEnd) -> None"}, |
| 1456 | {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1, |
| 1457 | "(LongRect destRect) -> None"}, |
| 1458 | {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1, |
| 1459 | "(LongRect viewRect) -> None"}, |
| 1460 | {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1, |
Jack Jansen | 8ae8e4f | 1996-04-23 16:17:08 +0000 | [diff] [blame] | 1461 | "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"}, |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1462 | {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1, |
| 1463 | "(long offset) -> (WERunInfo runInfo)"}, |
| 1464 | {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1, |
| 1465 | "(LongPt thePoint) -> (long _rv, char edge)"}, |
| 1466 | {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1, |
| 1467 | "(long offset) -> (LongPt thePoint, short lineHeight)"}, |
| 1468 | {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1, |
| 1469 | "(long offset, char edge) -> (long wordStart, long wordEnd)"}, |
| 1470 | {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1, |
| 1471 | "(long offset, char edge) -> (long lineStart, long lineEnd)"}, |
| 1472 | {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1, |
| 1473 | "(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"}, |
| 1474 | {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1, |
| 1475 | "() -> (WEAlignment _rv)"}, |
| 1476 | {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1, |
| 1477 | "(WEAlignment alignment) -> None"}, |
| 1478 | {"WECalText", (PyCFunction)wasteObj_WECalText, 1, |
| 1479 | "() -> None"}, |
| 1480 | {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1, |
| 1481 | "(RgnHandle updateRgn) -> None"}, |
| 1482 | {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1, |
| 1483 | "(long hOffset, long vOffset) -> None"}, |
| 1484 | {"WESelView", (PyCFunction)wasteObj_WESelView, 1, |
| 1485 | "() -> None"}, |
| 1486 | {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1, |
| 1487 | "() -> None"}, |
| 1488 | {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1, |
| 1489 | "() -> None"}, |
| 1490 | {"WEKey", (PyCFunction)wasteObj_WEKey, 1, |
| 1491 | "(short key, EventModifiers modifiers) -> None"}, |
| 1492 | {"WEClick", (PyCFunction)wasteObj_WEClick, 1, |
| 1493 | "(Point hitPt, EventModifiers modifiers, unsigned long clickTime) -> None"}, |
| 1494 | {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1, |
| 1495 | "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"}, |
| 1496 | {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1, |
| 1497 | "() -> (unsigned long maxSleep)"}, |
| 1498 | {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1, |
| 1499 | "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"}, |
| 1500 | {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1, |
| 1501 | "() -> None"}, |
| 1502 | {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1, |
| 1503 | "(WEStyleMode mode, TextStyle ts) -> None"}, |
| 1504 | {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1, |
| 1505 | "(StScrpHandle hStyles) -> None"}, |
| 1506 | {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1, |
| 1507 | "(Handle hText) -> None"}, |
| 1508 | {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1, |
| 1509 | "() -> None"}, |
| 1510 | {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1, |
| 1511 | "() -> None"}, |
| 1512 | {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1, |
| 1513 | "() -> (WEActionKind _rv, Boolean redoFlag)"}, |
| 1514 | {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1, |
| 1515 | "() -> (Boolean _rv)"}, |
| 1516 | {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1, |
| 1517 | "() -> (unsigned long _rv)"}, |
| 1518 | {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1, |
| 1519 | "() -> None"}, |
| 1520 | {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1, |
| 1521 | "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"}, |
| 1522 | {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1, |
| 1523 | "() -> (WEObjectReference obj)"}, |
| 1524 | {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1, |
| 1525 | "(long offset) -> (long _rv, WEObjectReference obj)"}, |
| 1526 | {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1, |
| 1527 | "(WESoupHandle hSoup) -> None"}, |
| 1528 | {"WECut", (PyCFunction)wasteObj_WECut, 1, |
| 1529 | "() -> None"}, |
| 1530 | {"WECopy", (PyCFunction)wasteObj_WECopy, 1, |
| 1531 | "() -> None"}, |
| 1532 | {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1, |
| 1533 | "() -> None"}, |
| 1534 | {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1, |
| 1535 | "() -> (Boolean _rv)"}, |
| 1536 | {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1, |
| 1537 | "(long rangeStart, long rangeEnd) -> (RgnHandle _rv)"}, |
| 1538 | {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1, |
| 1539 | "(long offset) -> (short _rv)"}, |
| 1540 | {"WECharType", (PyCFunction)wasteObj_WECharType, 1, |
| 1541 | "(long offset) -> (short _rv)"}, |
| 1542 | {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1, |
| 1543 | "() -> None"}, |
| 1544 | {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1, |
| 1545 | "(short feature, short action) -> (short _rv)"}, |
| 1546 | {NULL, NULL, 0} |
| 1547 | }; |
| 1548 | |
| 1549 | PyMethodChain wasteObj_chain = { wasteObj_methods, NULL }; |
| 1550 | |
| 1551 | static PyObject *wasteObj_getattr(self, name) |
| 1552 | wasteObject *self; |
| 1553 | char *name; |
| 1554 | { |
| 1555 | return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name); |
| 1556 | } |
| 1557 | |
| 1558 | #define wasteObj_setattr NULL |
| 1559 | |
| 1560 | PyTypeObject waste_Type = { |
| 1561 | PyObject_HEAD_INIT(&PyType_Type) |
| 1562 | 0, /*ob_size*/ |
| 1563 | "waste", /*tp_name*/ |
| 1564 | sizeof(wasteObject), /*tp_basicsize*/ |
| 1565 | 0, /*tp_itemsize*/ |
| 1566 | /* methods */ |
| 1567 | (destructor) wasteObj_dealloc, /*tp_dealloc*/ |
| 1568 | 0, /*tp_print*/ |
| 1569 | (getattrfunc) wasteObj_getattr, /*tp_getattr*/ |
| 1570 | (setattrfunc) wasteObj_setattr, /*tp_setattr*/ |
| 1571 | }; |
| 1572 | |
| 1573 | /* --------------------- End object type waste ---------------------- */ |
| 1574 | |
| 1575 | |
| 1576 | static PyObject *waste_WENew(_self, _args) |
| 1577 | PyObject *_self; |
| 1578 | PyObject *_args; |
| 1579 | { |
| 1580 | PyObject *_res = NULL; |
| 1581 | OSErr _err; |
| 1582 | LongRect destRect; |
| 1583 | LongRect viewRect; |
| 1584 | unsigned long flags; |
| 1585 | WEReference we; |
| 1586 | if (!PyArg_ParseTuple(_args, "O&O&l", |
| 1587 | LongRect_Convert, &destRect, |
| 1588 | LongRect_Convert, &viewRect, |
| 1589 | &flags)) |
| 1590 | return NULL; |
| 1591 | _err = WENew(&destRect, |
| 1592 | &viewRect, |
| 1593 | flags, |
| 1594 | &we); |
| 1595 | if (_err != noErr) return PyMac_Error(_err); |
| 1596 | _res = Py_BuildValue("O&", |
| 1597 | wasteObj_New, we); |
| 1598 | return _res; |
| 1599 | } |
| 1600 | |
| 1601 | static PyObject *waste_WEInstallTSMHandlers(_self, _args) |
| 1602 | PyObject *_self; |
| 1603 | PyObject *_args; |
| 1604 | { |
| 1605 | PyObject *_res = NULL; |
| 1606 | OSErr _err; |
| 1607 | if (!PyArg_ParseTuple(_args, "")) |
| 1608 | return NULL; |
| 1609 | _err = WEInstallTSMHandlers(); |
| 1610 | if (_err != noErr) return PyMac_Error(_err); |
| 1611 | Py_INCREF(Py_None); |
| 1612 | _res = Py_None; |
| 1613 | return _res; |
| 1614 | } |
| 1615 | |
| 1616 | static PyObject *waste_WERemoveTSMHandlers(_self, _args) |
| 1617 | PyObject *_self; |
| 1618 | PyObject *_args; |
| 1619 | { |
| 1620 | PyObject *_res = NULL; |
| 1621 | OSErr _err; |
| 1622 | if (!PyArg_ParseTuple(_args, "")) |
| 1623 | return NULL; |
| 1624 | _err = WERemoveTSMHandlers(); |
| 1625 | if (_err != noErr) return PyMac_Error(_err); |
| 1626 | Py_INCREF(Py_None); |
| 1627 | _res = Py_None; |
| 1628 | return _res; |
| 1629 | } |
| 1630 | |
| 1631 | static PyObject *waste_WELongPointToPoint(_self, _args) |
| 1632 | PyObject *_self; |
| 1633 | PyObject *_args; |
| 1634 | { |
| 1635 | PyObject *_res = NULL; |
| 1636 | LongPt lp; |
| 1637 | Point p; |
| 1638 | if (!PyArg_ParseTuple(_args, "O&", |
| 1639 | LongPt_Convert, &lp)) |
| 1640 | return NULL; |
| 1641 | WELongPointToPoint(&lp, |
| 1642 | &p); |
| 1643 | _res = Py_BuildValue("O&", |
| 1644 | PyMac_BuildPoint, p); |
| 1645 | return _res; |
| 1646 | } |
| 1647 | |
| 1648 | static PyObject *waste_WEPointToLongPoint(_self, _args) |
| 1649 | PyObject *_self; |
| 1650 | PyObject *_args; |
| 1651 | { |
| 1652 | PyObject *_res = NULL; |
| 1653 | Point p; |
| 1654 | LongPt lp; |
| 1655 | if (!PyArg_ParseTuple(_args, "O&", |
| 1656 | PyMac_GetPoint, &p)) |
| 1657 | return NULL; |
| 1658 | WEPointToLongPoint(p, |
| 1659 | &lp); |
| 1660 | _res = Py_BuildValue("O&", |
| 1661 | LongPt_New, &lp); |
| 1662 | return _res; |
| 1663 | } |
| 1664 | |
| 1665 | static PyObject *waste_WESetLongRect(_self, _args) |
| 1666 | PyObject *_self; |
| 1667 | PyObject *_args; |
| 1668 | { |
| 1669 | PyObject *_res = NULL; |
| 1670 | LongRect lr; |
| 1671 | long left; |
| 1672 | long top; |
| 1673 | long right; |
| 1674 | long bottom; |
| 1675 | if (!PyArg_ParseTuple(_args, "llll", |
| 1676 | &left, |
| 1677 | &top, |
| 1678 | &right, |
| 1679 | &bottom)) |
| 1680 | return NULL; |
| 1681 | WESetLongRect(&lr, |
| 1682 | left, |
| 1683 | top, |
| 1684 | right, |
| 1685 | bottom); |
| 1686 | _res = Py_BuildValue("O&", |
| 1687 | LongRect_New, &lr); |
| 1688 | return _res; |
| 1689 | } |
| 1690 | |
| 1691 | static PyObject *waste_WELongRectToRect(_self, _args) |
| 1692 | PyObject *_self; |
| 1693 | PyObject *_args; |
| 1694 | { |
| 1695 | PyObject *_res = NULL; |
| 1696 | LongRect lr; |
| 1697 | Rect r; |
| 1698 | if (!PyArg_ParseTuple(_args, "O&", |
| 1699 | LongRect_Convert, &lr)) |
| 1700 | return NULL; |
| 1701 | WELongRectToRect(&lr, |
| 1702 | &r); |
| 1703 | _res = Py_BuildValue("O&", |
| 1704 | PyMac_BuildRect, &r); |
| 1705 | return _res; |
| 1706 | } |
| 1707 | |
| 1708 | static PyObject *waste_WERectToLongRect(_self, _args) |
| 1709 | PyObject *_self; |
| 1710 | PyObject *_args; |
| 1711 | { |
| 1712 | PyObject *_res = NULL; |
| 1713 | Rect r; |
| 1714 | LongRect lr; |
| 1715 | if (!PyArg_ParseTuple(_args, "O&", |
| 1716 | PyMac_GetRect, &r)) |
| 1717 | return NULL; |
| 1718 | WERectToLongRect(&r, |
| 1719 | &lr); |
| 1720 | _res = Py_BuildValue("O&", |
| 1721 | LongRect_New, &lr); |
| 1722 | return _res; |
| 1723 | } |
| 1724 | |
| 1725 | static PyObject *waste_WEOffsetLongRect(_self, _args) |
| 1726 | PyObject *_self; |
| 1727 | PyObject *_args; |
| 1728 | { |
| 1729 | PyObject *_res = NULL; |
| 1730 | LongRect lr; |
| 1731 | long hOffset; |
| 1732 | long vOffset; |
| 1733 | if (!PyArg_ParseTuple(_args, "ll", |
| 1734 | &hOffset, |
| 1735 | &vOffset)) |
| 1736 | return NULL; |
| 1737 | WEOffsetLongRect(&lr, |
| 1738 | hOffset, |
| 1739 | vOffset); |
| 1740 | _res = Py_BuildValue("O&", |
| 1741 | LongRect_New, &lr); |
| 1742 | return _res; |
| 1743 | } |
| 1744 | |
| 1745 | static PyObject *waste_WELongPointInLongRect(_self, _args) |
| 1746 | PyObject *_self; |
| 1747 | PyObject *_args; |
| 1748 | { |
| 1749 | PyObject *_res = NULL; |
| 1750 | Boolean _rv; |
| 1751 | LongPt lp; |
| 1752 | LongRect lr; |
| 1753 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1754 | LongPt_Convert, &lp, |
| 1755 | LongRect_Convert, &lr)) |
| 1756 | return NULL; |
| 1757 | _rv = WELongPointInLongRect(&lp, |
| 1758 | &lr); |
| 1759 | _res = Py_BuildValue("b", |
| 1760 | _rv); |
| 1761 | return _res; |
| 1762 | } |
| 1763 | |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 1764 | static PyObject *waste_STDObjectHandlers(_self, _args) |
| 1765 | PyObject *_self; |
| 1766 | PyObject *_args; |
| 1767 | { |
| 1768 | PyObject *_res = NULL; |
| 1769 | |
| 1770 | OSErr err; |
| 1771 | // install the sample object handlers for pictures and sounds |
| 1772 | #define kTypePicture 'PICT' |
| 1773 | #define kTypeSound 'snd ' |
| 1774 | |
| 1775 | if ( !PyArg_ParseTuple(_args, "") ) return NULL; |
| 1776 | |
| 1777 | if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler, |
| 1778 | (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr) |
| 1779 | goto cleanup; |
| 1780 | |
| 1781 | if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler, |
| 1782 | (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr) |
| 1783 | goto cleanup; |
| 1784 | |
| 1785 | if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler, |
| 1786 | (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr) |
| 1787 | goto cleanup; |
| 1788 | |
| 1789 | if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler, |
| 1790 | (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr) |
| 1791 | goto cleanup; |
| 1792 | |
| 1793 | if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler, |
| 1794 | (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr) |
| 1795 | goto cleanup; |
| 1796 | |
| 1797 | if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler, |
| 1798 | (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr) |
| 1799 | goto cleanup; |
| 1800 | Py_INCREF(Py_None); |
| 1801 | return Py_None; |
| 1802 | |
| 1803 | cleanup: |
| 1804 | return PyMac_Error(err); |
| 1805 | |
| 1806 | } |
| 1807 | |
| 1808 | static PyObject *waste_WEInstallObjectHandler(_self, _args) |
| 1809 | PyObject *_self; |
| 1810 | PyObject *_args; |
| 1811 | { |
| 1812 | PyObject *_res = NULL; |
| 1813 | |
| 1814 | OSErr err; |
| 1815 | FlavorType objectType; |
| 1816 | WESelector selector; |
| 1817 | PyObject *py_handler; |
| 1818 | UniversalProcPtr handler; |
| 1819 | WEReference we = NULL; |
| 1820 | PyObject *key; |
| 1821 | |
| 1822 | |
| 1823 | if ( !PyArg_ParseTuple(_args, "O&O&O|O&", |
| 1824 | PyMac_GetOSType, &objectType, |
| 1825 | PyMac_GetOSType, &selector, |
| 1826 | &py_handler, |
| 1827 | ExistingwasteObj_New, &we) ) return NULL; |
| 1828 | |
| 1829 | if ( selector == weNewHandler ) handler = upp_new_handler; |
| 1830 | else if ( selector == weDisposeHandler ) handler = upp_dispose_handler; |
| 1831 | else if ( selector == weDrawHandler ) handler = upp_draw_handler; |
| 1832 | else if ( selector == weClickHandler ) handler = upp_click_handler; |
| 1833 | else return PyMac_Error(weUndefinedSelectorErr); |
| 1834 | |
| 1835 | if ((key = Py_BuildValue("O&O&", |
| 1836 | PyMac_BuildOSType, objectType, |
| 1837 | PyMac_BuildOSType, selector)) == NULL ) |
| 1838 | return NULL; |
| 1839 | |
| 1840 | PyDict_SetItem(callbackdict, key, py_handler); |
| 1841 | |
| 1842 | err = WEInstallObjectHandler(objectType, selector, handler, we); |
| 1843 | if ( err ) return PyMac_Error(err); |
| 1844 | Py_INCREF(Py_None); |
| 1845 | return Py_None; |
| 1846 | |
| 1847 | } |
| 1848 | |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1849 | static PyMethodDef waste_methods[] = { |
| 1850 | {"WENew", (PyCFunction)waste_WENew, 1, |
| 1851 | "(LongRect destRect, LongRect viewRect, unsigned long flags) -> (WEReference we)"}, |
| 1852 | {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1, |
| 1853 | "() -> None"}, |
| 1854 | {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1, |
| 1855 | "() -> None"}, |
| 1856 | {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1, |
| 1857 | "(LongPt lp) -> (Point p)"}, |
| 1858 | {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1, |
| 1859 | "(Point p) -> (LongPt lp)"}, |
| 1860 | {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1, |
| 1861 | "(long left, long top, long right, long bottom) -> (LongRect lr)"}, |
| 1862 | {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1, |
| 1863 | "(LongRect lr) -> (Rect r)"}, |
| 1864 | {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1, |
| 1865 | "(Rect r) -> (LongRect lr)"}, |
| 1866 | {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1, |
| 1867 | "(long hOffset, long vOffset) -> (LongRect lr)"}, |
| 1868 | {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1, |
| 1869 | "(LongPt lp, LongRect lr) -> (Boolean _rv)"}, |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 1870 | {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1, |
| 1871 | NULL}, |
| 1872 | {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1, |
| 1873 | NULL}, |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1874 | {NULL, NULL, 0} |
| 1875 | }; |
| 1876 | |
| 1877 | |
| 1878 | |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 1879 | /* Return the object corresponding to the window, or NULL */ |
| 1880 | |
| 1881 | PyObject * |
| 1882 | ExistingwasteObj_New(w) |
| 1883 | WEReference w; |
| 1884 | { |
| 1885 | PyObject *it = NULL; |
| 1886 | |
| 1887 | if (w == NULL) |
| 1888 | it = NULL; |
| 1889 | else |
| 1890 | WEGetInfo(weRefCon, (void *)&it, w); |
| 1891 | if (it == NULL || ((wasteObject *)it)->ob_itself != w) |
| 1892 | it = Py_None; |
| 1893 | Py_INCREF(it); |
| 1894 | return it; |
| 1895 | } |
| 1896 | |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1897 | |
| 1898 | void initwaste() |
| 1899 | { |
| 1900 | PyObject *m; |
| 1901 | PyObject *d; |
| 1902 | |
| 1903 | |
| 1904 | |
| 1905 | |
| 1906 | m = Py_InitModule("waste", waste_methods); |
| 1907 | d = PyModule_GetDict(m); |
| 1908 | waste_Error = PyMac_GetOSErrException(); |
| 1909 | if (waste_Error == NULL || |
| 1910 | PyDict_SetItemString(d, "Error", waste_Error) != 0) |
| 1911 | Py_FatalError("can't initialize waste.Error"); |
Jack Jansen | 756522f | 1996-05-07 15:24:01 +0000 | [diff] [blame^] | 1912 | |
| 1913 | callbackdict = PyDict_New(); |
| 1914 | if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0) |
| 1915 | Py_FatalError("can't initialize Waste.callbackdict"); |
| 1916 | upp_new_handler = NewWENewObjectProc(my_new_handler); |
| 1917 | upp_dispose_handler = NewWENewObjectProc(my_dispose_handler); |
| 1918 | upp_draw_handler = NewWENewObjectProc(my_draw_handler); |
| 1919 | upp_click_handler = NewWENewObjectProc(my_click_handler); |
| 1920 | |
| 1921 | |
Jack Jansen | 90ecdf4 | 1996-04-16 14:29:15 +0000 | [diff] [blame] | 1922 | } |
| 1923 | |
| 1924 | /* ======================== End module waste ======================== */ |
| 1925 | |