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