blob: fb8f620e34ae4e42abb05b550cfae225a8ebfd10 [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>
46
47/* Exported by Qdmodule.c: */
48extern PyObject *QdRGB_New(RGBColor *);
49extern int QdRGB_Convert(PyObject *, RGBColor *);
50
51/* Forward declaration */
52staticforward PyObject *WEOObj_New(WEObjectReference);
53
54/*
55** Parse/generate TextStyle records
56*/
57static
58PyObject *TextStyle_New(itself)
59 TextStylePtr itself;
60{
61
62 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
63 &itself->tsColor);
64}
65
66static
67TextStyle_Convert(v, p_itself)
68 PyObject *v;
69 TextStylePtr p_itself;
70{
71 long font, face, size;
72
73 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
74 return 0;
75 p_itself->tsFont = (short)font;
76 p_itself->tsFace = (Style)face;
77 p_itself->tsSize = (short)size;
78 return 1;
79}
80
81/*
82** Parse/generate RunInfo records
83*/
84static
85PyObject *RunInfo_New(itself)
86 WERunInfo *itself;
87{
88
89 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
90 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
91}
92
93/* Conversion of long points and rects */
94int
95LongRect_Convert(PyObject *v, LongRect *r)
96{
97 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
98}
99
100PyObject *
101LongRect_New(LongRect *r)
102{
103 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
104}
105
106
107LongPt_Convert(PyObject *v, LongPt *p)
108{
109 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
110}
111
112PyObject *
113LongPt_New(LongPt *p)
114{
115 return Py_BuildValue("(ll)", p->h, p->v);
116}
117
118static PyObject *waste_Error;
119
120/* ------------------------ Object type WEO ------------------------- */
121
122PyTypeObject WEO_Type;
123
124#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
125
126typedef struct WEOObject {
127 PyObject_HEAD
128 WEObjectReference ob_itself;
129} WEOObject;
130
131PyObject *WEOObj_New(itself)
132 WEObjectReference itself;
133{
134 WEOObject *it;
135 if (itself == NULL) {
136 Py_INCREF(Py_None);
137 return Py_None;
138 }
139 it = PyObject_NEW(WEOObject, &WEO_Type);
140 if (it == NULL) return NULL;
141 it->ob_itself = itself;
142 return (PyObject *)it;
143}
144WEOObj_Convert(v, p_itself)
145 PyObject *v;
146 WEObjectReference *p_itself;
147{
148 if (!WEOObj_Check(v))
149 {
150 PyErr_SetString(PyExc_TypeError, "WEO required");
151 return 0;
152 }
153 *p_itself = ((WEOObject *)v)->ob_itself;
154 return 1;
155}
156
157static void WEOObj_dealloc(self)
158 WEOObject *self;
159{
160 /* Cleanup of self->ob_itself goes here */
161 PyMem_DEL(self);
162}
163
164static PyObject *WEOObj_WEGetObjectType(_self, _args)
165 WEOObject *_self;
166 PyObject *_args;
167{
168 PyObject *_res = NULL;
169 FlavorType _rv;
170 if (!PyArg_ParseTuple(_args, ""))
171 return NULL;
172 _rv = WEGetObjectType(_self->ob_itself);
173 _res = Py_BuildValue("O&",
174 PyMac_BuildOSType, _rv);
175 return _res;
176}
177
178static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args)
179 WEOObject *_self;
180 PyObject *_args;
181{
182 PyObject *_res = NULL;
183 Handle _rv;
184 if (!PyArg_ParseTuple(_args, ""))
185 return NULL;
186 _rv = WEGetObjectDataHandle(_self->ob_itself);
187 _res = Py_BuildValue("O&",
188 ResObj_New, _rv);
189 return _res;
190}
191
192static PyObject *WEOObj_WEGetObjectSize(_self, _args)
193 WEOObject *_self;
194 PyObject *_args;
195{
196 PyObject *_res = NULL;
197 Point _rv;
198 if (!PyArg_ParseTuple(_args, ""))
199 return NULL;
200 _rv = WEGetObjectSize(_self->ob_itself);
201 _res = Py_BuildValue("O&",
202 PyMac_BuildPoint, _rv);
203 return _res;
204}
205
206static PyObject *WEOObj_WEGetObjectRefCon(_self, _args)
207 WEOObject *_self;
208 PyObject *_args;
209{
210 PyObject *_res = NULL;
211 long _rv;
212 if (!PyArg_ParseTuple(_args, ""))
213 return NULL;
214 _rv = WEGetObjectRefCon(_self->ob_itself);
215 _res = Py_BuildValue("l",
216 _rv);
217 return _res;
218}
219
220static PyObject *WEOObj_WESetObjectRefCon(_self, _args)
221 WEOObject *_self;
222 PyObject *_args;
223{
224 PyObject *_res = NULL;
225 long refCon;
226 if (!PyArg_ParseTuple(_args, "l",
227 &refCon))
228 return NULL;
229 WESetObjectRefCon(_self->ob_itself,
230 refCon);
231 Py_INCREF(Py_None);
232 _res = Py_None;
233 return _res;
234}
235
236static PyMethodDef WEOObj_methods[] = {
237 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
238 "() -> (FlavorType _rv)"},
239 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
240 "() -> (Handle _rv)"},
241 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
242 "() -> (Point _rv)"},
243 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
244 "() -> (long _rv)"},
245 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
246 "(long refCon) -> None"},
247 {NULL, NULL, 0}
248};
249
250PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
251
252static PyObject *WEOObj_getattr(self, name)
253 WEOObject *self;
254 char *name;
255{
256 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
257}
258
259#define WEOObj_setattr NULL
260
261PyTypeObject WEO_Type = {
262 PyObject_HEAD_INIT(&PyType_Type)
263 0, /*ob_size*/
264 "WEO", /*tp_name*/
265 sizeof(WEOObject), /*tp_basicsize*/
266 0, /*tp_itemsize*/
267 /* methods */
268 (destructor) WEOObj_dealloc, /*tp_dealloc*/
269 0, /*tp_print*/
270 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
271 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
272};
273
274/* ---------------------- End object type WEO ----------------------- */
275
276
277/* ----------------------- Object type waste ------------------------ */
278
279PyTypeObject waste_Type;
280
281#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
282
283typedef struct wasteObject {
284 PyObject_HEAD
285 WEReference ob_itself;
286} wasteObject;
287
288PyObject *wasteObj_New(itself)
289 WEReference itself;
290{
291 wasteObject *it;
292 if (itself == NULL) {
293 PyErr_SetString(waste_Error,"Cannot create null WE");
294 return NULL;
295 }
296 it = PyObject_NEW(wasteObject, &waste_Type);
297 if (it == NULL) return NULL;
298 it->ob_itself = itself;
299 return (PyObject *)it;
300}
301wasteObj_Convert(v, p_itself)
302 PyObject *v;
303 WEReference *p_itself;
304{
305 if (!wasteObj_Check(v))
306 {
307 PyErr_SetString(PyExc_TypeError, "waste required");
308 return 0;
309 }
310 *p_itself = ((wasteObject *)v)->ob_itself;
311 return 1;
312}
313
314static void wasteObj_dealloc(self)
315 wasteObject *self;
316{
317 WEDispose(self->ob_itself);
318 PyMem_DEL(self);
319}
320
321static PyObject *wasteObj_WEGetText(_self, _args)
322 wasteObject *_self;
323 PyObject *_args;
324{
325 PyObject *_res = NULL;
326 Handle _rv;
327 if (!PyArg_ParseTuple(_args, ""))
328 return NULL;
329 _rv = WEGetText(_self->ob_itself);
330 _res = Py_BuildValue("O&",
331 ResObj_New, _rv);
332 return _res;
333}
334
335static PyObject *wasteObj_WEGetChar(_self, _args)
336 wasteObject *_self;
337 PyObject *_args;
338{
339 PyObject *_res = NULL;
340 short _rv;
341 long offset;
342 if (!PyArg_ParseTuple(_args, "l",
343 &offset))
344 return NULL;
345 _rv = WEGetChar(offset,
346 _self->ob_itself);
347 _res = Py_BuildValue("h",
348 _rv);
349 return _res;
350}
351
352static PyObject *wasteObj_WEGetTextLength(_self, _args)
353 wasteObject *_self;
354 PyObject *_args;
355{
356 PyObject *_res = NULL;
357 long _rv;
358 if (!PyArg_ParseTuple(_args, ""))
359 return NULL;
360 _rv = WEGetTextLength(_self->ob_itself);
361 _res = Py_BuildValue("l",
362 _rv);
363 return _res;
364}
365
366static PyObject *wasteObj_WECountLines(_self, _args)
367 wasteObject *_self;
368 PyObject *_args;
369{
370 PyObject *_res = NULL;
371 long _rv;
372 if (!PyArg_ParseTuple(_args, ""))
373 return NULL;
374 _rv = WECountLines(_self->ob_itself);
375 _res = Py_BuildValue("l",
376 _rv);
377 return _res;
378}
379
380static PyObject *wasteObj_WEGetHeight(_self, _args)
381 wasteObject *_self;
382 PyObject *_args;
383{
384 PyObject *_res = NULL;
385 long _rv;
386 long startLine;
387 long endLine;
388 if (!PyArg_ParseTuple(_args, "ll",
389 &startLine,
390 &endLine))
391 return NULL;
392 _rv = WEGetHeight(startLine,
393 endLine,
394 _self->ob_itself);
395 _res = Py_BuildValue("l",
396 _rv);
397 return _res;
398}
399
400static PyObject *wasteObj_WEGetSelection(_self, _args)
401 wasteObject *_self;
402 PyObject *_args;
403{
404 PyObject *_res = NULL;
405 long selStart;
406 long selEnd;
407 if (!PyArg_ParseTuple(_args, ""))
408 return NULL;
409 WEGetSelection(&selStart,
410 &selEnd,
411 _self->ob_itself);
412 _res = Py_BuildValue("ll",
413 selStart,
414 selEnd);
415 return _res;
416}
417
418static PyObject *wasteObj_WEGetDestRect(_self, _args)
419 wasteObject *_self;
420 PyObject *_args;
421{
422 PyObject *_res = NULL;
423 LongRect destRect;
424 if (!PyArg_ParseTuple(_args, ""))
425 return NULL;
426 WEGetDestRect(&destRect,
427 _self->ob_itself);
428 _res = Py_BuildValue("O&",
429 LongRect_New, &destRect);
430 return _res;
431}
432
433static PyObject *wasteObj_WEGetViewRect(_self, _args)
434 wasteObject *_self;
435 PyObject *_args;
436{
437 PyObject *_res = NULL;
438 LongRect viewRect;
439 if (!PyArg_ParseTuple(_args, ""))
440 return NULL;
441 WEGetViewRect(&viewRect,
442 _self->ob_itself);
443 _res = Py_BuildValue("O&",
444 LongRect_New, &viewRect);
445 return _res;
446}
447
448static PyObject *wasteObj_WEIsActive(_self, _args)
449 wasteObject *_self;
450 PyObject *_args;
451{
452 PyObject *_res = NULL;
453 Boolean _rv;
454 if (!PyArg_ParseTuple(_args, ""))
455 return NULL;
456 _rv = WEIsActive(_self->ob_itself);
457 _res = Py_BuildValue("b",
458 _rv);
459 return _res;
460}
461
462static PyObject *wasteObj_WEOffsetToLine(_self, _args)
463 wasteObject *_self;
464 PyObject *_args;
465{
466 PyObject *_res = NULL;
467 long _rv;
468 long offset;
469 if (!PyArg_ParseTuple(_args, "l",
470 &offset))
471 return NULL;
472 _rv = WEOffsetToLine(offset,
473 _self->ob_itself);
474 _res = Py_BuildValue("l",
475 _rv);
476 return _res;
477}
478
479static PyObject *wasteObj_WEGetLineRange(_self, _args)
480 wasteObject *_self;
481 PyObject *_args;
482{
483 PyObject *_res = NULL;
484 long lineNo;
485 long lineStart;
486 long lineEnd;
487 if (!PyArg_ParseTuple(_args, "l",
488 &lineNo))
489 return NULL;
490 WEGetLineRange(lineNo,
491 &lineStart,
492 &lineEnd,
493 _self->ob_itself);
494 _res = Py_BuildValue("ll",
495 lineStart,
496 lineEnd);
497 return _res;
498}
499
500static PyObject *wasteObj_WESetSelection(_self, _args)
501 wasteObject *_self;
502 PyObject *_args;
503{
504 PyObject *_res = NULL;
505 long selStart;
506 long selEnd;
507 if (!PyArg_ParseTuple(_args, "ll",
508 &selStart,
509 &selEnd))
510 return NULL;
511 WESetSelection(selStart,
512 selEnd,
513 _self->ob_itself);
514 Py_INCREF(Py_None);
515 _res = Py_None;
516 return _res;
517}
518
519static PyObject *wasteObj_WESetDestRect(_self, _args)
520 wasteObject *_self;
521 PyObject *_args;
522{
523 PyObject *_res = NULL;
524 LongRect destRect;
525 if (!PyArg_ParseTuple(_args, "O&",
526 LongRect_Convert, &destRect))
527 return NULL;
528 WESetDestRect(&destRect,
529 _self->ob_itself);
530 Py_INCREF(Py_None);
531 _res = Py_None;
532 return _res;
533}
534
535static PyObject *wasteObj_WESetViewRect(_self, _args)
536 wasteObject *_self;
537 PyObject *_args;
538{
539 PyObject *_res = NULL;
540 LongRect viewRect;
541 if (!PyArg_ParseTuple(_args, "O&",
542 LongRect_Convert, &viewRect))
543 return NULL;
544 WESetViewRect(&viewRect,
545 _self->ob_itself);
546 Py_INCREF(Py_None);
547 _res = Py_None;
548 return _res;
549}
550
551static PyObject *wasteObj_WEContinuousStyle(_self, _args)
552 wasteObject *_self;
553 PyObject *_args;
554{
555 PyObject *_res = NULL;
556 Boolean _rv;
557 WEStyleMode mode;
558 TextStyle ts;
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000559 if (!PyArg_ParseTuple(_args, "h",
560 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000561 return NULL;
562 _rv = WEContinuousStyle(&mode,
563 &ts,
564 _self->ob_itself);
565 _res = Py_BuildValue("bhO&",
566 _rv,
567 mode,
568 TextStyle_New, &ts);
569 return _res;
570}
571
572static PyObject *wasteObj_WEGetRunInfo(_self, _args)
573 wasteObject *_self;
574 PyObject *_args;
575{
576 PyObject *_res = NULL;
577 long offset;
578 WERunInfo runInfo;
579 if (!PyArg_ParseTuple(_args, "l",
580 &offset))
581 return NULL;
582 WEGetRunInfo(offset,
583 &runInfo,
584 _self->ob_itself);
585 _res = Py_BuildValue("O&",
586 RunInfo_New, &runInfo);
587 return _res;
588}
589
590static PyObject *wasteObj_WEGetOffset(_self, _args)
591 wasteObject *_self;
592 PyObject *_args;
593{
594 PyObject *_res = NULL;
595 long _rv;
596 LongPt thePoint;
597 char edge;
598 if (!PyArg_ParseTuple(_args, "O&",
599 LongPt_Convert, &thePoint))
600 return NULL;
601 _rv = WEGetOffset(&thePoint,
602 &edge,
603 _self->ob_itself);
604 _res = Py_BuildValue("lc",
605 _rv,
606 edge);
607 return _res;
608}
609
610static PyObject *wasteObj_WEGetPoint(_self, _args)
611 wasteObject *_self;
612 PyObject *_args;
613{
614 PyObject *_res = NULL;
615 long offset;
616 LongPt thePoint;
617 short lineHeight;
618 if (!PyArg_ParseTuple(_args, "l",
619 &offset))
620 return NULL;
621 WEGetPoint(offset,
622 &thePoint,
623 &lineHeight,
624 _self->ob_itself);
625 _res = Py_BuildValue("O&h",
626 LongPt_New, &thePoint,
627 lineHeight);
628 return _res;
629}
630
631static PyObject *wasteObj_WEFindWord(_self, _args)
632 wasteObject *_self;
633 PyObject *_args;
634{
635 PyObject *_res = NULL;
636 long offset;
637 char edge;
638 long wordStart;
639 long wordEnd;
640 if (!PyArg_ParseTuple(_args, "lc",
641 &offset,
642 &edge))
643 return NULL;
644 WEFindWord(offset,
645 edge,
646 &wordStart,
647 &wordEnd,
648 _self->ob_itself);
649 _res = Py_BuildValue("ll",
650 wordStart,
651 wordEnd);
652 return _res;
653}
654
655static PyObject *wasteObj_WEFindLine(_self, _args)
656 wasteObject *_self;
657 PyObject *_args;
658{
659 PyObject *_res = NULL;
660 long offset;
661 char edge;
662 long lineStart;
663 long lineEnd;
664 if (!PyArg_ParseTuple(_args, "lc",
665 &offset,
666 &edge))
667 return NULL;
668 WEFindLine(offset,
669 edge,
670 &lineStart,
671 &lineEnd,
672 _self->ob_itself);
673 _res = Py_BuildValue("ll",
674 lineStart,
675 lineEnd);
676 return _res;
677}
678
679static PyObject *wasteObj_WECopyRange(_self, _args)
680 wasteObject *_self;
681 PyObject *_args;
682{
683 PyObject *_res = NULL;
684 OSErr _err;
685 long rangeStart;
686 long rangeEnd;
687 Handle hText;
688 StScrpHandle hStyles;
689 WESoupHandle hSoup;
690 if (!PyArg_ParseTuple(_args, "llO&O&O&",
691 &rangeStart,
692 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000693 OptResObj_Convert, &hText,
694 OptResObj_Convert, &hStyles,
695 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000696 return NULL;
697 _err = WECopyRange(rangeStart,
698 rangeEnd,
699 hText,
700 hStyles,
701 hSoup,
702 _self->ob_itself);
703 if (_err != noErr) return PyMac_Error(_err);
704 Py_INCREF(Py_None);
705 _res = Py_None;
706 return _res;
707}
708
709static PyObject *wasteObj_WEGetAlignment(_self, _args)
710 wasteObject *_self;
711 PyObject *_args;
712{
713 PyObject *_res = NULL;
714 WEAlignment _rv;
715 if (!PyArg_ParseTuple(_args, ""))
716 return NULL;
717 _rv = WEGetAlignment(_self->ob_itself);
718 _res = Py_BuildValue("b",
719 _rv);
720 return _res;
721}
722
723static PyObject *wasteObj_WESetAlignment(_self, _args)
724 wasteObject *_self;
725 PyObject *_args;
726{
727 PyObject *_res = NULL;
728 WEAlignment alignment;
729 if (!PyArg_ParseTuple(_args, "b",
730 &alignment))
731 return NULL;
732 WESetAlignment(alignment,
733 _self->ob_itself);
734 Py_INCREF(Py_None);
735 _res = Py_None;
736 return _res;
737}
738
739static PyObject *wasteObj_WECalText(_self, _args)
740 wasteObject *_self;
741 PyObject *_args;
742{
743 PyObject *_res = NULL;
744 OSErr _err;
745 if (!PyArg_ParseTuple(_args, ""))
746 return NULL;
747 _err = WECalText(_self->ob_itself);
748 if (_err != noErr) return PyMac_Error(_err);
749 Py_INCREF(Py_None);
750 _res = Py_None;
751 return _res;
752}
753
754static PyObject *wasteObj_WEUpdate(_self, _args)
755 wasteObject *_self;
756 PyObject *_args;
757{
758 PyObject *_res = NULL;
759 RgnHandle updateRgn;
760 if (!PyArg_ParseTuple(_args, "O&",
761 ResObj_Convert, &updateRgn))
762 return NULL;
763 WEUpdate(updateRgn,
764 _self->ob_itself);
765 Py_INCREF(Py_None);
766 _res = Py_None;
767 return _res;
768}
769
770static PyObject *wasteObj_WEScroll(_self, _args)
771 wasteObject *_self;
772 PyObject *_args;
773{
774 PyObject *_res = NULL;
775 long hOffset;
776 long vOffset;
777 if (!PyArg_ParseTuple(_args, "ll",
778 &hOffset,
779 &vOffset))
780 return NULL;
781 WEScroll(hOffset,
782 vOffset,
783 _self->ob_itself);
784 Py_INCREF(Py_None);
785 _res = Py_None;
786 return _res;
787}
788
789static PyObject *wasteObj_WESelView(_self, _args)
790 wasteObject *_self;
791 PyObject *_args;
792{
793 PyObject *_res = NULL;
794 if (!PyArg_ParseTuple(_args, ""))
795 return NULL;
796 WESelView(_self->ob_itself);
797 Py_INCREF(Py_None);
798 _res = Py_None;
799 return _res;
800}
801
802static PyObject *wasteObj_WEActivate(_self, _args)
803 wasteObject *_self;
804 PyObject *_args;
805{
806 PyObject *_res = NULL;
807 if (!PyArg_ParseTuple(_args, ""))
808 return NULL;
809 WEActivate(_self->ob_itself);
810 Py_INCREF(Py_None);
811 _res = Py_None;
812 return _res;
813}
814
815static PyObject *wasteObj_WEDeactivate(_self, _args)
816 wasteObject *_self;
817 PyObject *_args;
818{
819 PyObject *_res = NULL;
820 if (!PyArg_ParseTuple(_args, ""))
821 return NULL;
822 WEDeactivate(_self->ob_itself);
823 Py_INCREF(Py_None);
824 _res = Py_None;
825 return _res;
826}
827
828static PyObject *wasteObj_WEKey(_self, _args)
829 wasteObject *_self;
830 PyObject *_args;
831{
832 PyObject *_res = NULL;
833 short key;
834 EventModifiers modifiers;
835 if (!PyArg_ParseTuple(_args, "hh",
836 &key,
837 &modifiers))
838 return NULL;
839 WEKey(key,
840 modifiers,
841 _self->ob_itself);
842 Py_INCREF(Py_None);
843 _res = Py_None;
844 return _res;
845}
846
847static PyObject *wasteObj_WEClick(_self, _args)
848 wasteObject *_self;
849 PyObject *_args;
850{
851 PyObject *_res = NULL;
852 Point hitPt;
853 EventModifiers modifiers;
854 unsigned long clickTime;
855 if (!PyArg_ParseTuple(_args, "O&hl",
856 PyMac_GetPoint, &hitPt,
857 &modifiers,
858 &clickTime))
859 return NULL;
860 WEClick(hitPt,
861 modifiers,
862 clickTime,
863 _self->ob_itself);
864 Py_INCREF(Py_None);
865 _res = Py_None;
866 return _res;
867}
868
869static PyObject *wasteObj_WEAdjustCursor(_self, _args)
870 wasteObject *_self;
871 PyObject *_args;
872{
873 PyObject *_res = NULL;
874 Boolean _rv;
875 Point mouseLoc;
876 RgnHandle mouseRgn;
877 if (!PyArg_ParseTuple(_args, "O&O&",
878 PyMac_GetPoint, &mouseLoc,
879 ResObj_Convert, &mouseRgn))
880 return NULL;
881 _rv = WEAdjustCursor(mouseLoc,
882 mouseRgn,
883 _self->ob_itself);
884 _res = Py_BuildValue("b",
885 _rv);
886 return _res;
887}
888
889static PyObject *wasteObj_WEIdle(_self, _args)
890 wasteObject *_self;
891 PyObject *_args;
892{
893 PyObject *_res = NULL;
894 unsigned long maxSleep;
895 if (!PyArg_ParseTuple(_args, ""))
896 return NULL;
897 WEIdle(&maxSleep,
898 _self->ob_itself);
899 _res = Py_BuildValue("l",
900 maxSleep);
901 return _res;
902}
903
904static PyObject *wasteObj_WEInsert(_self, _args)
905 wasteObject *_self;
906 PyObject *_args;
907{
908 PyObject *_res = NULL;
909 OSErr _err;
910 char *pText__in__;
911 long pText__len__;
912 int pText__in_len__;
913 StScrpHandle hStyles;
914 WESoupHandle hSoup;
915 if (!PyArg_ParseTuple(_args, "s#O&O&",
916 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000917 OptResObj_Convert, &hStyles,
918 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000919 return NULL;
920 pText__len__ = pText__in_len__;
921 _err = WEInsert(pText__in__, pText__len__,
922 hStyles,
923 hSoup,
924 _self->ob_itself);
925 if (_err != noErr) return PyMac_Error(_err);
926 Py_INCREF(Py_None);
927 _res = Py_None;
928 pText__error__: ;
929 return _res;
930}
931
932static PyObject *wasteObj_WEDelete(_self, _args)
933 wasteObject *_self;
934 PyObject *_args;
935{
936 PyObject *_res = NULL;
937 OSErr _err;
938 if (!PyArg_ParseTuple(_args, ""))
939 return NULL;
940 _err = WEDelete(_self->ob_itself);
941 if (_err != noErr) return PyMac_Error(_err);
942 Py_INCREF(Py_None);
943 _res = Py_None;
944 return _res;
945}
946
947static PyObject *wasteObj_WESetStyle(_self, _args)
948 wasteObject *_self;
949 PyObject *_args;
950{
951 PyObject *_res = NULL;
952 OSErr _err;
953 WEStyleMode mode;
954 TextStyle ts;
955 if (!PyArg_ParseTuple(_args, "hO&",
956 &mode,
957 TextStyle_Convert, &ts))
958 return NULL;
959 _err = WESetStyle(mode,
960 &ts,
961 _self->ob_itself);
962 if (_err != noErr) return PyMac_Error(_err);
963 Py_INCREF(Py_None);
964 _res = Py_None;
965 return _res;
966}
967
968static PyObject *wasteObj_WEUseStyleScrap(_self, _args)
969 wasteObject *_self;
970 PyObject *_args;
971{
972 PyObject *_res = NULL;
973 OSErr _err;
974 StScrpHandle hStyles;
975 if (!PyArg_ParseTuple(_args, "O&",
976 ResObj_Convert, &hStyles))
977 return NULL;
978 _err = WEUseStyleScrap(hStyles,
979 _self->ob_itself);
980 if (_err != noErr) return PyMac_Error(_err);
981 Py_INCREF(Py_None);
982 _res = Py_None;
983 return _res;
984}
985
986static PyObject *wasteObj_WEUseText(_self, _args)
987 wasteObject *_self;
988 PyObject *_args;
989{
990 PyObject *_res = NULL;
991 OSErr _err;
992 Handle hText;
993 if (!PyArg_ParseTuple(_args, "O&",
994 ResObj_Convert, &hText))
995 return NULL;
996 _err = WEUseText(hText,
997 _self->ob_itself);
998 if (_err != noErr) return PyMac_Error(_err);
999 Py_INCREF(Py_None);
1000 _res = Py_None;
1001 return _res;
1002}
1003
1004static PyObject *wasteObj_WEUndo(_self, _args)
1005 wasteObject *_self;
1006 PyObject *_args;
1007{
1008 PyObject *_res = NULL;
1009 OSErr _err;
1010 if (!PyArg_ParseTuple(_args, ""))
1011 return NULL;
1012 _err = WEUndo(_self->ob_itself);
1013 if (_err != noErr) return PyMac_Error(_err);
1014 Py_INCREF(Py_None);
1015 _res = Py_None;
1016 return _res;
1017}
1018
1019static PyObject *wasteObj_WEClearUndo(_self, _args)
1020 wasteObject *_self;
1021 PyObject *_args;
1022{
1023 PyObject *_res = NULL;
1024 if (!PyArg_ParseTuple(_args, ""))
1025 return NULL;
1026 WEClearUndo(_self->ob_itself);
1027 Py_INCREF(Py_None);
1028 _res = Py_None;
1029 return _res;
1030}
1031
1032static PyObject *wasteObj_WEGetUndoInfo(_self, _args)
1033 wasteObject *_self;
1034 PyObject *_args;
1035{
1036 PyObject *_res = NULL;
1037 WEActionKind _rv;
1038 Boolean redoFlag;
1039 if (!PyArg_ParseTuple(_args, ""))
1040 return NULL;
1041 _rv = WEGetUndoInfo(&redoFlag,
1042 _self->ob_itself);
1043 _res = Py_BuildValue("hb",
1044 _rv,
1045 redoFlag);
1046 return _res;
1047}
1048
1049static PyObject *wasteObj_WEIsTyping(_self, _args)
1050 wasteObject *_self;
1051 PyObject *_args;
1052{
1053 PyObject *_res = NULL;
1054 Boolean _rv;
1055 if (!PyArg_ParseTuple(_args, ""))
1056 return NULL;
1057 _rv = WEIsTyping(_self->ob_itself);
1058 _res = Py_BuildValue("b",
1059 _rv);
1060 return _res;
1061}
1062
1063static PyObject *wasteObj_WEGetModCount(_self, _args)
1064 wasteObject *_self;
1065 PyObject *_args;
1066{
1067 PyObject *_res = NULL;
1068 unsigned long _rv;
1069 if (!PyArg_ParseTuple(_args, ""))
1070 return NULL;
1071 _rv = WEGetModCount(_self->ob_itself);
1072 _res = Py_BuildValue("l",
1073 _rv);
1074 return _res;
1075}
1076
1077static PyObject *wasteObj_WEResetModCount(_self, _args)
1078 wasteObject *_self;
1079 PyObject *_args;
1080{
1081 PyObject *_res = NULL;
1082 if (!PyArg_ParseTuple(_args, ""))
1083 return NULL;
1084 WEResetModCount(_self->ob_itself);
1085 Py_INCREF(Py_None);
1086 _res = Py_None;
1087 return _res;
1088}
1089
1090static PyObject *wasteObj_WEInsertObject(_self, _args)
1091 wasteObject *_self;
1092 PyObject *_args;
1093{
1094 PyObject *_res = NULL;
1095 OSErr _err;
1096 FlavorType objectType;
1097 Handle objectDataHandle;
1098 Point objectSize;
1099 if (!PyArg_ParseTuple(_args, "O&O&O&",
1100 PyMac_GetOSType, &objectType,
1101 ResObj_Convert, &objectDataHandle,
1102 PyMac_GetPoint, &objectSize))
1103 return NULL;
1104 _err = WEInsertObject(objectType,
1105 objectDataHandle,
1106 objectSize,
1107 _self->ob_itself);
1108 if (_err != noErr) return PyMac_Error(_err);
1109 Py_INCREF(Py_None);
1110 _res = Py_None;
1111 return _res;
1112}
1113
1114static PyObject *wasteObj_WEGetSelectedObject(_self, _args)
1115 wasteObject *_self;
1116 PyObject *_args;
1117{
1118 PyObject *_res = NULL;
1119 OSErr _err;
1120 WEObjectReference obj;
1121 if (!PyArg_ParseTuple(_args, ""))
1122 return NULL;
1123 _err = WEGetSelectedObject(&obj,
1124 _self->ob_itself);
1125 if (_err != noErr) return PyMac_Error(_err);
1126 _res = Py_BuildValue("O&",
1127 WEOObj_New, obj);
1128 return _res;
1129}
1130
1131static PyObject *wasteObj_WEFindNextObject(_self, _args)
1132 wasteObject *_self;
1133 PyObject *_args;
1134{
1135 PyObject *_res = NULL;
1136 long _rv;
1137 long offset;
1138 WEObjectReference obj;
1139 if (!PyArg_ParseTuple(_args, "l",
1140 &offset))
1141 return NULL;
1142 _rv = WEFindNextObject(offset,
1143 &obj,
1144 _self->ob_itself);
1145 _res = Py_BuildValue("lO&",
1146 _rv,
1147 WEOObj_New, obj);
1148 return _res;
1149}
1150
1151static PyObject *wasteObj_WEUseSoup(_self, _args)
1152 wasteObject *_self;
1153 PyObject *_args;
1154{
1155 PyObject *_res = NULL;
1156 OSErr _err;
1157 WESoupHandle hSoup;
1158 if (!PyArg_ParseTuple(_args, "O&",
1159 ResObj_Convert, &hSoup))
1160 return NULL;
1161 _err = WEUseSoup(hSoup,
1162 _self->ob_itself);
1163 if (_err != noErr) return PyMac_Error(_err);
1164 Py_INCREF(Py_None);
1165 _res = Py_None;
1166 return _res;
1167}
1168
1169static PyObject *wasteObj_WECut(_self, _args)
1170 wasteObject *_self;
1171 PyObject *_args;
1172{
1173 PyObject *_res = NULL;
1174 OSErr _err;
1175 if (!PyArg_ParseTuple(_args, ""))
1176 return NULL;
1177 _err = WECut(_self->ob_itself);
1178 if (_err != noErr) return PyMac_Error(_err);
1179 Py_INCREF(Py_None);
1180 _res = Py_None;
1181 return _res;
1182}
1183
1184static PyObject *wasteObj_WECopy(_self, _args)
1185 wasteObject *_self;
1186 PyObject *_args;
1187{
1188 PyObject *_res = NULL;
1189 OSErr _err;
1190 if (!PyArg_ParseTuple(_args, ""))
1191 return NULL;
1192 _err = WECopy(_self->ob_itself);
1193 if (_err != noErr) return PyMac_Error(_err);
1194 Py_INCREF(Py_None);
1195 _res = Py_None;
1196 return _res;
1197}
1198
1199static PyObject *wasteObj_WEPaste(_self, _args)
1200 wasteObject *_self;
1201 PyObject *_args;
1202{
1203 PyObject *_res = NULL;
1204 OSErr _err;
1205 if (!PyArg_ParseTuple(_args, ""))
1206 return NULL;
1207 _err = WEPaste(_self->ob_itself);
1208 if (_err != noErr) return PyMac_Error(_err);
1209 Py_INCREF(Py_None);
1210 _res = Py_None;
1211 return _res;
1212}
1213
1214static PyObject *wasteObj_WECanPaste(_self, _args)
1215 wasteObject *_self;
1216 PyObject *_args;
1217{
1218 PyObject *_res = NULL;
1219 Boolean _rv;
1220 if (!PyArg_ParseTuple(_args, ""))
1221 return NULL;
1222 _rv = WECanPaste(_self->ob_itself);
1223 _res = Py_BuildValue("b",
1224 _rv);
1225 return _res;
1226}
1227
1228static PyObject *wasteObj_WEGetHiliteRgn(_self, _args)
1229 wasteObject *_self;
1230 PyObject *_args;
1231{
1232 PyObject *_res = NULL;
1233 RgnHandle _rv;
1234 long rangeStart;
1235 long rangeEnd;
1236 if (!PyArg_ParseTuple(_args, "ll",
1237 &rangeStart,
1238 &rangeEnd))
1239 return NULL;
1240 _rv = WEGetHiliteRgn(rangeStart,
1241 rangeEnd,
1242 _self->ob_itself);
1243 _res = Py_BuildValue("O&",
1244 ResObj_New, _rv);
1245 return _res;
1246}
1247
1248static PyObject *wasteObj_WECharByte(_self, _args)
1249 wasteObject *_self;
1250 PyObject *_args;
1251{
1252 PyObject *_res = NULL;
1253 short _rv;
1254 long offset;
1255 if (!PyArg_ParseTuple(_args, "l",
1256 &offset))
1257 return NULL;
1258 _rv = WECharByte(offset,
1259 _self->ob_itself);
1260 _res = Py_BuildValue("h",
1261 _rv);
1262 return _res;
1263}
1264
1265static PyObject *wasteObj_WECharType(_self, _args)
1266 wasteObject *_self;
1267 PyObject *_args;
1268{
1269 PyObject *_res = NULL;
1270 short _rv;
1271 long offset;
1272 if (!PyArg_ParseTuple(_args, "l",
1273 &offset))
1274 return NULL;
1275 _rv = WECharType(offset,
1276 _self->ob_itself);
1277 _res = Py_BuildValue("h",
1278 _rv);
1279 return _res;
1280}
1281
1282static PyObject *wasteObj_WEStopInlineSession(_self, _args)
1283 wasteObject *_self;
1284 PyObject *_args;
1285{
1286 PyObject *_res = NULL;
1287 if (!PyArg_ParseTuple(_args, ""))
1288 return NULL;
1289 WEStopInlineSession(_self->ob_itself);
1290 Py_INCREF(Py_None);
1291 _res = Py_None;
1292 return _res;
1293}
1294
1295static PyObject *wasteObj_WEFeatureFlag(_self, _args)
1296 wasteObject *_self;
1297 PyObject *_args;
1298{
1299 PyObject *_res = NULL;
1300 short _rv;
1301 short feature;
1302 short action;
1303 if (!PyArg_ParseTuple(_args, "hh",
1304 &feature,
1305 &action))
1306 return NULL;
1307 _rv = WEFeatureFlag(feature,
1308 action,
1309 _self->ob_itself);
1310 _res = Py_BuildValue("h",
1311 _rv);
1312 return _res;
1313}
1314
1315static PyMethodDef wasteObj_methods[] = {
1316 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1317 "() -> (Handle _rv)"},
1318 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
1319 "(long offset) -> (short _rv)"},
1320 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
1321 "() -> (long _rv)"},
1322 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
1323 "() -> (long _rv)"},
1324 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
1325 "(long startLine, long endLine) -> (long _rv)"},
1326 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
1327 "() -> (long selStart, long selEnd)"},
1328 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1329 "() -> (LongRect destRect)"},
1330 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1331 "() -> (LongRect viewRect)"},
1332 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1333 "() -> (Boolean _rv)"},
1334 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
1335 "(long offset) -> (long _rv)"},
1336 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
1337 "(long lineNo) -> (long lineStart, long lineEnd)"},
1338 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
1339 "(long selStart, long selEnd) -> None"},
1340 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1341 "(LongRect destRect) -> None"},
1342 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1343 "(LongRect viewRect) -> None"},
1344 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001345 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001346 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
1347 "(long offset) -> (WERunInfo runInfo)"},
1348 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
1349 "(LongPt thePoint) -> (long _rv, char edge)"},
1350 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
1351 "(long offset) -> (LongPt thePoint, short lineHeight)"},
1352 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
1353 "(long offset, char edge) -> (long wordStart, long wordEnd)"},
1354 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
1355 "(long offset, char edge) -> (long lineStart, long lineEnd)"},
1356 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
1357 "(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1358 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1359 "() -> (WEAlignment _rv)"},
1360 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1361 "(WEAlignment alignment) -> None"},
1362 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1363 "() -> None"},
1364 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1365 "(RgnHandle updateRgn) -> None"},
1366 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
1367 "(long hOffset, long vOffset) -> None"},
1368 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1369 "() -> None"},
1370 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1371 "() -> None"},
1372 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1373 "() -> None"},
1374 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
1375 "(short key, EventModifiers modifiers) -> None"},
1376 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
1377 "(Point hitPt, EventModifiers modifiers, unsigned long clickTime) -> None"},
1378 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1379 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1380 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
1381 "() -> (unsigned long maxSleep)"},
1382 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1383 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1384 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1385 "() -> None"},
1386 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1387 "(WEStyleMode mode, TextStyle ts) -> None"},
1388 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1389 "(StScrpHandle hStyles) -> None"},
1390 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1391 "(Handle hText) -> None"},
1392 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1393 "() -> None"},
1394 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1395 "() -> None"},
1396 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1397 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1398 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1399 "() -> (Boolean _rv)"},
1400 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
1401 "() -> (unsigned long _rv)"},
1402 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1403 "() -> None"},
1404 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1405 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1406 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1407 "() -> (WEObjectReference obj)"},
1408 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
1409 "(long offset) -> (long _rv, WEObjectReference obj)"},
1410 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1411 "(WESoupHandle hSoup) -> None"},
1412 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1413 "() -> None"},
1414 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1415 "() -> None"},
1416 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1417 "() -> None"},
1418 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1419 "() -> (Boolean _rv)"},
1420 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
1421 "(long rangeStart, long rangeEnd) -> (RgnHandle _rv)"},
1422 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
1423 "(long offset) -> (short _rv)"},
1424 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
1425 "(long offset) -> (short _rv)"},
1426 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1427 "() -> None"},
1428 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
1429 "(short feature, short action) -> (short _rv)"},
1430 {NULL, NULL, 0}
1431};
1432
1433PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1434
1435static PyObject *wasteObj_getattr(self, name)
1436 wasteObject *self;
1437 char *name;
1438{
1439 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1440}
1441
1442#define wasteObj_setattr NULL
1443
1444PyTypeObject waste_Type = {
1445 PyObject_HEAD_INIT(&PyType_Type)
1446 0, /*ob_size*/
1447 "waste", /*tp_name*/
1448 sizeof(wasteObject), /*tp_basicsize*/
1449 0, /*tp_itemsize*/
1450 /* methods */
1451 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1452 0, /*tp_print*/
1453 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1454 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
1455};
1456
1457/* --------------------- End object type waste ---------------------- */
1458
1459
1460static PyObject *waste_WENew(_self, _args)
1461 PyObject *_self;
1462 PyObject *_args;
1463{
1464 PyObject *_res = NULL;
1465 OSErr _err;
1466 LongRect destRect;
1467 LongRect viewRect;
1468 unsigned long flags;
1469 WEReference we;
1470 if (!PyArg_ParseTuple(_args, "O&O&l",
1471 LongRect_Convert, &destRect,
1472 LongRect_Convert, &viewRect,
1473 &flags))
1474 return NULL;
1475 _err = WENew(&destRect,
1476 &viewRect,
1477 flags,
1478 &we);
1479 if (_err != noErr) return PyMac_Error(_err);
1480 _res = Py_BuildValue("O&",
1481 wasteObj_New, we);
1482 return _res;
1483}
1484
1485static PyObject *waste_WEInstallTSMHandlers(_self, _args)
1486 PyObject *_self;
1487 PyObject *_args;
1488{
1489 PyObject *_res = NULL;
1490 OSErr _err;
1491 if (!PyArg_ParseTuple(_args, ""))
1492 return NULL;
1493 _err = WEInstallTSMHandlers();
1494 if (_err != noErr) return PyMac_Error(_err);
1495 Py_INCREF(Py_None);
1496 _res = Py_None;
1497 return _res;
1498}
1499
1500static PyObject *waste_WERemoveTSMHandlers(_self, _args)
1501 PyObject *_self;
1502 PyObject *_args;
1503{
1504 PyObject *_res = NULL;
1505 OSErr _err;
1506 if (!PyArg_ParseTuple(_args, ""))
1507 return NULL;
1508 _err = WERemoveTSMHandlers();
1509 if (_err != noErr) return PyMac_Error(_err);
1510 Py_INCREF(Py_None);
1511 _res = Py_None;
1512 return _res;
1513}
1514
1515static PyObject *waste_WELongPointToPoint(_self, _args)
1516 PyObject *_self;
1517 PyObject *_args;
1518{
1519 PyObject *_res = NULL;
1520 LongPt lp;
1521 Point p;
1522 if (!PyArg_ParseTuple(_args, "O&",
1523 LongPt_Convert, &lp))
1524 return NULL;
1525 WELongPointToPoint(&lp,
1526 &p);
1527 _res = Py_BuildValue("O&",
1528 PyMac_BuildPoint, p);
1529 return _res;
1530}
1531
1532static PyObject *waste_WEPointToLongPoint(_self, _args)
1533 PyObject *_self;
1534 PyObject *_args;
1535{
1536 PyObject *_res = NULL;
1537 Point p;
1538 LongPt lp;
1539 if (!PyArg_ParseTuple(_args, "O&",
1540 PyMac_GetPoint, &p))
1541 return NULL;
1542 WEPointToLongPoint(p,
1543 &lp);
1544 _res = Py_BuildValue("O&",
1545 LongPt_New, &lp);
1546 return _res;
1547}
1548
1549static PyObject *waste_WESetLongRect(_self, _args)
1550 PyObject *_self;
1551 PyObject *_args;
1552{
1553 PyObject *_res = NULL;
1554 LongRect lr;
1555 long left;
1556 long top;
1557 long right;
1558 long bottom;
1559 if (!PyArg_ParseTuple(_args, "llll",
1560 &left,
1561 &top,
1562 &right,
1563 &bottom))
1564 return NULL;
1565 WESetLongRect(&lr,
1566 left,
1567 top,
1568 right,
1569 bottom);
1570 _res = Py_BuildValue("O&",
1571 LongRect_New, &lr);
1572 return _res;
1573}
1574
1575static PyObject *waste_WELongRectToRect(_self, _args)
1576 PyObject *_self;
1577 PyObject *_args;
1578{
1579 PyObject *_res = NULL;
1580 LongRect lr;
1581 Rect r;
1582 if (!PyArg_ParseTuple(_args, "O&",
1583 LongRect_Convert, &lr))
1584 return NULL;
1585 WELongRectToRect(&lr,
1586 &r);
1587 _res = Py_BuildValue("O&",
1588 PyMac_BuildRect, &r);
1589 return _res;
1590}
1591
1592static PyObject *waste_WERectToLongRect(_self, _args)
1593 PyObject *_self;
1594 PyObject *_args;
1595{
1596 PyObject *_res = NULL;
1597 Rect r;
1598 LongRect lr;
1599 if (!PyArg_ParseTuple(_args, "O&",
1600 PyMac_GetRect, &r))
1601 return NULL;
1602 WERectToLongRect(&r,
1603 &lr);
1604 _res = Py_BuildValue("O&",
1605 LongRect_New, &lr);
1606 return _res;
1607}
1608
1609static PyObject *waste_WEOffsetLongRect(_self, _args)
1610 PyObject *_self;
1611 PyObject *_args;
1612{
1613 PyObject *_res = NULL;
1614 LongRect lr;
1615 long hOffset;
1616 long vOffset;
1617 if (!PyArg_ParseTuple(_args, "ll",
1618 &hOffset,
1619 &vOffset))
1620 return NULL;
1621 WEOffsetLongRect(&lr,
1622 hOffset,
1623 vOffset);
1624 _res = Py_BuildValue("O&",
1625 LongRect_New, &lr);
1626 return _res;
1627}
1628
1629static PyObject *waste_WELongPointInLongRect(_self, _args)
1630 PyObject *_self;
1631 PyObject *_args;
1632{
1633 PyObject *_res = NULL;
1634 Boolean _rv;
1635 LongPt lp;
1636 LongRect lr;
1637 if (!PyArg_ParseTuple(_args, "O&O&",
1638 LongPt_Convert, &lp,
1639 LongRect_Convert, &lr))
1640 return NULL;
1641 _rv = WELongPointInLongRect(&lp,
1642 &lr);
1643 _res = Py_BuildValue("b",
1644 _rv);
1645 return _res;
1646}
1647
1648static PyMethodDef waste_methods[] = {
1649 {"WENew", (PyCFunction)waste_WENew, 1,
1650 "(LongRect destRect, LongRect viewRect, unsigned long flags) -> (WEReference we)"},
1651 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
1652 "() -> None"},
1653 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
1654 "() -> None"},
1655 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
1656 "(LongPt lp) -> (Point p)"},
1657 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
1658 "(Point p) -> (LongPt lp)"},
1659 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
1660 "(long left, long top, long right, long bottom) -> (LongRect lr)"},
1661 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
1662 "(LongRect lr) -> (Rect r)"},
1663 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
1664 "(Rect r) -> (LongRect lr)"},
1665 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
1666 "(long hOffset, long vOffset) -> (LongRect lr)"},
1667 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
1668 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
1669 {NULL, NULL, 0}
1670};
1671
1672
1673
1674
1675void initwaste()
1676{
1677 PyObject *m;
1678 PyObject *d;
1679
1680
1681
1682
1683 m = Py_InitModule("waste", waste_methods);
1684 d = PyModule_GetDict(m);
1685 waste_Error = PyMac_GetOSErrException();
1686 if (waste_Error == NULL ||
1687 PyDict_SetItemString(d, "Error", waste_Error) != 0)
1688 Py_FatalError("can't initialize waste.Error");
1689}
1690
1691/* ======================== End module waste ======================== */
1692