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