Another batch of updates...
[python/dscho.git] / Mac / Modules / waste / wastemodule.c
blob571a307ef311bd31eaceaecd2c091eb3fb20320b
2 /* ========================== Module waste ========================== */
4 #include "Python.h"
8 #define SystemSevenOrLater 1
10 #include "macglue.h"
11 #include <Memory.h>
12 #include <Dialogs.h>
13 #include <Menus.h>
14 #include <Controls.h>
16 extern PyObject *ResObj_New(Handle);
17 extern int ResObj_Convert(PyObject *, Handle *);
18 extern PyObject *OptResObj_New(Handle);
19 extern int OptResObj_Convert(PyObject *, Handle *);
21 extern PyObject *WinObj_New(WindowPtr);
22 extern int WinObj_Convert(PyObject *, WindowPtr *);
23 extern PyTypeObject Window_Type;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject *DlgObj_New(DialogPtr);
27 extern int DlgObj_Convert(PyObject *, DialogPtr *);
28 extern PyTypeObject Dialog_Type;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject *MenuObj_New(MenuHandle);
32 extern int MenuObj_Convert(PyObject *, MenuHandle *);
34 extern PyObject *CtlObj_New(ControlHandle);
35 extern int CtlObj_Convert(PyObject *, ControlHandle *);
37 extern PyObject *GrafObj_New(GrafPtr);
38 extern int GrafObj_Convert(PyObject *, GrafPtr *);
40 extern PyObject *BMObj_New(BitMapPtr);
41 extern int BMObj_Convert(PyObject *, BitMapPtr *);
43 extern PyObject *WinObj_WhichWindow(WindowPtr);
45 #include <WASTE.h>
46 #include <WEObjectHandlers.h>
48 /* Exported by Qdmodule.c: */
49 extern PyObject *QdRGB_New(RGBColor *);
50 extern int QdRGB_Convert(PyObject *, RGBColor *);
52 /* Forward declaration */
53 staticforward PyObject *WEOObj_New(WEObjectReference);
54 staticforward PyObject *ExistingwasteObj_New(WEReference);
57 ** Parse/generate TextStyle records
59 static
60 PyObject *TextStyle_New(itself)
61 TextStylePtr itself;
64 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
65 &itself->tsColor);
68 static
69 TextStyle_Convert(v, p_itself)
70 PyObject *v;
71 TextStylePtr p_itself;
73 long font, face, size;
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;
84 ** Parse/generate RunInfo records
86 static
87 PyObject *RunInfo_New(itself)
88 WERunInfo *itself;
91 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
92 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
95 /* Conversion of long points and rects */
96 int
97 LongRect_Convert(PyObject *v, LongRect *r)
99 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
102 PyObject *
103 LongRect_New(LongRect *r)
105 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
109 LongPt_Convert(PyObject *v, LongPt *p)
111 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
114 PyObject *
115 LongPt_New(LongPt *p)
117 return Py_BuildValue("(ll)", p->h, p->v);
120 /* Stuff for the callbacks: */
121 static PyObject *callbackdict;
122 WENewObjectUPP upp_new_handler;
123 WEDisposeObjectUPP upp_dispose_handler;
124 WEDrawObjectUPP upp_draw_handler;
125 WEClickObjectUPP upp_click_handler;
127 static OSErr
128 any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
130 FlavorType tp;
131 PyObject *key, *func;
133 if ( args == NULL ) return errAECorruptData;
135 tp = WEGetObjectType(who);
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;
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;
152 return 0;
155 static pascal OSErr
156 my_new_handler(Point *objectSize, WEObjectReference objref)
158 PyObject *args=NULL, *rv=NULL;
159 OSErr err;
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;
167 if ( args ) Py_DECREF(args);
168 if ( rv ) Py_DECREF(rv);
169 return err;
172 static pascal OSErr
173 my_dispose_handler(WEObjectReference objref)
175 PyObject *args=NULL, *rv=NULL;
176 OSErr err;
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;
185 static pascal OSErr
186 my_draw_handler(Rect *destRect, WEObjectReference objref)
188 PyObject *args=NULL, *rv=NULL;
189 OSErr err;
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;
198 static pascal Boolean
199 my_click_handler(Point hitPt, EventModifiers modifiers,
200 unsigned long clickTime, WEObjectReference objref)
202 PyObject *args=NULL, *rv=NULL;
203 int retvalue;
204 OSErr err;
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;
220 static PyObject *waste_Error;
222 /* ------------------------ Object type WEO ------------------------- */
224 PyTypeObject WEO_Type;
226 #define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
228 typedef struct WEOObject {
229 PyObject_HEAD
230 WEObjectReference ob_itself;
231 } WEOObject;
233 PyObject *WEOObj_New(itself)
234 WEObjectReference itself;
236 WEOObject *it;
237 if (itself == NULL) {
238 Py_INCREF(Py_None);
239 return Py_None;
241 it = PyObject_NEW(WEOObject, &WEO_Type);
242 if (it == NULL) return NULL;
243 it->ob_itself = itself;
244 return (PyObject *)it;
246 WEOObj_Convert(v, p_itself)
247 PyObject *v;
248 WEObjectReference *p_itself;
250 if (!WEOObj_Check(v))
252 PyErr_SetString(PyExc_TypeError, "WEO required");
253 return 0;
255 *p_itself = ((WEOObject *)v)->ob_itself;
256 return 1;
259 static void WEOObj_dealloc(self)
260 WEOObject *self;
262 /* Cleanup of self->ob_itself goes here */
263 PyMem_DEL(self);
266 static PyObject *WEOObj_WEGetObjectType(_self, _args)
267 WEOObject *_self;
268 PyObject *_args;
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;
280 static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args)
281 WEOObject *_self;
282 PyObject *_args;
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;
294 static PyObject *WEOObj_WEGetObjectSize(_self, _args)
295 WEOObject *_self;
296 PyObject *_args;
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;
308 static PyObject *WEOObj_WEGetObjectOwner(_self, _args)
309 WEOObject *_self;
310 PyObject *_args;
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;
322 static PyObject *WEOObj_WEGetObjectRefCon(_self, _args)
323 WEOObject *_self;
324 PyObject *_args;
326 PyObject *_res = NULL;
327 SInt32 _rv;
328 if (!PyArg_ParseTuple(_args, ""))
329 return NULL;
330 _rv = WEGetObjectRefCon(_self->ob_itself);
331 _res = Py_BuildValue("l",
332 _rv);
333 return _res;
336 static PyObject *WEOObj_WESetObjectRefCon(_self, _args)
337 WEOObject *_self;
338 PyObject *_args;
340 PyObject *_res = NULL;
341 SInt32 refCon;
342 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;
352 static 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)"},
359 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
360 "() -> (WEReference _rv)"},
361 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
362 "() -> (SInt32 _rv)"},
363 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
364 "(SInt32 refCon) -> None"},
365 {NULL, NULL, 0}
368 PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
370 static PyObject *WEOObj_getattr(self, name)
371 WEOObject *self;
372 char *name;
374 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
377 #define WEOObj_setattr NULL
379 PyTypeObject 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*/
392 /* ---------------------- End object type WEO ----------------------- */
395 /* ----------------------- Object type waste ------------------------ */
397 PyTypeObject waste_Type;
399 #define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
401 typedef struct wasteObject {
402 PyObject_HEAD
403 WEReference ob_itself;
404 } wasteObject;
406 PyObject *wasteObj_New(itself)
407 WEReference itself;
409 wasteObject *it;
410 if (itself == NULL) {
411 PyErr_SetString(waste_Error,"Cannot create null WE");
412 return NULL;
414 it = PyObject_NEW(wasteObject, &waste_Type);
415 if (it == NULL) return NULL;
416 it->ob_itself = itself;
417 WESetInfo(weRefCon, (void *)&it, itself);
418 return (PyObject *)it;
420 wasteObj_Convert(v, p_itself)
421 PyObject *v;
422 WEReference *p_itself;
424 if (!wasteObj_Check(v))
426 PyErr_SetString(PyExc_TypeError, "waste required");
427 return 0;
429 *p_itself = ((wasteObject *)v)->ob_itself;
430 return 1;
433 static void wasteObj_dealloc(self)
434 wasteObject *self;
436 WEDispose(self->ob_itself);
437 PyMem_DEL(self);
440 static PyObject *wasteObj_WEGetText(_self, _args)
441 wasteObject *_self;
442 PyObject *_args;
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;
454 static PyObject *wasteObj_WEGetChar(_self, _args)
455 wasteObject *_self;
456 PyObject *_args;
458 PyObject *_res = NULL;
459 SInt16 _rv;
460 SInt32 offset;
461 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;
471 static PyObject *wasteObj_WEGetTextLength(_self, _args)
472 wasteObject *_self;
473 PyObject *_args;
475 PyObject *_res = NULL;
476 SInt32 _rv;
477 if (!PyArg_ParseTuple(_args, ""))
478 return NULL;
479 _rv = WEGetTextLength(_self->ob_itself);
480 _res = Py_BuildValue("l",
481 _rv);
482 return _res;
485 static PyObject *wasteObj_WECountLines(_self, _args)
486 wasteObject *_self;
487 PyObject *_args;
489 PyObject *_res = NULL;
490 SInt32 _rv;
491 if (!PyArg_ParseTuple(_args, ""))
492 return NULL;
493 _rv = WECountLines(_self->ob_itself);
494 _res = Py_BuildValue("l",
495 _rv);
496 return _res;
499 static PyObject *wasteObj_WEGetHeight(_self, _args)
500 wasteObject *_self;
501 PyObject *_args;
503 PyObject *_res = NULL;
504 SInt32 _rv;
505 SInt32 startLine;
506 SInt32 endLine;
507 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;
519 static PyObject *wasteObj_WEGetSelection(_self, _args)
520 wasteObject *_self;
521 PyObject *_args;
523 PyObject *_res = NULL;
524 SInt32 selStart;
525 SInt32 selEnd;
526 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;
537 static PyObject *wasteObj_WEGetDestRect(_self, _args)
538 wasteObject *_self;
539 PyObject *_args;
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;
552 static PyObject *wasteObj_WEGetViewRect(_self, _args)
553 wasteObject *_self;
554 PyObject *_args;
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;
567 static PyObject *wasteObj_WEIsActive(_self, _args)
568 wasteObject *_self;
569 PyObject *_args;
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;
581 static PyObject *wasteObj_WEOffsetToLine(_self, _args)
582 wasteObject *_self;
583 PyObject *_args;
585 PyObject *_res = NULL;
586 SInt32 _rv;
587 SInt32 offset;
588 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;
598 static PyObject *wasteObj_WEGetLineRange(_self, _args)
599 wasteObject *_self;
600 PyObject *_args;
602 PyObject *_res = NULL;
603 SInt32 lineNo;
604 SInt32 lineStart;
605 SInt32 lineEnd;
606 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;
619 static PyObject *wasteObj_WEGetClickCount(_self, _args)
620 wasteObject *_self;
621 PyObject *_args;
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;
633 static PyObject *wasteObj_WESetSelection(_self, _args)
634 wasteObject *_self;
635 PyObject *_args;
637 PyObject *_res = NULL;
638 SInt32 selStart;
639 SInt32 selEnd;
640 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;
652 static PyObject *wasteObj_WESetDestRect(_self, _args)
653 wasteObject *_self;
654 PyObject *_args;
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;
668 static PyObject *wasteObj_WESetViewRect(_self, _args)
669 wasteObject *_self;
670 PyObject *_args;
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;
684 static PyObject *wasteObj_WEContinuousStyle(_self, _args)
685 wasteObject *_self;
686 PyObject *_args;
688 PyObject *_res = NULL;
689 Boolean _rv;
690 WEStyleMode mode;
691 TextStyle ts;
692 if (!PyArg_ParseTuple(_args, "h",
693 &mode))
694 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;
705 static PyObject *wasteObj_WEGetRunInfo(_self, _args)
706 wasteObject *_self;
707 PyObject *_args;
709 PyObject *_res = NULL;
710 SInt32 offset;
711 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;
723 static PyObject *wasteObj_WEGetOffset(_self, _args)
724 wasteObject *_self;
725 PyObject *_args;
727 PyObject *_res = NULL;
728 SInt32 _rv;
729 LongPt thePoint;
730 WEEdge edge;
731 if (!PyArg_ParseTuple(_args, "O&",
732 LongPt_Convert, &thePoint))
733 return NULL;
734 _rv = WEGetOffset(&thePoint,
735 &edge,
736 _self->ob_itself);
737 _res = Py_BuildValue("lb",
738 _rv,
739 edge);
740 return _res;
743 static PyObject *wasteObj_WEGetPoint(_self, _args)
744 wasteObject *_self;
745 PyObject *_args;
747 PyObject *_res = NULL;
748 SInt32 offset;
749 SInt16 direction;
750 LongPt thePoint;
751 SInt16 lineHeight;
752 if (!PyArg_ParseTuple(_args, "lh",
753 &offset,
754 &direction))
755 return NULL;
756 WEGetPoint(offset,
757 direction,
758 &thePoint,
759 &lineHeight,
760 _self->ob_itself);
761 _res = Py_BuildValue("O&h",
762 LongPt_New, &thePoint,
763 lineHeight);
764 return _res;
767 static PyObject *wasteObj_WEFindWord(_self, _args)
768 wasteObject *_self;
769 PyObject *_args;
771 PyObject *_res = NULL;
772 SInt32 offset;
773 WEEdge edge;
774 SInt32 wordStart;
775 SInt32 wordEnd;
776 if (!PyArg_ParseTuple(_args, "lb",
777 &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;
791 static PyObject *wasteObj_WEFindLine(_self, _args)
792 wasteObject *_self;
793 PyObject *_args;
795 PyObject *_res = NULL;
796 SInt32 offset;
797 WEEdge edge;
798 SInt32 lineStart;
799 SInt32 lineEnd;
800 if (!PyArg_ParseTuple(_args, "lb",
801 &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;
815 static PyObject *wasteObj_WECopyRange(_self, _args)
816 wasteObject *_self;
817 PyObject *_args;
819 PyObject *_res = NULL;
820 OSErr _err;
821 SInt32 rangeStart;
822 SInt32 rangeEnd;
823 Handle hText;
824 StScrpHandle hStyles;
825 WESoupHandle hSoup;
826 if (!PyArg_ParseTuple(_args, "llO&O&O&",
827 &rangeStart,
828 &rangeEnd,
829 OptResObj_Convert, &hText,
830 OptResObj_Convert, &hStyles,
831 OptResObj_Convert, &hSoup))
832 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;
845 static PyObject *wasteObj_WEGetAlignment(_self, _args)
846 wasteObject *_self;
847 PyObject *_args;
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;
859 static PyObject *wasteObj_WESetAlignment(_self, _args)
860 wasteObject *_self;
861 PyObject *_args;
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;
875 static PyObject *wasteObj_WECalText(_self, _args)
876 wasteObject *_self;
877 PyObject *_args;
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;
890 static PyObject *wasteObj_WEUpdate(_self, _args)
891 wasteObject *_self;
892 PyObject *_args;
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;
906 static PyObject *wasteObj_WEScroll(_self, _args)
907 wasteObject *_self;
908 PyObject *_args;
910 PyObject *_res = NULL;
911 SInt32 hOffset;
912 SInt32 vOffset;
913 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;
925 static PyObject *wasteObj_WESelView(_self, _args)
926 wasteObject *_self;
927 PyObject *_args;
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;
938 static PyObject *wasteObj_WEActivate(_self, _args)
939 wasteObject *_self;
940 PyObject *_args;
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;
951 static PyObject *wasteObj_WEDeactivate(_self, _args)
952 wasteObject *_self;
953 PyObject *_args;
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;
964 static PyObject *wasteObj_WEKey(_self, _args)
965 wasteObject *_self;
966 PyObject *_args;
968 PyObject *_res = NULL;
969 SInt16 key;
970 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;
983 static PyObject *wasteObj_WEClick(_self, _args)
984 wasteObject *_self;
985 PyObject *_args;
987 PyObject *_res = NULL;
988 Point hitPt;
989 EventModifiers modifiers;
990 UInt32 clickTime;
991 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;
1005 static PyObject *wasteObj_WEAdjustCursor(_self, _args)
1006 wasteObject *_self;
1007 PyObject *_args;
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;
1025 static PyObject *wasteObj_WEIdle(_self, _args)
1026 wasteObject *_self;
1027 PyObject *_args;
1029 PyObject *_res = NULL;
1030 UInt32 maxSleep;
1031 if (!PyArg_ParseTuple(_args, ""))
1032 return NULL;
1033 WEIdle(&maxSleep,
1034 _self->ob_itself);
1035 _res = Py_BuildValue("l",
1036 maxSleep);
1037 return _res;
1040 static PyObject *wasteObj_WEInsert(_self, _args)
1041 wasteObject *_self;
1042 PyObject *_args;
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__,
1053 OptResObj_Convert, &hStyles,
1054 OptResObj_Convert, &hSoup))
1055 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;
1068 static PyObject *wasteObj_WEDelete(_self, _args)
1069 wasteObject *_self;
1070 PyObject *_args;
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;
1083 static PyObject *wasteObj_WESetStyle(_self, _args)
1084 wasteObject *_self;
1085 PyObject *_args;
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;
1104 static PyObject *wasteObj_WEUseStyleScrap(_self, _args)
1105 wasteObject *_self;
1106 PyObject *_args;
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;
1122 static PyObject *wasteObj_WEUseText(_self, _args)
1123 wasteObject *_self;
1124 PyObject *_args;
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;
1140 static PyObject *wasteObj_WEUndo(_self, _args)
1141 wasteObject *_self;
1142 PyObject *_args;
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;
1155 static PyObject *wasteObj_WEClearUndo(_self, _args)
1156 wasteObject *_self;
1157 PyObject *_args;
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;
1168 static PyObject *wasteObj_WEGetUndoInfo(_self, _args)
1169 wasteObject *_self;
1170 PyObject *_args;
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;
1185 static PyObject *wasteObj_WEIsTyping(_self, _args)
1186 wasteObject *_self;
1187 PyObject *_args;
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;
1199 static PyObject *wasteObj_WEGetModCount(_self, _args)
1200 wasteObject *_self;
1201 PyObject *_args;
1203 PyObject *_res = NULL;
1204 UInt32 _rv;
1205 if (!PyArg_ParseTuple(_args, ""))
1206 return NULL;
1207 _rv = WEGetModCount(_self->ob_itself);
1208 _res = Py_BuildValue("l",
1209 _rv);
1210 return _res;
1213 static PyObject *wasteObj_WEResetModCount(_self, _args)
1214 wasteObject *_self;
1215 PyObject *_args;
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;
1226 static PyObject *wasteObj_WEInsertObject(_self, _args)
1227 wasteObject *_self;
1228 PyObject *_args;
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;
1250 static PyObject *wasteObj_WEGetSelectedObject(_self, _args)
1251 wasteObject *_self;
1252 PyObject *_args;
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;
1267 static PyObject *wasteObj_WEFindNextObject(_self, _args)
1268 wasteObject *_self;
1269 PyObject *_args;
1271 PyObject *_res = NULL;
1272 SInt32 _rv;
1273 SInt32 offset;
1274 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;
1287 static PyObject *wasteObj_WEUseSoup(_self, _args)
1288 wasteObject *_self;
1289 PyObject *_args;
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;
1305 static PyObject *wasteObj_WECut(_self, _args)
1306 wasteObject *_self;
1307 PyObject *_args;
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;
1320 static PyObject *wasteObj_WECopy(_self, _args)
1321 wasteObject *_self;
1322 PyObject *_args;
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;
1335 static PyObject *wasteObj_WEPaste(_self, _args)
1336 wasteObject *_self;
1337 PyObject *_args;
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;
1350 static PyObject *wasteObj_WECanPaste(_self, _args)
1351 wasteObject *_self;
1352 PyObject *_args;
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;
1364 static PyObject *wasteObj_WEGetHiliteRgn(_self, _args)
1365 wasteObject *_self;
1366 PyObject *_args;
1368 PyObject *_res = NULL;
1369 RgnHandle _rv;
1370 SInt32 rangeStart;
1371 SInt32 rangeEnd;
1372 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;
1384 static PyObject *wasteObj_WECharByte(_self, _args)
1385 wasteObject *_self;
1386 PyObject *_args;
1388 PyObject *_res = NULL;
1389 SInt16 _rv;
1390 SInt32 offset;
1391 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;
1401 static PyObject *wasteObj_WECharType(_self, _args)
1402 wasteObject *_self;
1403 PyObject *_args;
1405 PyObject *_res = NULL;
1406 SInt16 _rv;
1407 SInt32 offset;
1408 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;
1418 static PyObject *wasteObj_WEStopInlineSession(_self, _args)
1419 wasteObject *_self;
1420 PyObject *_args;
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;
1431 static PyObject *wasteObj_WEFeatureFlag(_self, _args)
1432 wasteObject *_self;
1433 PyObject *_args;
1435 PyObject *_res = NULL;
1436 SInt16 _rv;
1437 SInt16 feature;
1438 SInt16 action;
1439 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;
1451 static PyMethodDef wasteObj_methods[] = {
1452 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1453 "() -> (Handle _rv)"},
1454 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
1455 "(SInt32 offset) -> (SInt16 _rv)"},
1456 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
1457 "() -> (SInt32 _rv)"},
1458 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
1459 "() -> (SInt32 _rv)"},
1460 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
1461 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
1462 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
1463 "() -> (SInt32 selStart, SInt32 selEnd)"},
1464 {"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,
1471 "(SInt32 offset) -> (SInt32 _rv)"},
1472 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
1473 "(SInt32 lineNo) -> (SInt32 lineStart, SInt32 lineEnd)"},
1474 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1475 "() -> (UInt16 _rv)"},
1476 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
1477 "(SInt32 selStart, SInt32 selEnd) -> None"},
1478 {"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,
1483 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
1484 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
1485 "(SInt32 offset) -> (WERunInfo runInfo)"},
1486 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
1487 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
1488 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
1489 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
1490 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
1491 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
1492 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
1493 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
1494 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
1495 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1496 {"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,
1505 "(SInt32 hOffset, SInt32 vOffset) -> None"},
1506 {"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,
1513 "(SInt16 key, EventModifiers modifiers) -> None"},
1514 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
1515 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
1516 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1517 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1518 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
1519 "() -> (UInt32 maxSleep)"},
1520 {"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,
1539 "() -> (UInt32 _rv)"},
1540 {"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,
1547 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
1548 {"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,
1559 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
1560 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
1561 "(SInt32 offset) -> (SInt16 _rv)"},
1562 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
1563 "(SInt32 offset) -> (SInt16 _rv)"},
1564 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1565 "() -> None"},
1566 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
1567 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
1568 {NULL, NULL, 0}
1571 PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1573 static PyObject *wasteObj_getattr(self, name)
1574 wasteObject *self;
1575 char *name;
1577 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1580 #define wasteObj_setattr NULL
1582 PyTypeObject 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*/
1595 /* --------------------- End object type waste ---------------------- */
1598 static PyObject *waste_WENew(_self, _args)
1599 PyObject *_self;
1600 PyObject *_args;
1602 PyObject *_res = NULL;
1603 OSErr _err;
1604 LongRect destRect;
1605 LongRect viewRect;
1606 UInt32 flags;
1607 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;
1623 static PyObject *waste_WEInstallTSMHandlers(_self, _args)
1624 PyObject *_self;
1625 PyObject *_args;
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;
1638 static PyObject *waste_WERemoveTSMHandlers(_self, _args)
1639 PyObject *_self;
1640 PyObject *_args;
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;
1653 static PyObject *waste_WELongPointToPoint(_self, _args)
1654 PyObject *_self;
1655 PyObject *_args;
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;
1670 static PyObject *waste_WEPointToLongPoint(_self, _args)
1671 PyObject *_self;
1672 PyObject *_args;
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;
1687 static PyObject *waste_WESetLongRect(_self, _args)
1688 PyObject *_self;
1689 PyObject *_args;
1691 PyObject *_res = NULL;
1692 LongRect lr;
1693 SInt32 left;
1694 SInt32 top;
1695 SInt32 right;
1696 SInt32 bottom;
1697 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;
1713 static PyObject *waste_WELongRectToRect(_self, _args)
1714 PyObject *_self;
1715 PyObject *_args;
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;
1730 static PyObject *waste_WERectToLongRect(_self, _args)
1731 PyObject *_self;
1732 PyObject *_args;
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;
1747 static PyObject *waste_WEOffsetLongRect(_self, _args)
1748 PyObject *_self;
1749 PyObject *_args;
1751 PyObject *_res = NULL;
1752 LongRect lr;
1753 SInt32 hOffset;
1754 SInt32 vOffset;
1755 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;
1767 static PyObject *waste_WELongPointInLongRect(_self, _args)
1768 PyObject *_self;
1769 PyObject *_args;
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;
1786 static PyObject *waste_STDObjectHandlers(_self, _args)
1787 PyObject *_self;
1788 PyObject *_args;
1790 PyObject *_res = NULL;
1792 OSErr err;
1793 // install the sample object handlers for pictures and sounds
1794 #define kTypePicture 'PICT'
1795 #define kTypeSound 'snd '
1797 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
1799 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
1800 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
1801 goto cleanup;
1803 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
1804 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
1805 goto cleanup;
1807 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
1808 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
1809 goto cleanup;
1811 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
1812 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
1813 goto cleanup;
1815 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
1816 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
1817 goto cleanup;
1819 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
1820 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
1821 goto cleanup;
1822 Py_INCREF(Py_None);
1823 return Py_None;
1825 cleanup:
1826 return PyMac_Error(err);
1830 static PyObject *waste_WEInstallObjectHandler(_self, _args)
1831 PyObject *_self;
1832 PyObject *_args;
1834 PyObject *_res = NULL;
1836 OSErr err;
1837 FlavorType objectType;
1838 WESelector selector;
1839 PyObject *py_handler;
1840 UniversalProcPtr handler;
1841 WEReference we = NULL;
1842 PyObject *key;
1845 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
1846 PyMac_GetOSType, &objectType,
1847 PyMac_GetOSType, &selector,
1848 &py_handler,
1849 ExistingwasteObj_New, &we) ) return NULL;
1851 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;
1855 else return PyMac_Error(weUndefinedSelectorErr);
1857 if ((key = Py_BuildValue("O&O&",
1858 PyMac_BuildOSType, objectType,
1859 PyMac_BuildOSType, selector)) == NULL )
1860 return NULL;
1862 PyDict_SetItem(callbackdict, key, py_handler);
1864 err = WEInstallObjectHandler(objectType, selector, handler, we);
1865 if ( err ) return PyMac_Error(err);
1866 Py_INCREF(Py_None);
1867 return Py_None;
1871 static PyMethodDef waste_methods[] = {
1872 {"WENew", (PyCFunction)waste_WENew, 1,
1873 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
1874 {"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,
1883 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
1884 {"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,
1889 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
1890 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
1891 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
1892 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
1893 NULL},
1894 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
1895 NULL},
1896 {NULL, NULL, 0}
1901 /* Return the object corresponding to the window, or NULL */
1903 PyObject *
1904 ExistingwasteObj_New(w)
1905 WEReference w;
1907 PyObject *it = NULL;
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;
1920 void initwaste()
1922 PyObject *m;
1923 PyObject *d;
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");
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);
1939 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
1940 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
1941 upp_click_handler = NewWEClickObjectProc(my_click_handler);
1946 /* ======================== End module waste ======================== */