blob: d09641f51441c2e4fc46f8ba2fe191a181e2c2f5 [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 Jansen90ecdf41996-04-16 14:29:15 +000010
11#include <WASTE.h>
Jack Jansen8505ef81997-08-27 14:09:25 +000012#include <WEObjectHandlers.h>
Jack Jansena755e681997-09-20 17:40:22 +000013#include <WETabs.h>
Jack Jansen90ecdf41996-04-16 14:29:15 +000014
15/* Exported by Qdmodule.c: */
16extern PyObject *QdRGB_New(RGBColor *);
17extern int QdRGB_Convert(PyObject *, RGBColor *);
18
Jack Jansen8505ef81997-08-27 14:09:25 +000019/* Exported by AEModule.c: */
20extern PyObject *AEDesc_New(AppleEvent *);
21extern int AEDesc_Convert(PyObject *, AppleEvent *);
22
Jack Jansen90ecdf41996-04-16 14:29:15 +000023/* Forward declaration */
24staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000025staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000026
27/*
28** Parse/generate TextStyle records
29*/
30static
31PyObject *TextStyle_New(itself)
32 TextStylePtr itself;
33{
34
35 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
36 &itself->tsColor);
37}
38
39static
40TextStyle_Convert(v, p_itself)
41 PyObject *v;
42 TextStylePtr p_itself;
43{
44 long font, face, size;
45
46 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
47 return 0;
48 p_itself->tsFont = (short)font;
49 p_itself->tsFace = (Style)face;
50 p_itself->tsSize = (short)size;
51 return 1;
52}
53
54/*
55** Parse/generate RunInfo records
56*/
57static
58PyObject *RunInfo_New(itself)
59 WERunInfo *itself;
60{
61
62 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
63 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
64}
65
66/* Conversion of long points and rects */
67int
68LongRect_Convert(PyObject *v, LongRect *r)
69{
70 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
71}
72
73PyObject *
74LongRect_New(LongRect *r)
75{
76 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
77}
78
79
80LongPt_Convert(PyObject *v, LongPt *p)
81{
82 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
83}
84
85PyObject *
86LongPt_New(LongPt *p)
87{
88 return Py_BuildValue("(ll)", p->h, p->v);
89}
90
Jack Jansen756522f1996-05-07 15:24:01 +000091/* Stuff for the callbacks: */
92static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +000093WENewObjectUPP upp_new_handler;
94WEDisposeObjectUPP upp_dispose_handler;
95WEDrawObjectUPP upp_draw_handler;
96WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +000097
98static OSErr
99any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
100{
101 FlavorType tp;
102 PyObject *key, *func;
103
104 if ( args == NULL ) return errAECorruptData;
105
106 tp = WEGetObjectType(who);
107
108 if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
109 return errAECorruptData;
110 if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
111 Py_DECREF(key);
112 return errAEHandlerNotFound;
113 }
114 Py_INCREF(func);
115 *rv = PyEval_CallObject(func, args);
116 Py_DECREF(func);
117 Py_DECREF(key);
118 if ( *rv == NULL ) {
Jack Jansendeff89c1998-10-12 20:53:15 +0000119 PySys_WriteStderr("--Exception in callback: ");
Jack Jansen756522f1996-05-07 15:24:01 +0000120 PyErr_Print();
121 return errAEReplyNotArrived;
122 }
123 return 0;
124}
125
126static pascal OSErr
127my_new_handler(Point *objectSize, WEObjectReference objref)
128{
129 PyObject *args=NULL, *rv=NULL;
130 OSErr err;
131
132 args=Py_BuildValue("(O&)", WEOObj_New, objref);
133 err = any_handler(weNewHandler, objref, args, &rv);
134 if (!err) {
135 if (!PyMac_GetPoint(rv, objectSize) )
136 err = errAECoercionFail;
137 }
138 if ( args ) Py_DECREF(args);
139 if ( rv ) Py_DECREF(rv);
140 return err;
141}
142
143static pascal OSErr
144my_dispose_handler(WEObjectReference objref)
145{
146 PyObject *args=NULL, *rv=NULL;
147 OSErr err;
148
149 args=Py_BuildValue("(O&)", WEOObj_New, objref);
150 err = any_handler(weDisposeHandler, objref, args, &rv);
151 if ( args ) Py_DECREF(args);
152 if ( rv ) Py_DECREF(rv);
153 return err;
154}
155
156static pascal OSErr
Jack Jansen6b9289f2001-06-20 21:21:07 +0000157my_draw_handler(const Rect *destRect, WEObjectReference objref)
Jack Jansen756522f1996-05-07 15:24:01 +0000158{
159 PyObject *args=NULL, *rv=NULL;
160 OSErr err;
161
162 args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
163 err = any_handler(weDrawHandler, objref, args, &rv);
164 if ( args ) Py_DECREF(args);
165 if ( rv ) Py_DECREF(rv);
166 return err;
167}
168
169static pascal Boolean
170my_click_handler(Point hitPt, EventModifiers modifiers,
171 unsigned long clickTime, WEObjectReference objref)
172{
173 PyObject *args=NULL, *rv=NULL;
174 int retvalue;
175 OSErr err;
176
177 args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
178 (long)modifiers, (long)clickTime, WEOObj_New, objref);
179 err = any_handler(weClickHandler, objref, args, &rv);
180 if (!err)
181 retvalue = PyInt_AsLong(rv);
182 else
183 retvalue = 0;
184 if ( args ) Py_DECREF(args);
185 if ( rv ) Py_DECREF(rv);
186 return retvalue;
187}
188
189
190
Jack Jansen90ecdf41996-04-16 14:29:15 +0000191static PyObject *waste_Error;
192
193/* ------------------------ Object type WEO ------------------------- */
194
195PyTypeObject WEO_Type;
196
197#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
198
199typedef struct WEOObject {
200 PyObject_HEAD
201 WEObjectReference ob_itself;
202} WEOObject;
203
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000204PyObject *WEOObj_New(WEObjectReference itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000205{
206 WEOObject *it;
207 if (itself == NULL) {
208 Py_INCREF(Py_None);
209 return Py_None;
210 }
211 it = PyObject_NEW(WEOObject, &WEO_Type);
212 if (it == NULL) return NULL;
213 it->ob_itself = itself;
214 return (PyObject *)it;
215}
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000216WEOObj_Convert(PyObject *v, WEObjectReference *p_itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000217{
218 if (!WEOObj_Check(v))
219 {
220 PyErr_SetString(PyExc_TypeError, "WEO required");
221 return 0;
222 }
223 *p_itself = ((WEOObject *)v)->ob_itself;
224 return 1;
225}
226
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000227static void WEOObj_dealloc(WEOObject *self)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000228{
229 /* Cleanup of self->ob_itself goes here */
230 PyMem_DEL(self);
231}
232
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000233static PyObject *WEOObj_WEGetObjectType(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000234{
235 PyObject *_res = NULL;
236 FlavorType _rv;
237 if (!PyArg_ParseTuple(_args, ""))
238 return NULL;
239 _rv = WEGetObjectType(_self->ob_itself);
240 _res = Py_BuildValue("O&",
241 PyMac_BuildOSType, _rv);
242 return _res;
243}
244
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000245static PyObject *WEOObj_WEGetObjectDataHandle(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000246{
247 PyObject *_res = NULL;
248 Handle _rv;
249 if (!PyArg_ParseTuple(_args, ""))
250 return NULL;
251 _rv = WEGetObjectDataHandle(_self->ob_itself);
252 _res = Py_BuildValue("O&",
253 ResObj_New, _rv);
254 return _res;
255}
256
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000257static PyObject *WEOObj_WEGetObjectSize(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000258{
259 PyObject *_res = NULL;
260 Point _rv;
261 if (!PyArg_ParseTuple(_args, ""))
262 return NULL;
263 _rv = WEGetObjectSize(_self->ob_itself);
264 _res = Py_BuildValue("O&",
265 PyMac_BuildPoint, _rv);
266 return _res;
267}
268
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000269static PyObject *WEOObj_WEGetObjectOwner(WEOObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +0000270{
271 PyObject *_res = NULL;
272 WEReference _rv;
273 if (!PyArg_ParseTuple(_args, ""))
274 return NULL;
275 _rv = WEGetObjectOwner(_self->ob_itself);
276 _res = Py_BuildValue("O&",
277 ExistingwasteObj_New, _rv);
278 return _res;
279}
280
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000281static PyObject *WEOObj_WEGetObjectRefCon(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000282{
283 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000284 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000285 if (!PyArg_ParseTuple(_args, ""))
286 return NULL;
287 _rv = WEGetObjectRefCon(_self->ob_itself);
288 _res = Py_BuildValue("l",
289 _rv);
290 return _res;
291}
292
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000293static PyObject *WEOObj_WESetObjectRefCon(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000294{
295 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000296 SInt32 refCon;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000297 if (!PyArg_ParseTuple(_args, "l",
298 &refCon))
299 return NULL;
300 WESetObjectRefCon(_self->ob_itself,
301 refCon);
302 Py_INCREF(Py_None);
303 _res = Py_None;
304 return _res;
305}
306
307static PyMethodDef WEOObj_methods[] = {
308 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
309 "() -> (FlavorType _rv)"},
310 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
311 "() -> (Handle _rv)"},
312 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
313 "() -> (Point _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +0000314 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
315 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000316 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000317 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000318 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000319 "(SInt32 refCon) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000320 {NULL, NULL, 0}
321};
322
323PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
324
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000325static PyObject *WEOObj_getattr(WEOObject *self, char *name)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000326{
327 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
328}
329
330#define WEOObj_setattr NULL
331
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000332#define WEOObj_compare NULL
333
334#define WEOObj_repr NULL
335
336#define WEOObj_hash NULL
337
Jack Jansen90ecdf41996-04-16 14:29:15 +0000338PyTypeObject WEO_Type = {
339 PyObject_HEAD_INIT(&PyType_Type)
340 0, /*ob_size*/
341 "WEO", /*tp_name*/
342 sizeof(WEOObject), /*tp_basicsize*/
343 0, /*tp_itemsize*/
344 /* methods */
345 (destructor) WEOObj_dealloc, /*tp_dealloc*/
346 0, /*tp_print*/
347 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
348 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000349 (cmpfunc) WEOObj_compare, /*tp_compare*/
350 (reprfunc) WEOObj_repr, /*tp_repr*/
351 (PyNumberMethods *)0, /* tp_as_number */
352 (PySequenceMethods *)0, /* tp_as_sequence */
353 (PyMappingMethods *)0, /* tp_as_mapping */
354 (hashfunc) WEOObj_hash, /*tp_hash*/
Jack Jansen90ecdf41996-04-16 14:29:15 +0000355};
356
357/* ---------------------- End object type WEO ----------------------- */
358
359
360/* ----------------------- Object type waste ------------------------ */
361
362PyTypeObject waste_Type;
363
364#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
365
366typedef struct wasteObject {
367 PyObject_HEAD
368 WEReference ob_itself;
369} wasteObject;
370
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000371PyObject *wasteObj_New(WEReference itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000372{
373 wasteObject *it;
374 if (itself == NULL) {
375 PyErr_SetString(waste_Error,"Cannot create null WE");
376 return NULL;
377 }
378 it = PyObject_NEW(wasteObject, &waste_Type);
379 if (it == NULL) return NULL;
380 it->ob_itself = itself;
Jack Jansen756522f1996-05-07 15:24:01 +0000381 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000382 return (PyObject *)it;
383}
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000384wasteObj_Convert(PyObject *v, WEReference *p_itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000385{
386 if (!wasteObj_Check(v))
387 {
388 PyErr_SetString(PyExc_TypeError, "waste required");
389 return 0;
390 }
391 *p_itself = ((wasteObject *)v)->ob_itself;
392 return 1;
393}
394
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000395static void wasteObj_dealloc(wasteObject *self)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000396{
397 WEDispose(self->ob_itself);
398 PyMem_DEL(self);
399}
400
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000401static PyObject *wasteObj_WEGetText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000402{
403 PyObject *_res = NULL;
404 Handle _rv;
405 if (!PyArg_ParseTuple(_args, ""))
406 return NULL;
407 _rv = WEGetText(_self->ob_itself);
408 _res = Py_BuildValue("O&",
409 ResObj_New, _rv);
410 return _res;
411}
412
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000413static PyObject *wasteObj_WEGetChar(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000414{
415 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000416 SInt16 _rv;
417 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000418 if (!PyArg_ParseTuple(_args, "l",
419 &offset))
420 return NULL;
421 _rv = WEGetChar(offset,
422 _self->ob_itself);
423 _res = Py_BuildValue("h",
424 _rv);
425 return _res;
426}
427
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000428static PyObject *wasteObj_WEGetTextLength(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000429{
430 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000431 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000432 if (!PyArg_ParseTuple(_args, ""))
433 return NULL;
434 _rv = WEGetTextLength(_self->ob_itself);
435 _res = Py_BuildValue("l",
436 _rv);
437 return _res;
438}
439
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000440static PyObject *wasteObj_WEGetHeight(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000441{
442 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000443 SInt32 _rv;
444 SInt32 startLine;
445 SInt32 endLine;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000446 if (!PyArg_ParseTuple(_args, "ll",
447 &startLine,
448 &endLine))
449 return NULL;
450 _rv = WEGetHeight(startLine,
451 endLine,
452 _self->ob_itself);
453 _res = Py_BuildValue("l",
454 _rv);
455 return _res;
456}
457
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000458static PyObject *wasteObj_WEGetSelection(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000459{
460 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000461 SInt32 selStart;
462 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000463 if (!PyArg_ParseTuple(_args, ""))
464 return NULL;
465 WEGetSelection(&selStart,
466 &selEnd,
467 _self->ob_itself);
468 _res = Py_BuildValue("ll",
469 selStart,
470 selEnd);
471 return _res;
472}
473
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000474static PyObject *wasteObj_WEGetDestRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000475{
476 PyObject *_res = NULL;
477 LongRect destRect;
478 if (!PyArg_ParseTuple(_args, ""))
479 return NULL;
480 WEGetDestRect(&destRect,
481 _self->ob_itself);
482 _res = Py_BuildValue("O&",
483 LongRect_New, &destRect);
484 return _res;
485}
486
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000487static PyObject *wasteObj_WEGetViewRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000488{
489 PyObject *_res = NULL;
490 LongRect viewRect;
491 if (!PyArg_ParseTuple(_args, ""))
492 return NULL;
493 WEGetViewRect(&viewRect,
494 _self->ob_itself);
495 _res = Py_BuildValue("O&",
496 LongRect_New, &viewRect);
497 return _res;
498}
499
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000500static PyObject *wasteObj_WEIsActive(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000501{
502 PyObject *_res = NULL;
503 Boolean _rv;
504 if (!PyArg_ParseTuple(_args, ""))
505 return NULL;
506 _rv = WEIsActive(_self->ob_itself);
507 _res = Py_BuildValue("b",
508 _rv);
509 return _res;
510}
511
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000512static PyObject *wasteObj_WEOffsetToLine(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000513{
514 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000515 SInt32 _rv;
516 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000517 if (!PyArg_ParseTuple(_args, "l",
518 &offset))
519 return NULL;
520 _rv = WEOffsetToLine(offset,
521 _self->ob_itself);
522 _res = Py_BuildValue("l",
523 _rv);
524 return _res;
525}
526
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000527static PyObject *wasteObj_WEGetLineRange(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000528{
529 PyObject *_res = NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000530 SInt32 lineIndex;
Jack Jansen2268af51996-08-06 16:04:22 +0000531 SInt32 lineStart;
532 SInt32 lineEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000533 if (!PyArg_ParseTuple(_args, "l",
Jack Jansen2369a981998-02-20 15:57:30 +0000534 &lineIndex))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000535 return NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000536 WEGetLineRange(lineIndex,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000537 &lineStart,
538 &lineEnd,
539 _self->ob_itself);
540 _res = Py_BuildValue("ll",
541 lineStart,
542 lineEnd);
543 return _res;
544}
545
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000546static PyObject *wasteObj_WECountLines(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000547{
548 PyObject *_res = NULL;
549 SInt32 _rv;
550 if (!PyArg_ParseTuple(_args, ""))
551 return NULL;
552 _rv = WECountLines(_self->ob_itself);
553 _res = Py_BuildValue("l",
554 _rv);
555 return _res;
556}
557
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000558static PyObject *wasteObj_WEOffsetToRun(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000559{
560 PyObject *_res = NULL;
561 SInt32 _rv;
562 SInt32 offset;
563 if (!PyArg_ParseTuple(_args, "l",
564 &offset))
565 return NULL;
566 _rv = WEOffsetToRun(offset,
567 _self->ob_itself);
568 _res = Py_BuildValue("l",
569 _rv);
570 return _res;
571}
572
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000573static PyObject *wasteObj_WEGetRunRange(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000574{
575 PyObject *_res = NULL;
576 SInt32 runIndex;
577 SInt32 runStart;
578 SInt32 runEnd;
579 if (!PyArg_ParseTuple(_args, "l",
580 &runIndex))
581 return NULL;
582 WEGetRunRange(runIndex,
583 &runStart,
584 &runEnd,
585 _self->ob_itself);
586 _res = Py_BuildValue("ll",
587 runStart,
588 runEnd);
589 return _res;
590}
591
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000592static PyObject *wasteObj_WECountRuns(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000593{
594 PyObject *_res = NULL;
595 SInt32 _rv;
596 if (!PyArg_ParseTuple(_args, ""))
597 return NULL;
598 _rv = WECountRuns(_self->ob_itself);
599 _res = Py_BuildValue("l",
600 _rv);
601 return _res;
602}
603
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000604static PyObject *wasteObj_WEGetClickCount(wasteObject *_self, PyObject *_args)
Jack Jansen2268af51996-08-06 16:04:22 +0000605{
606 PyObject *_res = NULL;
607 UInt16 _rv;
608 if (!PyArg_ParseTuple(_args, ""))
609 return NULL;
610 _rv = WEGetClickCount(_self->ob_itself);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000611 _res = Py_BuildValue("H",
Jack Jansen2268af51996-08-06 16:04:22 +0000612 _rv);
613 return _res;
614}
615
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000616static PyObject *wasteObj_WESetSelection(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000617{
618 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000619 SInt32 selStart;
620 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000621 if (!PyArg_ParseTuple(_args, "ll",
622 &selStart,
623 &selEnd))
624 return NULL;
625 WESetSelection(selStart,
626 selEnd,
627 _self->ob_itself);
628 Py_INCREF(Py_None);
629 _res = Py_None;
630 return _res;
631}
632
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000633static PyObject *wasteObj_WESetDestRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000634{
635 PyObject *_res = NULL;
636 LongRect destRect;
637 if (!PyArg_ParseTuple(_args, "O&",
638 LongRect_Convert, &destRect))
639 return NULL;
640 WESetDestRect(&destRect,
641 _self->ob_itself);
642 Py_INCREF(Py_None);
643 _res = Py_None;
644 return _res;
645}
646
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000647static PyObject *wasteObj_WESetViewRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000648{
649 PyObject *_res = NULL;
650 LongRect viewRect;
651 if (!PyArg_ParseTuple(_args, "O&",
652 LongRect_Convert, &viewRect))
653 return NULL;
654 WESetViewRect(&viewRect,
655 _self->ob_itself);
656 Py_INCREF(Py_None);
657 _res = Py_None;
658 return _res;
659}
660
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000661static PyObject *wasteObj_WEContinuousStyle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000662{
663 PyObject *_res = NULL;
664 Boolean _rv;
665 WEStyleMode mode;
666 TextStyle ts;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000667 if (!PyArg_ParseTuple(_args, "H",
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000668 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000669 return NULL;
670 _rv = WEContinuousStyle(&mode,
671 &ts,
672 _self->ob_itself);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000673 _res = Py_BuildValue("bHO&",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000674 _rv,
675 mode,
676 TextStyle_New, &ts);
677 return _res;
678}
679
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000680static PyObject *wasteObj_WEGetRunInfo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000681{
682 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000683 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000684 WERunInfo runInfo;
685 if (!PyArg_ParseTuple(_args, "l",
686 &offset))
687 return NULL;
688 WEGetRunInfo(offset,
689 &runInfo,
690 _self->ob_itself);
691 _res = Py_BuildValue("O&",
692 RunInfo_New, &runInfo);
693 return _res;
694}
695
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000696static PyObject *wasteObj_WEGetRunDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000697{
698 PyObject *_res = NULL;
699 Boolean _rv;
700 SInt32 offset;
701 if (!PyArg_ParseTuple(_args, "l",
702 &offset))
703 return NULL;
704 _rv = WEGetRunDirection(offset,
705 _self->ob_itself);
706 _res = Py_BuildValue("b",
707 _rv);
708 return _res;
709}
710
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000711static PyObject *wasteObj_WEGetOffset(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000712{
713 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000714 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000715 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000716 WEEdge edge;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000717 if (!PyArg_ParseTuple(_args, "O&",
718 LongPt_Convert, &thePoint))
719 return NULL;
720 _rv = WEGetOffset(&thePoint,
721 &edge,
722 _self->ob_itself);
Jack Jansen97ed9072000-09-08 22:06:16 +0000723 _res = Py_BuildValue("lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000724 _rv,
725 edge);
726 return _res;
727}
728
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000729static PyObject *wasteObj_WEGetPoint(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000730{
731 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000732 SInt32 offset;
733 SInt16 direction;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000734 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000735 SInt16 lineHeight;
736 if (!PyArg_ParseTuple(_args, "lh",
737 &offset,
738 &direction))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000739 return NULL;
740 WEGetPoint(offset,
Jack Jansen2268af51996-08-06 16:04:22 +0000741 direction,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000742 &thePoint,
743 &lineHeight,
744 _self->ob_itself);
745 _res = Py_BuildValue("O&h",
746 LongPt_New, &thePoint,
747 lineHeight);
748 return _res;
749}
750
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000751static PyObject *wasteObj_WEFindWord(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000752{
753 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000754 SInt32 offset;
755 WEEdge edge;
756 SInt32 wordStart;
757 SInt32 wordEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000758 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000759 &offset,
760 &edge))
761 return NULL;
762 WEFindWord(offset,
763 edge,
764 &wordStart,
765 &wordEnd,
766 _self->ob_itself);
767 _res = Py_BuildValue("ll",
768 wordStart,
769 wordEnd);
770 return _res;
771}
772
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000773static PyObject *wasteObj_WEFindLine(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000774{
775 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000776 SInt32 offset;
777 WEEdge edge;
778 SInt32 lineStart;
779 SInt32 lineEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000780 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000781 &offset,
782 &edge))
783 return NULL;
784 WEFindLine(offset,
785 edge,
786 &lineStart,
787 &lineEnd,
788 _self->ob_itself);
789 _res = Py_BuildValue("ll",
790 lineStart,
791 lineEnd);
792 return _res;
793}
794
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000795static PyObject *wasteObj_WEFindParagraph(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000796{
797 PyObject *_res = NULL;
798 SInt32 offset;
799 WEEdge edge;
800 SInt32 paragraphStart;
801 SInt32 paragraphEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000802 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen2369a981998-02-20 15:57:30 +0000803 &offset,
804 &edge))
805 return NULL;
806 WEFindParagraph(offset,
807 edge,
808 &paragraphStart,
809 &paragraphEnd,
810 _self->ob_itself);
811 _res = Py_BuildValue("ll",
812 paragraphStart,
813 paragraphEnd);
814 return _res;
815}
816
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000817static PyObject *wasteObj_WECopyRange(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000818{
819 PyObject *_res = NULL;
820 OSErr _err;
Jack Jansen2268af51996-08-06 16:04:22 +0000821 SInt32 rangeStart;
822 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000823 Handle hText;
824 StScrpHandle hStyles;
825 WESoupHandle hSoup;
826 if (!PyArg_ParseTuple(_args, "llO&O&O&",
827 &rangeStart,
828 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000829 OptResObj_Convert, &hText,
830 OptResObj_Convert, &hStyles,
831 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000832 return NULL;
833 _err = WECopyRange(rangeStart,
834 rangeEnd,
835 hText,
836 hStyles,
837 hSoup,
838 _self->ob_itself);
839 if (_err != noErr) return PyMac_Error(_err);
840 Py_INCREF(Py_None);
841 _res = Py_None;
842 return _res;
843}
844
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000845static PyObject *wasteObj_WEGetAlignment(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000846{
847 PyObject *_res = NULL;
848 WEAlignment _rv;
849 if (!PyArg_ParseTuple(_args, ""))
850 return NULL;
851 _rv = WEGetAlignment(_self->ob_itself);
Jack Jansen97ed9072000-09-08 22:06:16 +0000852 _res = Py_BuildValue("B",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000853 _rv);
854 return _res;
855}
856
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000857static PyObject *wasteObj_WESetAlignment(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000858{
859 PyObject *_res = NULL;
860 WEAlignment alignment;
Jack Jansen97ed9072000-09-08 22:06:16 +0000861 if (!PyArg_ParseTuple(_args, "B",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000862 &alignment))
863 return NULL;
864 WESetAlignment(alignment,
865 _self->ob_itself);
866 Py_INCREF(Py_None);
867 _res = Py_None;
868 return _res;
869}
870
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000871static PyObject *wasteObj_WEGetDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000872{
873 PyObject *_res = NULL;
874 WEDirection _rv;
875 if (!PyArg_ParseTuple(_args, ""))
876 return NULL;
877 _rv = WEGetDirection(_self->ob_itself);
878 _res = Py_BuildValue("h",
879 _rv);
880 return _res;
881}
882
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000883static PyObject *wasteObj_WESetDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000884{
885 PyObject *_res = NULL;
886 WEDirection direction;
887 if (!PyArg_ParseTuple(_args, "h",
888 &direction))
889 return NULL;
890 WESetDirection(direction,
891 _self->ob_itself);
892 Py_INCREF(Py_None);
893 _res = Py_None;
894 return _res;
895}
896
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000897static PyObject *wasteObj_WECalText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000898{
899 PyObject *_res = NULL;
900 OSErr _err;
901 if (!PyArg_ParseTuple(_args, ""))
902 return NULL;
903 _err = WECalText(_self->ob_itself);
904 if (_err != noErr) return PyMac_Error(_err);
905 Py_INCREF(Py_None);
906 _res = Py_None;
907 return _res;
908}
909
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000910static PyObject *wasteObj_WEUpdate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000911{
912 PyObject *_res = NULL;
913 RgnHandle updateRgn;
914 if (!PyArg_ParseTuple(_args, "O&",
915 ResObj_Convert, &updateRgn))
916 return NULL;
917 WEUpdate(updateRgn,
918 _self->ob_itself);
919 Py_INCREF(Py_None);
920 _res = Py_None;
921 return _res;
922}
923
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000924static PyObject *wasteObj_WEScroll(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000925{
926 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000927 SInt32 hOffset;
928 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000929 if (!PyArg_ParseTuple(_args, "ll",
930 &hOffset,
931 &vOffset))
932 return NULL;
933 WEScroll(hOffset,
934 vOffset,
935 _self->ob_itself);
936 Py_INCREF(Py_None);
937 _res = Py_None;
938 return _res;
939}
940
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000941static PyObject *wasteObj_WESelView(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000942{
943 PyObject *_res = NULL;
944 if (!PyArg_ParseTuple(_args, ""))
945 return NULL;
946 WESelView(_self->ob_itself);
947 Py_INCREF(Py_None);
948 _res = Py_None;
949 return _res;
950}
951
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000952static PyObject *wasteObj_WEActivate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000953{
954 PyObject *_res = NULL;
955 if (!PyArg_ParseTuple(_args, ""))
956 return NULL;
957 WEActivate(_self->ob_itself);
958 Py_INCREF(Py_None);
959 _res = Py_None;
960 return _res;
961}
962
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000963static PyObject *wasteObj_WEDeactivate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000964{
965 PyObject *_res = NULL;
966 if (!PyArg_ParseTuple(_args, ""))
967 return NULL;
968 WEDeactivate(_self->ob_itself);
969 Py_INCREF(Py_None);
970 _res = Py_None;
971 return _res;
972}
973
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000974static PyObject *wasteObj_WEKey(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000975{
976 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000977 SInt16 key;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000978 EventModifiers modifiers;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000979 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000980 &key,
981 &modifiers))
982 return NULL;
983 WEKey(key,
984 modifiers,
985 _self->ob_itself);
986 Py_INCREF(Py_None);
987 _res = Py_None;
988 return _res;
989}
990
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000991static PyObject *wasteObj_WEClick(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000992{
993 PyObject *_res = NULL;
994 Point hitPt;
995 EventModifiers modifiers;
Jack Jansen2268af51996-08-06 16:04:22 +0000996 UInt32 clickTime;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000997 if (!PyArg_ParseTuple(_args, "O&Hl",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000998 PyMac_GetPoint, &hitPt,
999 &modifiers,
1000 &clickTime))
1001 return NULL;
1002 WEClick(hitPt,
1003 modifiers,
1004 clickTime,
1005 _self->ob_itself);
1006 Py_INCREF(Py_None);
1007 _res = Py_None;
1008 return _res;
1009}
1010
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001011static PyObject *wasteObj_WEAdjustCursor(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001012{
1013 PyObject *_res = NULL;
1014 Boolean _rv;
1015 Point mouseLoc;
1016 RgnHandle mouseRgn;
1017 if (!PyArg_ParseTuple(_args, "O&O&",
1018 PyMac_GetPoint, &mouseLoc,
1019 ResObj_Convert, &mouseRgn))
1020 return NULL;
1021 _rv = WEAdjustCursor(mouseLoc,
1022 mouseRgn,
1023 _self->ob_itself);
1024 _res = Py_BuildValue("b",
1025 _rv);
1026 return _res;
1027}
1028
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001029static PyObject *wasteObj_WEIdle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001030{
1031 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001032 UInt32 maxSleep;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001033 if (!PyArg_ParseTuple(_args, ""))
1034 return NULL;
1035 WEIdle(&maxSleep,
1036 _self->ob_itself);
1037 _res = Py_BuildValue("l",
1038 maxSleep);
1039 return _res;
1040}
1041
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001042static PyObject *wasteObj_WEInsert(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001043{
1044 PyObject *_res = NULL;
1045 OSErr _err;
1046 char *pText__in__;
1047 long pText__len__;
1048 int pText__in_len__;
1049 StScrpHandle hStyles;
1050 WESoupHandle hSoup;
1051 if (!PyArg_ParseTuple(_args, "s#O&O&",
1052 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001053 OptResObj_Convert, &hStyles,
1054 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001055 return NULL;
1056 pText__len__ = pText__in_len__;
1057 _err = WEInsert(pText__in__, pText__len__,
1058 hStyles,
1059 hSoup,
1060 _self->ob_itself);
1061 if (_err != noErr) return PyMac_Error(_err);
1062 Py_INCREF(Py_None);
1063 _res = Py_None;
1064 pText__error__: ;
1065 return _res;
1066}
1067
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001068static PyObject *wasteObj_WEDelete(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001069{
1070 PyObject *_res = NULL;
1071 OSErr _err;
1072 if (!PyArg_ParseTuple(_args, ""))
1073 return NULL;
1074 _err = WEDelete(_self->ob_itself);
1075 if (_err != noErr) return PyMac_Error(_err);
1076 Py_INCREF(Py_None);
1077 _res = Py_None;
1078 return _res;
1079}
1080
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001081static PyObject *wasteObj_WESetStyle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001082{
1083 PyObject *_res = NULL;
1084 OSErr _err;
1085 WEStyleMode mode;
1086 TextStyle ts;
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001087 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansen90ecdf41996-04-16 14:29:15 +00001088 &mode,
1089 TextStyle_Convert, &ts))
1090 return NULL;
1091 _err = WESetStyle(mode,
1092 &ts,
1093 _self->ob_itself);
1094 if (_err != noErr) return PyMac_Error(_err);
1095 Py_INCREF(Py_None);
1096 _res = Py_None;
1097 return _res;
1098}
1099
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001100static PyObject *wasteObj_WEUseStyleScrap(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001101{
1102 PyObject *_res = NULL;
1103 OSErr _err;
1104 StScrpHandle hStyles;
1105 if (!PyArg_ParseTuple(_args, "O&",
1106 ResObj_Convert, &hStyles))
1107 return NULL;
1108 _err = WEUseStyleScrap(hStyles,
1109 _self->ob_itself);
1110 if (_err != noErr) return PyMac_Error(_err);
1111 Py_INCREF(Py_None);
1112 _res = Py_None;
1113 return _res;
1114}
1115
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001116static PyObject *wasteObj_WEUseText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001117{
1118 PyObject *_res = NULL;
1119 OSErr _err;
1120 Handle hText;
1121 if (!PyArg_ParseTuple(_args, "O&",
1122 ResObj_Convert, &hText))
1123 return NULL;
1124 _err = WEUseText(hText,
1125 _self->ob_itself);
1126 if (_err != noErr) return PyMac_Error(_err);
1127 Py_INCREF(Py_None);
1128 _res = Py_None;
1129 return _res;
1130}
1131
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001132static PyObject *wasteObj_WEUndo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001133{
1134 PyObject *_res = NULL;
1135 OSErr _err;
1136 if (!PyArg_ParseTuple(_args, ""))
1137 return NULL;
1138 _err = WEUndo(_self->ob_itself);
1139 if (_err != noErr) return PyMac_Error(_err);
1140 Py_INCREF(Py_None);
1141 _res = Py_None;
1142 return _res;
1143}
1144
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001145static PyObject *wasteObj_WEClearUndo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001146{
1147 PyObject *_res = NULL;
1148 if (!PyArg_ParseTuple(_args, ""))
1149 return NULL;
1150 WEClearUndo(_self->ob_itself);
1151 Py_INCREF(Py_None);
1152 _res = Py_None;
1153 return _res;
1154}
1155
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001156static PyObject *wasteObj_WEGetUndoInfo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001157{
1158 PyObject *_res = NULL;
1159 WEActionKind _rv;
1160 Boolean redoFlag;
1161 if (!PyArg_ParseTuple(_args, ""))
1162 return NULL;
1163 _rv = WEGetUndoInfo(&redoFlag,
1164 _self->ob_itself);
1165 _res = Py_BuildValue("hb",
1166 _rv,
1167 redoFlag);
1168 return _res;
1169}
1170
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001171static PyObject *wasteObj_WEIsTyping(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001172{
1173 PyObject *_res = NULL;
1174 Boolean _rv;
1175 if (!PyArg_ParseTuple(_args, ""))
1176 return NULL;
1177 _rv = WEIsTyping(_self->ob_itself);
1178 _res = Py_BuildValue("b",
1179 _rv);
1180 return _res;
1181}
1182
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001183static PyObject *wasteObj_WEBeginAction(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001184{
1185 PyObject *_res = NULL;
1186 OSErr _err;
1187 if (!PyArg_ParseTuple(_args, ""))
1188 return NULL;
1189 _err = WEBeginAction(_self->ob_itself);
1190 if (_err != noErr) return PyMac_Error(_err);
1191 Py_INCREF(Py_None);
1192 _res = Py_None;
1193 return _res;
1194}
1195
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001196static PyObject *wasteObj_WEEndAction(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001197{
1198 PyObject *_res = NULL;
1199 OSErr _err;
1200 WEActionKind actionKind;
1201 if (!PyArg_ParseTuple(_args, "h",
1202 &actionKind))
1203 return NULL;
1204 _err = WEEndAction(actionKind,
1205 _self->ob_itself);
1206 if (_err != noErr) return PyMac_Error(_err);
1207 Py_INCREF(Py_None);
1208 _res = Py_None;
1209 return _res;
1210}
1211
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001212static PyObject *wasteObj_WEGetModCount(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001213{
1214 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001215 UInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001216 if (!PyArg_ParseTuple(_args, ""))
1217 return NULL;
1218 _rv = WEGetModCount(_self->ob_itself);
1219 _res = Py_BuildValue("l",
1220 _rv);
1221 return _res;
1222}
1223
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001224static PyObject *wasteObj_WEResetModCount(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001225{
1226 PyObject *_res = NULL;
1227 if (!PyArg_ParseTuple(_args, ""))
1228 return NULL;
1229 WEResetModCount(_self->ob_itself);
1230 Py_INCREF(Py_None);
1231 _res = Py_None;
1232 return _res;
1233}
1234
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001235static PyObject *wasteObj_WEInsertObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001236{
1237 PyObject *_res = NULL;
1238 OSErr _err;
1239 FlavorType objectType;
1240 Handle objectDataHandle;
1241 Point objectSize;
1242 if (!PyArg_ParseTuple(_args, "O&O&O&",
1243 PyMac_GetOSType, &objectType,
1244 ResObj_Convert, &objectDataHandle,
1245 PyMac_GetPoint, &objectSize))
1246 return NULL;
1247 _err = WEInsertObject(objectType,
1248 objectDataHandle,
1249 objectSize,
1250 _self->ob_itself);
1251 if (_err != noErr) return PyMac_Error(_err);
1252 Py_INCREF(Py_None);
1253 _res = Py_None;
1254 return _res;
1255}
1256
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001257static PyObject *wasteObj_WEGetSelectedObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001258{
1259 PyObject *_res = NULL;
1260 OSErr _err;
1261 WEObjectReference obj;
1262 if (!PyArg_ParseTuple(_args, ""))
1263 return NULL;
1264 _err = WEGetSelectedObject(&obj,
1265 _self->ob_itself);
1266 if (_err != noErr) return PyMac_Error(_err);
1267 _res = Py_BuildValue("O&",
1268 WEOObj_New, obj);
1269 return _res;
1270}
1271
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001272static PyObject *wasteObj_WEFindNextObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001273{
1274 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001275 SInt32 _rv;
1276 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001277 WEObjectReference obj;
1278 if (!PyArg_ParseTuple(_args, "l",
1279 &offset))
1280 return NULL;
1281 _rv = WEFindNextObject(offset,
1282 &obj,
1283 _self->ob_itself);
1284 _res = Py_BuildValue("lO&",
1285 _rv,
1286 WEOObj_New, obj);
1287 return _res;
1288}
1289
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001290static PyObject *wasteObj_WEUseSoup(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001291{
1292 PyObject *_res = NULL;
1293 OSErr _err;
1294 WESoupHandle hSoup;
1295 if (!PyArg_ParseTuple(_args, "O&",
1296 ResObj_Convert, &hSoup))
1297 return NULL;
1298 _err = WEUseSoup(hSoup,
1299 _self->ob_itself);
1300 if (_err != noErr) return PyMac_Error(_err);
1301 Py_INCREF(Py_None);
1302 _res = Py_None;
1303 return _res;
1304}
1305
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001306static PyObject *wasteObj_WECut(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001307{
1308 PyObject *_res = NULL;
1309 OSErr _err;
1310 if (!PyArg_ParseTuple(_args, ""))
1311 return NULL;
1312 _err = WECut(_self->ob_itself);
1313 if (_err != noErr) return PyMac_Error(_err);
1314 Py_INCREF(Py_None);
1315 _res = Py_None;
1316 return _res;
1317}
1318
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001319static PyObject *wasteObj_WECopy(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001320{
1321 PyObject *_res = NULL;
1322 OSErr _err;
1323 if (!PyArg_ParseTuple(_args, ""))
1324 return NULL;
1325 _err = WECopy(_self->ob_itself);
1326 if (_err != noErr) return PyMac_Error(_err);
1327 Py_INCREF(Py_None);
1328 _res = Py_None;
1329 return _res;
1330}
1331
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001332static PyObject *wasteObj_WEPaste(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001333{
1334 PyObject *_res = NULL;
1335 OSErr _err;
1336 if (!PyArg_ParseTuple(_args, ""))
1337 return NULL;
1338 _err = WEPaste(_self->ob_itself);
1339 if (_err != noErr) return PyMac_Error(_err);
1340 Py_INCREF(Py_None);
1341 _res = Py_None;
1342 return _res;
1343}
1344
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001345static PyObject *wasteObj_WECanPaste(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001346{
1347 PyObject *_res = NULL;
1348 Boolean _rv;
1349 if (!PyArg_ParseTuple(_args, ""))
1350 return NULL;
1351 _rv = WECanPaste(_self->ob_itself);
1352 _res = Py_BuildValue("b",
1353 _rv);
1354 return _res;
1355}
1356
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001357static PyObject *wasteObj_WEGetHiliteRgn(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001358{
1359 PyObject *_res = NULL;
1360 RgnHandle _rv;
Jack Jansen2268af51996-08-06 16:04:22 +00001361 SInt32 rangeStart;
1362 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001363 if (!PyArg_ParseTuple(_args, "ll",
1364 &rangeStart,
1365 &rangeEnd))
1366 return NULL;
1367 _rv = WEGetHiliteRgn(rangeStart,
1368 rangeEnd,
1369 _self->ob_itself);
1370 _res = Py_BuildValue("O&",
1371 ResObj_New, _rv);
1372 return _res;
1373}
1374
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001375static PyObject *wasteObj_WECharByte(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001376{
1377 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001378 SInt16 _rv;
1379 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001380 if (!PyArg_ParseTuple(_args, "l",
1381 &offset))
1382 return NULL;
1383 _rv = WECharByte(offset,
1384 _self->ob_itself);
1385 _res = Py_BuildValue("h",
1386 _rv);
1387 return _res;
1388}
1389
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001390static PyObject *wasteObj_WECharType(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001391{
1392 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001393 SInt16 _rv;
1394 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001395 if (!PyArg_ParseTuple(_args, "l",
1396 &offset))
1397 return NULL;
1398 _rv = WECharType(offset,
1399 _self->ob_itself);
1400 _res = Py_BuildValue("h",
1401 _rv);
1402 return _res;
1403}
1404
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001405static PyObject *wasteObj_WEStopInlineSession(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001406{
1407 PyObject *_res = NULL;
1408 if (!PyArg_ParseTuple(_args, ""))
1409 return NULL;
1410 WEStopInlineSession(_self->ob_itself);
1411 Py_INCREF(Py_None);
1412 _res = Py_None;
1413 return _res;
1414}
1415
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001416static PyObject *wasteObj_WEFeatureFlag(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001417{
1418 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001419 SInt16 _rv;
1420 SInt16 feature;
1421 SInt16 action;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001422 if (!PyArg_ParseTuple(_args, "hh",
1423 &feature,
1424 &action))
1425 return NULL;
1426 _rv = WEFeatureFlag(feature,
1427 action,
1428 _self->ob_itself);
1429 _res = Py_BuildValue("h",
1430 _rv);
1431 return _res;
1432}
1433
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001434static PyObject *wasteObj_WEGetUserInfo(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001435{
1436 PyObject *_res = NULL;
1437 OSErr _err;
1438 WESelector tag;
1439 SInt32 userInfo;
1440 if (!PyArg_ParseTuple(_args, "O&",
1441 PyMac_GetOSType, &tag))
1442 return NULL;
1443 _err = WEGetUserInfo(tag,
1444 &userInfo,
1445 _self->ob_itself);
1446 if (_err != noErr) return PyMac_Error(_err);
1447 _res = Py_BuildValue("l",
1448 userInfo);
1449 return _res;
1450}
1451
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001452static PyObject *wasteObj_WESetUserInfo(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001453{
1454 PyObject *_res = NULL;
1455 OSErr _err;
1456 WESelector tag;
1457 SInt32 userInfo;
1458 if (!PyArg_ParseTuple(_args, "O&l",
1459 PyMac_GetOSType, &tag,
1460 &userInfo))
1461 return NULL;
1462 _err = WESetUserInfo(tag,
1463 userInfo,
1464 _self->ob_itself);
1465 if (_err != noErr) return PyMac_Error(_err);
1466 Py_INCREF(Py_None);
1467 _res = Py_None;
1468 return _res;
1469}
1470
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001471static PyObject *wasteObj_WEInstallTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001472{
1473 PyObject *_res = NULL;
1474 OSErr _err;
1475 if (!PyArg_ParseTuple(_args, ""))
1476 return NULL;
1477 _err = WEInstallTabHooks(_self->ob_itself);
1478 if (_err != noErr) return PyMac_Error(_err);
1479 Py_INCREF(Py_None);
1480 _res = Py_None;
1481 return _res;
1482}
1483
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001484static PyObject *wasteObj_WERemoveTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001485{
1486 PyObject *_res = NULL;
1487 OSErr _err;
1488 if (!PyArg_ParseTuple(_args, ""))
1489 return NULL;
1490 _err = WERemoveTabHooks(_self->ob_itself);
1491 if (_err != noErr) return PyMac_Error(_err);
1492 Py_INCREF(Py_None);
1493 _res = Py_None;
1494 return _res;
1495}
1496
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001497static PyObject *wasteObj_WEIsTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001498{
1499 PyObject *_res = NULL;
1500 Boolean _rv;
1501 if (!PyArg_ParseTuple(_args, ""))
1502 return NULL;
1503 _rv = WEIsTabHooks(_self->ob_itself);
1504 _res = Py_BuildValue("b",
1505 _rv);
1506 return _res;
1507}
1508
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001509static PyObject *wasteObj_WEGetTabSize(wasteObject *_self, PyObject *_args)
Jack Jansena4f03091998-03-02 16:56:18 +00001510{
1511 PyObject *_res = NULL;
1512 SInt16 _rv;
1513 if (!PyArg_ParseTuple(_args, ""))
1514 return NULL;
1515 _rv = WEGetTabSize(_self->ob_itself);
1516 _res = Py_BuildValue("h",
1517 _rv);
1518 return _res;
1519}
1520
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001521static PyObject *wasteObj_WESetTabSize(wasteObject *_self, PyObject *_args)
Jack Jansena4f03091998-03-02 16:56:18 +00001522{
1523 PyObject *_res = NULL;
1524 OSErr _err;
1525 SInt16 tabWidth;
1526 if (!PyArg_ParseTuple(_args, "h",
1527 &tabWidth))
1528 return NULL;
1529 _err = WESetTabSize(tabWidth,
1530 _self->ob_itself);
1531 if (_err != noErr) return PyMac_Error(_err);
1532 Py_INCREF(Py_None);
1533 _res = Py_None;
1534 return _res;
1535}
1536
Jack Jansen90ecdf41996-04-16 14:29:15 +00001537static PyMethodDef wasteObj_methods[] = {
1538 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1539 "() -> (Handle _rv)"},
1540 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001541 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001542 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001543 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001544 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001545 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001546 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001547 "() -> (SInt32 selStart, SInt32 selEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001548 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1549 "() -> (LongRect destRect)"},
1550 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1551 "() -> (LongRect viewRect)"},
1552 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1553 "() -> (Boolean _rv)"},
1554 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001555 "(SInt32 offset) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001556 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
Jack Jansen2369a981998-02-20 15:57:30 +00001557 "(SInt32 lineIndex) -> (SInt32 lineStart, SInt32 lineEnd)"},
1558 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
1559 "() -> (SInt32 _rv)"},
1560 {"WEOffsetToRun", (PyCFunction)wasteObj_WEOffsetToRun, 1,
1561 "(SInt32 offset) -> (SInt32 _rv)"},
1562 {"WEGetRunRange", (PyCFunction)wasteObj_WEGetRunRange, 1,
1563 "(SInt32 runIndex) -> (SInt32 runStart, SInt32 runEnd)"},
1564 {"WECountRuns", (PyCFunction)wasteObj_WECountRuns, 1,
1565 "() -> (SInt32 _rv)"},
Jack Jansen2268af51996-08-06 16:04:22 +00001566 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1567 "() -> (UInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001568 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001569 "(SInt32 selStart, SInt32 selEnd) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001570 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1571 "(LongRect destRect) -> None"},
1572 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1573 "(LongRect viewRect) -> None"},
1574 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001575 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001576 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001577 "(SInt32 offset) -> (WERunInfo runInfo)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001578 {"WEGetRunDirection", (PyCFunction)wasteObj_WEGetRunDirection, 1,
1579 "(SInt32 offset) -> (Boolean _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001580 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001581 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001582 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001583 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001584 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001585 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001586 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001587 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001588 {"WEFindParagraph", (PyCFunction)wasteObj_WEFindParagraph, 1,
1589 "(SInt32 offset, WEEdge edge) -> (SInt32 paragraphStart, SInt32 paragraphEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001590 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001591 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001592 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1593 "() -> (WEAlignment _rv)"},
1594 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1595 "(WEAlignment alignment) -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00001596 {"WEGetDirection", (PyCFunction)wasteObj_WEGetDirection, 1,
1597 "() -> (WEDirection _rv)"},
1598 {"WESetDirection", (PyCFunction)wasteObj_WESetDirection, 1,
1599 "(WEDirection direction) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001600 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1601 "() -> None"},
1602 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1603 "(RgnHandle updateRgn) -> None"},
1604 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001605 "(SInt32 hOffset, SInt32 vOffset) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001606 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1607 "() -> None"},
1608 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1609 "() -> None"},
1610 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1611 "() -> None"},
1612 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001613 "(SInt16 key, EventModifiers modifiers) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001614 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001615 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001616 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1617 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1618 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001619 "() -> (UInt32 maxSleep)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001620 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1621 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1622 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1623 "() -> None"},
1624 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1625 "(WEStyleMode mode, TextStyle ts) -> None"},
1626 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1627 "(StScrpHandle hStyles) -> None"},
1628 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1629 "(Handle hText) -> None"},
1630 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1631 "() -> None"},
1632 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1633 "() -> None"},
1634 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1635 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1636 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1637 "() -> (Boolean _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001638 {"WEBeginAction", (PyCFunction)wasteObj_WEBeginAction, 1,
1639 "() -> None"},
1640 {"WEEndAction", (PyCFunction)wasteObj_WEEndAction, 1,
1641 "(WEActionKind actionKind) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001642 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001643 "() -> (UInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001644 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1645 "() -> None"},
1646 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1647 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1648 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1649 "() -> (WEObjectReference obj)"},
1650 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001651 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001652 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1653 "(WESoupHandle hSoup) -> None"},
1654 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1655 "() -> None"},
1656 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1657 "() -> None"},
1658 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1659 "() -> None"},
1660 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1661 "() -> (Boolean _rv)"},
1662 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001663 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001664 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001665 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001666 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001667 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001668 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1669 "() -> None"},
1670 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001671 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001672 {"WEGetUserInfo", (PyCFunction)wasteObj_WEGetUserInfo, 1,
1673 "(WESelector tag) -> (SInt32 userInfo)"},
1674 {"WESetUserInfo", (PyCFunction)wasteObj_WESetUserInfo, 1,
1675 "(WESelector tag, SInt32 userInfo) -> None"},
Jack Jansen176f3a91996-10-23 15:43:46 +00001676 {"WEInstallTabHooks", (PyCFunction)wasteObj_WEInstallTabHooks, 1,
1677 "() -> None"},
1678 {"WERemoveTabHooks", (PyCFunction)wasteObj_WERemoveTabHooks, 1,
1679 "() -> None"},
1680 {"WEIsTabHooks", (PyCFunction)wasteObj_WEIsTabHooks, 1,
1681 "() -> (Boolean _rv)"},
Jack Jansena4f03091998-03-02 16:56:18 +00001682 {"WEGetTabSize", (PyCFunction)wasteObj_WEGetTabSize, 1,
1683 "() -> (SInt16 _rv)"},
1684 {"WESetTabSize", (PyCFunction)wasteObj_WESetTabSize, 1,
1685 "(SInt16 tabWidth) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001686 {NULL, NULL, 0}
1687};
1688
1689PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1690
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001691static PyObject *wasteObj_getattr(wasteObject *self, char *name)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001692{
1693 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1694}
1695
1696#define wasteObj_setattr NULL
1697
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001698#define wasteObj_compare NULL
1699
1700#define wasteObj_repr NULL
1701
1702#define wasteObj_hash NULL
1703
Jack Jansen90ecdf41996-04-16 14:29:15 +00001704PyTypeObject waste_Type = {
1705 PyObject_HEAD_INIT(&PyType_Type)
1706 0, /*ob_size*/
1707 "waste", /*tp_name*/
1708 sizeof(wasteObject), /*tp_basicsize*/
1709 0, /*tp_itemsize*/
1710 /* methods */
1711 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1712 0, /*tp_print*/
1713 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1714 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001715 (cmpfunc) wasteObj_compare, /*tp_compare*/
1716 (reprfunc) wasteObj_repr, /*tp_repr*/
1717 (PyNumberMethods *)0, /* tp_as_number */
1718 (PySequenceMethods *)0, /* tp_as_sequence */
1719 (PyMappingMethods *)0, /* tp_as_mapping */
1720 (hashfunc) wasteObj_hash, /*tp_hash*/
Jack Jansen90ecdf41996-04-16 14:29:15 +00001721};
1722
1723/* --------------------- End object type waste ---------------------- */
1724
1725
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001726static PyObject *waste_WENew(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001727{
1728 PyObject *_res = NULL;
1729 OSErr _err;
1730 LongRect destRect;
1731 LongRect viewRect;
Jack Jansen2268af51996-08-06 16:04:22 +00001732 UInt32 flags;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001733 WEReference we;
1734 if (!PyArg_ParseTuple(_args, "O&O&l",
1735 LongRect_Convert, &destRect,
1736 LongRect_Convert, &viewRect,
1737 &flags))
1738 return NULL;
1739 _err = WENew(&destRect,
1740 &viewRect,
1741 flags,
1742 &we);
1743 if (_err != noErr) return PyMac_Error(_err);
1744 _res = Py_BuildValue("O&",
1745 wasteObj_New, we);
1746 return _res;
1747}
1748
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001749static PyObject *waste_WEUpdateStyleScrap(PyObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001750{
1751 PyObject *_res = NULL;
1752 OSErr _err;
1753 StScrpHandle hStyles;
1754 WEFontTableHandle hFontTable;
1755 if (!PyArg_ParseTuple(_args, "O&O&",
1756 ResObj_Convert, &hStyles,
1757 ResObj_Convert, &hFontTable))
1758 return NULL;
1759 _err = WEUpdateStyleScrap(hStyles,
1760 hFontTable);
1761 if (_err != noErr) return PyMac_Error(_err);
1762 Py_INCREF(Py_None);
1763 _res = Py_None;
1764 return _res;
1765}
1766
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001767static PyObject *waste_WEInstallTSMHandlers(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001768{
1769 PyObject *_res = NULL;
1770 OSErr _err;
1771 if (!PyArg_ParseTuple(_args, ""))
1772 return NULL;
1773 _err = WEInstallTSMHandlers();
1774 if (_err != noErr) return PyMac_Error(_err);
1775 Py_INCREF(Py_None);
1776 _res = Py_None;
1777 return _res;
1778}
1779
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001780static PyObject *waste_WERemoveTSMHandlers(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001781{
1782 PyObject *_res = NULL;
1783 OSErr _err;
1784 if (!PyArg_ParseTuple(_args, ""))
1785 return NULL;
1786 _err = WERemoveTSMHandlers();
1787 if (_err != noErr) return PyMac_Error(_err);
1788 Py_INCREF(Py_None);
1789 _res = Py_None;
1790 return _res;
1791}
1792
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001793static PyObject *waste_WEHandleTSMEvent(PyObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001794{
1795 PyObject *_res = NULL;
1796 OSErr _err;
1797 AppleEvent ae;
1798 AppleEvent reply;
1799 if (!PyArg_ParseTuple(_args, "O&",
1800 AEDesc_Convert, &ae))
1801 return NULL;
1802 _err = WEHandleTSMEvent(&ae,
1803 &reply);
1804 if (_err != noErr) return PyMac_Error(_err);
1805 _res = Py_BuildValue("O&",
1806 AEDesc_New, &reply);
1807 return _res;
1808}
1809
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001810static PyObject *waste_WELongPointToPoint(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001811{
1812 PyObject *_res = NULL;
1813 LongPt lp;
1814 Point p;
1815 if (!PyArg_ParseTuple(_args, "O&",
1816 LongPt_Convert, &lp))
1817 return NULL;
1818 WELongPointToPoint(&lp,
1819 &p);
1820 _res = Py_BuildValue("O&",
1821 PyMac_BuildPoint, p);
1822 return _res;
1823}
1824
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001825static PyObject *waste_WEPointToLongPoint(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001826{
1827 PyObject *_res = NULL;
1828 Point p;
1829 LongPt lp;
1830 if (!PyArg_ParseTuple(_args, "O&",
1831 PyMac_GetPoint, &p))
1832 return NULL;
1833 WEPointToLongPoint(p,
1834 &lp);
1835 _res = Py_BuildValue("O&",
1836 LongPt_New, &lp);
1837 return _res;
1838}
1839
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001840static PyObject *waste_WESetLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001841{
1842 PyObject *_res = NULL;
1843 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001844 SInt32 left;
1845 SInt32 top;
1846 SInt32 right;
1847 SInt32 bottom;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001848 if (!PyArg_ParseTuple(_args, "llll",
1849 &left,
1850 &top,
1851 &right,
1852 &bottom))
1853 return NULL;
1854 WESetLongRect(&lr,
1855 left,
1856 top,
1857 right,
1858 bottom);
1859 _res = Py_BuildValue("O&",
1860 LongRect_New, &lr);
1861 return _res;
1862}
1863
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001864static PyObject *waste_WELongRectToRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001865{
1866 PyObject *_res = NULL;
1867 LongRect lr;
1868 Rect r;
1869 if (!PyArg_ParseTuple(_args, "O&",
1870 LongRect_Convert, &lr))
1871 return NULL;
1872 WELongRectToRect(&lr,
1873 &r);
1874 _res = Py_BuildValue("O&",
1875 PyMac_BuildRect, &r);
1876 return _res;
1877}
1878
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001879static PyObject *waste_WERectToLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001880{
1881 PyObject *_res = NULL;
1882 Rect r;
1883 LongRect lr;
1884 if (!PyArg_ParseTuple(_args, "O&",
1885 PyMac_GetRect, &r))
1886 return NULL;
1887 WERectToLongRect(&r,
1888 &lr);
1889 _res = Py_BuildValue("O&",
1890 LongRect_New, &lr);
1891 return _res;
1892}
1893
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001894static PyObject *waste_WEOffsetLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001895{
1896 PyObject *_res = NULL;
1897 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001898 SInt32 hOffset;
1899 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001900 if (!PyArg_ParseTuple(_args, "ll",
1901 &hOffset,
1902 &vOffset))
1903 return NULL;
1904 WEOffsetLongRect(&lr,
1905 hOffset,
1906 vOffset);
1907 _res = Py_BuildValue("O&",
1908 LongRect_New, &lr);
1909 return _res;
1910}
1911
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001912static PyObject *waste_WELongPointInLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001913{
1914 PyObject *_res = NULL;
1915 Boolean _rv;
1916 LongPt lp;
1917 LongRect lr;
1918 if (!PyArg_ParseTuple(_args, "O&O&",
1919 LongPt_Convert, &lp,
1920 LongRect_Convert, &lr))
1921 return NULL;
1922 _rv = WELongPointInLongRect(&lp,
1923 &lr);
1924 _res = Py_BuildValue("b",
1925 _rv);
1926 return _res;
1927}
1928
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001929static PyObject *waste_STDObjectHandlers(PyObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +00001930{
1931 PyObject *_res = NULL;
1932
1933 OSErr err;
1934 // install the sample object handlers for pictures and sounds
1935#define kTypePicture 'PICT'
1936#define kTypeSound 'snd '
1937
1938 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
1939
1940 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
1941 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
1942 goto cleanup;
1943
1944 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
1945 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
1946 goto cleanup;
1947
1948 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
1949 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
1950 goto cleanup;
1951
1952 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
1953 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
1954 goto cleanup;
1955
1956 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
1957 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
1958 goto cleanup;
1959
1960 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
1961 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
1962 goto cleanup;
1963 Py_INCREF(Py_None);
1964 return Py_None;
1965
1966 cleanup:
1967 return PyMac_Error(err);
1968
1969}
1970
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001971static PyObject *waste_WEInstallObjectHandler(PyObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +00001972{
1973 PyObject *_res = NULL;
1974
1975 OSErr err;
1976 FlavorType objectType;
1977 WESelector selector;
1978 PyObject *py_handler;
1979 UniversalProcPtr handler;
1980 WEReference we = NULL;
1981 PyObject *key;
1982
1983
1984 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
1985 PyMac_GetOSType, &objectType,
1986 PyMac_GetOSType, &selector,
1987 &py_handler,
Jack Jansen7df36061996-10-01 11:41:14 +00001988 WEOObj_Convert, &we) ) return NULL;
Jack Jansen756522f1996-05-07 15:24:01 +00001989
Jack Jansen25241d91996-05-20 11:30:45 +00001990 if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
1991 else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
1992 else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
1993 else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +00001994 else return PyMac_Error(weUndefinedSelectorErr);
1995
1996 if ((key = Py_BuildValue("O&O&",
1997 PyMac_BuildOSType, objectType,
1998 PyMac_BuildOSType, selector)) == NULL )
1999 return NULL;
2000
2001 PyDict_SetItem(callbackdict, key, py_handler);
2002
2003 err = WEInstallObjectHandler(objectType, selector, handler, we);
2004 if ( err ) return PyMac_Error(err);
2005 Py_INCREF(Py_None);
2006 return Py_None;
2007
2008}
2009
Jack Jansen90ecdf41996-04-16 14:29:15 +00002010static PyMethodDef waste_methods[] = {
2011 {"WENew", (PyCFunction)waste_WENew, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002012 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
Jack Jansen2369a981998-02-20 15:57:30 +00002013 {"WEUpdateStyleScrap", (PyCFunction)waste_WEUpdateStyleScrap, 1,
2014 "(StScrpHandle hStyles, WEFontTableHandle hFontTable) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002015 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
2016 "() -> None"},
2017 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
2018 "() -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00002019 {"WEHandleTSMEvent", (PyCFunction)waste_WEHandleTSMEvent, 1,
2020 "(AppleEvent ae) -> (AppleEvent reply)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002021 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
2022 "(LongPt lp) -> (Point p)"},
2023 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
2024 "(Point p) -> (LongPt lp)"},
2025 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002026 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002027 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
2028 "(LongRect lr) -> (Rect r)"},
2029 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
2030 "(Rect r) -> (LongRect lr)"},
2031 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002032 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002033 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
2034 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00002035 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
2036 NULL},
2037 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
2038 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002039 {NULL, NULL, 0}
2040};
2041
2042
2043
Jack Jansen756522f1996-05-07 15:24:01 +00002044/* Return the object corresponding to the window, or NULL */
2045
2046PyObject *
2047ExistingwasteObj_New(w)
2048 WEReference w;
2049{
2050 PyObject *it = NULL;
2051
2052 if (w == NULL)
2053 it = NULL;
2054 else
2055 WEGetInfo(weRefCon, (void *)&it, w);
2056 if (it == NULL || ((wasteObject *)it)->ob_itself != w)
2057 it = Py_None;
2058 Py_INCREF(it);
2059 return it;
2060}
2061
Jack Jansen90ecdf41996-04-16 14:29:15 +00002062
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002063void initwaste(void)
Jack Jansen90ecdf41996-04-16 14:29:15 +00002064{
2065 PyObject *m;
2066 PyObject *d;
2067
2068
2069
2070
2071 m = Py_InitModule("waste", waste_methods);
2072 d = PyModule_GetDict(m);
2073 waste_Error = PyMac_GetOSErrException();
2074 if (waste_Error == NULL ||
2075 PyDict_SetItemString(d, "Error", waste_Error) != 0)
Jack Jansen97ed9072000-09-08 22:06:16 +00002076 return;
Jack Jansena755e681997-09-20 17:40:22 +00002077 WEO_Type.ob_type = &PyType_Type;
2078 Py_INCREF(&WEO_Type);
2079 if (PyDict_SetItemString(d, "WEOType", (PyObject *)&WEO_Type) != 0)
2080 Py_FatalError("can't initialize WEOType");
2081 waste_Type.ob_type = &PyType_Type;
2082 Py_INCREF(&waste_Type);
2083 if (PyDict_SetItemString(d, "wasteType", (PyObject *)&waste_Type) != 0)
2084 Py_FatalError("can't initialize wasteType");
Jack Jansen756522f1996-05-07 15:24:01 +00002085
2086 callbackdict = PyDict_New();
2087 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
Jack Jansen97ed9072000-09-08 22:06:16 +00002088 return;
Jack Jansen756522f1996-05-07 15:24:01 +00002089 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00002090 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
2091 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
2092 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00002093
2094
Jack Jansen90ecdf41996-04-16 14:29:15 +00002095}
2096
2097/* ======================== End module waste ======================== */
2098