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