2 /* ========================== Module waste ========================== */
8 #include "pymactoolbox.h"
10 /* Macro to test whether a weak-loaded CFM function exists */
11 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
12 PyErr_SetString(PyExc_NotImplementedError, \
13 "Not available in this shared library/OS version"); \
19 #include <WEObjectHandlers.h>
22 /* Exported by Qdmodule.c: */
23 extern PyObject
*QdRGB_New(RGBColor
*);
24 extern int QdRGB_Convert(PyObject
*, RGBColor
*);
26 /* Exported by AEModule.c: */
27 extern PyObject
*AEDesc_New(AppleEvent
*);
28 extern int AEDesc_Convert(PyObject
*, AppleEvent
*);
30 /* Forward declaration */
31 static PyObject
*WEOObj_New(WEObjectReference
);
32 static PyObject
*ExistingwasteObj_New(WEReference
);
35 ** Parse/generate TextStyle records
38 TextStyle_New(TextStylePtr itself
)
41 return Py_BuildValue("lllO&", (long)itself
->tsFont
, (long)itself
->tsFace
, (long)itself
->tsSize
, QdRGB_New
,
46 TextStyle_Convert(PyObject
*v
, TextStylePtr p_itself
)
48 long font
, face
, size
;
50 if( !PyArg_ParseTuple(v
, "lllO&", &font
, &face
, &size
, QdRGB_Convert
, &p_itself
->tsColor
) )
52 p_itself
->tsFont
= (short)font
;
53 p_itself
->tsFace
= (Style
)face
;
54 p_itself
->tsSize
= (short)size
;
59 ** Parse/generate RunInfo records
62 RunInfo_New(WERunInfo
*itself
)
65 return Py_BuildValue("llhhO&O&", itself
->runStart
, itself
->runEnd
, itself
->runHeight
,
66 itself
->runAscent
, TextStyle_New
, &itself
->runStyle
, WEOObj_New
, itself
->runObject
);
69 /* Conversion of long points and rects */
71 LongRect_Convert(PyObject
*v
, LongRect
*r
)
73 return PyArg_Parse(v
, "(llll)", &r
->left
, &r
->top
, &r
->right
, &r
->bottom
);
77 LongRect_New(LongRect
*r
)
79 return Py_BuildValue("(llll)", r
->left
, r
->top
, r
->right
, r
->bottom
);
83 LongPt_Convert(PyObject
*v
, LongPt
*p
)
85 return PyArg_Parse(v
, "(ll)", &p
->h
, &p
->v
);
91 return Py_BuildValue("(ll)", p
->h
, p
->v
);
94 /* Stuff for the callbacks: */
95 static PyObject
*callbackdict
;
96 WENewObjectUPP upp_new_handler
;
97 WEDisposeObjectUPP upp_dispose_handler
;
98 WEDrawObjectUPP upp_draw_handler
;
99 WEClickObjectUPP upp_click_handler
;
102 any_handler(WESelector what
, WEObjectReference who
, PyObject
*args
, PyObject
**rv
)
105 PyObject
*key
, *func
;
107 if ( args
== NULL
) return errAECorruptData
;
109 tp
= WEGetObjectType(who
);
111 if( (key
=Py_BuildValue("O&O&", PyMac_BuildOSType
, tp
, PyMac_BuildOSType
, what
)) == NULL
)
112 return errAECorruptData
;
113 if( (func
= PyDict_GetItem(callbackdict
, key
)) == NULL
) {
115 return errAEHandlerNotFound
;
118 *rv
= PyEval_CallObject(func
, args
);
122 PySys_WriteStderr("--Exception in callback: ");
124 return errAEReplyNotArrived
;
130 my_new_handler(Point
*objectSize
, WEObjectReference objref
)
132 PyObject
*args
=NULL
, *rv
=NULL
;
135 args
=Py_BuildValue("(O&)", WEOObj_New
, objref
);
136 err
= any_handler(weNewHandler
, objref
, args
, &rv
);
138 if (!PyMac_GetPoint(rv
, objectSize
) )
139 err
= errAECoercionFail
;
151 my_dispose_handler(WEObjectReference objref
)
153 PyObject
*args
=NULL
, *rv
=NULL
;
156 args
=Py_BuildValue("(O&)", WEOObj_New
, objref
);
157 err
= any_handler(weDisposeHandler
, objref
, args
, &rv
);
168 my_draw_handler(const Rect
*destRect
, WEObjectReference objref
)
170 PyObject
*args
=NULL
, *rv
=NULL
;
173 args
=Py_BuildValue("O&O&", PyMac_BuildRect
, destRect
, WEOObj_New
, objref
);
174 err
= any_handler(weDrawHandler
, objref
, args
, &rv
);
184 static pascal Boolean
185 my_click_handler(Point hitPt
, EventModifiers modifiers
,
186 unsigned long clickTime
, WEObjectReference objref
)
188 PyObject
*args
=NULL
, *rv
=NULL
;
192 args
=Py_BuildValue("O&llO&", PyMac_BuildPoint
, hitPt
,
193 (long)modifiers
, (long)clickTime
, WEOObj_New
, objref
);
194 err
= any_handler(weClickHandler
, objref
, args
, &rv
);
196 retvalue
= PyInt_AsLong(rv
);
210 static PyObject
*waste_Error
;
212 /* ------------------------ Object type WEO ------------------------- */
214 PyTypeObject WEO_Type
;
216 #define WEOObj_Check(x) ((x)->ob_type == &WEO_Type || PyObject_TypeCheck((x), &WEO_Type))
218 typedef struct WEOObject
{
220 WEObjectReference ob_itself
;
223 PyObject
*WEOObj_New(WEObjectReference itself
)
226 if (itself
== NULL
) {
230 it
= PyObject_NEW(WEOObject
, &WEO_Type
);
231 if (it
== NULL
) return NULL
;
232 it
->ob_itself
= itself
;
233 return (PyObject
*)it
;
235 int WEOObj_Convert(PyObject
*v
, WEObjectReference
*p_itself
)
237 if (!WEOObj_Check(v
))
239 PyErr_SetString(PyExc_TypeError
, "WEO required");
242 *p_itself
= ((WEOObject
*)v
)->ob_itself
;
246 static void WEOObj_dealloc(WEOObject
*self
)
248 /* Cleanup of self->ob_itself goes here */
249 self
->ob_type
->tp_free((PyObject
*)self
);
252 static PyObject
*WEOObj_WEGetObjectType(WEOObject
*_self
, PyObject
*_args
)
254 PyObject
*_res
= NULL
;
256 if (!PyArg_ParseTuple(_args
, ""))
258 _rv
= WEGetObjectType(_self
->ob_itself
);
259 _res
= Py_BuildValue("O&",
260 PyMac_BuildOSType
, _rv
);
264 static PyObject
*WEOObj_WEGetObjectDataHandle(WEOObject
*_self
, PyObject
*_args
)
266 PyObject
*_res
= NULL
;
268 if (!PyArg_ParseTuple(_args
, ""))
270 _rv
= WEGetObjectDataHandle(_self
->ob_itself
);
271 _res
= Py_BuildValue("O&",
276 static PyObject
*WEOObj_WEGetObjectOwner(WEOObject
*_self
, PyObject
*_args
)
278 PyObject
*_res
= NULL
;
280 if (!PyArg_ParseTuple(_args
, ""))
282 _rv
= WEGetObjectOwner(_self
->ob_itself
);
283 _res
= Py_BuildValue("O&",
284 ExistingwasteObj_New
, _rv
);
288 static PyObject
*WEOObj_WEGetObjectOffset(WEOObject
*_self
, PyObject
*_args
)
290 PyObject
*_res
= NULL
;
292 if (!PyArg_ParseTuple(_args
, ""))
294 _rv
= WEGetObjectOffset(_self
->ob_itself
);
295 _res
= Py_BuildValue("l",
300 static PyObject
*WEOObj_WEGetObjectSize(WEOObject
*_self
, PyObject
*_args
)
302 PyObject
*_res
= NULL
;
304 if (!PyArg_ParseTuple(_args
, ""))
306 _rv
= WEGetObjectSize(_self
->ob_itself
);
307 _res
= Py_BuildValue("O&",
308 PyMac_BuildPoint
, _rv
);
312 static PyObject
*WEOObj_WESetObjectSize(WEOObject
*_self
, PyObject
*_args
)
314 PyObject
*_res
= NULL
;
317 if (!PyArg_ParseTuple(_args
, "O&",
318 PyMac_GetPoint
, &inObjectSize
))
320 _err
= WESetObjectSize(_self
->ob_itself
,
322 if (_err
!= noErr
) return PyMac_Error(_err
);
328 static PyObject
*WEOObj_WEGetObjectFrame(WEOObject
*_self
, PyObject
*_args
)
330 PyObject
*_res
= NULL
;
332 LongRect outObjectFrame
;
333 if (!PyArg_ParseTuple(_args
, ""))
335 _err
= WEGetObjectFrame(_self
->ob_itself
,
337 if (_err
!= noErr
) return PyMac_Error(_err
);
338 _res
= Py_BuildValue("O&",
339 LongRect_New
, &outObjectFrame
);
343 static PyObject
*WEOObj_WEGetObjectRefCon(WEOObject
*_self
, PyObject
*_args
)
345 PyObject
*_res
= NULL
;
347 if (!PyArg_ParseTuple(_args
, ""))
349 _rv
= WEGetObjectRefCon(_self
->ob_itself
);
350 _res
= Py_BuildValue("l",
355 static PyObject
*WEOObj_WESetObjectRefCon(WEOObject
*_self
, PyObject
*_args
)
357 PyObject
*_res
= NULL
;
359 if (!PyArg_ParseTuple(_args
, "l",
362 WESetObjectRefCon(_self
->ob_itself
,
369 static PyMethodDef WEOObj_methods
[] = {
370 {"WEGetObjectType", (PyCFunction
)WEOObj_WEGetObjectType
, 1,
371 PyDoc_STR("() -> (FlavorType _rv)")},
372 {"WEGetObjectDataHandle", (PyCFunction
)WEOObj_WEGetObjectDataHandle
, 1,
373 PyDoc_STR("() -> (Handle _rv)")},
374 {"WEGetObjectOwner", (PyCFunction
)WEOObj_WEGetObjectOwner
, 1,
375 PyDoc_STR("() -> (WEReference _rv)")},
376 {"WEGetObjectOffset", (PyCFunction
)WEOObj_WEGetObjectOffset
, 1,
377 PyDoc_STR("() -> (SInt32 _rv)")},
378 {"WEGetObjectSize", (PyCFunction
)WEOObj_WEGetObjectSize
, 1,
379 PyDoc_STR("() -> (Point _rv)")},
380 {"WESetObjectSize", (PyCFunction
)WEOObj_WESetObjectSize
, 1,
381 PyDoc_STR("(Point inObjectSize) -> None")},
382 {"WEGetObjectFrame", (PyCFunction
)WEOObj_WEGetObjectFrame
, 1,
383 PyDoc_STR("() -> (LongRect outObjectFrame)")},
384 {"WEGetObjectRefCon", (PyCFunction
)WEOObj_WEGetObjectRefCon
, 1,
385 PyDoc_STR("() -> (SInt32 _rv)")},
386 {"WESetObjectRefCon", (PyCFunction
)WEOObj_WESetObjectRefCon
, 1,
387 PyDoc_STR("(SInt32 inRefCon) -> None")},
391 #define WEOObj_getsetlist NULL
394 #define WEOObj_compare NULL
396 #define WEOObj_repr NULL
398 #define WEOObj_hash NULL
399 #define WEOObj_tp_init 0
401 #define WEOObj_tp_alloc PyType_GenericAlloc
403 static PyObject
*WEOObj_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
406 WEObjectReference itself
;
407 char *kw
[] = {"itself", 0};
409 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, WEOObj_Convert
, &itself
)) return NULL
;
410 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
411 ((WEOObject
*)self
)->ob_itself
= itself
;
415 #define WEOObj_tp_free PyObject_Del
418 PyTypeObject WEO_Type
= {
419 PyObject_HEAD_INIT(NULL
)
421 "waste.WEO", /*tp_name*/
422 sizeof(WEOObject
), /*tp_basicsize*/
425 (destructor
) WEOObj_dealloc
, /*tp_dealloc*/
427 (getattrfunc
)0, /*tp_getattr*/
428 (setattrfunc
)0, /*tp_setattr*/
429 (cmpfunc
) WEOObj_compare
, /*tp_compare*/
430 (reprfunc
) WEOObj_repr
, /*tp_repr*/
431 (PyNumberMethods
*)0, /* tp_as_number */
432 (PySequenceMethods
*)0, /* tp_as_sequence */
433 (PyMappingMethods
*)0, /* tp_as_mapping */
434 (hashfunc
) WEOObj_hash
, /*tp_hash*/
437 PyObject_GenericGetAttr
, /*tp_getattro*/
438 PyObject_GenericSetAttr
, /*tp_setattro */
440 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
444 0, /*tp_richcompare*/
445 0, /*tp_weaklistoffset*/
448 WEOObj_methods
, /* tp_methods */
450 WEOObj_getsetlist
, /*tp_getset*/
456 WEOObj_tp_init
, /* tp_init */
457 WEOObj_tp_alloc
, /* tp_alloc */
458 WEOObj_tp_new
, /* tp_new */
459 WEOObj_tp_free
, /* tp_free */
462 /* ---------------------- End object type WEO ----------------------- */
465 /* ----------------------- Object type waste ------------------------ */
467 PyTypeObject waste_Type
;
469 #define wasteObj_Check(x) ((x)->ob_type == &waste_Type || PyObject_TypeCheck((x), &waste_Type))
471 typedef struct wasteObject
{
473 WEReference ob_itself
;
476 PyObject
*wasteObj_New(WEReference itself
)
479 if (itself
== NULL
) {
480 PyErr_SetString(waste_Error
,"Cannot create null WE");
483 it
= PyObject_NEW(wasteObject
, &waste_Type
);
484 if (it
== NULL
) return NULL
;
485 it
->ob_itself
= itself
;
486 WESetInfo(weRefCon
, (void *)&it
, itself
);
487 return (PyObject
*)it
;
489 int wasteObj_Convert(PyObject
*v
, WEReference
*p_itself
)
491 if (!wasteObj_Check(v
))
493 PyErr_SetString(PyExc_TypeError
, "waste required");
496 *p_itself
= ((wasteObject
*)v
)->ob_itself
;
500 static void wasteObj_dealloc(wasteObject
*self
)
502 WEDispose(self
->ob_itself
);
503 self
->ob_type
->tp_free((PyObject
*)self
);
506 static PyObject
*wasteObj_WEGetText(wasteObject
*_self
, PyObject
*_args
)
508 PyObject
*_res
= NULL
;
510 if (!PyArg_ParseTuple(_args
, ""))
512 _rv
= WEGetText(_self
->ob_itself
);
513 _res
= Py_BuildValue("O&",
518 static PyObject
*wasteObj_WEGetChar(wasteObject
*_self
, PyObject
*_args
)
520 PyObject
*_res
= NULL
;
523 if (!PyArg_ParseTuple(_args
, "l",
526 _rv
= WEGetChar(inOffset
,
528 _res
= Py_BuildValue("h",
533 static PyObject
*wasteObj_WEGetTextLength(wasteObject
*_self
, PyObject
*_args
)
535 PyObject
*_res
= NULL
;
537 if (!PyArg_ParseTuple(_args
, ""))
539 _rv
= WEGetTextLength(_self
->ob_itself
);
540 _res
= Py_BuildValue("l",
545 static PyObject
*wasteObj_WEGetSelection(wasteObject
*_self
, PyObject
*_args
)
547 PyObject
*_res
= NULL
;
550 if (!PyArg_ParseTuple(_args
, ""))
552 WEGetSelection(&outSelStart
,
555 _res
= Py_BuildValue("ll",
561 static PyObject
*wasteObj_WEGetDestRect(wasteObject
*_self
, PyObject
*_args
)
563 PyObject
*_res
= NULL
;
564 LongRect outDestRect
;
565 if (!PyArg_ParseTuple(_args
, ""))
567 WEGetDestRect(&outDestRect
,
569 _res
= Py_BuildValue("O&",
570 LongRect_New
, &outDestRect
);
574 static PyObject
*wasteObj_WEGetViewRect(wasteObject
*_self
, PyObject
*_args
)
576 PyObject
*_res
= NULL
;
577 LongRect outViewRect
;
578 if (!PyArg_ParseTuple(_args
, ""))
580 WEGetViewRect(&outViewRect
,
582 _res
= Py_BuildValue("O&",
583 LongRect_New
, &outViewRect
);
587 static PyObject
*wasteObj_WEIsActive(wasteObject
*_self
, PyObject
*_args
)
589 PyObject
*_res
= NULL
;
591 if (!PyArg_ParseTuple(_args
, ""))
593 _rv
= WEIsActive(_self
->ob_itself
);
594 _res
= Py_BuildValue("b",
599 static PyObject
*wasteObj_WEGetClickCount(wasteObject
*_self
, PyObject
*_args
)
601 PyObject
*_res
= NULL
;
603 if (!PyArg_ParseTuple(_args
, ""))
605 _rv
= WEGetClickCount(_self
->ob_itself
);
606 _res
= Py_BuildValue("H",
611 static PyObject
*wasteObj_WESetSelection(wasteObject
*_self
, PyObject
*_args
)
613 PyObject
*_res
= NULL
;
616 if (!PyArg_ParseTuple(_args
, "ll",
620 WESetSelection(inSelStart
,
628 static PyObject
*wasteObj_WESetDestRect(wasteObject
*_self
, PyObject
*_args
)
630 PyObject
*_res
= NULL
;
632 if (!PyArg_ParseTuple(_args
, "O&",
633 LongRect_Convert
, &inDestRect
))
635 WESetDestRect(&inDestRect
,
642 static PyObject
*wasteObj_WESetViewRect(wasteObject
*_self
, PyObject
*_args
)
644 PyObject
*_res
= NULL
;
646 if (!PyArg_ParseTuple(_args
, "O&",
647 LongRect_Convert
, &inViewRect
))
649 WESetViewRect(&inViewRect
,
656 static PyObject
*wasteObj_WEContinuousStyle(wasteObject
*_self
, PyObject
*_args
)
658 PyObject
*_res
= NULL
;
661 TextStyle outTextStyle
;
662 if (!PyArg_ParseTuple(_args
, "H",
665 _rv
= WEContinuousStyle(&ioMode
,
668 _res
= Py_BuildValue("bHO&",
671 TextStyle_New
, &outTextStyle
);
675 static PyObject
*wasteObj_WECountRuns(wasteObject
*_self
, PyObject
*_args
)
677 PyObject
*_res
= NULL
;
679 if (!PyArg_ParseTuple(_args
, ""))
681 _rv
= WECountRuns(_self
->ob_itself
);
682 _res
= Py_BuildValue("l",
687 static PyObject
*wasteObj_WEOffsetToRun(wasteObject
*_self
, PyObject
*_args
)
689 PyObject
*_res
= NULL
;
692 if (!PyArg_ParseTuple(_args
, "l",
695 _rv
= WEOffsetToRun(inOffset
,
697 _res
= Py_BuildValue("l",
702 static PyObject
*wasteObj_WEGetRunRange(wasteObject
*_self
, PyObject
*_args
)
704 PyObject
*_res
= NULL
;
705 SInt32 inStyleRunIndex
;
706 SInt32 outStyleRunStart
;
707 SInt32 outStyleRunEnd
;
708 if (!PyArg_ParseTuple(_args
, "l",
711 WEGetRunRange(inStyleRunIndex
,
715 _res
= Py_BuildValue("ll",
721 static PyObject
*wasteObj_WEGetRunInfo(wasteObject
*_self
, PyObject
*_args
)
723 PyObject
*_res
= NULL
;
725 WERunInfo outStyleRunInfo
;
726 if (!PyArg_ParseTuple(_args
, "l",
729 WEGetRunInfo(inOffset
,
732 _res
= Py_BuildValue("O&",
733 RunInfo_New
, &outStyleRunInfo
);
737 static PyObject
*wasteObj_WEGetIndRunInfo(wasteObject
*_self
, PyObject
*_args
)
739 PyObject
*_res
= NULL
;
740 SInt32 inStyleRunIndex
;
741 WERunInfo outStyleRunInfo
;
742 if (!PyArg_ParseTuple(_args
, "l",
745 WEGetIndRunInfo(inStyleRunIndex
,
748 _res
= Py_BuildValue("O&",
749 RunInfo_New
, &outStyleRunInfo
);
753 static PyObject
*wasteObj_WEGetRunDirection(wasteObject
*_self
, PyObject
*_args
)
755 PyObject
*_res
= NULL
;
758 if (!PyArg_ParseTuple(_args
, "l",
761 _rv
= WEGetRunDirection(inOffset
,
763 _res
= Py_BuildValue("b",
768 static PyObject
*wasteObj_WECountParaRuns(wasteObject
*_self
, PyObject
*_args
)
770 PyObject
*_res
= NULL
;
772 if (!PyArg_ParseTuple(_args
, ""))
774 _rv
= WECountParaRuns(_self
->ob_itself
);
775 _res
= Py_BuildValue("l",
780 static PyObject
*wasteObj_WEOffsetToParaRun(wasteObject
*_self
, PyObject
*_args
)
782 PyObject
*_res
= NULL
;
785 if (!PyArg_ParseTuple(_args
, "l",
788 _rv
= WEOffsetToParaRun(inOffset
,
790 _res
= Py_BuildValue("l",
795 static PyObject
*wasteObj_WEGetParaRunRange(wasteObject
*_self
, PyObject
*_args
)
797 PyObject
*_res
= NULL
;
798 SInt32 inParagraphRunIndex
;
799 SInt32 outParagraphRunStart
;
800 SInt32 outParagraphRunEnd
;
801 if (!PyArg_ParseTuple(_args
, "l",
802 &inParagraphRunIndex
))
804 WEGetParaRunRange(inParagraphRunIndex
,
805 &outParagraphRunStart
,
808 _res
= Py_BuildValue("ll",
809 outParagraphRunStart
,
814 static PyObject
*wasteObj_WECountLines(wasteObject
*_self
, PyObject
*_args
)
816 PyObject
*_res
= NULL
;
818 if (!PyArg_ParseTuple(_args
, ""))
820 _rv
= WECountLines(_self
->ob_itself
);
821 _res
= Py_BuildValue("l",
826 static PyObject
*wasteObj_WEOffsetToLine(wasteObject
*_self
, PyObject
*_args
)
828 PyObject
*_res
= NULL
;
831 if (!PyArg_ParseTuple(_args
, "l",
834 _rv
= WEOffsetToLine(inOffset
,
836 _res
= Py_BuildValue("l",
841 static PyObject
*wasteObj_WEGetLineRange(wasteObject
*_self
, PyObject
*_args
)
843 PyObject
*_res
= NULL
;
847 if (!PyArg_ParseTuple(_args
, "l",
850 WEGetLineRange(inLineIndex
,
854 _res
= Py_BuildValue("ll",
860 static PyObject
*wasteObj_WEGetHeight(wasteObject
*_self
, PyObject
*_args
)
862 PyObject
*_res
= NULL
;
864 SInt32 inStartLineIndex
;
865 SInt32 inEndLineIndex
;
866 if (!PyArg_ParseTuple(_args
, "ll",
870 _rv
= WEGetHeight(inStartLineIndex
,
873 _res
= Py_BuildValue("l",
878 static PyObject
*wasteObj_WEGetOffset(wasteObject
*_self
, PyObject
*_args
)
880 PyObject
*_res
= NULL
;
884 if (!PyArg_ParseTuple(_args
, "O&",
885 LongPt_Convert
, &inPoint
))
887 _rv
= WEGetOffset(&inPoint
,
890 _res
= Py_BuildValue("lB",
896 static PyObject
*wasteObj_WEGetPoint(wasteObject
*_self
, PyObject
*_args
)
898 PyObject
*_res
= NULL
;
902 SInt16 outLineHeight
;
903 if (!PyArg_ParseTuple(_args
, "lh",
912 _res
= Py_BuildValue("O&h",
913 LongPt_New
, &outPoint
,
918 static PyObject
*wasteObj_WEFindWord(wasteObject
*_self
, PyObject
*_args
)
920 PyObject
*_res
= NULL
;
925 if (!PyArg_ParseTuple(_args
, "lB",
934 _res
= Py_BuildValue("ll",
940 static PyObject
*wasteObj_WEFindLine(wasteObject
*_self
, PyObject
*_args
)
942 PyObject
*_res
= NULL
;
947 if (!PyArg_ParseTuple(_args
, "lB",
956 _res
= Py_BuildValue("ll",
962 static PyObject
*wasteObj_WEFindParagraph(wasteObject
*_self
, PyObject
*_args
)
964 PyObject
*_res
= NULL
;
967 SInt32 outParagraphStart
;
968 SInt32 outParagraphEnd
;
969 if (!PyArg_ParseTuple(_args
, "lB",
973 WEFindParagraph(inOffset
,
978 _res
= Py_BuildValue("ll",
984 static PyObject
*wasteObj_WEFind(wasteObject
*_self
, PyObject
*_args
)
986 PyObject
*_res
= NULL
;
990 TextEncoding inKeyEncoding
;
991 OptionBits inMatchOptions
;
994 SInt32 outMatchStart
;
996 if (!PyArg_ParseTuple(_args
, "slllll",
1004 _err
= WEFind(inKey
,
1013 if (_err
!= noErr
) return PyMac_Error(_err
);
1014 _res
= Py_BuildValue("ll",
1020 static PyObject
*wasteObj_WEStreamRange(wasteObject
*_self
, PyObject
*_args
)
1022 PyObject
*_res
= NULL
;
1024 SInt32 inRangeStart
;
1026 FlavorType inRequestedType
;
1027 OptionBits inStreamOptions
;
1029 if (!PyArg_ParseTuple(_args
, "llO&lO&",
1032 PyMac_GetOSType
, &inRequestedType
,
1034 ResObj_Convert
, &outData
))
1036 _err
= WEStreamRange(inRangeStart
,
1042 if (_err
!= noErr
) return PyMac_Error(_err
);
1048 static PyObject
*wasteObj_WECopyRange(wasteObject
*_self
, PyObject
*_args
)
1050 PyObject
*_res
= NULL
;
1052 SInt32 inRangeStart
;
1055 StScrpHandle outStyles
;
1056 WESoupHandle outSoup
;
1057 if (!PyArg_ParseTuple(_args
, "llO&O&O&",
1060 OptResObj_Convert
, &outText
,
1061 OptResObj_Convert
, &outStyles
,
1062 OptResObj_Convert
, &outSoup
))
1064 _err
= WECopyRange(inRangeStart
,
1070 if (_err
!= noErr
) return PyMac_Error(_err
);
1076 static PyObject
*wasteObj_WEGetTextRangeAsUnicode(wasteObject
*_self
, PyObject
*_args
)
1078 PyObject
*_res
= NULL
;
1080 SInt32 inRangeStart
;
1082 Handle outUnicodeText
;
1083 Handle ioCharFormat
;
1084 Handle ioParaFormat
;
1085 TextEncodingVariant inUnicodeVariant
;
1086 TextEncodingFormat inTransformationFormat
;
1087 OptionBits inGetOptions
;
1088 if (!PyArg_ParseTuple(_args
, "llO&O&O&lll",
1091 ResObj_Convert
, &outUnicodeText
,
1092 ResObj_Convert
, &ioCharFormat
,
1093 ResObj_Convert
, &ioParaFormat
,
1095 &inTransformationFormat
,
1098 _err
= WEGetTextRangeAsUnicode(inRangeStart
,
1104 inTransformationFormat
,
1107 if (_err
!= noErr
) return PyMac_Error(_err
);
1113 static PyObject
*wasteObj_WEGetAlignment(wasteObject
*_self
, PyObject
*_args
)
1115 PyObject
*_res
= NULL
;
1117 if (!PyArg_ParseTuple(_args
, ""))
1119 _rv
= WEGetAlignment(_self
->ob_itself
);
1120 _res
= Py_BuildValue("B",
1125 static PyObject
*wasteObj_WESetAlignment(wasteObject
*_self
, PyObject
*_args
)
1127 PyObject
*_res
= NULL
;
1128 WEAlignment inAlignment
;
1129 if (!PyArg_ParseTuple(_args
, "B",
1132 WESetAlignment(inAlignment
,
1139 static PyObject
*wasteObj_WEGetDirection(wasteObject
*_self
, PyObject
*_args
)
1141 PyObject
*_res
= NULL
;
1143 if (!PyArg_ParseTuple(_args
, ""))
1145 _rv
= WEGetDirection(_self
->ob_itself
);
1146 _res
= Py_BuildValue("h",
1151 static PyObject
*wasteObj_WESetDirection(wasteObject
*_self
, PyObject
*_args
)
1153 PyObject
*_res
= NULL
;
1154 WEDirection inDirection
;
1155 if (!PyArg_ParseTuple(_args
, "h",
1158 WESetDirection(inDirection
,
1165 static PyObject
*wasteObj_WECalText(wasteObject
*_self
, PyObject
*_args
)
1167 PyObject
*_res
= NULL
;
1169 if (!PyArg_ParseTuple(_args
, ""))
1171 _err
= WECalText(_self
->ob_itself
);
1172 if (_err
!= noErr
) return PyMac_Error(_err
);
1178 static PyObject
*wasteObj_WEUpdate(wasteObject
*_self
, PyObject
*_args
)
1180 PyObject
*_res
= NULL
;
1181 RgnHandle inUpdateRgn
;
1182 if (!PyArg_ParseTuple(_args
, "O&",
1183 ResObj_Convert
, &inUpdateRgn
))
1185 WEUpdate(inUpdateRgn
,
1192 static PyObject
*wasteObj_WEScroll(wasteObject
*_self
, PyObject
*_args
)
1194 PyObject
*_res
= NULL
;
1195 SInt32 inHorizontalOffset
;
1196 SInt32 inVerticalOffset
;
1197 if (!PyArg_ParseTuple(_args
, "ll",
1198 &inHorizontalOffset
,
1201 WEScroll(inHorizontalOffset
,
1209 static PyObject
*wasteObj_WEPinScroll(wasteObject
*_self
, PyObject
*_args
)
1211 PyObject
*_res
= NULL
;
1212 SInt32 inHorizontalOffset
;
1213 SInt32 inVerticalOffset
;
1214 if (!PyArg_ParseTuple(_args
, "ll",
1215 &inHorizontalOffset
,
1218 WEPinScroll(inHorizontalOffset
,
1226 static PyObject
*wasteObj_WESelView(wasteObject
*_self
, PyObject
*_args
)
1228 PyObject
*_res
= NULL
;
1229 if (!PyArg_ParseTuple(_args
, ""))
1231 WESelView(_self
->ob_itself
);
1237 static PyObject
*wasteObj_WEActivate(wasteObject
*_self
, PyObject
*_args
)
1239 PyObject
*_res
= NULL
;
1240 if (!PyArg_ParseTuple(_args
, ""))
1242 WEActivate(_self
->ob_itself
);
1248 static PyObject
*wasteObj_WEDeactivate(wasteObject
*_self
, PyObject
*_args
)
1250 PyObject
*_res
= NULL
;
1251 if (!PyArg_ParseTuple(_args
, ""))
1253 WEDeactivate(_self
->ob_itself
);
1259 static PyObject
*wasteObj_WEKey(wasteObject
*_self
, PyObject
*_args
)
1261 PyObject
*_res
= NULL
;
1262 CharParameter inKey
;
1263 EventModifiers inModifiers
;
1264 if (!PyArg_ParseTuple(_args
, "hH",
1276 static PyObject
*wasteObj_WEClick(wasteObject
*_self
, PyObject
*_args
)
1278 PyObject
*_res
= NULL
;
1280 EventModifiers inModifiers
;
1282 if (!PyArg_ParseTuple(_args
, "O&Hl",
1283 PyMac_GetPoint
, &inHitPoint
,
1296 static PyObject
*wasteObj_WEAdjustCursor(wasteObject
*_self
, PyObject
*_args
)
1298 PyObject
*_res
= NULL
;
1301 RgnHandle ioMouseRgn
;
1302 if (!PyArg_ParseTuple(_args
, "O&O&",
1303 PyMac_GetPoint
, &inMouseLoc
,
1304 ResObj_Convert
, &ioMouseRgn
))
1306 _rv
= WEAdjustCursor(inMouseLoc
,
1309 _res
= Py_BuildValue("b",
1314 static PyObject
*wasteObj_WEIdle(wasteObject
*_self
, PyObject
*_args
)
1316 PyObject
*_res
= NULL
;
1318 if (!PyArg_ParseTuple(_args
, ""))
1320 WEIdle(&outMaxSleep
,
1322 _res
= Py_BuildValue("l",
1327 static PyObject
*wasteObj_WEInsert(wasteObject
*_self
, PyObject
*_args
)
1329 PyObject
*_res
= NULL
;
1331 char *inTextPtr__in__
;
1332 long inTextPtr__len__
;
1333 int inTextPtr__in_len__
;
1334 StScrpHandle inStyles
;
1335 WESoupHandle inSoup
;
1336 if (!PyArg_ParseTuple(_args
, "s#O&O&",
1337 &inTextPtr__in__
, &inTextPtr__in_len__
,
1338 OptResObj_Convert
, &inStyles
,
1339 OptResObj_Convert
, &inSoup
))
1341 inTextPtr__len__
= inTextPtr__in_len__
;
1342 _err
= WEInsert(inTextPtr__in__
, inTextPtr__len__
,
1346 if (_err
!= noErr
) return PyMac_Error(_err
);
1352 static PyObject
*wasteObj_WEInsertFormattedText(wasteObject
*_self
, PyObject
*_args
)
1354 PyObject
*_res
= NULL
;
1356 char *inTextPtr__in__
;
1357 long inTextPtr__len__
;
1358 int inTextPtr__in_len__
;
1359 StScrpHandle inStyles
;
1360 WESoupHandle inSoup
;
1361 Handle inParaFormat
;
1362 Handle inRulerScrap
;
1363 if (!PyArg_ParseTuple(_args
, "s#O&O&O&O&",
1364 &inTextPtr__in__
, &inTextPtr__in_len__
,
1365 OptResObj_Convert
, &inStyles
,
1366 OptResObj_Convert
, &inSoup
,
1367 ResObj_Convert
, &inParaFormat
,
1368 ResObj_Convert
, &inRulerScrap
))
1370 inTextPtr__len__
= inTextPtr__in_len__
;
1371 _err
= WEInsertFormattedText(inTextPtr__in__
, inTextPtr__len__
,
1377 if (_err
!= noErr
) return PyMac_Error(_err
);
1383 static PyObject
*wasteObj_WEDelete(wasteObject
*_self
, PyObject
*_args
)
1385 PyObject
*_res
= NULL
;
1387 if (!PyArg_ParseTuple(_args
, ""))
1389 _err
= WEDelete(_self
->ob_itself
);
1390 if (_err
!= noErr
) return PyMac_Error(_err
);
1396 static PyObject
*wasteObj_WEUseText(wasteObject
*_self
, PyObject
*_args
)
1398 PyObject
*_res
= NULL
;
1401 if (!PyArg_ParseTuple(_args
, "O&",
1402 ResObj_Convert
, &inText
))
1404 _err
= WEUseText(inText
,
1406 if (_err
!= noErr
) return PyMac_Error(_err
);
1412 static PyObject
*wasteObj_WEChangeCase(wasteObject
*_self
, PyObject
*_args
)
1414 PyObject
*_res
= NULL
;
1417 if (!PyArg_ParseTuple(_args
, "h",
1420 _err
= WEChangeCase(inCase
,
1422 if (_err
!= noErr
) return PyMac_Error(_err
);
1428 static PyObject
*wasteObj_WESetOneAttribute(wasteObject
*_self
, PyObject
*_args
)
1430 PyObject
*_res
= NULL
;
1432 SInt32 inRangeStart
;
1434 WESelector inAttributeSelector
;
1435 char *inAttributeValue__in__
;
1436 long inAttributeValue__len__
;
1437 int inAttributeValue__in_len__
;
1438 if (!PyArg_ParseTuple(_args
, "llO&s#",
1441 PyMac_GetOSType
, &inAttributeSelector
,
1442 &inAttributeValue__in__
, &inAttributeValue__in_len__
))
1444 inAttributeValue__len__
= inAttributeValue__in_len__
;
1445 _err
= WESetOneAttribute(inRangeStart
,
1447 inAttributeSelector
,
1448 inAttributeValue__in__
, inAttributeValue__len__
,
1450 if (_err
!= noErr
) return PyMac_Error(_err
);
1456 static PyObject
*wasteObj_WESetStyle(wasteObject
*_self
, PyObject
*_args
)
1458 PyObject
*_res
= NULL
;
1461 TextStyle inTextStyle
;
1462 if (!PyArg_ParseTuple(_args
, "HO&",
1464 TextStyle_Convert
, &inTextStyle
))
1466 _err
= WESetStyle(inMode
,
1469 if (_err
!= noErr
) return PyMac_Error(_err
);
1475 static PyObject
*wasteObj_WEUseStyleScrap(wasteObject
*_self
, PyObject
*_args
)
1477 PyObject
*_res
= NULL
;
1479 StScrpHandle inStyles
;
1480 if (!PyArg_ParseTuple(_args
, "O&",
1481 ResObj_Convert
, &inStyles
))
1483 _err
= WEUseStyleScrap(inStyles
,
1485 if (_err
!= noErr
) return PyMac_Error(_err
);
1491 static PyObject
*wasteObj_WEUndo(wasteObject
*_self
, PyObject
*_args
)
1493 PyObject
*_res
= NULL
;
1495 if (!PyArg_ParseTuple(_args
, ""))
1497 _err
= WEUndo(_self
->ob_itself
);
1498 if (_err
!= noErr
) return PyMac_Error(_err
);
1504 static PyObject
*wasteObj_WERedo(wasteObject
*_self
, PyObject
*_args
)
1506 PyObject
*_res
= NULL
;
1508 if (!PyArg_ParseTuple(_args
, ""))
1510 _err
= WERedo(_self
->ob_itself
);
1511 if (_err
!= noErr
) return PyMac_Error(_err
);
1517 static PyObject
*wasteObj_WEClearUndo(wasteObject
*_self
, PyObject
*_args
)
1519 PyObject
*_res
= NULL
;
1520 if (!PyArg_ParseTuple(_args
, ""))
1522 WEClearUndo(_self
->ob_itself
);
1528 static PyObject
*wasteObj_WEGetUndoInfo(wasteObject
*_self
, PyObject
*_args
)
1530 PyObject
*_res
= NULL
;
1532 Boolean outRedoFlag
;
1533 if (!PyArg_ParseTuple(_args
, ""))
1535 _rv
= WEGetUndoInfo(&outRedoFlag
,
1537 _res
= Py_BuildValue("hb",
1543 static PyObject
*wasteObj_WEGetIndUndoInfo(wasteObject
*_self
, PyObject
*_args
)
1545 PyObject
*_res
= NULL
;
1548 if (!PyArg_ParseTuple(_args
, "l",
1551 _rv
= WEGetIndUndoInfo(inUndoLevel
,
1553 _res
= Py_BuildValue("h",
1558 static PyObject
*wasteObj_WEIsTyping(wasteObject
*_self
, PyObject
*_args
)
1560 PyObject
*_res
= NULL
;
1562 if (!PyArg_ParseTuple(_args
, ""))
1564 _rv
= WEIsTyping(_self
->ob_itself
);
1565 _res
= Py_BuildValue("b",
1570 static PyObject
*wasteObj_WEBeginAction(wasteObject
*_self
, PyObject
*_args
)
1572 PyObject
*_res
= NULL
;
1574 if (!PyArg_ParseTuple(_args
, ""))
1576 _err
= WEBeginAction(_self
->ob_itself
);
1577 if (_err
!= noErr
) return PyMac_Error(_err
);
1583 static PyObject
*wasteObj_WEEndAction(wasteObject
*_self
, PyObject
*_args
)
1585 PyObject
*_res
= NULL
;
1587 WEActionKind inActionKind
;
1588 if (!PyArg_ParseTuple(_args
, "h",
1591 _err
= WEEndAction(inActionKind
,
1593 if (_err
!= noErr
) return PyMac_Error(_err
);
1599 static PyObject
*wasteObj_WEGetModCount(wasteObject
*_self
, PyObject
*_args
)
1601 PyObject
*_res
= NULL
;
1603 if (!PyArg_ParseTuple(_args
, ""))
1605 _rv
= WEGetModCount(_self
->ob_itself
);
1606 _res
= Py_BuildValue("l",
1611 static PyObject
*wasteObj_WEResetModCount(wasteObject
*_self
, PyObject
*_args
)
1613 PyObject
*_res
= NULL
;
1614 if (!PyArg_ParseTuple(_args
, ""))
1616 WEResetModCount(_self
->ob_itself
);
1622 static PyObject
*wasteObj_WEInsertObject(wasteObject
*_self
, PyObject
*_args
)
1624 PyObject
*_res
= NULL
;
1626 FlavorType inObjectType
;
1627 Handle inObjectDataHandle
;
1629 if (!PyArg_ParseTuple(_args
, "O&O&O&",
1630 PyMac_GetOSType
, &inObjectType
,
1631 ResObj_Convert
, &inObjectDataHandle
,
1632 PyMac_GetPoint
, &inObjectSize
))
1634 _err
= WEInsertObject(inObjectType
,
1638 if (_err
!= noErr
) return PyMac_Error(_err
);
1644 static PyObject
*wasteObj_WEGetSelectedObject(wasteObject
*_self
, PyObject
*_args
)
1646 PyObject
*_res
= NULL
;
1648 WEObjectReference outObject
;
1649 if (!PyArg_ParseTuple(_args
, ""))
1651 _err
= WEGetSelectedObject(&outObject
,
1653 if (_err
!= noErr
) return PyMac_Error(_err
);
1654 _res
= Py_BuildValue("O&",
1655 WEOObj_New
, outObject
);
1659 static PyObject
*wasteObj_WEGetObjectAtOffset(wasteObject
*_self
, PyObject
*_args
)
1661 PyObject
*_res
= NULL
;
1664 WEObjectReference outObject
;
1665 if (!PyArg_ParseTuple(_args
, "l",
1668 _err
= WEGetObjectAtOffset(inOffset
,
1671 if (_err
!= noErr
) return PyMac_Error(_err
);
1672 _res
= Py_BuildValue("O&",
1673 WEOObj_New
, outObject
);
1677 static PyObject
*wasteObj_WEFindNextObject(wasteObject
*_self
, PyObject
*_args
)
1679 PyObject
*_res
= NULL
;
1682 WEObjectReference outObject
;
1683 if (!PyArg_ParseTuple(_args
, "l",
1686 _rv
= WEFindNextObject(inOffset
,
1689 _res
= Py_BuildValue("lO&",
1691 WEOObj_New
, outObject
);
1695 static PyObject
*wasteObj_WEUseSoup(wasteObject
*_self
, PyObject
*_args
)
1697 PyObject
*_res
= NULL
;
1699 WESoupHandle inSoup
;
1700 if (!PyArg_ParseTuple(_args
, "O&",
1701 ResObj_Convert
, &inSoup
))
1703 _err
= WEUseSoup(inSoup
,
1705 if (_err
!= noErr
) return PyMac_Error(_err
);
1711 static PyObject
*wasteObj_WECut(wasteObject
*_self
, PyObject
*_args
)
1713 PyObject
*_res
= NULL
;
1715 if (!PyArg_ParseTuple(_args
, ""))
1717 _err
= WECut(_self
->ob_itself
);
1718 if (_err
!= noErr
) return PyMac_Error(_err
);
1724 static PyObject
*wasteObj_WECopy(wasteObject
*_self
, PyObject
*_args
)
1726 PyObject
*_res
= NULL
;
1728 if (!PyArg_ParseTuple(_args
, ""))
1730 _err
= WECopy(_self
->ob_itself
);
1731 if (_err
!= noErr
) return PyMac_Error(_err
);
1737 static PyObject
*wasteObj_WEPaste(wasteObject
*_self
, PyObject
*_args
)
1739 PyObject
*_res
= NULL
;
1741 if (!PyArg_ParseTuple(_args
, ""))
1743 _err
= WEPaste(_self
->ob_itself
);
1744 if (_err
!= noErr
) return PyMac_Error(_err
);
1750 static PyObject
*wasteObj_WECanPaste(wasteObject
*_self
, PyObject
*_args
)
1752 PyObject
*_res
= NULL
;
1754 if (!PyArg_ParseTuple(_args
, ""))
1756 _rv
= WECanPaste(_self
->ob_itself
);
1757 _res
= Py_BuildValue("b",
1762 static PyObject
*wasteObj_WEGetHiliteRgn(wasteObject
*_self
, PyObject
*_args
)
1764 PyObject
*_res
= NULL
;
1766 SInt32 inRangeStart
;
1768 if (!PyArg_ParseTuple(_args
, "ll",
1772 _rv
= WEGetHiliteRgn(inRangeStart
,
1775 _res
= Py_BuildValue("O&",
1780 static PyObject
*wasteObj_WECharByte(wasteObject
*_self
, PyObject
*_args
)
1782 PyObject
*_res
= NULL
;
1785 if (!PyArg_ParseTuple(_args
, "l",
1788 _rv
= WECharByte(inOffset
,
1790 _res
= Py_BuildValue("h",
1795 static PyObject
*wasteObj_WECharType(wasteObject
*_self
, PyObject
*_args
)
1797 PyObject
*_res
= NULL
;
1800 if (!PyArg_ParseTuple(_args
, "l",
1803 _rv
= WECharType(inOffset
,
1805 _res
= Py_BuildValue("h",
1810 static PyObject
*wasteObj_WEStopInlineSession(wasteObject
*_self
, PyObject
*_args
)
1812 PyObject
*_res
= NULL
;
1813 if (!PyArg_ParseTuple(_args
, ""))
1815 WEStopInlineSession(_self
->ob_itself
);
1821 static PyObject
*wasteObj_WEFeatureFlag(wasteObject
*_self
, PyObject
*_args
)
1823 PyObject
*_res
= NULL
;
1827 if (!PyArg_ParseTuple(_args
, "hh",
1831 _rv
= WEFeatureFlag(inFeature
,
1834 _res
= Py_BuildValue("h",
1839 static PyObject
*wasteObj_WEGetUserInfo(wasteObject
*_self
, PyObject
*_args
)
1841 PyObject
*_res
= NULL
;
1843 WESelector inUserTag
;
1845 if (!PyArg_ParseTuple(_args
, "O&",
1846 PyMac_GetOSType
, &inUserTag
))
1848 _err
= WEGetUserInfo(inUserTag
,
1851 if (_err
!= noErr
) return PyMac_Error(_err
);
1852 _res
= Py_BuildValue("l",
1857 static PyObject
*wasteObj_WESetUserInfo(wasteObject
*_self
, PyObject
*_args
)
1859 PyObject
*_res
= NULL
;
1861 WESelector inUserTag
;
1863 if (!PyArg_ParseTuple(_args
, "O&l",
1864 PyMac_GetOSType
, &inUserTag
,
1867 _err
= WESetUserInfo(inUserTag
,
1870 if (_err
!= noErr
) return PyMac_Error(_err
);
1876 static PyObject
*wasteObj_WERemoveUserInfo(wasteObject
*_self
, PyObject
*_args
)
1878 PyObject
*_res
= NULL
;
1880 WESelector inUserTag
;
1881 if (!PyArg_ParseTuple(_args
, "O&",
1882 PyMac_GetOSType
, &inUserTag
))
1884 _err
= WERemoveUserInfo(inUserTag
,
1886 if (_err
!= noErr
) return PyMac_Error(_err
);
1892 static PyObject
*wasteObj_WEInstallTabHooks(wasteObject
*_self
, PyObject
*_args
)
1894 PyObject
*_res
= NULL
;
1896 if (!PyArg_ParseTuple(_args
, ""))
1898 _err
= WEInstallTabHooks(_self
->ob_itself
);
1899 if (_err
!= noErr
) return PyMac_Error(_err
);
1905 static PyObject
*wasteObj_WERemoveTabHooks(wasteObject
*_self
, PyObject
*_args
)
1907 PyObject
*_res
= NULL
;
1909 if (!PyArg_ParseTuple(_args
, ""))
1911 _err
= WERemoveTabHooks(_self
->ob_itself
);
1912 if (_err
!= noErr
) return PyMac_Error(_err
);
1918 static PyObject
*wasteObj_WEIsTabHooks(wasteObject
*_self
, PyObject
*_args
)
1920 PyObject
*_res
= NULL
;
1922 if (!PyArg_ParseTuple(_args
, ""))
1924 _rv
= WEIsTabHooks(_self
->ob_itself
);
1925 _res
= Py_BuildValue("b",
1930 static PyObject
*wasteObj_WEGetTabSize(wasteObject
*_self
, PyObject
*_args
)
1932 PyObject
*_res
= NULL
;
1934 if (!PyArg_ParseTuple(_args
, ""))
1936 _rv
= WEGetTabSize(_self
->ob_itself
);
1937 _res
= Py_BuildValue("h",
1942 static PyObject
*wasteObj_WESetTabSize(wasteObject
*_self
, PyObject
*_args
)
1944 PyObject
*_res
= NULL
;
1947 if (!PyArg_ParseTuple(_args
, "h",
1950 _err
= WESetTabSize(tabWidth
,
1952 if (_err
!= noErr
) return PyMac_Error(_err
);
1958 static PyMethodDef wasteObj_methods
[] = {
1959 {"WEGetText", (PyCFunction
)wasteObj_WEGetText
, 1,
1960 PyDoc_STR("() -> (Handle _rv)")},
1961 {"WEGetChar", (PyCFunction
)wasteObj_WEGetChar
, 1,
1962 PyDoc_STR("(SInt32 inOffset) -> (SInt16 _rv)")},
1963 {"WEGetTextLength", (PyCFunction
)wasteObj_WEGetTextLength
, 1,
1964 PyDoc_STR("() -> (SInt32 _rv)")},
1965 {"WEGetSelection", (PyCFunction
)wasteObj_WEGetSelection
, 1,
1966 PyDoc_STR("() -> (SInt32 outSelStart, SInt32 outSelEnd)")},
1967 {"WEGetDestRect", (PyCFunction
)wasteObj_WEGetDestRect
, 1,
1968 PyDoc_STR("() -> (LongRect outDestRect)")},
1969 {"WEGetViewRect", (PyCFunction
)wasteObj_WEGetViewRect
, 1,
1970 PyDoc_STR("() -> (LongRect outViewRect)")},
1971 {"WEIsActive", (PyCFunction
)wasteObj_WEIsActive
, 1,
1972 PyDoc_STR("() -> (Boolean _rv)")},
1973 {"WEGetClickCount", (PyCFunction
)wasteObj_WEGetClickCount
, 1,
1974 PyDoc_STR("() -> (UInt16 _rv)")},
1975 {"WESetSelection", (PyCFunction
)wasteObj_WESetSelection
, 1,
1976 PyDoc_STR("(SInt32 inSelStart, SInt32 inSelEnd) -> None")},
1977 {"WESetDestRect", (PyCFunction
)wasteObj_WESetDestRect
, 1,
1978 PyDoc_STR("(LongRect inDestRect) -> None")},
1979 {"WESetViewRect", (PyCFunction
)wasteObj_WESetViewRect
, 1,
1980 PyDoc_STR("(LongRect inViewRect) -> None")},
1981 {"WEContinuousStyle", (PyCFunction
)wasteObj_WEContinuousStyle
, 1,
1982 PyDoc_STR("(WEStyleMode ioMode) -> (Boolean _rv, WEStyleMode ioMode, TextStyle outTextStyle)")},
1983 {"WECountRuns", (PyCFunction
)wasteObj_WECountRuns
, 1,
1984 PyDoc_STR("() -> (SInt32 _rv)")},
1985 {"WEOffsetToRun", (PyCFunction
)wasteObj_WEOffsetToRun
, 1,
1986 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv)")},
1987 {"WEGetRunRange", (PyCFunction
)wasteObj_WEGetRunRange
, 1,
1988 PyDoc_STR("(SInt32 inStyleRunIndex) -> (SInt32 outStyleRunStart, SInt32 outStyleRunEnd)")},
1989 {"WEGetRunInfo", (PyCFunction
)wasteObj_WEGetRunInfo
, 1,
1990 PyDoc_STR("(SInt32 inOffset) -> (WERunInfo outStyleRunInfo)")},
1991 {"WEGetIndRunInfo", (PyCFunction
)wasteObj_WEGetIndRunInfo
, 1,
1992 PyDoc_STR("(SInt32 inStyleRunIndex) -> (WERunInfo outStyleRunInfo)")},
1993 {"WEGetRunDirection", (PyCFunction
)wasteObj_WEGetRunDirection
, 1,
1994 PyDoc_STR("(SInt32 inOffset) -> (Boolean _rv)")},
1995 {"WECountParaRuns", (PyCFunction
)wasteObj_WECountParaRuns
, 1,
1996 PyDoc_STR("() -> (SInt32 _rv)")},
1997 {"WEOffsetToParaRun", (PyCFunction
)wasteObj_WEOffsetToParaRun
, 1,
1998 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv)")},
1999 {"WEGetParaRunRange", (PyCFunction
)wasteObj_WEGetParaRunRange
, 1,
2000 PyDoc_STR("(SInt32 inParagraphRunIndex) -> (SInt32 outParagraphRunStart, SInt32 outParagraphRunEnd)")},
2001 {"WECountLines", (PyCFunction
)wasteObj_WECountLines
, 1,
2002 PyDoc_STR("() -> (SInt32 _rv)")},
2003 {"WEOffsetToLine", (PyCFunction
)wasteObj_WEOffsetToLine
, 1,
2004 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv)")},
2005 {"WEGetLineRange", (PyCFunction
)wasteObj_WEGetLineRange
, 1,
2006 PyDoc_STR("(SInt32 inLineIndex) -> (SInt32 outLineStart, SInt32 outLineEnd)")},
2007 {"WEGetHeight", (PyCFunction
)wasteObj_WEGetHeight
, 1,
2008 PyDoc_STR("(SInt32 inStartLineIndex, SInt32 inEndLineIndex) -> (SInt32 _rv)")},
2009 {"WEGetOffset", (PyCFunction
)wasteObj_WEGetOffset
, 1,
2010 PyDoc_STR("(LongPt inPoint) -> (SInt32 _rv, WEEdge outEdge)")},
2011 {"WEGetPoint", (PyCFunction
)wasteObj_WEGetPoint
, 1,
2012 PyDoc_STR("(SInt32 inOffset, SInt16 inDirection) -> (LongPt outPoint, SInt16 outLineHeight)")},
2013 {"WEFindWord", (PyCFunction
)wasteObj_WEFindWord
, 1,
2014 PyDoc_STR("(SInt32 inOffset, WEEdge inEdge) -> (SInt32 outWordStart, SInt32 outWordEnd)")},
2015 {"WEFindLine", (PyCFunction
)wasteObj_WEFindLine
, 1,
2016 PyDoc_STR("(SInt32 inOffset, WEEdge inEdge) -> (SInt32 outLineStart, SInt32 outLineEnd)")},
2017 {"WEFindParagraph", (PyCFunction
)wasteObj_WEFindParagraph
, 1,
2018 PyDoc_STR("(SInt32 inOffset, WEEdge inEdge) -> (SInt32 outParagraphStart, SInt32 outParagraphEnd)")},
2019 {"WEFind", (PyCFunction
)wasteObj_WEFind
, 1,
2020 PyDoc_STR("(char* inKey, SInt32 inKeyLength, TextEncoding inKeyEncoding, OptionBits inMatchOptions, SInt32 inRangeStart, SInt32 inRangeEnd) -> (SInt32 outMatchStart, SInt32 outMatchEnd)")},
2021 {"WEStreamRange", (PyCFunction
)wasteObj_WEStreamRange
, 1,
2022 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, FlavorType inRequestedType, OptionBits inStreamOptions, Handle outData) -> None")},
2023 {"WECopyRange", (PyCFunction
)wasteObj_WECopyRange
, 1,
2024 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, Handle outText, StScrpHandle outStyles, WESoupHandle outSoup) -> None")},
2025 {"WEGetTextRangeAsUnicode", (PyCFunction
)wasteObj_WEGetTextRangeAsUnicode
, 1,
2026 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, Handle outUnicodeText, Handle ioCharFormat, Handle ioParaFormat, TextEncodingVariant inUnicodeVariant, TextEncodingFormat inTransformationFormat, OptionBits inGetOptions) -> None")},
2027 {"WEGetAlignment", (PyCFunction
)wasteObj_WEGetAlignment
, 1,
2028 PyDoc_STR("() -> (WEAlignment _rv)")},
2029 {"WESetAlignment", (PyCFunction
)wasteObj_WESetAlignment
, 1,
2030 PyDoc_STR("(WEAlignment inAlignment) -> None")},
2031 {"WEGetDirection", (PyCFunction
)wasteObj_WEGetDirection
, 1,
2032 PyDoc_STR("() -> (WEDirection _rv)")},
2033 {"WESetDirection", (PyCFunction
)wasteObj_WESetDirection
, 1,
2034 PyDoc_STR("(WEDirection inDirection) -> None")},
2035 {"WECalText", (PyCFunction
)wasteObj_WECalText
, 1,
2036 PyDoc_STR("() -> None")},
2037 {"WEUpdate", (PyCFunction
)wasteObj_WEUpdate
, 1,
2038 PyDoc_STR("(RgnHandle inUpdateRgn) -> None")},
2039 {"WEScroll", (PyCFunction
)wasteObj_WEScroll
, 1,
2040 PyDoc_STR("(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> None")},
2041 {"WEPinScroll", (PyCFunction
)wasteObj_WEPinScroll
, 1,
2042 PyDoc_STR("(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> None")},
2043 {"WESelView", (PyCFunction
)wasteObj_WESelView
, 1,
2044 PyDoc_STR("() -> None")},
2045 {"WEActivate", (PyCFunction
)wasteObj_WEActivate
, 1,
2046 PyDoc_STR("() -> None")},
2047 {"WEDeactivate", (PyCFunction
)wasteObj_WEDeactivate
, 1,
2048 PyDoc_STR("() -> None")},
2049 {"WEKey", (PyCFunction
)wasteObj_WEKey
, 1,
2050 PyDoc_STR("(CharParameter inKey, EventModifiers inModifiers) -> None")},
2051 {"WEClick", (PyCFunction
)wasteObj_WEClick
, 1,
2052 PyDoc_STR("(Point inHitPoint, EventModifiers inModifiers, UInt32 inClickTime) -> None")},
2053 {"WEAdjustCursor", (PyCFunction
)wasteObj_WEAdjustCursor
, 1,
2054 PyDoc_STR("(Point inMouseLoc, RgnHandle ioMouseRgn) -> (Boolean _rv)")},
2055 {"WEIdle", (PyCFunction
)wasteObj_WEIdle
, 1,
2056 PyDoc_STR("() -> (UInt32 outMaxSleep)")},
2057 {"WEInsert", (PyCFunction
)wasteObj_WEInsert
, 1,
2058 PyDoc_STR("(Buffer inTextPtr, StScrpHandle inStyles, WESoupHandle inSoup) -> None")},
2059 {"WEInsertFormattedText", (PyCFunction
)wasteObj_WEInsertFormattedText
, 1,
2060 PyDoc_STR("(Buffer inTextPtr, StScrpHandle inStyles, WESoupHandle inSoup, Handle inParaFormat, Handle inRulerScrap) -> None")},
2061 {"WEDelete", (PyCFunction
)wasteObj_WEDelete
, 1,
2062 PyDoc_STR("() -> None")},
2063 {"WEUseText", (PyCFunction
)wasteObj_WEUseText
, 1,
2064 PyDoc_STR("(Handle inText) -> None")},
2065 {"WEChangeCase", (PyCFunction
)wasteObj_WEChangeCase
, 1,
2066 PyDoc_STR("(SInt16 inCase) -> None")},
2067 {"WESetOneAttribute", (PyCFunction
)wasteObj_WESetOneAttribute
, 1,
2068 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, WESelector inAttributeSelector, Buffer inAttributeValue) -> None")},
2069 {"WESetStyle", (PyCFunction
)wasteObj_WESetStyle
, 1,
2070 PyDoc_STR("(WEStyleMode inMode, TextStyle inTextStyle) -> None")},
2071 {"WEUseStyleScrap", (PyCFunction
)wasteObj_WEUseStyleScrap
, 1,
2072 PyDoc_STR("(StScrpHandle inStyles) -> None")},
2073 {"WEUndo", (PyCFunction
)wasteObj_WEUndo
, 1,
2074 PyDoc_STR("() -> None")},
2075 {"WERedo", (PyCFunction
)wasteObj_WERedo
, 1,
2076 PyDoc_STR("() -> None")},
2077 {"WEClearUndo", (PyCFunction
)wasteObj_WEClearUndo
, 1,
2078 PyDoc_STR("() -> None")},
2079 {"WEGetUndoInfo", (PyCFunction
)wasteObj_WEGetUndoInfo
, 1,
2080 PyDoc_STR("() -> (WEActionKind _rv, Boolean outRedoFlag)")},
2081 {"WEGetIndUndoInfo", (PyCFunction
)wasteObj_WEGetIndUndoInfo
, 1,
2082 PyDoc_STR("(SInt32 inUndoLevel) -> (WEActionKind _rv)")},
2083 {"WEIsTyping", (PyCFunction
)wasteObj_WEIsTyping
, 1,
2084 PyDoc_STR("() -> (Boolean _rv)")},
2085 {"WEBeginAction", (PyCFunction
)wasteObj_WEBeginAction
, 1,
2086 PyDoc_STR("() -> None")},
2087 {"WEEndAction", (PyCFunction
)wasteObj_WEEndAction
, 1,
2088 PyDoc_STR("(WEActionKind inActionKind) -> None")},
2089 {"WEGetModCount", (PyCFunction
)wasteObj_WEGetModCount
, 1,
2090 PyDoc_STR("() -> (UInt32 _rv)")},
2091 {"WEResetModCount", (PyCFunction
)wasteObj_WEResetModCount
, 1,
2092 PyDoc_STR("() -> None")},
2093 {"WEInsertObject", (PyCFunction
)wasteObj_WEInsertObject
, 1,
2094 PyDoc_STR("(FlavorType inObjectType, Handle inObjectDataHandle, Point inObjectSize) -> None")},
2095 {"WEGetSelectedObject", (PyCFunction
)wasteObj_WEGetSelectedObject
, 1,
2096 PyDoc_STR("() -> (WEObjectReference outObject)")},
2097 {"WEGetObjectAtOffset", (PyCFunction
)wasteObj_WEGetObjectAtOffset
, 1,
2098 PyDoc_STR("(SInt32 inOffset) -> (WEObjectReference outObject)")},
2099 {"WEFindNextObject", (PyCFunction
)wasteObj_WEFindNextObject
, 1,
2100 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv, WEObjectReference outObject)")},
2101 {"WEUseSoup", (PyCFunction
)wasteObj_WEUseSoup
, 1,
2102 PyDoc_STR("(WESoupHandle inSoup) -> None")},
2103 {"WECut", (PyCFunction
)wasteObj_WECut
, 1,
2104 PyDoc_STR("() -> None")},
2105 {"WECopy", (PyCFunction
)wasteObj_WECopy
, 1,
2106 PyDoc_STR("() -> None")},
2107 {"WEPaste", (PyCFunction
)wasteObj_WEPaste
, 1,
2108 PyDoc_STR("() -> None")},
2109 {"WECanPaste", (PyCFunction
)wasteObj_WECanPaste
, 1,
2110 PyDoc_STR("() -> (Boolean _rv)")},
2111 {"WEGetHiliteRgn", (PyCFunction
)wasteObj_WEGetHiliteRgn
, 1,
2112 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd) -> (RgnHandle _rv)")},
2113 {"WECharByte", (PyCFunction
)wasteObj_WECharByte
, 1,
2114 PyDoc_STR("(SInt32 inOffset) -> (SInt16 _rv)")},
2115 {"WECharType", (PyCFunction
)wasteObj_WECharType
, 1,
2116 PyDoc_STR("(SInt32 inOffset) -> (SInt16 _rv)")},
2117 {"WEStopInlineSession", (PyCFunction
)wasteObj_WEStopInlineSession
, 1,
2118 PyDoc_STR("() -> None")},
2119 {"WEFeatureFlag", (PyCFunction
)wasteObj_WEFeatureFlag
, 1,
2120 PyDoc_STR("(SInt16 inFeature, SInt16 inAction) -> (SInt16 _rv)")},
2121 {"WEGetUserInfo", (PyCFunction
)wasteObj_WEGetUserInfo
, 1,
2122 PyDoc_STR("(WESelector inUserTag) -> (SInt32 outUserInfo)")},
2123 {"WESetUserInfo", (PyCFunction
)wasteObj_WESetUserInfo
, 1,
2124 PyDoc_STR("(WESelector inUserTag, SInt32 inUserInfo) -> None")},
2125 {"WERemoveUserInfo", (PyCFunction
)wasteObj_WERemoveUserInfo
, 1,
2126 PyDoc_STR("(WESelector inUserTag) -> None")},
2127 {"WEInstallTabHooks", (PyCFunction
)wasteObj_WEInstallTabHooks
, 1,
2128 PyDoc_STR("() -> None")},
2129 {"WERemoveTabHooks", (PyCFunction
)wasteObj_WERemoveTabHooks
, 1,
2130 PyDoc_STR("() -> None")},
2131 {"WEIsTabHooks", (PyCFunction
)wasteObj_WEIsTabHooks
, 1,
2132 PyDoc_STR("() -> (Boolean _rv)")},
2133 {"WEGetTabSize", (PyCFunction
)wasteObj_WEGetTabSize
, 1,
2134 PyDoc_STR("() -> (SInt16 _rv)")},
2135 {"WESetTabSize", (PyCFunction
)wasteObj_WESetTabSize
, 1,
2136 PyDoc_STR("(SInt16 tabWidth) -> None")},
2140 #define wasteObj_getsetlist NULL
2143 #define wasteObj_compare NULL
2145 #define wasteObj_repr NULL
2147 #define wasteObj_hash NULL
2148 #define wasteObj_tp_init 0
2150 #define wasteObj_tp_alloc PyType_GenericAlloc
2152 static PyObject
*wasteObj_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
2156 char *kw
[] = {"itself", 0};
2158 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, wasteObj_Convert
, &itself
)) return NULL
;
2159 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
2160 ((wasteObject
*)self
)->ob_itself
= itself
;
2164 #define wasteObj_tp_free PyObject_Del
2167 PyTypeObject waste_Type
= {
2168 PyObject_HEAD_INIT(NULL
)
2170 "waste.waste", /*tp_name*/
2171 sizeof(wasteObject
), /*tp_basicsize*/
2174 (destructor
) wasteObj_dealloc
, /*tp_dealloc*/
2176 (getattrfunc
)0, /*tp_getattr*/
2177 (setattrfunc
)0, /*tp_setattr*/
2178 (cmpfunc
) wasteObj_compare
, /*tp_compare*/
2179 (reprfunc
) wasteObj_repr
, /*tp_repr*/
2180 (PyNumberMethods
*)0, /* tp_as_number */
2181 (PySequenceMethods
*)0, /* tp_as_sequence */
2182 (PyMappingMethods
*)0, /* tp_as_mapping */
2183 (hashfunc
) wasteObj_hash
, /*tp_hash*/
2186 PyObject_GenericGetAttr
, /*tp_getattro*/
2187 PyObject_GenericSetAttr
, /*tp_setattro */
2189 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
2193 0, /*tp_richcompare*/
2194 0, /*tp_weaklistoffset*/
2197 wasteObj_methods
, /* tp_methods */
2199 wasteObj_getsetlist
, /*tp_getset*/
2204 0, /*tp_dictoffset*/
2205 wasteObj_tp_init
, /* tp_init */
2206 wasteObj_tp_alloc
, /* tp_alloc */
2207 wasteObj_tp_new
, /* tp_new */
2208 wasteObj_tp_free
, /* tp_free */
2211 /* --------------------- End object type waste ---------------------- */
2214 static PyObject
*waste_WENew(PyObject
*_self
, PyObject
*_args
)
2216 PyObject
*_res
= NULL
;
2218 LongRect inDestRect
;
2219 LongRect inViewRect
;
2220 OptionBits inOptions
;
2222 if (!PyArg_ParseTuple(_args
, "O&O&l",
2223 LongRect_Convert
, &inDestRect
,
2224 LongRect_Convert
, &inViewRect
,
2227 _err
= WENew(&inDestRect
,
2231 if (_err
!= noErr
) return PyMac_Error(_err
);
2232 _res
= Py_BuildValue("O&",
2233 wasteObj_New
, outWE
);
2237 static PyObject
*waste_WEUpdateStyleScrap(PyObject
*_self
, PyObject
*_args
)
2239 PyObject
*_res
= NULL
;
2241 StScrpHandle ioStyles
;
2242 WEFontTableHandle inFontTable
;
2243 if (!PyArg_ParseTuple(_args
, "O&O&",
2244 ResObj_Convert
, &ioStyles
,
2245 ResObj_Convert
, &inFontTable
))
2247 _err
= WEUpdateStyleScrap(ioStyles
,
2249 if (_err
!= noErr
) return PyMac_Error(_err
);
2255 static PyObject
*waste_WEInstallTSMHandlers(PyObject
*_self
, PyObject
*_args
)
2257 PyObject
*_res
= NULL
;
2259 if (!PyArg_ParseTuple(_args
, ""))
2261 _err
= WEInstallTSMHandlers();
2262 if (_err
!= noErr
) return PyMac_Error(_err
);
2268 static PyObject
*waste_WERemoveTSMHandlers(PyObject
*_self
, PyObject
*_args
)
2270 PyObject
*_res
= NULL
;
2272 if (!PyArg_ParseTuple(_args
, ""))
2274 _err
= WERemoveTSMHandlers();
2275 if (_err
!= noErr
) return PyMac_Error(_err
);
2281 static PyObject
*waste_WEHandleTSMEvent(PyObject
*_self
, PyObject
*_args
)
2283 PyObject
*_res
= NULL
;
2285 AppleEvent inAppleEvent
;
2287 if (!PyArg_ParseTuple(_args
, "O&",
2288 AEDesc_Convert
, &inAppleEvent
))
2290 _err
= WEHandleTSMEvent(&inAppleEvent
,
2292 if (_err
!= noErr
) return PyMac_Error(_err
);
2293 _res
= Py_BuildValue("O&",
2294 AEDesc_New
, &ioReply
);
2298 static PyObject
*waste_WELongPointToPoint(PyObject
*_self
, PyObject
*_args
)
2300 PyObject
*_res
= NULL
;
2303 if (!PyArg_ParseTuple(_args
, "O&",
2304 LongPt_Convert
, &inLongPoint
))
2306 WELongPointToPoint(&inLongPoint
,
2308 _res
= Py_BuildValue("O&",
2309 PyMac_BuildPoint
, outPoint
);
2313 static PyObject
*waste_WEPointToLongPoint(PyObject
*_self
, PyObject
*_args
)
2315 PyObject
*_res
= NULL
;
2317 LongPt outLongPoint
;
2318 if (!PyArg_ParseTuple(_args
, "O&",
2319 PyMac_GetPoint
, &inPoint
))
2321 WEPointToLongPoint(inPoint
,
2323 _res
= Py_BuildValue("O&",
2324 LongPt_New
, &outLongPoint
);
2328 static PyObject
*waste_WESetLongRect(PyObject
*_self
, PyObject
*_args
)
2330 PyObject
*_res
= NULL
;
2331 LongRect outLongRect
;
2336 if (!PyArg_ParseTuple(_args
, "llll",
2342 WESetLongRect(&outLongRect
,
2347 _res
= Py_BuildValue("O&",
2348 LongRect_New
, &outLongRect
);
2352 static PyObject
*waste_WELongRectToRect(PyObject
*_self
, PyObject
*_args
)
2354 PyObject
*_res
= NULL
;
2355 LongRect inLongRect
;
2357 if (!PyArg_ParseTuple(_args
, "O&",
2358 LongRect_Convert
, &inLongRect
))
2360 WELongRectToRect(&inLongRect
,
2362 _res
= Py_BuildValue("O&",
2363 PyMac_BuildRect
, &outRect
);
2367 static PyObject
*waste_WERectToLongRect(PyObject
*_self
, PyObject
*_args
)
2369 PyObject
*_res
= NULL
;
2371 LongRect outLongRect
;
2372 if (!PyArg_ParseTuple(_args
, "O&",
2373 PyMac_GetRect
, &inRect
))
2375 WERectToLongRect(&inRect
,
2377 _res
= Py_BuildValue("O&",
2378 LongRect_New
, &outLongRect
);
2382 static PyObject
*waste_WEOffsetLongRect(PyObject
*_self
, PyObject
*_args
)
2384 PyObject
*_res
= NULL
;
2385 LongRect ioLongRect
;
2386 SInt32 inHorizontalOffset
;
2387 SInt32 inVerticalOffset
;
2388 if (!PyArg_ParseTuple(_args
, "ll",
2389 &inHorizontalOffset
,
2392 WEOffsetLongRect(&ioLongRect
,
2395 _res
= Py_BuildValue("O&",
2396 LongRect_New
, &ioLongRect
);
2400 static PyObject
*waste_WELongPointInLongRect(PyObject
*_self
, PyObject
*_args
)
2402 PyObject
*_res
= NULL
;
2405 LongRect inLongRect
;
2406 if (!PyArg_ParseTuple(_args
, "O&O&",
2407 LongPt_Convert
, &inLongPoint
,
2408 LongRect_Convert
, &inLongRect
))
2410 _rv
= WELongPointInLongRect(&inLongPoint
,
2412 _res
= Py_BuildValue("b",
2417 static PyObject
*waste_STDObjectHandlers(PyObject
*_self
, PyObject
*_args
)
2419 PyObject
*_res
= NULL
;
2422 // install the sample object handlers for pictures and sounds
2423 #define kTypePicture 'PICT'
2424 #define kTypeSound 'snd '
2426 if ( !PyArg_ParseTuple(_args
, "") ) return NULL
;
2428 if ((err
= WEInstallObjectHandler(kTypePicture
, weNewHandler
,
2429 (UniversalProcPtr
) NewWENewObjectProc(HandleNewPicture
), NULL
)) != noErr
)
2432 if ((err
= WEInstallObjectHandler(kTypePicture
, weDisposeHandler
,
2433 (UniversalProcPtr
) NewWEDisposeObjectProc(HandleDisposePicture
), NULL
)) != noErr
)
2436 if ((err
= WEInstallObjectHandler(kTypePicture
, weDrawHandler
,
2437 (UniversalProcPtr
) NewWEDrawObjectProc(HandleDrawPicture
), NULL
)) != noErr
)
2440 if ((err
= WEInstallObjectHandler(kTypeSound
, weNewHandler
,
2441 (UniversalProcPtr
) NewWENewObjectProc(HandleNewSound
), NULL
)) != noErr
)
2444 if ((err
= WEInstallObjectHandler(kTypeSound
, weDrawHandler
,
2445 (UniversalProcPtr
) NewWEDrawObjectProc(HandleDrawSound
), NULL
)) != noErr
)
2448 if ((err
= WEInstallObjectHandler(kTypeSound
, weClickHandler
,
2449 (UniversalProcPtr
) NewWEClickObjectProc(HandleClickSound
), NULL
)) != noErr
)
2456 return PyMac_Error(err
);
2460 static PyObject
*waste_WEInstallObjectHandler(PyObject
*_self
, PyObject
*_args
)
2462 PyObject
*_res
= NULL
;
2465 FlavorType objectType
;
2466 WESelector selector
;
2467 PyObject
*py_handler
;
2468 UniversalProcPtr handler
;
2469 WEReference we
= NULL
;
2473 if ( !PyArg_ParseTuple(_args
, "O&O&O|O&",
2474 PyMac_GetOSType
, &objectType
,
2475 PyMac_GetOSType
, &selector
,
2477 WEOObj_Convert
, &we
) ) return NULL
;
2479 if ( selector
== weNewHandler
) handler
= (UniversalProcPtr
)upp_new_handler
;
2480 else if ( selector
== weDisposeHandler
) handler
= (UniversalProcPtr
)upp_dispose_handler
;
2481 else if ( selector
== weDrawHandler
) handler
= (UniversalProcPtr
)upp_draw_handler
;
2482 else if ( selector
== weClickHandler
) handler
= (UniversalProcPtr
)upp_click_handler
;
2483 else return PyMac_Error(weUndefinedSelectorErr
);
2485 if ((key
= Py_BuildValue("O&O&",
2486 PyMac_BuildOSType
, objectType
,
2487 PyMac_BuildOSType
, selector
)) == NULL
)
2490 PyDict_SetItem(callbackdict
, key
, py_handler
);
2492 err
= WEInstallObjectHandler(objectType
, selector
, handler
, we
);
2493 if ( err
) return PyMac_Error(err
);
2500 static PyMethodDef waste_methods
[] = {
2501 {"WENew", (PyCFunction
)waste_WENew
, 1,
2502 PyDoc_STR("(LongRect inDestRect, LongRect inViewRect, OptionBits inOptions) -> (WEReference outWE)")},
2503 {"WEUpdateStyleScrap", (PyCFunction
)waste_WEUpdateStyleScrap
, 1,
2504 PyDoc_STR("(StScrpHandle ioStyles, WEFontTableHandle inFontTable) -> None")},
2505 {"WEInstallTSMHandlers", (PyCFunction
)waste_WEInstallTSMHandlers
, 1,
2506 PyDoc_STR("() -> None")},
2507 {"WERemoveTSMHandlers", (PyCFunction
)waste_WERemoveTSMHandlers
, 1,
2508 PyDoc_STR("() -> None")},
2509 {"WEHandleTSMEvent", (PyCFunction
)waste_WEHandleTSMEvent
, 1,
2510 PyDoc_STR("(AppleEvent inAppleEvent) -> (AppleEvent ioReply)")},
2511 {"WELongPointToPoint", (PyCFunction
)waste_WELongPointToPoint
, 1,
2512 PyDoc_STR("(LongPt inLongPoint) -> (Point outPoint)")},
2513 {"WEPointToLongPoint", (PyCFunction
)waste_WEPointToLongPoint
, 1,
2514 PyDoc_STR("(Point inPoint) -> (LongPt outLongPoint)")},
2515 {"WESetLongRect", (PyCFunction
)waste_WESetLongRect
, 1,
2516 PyDoc_STR("(SInt32 inLeft, SInt32 inTop, SInt32 inRight, SInt32 inBottom) -> (LongRect outLongRect)")},
2517 {"WELongRectToRect", (PyCFunction
)waste_WELongRectToRect
, 1,
2518 PyDoc_STR("(LongRect inLongRect) -> (Rect outRect)")},
2519 {"WERectToLongRect", (PyCFunction
)waste_WERectToLongRect
, 1,
2520 PyDoc_STR("(Rect inRect) -> (LongRect outLongRect)")},
2521 {"WEOffsetLongRect", (PyCFunction
)waste_WEOffsetLongRect
, 1,
2522 PyDoc_STR("(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> (LongRect ioLongRect)")},
2523 {"WELongPointInLongRect", (PyCFunction
)waste_WELongPointInLongRect
, 1,
2524 PyDoc_STR("(LongPt inLongPoint, LongRect inLongRect) -> (Boolean _rv)")},
2525 {"STDObjectHandlers", (PyCFunction
)waste_STDObjectHandlers
, 1,
2527 {"WEInstallObjectHandler", (PyCFunction
)waste_WEInstallObjectHandler
, 1,
2534 /* Return the object corresponding to the window, or NULL */
2537 ExistingwasteObj_New(w
)
2540 PyObject
*it
= NULL
;
2545 WEGetInfo(weRefCon
, (void *)&it
, w
);
2546 if (it
== NULL
|| ((wasteObject
*)it
)->ob_itself
!= w
)
2553 void initwaste(void)
2561 m
= Py_InitModule("waste", waste_methods
);
2562 d
= PyModule_GetDict(m
);
2563 waste_Error
= PyMac_GetOSErrException();
2564 if (waste_Error
== NULL
||
2565 PyDict_SetItemString(d
, "Error", waste_Error
) != 0)
2567 WEO_Type
.ob_type
= &PyType_Type
;
2568 if (PyType_Ready(&WEO_Type
) < 0) return;
2569 Py_INCREF(&WEO_Type
);
2570 PyModule_AddObject(m
, "WEO", (PyObject
*)&WEO_Type
);
2571 /* Backward-compatible name */
2572 Py_INCREF(&WEO_Type
);
2573 PyModule_AddObject(m
, "WEOType", (PyObject
*)&WEO_Type
);
2574 waste_Type
.ob_type
= &PyType_Type
;
2575 if (PyType_Ready(&waste_Type
) < 0) return;
2576 Py_INCREF(&waste_Type
);
2577 PyModule_AddObject(m
, "waste", (PyObject
*)&waste_Type
);
2578 /* Backward-compatible name */
2579 Py_INCREF(&waste_Type
);
2580 PyModule_AddObject(m
, "wasteType", (PyObject
*)&waste_Type
);
2582 callbackdict
= PyDict_New();
2583 if (callbackdict
== NULL
|| PyDict_SetItemString(d
, "callbacks", callbackdict
) != 0)
2585 upp_new_handler
= NewWENewObjectProc(my_new_handler
);
2586 upp_dispose_handler
= NewWEDisposeObjectProc(my_dispose_handler
);
2587 upp_draw_handler
= NewWEDrawObjectProc(my_draw_handler
);
2588 upp_click_handler
= NewWEClickObjectProc(my_click_handler
);
2593 /* ======================== End module waste ======================== */