blob: 734a2e7f32988ba30d56e7204671f2544d1941d4 [file] [log] [blame]
Jack Jansen90ecdf41996-04-16 14:29:15 +00001
2/* ========================== Module waste ========================== */
3
4#include "Python.h"
5
6
7
Jack Jansen90ecdf41996-04-16 14:29:15 +00008#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +00009#include "pymactoolbox.h"
Jack Jansen044d95e2001-09-05 15:44:37 +000010
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 Jansen90ecdf41996-04-16 14:29:15 +000018
19#include <WASTE.h>
Jack Jansen8505ef81997-08-27 14:09:25 +000020#include <WEObjectHandlers.h>
Jack Jansena755e681997-09-20 17:40:22 +000021#include <WETabs.h>
Jack Jansen90ecdf41996-04-16 14:29:15 +000022
23/* Exported by Qdmodule.c: */
24extern PyObject *QdRGB_New(RGBColor *);
25extern int QdRGB_Convert(PyObject *, RGBColor *);
26
Jack Jansen8505ef81997-08-27 14:09:25 +000027/* Exported by AEModule.c: */
28extern PyObject *AEDesc_New(AppleEvent *);
29extern int AEDesc_Convert(PyObject *, AppleEvent *);
30
Jack Jansen90ecdf41996-04-16 14:29:15 +000031/* Forward declaration */
32staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000033staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000034
35/*
36** Parse/generate TextStyle records
37*/
38static
39PyObject *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
47static
48TextStyle_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*/
65static
66PyObject *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 */
75int
76LongRect_Convert(PyObject *v, LongRect *r)
77{
78 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
79}
80
81PyObject *
82LongRect_New(LongRect *r)
83{
84 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
85}
86
87
88LongPt_Convert(PyObject *v, LongPt *p)
89{
90 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
91}
92
93PyObject *
94LongPt_New(LongPt *p)
95{
96 return Py_BuildValue("(ll)", p->h, p->v);
97}
98
Jack Jansen756522f1996-05-07 15:24:01 +000099/* Stuff for the callbacks: */
100static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +0000101WENewObjectUPP upp_new_handler;
102WEDisposeObjectUPP upp_dispose_handler;
103WEDrawObjectUPP upp_draw_handler;
104WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +0000105
106static OSErr
107any_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 Jansendeff89c1998-10-12 20:53:15 +0000127 PySys_WriteStderr("--Exception in callback: ");
Jack Jansen756522f1996-05-07 15:24:01 +0000128 PyErr_Print();
129 return errAEReplyNotArrived;
130 }
131 return 0;
132}
133
134static pascal OSErr
135my_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
151static pascal OSErr
152my_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
164static pascal OSErr
Jack Jansen6b9289f2001-06-20 21:21:07 +0000165my_draw_handler(const Rect *destRect, WEObjectReference objref)
Jack Jansen756522f1996-05-07 15:24:01 +0000166{
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
177static pascal Boolean
178my_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 Jansen90ecdf41996-04-16 14:29:15 +0000199static PyObject *waste_Error;
200
201/* ------------------------ Object type WEO ------------------------- */
202
203PyTypeObject WEO_Type;
204
205#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
206
207typedef struct WEOObject {
208 PyObject_HEAD
209 WEObjectReference ob_itself;
210} WEOObject;
211
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000212PyObject *WEOObj_New(WEObjectReference itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000213{
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 Jansen044d95e2001-09-05 15:44:37 +0000224int WEOObj_Convert(PyObject *v, WEObjectReference *p_itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000225{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000235static void WEOObj_dealloc(WEOObject *self)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000236{
237 /* Cleanup of self->ob_itself goes here */
238 PyMem_DEL(self);
239}
240
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000241static PyObject *WEOObj_WEGetObjectType(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000242{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000253static PyObject *WEOObj_WEGetObjectDataHandle(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000254{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000265static PyObject *WEOObj_WEGetObjectSize(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000266{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000277static PyObject *WEOObj_WEGetObjectOwner(WEOObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +0000278{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000289static PyObject *WEOObj_WEGetObjectRefCon(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000290{
291 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000292 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000293 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 Jansenfa77e1a2001-05-22 21:56:42 +0000301static PyObject *WEOObj_WESetObjectRefCon(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000302{
303 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000304 SInt32 refCon;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000305 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
315static 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 Jansen756522f1996-05-07 15:24:01 +0000322 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
323 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000324 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000325 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000326 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000327 "(SInt32 refCon) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000328 {NULL, NULL, 0}
329};
330
331PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
332
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000333static PyObject *WEOObj_getattr(WEOObject *self, char *name)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000334{
335 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
336}
337
338#define WEOObj_setattr NULL
339
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000340#define WEOObj_compare NULL
341
342#define WEOObj_repr NULL
343
344#define WEOObj_hash NULL
345
Jack Jansen90ecdf41996-04-16 14:29:15 +0000346PyTypeObject WEO_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000347 PyObject_HEAD_INIT(NULL)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000348 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000349 "waste.WEO", /*tp_name*/
Jack Jansen90ecdf41996-04-16 14:29:15 +0000350 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 Jansen9d8b96c2000-07-14 22:16:45 +0000357 (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 Jansen90ecdf41996-04-16 14:29:15 +0000363};
364
365/* ---------------------- End object type WEO ----------------------- */
366
367
368/* ----------------------- Object type waste ------------------------ */
369
370PyTypeObject waste_Type;
371
372#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
373
374typedef struct wasteObject {
375 PyObject_HEAD
376 WEReference ob_itself;
377} wasteObject;
378
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000379PyObject *wasteObj_New(WEReference itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000380{
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 Jansen756522f1996-05-07 15:24:01 +0000389 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000390 return (PyObject *)it;
391}
Jack Jansen044d95e2001-09-05 15:44:37 +0000392int wasteObj_Convert(PyObject *v, WEReference *p_itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000393{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000403static void wasteObj_dealloc(wasteObject *self)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000404{
405 WEDispose(self->ob_itself);
406 PyMem_DEL(self);
407}
408
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000409static PyObject *wasteObj_WEGetText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000410{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000421static PyObject *wasteObj_WEGetChar(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000422{
423 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000424 SInt16 _rv;
425 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000426 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 Jansenfa77e1a2001-05-22 21:56:42 +0000436static PyObject *wasteObj_WEGetTextLength(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000437{
438 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000439 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000440 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 Jansenfa77e1a2001-05-22 21:56:42 +0000448static PyObject *wasteObj_WEGetHeight(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000449{
450 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000451 SInt32 _rv;
452 SInt32 startLine;
453 SInt32 endLine;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000454 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 Jansenfa77e1a2001-05-22 21:56:42 +0000466static PyObject *wasteObj_WEGetSelection(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000467{
468 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000469 SInt32 selStart;
470 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000471 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 Jansenfa77e1a2001-05-22 21:56:42 +0000482static PyObject *wasteObj_WEGetDestRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000483{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000495static PyObject *wasteObj_WEGetViewRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000496{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000508static PyObject *wasteObj_WEIsActive(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000509{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000520static PyObject *wasteObj_WEOffsetToLine(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000521{
522 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000523 SInt32 _rv;
524 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000525 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 Jansenfa77e1a2001-05-22 21:56:42 +0000535static PyObject *wasteObj_WEGetLineRange(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000536{
537 PyObject *_res = NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000538 SInt32 lineIndex;
Jack Jansen2268af51996-08-06 16:04:22 +0000539 SInt32 lineStart;
540 SInt32 lineEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000541 if (!PyArg_ParseTuple(_args, "l",
Jack Jansen2369a981998-02-20 15:57:30 +0000542 &lineIndex))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000543 return NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000544 WEGetLineRange(lineIndex,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000545 &lineStart,
546 &lineEnd,
547 _self->ob_itself);
548 _res = Py_BuildValue("ll",
549 lineStart,
550 lineEnd);
551 return _res;
552}
553
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000554static PyObject *wasteObj_WECountLines(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000555{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000566static PyObject *wasteObj_WEOffsetToRun(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000567{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000581static PyObject *wasteObj_WEGetRunRange(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000582{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000600static PyObject *wasteObj_WECountRuns(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000601{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000612static PyObject *wasteObj_WEGetClickCount(wasteObject *_self, PyObject *_args)
Jack Jansen2268af51996-08-06 16:04:22 +0000613{
614 PyObject *_res = NULL;
615 UInt16 _rv;
616 if (!PyArg_ParseTuple(_args, ""))
617 return NULL;
618 _rv = WEGetClickCount(_self->ob_itself);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000619 _res = Py_BuildValue("H",
Jack Jansen2268af51996-08-06 16:04:22 +0000620 _rv);
621 return _res;
622}
623
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000624static PyObject *wasteObj_WESetSelection(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000625{
626 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000627 SInt32 selStart;
628 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000629 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 Jansenfa77e1a2001-05-22 21:56:42 +0000641static PyObject *wasteObj_WESetDestRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000642{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000655static PyObject *wasteObj_WESetViewRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000656{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000669static PyObject *wasteObj_WEContinuousStyle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000670{
671 PyObject *_res = NULL;
672 Boolean _rv;
673 WEStyleMode mode;
674 TextStyle ts;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000675 if (!PyArg_ParseTuple(_args, "H",
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000676 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000677 return NULL;
678 _rv = WEContinuousStyle(&mode,
679 &ts,
680 _self->ob_itself);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000681 _res = Py_BuildValue("bHO&",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000682 _rv,
683 mode,
684 TextStyle_New, &ts);
685 return _res;
686}
687
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000688static PyObject *wasteObj_WEGetRunInfo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000689{
690 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000691 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000692 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 Jansenfa77e1a2001-05-22 21:56:42 +0000704static PyObject *wasteObj_WEGetRunDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000705{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000719static PyObject *wasteObj_WEGetOffset(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000720{
721 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000722 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000723 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000724 WEEdge edge;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000725 if (!PyArg_ParseTuple(_args, "O&",
726 LongPt_Convert, &thePoint))
727 return NULL;
728 _rv = WEGetOffset(&thePoint,
729 &edge,
730 _self->ob_itself);
Jack Jansen97ed9072000-09-08 22:06:16 +0000731 _res = Py_BuildValue("lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000732 _rv,
733 edge);
734 return _res;
735}
736
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000737static PyObject *wasteObj_WEGetPoint(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000738{
739 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000740 SInt32 offset;
741 SInt16 direction;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000742 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000743 SInt16 lineHeight;
744 if (!PyArg_ParseTuple(_args, "lh",
745 &offset,
746 &direction))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000747 return NULL;
748 WEGetPoint(offset,
Jack Jansen2268af51996-08-06 16:04:22 +0000749 direction,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000750 &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 Jansenfa77e1a2001-05-22 21:56:42 +0000759static PyObject *wasteObj_WEFindWord(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000760{
761 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000762 SInt32 offset;
763 WEEdge edge;
764 SInt32 wordStart;
765 SInt32 wordEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000766 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000767 &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 Jansenfa77e1a2001-05-22 21:56:42 +0000781static PyObject *wasteObj_WEFindLine(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000782{
783 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000784 SInt32 offset;
785 WEEdge edge;
786 SInt32 lineStart;
787 SInt32 lineEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000788 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000789 &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 Jansenfa77e1a2001-05-22 21:56:42 +0000803static PyObject *wasteObj_WEFindParagraph(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000804{
805 PyObject *_res = NULL;
806 SInt32 offset;
807 WEEdge edge;
808 SInt32 paragraphStart;
809 SInt32 paragraphEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000810 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen2369a981998-02-20 15:57:30 +0000811 &offset,
812 &edge))
813 return NULL;
814 WEFindParagraph(offset,
815 edge,
816 &paragraphStart,
817 &paragraphEnd,
818 _self->ob_itself);
819 _res = Py_BuildValue("ll",
820 paragraphStart,
821 paragraphEnd);
822 return _res;
823}
824
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000825static PyObject *wasteObj_WECopyRange(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000826{
827 PyObject *_res = NULL;
828 OSErr _err;
Jack Jansen2268af51996-08-06 16:04:22 +0000829 SInt32 rangeStart;
830 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000831 Handle hText;
832 StScrpHandle hStyles;
833 WESoupHandle hSoup;
834 if (!PyArg_ParseTuple(_args, "llO&O&O&",
835 &rangeStart,
836 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000837 OptResObj_Convert, &hText,
838 OptResObj_Convert, &hStyles,
839 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000840 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 Jansenfa77e1a2001-05-22 21:56:42 +0000853static PyObject *wasteObj_WEGetAlignment(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000854{
855 PyObject *_res = NULL;
856 WEAlignment _rv;
857 if (!PyArg_ParseTuple(_args, ""))
858 return NULL;
859 _rv = WEGetAlignment(_self->ob_itself);
Jack Jansen97ed9072000-09-08 22:06:16 +0000860 _res = Py_BuildValue("B",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000861 _rv);
862 return _res;
863}
864
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000865static PyObject *wasteObj_WESetAlignment(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000866{
867 PyObject *_res = NULL;
868 WEAlignment alignment;
Jack Jansen97ed9072000-09-08 22:06:16 +0000869 if (!PyArg_ParseTuple(_args, "B",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000870 &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 Jansenfa77e1a2001-05-22 21:56:42 +0000879static PyObject *wasteObj_WEGetDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000880{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000891static PyObject *wasteObj_WESetDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000892{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000905static PyObject *wasteObj_WECalText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000906{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000918static PyObject *wasteObj_WEUpdate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000919{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000932static PyObject *wasteObj_WEScroll(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000933{
934 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000935 SInt32 hOffset;
936 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000937 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 Jansenfa77e1a2001-05-22 21:56:42 +0000949static PyObject *wasteObj_WESelView(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000950{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000960static PyObject *wasteObj_WEActivate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000961{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000971static PyObject *wasteObj_WEDeactivate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000972{
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 Jansenfa77e1a2001-05-22 21:56:42 +0000982static PyObject *wasteObj_WEKey(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000983{
984 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000985 SInt16 key;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000986 EventModifiers modifiers;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000987 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000988 &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 Jansenfa77e1a2001-05-22 21:56:42 +0000999static PyObject *wasteObj_WEClick(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001000{
1001 PyObject *_res = NULL;
1002 Point hitPt;
1003 EventModifiers modifiers;
Jack Jansen2268af51996-08-06 16:04:22 +00001004 UInt32 clickTime;
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001005 if (!PyArg_ParseTuple(_args, "O&Hl",
Jack Jansen90ecdf41996-04-16 14:29:15 +00001006 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 Jansenfa77e1a2001-05-22 21:56:42 +00001019static PyObject *wasteObj_WEAdjustCursor(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001020{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001037static PyObject *wasteObj_WEIdle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001038{
1039 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001040 UInt32 maxSleep;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001041 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 Jansenfa77e1a2001-05-22 21:56:42 +00001050static PyObject *wasteObj_WEInsert(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001051{
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 Jansen8ae8e4f1996-04-23 16:17:08 +00001061 OptResObj_Convert, &hStyles,
1062 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001063 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 Jansen90ecdf41996-04-16 14:29:15 +00001072 return _res;
1073}
1074
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001075static PyObject *wasteObj_WEDelete(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001076{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001088static PyObject *wasteObj_WESetStyle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001089{
1090 PyObject *_res = NULL;
1091 OSErr _err;
1092 WEStyleMode mode;
1093 TextStyle ts;
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001094 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansen90ecdf41996-04-16 14:29:15 +00001095 &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 Jansenfa77e1a2001-05-22 21:56:42 +00001107static PyObject *wasteObj_WEUseStyleScrap(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001108{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001123static PyObject *wasteObj_WEUseText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001124{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001139static PyObject *wasteObj_WEUndo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001140{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001152static PyObject *wasteObj_WEClearUndo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001153{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001163static PyObject *wasteObj_WEGetUndoInfo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001164{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001178static PyObject *wasteObj_WEIsTyping(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001179{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001190static PyObject *wasteObj_WEBeginAction(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001191{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001203static PyObject *wasteObj_WEEndAction(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001204{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001219static PyObject *wasteObj_WEGetModCount(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001220{
1221 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001222 UInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001223 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 Jansenfa77e1a2001-05-22 21:56:42 +00001231static PyObject *wasteObj_WEResetModCount(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001232{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001242static PyObject *wasteObj_WEInsertObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001243{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001264static PyObject *wasteObj_WEGetSelectedObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001265{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001279static PyObject *wasteObj_WEFindNextObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001280{
1281 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001282 SInt32 _rv;
1283 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001284 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 Jansenfa77e1a2001-05-22 21:56:42 +00001297static PyObject *wasteObj_WEUseSoup(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001298{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001313static PyObject *wasteObj_WECut(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001314{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001326static PyObject *wasteObj_WECopy(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001327{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001339static PyObject *wasteObj_WEPaste(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001340{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001352static PyObject *wasteObj_WECanPaste(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001353{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001364static PyObject *wasteObj_WEGetHiliteRgn(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001365{
1366 PyObject *_res = NULL;
1367 RgnHandle _rv;
Jack Jansen2268af51996-08-06 16:04:22 +00001368 SInt32 rangeStart;
1369 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001370 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 Jansenfa77e1a2001-05-22 21:56:42 +00001382static PyObject *wasteObj_WECharByte(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001383{
1384 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001385 SInt16 _rv;
1386 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001387 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 Jansenfa77e1a2001-05-22 21:56:42 +00001397static PyObject *wasteObj_WECharType(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001398{
1399 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001400 SInt16 _rv;
1401 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001402 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 Jansenfa77e1a2001-05-22 21:56:42 +00001412static PyObject *wasteObj_WEStopInlineSession(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001413{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001423static PyObject *wasteObj_WEFeatureFlag(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001424{
1425 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001426 SInt16 _rv;
1427 SInt16 feature;
1428 SInt16 action;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001429 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 Jansenfa77e1a2001-05-22 21:56:42 +00001441static PyObject *wasteObj_WEGetUserInfo(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001442{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001459static PyObject *wasteObj_WESetUserInfo(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001460{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001478static PyObject *wasteObj_WEInstallTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001479{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001491static PyObject *wasteObj_WERemoveTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001492{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001504static PyObject *wasteObj_WEIsTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001505{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001516static PyObject *wasteObj_WEGetTabSize(wasteObject *_self, PyObject *_args)
Jack Jansena4f03091998-03-02 16:56:18 +00001517{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001528static PyObject *wasteObj_WESetTabSize(wasteObject *_self, PyObject *_args)
Jack Jansena4f03091998-03-02 16:56:18 +00001529{
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 Jansen90ecdf41996-04-16 14:29:15 +00001544static PyMethodDef wasteObj_methods[] = {
1545 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1546 "() -> (Handle _rv)"},
1547 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001548 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001549 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001550 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001551 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001552 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001553 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001554 "() -> (SInt32 selStart, SInt32 selEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001555 {"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 Jansen2268af51996-08-06 16:04:22 +00001562 "(SInt32 offset) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001563 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
Jack Jansen2369a981998-02-20 15:57:30 +00001564 "(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 Jansen2268af51996-08-06 16:04:22 +00001573 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1574 "() -> (UInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001575 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001576 "(SInt32 selStart, SInt32 selEnd) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001577 {"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 Jansen8ae8e4f1996-04-23 16:17:08 +00001582 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001583 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001584 "(SInt32 offset) -> (WERunInfo runInfo)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001585 {"WEGetRunDirection", (PyCFunction)wasteObj_WEGetRunDirection, 1,
1586 "(SInt32 offset) -> (Boolean _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001587 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001588 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001589 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001590 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001591 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001592 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001593 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001594 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001595 {"WEFindParagraph", (PyCFunction)wasteObj_WEFindParagraph, 1,
1596 "(SInt32 offset, WEEdge edge) -> (SInt32 paragraphStart, SInt32 paragraphEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001597 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001598 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001599 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1600 "() -> (WEAlignment _rv)"},
1601 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1602 "(WEAlignment alignment) -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00001603 {"WEGetDirection", (PyCFunction)wasteObj_WEGetDirection, 1,
1604 "() -> (WEDirection _rv)"},
1605 {"WESetDirection", (PyCFunction)wasteObj_WESetDirection, 1,
1606 "(WEDirection direction) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001607 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1608 "() -> None"},
1609 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1610 "(RgnHandle updateRgn) -> None"},
1611 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001612 "(SInt32 hOffset, SInt32 vOffset) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001613 {"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 Jansen2268af51996-08-06 16:04:22 +00001620 "(SInt16 key, EventModifiers modifiers) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001621 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001622 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001623 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1624 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1625 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001626 "() -> (UInt32 maxSleep)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001627 {"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 Jansen2369a981998-02-20 15:57:30 +00001645 {"WEBeginAction", (PyCFunction)wasteObj_WEBeginAction, 1,
1646 "() -> None"},
1647 {"WEEndAction", (PyCFunction)wasteObj_WEEndAction, 1,
1648 "(WEActionKind actionKind) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001649 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001650 "() -> (UInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001651 {"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 Jansen2268af51996-08-06 16:04:22 +00001658 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001659 {"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 Jansen2268af51996-08-06 16:04:22 +00001670 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001671 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001672 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001673 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001674 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001675 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1676 "() -> None"},
1677 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001678 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001679 {"WEGetUserInfo", (PyCFunction)wasteObj_WEGetUserInfo, 1,
1680 "(WESelector tag) -> (SInt32 userInfo)"},
1681 {"WESetUserInfo", (PyCFunction)wasteObj_WESetUserInfo, 1,
1682 "(WESelector tag, SInt32 userInfo) -> None"},
Jack Jansen176f3a91996-10-23 15:43:46 +00001683 {"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 Jansena4f03091998-03-02 16:56:18 +00001689 {"WEGetTabSize", (PyCFunction)wasteObj_WEGetTabSize, 1,
1690 "() -> (SInt16 _rv)"},
1691 {"WESetTabSize", (PyCFunction)wasteObj_WESetTabSize, 1,
1692 "(SInt16 tabWidth) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001693 {NULL, NULL, 0}
1694};
1695
1696PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1697
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001698static PyObject *wasteObj_getattr(wasteObject *self, char *name)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001699{
1700 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1701}
1702
1703#define wasteObj_setattr NULL
1704
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001705#define wasteObj_compare NULL
1706
1707#define wasteObj_repr NULL
1708
1709#define wasteObj_hash NULL
1710
Jack Jansen90ecdf41996-04-16 14:29:15 +00001711PyTypeObject waste_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00001712 PyObject_HEAD_INIT(NULL)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001713 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00001714 "waste.waste", /*tp_name*/
Jack Jansen90ecdf41996-04-16 14:29:15 +00001715 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 Jansen9d8b96c2000-07-14 22:16:45 +00001722 (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 Jansen90ecdf41996-04-16 14:29:15 +00001728};
1729
1730/* --------------------- End object type waste ---------------------- */
1731
1732
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001733static PyObject *waste_WENew(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001734{
1735 PyObject *_res = NULL;
1736 OSErr _err;
1737 LongRect destRect;
1738 LongRect viewRect;
Jack Jansen2268af51996-08-06 16:04:22 +00001739 UInt32 flags;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001740 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 Jansenfa77e1a2001-05-22 21:56:42 +00001756static PyObject *waste_WEUpdateStyleScrap(PyObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001757{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001774static PyObject *waste_WEInstallTSMHandlers(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001775{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001787static PyObject *waste_WERemoveTSMHandlers(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001788{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001800static PyObject *waste_WEHandleTSMEvent(PyObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001801{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001817static PyObject *waste_WELongPointToPoint(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001818{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001832static PyObject *waste_WEPointToLongPoint(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001833{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001847static PyObject *waste_WESetLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001848{
1849 PyObject *_res = NULL;
1850 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001851 SInt32 left;
1852 SInt32 top;
1853 SInt32 right;
1854 SInt32 bottom;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001855 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 Jansenfa77e1a2001-05-22 21:56:42 +00001871static PyObject *waste_WELongRectToRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001872{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001886static PyObject *waste_WERectToLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001887{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001901static PyObject *waste_WEOffsetLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001902{
1903 PyObject *_res = NULL;
1904 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001905 SInt32 hOffset;
1906 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001907 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 Jansenfa77e1a2001-05-22 21:56:42 +00001919static PyObject *waste_WELongPointInLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001920{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001936static PyObject *waste_STDObjectHandlers(PyObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +00001937{
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 Jansenfa77e1a2001-05-22 21:56:42 +00001978static PyObject *waste_WEInstallObjectHandler(PyObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +00001979{
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 Jansen7df36061996-10-01 11:41:14 +00001995 WEOObj_Convert, &we) ) return NULL;
Jack Jansen756522f1996-05-07 15:24:01 +00001996
Jack Jansen25241d91996-05-20 11:30:45 +00001997 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 Jansen756522f1996-05-07 15:24:01 +00002001 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 Jansen90ecdf41996-04-16 14:29:15 +00002017static PyMethodDef waste_methods[] = {
2018 {"WENew", (PyCFunction)waste_WENew, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002019 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
Jack Jansen2369a981998-02-20 15:57:30 +00002020 {"WEUpdateStyleScrap", (PyCFunction)waste_WEUpdateStyleScrap, 1,
2021 "(StScrpHandle hStyles, WEFontTableHandle hFontTable) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002022 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
2023 "() -> None"},
2024 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
2025 "() -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00002026 {"WEHandleTSMEvent", (PyCFunction)waste_WEHandleTSMEvent, 1,
2027 "(AppleEvent ae) -> (AppleEvent reply)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002028 {"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 Jansen2268af51996-08-06 16:04:22 +00002033 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002034 {"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 Jansen2268af51996-08-06 16:04:22 +00002039 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002040 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
2041 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00002042 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
2043 NULL},
2044 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
2045 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002046 {NULL, NULL, 0}
2047};
2048
2049
2050
Jack Jansen756522f1996-05-07 15:24:01 +00002051/* Return the object corresponding to the window, or NULL */
2052
2053PyObject *
2054ExistingwasteObj_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 Jansen90ecdf41996-04-16 14:29:15 +00002069
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002070void initwaste(void)
Jack Jansen90ecdf41996-04-16 14:29:15 +00002071{
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 Jansen97ed9072000-09-08 22:06:16 +00002083 return;
Jack Jansena755e681997-09-20 17:40:22 +00002084 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 Jansen756522f1996-05-07 15:24:01 +00002092
2093 callbackdict = PyDict_New();
2094 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
Jack Jansen97ed9072000-09-08 22:06:16 +00002095 return;
Jack Jansen756522f1996-05-07 15:24:01 +00002096 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00002097 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
2098 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
2099 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00002100
2101
Jack Jansen90ecdf41996-04-16 14:29:15 +00002102}
2103
2104/* ======================== End module waste ======================== */
2105