blob: 7f74ff6a3cfe21891d62c4dd65790bef962de859 [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 Jansen756522f1996-05-07 15:24:01 +000046#include <WEObjectHandlers.h>
Jack Jansen176f3a91996-10-23 15:43:46 +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
53/* Forward declaration */
54staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000055staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000056
57/*
58** Parse/generate TextStyle records
59*/
60static
61PyObject *TextStyle_New(itself)
62 TextStylePtr itself;
63{
64
65 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
66 &itself->tsColor);
67}
68
69static
70TextStyle_Convert(v, p_itself)
71 PyObject *v;
72 TextStylePtr p_itself;
73{
74 long font, face, size;
75
76 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
77 return 0;
78 p_itself->tsFont = (short)font;
79 p_itself->tsFace = (Style)face;
80 p_itself->tsSize = (short)size;
81 return 1;
82}
83
84/*
85** Parse/generate RunInfo records
86*/
87static
88PyObject *RunInfo_New(itself)
89 WERunInfo *itself;
90{
91
92 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
93 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
94}
95
96/* Conversion of long points and rects */
97int
98LongRect_Convert(PyObject *v, LongRect *r)
99{
100 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
101}
102
103PyObject *
104LongRect_New(LongRect *r)
105{
106 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
107}
108
109
110LongPt_Convert(PyObject *v, LongPt *p)
111{
112 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
113}
114
115PyObject *
116LongPt_New(LongPt *p)
117{
118 return Py_BuildValue("(ll)", p->h, p->v);
119}
120
Jack Jansen756522f1996-05-07 15:24:01 +0000121/* Stuff for the callbacks: */
122static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +0000123WENewObjectUPP upp_new_handler;
124WEDisposeObjectUPP upp_dispose_handler;
125WEDrawObjectUPP upp_draw_handler;
126WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +0000127
128static OSErr
129any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
130{
131 FlavorType tp;
132 PyObject *key, *func;
133
134 if ( args == NULL ) return errAECorruptData;
135
136 tp = WEGetObjectType(who);
137
138 if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
139 return errAECorruptData;
140 if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
141 Py_DECREF(key);
142 return errAEHandlerNotFound;
143 }
144 Py_INCREF(func);
145 *rv = PyEval_CallObject(func, args);
146 Py_DECREF(func);
147 Py_DECREF(key);
148 if ( *rv == NULL ) {
149 fprintf(stderr, "--Exception in callback: ");
150 PyErr_Print();
151 return errAEReplyNotArrived;
152 }
153 return 0;
154}
155
156static pascal OSErr
157my_new_handler(Point *objectSize, WEObjectReference objref)
158{
159 PyObject *args=NULL, *rv=NULL;
160 OSErr err;
161
162 args=Py_BuildValue("(O&)", WEOObj_New, objref);
163 err = any_handler(weNewHandler, objref, args, &rv);
164 if (!err) {
165 if (!PyMac_GetPoint(rv, objectSize) )
166 err = errAECoercionFail;
167 }
168 if ( args ) Py_DECREF(args);
169 if ( rv ) Py_DECREF(rv);
170 return err;
171}
172
173static pascal OSErr
174my_dispose_handler(WEObjectReference objref)
175{
176 PyObject *args=NULL, *rv=NULL;
177 OSErr err;
178
179 args=Py_BuildValue("(O&)", WEOObj_New, objref);
180 err = any_handler(weDisposeHandler, objref, args, &rv);
181 if ( args ) Py_DECREF(args);
182 if ( rv ) Py_DECREF(rv);
183 return err;
184}
185
186static pascal OSErr
187my_draw_handler(Rect *destRect, WEObjectReference objref)
188{
189 PyObject *args=NULL, *rv=NULL;
190 OSErr err;
191
192 args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
193 err = any_handler(weDrawHandler, objref, args, &rv);
194 if ( args ) Py_DECREF(args);
195 if ( rv ) Py_DECREF(rv);
196 return err;
197}
198
199static pascal Boolean
200my_click_handler(Point hitPt, EventModifiers modifiers,
201 unsigned long clickTime, WEObjectReference objref)
202{
203 PyObject *args=NULL, *rv=NULL;
204 int retvalue;
205 OSErr err;
206
207 args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
208 (long)modifiers, (long)clickTime, WEOObj_New, objref);
209 err = any_handler(weClickHandler, objref, args, &rv);
210 if (!err)
211 retvalue = PyInt_AsLong(rv);
212 else
213 retvalue = 0;
214 if ( args ) Py_DECREF(args);
215 if ( rv ) Py_DECREF(rv);
216 return retvalue;
217}
218
219
220
Jack Jansen90ecdf41996-04-16 14:29:15 +0000221static PyObject *waste_Error;
222
223/* ------------------------ Object type WEO ------------------------- */
224
225PyTypeObject WEO_Type;
226
227#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
228
229typedef struct WEOObject {
230 PyObject_HEAD
231 WEObjectReference ob_itself;
232} WEOObject;
233
234PyObject *WEOObj_New(itself)
235 WEObjectReference itself;
236{
237 WEOObject *it;
238 if (itself == NULL) {
239 Py_INCREF(Py_None);
240 return Py_None;
241 }
242 it = PyObject_NEW(WEOObject, &WEO_Type);
243 if (it == NULL) return NULL;
244 it->ob_itself = itself;
245 return (PyObject *)it;
246}
247WEOObj_Convert(v, p_itself)
248 PyObject *v;
249 WEObjectReference *p_itself;
250{
251 if (!WEOObj_Check(v))
252 {
253 PyErr_SetString(PyExc_TypeError, "WEO required");
254 return 0;
255 }
256 *p_itself = ((WEOObject *)v)->ob_itself;
257 return 1;
258}
259
260static void WEOObj_dealloc(self)
261 WEOObject *self;
262{
263 /* Cleanup of self->ob_itself goes here */
264 PyMem_DEL(self);
265}
266
267static PyObject *WEOObj_WEGetObjectType(_self, _args)
268 WEOObject *_self;
269 PyObject *_args;
270{
271 PyObject *_res = NULL;
272 FlavorType _rv;
273 if (!PyArg_ParseTuple(_args, ""))
274 return NULL;
275 _rv = WEGetObjectType(_self->ob_itself);
276 _res = Py_BuildValue("O&",
277 PyMac_BuildOSType, _rv);
278 return _res;
279}
280
281static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args)
282 WEOObject *_self;
283 PyObject *_args;
284{
285 PyObject *_res = NULL;
286 Handle _rv;
287 if (!PyArg_ParseTuple(_args, ""))
288 return NULL;
289 _rv = WEGetObjectDataHandle(_self->ob_itself);
290 _res = Py_BuildValue("O&",
291 ResObj_New, _rv);
292 return _res;
293}
294
295static PyObject *WEOObj_WEGetObjectSize(_self, _args)
296 WEOObject *_self;
297 PyObject *_args;
298{
299 PyObject *_res = NULL;
300 Point _rv;
301 if (!PyArg_ParseTuple(_args, ""))
302 return NULL;
303 _rv = WEGetObjectSize(_self->ob_itself);
304 _res = Py_BuildValue("O&",
305 PyMac_BuildPoint, _rv);
306 return _res;
307}
308
Jack Jansen756522f1996-05-07 15:24:01 +0000309static PyObject *WEOObj_WEGetObjectOwner(_self, _args)
310 WEOObject *_self;
311 PyObject *_args;
312{
313 PyObject *_res = NULL;
314 WEReference _rv;
315 if (!PyArg_ParseTuple(_args, ""))
316 return NULL;
317 _rv = WEGetObjectOwner(_self->ob_itself);
318 _res = Py_BuildValue("O&",
319 ExistingwasteObj_New, _rv);
320 return _res;
321}
322
Jack Jansen90ecdf41996-04-16 14:29:15 +0000323static PyObject *WEOObj_WEGetObjectRefCon(_self, _args)
324 WEOObject *_self;
325 PyObject *_args;
326{
327 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000328 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000329 if (!PyArg_ParseTuple(_args, ""))
330 return NULL;
331 _rv = WEGetObjectRefCon(_self->ob_itself);
332 _res = Py_BuildValue("l",
333 _rv);
334 return _res;
335}
336
337static PyObject *WEOObj_WESetObjectRefCon(_self, _args)
338 WEOObject *_self;
339 PyObject *_args;
340{
341 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000342 SInt32 refCon;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000343 if (!PyArg_ParseTuple(_args, "l",
344 &refCon))
345 return NULL;
346 WESetObjectRefCon(_self->ob_itself,
347 refCon);
348 Py_INCREF(Py_None);
349 _res = Py_None;
350 return _res;
351}
352
353static PyMethodDef WEOObj_methods[] = {
354 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
355 "() -> (FlavorType _rv)"},
356 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
357 "() -> (Handle _rv)"},
358 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
359 "() -> (Point _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +0000360 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
361 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000362 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000363 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000364 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000365 "(SInt32 refCon) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000366 {NULL, NULL, 0}
367};
368
369PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
370
371static PyObject *WEOObj_getattr(self, name)
372 WEOObject *self;
373 char *name;
374{
375 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
376}
377
378#define WEOObj_setattr NULL
379
380PyTypeObject WEO_Type = {
381 PyObject_HEAD_INIT(&PyType_Type)
382 0, /*ob_size*/
383 "WEO", /*tp_name*/
384 sizeof(WEOObject), /*tp_basicsize*/
385 0, /*tp_itemsize*/
386 /* methods */
387 (destructor) WEOObj_dealloc, /*tp_dealloc*/
388 0, /*tp_print*/
389 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
390 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
391};
392
393/* ---------------------- End object type WEO ----------------------- */
394
395
396/* ----------------------- Object type waste ------------------------ */
397
398PyTypeObject waste_Type;
399
400#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
401
402typedef struct wasteObject {
403 PyObject_HEAD
404 WEReference ob_itself;
405} wasteObject;
406
407PyObject *wasteObj_New(itself)
408 WEReference itself;
409{
410 wasteObject *it;
411 if (itself == NULL) {
412 PyErr_SetString(waste_Error,"Cannot create null WE");
413 return NULL;
414 }
415 it = PyObject_NEW(wasteObject, &waste_Type);
416 if (it == NULL) return NULL;
417 it->ob_itself = itself;
Jack Jansen756522f1996-05-07 15:24:01 +0000418 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000419 return (PyObject *)it;
420}
421wasteObj_Convert(v, p_itself)
422 PyObject *v;
423 WEReference *p_itself;
424{
425 if (!wasteObj_Check(v))
426 {
427 PyErr_SetString(PyExc_TypeError, "waste required");
428 return 0;
429 }
430 *p_itself = ((wasteObject *)v)->ob_itself;
431 return 1;
432}
433
434static void wasteObj_dealloc(self)
435 wasteObject *self;
436{
437 WEDispose(self->ob_itself);
438 PyMem_DEL(self);
439}
440
441static PyObject *wasteObj_WEGetText(_self, _args)
442 wasteObject *_self;
443 PyObject *_args;
444{
445 PyObject *_res = NULL;
446 Handle _rv;
447 if (!PyArg_ParseTuple(_args, ""))
448 return NULL;
449 _rv = WEGetText(_self->ob_itself);
450 _res = Py_BuildValue("O&",
451 ResObj_New, _rv);
452 return _res;
453}
454
455static PyObject *wasteObj_WEGetChar(_self, _args)
456 wasteObject *_self;
457 PyObject *_args;
458{
459 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000460 SInt16 _rv;
461 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000462 if (!PyArg_ParseTuple(_args, "l",
463 &offset))
464 return NULL;
465 _rv = WEGetChar(offset,
466 _self->ob_itself);
467 _res = Py_BuildValue("h",
468 _rv);
469 return _res;
470}
471
472static PyObject *wasteObj_WEGetTextLength(_self, _args)
473 wasteObject *_self;
474 PyObject *_args;
475{
476 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000477 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000478 if (!PyArg_ParseTuple(_args, ""))
479 return NULL;
480 _rv = WEGetTextLength(_self->ob_itself);
481 _res = Py_BuildValue("l",
482 _rv);
483 return _res;
484}
485
486static PyObject *wasteObj_WECountLines(_self, _args)
487 wasteObject *_self;
488 PyObject *_args;
489{
490 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000491 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000492 if (!PyArg_ParseTuple(_args, ""))
493 return NULL;
494 _rv = WECountLines(_self->ob_itself);
495 _res = Py_BuildValue("l",
496 _rv);
497 return _res;
498}
499
500static PyObject *wasteObj_WEGetHeight(_self, _args)
501 wasteObject *_self;
502 PyObject *_args;
503{
504 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000505 SInt32 _rv;
506 SInt32 startLine;
507 SInt32 endLine;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000508 if (!PyArg_ParseTuple(_args, "ll",
509 &startLine,
510 &endLine))
511 return NULL;
512 _rv = WEGetHeight(startLine,
513 endLine,
514 _self->ob_itself);
515 _res = Py_BuildValue("l",
516 _rv);
517 return _res;
518}
519
520static PyObject *wasteObj_WEGetSelection(_self, _args)
521 wasteObject *_self;
522 PyObject *_args;
523{
524 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000525 SInt32 selStart;
526 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000527 if (!PyArg_ParseTuple(_args, ""))
528 return NULL;
529 WEGetSelection(&selStart,
530 &selEnd,
531 _self->ob_itself);
532 _res = Py_BuildValue("ll",
533 selStart,
534 selEnd);
535 return _res;
536}
537
538static PyObject *wasteObj_WEGetDestRect(_self, _args)
539 wasteObject *_self;
540 PyObject *_args;
541{
542 PyObject *_res = NULL;
543 LongRect destRect;
544 if (!PyArg_ParseTuple(_args, ""))
545 return NULL;
546 WEGetDestRect(&destRect,
547 _self->ob_itself);
548 _res = Py_BuildValue("O&",
549 LongRect_New, &destRect);
550 return _res;
551}
552
553static PyObject *wasteObj_WEGetViewRect(_self, _args)
554 wasteObject *_self;
555 PyObject *_args;
556{
557 PyObject *_res = NULL;
558 LongRect viewRect;
559 if (!PyArg_ParseTuple(_args, ""))
560 return NULL;
561 WEGetViewRect(&viewRect,
562 _self->ob_itself);
563 _res = Py_BuildValue("O&",
564 LongRect_New, &viewRect);
565 return _res;
566}
567
568static PyObject *wasteObj_WEIsActive(_self, _args)
569 wasteObject *_self;
570 PyObject *_args;
571{
572 PyObject *_res = NULL;
573 Boolean _rv;
574 if (!PyArg_ParseTuple(_args, ""))
575 return NULL;
576 _rv = WEIsActive(_self->ob_itself);
577 _res = Py_BuildValue("b",
578 _rv);
579 return _res;
580}
581
582static PyObject *wasteObj_WEOffsetToLine(_self, _args)
583 wasteObject *_self;
584 PyObject *_args;
585{
586 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000587 SInt32 _rv;
588 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000589 if (!PyArg_ParseTuple(_args, "l",
590 &offset))
591 return NULL;
592 _rv = WEOffsetToLine(offset,
593 _self->ob_itself);
594 _res = Py_BuildValue("l",
595 _rv);
596 return _res;
597}
598
599static PyObject *wasteObj_WEGetLineRange(_self, _args)
600 wasteObject *_self;
601 PyObject *_args;
602{
603 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000604 SInt32 lineNo;
605 SInt32 lineStart;
606 SInt32 lineEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000607 if (!PyArg_ParseTuple(_args, "l",
608 &lineNo))
609 return NULL;
610 WEGetLineRange(lineNo,
611 &lineStart,
612 &lineEnd,
613 _self->ob_itself);
614 _res = Py_BuildValue("ll",
615 lineStart,
616 lineEnd);
617 return _res;
618}
619
Jack Jansen2268af51996-08-06 16:04:22 +0000620static PyObject *wasteObj_WEGetClickCount(_self, _args)
621 wasteObject *_self;
622 PyObject *_args;
623{
624 PyObject *_res = NULL;
625 UInt16 _rv;
626 if (!PyArg_ParseTuple(_args, ""))
627 return NULL;
628 _rv = WEGetClickCount(_self->ob_itself);
629 _res = Py_BuildValue("h",
630 _rv);
631 return _res;
632}
633
Jack Jansen90ecdf41996-04-16 14:29:15 +0000634static PyObject *wasteObj_WESetSelection(_self, _args)
635 wasteObject *_self;
636 PyObject *_args;
637{
638 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000639 SInt32 selStart;
640 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000641 if (!PyArg_ParseTuple(_args, "ll",
642 &selStart,
643 &selEnd))
644 return NULL;
645 WESetSelection(selStart,
646 selEnd,
647 _self->ob_itself);
648 Py_INCREF(Py_None);
649 _res = Py_None;
650 return _res;
651}
652
653static PyObject *wasteObj_WESetDestRect(_self, _args)
654 wasteObject *_self;
655 PyObject *_args;
656{
657 PyObject *_res = NULL;
658 LongRect destRect;
659 if (!PyArg_ParseTuple(_args, "O&",
660 LongRect_Convert, &destRect))
661 return NULL;
662 WESetDestRect(&destRect,
663 _self->ob_itself);
664 Py_INCREF(Py_None);
665 _res = Py_None;
666 return _res;
667}
668
669static PyObject *wasteObj_WESetViewRect(_self, _args)
670 wasteObject *_self;
671 PyObject *_args;
672{
673 PyObject *_res = NULL;
674 LongRect viewRect;
675 if (!PyArg_ParseTuple(_args, "O&",
676 LongRect_Convert, &viewRect))
677 return NULL;
678 WESetViewRect(&viewRect,
679 _self->ob_itself);
680 Py_INCREF(Py_None);
681 _res = Py_None;
682 return _res;
683}
684
685static PyObject *wasteObj_WEContinuousStyle(_self, _args)
686 wasteObject *_self;
687 PyObject *_args;
688{
689 PyObject *_res = NULL;
690 Boolean _rv;
691 WEStyleMode mode;
692 TextStyle ts;
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000693 if (!PyArg_ParseTuple(_args, "h",
694 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000695 return NULL;
696 _rv = WEContinuousStyle(&mode,
697 &ts,
698 _self->ob_itself);
699 _res = Py_BuildValue("bhO&",
700 _rv,
701 mode,
702 TextStyle_New, &ts);
703 return _res;
704}
705
706static PyObject *wasteObj_WEGetRunInfo(_self, _args)
707 wasteObject *_self;
708 PyObject *_args;
709{
710 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000711 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000712 WERunInfo runInfo;
713 if (!PyArg_ParseTuple(_args, "l",
714 &offset))
715 return NULL;
716 WEGetRunInfo(offset,
717 &runInfo,
718 _self->ob_itself);
719 _res = Py_BuildValue("O&",
720 RunInfo_New, &runInfo);
721 return _res;
722}
723
724static PyObject *wasteObj_WEGetOffset(_self, _args)
725 wasteObject *_self;
726 PyObject *_args;
727{
728 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000729 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000730 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000731 WEEdge edge;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000732 if (!PyArg_ParseTuple(_args, "O&",
733 LongPt_Convert, &thePoint))
734 return NULL;
735 _rv = WEGetOffset(&thePoint,
736 &edge,
737 _self->ob_itself);
Jack Jansen2268af51996-08-06 16:04:22 +0000738 _res = Py_BuildValue("lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000739 _rv,
740 edge);
741 return _res;
742}
743
744static PyObject *wasteObj_WEGetPoint(_self, _args)
745 wasteObject *_self;
746 PyObject *_args;
747{
748 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000749 SInt32 offset;
750 SInt16 direction;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000751 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000752 SInt16 lineHeight;
753 if (!PyArg_ParseTuple(_args, "lh",
754 &offset,
755 &direction))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000756 return NULL;
757 WEGetPoint(offset,
Jack Jansen2268af51996-08-06 16:04:22 +0000758 direction,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000759 &thePoint,
760 &lineHeight,
761 _self->ob_itself);
762 _res = Py_BuildValue("O&h",
763 LongPt_New, &thePoint,
764 lineHeight);
765 return _res;
766}
767
768static PyObject *wasteObj_WEFindWord(_self, _args)
769 wasteObject *_self;
770 PyObject *_args;
771{
772 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000773 SInt32 offset;
774 WEEdge edge;
775 SInt32 wordStart;
776 SInt32 wordEnd;
777 if (!PyArg_ParseTuple(_args, "lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000778 &offset,
779 &edge))
780 return NULL;
781 WEFindWord(offset,
782 edge,
783 &wordStart,
784 &wordEnd,
785 _self->ob_itself);
786 _res = Py_BuildValue("ll",
787 wordStart,
788 wordEnd);
789 return _res;
790}
791
792static PyObject *wasteObj_WEFindLine(_self, _args)
793 wasteObject *_self;
794 PyObject *_args;
795{
796 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000797 SInt32 offset;
798 WEEdge edge;
799 SInt32 lineStart;
800 SInt32 lineEnd;
801 if (!PyArg_ParseTuple(_args, "lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000802 &offset,
803 &edge))
804 return NULL;
805 WEFindLine(offset,
806 edge,
807 &lineStart,
808 &lineEnd,
809 _self->ob_itself);
810 _res = Py_BuildValue("ll",
811 lineStart,
812 lineEnd);
813 return _res;
814}
815
816static PyObject *wasteObj_WECopyRange(_self, _args)
817 wasteObject *_self;
818 PyObject *_args;
819{
820 PyObject *_res = NULL;
821 OSErr _err;
Jack Jansen2268af51996-08-06 16:04:22 +0000822 SInt32 rangeStart;
823 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000824 Handle hText;
825 StScrpHandle hStyles;
826 WESoupHandle hSoup;
827 if (!PyArg_ParseTuple(_args, "llO&O&O&",
828 &rangeStart,
829 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000830 OptResObj_Convert, &hText,
831 OptResObj_Convert, &hStyles,
832 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000833 return NULL;
834 _err = WECopyRange(rangeStart,
835 rangeEnd,
836 hText,
837 hStyles,
838 hSoup,
839 _self->ob_itself);
840 if (_err != noErr) return PyMac_Error(_err);
841 Py_INCREF(Py_None);
842 _res = Py_None;
843 return _res;
844}
845
846static PyObject *wasteObj_WEGetAlignment(_self, _args)
847 wasteObject *_self;
848 PyObject *_args;
849{
850 PyObject *_res = NULL;
851 WEAlignment _rv;
852 if (!PyArg_ParseTuple(_args, ""))
853 return NULL;
854 _rv = WEGetAlignment(_self->ob_itself);
855 _res = Py_BuildValue("b",
856 _rv);
857 return _res;
858}
859
860static PyObject *wasteObj_WESetAlignment(_self, _args)
861 wasteObject *_self;
862 PyObject *_args;
863{
864 PyObject *_res = NULL;
865 WEAlignment alignment;
866 if (!PyArg_ParseTuple(_args, "b",
867 &alignment))
868 return NULL;
869 WESetAlignment(alignment,
870 _self->ob_itself);
871 Py_INCREF(Py_None);
872 _res = Py_None;
873 return _res;
874}
875
876static PyObject *wasteObj_WECalText(_self, _args)
877 wasteObject *_self;
878 PyObject *_args;
879{
880 PyObject *_res = NULL;
881 OSErr _err;
882 if (!PyArg_ParseTuple(_args, ""))
883 return NULL;
884 _err = WECalText(_self->ob_itself);
885 if (_err != noErr) return PyMac_Error(_err);
886 Py_INCREF(Py_None);
887 _res = Py_None;
888 return _res;
889}
890
891static PyObject *wasteObj_WEUpdate(_self, _args)
892 wasteObject *_self;
893 PyObject *_args;
894{
895 PyObject *_res = NULL;
896 RgnHandle updateRgn;
897 if (!PyArg_ParseTuple(_args, "O&",
898 ResObj_Convert, &updateRgn))
899 return NULL;
900 WEUpdate(updateRgn,
901 _self->ob_itself);
902 Py_INCREF(Py_None);
903 _res = Py_None;
904 return _res;
905}
906
907static PyObject *wasteObj_WEScroll(_self, _args)
908 wasteObject *_self;
909 PyObject *_args;
910{
911 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000912 SInt32 hOffset;
913 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000914 if (!PyArg_ParseTuple(_args, "ll",
915 &hOffset,
916 &vOffset))
917 return NULL;
918 WEScroll(hOffset,
919 vOffset,
920 _self->ob_itself);
921 Py_INCREF(Py_None);
922 _res = Py_None;
923 return _res;
924}
925
926static PyObject *wasteObj_WESelView(_self, _args)
927 wasteObject *_self;
928 PyObject *_args;
929{
930 PyObject *_res = NULL;
931 if (!PyArg_ParseTuple(_args, ""))
932 return NULL;
933 WESelView(_self->ob_itself);
934 Py_INCREF(Py_None);
935 _res = Py_None;
936 return _res;
937}
938
939static PyObject *wasteObj_WEActivate(_self, _args)
940 wasteObject *_self;
941 PyObject *_args;
942{
943 PyObject *_res = NULL;
944 if (!PyArg_ParseTuple(_args, ""))
945 return NULL;
946 WEActivate(_self->ob_itself);
947 Py_INCREF(Py_None);
948 _res = Py_None;
949 return _res;
950}
951
952static PyObject *wasteObj_WEDeactivate(_self, _args)
953 wasteObject *_self;
954 PyObject *_args;
955{
956 PyObject *_res = NULL;
957 if (!PyArg_ParseTuple(_args, ""))
958 return NULL;
959 WEDeactivate(_self->ob_itself);
960 Py_INCREF(Py_None);
961 _res = Py_None;
962 return _res;
963}
964
965static PyObject *wasteObj_WEKey(_self, _args)
966 wasteObject *_self;
967 PyObject *_args;
968{
969 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000970 SInt16 key;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000971 EventModifiers modifiers;
972 if (!PyArg_ParseTuple(_args, "hh",
973 &key,
974 &modifiers))
975 return NULL;
976 WEKey(key,
977 modifiers,
978 _self->ob_itself);
979 Py_INCREF(Py_None);
980 _res = Py_None;
981 return _res;
982}
983
984static PyObject *wasteObj_WEClick(_self, _args)
985 wasteObject *_self;
986 PyObject *_args;
987{
988 PyObject *_res = NULL;
989 Point hitPt;
990 EventModifiers modifiers;
Jack Jansen2268af51996-08-06 16:04:22 +0000991 UInt32 clickTime;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000992 if (!PyArg_ParseTuple(_args, "O&hl",
993 PyMac_GetPoint, &hitPt,
994 &modifiers,
995 &clickTime))
996 return NULL;
997 WEClick(hitPt,
998 modifiers,
999 clickTime,
1000 _self->ob_itself);
1001 Py_INCREF(Py_None);
1002 _res = Py_None;
1003 return _res;
1004}
1005
1006static PyObject *wasteObj_WEAdjustCursor(_self, _args)
1007 wasteObject *_self;
1008 PyObject *_args;
1009{
1010 PyObject *_res = NULL;
1011 Boolean _rv;
1012 Point mouseLoc;
1013 RgnHandle mouseRgn;
1014 if (!PyArg_ParseTuple(_args, "O&O&",
1015 PyMac_GetPoint, &mouseLoc,
1016 ResObj_Convert, &mouseRgn))
1017 return NULL;
1018 _rv = WEAdjustCursor(mouseLoc,
1019 mouseRgn,
1020 _self->ob_itself);
1021 _res = Py_BuildValue("b",
1022 _rv);
1023 return _res;
1024}
1025
1026static PyObject *wasteObj_WEIdle(_self, _args)
1027 wasteObject *_self;
1028 PyObject *_args;
1029{
1030 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001031 UInt32 maxSleep;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001032 if (!PyArg_ParseTuple(_args, ""))
1033 return NULL;
1034 WEIdle(&maxSleep,
1035 _self->ob_itself);
1036 _res = Py_BuildValue("l",
1037 maxSleep);
1038 return _res;
1039}
1040
1041static PyObject *wasteObj_WEInsert(_self, _args)
1042 wasteObject *_self;
1043 PyObject *_args;
1044{
1045 PyObject *_res = NULL;
1046 OSErr _err;
1047 char *pText__in__;
1048 long pText__len__;
1049 int pText__in_len__;
1050 StScrpHandle hStyles;
1051 WESoupHandle hSoup;
1052 if (!PyArg_ParseTuple(_args, "s#O&O&",
1053 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001054 OptResObj_Convert, &hStyles,
1055 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001056 return NULL;
1057 pText__len__ = pText__in_len__;
1058 _err = WEInsert(pText__in__, pText__len__,
1059 hStyles,
1060 hSoup,
1061 _self->ob_itself);
1062 if (_err != noErr) return PyMac_Error(_err);
1063 Py_INCREF(Py_None);
1064 _res = Py_None;
1065 pText__error__: ;
1066 return _res;
1067}
1068
1069static PyObject *wasteObj_WEDelete(_self, _args)
1070 wasteObject *_self;
1071 PyObject *_args;
1072{
1073 PyObject *_res = NULL;
1074 OSErr _err;
1075 if (!PyArg_ParseTuple(_args, ""))
1076 return NULL;
1077 _err = WEDelete(_self->ob_itself);
1078 if (_err != noErr) return PyMac_Error(_err);
1079 Py_INCREF(Py_None);
1080 _res = Py_None;
1081 return _res;
1082}
1083
1084static PyObject *wasteObj_WESetStyle(_self, _args)
1085 wasteObject *_self;
1086 PyObject *_args;
1087{
1088 PyObject *_res = NULL;
1089 OSErr _err;
1090 WEStyleMode mode;
1091 TextStyle ts;
1092 if (!PyArg_ParseTuple(_args, "hO&",
1093 &mode,
1094 TextStyle_Convert, &ts))
1095 return NULL;
1096 _err = WESetStyle(mode,
1097 &ts,
1098 _self->ob_itself);
1099 if (_err != noErr) return PyMac_Error(_err);
1100 Py_INCREF(Py_None);
1101 _res = Py_None;
1102 return _res;
1103}
1104
1105static PyObject *wasteObj_WEUseStyleScrap(_self, _args)
1106 wasteObject *_self;
1107 PyObject *_args;
1108{
1109 PyObject *_res = NULL;
1110 OSErr _err;
1111 StScrpHandle hStyles;
1112 if (!PyArg_ParseTuple(_args, "O&",
1113 ResObj_Convert, &hStyles))
1114 return NULL;
1115 _err = WEUseStyleScrap(hStyles,
1116 _self->ob_itself);
1117 if (_err != noErr) return PyMac_Error(_err);
1118 Py_INCREF(Py_None);
1119 _res = Py_None;
1120 return _res;
1121}
1122
1123static PyObject *wasteObj_WEUseText(_self, _args)
1124 wasteObject *_self;
1125 PyObject *_args;
1126{
1127 PyObject *_res = NULL;
1128 OSErr _err;
1129 Handle hText;
1130 if (!PyArg_ParseTuple(_args, "O&",
1131 ResObj_Convert, &hText))
1132 return NULL;
1133 _err = WEUseText(hText,
1134 _self->ob_itself);
1135 if (_err != noErr) return PyMac_Error(_err);
1136 Py_INCREF(Py_None);
1137 _res = Py_None;
1138 return _res;
1139}
1140
1141static PyObject *wasteObj_WEUndo(_self, _args)
1142 wasteObject *_self;
1143 PyObject *_args;
1144{
1145 PyObject *_res = NULL;
1146 OSErr _err;
1147 if (!PyArg_ParseTuple(_args, ""))
1148 return NULL;
1149 _err = WEUndo(_self->ob_itself);
1150 if (_err != noErr) return PyMac_Error(_err);
1151 Py_INCREF(Py_None);
1152 _res = Py_None;
1153 return _res;
1154}
1155
1156static PyObject *wasteObj_WEClearUndo(_self, _args)
1157 wasteObject *_self;
1158 PyObject *_args;
1159{
1160 PyObject *_res = NULL;
1161 if (!PyArg_ParseTuple(_args, ""))
1162 return NULL;
1163 WEClearUndo(_self->ob_itself);
1164 Py_INCREF(Py_None);
1165 _res = Py_None;
1166 return _res;
1167}
1168
1169static PyObject *wasteObj_WEGetUndoInfo(_self, _args)
1170 wasteObject *_self;
1171 PyObject *_args;
1172{
1173 PyObject *_res = NULL;
1174 WEActionKind _rv;
1175 Boolean redoFlag;
1176 if (!PyArg_ParseTuple(_args, ""))
1177 return NULL;
1178 _rv = WEGetUndoInfo(&redoFlag,
1179 _self->ob_itself);
1180 _res = Py_BuildValue("hb",
1181 _rv,
1182 redoFlag);
1183 return _res;
1184}
1185
1186static PyObject *wasteObj_WEIsTyping(_self, _args)
1187 wasteObject *_self;
1188 PyObject *_args;
1189{
1190 PyObject *_res = NULL;
1191 Boolean _rv;
1192 if (!PyArg_ParseTuple(_args, ""))
1193 return NULL;
1194 _rv = WEIsTyping(_self->ob_itself);
1195 _res = Py_BuildValue("b",
1196 _rv);
1197 return _res;
1198}
1199
1200static PyObject *wasteObj_WEGetModCount(_self, _args)
1201 wasteObject *_self;
1202 PyObject *_args;
1203{
1204 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001205 UInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001206 if (!PyArg_ParseTuple(_args, ""))
1207 return NULL;
1208 _rv = WEGetModCount(_self->ob_itself);
1209 _res = Py_BuildValue("l",
1210 _rv);
1211 return _res;
1212}
1213
1214static PyObject *wasteObj_WEResetModCount(_self, _args)
1215 wasteObject *_self;
1216 PyObject *_args;
1217{
1218 PyObject *_res = NULL;
1219 if (!PyArg_ParseTuple(_args, ""))
1220 return NULL;
1221 WEResetModCount(_self->ob_itself);
1222 Py_INCREF(Py_None);
1223 _res = Py_None;
1224 return _res;
1225}
1226
1227static PyObject *wasteObj_WEInsertObject(_self, _args)
1228 wasteObject *_self;
1229 PyObject *_args;
1230{
1231 PyObject *_res = NULL;
1232 OSErr _err;
1233 FlavorType objectType;
1234 Handle objectDataHandle;
1235 Point objectSize;
1236 if (!PyArg_ParseTuple(_args, "O&O&O&",
1237 PyMac_GetOSType, &objectType,
1238 ResObj_Convert, &objectDataHandle,
1239 PyMac_GetPoint, &objectSize))
1240 return NULL;
1241 _err = WEInsertObject(objectType,
1242 objectDataHandle,
1243 objectSize,
1244 _self->ob_itself);
1245 if (_err != noErr) return PyMac_Error(_err);
1246 Py_INCREF(Py_None);
1247 _res = Py_None;
1248 return _res;
1249}
1250
1251static PyObject *wasteObj_WEGetSelectedObject(_self, _args)
1252 wasteObject *_self;
1253 PyObject *_args;
1254{
1255 PyObject *_res = NULL;
1256 OSErr _err;
1257 WEObjectReference obj;
1258 if (!PyArg_ParseTuple(_args, ""))
1259 return NULL;
1260 _err = WEGetSelectedObject(&obj,
1261 _self->ob_itself);
1262 if (_err != noErr) return PyMac_Error(_err);
1263 _res = Py_BuildValue("O&",
1264 WEOObj_New, obj);
1265 return _res;
1266}
1267
1268static PyObject *wasteObj_WEFindNextObject(_self, _args)
1269 wasteObject *_self;
1270 PyObject *_args;
1271{
1272 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001273 SInt32 _rv;
1274 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001275 WEObjectReference obj;
1276 if (!PyArg_ParseTuple(_args, "l",
1277 &offset))
1278 return NULL;
1279 _rv = WEFindNextObject(offset,
1280 &obj,
1281 _self->ob_itself);
1282 _res = Py_BuildValue("lO&",
1283 _rv,
1284 WEOObj_New, obj);
1285 return _res;
1286}
1287
1288static PyObject *wasteObj_WEUseSoup(_self, _args)
1289 wasteObject *_self;
1290 PyObject *_args;
1291{
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
1306static PyObject *wasteObj_WECut(_self, _args)
1307 wasteObject *_self;
1308 PyObject *_args;
1309{
1310 PyObject *_res = NULL;
1311 OSErr _err;
1312 if (!PyArg_ParseTuple(_args, ""))
1313 return NULL;
1314 _err = WECut(_self->ob_itself);
1315 if (_err != noErr) return PyMac_Error(_err);
1316 Py_INCREF(Py_None);
1317 _res = Py_None;
1318 return _res;
1319}
1320
1321static PyObject *wasteObj_WECopy(_self, _args)
1322 wasteObject *_self;
1323 PyObject *_args;
1324{
1325 PyObject *_res = NULL;
1326 OSErr _err;
1327 if (!PyArg_ParseTuple(_args, ""))
1328 return NULL;
1329 _err = WECopy(_self->ob_itself);
1330 if (_err != noErr) return PyMac_Error(_err);
1331 Py_INCREF(Py_None);
1332 _res = Py_None;
1333 return _res;
1334}
1335
1336static PyObject *wasteObj_WEPaste(_self, _args)
1337 wasteObject *_self;
1338 PyObject *_args;
1339{
1340 PyObject *_res = NULL;
1341 OSErr _err;
1342 if (!PyArg_ParseTuple(_args, ""))
1343 return NULL;
1344 _err = WEPaste(_self->ob_itself);
1345 if (_err != noErr) return PyMac_Error(_err);
1346 Py_INCREF(Py_None);
1347 _res = Py_None;
1348 return _res;
1349}
1350
1351static PyObject *wasteObj_WECanPaste(_self, _args)
1352 wasteObject *_self;
1353 PyObject *_args;
1354{
1355 PyObject *_res = NULL;
1356 Boolean _rv;
1357 if (!PyArg_ParseTuple(_args, ""))
1358 return NULL;
1359 _rv = WECanPaste(_self->ob_itself);
1360 _res = Py_BuildValue("b",
1361 _rv);
1362 return _res;
1363}
1364
1365static PyObject *wasteObj_WEGetHiliteRgn(_self, _args)
1366 wasteObject *_self;
1367 PyObject *_args;
1368{
1369 PyObject *_res = NULL;
1370 RgnHandle _rv;
Jack Jansen2268af51996-08-06 16:04:22 +00001371 SInt32 rangeStart;
1372 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001373 if (!PyArg_ParseTuple(_args, "ll",
1374 &rangeStart,
1375 &rangeEnd))
1376 return NULL;
1377 _rv = WEGetHiliteRgn(rangeStart,
1378 rangeEnd,
1379 _self->ob_itself);
1380 _res = Py_BuildValue("O&",
1381 ResObj_New, _rv);
1382 return _res;
1383}
1384
1385static PyObject *wasteObj_WECharByte(_self, _args)
1386 wasteObject *_self;
1387 PyObject *_args;
1388{
1389 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001390 SInt16 _rv;
1391 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001392 if (!PyArg_ParseTuple(_args, "l",
1393 &offset))
1394 return NULL;
1395 _rv = WECharByte(offset,
1396 _self->ob_itself);
1397 _res = Py_BuildValue("h",
1398 _rv);
1399 return _res;
1400}
1401
1402static PyObject *wasteObj_WECharType(_self, _args)
1403 wasteObject *_self;
1404 PyObject *_args;
1405{
1406 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001407 SInt16 _rv;
1408 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001409 if (!PyArg_ParseTuple(_args, "l",
1410 &offset))
1411 return NULL;
1412 _rv = WECharType(offset,
1413 _self->ob_itself);
1414 _res = Py_BuildValue("h",
1415 _rv);
1416 return _res;
1417}
1418
1419static PyObject *wasteObj_WEStopInlineSession(_self, _args)
1420 wasteObject *_self;
1421 PyObject *_args;
1422{
1423 PyObject *_res = NULL;
1424 if (!PyArg_ParseTuple(_args, ""))
1425 return NULL;
1426 WEStopInlineSession(_self->ob_itself);
1427 Py_INCREF(Py_None);
1428 _res = Py_None;
1429 return _res;
1430}
1431
1432static PyObject *wasteObj_WEFeatureFlag(_self, _args)
1433 wasteObject *_self;
1434 PyObject *_args;
1435{
1436 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001437 SInt16 _rv;
1438 SInt16 feature;
1439 SInt16 action;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001440 if (!PyArg_ParseTuple(_args, "hh",
1441 &feature,
1442 &action))
1443 return NULL;
1444 _rv = WEFeatureFlag(feature,
1445 action,
1446 _self->ob_itself);
1447 _res = Py_BuildValue("h",
1448 _rv);
1449 return _res;
1450}
1451
Jack Jansen176f3a91996-10-23 15:43:46 +00001452static PyObject *wasteObj_WEInstallTabHooks(_self, _args)
1453 wasteObject *_self;
1454 PyObject *_args;
1455{
1456 PyObject *_res = NULL;
1457 OSErr _err;
1458 if (!PyArg_ParseTuple(_args, ""))
1459 return NULL;
1460 _err = WEInstallTabHooks(_self->ob_itself);
1461 if (_err != noErr) return PyMac_Error(_err);
1462 Py_INCREF(Py_None);
1463 _res = Py_None;
1464 return _res;
1465}
1466
1467static PyObject *wasteObj_WERemoveTabHooks(_self, _args)
1468 wasteObject *_self;
1469 PyObject *_args;
1470{
1471 PyObject *_res = NULL;
1472 OSErr _err;
1473 if (!PyArg_ParseTuple(_args, ""))
1474 return NULL;
1475 _err = WERemoveTabHooks(_self->ob_itself);
1476 if (_err != noErr) return PyMac_Error(_err);
1477 Py_INCREF(Py_None);
1478 _res = Py_None;
1479 return _res;
1480}
1481
1482static PyObject *wasteObj_WEIsTabHooks(_self, _args)
1483 wasteObject *_self;
1484 PyObject *_args;
1485{
1486 PyObject *_res = NULL;
1487 Boolean _rv;
1488 if (!PyArg_ParseTuple(_args, ""))
1489 return NULL;
1490 _rv = WEIsTabHooks(_self->ob_itself);
1491 _res = Py_BuildValue("b",
1492 _rv);
1493 return _res;
1494}
1495
Jack Jansen90ecdf41996-04-16 14:29:15 +00001496static PyMethodDef wasteObj_methods[] = {
1497 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1498 "() -> (Handle _rv)"},
1499 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001500 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001501 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001502 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001503 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001504 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001505 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001506 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001507 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001508 "() -> (SInt32 selStart, SInt32 selEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001509 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1510 "() -> (LongRect destRect)"},
1511 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1512 "() -> (LongRect viewRect)"},
1513 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1514 "() -> (Boolean _rv)"},
1515 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001516 "(SInt32 offset) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001517 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001518 "(SInt32 lineNo) -> (SInt32 lineStart, SInt32 lineEnd)"},
1519 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1520 "() -> (UInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001521 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001522 "(SInt32 selStart, SInt32 selEnd) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001523 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1524 "(LongRect destRect) -> None"},
1525 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1526 "(LongRect viewRect) -> None"},
1527 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001528 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001529 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001530 "(SInt32 offset) -> (WERunInfo runInfo)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001531 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001532 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001533 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001534 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001535 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001536 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001537 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001538 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001539 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001540 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001541 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1542 "() -> (WEAlignment _rv)"},
1543 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1544 "(WEAlignment alignment) -> None"},
1545 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1546 "() -> None"},
1547 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1548 "(RgnHandle updateRgn) -> None"},
1549 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001550 "(SInt32 hOffset, SInt32 vOffset) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001551 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1552 "() -> None"},
1553 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1554 "() -> None"},
1555 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1556 "() -> None"},
1557 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001558 "(SInt16 key, EventModifiers modifiers) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001559 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001560 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001561 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1562 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1563 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001564 "() -> (UInt32 maxSleep)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001565 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1566 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1567 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1568 "() -> None"},
1569 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1570 "(WEStyleMode mode, TextStyle ts) -> None"},
1571 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1572 "(StScrpHandle hStyles) -> None"},
1573 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1574 "(Handle hText) -> None"},
1575 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1576 "() -> None"},
1577 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1578 "() -> None"},
1579 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1580 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1581 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1582 "() -> (Boolean _rv)"},
1583 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001584 "() -> (UInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001585 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1586 "() -> None"},
1587 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1588 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1589 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1590 "() -> (WEObjectReference obj)"},
1591 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001592 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001593 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1594 "(WESoupHandle hSoup) -> None"},
1595 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1596 "() -> None"},
1597 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1598 "() -> None"},
1599 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1600 "() -> None"},
1601 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1602 "() -> (Boolean _rv)"},
1603 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001604 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001605 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001606 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001607 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001608 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001609 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1610 "() -> None"},
1611 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001612 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
Jack Jansen176f3a91996-10-23 15:43:46 +00001613 {"WEInstallTabHooks", (PyCFunction)wasteObj_WEInstallTabHooks, 1,
1614 "() -> None"},
1615 {"WERemoveTabHooks", (PyCFunction)wasteObj_WERemoveTabHooks, 1,
1616 "() -> None"},
1617 {"WEIsTabHooks", (PyCFunction)wasteObj_WEIsTabHooks, 1,
1618 "() -> (Boolean _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001619 {NULL, NULL, 0}
1620};
1621
1622PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1623
1624static PyObject *wasteObj_getattr(self, name)
1625 wasteObject *self;
1626 char *name;
1627{
1628 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1629}
1630
1631#define wasteObj_setattr NULL
1632
1633PyTypeObject waste_Type = {
1634 PyObject_HEAD_INIT(&PyType_Type)
1635 0, /*ob_size*/
1636 "waste", /*tp_name*/
1637 sizeof(wasteObject), /*tp_basicsize*/
1638 0, /*tp_itemsize*/
1639 /* methods */
1640 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1641 0, /*tp_print*/
1642 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1643 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
1644};
1645
1646/* --------------------- End object type waste ---------------------- */
1647
1648
1649static PyObject *waste_WENew(_self, _args)
1650 PyObject *_self;
1651 PyObject *_args;
1652{
1653 PyObject *_res = NULL;
1654 OSErr _err;
1655 LongRect destRect;
1656 LongRect viewRect;
Jack Jansen2268af51996-08-06 16:04:22 +00001657 UInt32 flags;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001658 WEReference we;
1659 if (!PyArg_ParseTuple(_args, "O&O&l",
1660 LongRect_Convert, &destRect,
1661 LongRect_Convert, &viewRect,
1662 &flags))
1663 return NULL;
1664 _err = WENew(&destRect,
1665 &viewRect,
1666 flags,
1667 &we);
1668 if (_err != noErr) return PyMac_Error(_err);
1669 _res = Py_BuildValue("O&",
1670 wasteObj_New, we);
1671 return _res;
1672}
1673
1674static PyObject *waste_WEInstallTSMHandlers(_self, _args)
1675 PyObject *_self;
1676 PyObject *_args;
1677{
1678 PyObject *_res = NULL;
1679 OSErr _err;
1680 if (!PyArg_ParseTuple(_args, ""))
1681 return NULL;
1682 _err = WEInstallTSMHandlers();
1683 if (_err != noErr) return PyMac_Error(_err);
1684 Py_INCREF(Py_None);
1685 _res = Py_None;
1686 return _res;
1687}
1688
1689static PyObject *waste_WERemoveTSMHandlers(_self, _args)
1690 PyObject *_self;
1691 PyObject *_args;
1692{
1693 PyObject *_res = NULL;
1694 OSErr _err;
1695 if (!PyArg_ParseTuple(_args, ""))
1696 return NULL;
1697 _err = WERemoveTSMHandlers();
1698 if (_err != noErr) return PyMac_Error(_err);
1699 Py_INCREF(Py_None);
1700 _res = Py_None;
1701 return _res;
1702}
1703
1704static PyObject *waste_WELongPointToPoint(_self, _args)
1705 PyObject *_self;
1706 PyObject *_args;
1707{
1708 PyObject *_res = NULL;
1709 LongPt lp;
1710 Point p;
1711 if (!PyArg_ParseTuple(_args, "O&",
1712 LongPt_Convert, &lp))
1713 return NULL;
1714 WELongPointToPoint(&lp,
1715 &p);
1716 _res = Py_BuildValue("O&",
1717 PyMac_BuildPoint, p);
1718 return _res;
1719}
1720
1721static PyObject *waste_WEPointToLongPoint(_self, _args)
1722 PyObject *_self;
1723 PyObject *_args;
1724{
1725 PyObject *_res = NULL;
1726 Point p;
1727 LongPt lp;
1728 if (!PyArg_ParseTuple(_args, "O&",
1729 PyMac_GetPoint, &p))
1730 return NULL;
1731 WEPointToLongPoint(p,
1732 &lp);
1733 _res = Py_BuildValue("O&",
1734 LongPt_New, &lp);
1735 return _res;
1736}
1737
1738static PyObject *waste_WESetLongRect(_self, _args)
1739 PyObject *_self;
1740 PyObject *_args;
1741{
1742 PyObject *_res = NULL;
1743 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001744 SInt32 left;
1745 SInt32 top;
1746 SInt32 right;
1747 SInt32 bottom;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001748 if (!PyArg_ParseTuple(_args, "llll",
1749 &left,
1750 &top,
1751 &right,
1752 &bottom))
1753 return NULL;
1754 WESetLongRect(&lr,
1755 left,
1756 top,
1757 right,
1758 bottom);
1759 _res = Py_BuildValue("O&",
1760 LongRect_New, &lr);
1761 return _res;
1762}
1763
1764static PyObject *waste_WELongRectToRect(_self, _args)
1765 PyObject *_self;
1766 PyObject *_args;
1767{
1768 PyObject *_res = NULL;
1769 LongRect lr;
1770 Rect r;
1771 if (!PyArg_ParseTuple(_args, "O&",
1772 LongRect_Convert, &lr))
1773 return NULL;
1774 WELongRectToRect(&lr,
1775 &r);
1776 _res = Py_BuildValue("O&",
1777 PyMac_BuildRect, &r);
1778 return _res;
1779}
1780
1781static PyObject *waste_WERectToLongRect(_self, _args)
1782 PyObject *_self;
1783 PyObject *_args;
1784{
1785 PyObject *_res = NULL;
1786 Rect r;
1787 LongRect lr;
1788 if (!PyArg_ParseTuple(_args, "O&",
1789 PyMac_GetRect, &r))
1790 return NULL;
1791 WERectToLongRect(&r,
1792 &lr);
1793 _res = Py_BuildValue("O&",
1794 LongRect_New, &lr);
1795 return _res;
1796}
1797
1798static PyObject *waste_WEOffsetLongRect(_self, _args)
1799 PyObject *_self;
1800 PyObject *_args;
1801{
1802 PyObject *_res = NULL;
1803 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001804 SInt32 hOffset;
1805 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001806 if (!PyArg_ParseTuple(_args, "ll",
1807 &hOffset,
1808 &vOffset))
1809 return NULL;
1810 WEOffsetLongRect(&lr,
1811 hOffset,
1812 vOffset);
1813 _res = Py_BuildValue("O&",
1814 LongRect_New, &lr);
1815 return _res;
1816}
1817
1818static PyObject *waste_WELongPointInLongRect(_self, _args)
1819 PyObject *_self;
1820 PyObject *_args;
1821{
1822 PyObject *_res = NULL;
1823 Boolean _rv;
1824 LongPt lp;
1825 LongRect lr;
1826 if (!PyArg_ParseTuple(_args, "O&O&",
1827 LongPt_Convert, &lp,
1828 LongRect_Convert, &lr))
1829 return NULL;
1830 _rv = WELongPointInLongRect(&lp,
1831 &lr);
1832 _res = Py_BuildValue("b",
1833 _rv);
1834 return _res;
1835}
1836
Jack Jansen756522f1996-05-07 15:24:01 +00001837static PyObject *waste_STDObjectHandlers(_self, _args)
1838 PyObject *_self;
1839 PyObject *_args;
1840{
1841 PyObject *_res = NULL;
1842
1843 OSErr err;
1844 // install the sample object handlers for pictures and sounds
1845#define kTypePicture 'PICT'
1846#define kTypeSound 'snd '
1847
1848 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
1849
1850 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
1851 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
1852 goto cleanup;
1853
1854 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
1855 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
1856 goto cleanup;
1857
1858 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
1859 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
1860 goto cleanup;
1861
1862 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
1863 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
1864 goto cleanup;
1865
1866 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
1867 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
1868 goto cleanup;
1869
1870 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
1871 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
1872 goto cleanup;
1873 Py_INCREF(Py_None);
1874 return Py_None;
1875
1876 cleanup:
1877 return PyMac_Error(err);
1878
1879}
1880
1881static PyObject *waste_WEInstallObjectHandler(_self, _args)
1882 PyObject *_self;
1883 PyObject *_args;
1884{
1885 PyObject *_res = NULL;
1886
1887 OSErr err;
1888 FlavorType objectType;
1889 WESelector selector;
1890 PyObject *py_handler;
1891 UniversalProcPtr handler;
1892 WEReference we = NULL;
1893 PyObject *key;
1894
1895
1896 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
1897 PyMac_GetOSType, &objectType,
1898 PyMac_GetOSType, &selector,
1899 &py_handler,
Jack Jansen7df36061996-10-01 11:41:14 +00001900 WEOObj_Convert, &we) ) return NULL;
Jack Jansen756522f1996-05-07 15:24:01 +00001901
Jack Jansen25241d91996-05-20 11:30:45 +00001902 if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
1903 else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
1904 else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
1905 else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +00001906 else return PyMac_Error(weUndefinedSelectorErr);
1907
1908 if ((key = Py_BuildValue("O&O&",
1909 PyMac_BuildOSType, objectType,
1910 PyMac_BuildOSType, selector)) == NULL )
1911 return NULL;
1912
1913 PyDict_SetItem(callbackdict, key, py_handler);
1914
1915 err = WEInstallObjectHandler(objectType, selector, handler, we);
1916 if ( err ) return PyMac_Error(err);
1917 Py_INCREF(Py_None);
1918 return Py_None;
1919
1920}
1921
Jack Jansen90ecdf41996-04-16 14:29:15 +00001922static PyMethodDef waste_methods[] = {
1923 {"WENew", (PyCFunction)waste_WENew, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001924 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001925 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
1926 "() -> None"},
1927 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
1928 "() -> None"},
1929 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
1930 "(LongPt lp) -> (Point p)"},
1931 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
1932 "(Point p) -> (LongPt lp)"},
1933 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001934 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001935 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
1936 "(LongRect lr) -> (Rect r)"},
1937 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
1938 "(Rect r) -> (LongRect lr)"},
1939 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001940 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001941 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
1942 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00001943 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
1944 NULL},
1945 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
1946 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001947 {NULL, NULL, 0}
1948};
1949
1950
1951
Jack Jansen756522f1996-05-07 15:24:01 +00001952/* Return the object corresponding to the window, or NULL */
1953
1954PyObject *
1955ExistingwasteObj_New(w)
1956 WEReference w;
1957{
1958 PyObject *it = NULL;
1959
1960 if (w == NULL)
1961 it = NULL;
1962 else
1963 WEGetInfo(weRefCon, (void *)&it, w);
1964 if (it == NULL || ((wasteObject *)it)->ob_itself != w)
1965 it = Py_None;
1966 Py_INCREF(it);
1967 return it;
1968}
1969
Jack Jansen90ecdf41996-04-16 14:29:15 +00001970
1971void initwaste()
1972{
1973 PyObject *m;
1974 PyObject *d;
1975
1976
1977
1978
1979 m = Py_InitModule("waste", waste_methods);
1980 d = PyModule_GetDict(m);
1981 waste_Error = PyMac_GetOSErrException();
1982 if (waste_Error == NULL ||
1983 PyDict_SetItemString(d, "Error", waste_Error) != 0)
1984 Py_FatalError("can't initialize waste.Error");
Jack Jansen756522f1996-05-07 15:24:01 +00001985
1986 callbackdict = PyDict_New();
1987 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
1988 Py_FatalError("can't initialize Waste.callbackdict");
1989 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00001990 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
1991 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
1992 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00001993
1994
Jack Jansen90ecdf41996-04-16 14:29:15 +00001995}
1996
1997/* ======================== End module waste ======================== */
1998