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