blob: 99e5675226e0c809a840db5c46426c2b7b4212f7 [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 Jansen90ecdf41996-04-16 14:29:15 +000047
48/* Exported by Qdmodule.c: */
49extern PyObject *QdRGB_New(RGBColor *);
50extern int QdRGB_Convert(PyObject *, RGBColor *);
51
52/* Forward declaration */
53staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000054staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000055
56/*
57** Parse/generate TextStyle records
58*/
59static
60PyObject *TextStyle_New(itself)
61 TextStylePtr itself;
62{
63
64 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
65 &itself->tsColor);
66}
67
68static
69TextStyle_Convert(v, p_itself)
70 PyObject *v;
71 TextStylePtr p_itself;
72{
73 long font, face, size;
74
75 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
76 return 0;
77 p_itself->tsFont = (short)font;
78 p_itself->tsFace = (Style)face;
79 p_itself->tsSize = (short)size;
80 return 1;
81}
82
83/*
84** Parse/generate RunInfo records
85*/
86static
87PyObject *RunInfo_New(itself)
88 WERunInfo *itself;
89{
90
91 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
92 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
93}
94
95/* Conversion of long points and rects */
96int
97LongRect_Convert(PyObject *v, LongRect *r)
98{
99 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
100}
101
102PyObject *
103LongRect_New(LongRect *r)
104{
105 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
106}
107
108
109LongPt_Convert(PyObject *v, LongPt *p)
110{
111 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
112}
113
114PyObject *
115LongPt_New(LongPt *p)
116{
117 return Py_BuildValue("(ll)", p->h, p->v);
118}
119
Jack Jansen756522f1996-05-07 15:24:01 +0000120/* Stuff for the callbacks: */
121static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +0000122WENewObjectUPP upp_new_handler;
123WEDisposeObjectUPP upp_dispose_handler;
124WEDrawObjectUPP upp_draw_handler;
125WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +0000126
127static OSErr
128any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
129{
130 FlavorType tp;
131 PyObject *key, *func;
132
133 if ( args == NULL ) return errAECorruptData;
134
135 tp = WEGetObjectType(who);
136
137 if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
138 return errAECorruptData;
139 if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
140 Py_DECREF(key);
141 return errAEHandlerNotFound;
142 }
143 Py_INCREF(func);
144 *rv = PyEval_CallObject(func, args);
145 Py_DECREF(func);
146 Py_DECREF(key);
147 if ( *rv == NULL ) {
148 fprintf(stderr, "--Exception in callback: ");
149 PyErr_Print();
150 return errAEReplyNotArrived;
151 }
152 return 0;
153}
154
155static pascal OSErr
156my_new_handler(Point *objectSize, WEObjectReference objref)
157{
158 PyObject *args=NULL, *rv=NULL;
159 OSErr err;
160
161 args=Py_BuildValue("(O&)", WEOObj_New, objref);
162 err = any_handler(weNewHandler, objref, args, &rv);
163 if (!err) {
164 if (!PyMac_GetPoint(rv, objectSize) )
165 err = errAECoercionFail;
166 }
167 if ( args ) Py_DECREF(args);
168 if ( rv ) Py_DECREF(rv);
169 return err;
170}
171
172static pascal OSErr
173my_dispose_handler(WEObjectReference objref)
174{
175 PyObject *args=NULL, *rv=NULL;
176 OSErr err;
177
178 args=Py_BuildValue("(O&)", WEOObj_New, objref);
179 err = any_handler(weDisposeHandler, objref, args, &rv);
180 if ( args ) Py_DECREF(args);
181 if ( rv ) Py_DECREF(rv);
182 return err;
183}
184
185static pascal OSErr
186my_draw_handler(Rect *destRect, WEObjectReference objref)
187{
188 PyObject *args=NULL, *rv=NULL;
189 OSErr err;
190
191 args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
192 err = any_handler(weDrawHandler, objref, args, &rv);
193 if ( args ) Py_DECREF(args);
194 if ( rv ) Py_DECREF(rv);
195 return err;
196}
197
198static pascal Boolean
199my_click_handler(Point hitPt, EventModifiers modifiers,
200 unsigned long clickTime, WEObjectReference objref)
201{
202 PyObject *args=NULL, *rv=NULL;
203 int retvalue;
204 OSErr err;
205
206 args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
207 (long)modifiers, (long)clickTime, WEOObj_New, objref);
208 err = any_handler(weClickHandler, objref, args, &rv);
209 if (!err)
210 retvalue = PyInt_AsLong(rv);
211 else
212 retvalue = 0;
213 if ( args ) Py_DECREF(args);
214 if ( rv ) Py_DECREF(rv);
215 return retvalue;
216}
217
218
219
Jack Jansen90ecdf41996-04-16 14:29:15 +0000220static PyObject *waste_Error;
221
222/* ------------------------ Object type WEO ------------------------- */
223
224PyTypeObject WEO_Type;
225
226#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
227
228typedef struct WEOObject {
229 PyObject_HEAD
230 WEObjectReference ob_itself;
231} WEOObject;
232
233PyObject *WEOObj_New(itself)
234 WEObjectReference itself;
235{
236 WEOObject *it;
237 if (itself == NULL) {
238 Py_INCREF(Py_None);
239 return Py_None;
240 }
241 it = PyObject_NEW(WEOObject, &WEO_Type);
242 if (it == NULL) return NULL;
243 it->ob_itself = itself;
244 return (PyObject *)it;
245}
246WEOObj_Convert(v, p_itself)
247 PyObject *v;
248 WEObjectReference *p_itself;
249{
250 if (!WEOObj_Check(v))
251 {
252 PyErr_SetString(PyExc_TypeError, "WEO required");
253 return 0;
254 }
255 *p_itself = ((WEOObject *)v)->ob_itself;
256 return 1;
257}
258
259static void WEOObj_dealloc(self)
260 WEOObject *self;
261{
262 /* Cleanup of self->ob_itself goes here */
263 PyMem_DEL(self);
264}
265
266static PyObject *WEOObj_WEGetObjectType(_self, _args)
267 WEOObject *_self;
268 PyObject *_args;
269{
270 PyObject *_res = NULL;
271 FlavorType _rv;
272 if (!PyArg_ParseTuple(_args, ""))
273 return NULL;
274 _rv = WEGetObjectType(_self->ob_itself);
275 _res = Py_BuildValue("O&",
276 PyMac_BuildOSType, _rv);
277 return _res;
278}
279
280static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args)
281 WEOObject *_self;
282 PyObject *_args;
283{
284 PyObject *_res = NULL;
285 Handle _rv;
286 if (!PyArg_ParseTuple(_args, ""))
287 return NULL;
288 _rv = WEGetObjectDataHandle(_self->ob_itself);
289 _res = Py_BuildValue("O&",
290 ResObj_New, _rv);
291 return _res;
292}
293
294static PyObject *WEOObj_WEGetObjectSize(_self, _args)
295 WEOObject *_self;
296 PyObject *_args;
297{
298 PyObject *_res = NULL;
299 Point _rv;
300 if (!PyArg_ParseTuple(_args, ""))
301 return NULL;
302 _rv = WEGetObjectSize(_self->ob_itself);
303 _res = Py_BuildValue("O&",
304 PyMac_BuildPoint, _rv);
305 return _res;
306}
307
Jack Jansen756522f1996-05-07 15:24:01 +0000308static PyObject *WEOObj_WEGetObjectOwner(_self, _args)
309 WEOObject *_self;
310 PyObject *_args;
311{
312 PyObject *_res = NULL;
313 WEReference _rv;
314 if (!PyArg_ParseTuple(_args, ""))
315 return NULL;
316 _rv = WEGetObjectOwner(_self->ob_itself);
317 _res = Py_BuildValue("O&",
318 ExistingwasteObj_New, _rv);
319 return _res;
320}
321
Jack Jansen90ecdf41996-04-16 14:29:15 +0000322static PyObject *WEOObj_WEGetObjectRefCon(_self, _args)
323 WEOObject *_self;
324 PyObject *_args;
325{
326 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000327 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000328 if (!PyArg_ParseTuple(_args, ""))
329 return NULL;
330 _rv = WEGetObjectRefCon(_self->ob_itself);
331 _res = Py_BuildValue("l",
332 _rv);
333 return _res;
334}
335
336static PyObject *WEOObj_WESetObjectRefCon(_self, _args)
337 WEOObject *_self;
338 PyObject *_args;
339{
340 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000341 SInt32 refCon;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000342 if (!PyArg_ParseTuple(_args, "l",
343 &refCon))
344 return NULL;
345 WESetObjectRefCon(_self->ob_itself,
346 refCon);
347 Py_INCREF(Py_None);
348 _res = Py_None;
349 return _res;
350}
351
352static PyMethodDef WEOObj_methods[] = {
353 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
354 "() -> (FlavorType _rv)"},
355 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
356 "() -> (Handle _rv)"},
357 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
358 "() -> (Point _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +0000359 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
360 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000361 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000362 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000363 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000364 "(SInt32 refCon) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000365 {NULL, NULL, 0}
366};
367
368PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
369
370static PyObject *WEOObj_getattr(self, name)
371 WEOObject *self;
372 char *name;
373{
374 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
375}
376
377#define WEOObj_setattr NULL
378
379PyTypeObject WEO_Type = {
380 PyObject_HEAD_INIT(&PyType_Type)
381 0, /*ob_size*/
382 "WEO", /*tp_name*/
383 sizeof(WEOObject), /*tp_basicsize*/
384 0, /*tp_itemsize*/
385 /* methods */
386 (destructor) WEOObj_dealloc, /*tp_dealloc*/
387 0, /*tp_print*/
388 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
389 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
390};
391
392/* ---------------------- End object type WEO ----------------------- */
393
394
395/* ----------------------- Object type waste ------------------------ */
396
397PyTypeObject waste_Type;
398
399#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
400
401typedef struct wasteObject {
402 PyObject_HEAD
403 WEReference ob_itself;
404} wasteObject;
405
406PyObject *wasteObj_New(itself)
407 WEReference itself;
408{
409 wasteObject *it;
410 if (itself == NULL) {
411 PyErr_SetString(waste_Error,"Cannot create null WE");
412 return NULL;
413 }
414 it = PyObject_NEW(wasteObject, &waste_Type);
415 if (it == NULL) return NULL;
416 it->ob_itself = itself;
Jack Jansen756522f1996-05-07 15:24:01 +0000417 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000418 return (PyObject *)it;
419}
420wasteObj_Convert(v, p_itself)
421 PyObject *v;
422 WEReference *p_itself;
423{
424 if (!wasteObj_Check(v))
425 {
426 PyErr_SetString(PyExc_TypeError, "waste required");
427 return 0;
428 }
429 *p_itself = ((wasteObject *)v)->ob_itself;
430 return 1;
431}
432
433static void wasteObj_dealloc(self)
434 wasteObject *self;
435{
436 WEDispose(self->ob_itself);
437 PyMem_DEL(self);
438}
439
440static PyObject *wasteObj_WEGetText(_self, _args)
441 wasteObject *_self;
442 PyObject *_args;
443{
444 PyObject *_res = NULL;
445 Handle _rv;
446 if (!PyArg_ParseTuple(_args, ""))
447 return NULL;
448 _rv = WEGetText(_self->ob_itself);
449 _res = Py_BuildValue("O&",
450 ResObj_New, _rv);
451 return _res;
452}
453
454static PyObject *wasteObj_WEGetChar(_self, _args)
455 wasteObject *_self;
456 PyObject *_args;
457{
458 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000459 SInt16 _rv;
460 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000461 if (!PyArg_ParseTuple(_args, "l",
462 &offset))
463 return NULL;
464 _rv = WEGetChar(offset,
465 _self->ob_itself);
466 _res = Py_BuildValue("h",
467 _rv);
468 return _res;
469}
470
471static PyObject *wasteObj_WEGetTextLength(_self, _args)
472 wasteObject *_self;
473 PyObject *_args;
474{
475 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000476 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000477 if (!PyArg_ParseTuple(_args, ""))
478 return NULL;
479 _rv = WEGetTextLength(_self->ob_itself);
480 _res = Py_BuildValue("l",
481 _rv);
482 return _res;
483}
484
485static PyObject *wasteObj_WECountLines(_self, _args)
486 wasteObject *_self;
487 PyObject *_args;
488{
489 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000490 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000491 if (!PyArg_ParseTuple(_args, ""))
492 return NULL;
493 _rv = WECountLines(_self->ob_itself);
494 _res = Py_BuildValue("l",
495 _rv);
496 return _res;
497}
498
499static PyObject *wasteObj_WEGetHeight(_self, _args)
500 wasteObject *_self;
501 PyObject *_args;
502{
503 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000504 SInt32 _rv;
505 SInt32 startLine;
506 SInt32 endLine;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000507 if (!PyArg_ParseTuple(_args, "ll",
508 &startLine,
509 &endLine))
510 return NULL;
511 _rv = WEGetHeight(startLine,
512 endLine,
513 _self->ob_itself);
514 _res = Py_BuildValue("l",
515 _rv);
516 return _res;
517}
518
519static PyObject *wasteObj_WEGetSelection(_self, _args)
520 wasteObject *_self;
521 PyObject *_args;
522{
523 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000524 SInt32 selStart;
525 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000526 if (!PyArg_ParseTuple(_args, ""))
527 return NULL;
528 WEGetSelection(&selStart,
529 &selEnd,
530 _self->ob_itself);
531 _res = Py_BuildValue("ll",
532 selStart,
533 selEnd);
534 return _res;
535}
536
537static PyObject *wasteObj_WEGetDestRect(_self, _args)
538 wasteObject *_self;
539 PyObject *_args;
540{
541 PyObject *_res = NULL;
542 LongRect destRect;
543 if (!PyArg_ParseTuple(_args, ""))
544 return NULL;
545 WEGetDestRect(&destRect,
546 _self->ob_itself);
547 _res = Py_BuildValue("O&",
548 LongRect_New, &destRect);
549 return _res;
550}
551
552static PyObject *wasteObj_WEGetViewRect(_self, _args)
553 wasteObject *_self;
554 PyObject *_args;
555{
556 PyObject *_res = NULL;
557 LongRect viewRect;
558 if (!PyArg_ParseTuple(_args, ""))
559 return NULL;
560 WEGetViewRect(&viewRect,
561 _self->ob_itself);
562 _res = Py_BuildValue("O&",
563 LongRect_New, &viewRect);
564 return _res;
565}
566
567static PyObject *wasteObj_WEIsActive(_self, _args)
568 wasteObject *_self;
569 PyObject *_args;
570{
571 PyObject *_res = NULL;
572 Boolean _rv;
573 if (!PyArg_ParseTuple(_args, ""))
574 return NULL;
575 _rv = WEIsActive(_self->ob_itself);
576 _res = Py_BuildValue("b",
577 _rv);
578 return _res;
579}
580
581static PyObject *wasteObj_WEOffsetToLine(_self, _args)
582 wasteObject *_self;
583 PyObject *_args;
584{
585 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000586 SInt32 _rv;
587 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000588 if (!PyArg_ParseTuple(_args, "l",
589 &offset))
590 return NULL;
591 _rv = WEOffsetToLine(offset,
592 _self->ob_itself);
593 _res = Py_BuildValue("l",
594 _rv);
595 return _res;
596}
597
598static PyObject *wasteObj_WEGetLineRange(_self, _args)
599 wasteObject *_self;
600 PyObject *_args;
601{
602 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000603 SInt32 lineNo;
604 SInt32 lineStart;
605 SInt32 lineEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000606 if (!PyArg_ParseTuple(_args, "l",
607 &lineNo))
608 return NULL;
609 WEGetLineRange(lineNo,
610 &lineStart,
611 &lineEnd,
612 _self->ob_itself);
613 _res = Py_BuildValue("ll",
614 lineStart,
615 lineEnd);
616 return _res;
617}
618
Jack Jansen2268af51996-08-06 16:04:22 +0000619static PyObject *wasteObj_WEGetClickCount(_self, _args)
620 wasteObject *_self;
621 PyObject *_args;
622{
623 PyObject *_res = NULL;
624 UInt16 _rv;
625 if (!PyArg_ParseTuple(_args, ""))
626 return NULL;
627 _rv = WEGetClickCount(_self->ob_itself);
628 _res = Py_BuildValue("h",
629 _rv);
630 return _res;
631}
632
Jack Jansen90ecdf41996-04-16 14:29:15 +0000633static PyObject *wasteObj_WESetSelection(_self, _args)
634 wasteObject *_self;
635 PyObject *_args;
636{
637 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000638 SInt32 selStart;
639 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000640 if (!PyArg_ParseTuple(_args, "ll",
641 &selStart,
642 &selEnd))
643 return NULL;
644 WESetSelection(selStart,
645 selEnd,
646 _self->ob_itself);
647 Py_INCREF(Py_None);
648 _res = Py_None;
649 return _res;
650}
651
652static PyObject *wasteObj_WESetDestRect(_self, _args)
653 wasteObject *_self;
654 PyObject *_args;
655{
656 PyObject *_res = NULL;
657 LongRect destRect;
658 if (!PyArg_ParseTuple(_args, "O&",
659 LongRect_Convert, &destRect))
660 return NULL;
661 WESetDestRect(&destRect,
662 _self->ob_itself);
663 Py_INCREF(Py_None);
664 _res = Py_None;
665 return _res;
666}
667
668static PyObject *wasteObj_WESetViewRect(_self, _args)
669 wasteObject *_self;
670 PyObject *_args;
671{
672 PyObject *_res = NULL;
673 LongRect viewRect;
674 if (!PyArg_ParseTuple(_args, "O&",
675 LongRect_Convert, &viewRect))
676 return NULL;
677 WESetViewRect(&viewRect,
678 _self->ob_itself);
679 Py_INCREF(Py_None);
680 _res = Py_None;
681 return _res;
682}
683
684static PyObject *wasteObj_WEContinuousStyle(_self, _args)
685 wasteObject *_self;
686 PyObject *_args;
687{
688 PyObject *_res = NULL;
689 Boolean _rv;
690 WEStyleMode mode;
691 TextStyle ts;
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000692 if (!PyArg_ParseTuple(_args, "h",
693 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000694 return NULL;
695 _rv = WEContinuousStyle(&mode,
696 &ts,
697 _self->ob_itself);
698 _res = Py_BuildValue("bhO&",
699 _rv,
700 mode,
701 TextStyle_New, &ts);
702 return _res;
703}
704
705static PyObject *wasteObj_WEGetRunInfo(_self, _args)
706 wasteObject *_self;
707 PyObject *_args;
708{
709 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000710 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000711 WERunInfo runInfo;
712 if (!PyArg_ParseTuple(_args, "l",
713 &offset))
714 return NULL;
715 WEGetRunInfo(offset,
716 &runInfo,
717 _self->ob_itself);
718 _res = Py_BuildValue("O&",
719 RunInfo_New, &runInfo);
720 return _res;
721}
722
723static PyObject *wasteObj_WEGetOffset(_self, _args)
724 wasteObject *_self;
725 PyObject *_args;
726{
727 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000728 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000729 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000730 WEEdge edge;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000731 if (!PyArg_ParseTuple(_args, "O&",
732 LongPt_Convert, &thePoint))
733 return NULL;
734 _rv = WEGetOffset(&thePoint,
735 &edge,
736 _self->ob_itself);
Jack Jansen2268af51996-08-06 16:04:22 +0000737 _res = Py_BuildValue("lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000738 _rv,
739 edge);
740 return _res;
741}
742
743static PyObject *wasteObj_WEGetPoint(_self, _args)
744 wasteObject *_self;
745 PyObject *_args;
746{
747 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000748 SInt32 offset;
749 SInt16 direction;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000750 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000751 SInt16 lineHeight;
752 if (!PyArg_ParseTuple(_args, "lh",
753 &offset,
754 &direction))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000755 return NULL;
756 WEGetPoint(offset,
Jack Jansen2268af51996-08-06 16:04:22 +0000757 direction,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000758 &thePoint,
759 &lineHeight,
760 _self->ob_itself);
761 _res = Py_BuildValue("O&h",
762 LongPt_New, &thePoint,
763 lineHeight);
764 return _res;
765}
766
767static PyObject *wasteObj_WEFindWord(_self, _args)
768 wasteObject *_self;
769 PyObject *_args;
770{
771 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000772 SInt32 offset;
773 WEEdge edge;
774 SInt32 wordStart;
775 SInt32 wordEnd;
776 if (!PyArg_ParseTuple(_args, "lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000777 &offset,
778 &edge))
779 return NULL;
780 WEFindWord(offset,
781 edge,
782 &wordStart,
783 &wordEnd,
784 _self->ob_itself);
785 _res = Py_BuildValue("ll",
786 wordStart,
787 wordEnd);
788 return _res;
789}
790
791static PyObject *wasteObj_WEFindLine(_self, _args)
792 wasteObject *_self;
793 PyObject *_args;
794{
795 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000796 SInt32 offset;
797 WEEdge edge;
798 SInt32 lineStart;
799 SInt32 lineEnd;
800 if (!PyArg_ParseTuple(_args, "lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000801 &offset,
802 &edge))
803 return NULL;
804 WEFindLine(offset,
805 edge,
806 &lineStart,
807 &lineEnd,
808 _self->ob_itself);
809 _res = Py_BuildValue("ll",
810 lineStart,
811 lineEnd);
812 return _res;
813}
814
815static PyObject *wasteObj_WECopyRange(_self, _args)
816 wasteObject *_self;
817 PyObject *_args;
818{
819 PyObject *_res = NULL;
820 OSErr _err;
Jack Jansen2268af51996-08-06 16:04:22 +0000821 SInt32 rangeStart;
822 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000823 Handle hText;
824 StScrpHandle hStyles;
825 WESoupHandle hSoup;
826 if (!PyArg_ParseTuple(_args, "llO&O&O&",
827 &rangeStart,
828 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000829 OptResObj_Convert, &hText,
830 OptResObj_Convert, &hStyles,
831 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000832 return NULL;
833 _err = WECopyRange(rangeStart,
834 rangeEnd,
835 hText,
836 hStyles,
837 hSoup,
838 _self->ob_itself);
839 if (_err != noErr) return PyMac_Error(_err);
840 Py_INCREF(Py_None);
841 _res = Py_None;
842 return _res;
843}
844
845static PyObject *wasteObj_WEGetAlignment(_self, _args)
846 wasteObject *_self;
847 PyObject *_args;
848{
849 PyObject *_res = NULL;
850 WEAlignment _rv;
851 if (!PyArg_ParseTuple(_args, ""))
852 return NULL;
853 _rv = WEGetAlignment(_self->ob_itself);
854 _res = Py_BuildValue("b",
855 _rv);
856 return _res;
857}
858
859static PyObject *wasteObj_WESetAlignment(_self, _args)
860 wasteObject *_self;
861 PyObject *_args;
862{
863 PyObject *_res = NULL;
864 WEAlignment alignment;
865 if (!PyArg_ParseTuple(_args, "b",
866 &alignment))
867 return NULL;
868 WESetAlignment(alignment,
869 _self->ob_itself);
870 Py_INCREF(Py_None);
871 _res = Py_None;
872 return _res;
873}
874
875static PyObject *wasteObj_WECalText(_self, _args)
876 wasteObject *_self;
877 PyObject *_args;
878{
879 PyObject *_res = NULL;
880 OSErr _err;
881 if (!PyArg_ParseTuple(_args, ""))
882 return NULL;
883 _err = WECalText(_self->ob_itself);
884 if (_err != noErr) return PyMac_Error(_err);
885 Py_INCREF(Py_None);
886 _res = Py_None;
887 return _res;
888}
889
890static PyObject *wasteObj_WEUpdate(_self, _args)
891 wasteObject *_self;
892 PyObject *_args;
893{
894 PyObject *_res = NULL;
895 RgnHandle updateRgn;
896 if (!PyArg_ParseTuple(_args, "O&",
897 ResObj_Convert, &updateRgn))
898 return NULL;
899 WEUpdate(updateRgn,
900 _self->ob_itself);
901 Py_INCREF(Py_None);
902 _res = Py_None;
903 return _res;
904}
905
906static PyObject *wasteObj_WEScroll(_self, _args)
907 wasteObject *_self;
908 PyObject *_args;
909{
910 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000911 SInt32 hOffset;
912 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000913 if (!PyArg_ParseTuple(_args, "ll",
914 &hOffset,
915 &vOffset))
916 return NULL;
917 WEScroll(hOffset,
918 vOffset,
919 _self->ob_itself);
920 Py_INCREF(Py_None);
921 _res = Py_None;
922 return _res;
923}
924
925static PyObject *wasteObj_WESelView(_self, _args)
926 wasteObject *_self;
927 PyObject *_args;
928{
929 PyObject *_res = NULL;
930 if (!PyArg_ParseTuple(_args, ""))
931 return NULL;
932 WESelView(_self->ob_itself);
933 Py_INCREF(Py_None);
934 _res = Py_None;
935 return _res;
936}
937
938static PyObject *wasteObj_WEActivate(_self, _args)
939 wasteObject *_self;
940 PyObject *_args;
941{
942 PyObject *_res = NULL;
943 if (!PyArg_ParseTuple(_args, ""))
944 return NULL;
945 WEActivate(_self->ob_itself);
946 Py_INCREF(Py_None);
947 _res = Py_None;
948 return _res;
949}
950
951static PyObject *wasteObj_WEDeactivate(_self, _args)
952 wasteObject *_self;
953 PyObject *_args;
954{
955 PyObject *_res = NULL;
956 if (!PyArg_ParseTuple(_args, ""))
957 return NULL;
958 WEDeactivate(_self->ob_itself);
959 Py_INCREF(Py_None);
960 _res = Py_None;
961 return _res;
962}
963
964static PyObject *wasteObj_WEKey(_self, _args)
965 wasteObject *_self;
966 PyObject *_args;
967{
968 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000969 SInt16 key;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000970 EventModifiers modifiers;
971 if (!PyArg_ParseTuple(_args, "hh",
972 &key,
973 &modifiers))
974 return NULL;
975 WEKey(key,
976 modifiers,
977 _self->ob_itself);
978 Py_INCREF(Py_None);
979 _res = Py_None;
980 return _res;
981}
982
983static PyObject *wasteObj_WEClick(_self, _args)
984 wasteObject *_self;
985 PyObject *_args;
986{
987 PyObject *_res = NULL;
988 Point hitPt;
989 EventModifiers modifiers;
Jack Jansen2268af51996-08-06 16:04:22 +0000990 UInt32 clickTime;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000991 if (!PyArg_ParseTuple(_args, "O&hl",
992 PyMac_GetPoint, &hitPt,
993 &modifiers,
994 &clickTime))
995 return NULL;
996 WEClick(hitPt,
997 modifiers,
998 clickTime,
999 _self->ob_itself);
1000 Py_INCREF(Py_None);
1001 _res = Py_None;
1002 return _res;
1003}
1004
1005static PyObject *wasteObj_WEAdjustCursor(_self, _args)
1006 wasteObject *_self;
1007 PyObject *_args;
1008{
1009 PyObject *_res = NULL;
1010 Boolean _rv;
1011 Point mouseLoc;
1012 RgnHandle mouseRgn;
1013 if (!PyArg_ParseTuple(_args, "O&O&",
1014 PyMac_GetPoint, &mouseLoc,
1015 ResObj_Convert, &mouseRgn))
1016 return NULL;
1017 _rv = WEAdjustCursor(mouseLoc,
1018 mouseRgn,
1019 _self->ob_itself);
1020 _res = Py_BuildValue("b",
1021 _rv);
1022 return _res;
1023}
1024
1025static PyObject *wasteObj_WEIdle(_self, _args)
1026 wasteObject *_self;
1027 PyObject *_args;
1028{
1029 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001030 UInt32 maxSleep;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001031 if (!PyArg_ParseTuple(_args, ""))
1032 return NULL;
1033 WEIdle(&maxSleep,
1034 _self->ob_itself);
1035 _res = Py_BuildValue("l",
1036 maxSleep);
1037 return _res;
1038}
1039
1040static PyObject *wasteObj_WEInsert(_self, _args)
1041 wasteObject *_self;
1042 PyObject *_args;
1043{
1044 PyObject *_res = NULL;
1045 OSErr _err;
1046 char *pText__in__;
1047 long pText__len__;
1048 int pText__in_len__;
1049 StScrpHandle hStyles;
1050 WESoupHandle hSoup;
1051 if (!PyArg_ParseTuple(_args, "s#O&O&",
1052 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001053 OptResObj_Convert, &hStyles,
1054 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001055 return NULL;
1056 pText__len__ = pText__in_len__;
1057 _err = WEInsert(pText__in__, pText__len__,
1058 hStyles,
1059 hSoup,
1060 _self->ob_itself);
1061 if (_err != noErr) return PyMac_Error(_err);
1062 Py_INCREF(Py_None);
1063 _res = Py_None;
1064 pText__error__: ;
1065 return _res;
1066}
1067
1068static PyObject *wasteObj_WEDelete(_self, _args)
1069 wasteObject *_self;
1070 PyObject *_args;
1071{
1072 PyObject *_res = NULL;
1073 OSErr _err;
1074 if (!PyArg_ParseTuple(_args, ""))
1075 return NULL;
1076 _err = WEDelete(_self->ob_itself);
1077 if (_err != noErr) return PyMac_Error(_err);
1078 Py_INCREF(Py_None);
1079 _res = Py_None;
1080 return _res;
1081}
1082
1083static PyObject *wasteObj_WESetStyle(_self, _args)
1084 wasteObject *_self;
1085 PyObject *_args;
1086{
1087 PyObject *_res = NULL;
1088 OSErr _err;
1089 WEStyleMode mode;
1090 TextStyle ts;
1091 if (!PyArg_ParseTuple(_args, "hO&",
1092 &mode,
1093 TextStyle_Convert, &ts))
1094 return NULL;
1095 _err = WESetStyle(mode,
1096 &ts,
1097 _self->ob_itself);
1098 if (_err != noErr) return PyMac_Error(_err);
1099 Py_INCREF(Py_None);
1100 _res = Py_None;
1101 return _res;
1102}
1103
1104static PyObject *wasteObj_WEUseStyleScrap(_self, _args)
1105 wasteObject *_self;
1106 PyObject *_args;
1107{
1108 PyObject *_res = NULL;
1109 OSErr _err;
1110 StScrpHandle hStyles;
1111 if (!PyArg_ParseTuple(_args, "O&",
1112 ResObj_Convert, &hStyles))
1113 return NULL;
1114 _err = WEUseStyleScrap(hStyles,
1115 _self->ob_itself);
1116 if (_err != noErr) return PyMac_Error(_err);
1117 Py_INCREF(Py_None);
1118 _res = Py_None;
1119 return _res;
1120}
1121
1122static PyObject *wasteObj_WEUseText(_self, _args)
1123 wasteObject *_self;
1124 PyObject *_args;
1125{
1126 PyObject *_res = NULL;
1127 OSErr _err;
1128 Handle hText;
1129 if (!PyArg_ParseTuple(_args, "O&",
1130 ResObj_Convert, &hText))
1131 return NULL;
1132 _err = WEUseText(hText,
1133 _self->ob_itself);
1134 if (_err != noErr) return PyMac_Error(_err);
1135 Py_INCREF(Py_None);
1136 _res = Py_None;
1137 return _res;
1138}
1139
1140static PyObject *wasteObj_WEUndo(_self, _args)
1141 wasteObject *_self;
1142 PyObject *_args;
1143{
1144 PyObject *_res = NULL;
1145 OSErr _err;
1146 if (!PyArg_ParseTuple(_args, ""))
1147 return NULL;
1148 _err = WEUndo(_self->ob_itself);
1149 if (_err != noErr) return PyMac_Error(_err);
1150 Py_INCREF(Py_None);
1151 _res = Py_None;
1152 return _res;
1153}
1154
1155static PyObject *wasteObj_WEClearUndo(_self, _args)
1156 wasteObject *_self;
1157 PyObject *_args;
1158{
1159 PyObject *_res = NULL;
1160 if (!PyArg_ParseTuple(_args, ""))
1161 return NULL;
1162 WEClearUndo(_self->ob_itself);
1163 Py_INCREF(Py_None);
1164 _res = Py_None;
1165 return _res;
1166}
1167
1168static PyObject *wasteObj_WEGetUndoInfo(_self, _args)
1169 wasteObject *_self;
1170 PyObject *_args;
1171{
1172 PyObject *_res = NULL;
1173 WEActionKind _rv;
1174 Boolean redoFlag;
1175 if (!PyArg_ParseTuple(_args, ""))
1176 return NULL;
1177 _rv = WEGetUndoInfo(&redoFlag,
1178 _self->ob_itself);
1179 _res = Py_BuildValue("hb",
1180 _rv,
1181 redoFlag);
1182 return _res;
1183}
1184
1185static PyObject *wasteObj_WEIsTyping(_self, _args)
1186 wasteObject *_self;
1187 PyObject *_args;
1188{
1189 PyObject *_res = NULL;
1190 Boolean _rv;
1191 if (!PyArg_ParseTuple(_args, ""))
1192 return NULL;
1193 _rv = WEIsTyping(_self->ob_itself);
1194 _res = Py_BuildValue("b",
1195 _rv);
1196 return _res;
1197}
1198
1199static PyObject *wasteObj_WEGetModCount(_self, _args)
1200 wasteObject *_self;
1201 PyObject *_args;
1202{
1203 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001204 UInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001205 if (!PyArg_ParseTuple(_args, ""))
1206 return NULL;
1207 _rv = WEGetModCount(_self->ob_itself);
1208 _res = Py_BuildValue("l",
1209 _rv);
1210 return _res;
1211}
1212
1213static PyObject *wasteObj_WEResetModCount(_self, _args)
1214 wasteObject *_self;
1215 PyObject *_args;
1216{
1217 PyObject *_res = NULL;
1218 if (!PyArg_ParseTuple(_args, ""))
1219 return NULL;
1220 WEResetModCount(_self->ob_itself);
1221 Py_INCREF(Py_None);
1222 _res = Py_None;
1223 return _res;
1224}
1225
1226static PyObject *wasteObj_WEInsertObject(_self, _args)
1227 wasteObject *_self;
1228 PyObject *_args;
1229{
1230 PyObject *_res = NULL;
1231 OSErr _err;
1232 FlavorType objectType;
1233 Handle objectDataHandle;
1234 Point objectSize;
1235 if (!PyArg_ParseTuple(_args, "O&O&O&",
1236 PyMac_GetOSType, &objectType,
1237 ResObj_Convert, &objectDataHandle,
1238 PyMac_GetPoint, &objectSize))
1239 return NULL;
1240 _err = WEInsertObject(objectType,
1241 objectDataHandle,
1242 objectSize,
1243 _self->ob_itself);
1244 if (_err != noErr) return PyMac_Error(_err);
1245 Py_INCREF(Py_None);
1246 _res = Py_None;
1247 return _res;
1248}
1249
1250static PyObject *wasteObj_WEGetSelectedObject(_self, _args)
1251 wasteObject *_self;
1252 PyObject *_args;
1253{
1254 PyObject *_res = NULL;
1255 OSErr _err;
1256 WEObjectReference obj;
1257 if (!PyArg_ParseTuple(_args, ""))
1258 return NULL;
1259 _err = WEGetSelectedObject(&obj,
1260 _self->ob_itself);
1261 if (_err != noErr) return PyMac_Error(_err);
1262 _res = Py_BuildValue("O&",
1263 WEOObj_New, obj);
1264 return _res;
1265}
1266
1267static PyObject *wasteObj_WEFindNextObject(_self, _args)
1268 wasteObject *_self;
1269 PyObject *_args;
1270{
1271 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001272 SInt32 _rv;
1273 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001274 WEObjectReference obj;
1275 if (!PyArg_ParseTuple(_args, "l",
1276 &offset))
1277 return NULL;
1278 _rv = WEFindNextObject(offset,
1279 &obj,
1280 _self->ob_itself);
1281 _res = Py_BuildValue("lO&",
1282 _rv,
1283 WEOObj_New, obj);
1284 return _res;
1285}
1286
1287static PyObject *wasteObj_WEUseSoup(_self, _args)
1288 wasteObject *_self;
1289 PyObject *_args;
1290{
1291 PyObject *_res = NULL;
1292 OSErr _err;
1293 WESoupHandle hSoup;
1294 if (!PyArg_ParseTuple(_args, "O&",
1295 ResObj_Convert, &hSoup))
1296 return NULL;
1297 _err = WEUseSoup(hSoup,
1298 _self->ob_itself);
1299 if (_err != noErr) return PyMac_Error(_err);
1300 Py_INCREF(Py_None);
1301 _res = Py_None;
1302 return _res;
1303}
1304
1305static PyObject *wasteObj_WECut(_self, _args)
1306 wasteObject *_self;
1307 PyObject *_args;
1308{
1309 PyObject *_res = NULL;
1310 OSErr _err;
1311 if (!PyArg_ParseTuple(_args, ""))
1312 return NULL;
1313 _err = WECut(_self->ob_itself);
1314 if (_err != noErr) return PyMac_Error(_err);
1315 Py_INCREF(Py_None);
1316 _res = Py_None;
1317 return _res;
1318}
1319
1320static PyObject *wasteObj_WECopy(_self, _args)
1321 wasteObject *_self;
1322 PyObject *_args;
1323{
1324 PyObject *_res = NULL;
1325 OSErr _err;
1326 if (!PyArg_ParseTuple(_args, ""))
1327 return NULL;
1328 _err = WECopy(_self->ob_itself);
1329 if (_err != noErr) return PyMac_Error(_err);
1330 Py_INCREF(Py_None);
1331 _res = Py_None;
1332 return _res;
1333}
1334
1335static PyObject *wasteObj_WEPaste(_self, _args)
1336 wasteObject *_self;
1337 PyObject *_args;
1338{
1339 PyObject *_res = NULL;
1340 OSErr _err;
1341 if (!PyArg_ParseTuple(_args, ""))
1342 return NULL;
1343 _err = WEPaste(_self->ob_itself);
1344 if (_err != noErr) return PyMac_Error(_err);
1345 Py_INCREF(Py_None);
1346 _res = Py_None;
1347 return _res;
1348}
1349
1350static PyObject *wasteObj_WECanPaste(_self, _args)
1351 wasteObject *_self;
1352 PyObject *_args;
1353{
1354 PyObject *_res = NULL;
1355 Boolean _rv;
1356 if (!PyArg_ParseTuple(_args, ""))
1357 return NULL;
1358 _rv = WECanPaste(_self->ob_itself);
1359 _res = Py_BuildValue("b",
1360 _rv);
1361 return _res;
1362}
1363
1364static PyObject *wasteObj_WEGetHiliteRgn(_self, _args)
1365 wasteObject *_self;
1366 PyObject *_args;
1367{
1368 PyObject *_res = NULL;
1369 RgnHandle _rv;
Jack Jansen2268af51996-08-06 16:04:22 +00001370 SInt32 rangeStart;
1371 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001372 if (!PyArg_ParseTuple(_args, "ll",
1373 &rangeStart,
1374 &rangeEnd))
1375 return NULL;
1376 _rv = WEGetHiliteRgn(rangeStart,
1377 rangeEnd,
1378 _self->ob_itself);
1379 _res = Py_BuildValue("O&",
1380 ResObj_New, _rv);
1381 return _res;
1382}
1383
1384static PyObject *wasteObj_WECharByte(_self, _args)
1385 wasteObject *_self;
1386 PyObject *_args;
1387{
1388 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001389 SInt16 _rv;
1390 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001391 if (!PyArg_ParseTuple(_args, "l",
1392 &offset))
1393 return NULL;
1394 _rv = WECharByte(offset,
1395 _self->ob_itself);
1396 _res = Py_BuildValue("h",
1397 _rv);
1398 return _res;
1399}
1400
1401static PyObject *wasteObj_WECharType(_self, _args)
1402 wasteObject *_self;
1403 PyObject *_args;
1404{
1405 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001406 SInt16 _rv;
1407 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001408 if (!PyArg_ParseTuple(_args, "l",
1409 &offset))
1410 return NULL;
1411 _rv = WECharType(offset,
1412 _self->ob_itself);
1413 _res = Py_BuildValue("h",
1414 _rv);
1415 return _res;
1416}
1417
1418static PyObject *wasteObj_WEStopInlineSession(_self, _args)
1419 wasteObject *_self;
1420 PyObject *_args;
1421{
1422 PyObject *_res = NULL;
1423 if (!PyArg_ParseTuple(_args, ""))
1424 return NULL;
1425 WEStopInlineSession(_self->ob_itself);
1426 Py_INCREF(Py_None);
1427 _res = Py_None;
1428 return _res;
1429}
1430
1431static PyObject *wasteObj_WEFeatureFlag(_self, _args)
1432 wasteObject *_self;
1433 PyObject *_args;
1434{
1435 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001436 SInt16 _rv;
1437 SInt16 feature;
1438 SInt16 action;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001439 if (!PyArg_ParseTuple(_args, "hh",
1440 &feature,
1441 &action))
1442 return NULL;
1443 _rv = WEFeatureFlag(feature,
1444 action,
1445 _self->ob_itself);
1446 _res = Py_BuildValue("h",
1447 _rv);
1448 return _res;
1449}
1450
1451static PyMethodDef wasteObj_methods[] = {
1452 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1453 "() -> (Handle _rv)"},
1454 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001455 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001456 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001457 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001458 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001459 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001460 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001461 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001462 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001463 "() -> (SInt32 selStart, SInt32 selEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001464 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1465 "() -> (LongRect destRect)"},
1466 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1467 "() -> (LongRect viewRect)"},
1468 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1469 "() -> (Boolean _rv)"},
1470 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001471 "(SInt32 offset) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001472 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001473 "(SInt32 lineNo) -> (SInt32 lineStart, SInt32 lineEnd)"},
1474 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1475 "() -> (UInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001476 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001477 "(SInt32 selStart, SInt32 selEnd) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001478 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1479 "(LongRect destRect) -> None"},
1480 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1481 "(LongRect viewRect) -> None"},
1482 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001483 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001484 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001485 "(SInt32 offset) -> (WERunInfo runInfo)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001486 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001487 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001488 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001489 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001490 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001491 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001492 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001493 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001494 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001495 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001496 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1497 "() -> (WEAlignment _rv)"},
1498 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1499 "(WEAlignment alignment) -> None"},
1500 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1501 "() -> None"},
1502 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1503 "(RgnHandle updateRgn) -> None"},
1504 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001505 "(SInt32 hOffset, SInt32 vOffset) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001506 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1507 "() -> None"},
1508 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1509 "() -> None"},
1510 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1511 "() -> None"},
1512 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001513 "(SInt16 key, EventModifiers modifiers) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001514 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001515 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001516 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1517 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1518 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001519 "() -> (UInt32 maxSleep)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001520 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1521 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1522 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1523 "() -> None"},
1524 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1525 "(WEStyleMode mode, TextStyle ts) -> None"},
1526 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1527 "(StScrpHandle hStyles) -> None"},
1528 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1529 "(Handle hText) -> None"},
1530 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1531 "() -> None"},
1532 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1533 "() -> None"},
1534 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1535 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1536 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1537 "() -> (Boolean _rv)"},
1538 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001539 "() -> (UInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001540 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1541 "() -> None"},
1542 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1543 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1544 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1545 "() -> (WEObjectReference obj)"},
1546 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001547 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001548 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1549 "(WESoupHandle hSoup) -> None"},
1550 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1551 "() -> None"},
1552 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1553 "() -> None"},
1554 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1555 "() -> None"},
1556 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1557 "() -> (Boolean _rv)"},
1558 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001559 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001560 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001561 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001562 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001563 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001564 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1565 "() -> None"},
1566 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001567 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001568 {NULL, NULL, 0}
1569};
1570
1571PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1572
1573static PyObject *wasteObj_getattr(self, name)
1574 wasteObject *self;
1575 char *name;
1576{
1577 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1578}
1579
1580#define wasteObj_setattr NULL
1581
1582PyTypeObject waste_Type = {
1583 PyObject_HEAD_INIT(&PyType_Type)
1584 0, /*ob_size*/
1585 "waste", /*tp_name*/
1586 sizeof(wasteObject), /*tp_basicsize*/
1587 0, /*tp_itemsize*/
1588 /* methods */
1589 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1590 0, /*tp_print*/
1591 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1592 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
1593};
1594
1595/* --------------------- End object type waste ---------------------- */
1596
1597
1598static PyObject *waste_WENew(_self, _args)
1599 PyObject *_self;
1600 PyObject *_args;
1601{
1602 PyObject *_res = NULL;
1603 OSErr _err;
1604 LongRect destRect;
1605 LongRect viewRect;
Jack Jansen2268af51996-08-06 16:04:22 +00001606 UInt32 flags;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001607 WEReference we;
1608 if (!PyArg_ParseTuple(_args, "O&O&l",
1609 LongRect_Convert, &destRect,
1610 LongRect_Convert, &viewRect,
1611 &flags))
1612 return NULL;
1613 _err = WENew(&destRect,
1614 &viewRect,
1615 flags,
1616 &we);
1617 if (_err != noErr) return PyMac_Error(_err);
1618 _res = Py_BuildValue("O&",
1619 wasteObj_New, we);
1620 return _res;
1621}
1622
1623static PyObject *waste_WEInstallTSMHandlers(_self, _args)
1624 PyObject *_self;
1625 PyObject *_args;
1626{
1627 PyObject *_res = NULL;
1628 OSErr _err;
1629 if (!PyArg_ParseTuple(_args, ""))
1630 return NULL;
1631 _err = WEInstallTSMHandlers();
1632 if (_err != noErr) return PyMac_Error(_err);
1633 Py_INCREF(Py_None);
1634 _res = Py_None;
1635 return _res;
1636}
1637
1638static PyObject *waste_WERemoveTSMHandlers(_self, _args)
1639 PyObject *_self;
1640 PyObject *_args;
1641{
1642 PyObject *_res = NULL;
1643 OSErr _err;
1644 if (!PyArg_ParseTuple(_args, ""))
1645 return NULL;
1646 _err = WERemoveTSMHandlers();
1647 if (_err != noErr) return PyMac_Error(_err);
1648 Py_INCREF(Py_None);
1649 _res = Py_None;
1650 return _res;
1651}
1652
1653static PyObject *waste_WELongPointToPoint(_self, _args)
1654 PyObject *_self;
1655 PyObject *_args;
1656{
1657 PyObject *_res = NULL;
1658 LongPt lp;
1659 Point p;
1660 if (!PyArg_ParseTuple(_args, "O&",
1661 LongPt_Convert, &lp))
1662 return NULL;
1663 WELongPointToPoint(&lp,
1664 &p);
1665 _res = Py_BuildValue("O&",
1666 PyMac_BuildPoint, p);
1667 return _res;
1668}
1669
1670static PyObject *waste_WEPointToLongPoint(_self, _args)
1671 PyObject *_self;
1672 PyObject *_args;
1673{
1674 PyObject *_res = NULL;
1675 Point p;
1676 LongPt lp;
1677 if (!PyArg_ParseTuple(_args, "O&",
1678 PyMac_GetPoint, &p))
1679 return NULL;
1680 WEPointToLongPoint(p,
1681 &lp);
1682 _res = Py_BuildValue("O&",
1683 LongPt_New, &lp);
1684 return _res;
1685}
1686
1687static PyObject *waste_WESetLongRect(_self, _args)
1688 PyObject *_self;
1689 PyObject *_args;
1690{
1691 PyObject *_res = NULL;
1692 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001693 SInt32 left;
1694 SInt32 top;
1695 SInt32 right;
1696 SInt32 bottom;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001697 if (!PyArg_ParseTuple(_args, "llll",
1698 &left,
1699 &top,
1700 &right,
1701 &bottom))
1702 return NULL;
1703 WESetLongRect(&lr,
1704 left,
1705 top,
1706 right,
1707 bottom);
1708 _res = Py_BuildValue("O&",
1709 LongRect_New, &lr);
1710 return _res;
1711}
1712
1713static PyObject *waste_WELongRectToRect(_self, _args)
1714 PyObject *_self;
1715 PyObject *_args;
1716{
1717 PyObject *_res = NULL;
1718 LongRect lr;
1719 Rect r;
1720 if (!PyArg_ParseTuple(_args, "O&",
1721 LongRect_Convert, &lr))
1722 return NULL;
1723 WELongRectToRect(&lr,
1724 &r);
1725 _res = Py_BuildValue("O&",
1726 PyMac_BuildRect, &r);
1727 return _res;
1728}
1729
1730static PyObject *waste_WERectToLongRect(_self, _args)
1731 PyObject *_self;
1732 PyObject *_args;
1733{
1734 PyObject *_res = NULL;
1735 Rect r;
1736 LongRect lr;
1737 if (!PyArg_ParseTuple(_args, "O&",
1738 PyMac_GetRect, &r))
1739 return NULL;
1740 WERectToLongRect(&r,
1741 &lr);
1742 _res = Py_BuildValue("O&",
1743 LongRect_New, &lr);
1744 return _res;
1745}
1746
1747static PyObject *waste_WEOffsetLongRect(_self, _args)
1748 PyObject *_self;
1749 PyObject *_args;
1750{
1751 PyObject *_res = NULL;
1752 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001753 SInt32 hOffset;
1754 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001755 if (!PyArg_ParseTuple(_args, "ll",
1756 &hOffset,
1757 &vOffset))
1758 return NULL;
1759 WEOffsetLongRect(&lr,
1760 hOffset,
1761 vOffset);
1762 _res = Py_BuildValue("O&",
1763 LongRect_New, &lr);
1764 return _res;
1765}
1766
1767static PyObject *waste_WELongPointInLongRect(_self, _args)
1768 PyObject *_self;
1769 PyObject *_args;
1770{
1771 PyObject *_res = NULL;
1772 Boolean _rv;
1773 LongPt lp;
1774 LongRect lr;
1775 if (!PyArg_ParseTuple(_args, "O&O&",
1776 LongPt_Convert, &lp,
1777 LongRect_Convert, &lr))
1778 return NULL;
1779 _rv = WELongPointInLongRect(&lp,
1780 &lr);
1781 _res = Py_BuildValue("b",
1782 _rv);
1783 return _res;
1784}
1785
Jack Jansen756522f1996-05-07 15:24:01 +00001786static PyObject *waste_STDObjectHandlers(_self, _args)
1787 PyObject *_self;
1788 PyObject *_args;
1789{
1790 PyObject *_res = NULL;
1791
1792 OSErr err;
1793 // install the sample object handlers for pictures and sounds
1794#define kTypePicture 'PICT'
1795#define kTypeSound 'snd '
1796
1797 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
1798
1799 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
1800 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
1801 goto cleanup;
1802
1803 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
1804 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
1805 goto cleanup;
1806
1807 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
1808 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
1809 goto cleanup;
1810
1811 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
1812 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
1813 goto cleanup;
1814
1815 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
1816 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
1817 goto cleanup;
1818
1819 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
1820 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
1821 goto cleanup;
1822 Py_INCREF(Py_None);
1823 return Py_None;
1824
1825 cleanup:
1826 return PyMac_Error(err);
1827
1828}
1829
1830static PyObject *waste_WEInstallObjectHandler(_self, _args)
1831 PyObject *_self;
1832 PyObject *_args;
1833{
1834 PyObject *_res = NULL;
1835
1836 OSErr err;
1837 FlavorType objectType;
1838 WESelector selector;
1839 PyObject *py_handler;
1840 UniversalProcPtr handler;
1841 WEReference we = NULL;
1842 PyObject *key;
1843
1844
1845 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
1846 PyMac_GetOSType, &objectType,
1847 PyMac_GetOSType, &selector,
1848 &py_handler,
Jack Jansen7df36061996-10-01 11:41:14 +00001849 WEOObj_Convert, &we) ) return NULL;
Jack Jansen756522f1996-05-07 15:24:01 +00001850
Jack Jansen25241d91996-05-20 11:30:45 +00001851 if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
1852 else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
1853 else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
1854 else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +00001855 else return PyMac_Error(weUndefinedSelectorErr);
1856
1857 if ((key = Py_BuildValue("O&O&",
1858 PyMac_BuildOSType, objectType,
1859 PyMac_BuildOSType, selector)) == NULL )
1860 return NULL;
1861
1862 PyDict_SetItem(callbackdict, key, py_handler);
1863
1864 err = WEInstallObjectHandler(objectType, selector, handler, we);
1865 if ( err ) return PyMac_Error(err);
1866 Py_INCREF(Py_None);
1867 return Py_None;
1868
1869}
1870
Jack Jansen90ecdf41996-04-16 14:29:15 +00001871static PyMethodDef waste_methods[] = {
1872 {"WENew", (PyCFunction)waste_WENew, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001873 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001874 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
1875 "() -> None"},
1876 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
1877 "() -> None"},
1878 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
1879 "(LongPt lp) -> (Point p)"},
1880 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
1881 "(Point p) -> (LongPt lp)"},
1882 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001883 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001884 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
1885 "(LongRect lr) -> (Rect r)"},
1886 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
1887 "(Rect r) -> (LongRect lr)"},
1888 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001889 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001890 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
1891 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00001892 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
1893 NULL},
1894 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
1895 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001896 {NULL, NULL, 0}
1897};
1898
1899
1900
Jack Jansen756522f1996-05-07 15:24:01 +00001901/* Return the object corresponding to the window, or NULL */
1902
1903PyObject *
1904ExistingwasteObj_New(w)
1905 WEReference w;
1906{
1907 PyObject *it = NULL;
1908
1909 if (w == NULL)
1910 it = NULL;
1911 else
1912 WEGetInfo(weRefCon, (void *)&it, w);
1913 if (it == NULL || ((wasteObject *)it)->ob_itself != w)
1914 it = Py_None;
1915 Py_INCREF(it);
1916 return it;
1917}
1918
Jack Jansen90ecdf41996-04-16 14:29:15 +00001919
1920void initwaste()
1921{
1922 PyObject *m;
1923 PyObject *d;
1924
1925
1926
1927
1928 m = Py_InitModule("waste", waste_methods);
1929 d = PyModule_GetDict(m);
1930 waste_Error = PyMac_GetOSErrException();
1931 if (waste_Error == NULL ||
1932 PyDict_SetItemString(d, "Error", waste_Error) != 0)
1933 Py_FatalError("can't initialize waste.Error");
Jack Jansen756522f1996-05-07 15:24:01 +00001934
1935 callbackdict = PyDict_New();
1936 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
1937 Py_FatalError("can't initialize Waste.callbackdict");
1938 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00001939 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
1940 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
1941 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00001942
1943
Jack Jansen90ecdf41996-04-16 14:29:15 +00001944}
1945
1946/* ======================== End module waste ======================== */
1947