2 /* ========================== Module waste ========================== */
9 #include "pywintoolbox.h"
12 #include "pymactoolbox.h"
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
24 #include <WEObjectHandlers.h>
27 /* Exported by Qdmodule.c: */
28 extern PyObject
*QdRGB_New(RGBColor
*);
29 extern int QdRGB_Convert(PyObject
*, RGBColor
*);
31 /* Exported by AEModule.c: */
32 extern PyObject
*AEDesc_New(AppleEvent
*);
33 extern int AEDesc_Convert(PyObject
*, AppleEvent
*);
35 /* Forward declaration */
36 static PyObject
*WEOObj_New(WEObjectReference
);
37 static PyObject
*ExistingwasteObj_New(WEReference
);
40 ** Parse/generate TextStyle records
43 PyObject
*TextStyle_New(itself
)
47 return Py_BuildValue("lllO&", (long)itself
->tsFont
, (long)itself
->tsFace
, (long)itself
->tsSize
, QdRGB_New
,
52 TextStyle_Convert(v
, p_itself
)
54 TextStylePtr p_itself
;
56 long font
, face
, size
;
58 if( !PyArg_ParseTuple(v
, "lllO&", &font
, &face
, &size
, QdRGB_Convert
, &p_itself
->tsColor
) )
60 p_itself
->tsFont
= (short)font
;
61 p_itself
->tsFace
= (Style
)face
;
62 p_itself
->tsSize
= (short)size
;
67 ** Parse/generate RunInfo records
70 PyObject
*RunInfo_New(itself
)
74 return Py_BuildValue("llhhO&O&", itself
->runStart
, itself
->runEnd
, itself
->runHeight
,
75 itself
->runAscent
, TextStyle_New
, &itself
->runStyle
, WEOObj_New
, itself
->runObject
);
78 /* Conversion of long points and rects */
80 LongRect_Convert(PyObject
*v
, LongRect
*r
)
82 return PyArg_Parse(v
, "(llll)", &r
->left
, &r
->top
, &r
->right
, &r
->bottom
);
86 LongRect_New(LongRect
*r
)
88 return Py_BuildValue("(llll)", r
->left
, r
->top
, r
->right
, r
->bottom
);
92 LongPt_Convert(PyObject
*v
, LongPt
*p
)
94 return PyArg_Parse(v
, "(ll)", &p
->h
, &p
->v
);
100 return Py_BuildValue("(ll)", p
->h
, p
->v
);
103 /* Stuff for the callbacks: */
104 static PyObject
*callbackdict
;
105 WENewObjectUPP upp_new_handler
;
106 WEDisposeObjectUPP upp_dispose_handler
;
107 WEDrawObjectUPP upp_draw_handler
;
108 WEClickObjectUPP upp_click_handler
;
111 any_handler(WESelector what
, WEObjectReference who
, PyObject
*args
, PyObject
**rv
)
114 PyObject
*key
, *func
;
116 if ( args
== NULL
) return errAECorruptData
;
118 tp
= WEGetObjectType(who
);
120 if( (key
=Py_BuildValue("O&O&", PyMac_BuildOSType
, tp
, PyMac_BuildOSType
, what
)) == NULL
)
121 return errAECorruptData
;
122 if( (func
= PyDict_GetItem(callbackdict
, key
)) == NULL
) {
124 return errAEHandlerNotFound
;
127 *rv
= PyEval_CallObject(func
, args
);
131 PySys_WriteStderr("--Exception in callback: ");
133 return errAEReplyNotArrived
;
139 my_new_handler(Point
*objectSize
, WEObjectReference objref
)
141 PyObject
*args
=NULL
, *rv
=NULL
;
144 args
=Py_BuildValue("(O&)", WEOObj_New
, objref
);
145 err
= any_handler(weNewHandler
, objref
, args
, &rv
);
147 if (!PyMac_GetPoint(rv
, objectSize
) )
148 err
= errAECoercionFail
;
150 if ( args
) Py_DECREF(args
);
151 if ( rv
) Py_DECREF(rv
);
156 my_dispose_handler(WEObjectReference objref
)
158 PyObject
*args
=NULL
, *rv
=NULL
;
161 args
=Py_BuildValue("(O&)", WEOObj_New
, objref
);
162 err
= any_handler(weDisposeHandler
, objref
, args
, &rv
);
163 if ( args
) Py_DECREF(args
);
164 if ( rv
) Py_DECREF(rv
);
169 my_draw_handler(const Rect
*destRect
, WEObjectReference objref
)
171 PyObject
*args
=NULL
, *rv
=NULL
;
174 args
=Py_BuildValue("O&O&", PyMac_BuildRect
, destRect
, WEOObj_New
, objref
);
175 err
= any_handler(weDrawHandler
, objref
, args
, &rv
);
176 if ( args
) Py_DECREF(args
);
177 if ( rv
) Py_DECREF(rv
);
181 static pascal Boolean
182 my_click_handler(Point hitPt
, EventModifiers modifiers
,
183 unsigned long clickTime
, WEObjectReference objref
)
185 PyObject
*args
=NULL
, *rv
=NULL
;
189 args
=Py_BuildValue("O&llO&", PyMac_BuildPoint
, hitPt
,
190 (long)modifiers
, (long)clickTime
, WEOObj_New
, objref
);
191 err
= any_handler(weClickHandler
, objref
, args
, &rv
);
193 retvalue
= PyInt_AsLong(rv
);
196 if ( args
) Py_DECREF(args
);
197 if ( rv
) Py_DECREF(rv
);
203 static PyObject
*waste_Error
;
205 /* ------------------------ Object type WEO ------------------------- */
207 PyTypeObject WEO_Type
;
209 #define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
211 typedef struct WEOObject
{
213 WEObjectReference ob_itself
;
216 PyObject
*WEOObj_New(WEObjectReference itself
)
219 if (itself
== NULL
) {
223 it
= PyObject_NEW(WEOObject
, &WEO_Type
);
224 if (it
== NULL
) return NULL
;
225 it
->ob_itself
= itself
;
226 return (PyObject
*)it
;
228 int WEOObj_Convert(PyObject
*v
, WEObjectReference
*p_itself
)
230 if (!WEOObj_Check(v
))
232 PyErr_SetString(PyExc_TypeError
, "WEO required");
235 *p_itself
= ((WEOObject
*)v
)->ob_itself
;
239 static void WEOObj_dealloc(WEOObject
*self
)
241 /* Cleanup of self->ob_itself goes here */
245 static PyObject
*WEOObj_WEGetObjectType(WEOObject
*_self
, PyObject
*_args
)
247 PyObject
*_res
= NULL
;
249 if (!PyArg_ParseTuple(_args
, ""))
251 _rv
= WEGetObjectType(_self
->ob_itself
);
252 _res
= Py_BuildValue("O&",
253 PyMac_BuildOSType
, _rv
);
257 static PyObject
*WEOObj_WEGetObjectDataHandle(WEOObject
*_self
, PyObject
*_args
)
259 PyObject
*_res
= NULL
;
261 if (!PyArg_ParseTuple(_args
, ""))
263 _rv
= WEGetObjectDataHandle(_self
->ob_itself
);
264 _res
= Py_BuildValue("O&",
269 static PyObject
*WEOObj_WEGetObjectOwner(WEOObject
*_self
, PyObject
*_args
)
271 PyObject
*_res
= NULL
;
273 if (!PyArg_ParseTuple(_args
, ""))
275 _rv
= WEGetObjectOwner(_self
->ob_itself
);
276 _res
= Py_BuildValue("O&",
277 ExistingwasteObj_New
, _rv
);
281 static PyObject
*WEOObj_WEGetObjectOffset(WEOObject
*_self
, PyObject
*_args
)
283 PyObject
*_res
= NULL
;
285 if (!PyArg_ParseTuple(_args
, ""))
287 _rv
= WEGetObjectOffset(_self
->ob_itself
);
288 _res
= Py_BuildValue("l",
293 static PyObject
*WEOObj_WEGetObjectSize(WEOObject
*_self
, PyObject
*_args
)
295 PyObject
*_res
= NULL
;
297 if (!PyArg_ParseTuple(_args
, ""))
299 _rv
= WEGetObjectSize(_self
->ob_itself
);
300 _res
= Py_BuildValue("O&",
301 PyMac_BuildPoint
, _rv
);
305 static PyObject
*WEOObj_WESetObjectSize(WEOObject
*_self
, PyObject
*_args
)
307 PyObject
*_res
= NULL
;
310 if (!PyArg_ParseTuple(_args
, "O&",
311 PyMac_GetPoint
, &inObjectSize
))
313 _err
= WESetObjectSize(_self
->ob_itself
,
315 if (_err
!= noErr
) return PyMac_Error(_err
);
321 static PyObject
*WEOObj_WEGetObjectFrame(WEOObject
*_self
, PyObject
*_args
)
323 PyObject
*_res
= NULL
;
325 LongRect outObjectFrame
;
326 if (!PyArg_ParseTuple(_args
, ""))
328 _err
= WEGetObjectFrame(_self
->ob_itself
,
330 if (_err
!= noErr
) return PyMac_Error(_err
);
331 _res
= Py_BuildValue("O&",
332 LongRect_New
, &outObjectFrame
);
336 static PyObject
*WEOObj_WEGetObjectRefCon(WEOObject
*_self
, PyObject
*_args
)
338 PyObject
*_res
= NULL
;
340 if (!PyArg_ParseTuple(_args
, ""))
342 _rv
= WEGetObjectRefCon(_self
->ob_itself
);
343 _res
= Py_BuildValue("l",
348 static PyObject
*WEOObj_WESetObjectRefCon(WEOObject
*_self
, PyObject
*_args
)
350 PyObject
*_res
= NULL
;
352 if (!PyArg_ParseTuple(_args
, "l",
355 WESetObjectRefCon(_self
->ob_itself
,
362 static PyMethodDef WEOObj_methods
[] = {
363 {"WEGetObjectType", (PyCFunction
)WEOObj_WEGetObjectType
, 1,
364 PyDoc_STR("() -> (FlavorType _rv)")},
365 {"WEGetObjectDataHandle", (PyCFunction
)WEOObj_WEGetObjectDataHandle
, 1,
366 PyDoc_STR("() -> (Handle _rv)")},
367 {"WEGetObjectOwner", (PyCFunction
)WEOObj_WEGetObjectOwner
, 1,
368 PyDoc_STR("() -> (WEReference _rv)")},
369 {"WEGetObjectOffset", (PyCFunction
)WEOObj_WEGetObjectOffset
, 1,
370 PyDoc_STR("() -> (SInt32 _rv)")},
371 {"WEGetObjectSize", (PyCFunction
)WEOObj_WEGetObjectSize
, 1,
372 PyDoc_STR("() -> (Point _rv)")},
373 {"WESetObjectSize", (PyCFunction
)WEOObj_WESetObjectSize
, 1,
374 PyDoc_STR("(Point inObjectSize) -> None")},
375 {"WEGetObjectFrame", (PyCFunction
)WEOObj_WEGetObjectFrame
, 1,
376 PyDoc_STR("() -> (LongRect outObjectFrame)")},
377 {"WEGetObjectRefCon", (PyCFunction
)WEOObj_WEGetObjectRefCon
, 1,
378 PyDoc_STR("() -> (SInt32 _rv)")},
379 {"WESetObjectRefCon", (PyCFunction
)WEOObj_WESetObjectRefCon
, 1,
380 PyDoc_STR("(SInt32 inRefCon) -> None")},
384 PyMethodChain WEOObj_chain
= { WEOObj_methods
, NULL
};
386 static PyObject
*WEOObj_getattr(WEOObject
*self
, char *name
)
388 return Py_FindMethodInChain(&WEOObj_chain
, (PyObject
*)self
, name
);
391 #define WEOObj_setattr NULL
393 #define WEOObj_compare NULL
395 #define WEOObj_repr NULL
397 #define WEOObj_hash NULL
399 PyTypeObject WEO_Type
= {
400 PyObject_HEAD_INIT(NULL
)
402 "waste.WEO", /*tp_name*/
403 sizeof(WEOObject
), /*tp_basicsize*/
406 (destructor
) WEOObj_dealloc
, /*tp_dealloc*/
408 (getattrfunc
) WEOObj_getattr
, /*tp_getattr*/
409 (setattrfunc
) WEOObj_setattr
, /*tp_setattr*/
410 (cmpfunc
) WEOObj_compare
, /*tp_compare*/
411 (reprfunc
) WEOObj_repr
, /*tp_repr*/
412 (PyNumberMethods
*)0, /* tp_as_number */
413 (PySequenceMethods
*)0, /* tp_as_sequence */
414 (PyMappingMethods
*)0, /* tp_as_mapping */
415 (hashfunc
) WEOObj_hash
, /*tp_hash*/
418 /* ---------------------- End object type WEO ----------------------- */
421 /* ----------------------- Object type waste ------------------------ */
423 PyTypeObject waste_Type
;
425 #define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
427 typedef struct wasteObject
{
429 WEReference ob_itself
;
432 PyObject
*wasteObj_New(WEReference itself
)
435 if (itself
== NULL
) {
436 PyErr_SetString(waste_Error
,"Cannot create null WE");
439 it
= PyObject_NEW(wasteObject
, &waste_Type
);
440 if (it
== NULL
) return NULL
;
441 it
->ob_itself
= itself
;
442 WESetInfo(weRefCon
, (void *)&it
, itself
);
443 return (PyObject
*)it
;
445 int wasteObj_Convert(PyObject
*v
, WEReference
*p_itself
)
447 if (!wasteObj_Check(v
))
449 PyErr_SetString(PyExc_TypeError
, "waste required");
452 *p_itself
= ((wasteObject
*)v
)->ob_itself
;
456 static void wasteObj_dealloc(wasteObject
*self
)
458 WEDispose(self
->ob_itself
);
462 static PyObject
*wasteObj_WEGetText(wasteObject
*_self
, PyObject
*_args
)
464 PyObject
*_res
= NULL
;
466 if (!PyArg_ParseTuple(_args
, ""))
468 _rv
= WEGetText(_self
->ob_itself
);
469 _res
= Py_BuildValue("O&",
474 static PyObject
*wasteObj_WEGetChar(wasteObject
*_self
, PyObject
*_args
)
476 PyObject
*_res
= NULL
;
479 if (!PyArg_ParseTuple(_args
, "l",
482 _rv
= WEGetChar(inOffset
,
484 _res
= Py_BuildValue("h",
489 static PyObject
*wasteObj_WEGetTextLength(wasteObject
*_self
, PyObject
*_args
)
491 PyObject
*_res
= NULL
;
493 if (!PyArg_ParseTuple(_args
, ""))
495 _rv
= WEGetTextLength(_self
->ob_itself
);
496 _res
= Py_BuildValue("l",
501 static PyObject
*wasteObj_WEGetSelection(wasteObject
*_self
, PyObject
*_args
)
503 PyObject
*_res
= NULL
;
506 if (!PyArg_ParseTuple(_args
, ""))
508 WEGetSelection(&outSelStart
,
511 _res
= Py_BuildValue("ll",
517 static PyObject
*wasteObj_WEGetDestRect(wasteObject
*_self
, PyObject
*_args
)
519 PyObject
*_res
= NULL
;
520 LongRect outDestRect
;
521 if (!PyArg_ParseTuple(_args
, ""))
523 WEGetDestRect(&outDestRect
,
525 _res
= Py_BuildValue("O&",
526 LongRect_New
, &outDestRect
);
530 static PyObject
*wasteObj_WEGetViewRect(wasteObject
*_self
, PyObject
*_args
)
532 PyObject
*_res
= NULL
;
533 LongRect outViewRect
;
534 if (!PyArg_ParseTuple(_args
, ""))
536 WEGetViewRect(&outViewRect
,
538 _res
= Py_BuildValue("O&",
539 LongRect_New
, &outViewRect
);
543 static PyObject
*wasteObj_WEIsActive(wasteObject
*_self
, PyObject
*_args
)
545 PyObject
*_res
= NULL
;
547 if (!PyArg_ParseTuple(_args
, ""))
549 _rv
= WEIsActive(_self
->ob_itself
);
550 _res
= Py_BuildValue("b",
555 static PyObject
*wasteObj_WEGetClickCount(wasteObject
*_self
, PyObject
*_args
)
557 PyObject
*_res
= NULL
;
559 if (!PyArg_ParseTuple(_args
, ""))
561 _rv
= WEGetClickCount(_self
->ob_itself
);
562 _res
= Py_BuildValue("H",
567 static PyObject
*wasteObj_WESetSelection(wasteObject
*_self
, PyObject
*_args
)
569 PyObject
*_res
= NULL
;
572 if (!PyArg_ParseTuple(_args
, "ll",
576 WESetSelection(inSelStart
,
584 static PyObject
*wasteObj_WESetDestRect(wasteObject
*_self
, PyObject
*_args
)
586 PyObject
*_res
= NULL
;
588 if (!PyArg_ParseTuple(_args
, "O&",
589 LongRect_Convert
, &inDestRect
))
591 WESetDestRect(&inDestRect
,
598 static PyObject
*wasteObj_WESetViewRect(wasteObject
*_self
, PyObject
*_args
)
600 PyObject
*_res
= NULL
;
602 if (!PyArg_ParseTuple(_args
, "O&",
603 LongRect_Convert
, &inViewRect
))
605 WESetViewRect(&inViewRect
,
612 static PyObject
*wasteObj_WEContinuousStyle(wasteObject
*_self
, PyObject
*_args
)
614 PyObject
*_res
= NULL
;
617 TextStyle outTextStyle
;
618 if (!PyArg_ParseTuple(_args
, "H",
621 _rv
= WEContinuousStyle(&ioMode
,
624 _res
= Py_BuildValue("bHO&",
627 TextStyle_New
, &outTextStyle
);
631 static PyObject
*wasteObj_WECountRuns(wasteObject
*_self
, PyObject
*_args
)
633 PyObject
*_res
= NULL
;
635 if (!PyArg_ParseTuple(_args
, ""))
637 _rv
= WECountRuns(_self
->ob_itself
);
638 _res
= Py_BuildValue("l",
643 static PyObject
*wasteObj_WEOffsetToRun(wasteObject
*_self
, PyObject
*_args
)
645 PyObject
*_res
= NULL
;
648 if (!PyArg_ParseTuple(_args
, "l",
651 _rv
= WEOffsetToRun(inOffset
,
653 _res
= Py_BuildValue("l",
658 static PyObject
*wasteObj_WEGetRunRange(wasteObject
*_self
, PyObject
*_args
)
660 PyObject
*_res
= NULL
;
661 SInt32 inStyleRunIndex
;
662 SInt32 outStyleRunStart
;
663 SInt32 outStyleRunEnd
;
664 if (!PyArg_ParseTuple(_args
, "l",
667 WEGetRunRange(inStyleRunIndex
,
671 _res
= Py_BuildValue("ll",
677 static PyObject
*wasteObj_WEGetRunInfo(wasteObject
*_self
, PyObject
*_args
)
679 PyObject
*_res
= NULL
;
681 WERunInfo outStyleRunInfo
;
682 if (!PyArg_ParseTuple(_args
, "l",
685 WEGetRunInfo(inOffset
,
688 _res
= Py_BuildValue("O&",
689 RunInfo_New
, &outStyleRunInfo
);
693 static PyObject
*wasteObj_WEGetIndRunInfo(wasteObject
*_self
, PyObject
*_args
)
695 PyObject
*_res
= NULL
;
696 SInt32 inStyleRunIndex
;
697 WERunInfo outStyleRunInfo
;
698 if (!PyArg_ParseTuple(_args
, "l",
701 WEGetIndRunInfo(inStyleRunIndex
,
704 _res
= Py_BuildValue("O&",
705 RunInfo_New
, &outStyleRunInfo
);
709 static PyObject
*wasteObj_WEGetRunDirection(wasteObject
*_self
, PyObject
*_args
)
711 PyObject
*_res
= NULL
;
714 if (!PyArg_ParseTuple(_args
, "l",
717 _rv
= WEGetRunDirection(inOffset
,
719 _res
= Py_BuildValue("b",
724 static PyObject
*wasteObj_WECountParaRuns(wasteObject
*_self
, PyObject
*_args
)
726 PyObject
*_res
= NULL
;
728 if (!PyArg_ParseTuple(_args
, ""))
730 _rv
= WECountParaRuns(_self
->ob_itself
);
731 _res
= Py_BuildValue("l",
736 static PyObject
*wasteObj_WEOffsetToParaRun(wasteObject
*_self
, PyObject
*_args
)
738 PyObject
*_res
= NULL
;
741 if (!PyArg_ParseTuple(_args
, "l",
744 _rv
= WEOffsetToParaRun(inOffset
,
746 _res
= Py_BuildValue("l",
751 static PyObject
*wasteObj_WEGetParaRunRange(wasteObject
*_self
, PyObject
*_args
)
753 PyObject
*_res
= NULL
;
754 SInt32 inParagraphRunIndex
;
755 SInt32 outParagraphRunStart
;
756 SInt32 outParagraphRunEnd
;
757 if (!PyArg_ParseTuple(_args
, "l",
758 &inParagraphRunIndex
))
760 WEGetParaRunRange(inParagraphRunIndex
,
761 &outParagraphRunStart
,
764 _res
= Py_BuildValue("ll",
765 outParagraphRunStart
,
770 static PyObject
*wasteObj_WECountLines(wasteObject
*_self
, PyObject
*_args
)
772 PyObject
*_res
= NULL
;
774 if (!PyArg_ParseTuple(_args
, ""))
776 _rv
= WECountLines(_self
->ob_itself
);
777 _res
= Py_BuildValue("l",
782 static PyObject
*wasteObj_WEOffsetToLine(wasteObject
*_self
, PyObject
*_args
)
784 PyObject
*_res
= NULL
;
787 if (!PyArg_ParseTuple(_args
, "l",
790 _rv
= WEOffsetToLine(inOffset
,
792 _res
= Py_BuildValue("l",
797 static PyObject
*wasteObj_WEGetLineRange(wasteObject
*_self
, PyObject
*_args
)
799 PyObject
*_res
= NULL
;
803 if (!PyArg_ParseTuple(_args
, "l",
806 WEGetLineRange(inLineIndex
,
810 _res
= Py_BuildValue("ll",
816 static PyObject
*wasteObj_WEGetHeight(wasteObject
*_self
, PyObject
*_args
)
818 PyObject
*_res
= NULL
;
820 SInt32 inStartLineIndex
;
821 SInt32 inEndLineIndex
;
822 if (!PyArg_ParseTuple(_args
, "ll",
826 _rv
= WEGetHeight(inStartLineIndex
,
829 _res
= Py_BuildValue("l",
834 static PyObject
*wasteObj_WEGetOffset(wasteObject
*_self
, PyObject
*_args
)
836 PyObject
*_res
= NULL
;
840 if (!PyArg_ParseTuple(_args
, "O&",
841 LongPt_Convert
, &inPoint
))
843 _rv
= WEGetOffset(&inPoint
,
846 _res
= Py_BuildValue("lB",
852 static PyObject
*wasteObj_WEGetPoint(wasteObject
*_self
, PyObject
*_args
)
854 PyObject
*_res
= NULL
;
858 SInt16 outLineHeight
;
859 if (!PyArg_ParseTuple(_args
, "lh",
868 _res
= Py_BuildValue("O&h",
869 LongPt_New
, &outPoint
,
874 static PyObject
*wasteObj_WEFindWord(wasteObject
*_self
, PyObject
*_args
)
876 PyObject
*_res
= NULL
;
881 if (!PyArg_ParseTuple(_args
, "lB",
890 _res
= Py_BuildValue("ll",
896 static PyObject
*wasteObj_WEFindLine(wasteObject
*_self
, PyObject
*_args
)
898 PyObject
*_res
= NULL
;
903 if (!PyArg_ParseTuple(_args
, "lB",
912 _res
= Py_BuildValue("ll",
918 static PyObject
*wasteObj_WEFindParagraph(wasteObject
*_self
, PyObject
*_args
)
920 PyObject
*_res
= NULL
;
923 SInt32 outParagraphStart
;
924 SInt32 outParagraphEnd
;
925 if (!PyArg_ParseTuple(_args
, "lB",
929 WEFindParagraph(inOffset
,
934 _res
= Py_BuildValue("ll",
940 static PyObject
*wasteObj_WEFind(wasteObject
*_self
, PyObject
*_args
)
942 PyObject
*_res
= NULL
;
946 TextEncoding inKeyEncoding
;
947 OptionBits inMatchOptions
;
950 SInt32 outMatchStart
;
952 if (!PyArg_ParseTuple(_args
, "slllll",
969 if (_err
!= noErr
) return PyMac_Error(_err
);
970 _res
= Py_BuildValue("ll",
976 static PyObject
*wasteObj_WEStreamRange(wasteObject
*_self
, PyObject
*_args
)
978 PyObject
*_res
= NULL
;
982 FlavorType inRequestedType
;
983 OptionBits inStreamOptions
;
985 if (!PyArg_ParseTuple(_args
, "llO&lO&",
988 PyMac_GetOSType
, &inRequestedType
,
990 ResObj_Convert
, &outData
))
992 _err
= WEStreamRange(inRangeStart
,
998 if (_err
!= noErr
) return PyMac_Error(_err
);
1004 static PyObject
*wasteObj_WECopyRange(wasteObject
*_self
, PyObject
*_args
)
1006 PyObject
*_res
= NULL
;
1008 SInt32 inRangeStart
;
1011 StScrpHandle outStyles
;
1012 WESoupHandle outSoup
;
1013 if (!PyArg_ParseTuple(_args
, "llO&O&O&",
1016 OptResObj_Convert
, &outText
,
1017 OptResObj_Convert
, &outStyles
,
1018 OptResObj_Convert
, &outSoup
))
1020 _err
= WECopyRange(inRangeStart
,
1026 if (_err
!= noErr
) return PyMac_Error(_err
);
1032 static PyObject
*wasteObj_WEGetTextRangeAsUnicode(wasteObject
*_self
, PyObject
*_args
)
1034 PyObject
*_res
= NULL
;
1036 SInt32 inRangeStart
;
1038 Handle outUnicodeText
;
1039 Handle ioCharFormat
;
1040 Handle ioParaFormat
;
1041 TextEncodingVariant inUnicodeVariant
;
1042 TextEncodingFormat inTransformationFormat
;
1043 OptionBits inGetOptions
;
1044 if (!PyArg_ParseTuple(_args
, "llO&O&O&lll",
1047 ResObj_Convert
, &outUnicodeText
,
1048 ResObj_Convert
, &ioCharFormat
,
1049 ResObj_Convert
, &ioParaFormat
,
1051 &inTransformationFormat
,
1054 _err
= WEGetTextRangeAsUnicode(inRangeStart
,
1060 inTransformationFormat
,
1063 if (_err
!= noErr
) return PyMac_Error(_err
);
1069 static PyObject
*wasteObj_WEGetAlignment(wasteObject
*_self
, PyObject
*_args
)
1071 PyObject
*_res
= NULL
;
1073 if (!PyArg_ParseTuple(_args
, ""))
1075 _rv
= WEGetAlignment(_self
->ob_itself
);
1076 _res
= Py_BuildValue("B",
1081 static PyObject
*wasteObj_WESetAlignment(wasteObject
*_self
, PyObject
*_args
)
1083 PyObject
*_res
= NULL
;
1084 WEAlignment inAlignment
;
1085 if (!PyArg_ParseTuple(_args
, "B",
1088 WESetAlignment(inAlignment
,
1095 static PyObject
*wasteObj_WEGetDirection(wasteObject
*_self
, PyObject
*_args
)
1097 PyObject
*_res
= NULL
;
1099 if (!PyArg_ParseTuple(_args
, ""))
1101 _rv
= WEGetDirection(_self
->ob_itself
);
1102 _res
= Py_BuildValue("h",
1107 static PyObject
*wasteObj_WESetDirection(wasteObject
*_self
, PyObject
*_args
)
1109 PyObject
*_res
= NULL
;
1110 WEDirection inDirection
;
1111 if (!PyArg_ParseTuple(_args
, "h",
1114 WESetDirection(inDirection
,
1121 static PyObject
*wasteObj_WECalText(wasteObject
*_self
, PyObject
*_args
)
1123 PyObject
*_res
= NULL
;
1125 if (!PyArg_ParseTuple(_args
, ""))
1127 _err
= WECalText(_self
->ob_itself
);
1128 if (_err
!= noErr
) return PyMac_Error(_err
);
1134 static PyObject
*wasteObj_WEUpdate(wasteObject
*_self
, PyObject
*_args
)
1136 PyObject
*_res
= NULL
;
1137 RgnHandle inUpdateRgn
;
1138 if (!PyArg_ParseTuple(_args
, "O&",
1139 ResObj_Convert
, &inUpdateRgn
))
1141 WEUpdate(inUpdateRgn
,
1148 static PyObject
*wasteObj_WEScroll(wasteObject
*_self
, PyObject
*_args
)
1150 PyObject
*_res
= NULL
;
1151 SInt32 inHorizontalOffset
;
1152 SInt32 inVerticalOffset
;
1153 if (!PyArg_ParseTuple(_args
, "ll",
1154 &inHorizontalOffset
,
1157 WEScroll(inHorizontalOffset
,
1165 static PyObject
*wasteObj_WEPinScroll(wasteObject
*_self
, PyObject
*_args
)
1167 PyObject
*_res
= NULL
;
1168 SInt32 inHorizontalOffset
;
1169 SInt32 inVerticalOffset
;
1170 if (!PyArg_ParseTuple(_args
, "ll",
1171 &inHorizontalOffset
,
1174 WEPinScroll(inHorizontalOffset
,
1182 static PyObject
*wasteObj_WESelView(wasteObject
*_self
, PyObject
*_args
)
1184 PyObject
*_res
= NULL
;
1185 if (!PyArg_ParseTuple(_args
, ""))
1187 WESelView(_self
->ob_itself
);
1193 static PyObject
*wasteObj_WEActivate(wasteObject
*_self
, PyObject
*_args
)
1195 PyObject
*_res
= NULL
;
1196 if (!PyArg_ParseTuple(_args
, ""))
1198 WEActivate(_self
->ob_itself
);
1204 static PyObject
*wasteObj_WEDeactivate(wasteObject
*_self
, PyObject
*_args
)
1206 PyObject
*_res
= NULL
;
1207 if (!PyArg_ParseTuple(_args
, ""))
1209 WEDeactivate(_self
->ob_itself
);
1215 static PyObject
*wasteObj_WEKey(wasteObject
*_self
, PyObject
*_args
)
1217 PyObject
*_res
= NULL
;
1218 CharParameter inKey
;
1219 EventModifiers inModifiers
;
1220 if (!PyArg_ParseTuple(_args
, "hH",
1232 static PyObject
*wasteObj_WEClick(wasteObject
*_self
, PyObject
*_args
)
1234 PyObject
*_res
= NULL
;
1236 EventModifiers inModifiers
;
1238 if (!PyArg_ParseTuple(_args
, "O&Hl",
1239 PyMac_GetPoint
, &inHitPoint
,
1252 static PyObject
*wasteObj_WEAdjustCursor(wasteObject
*_self
, PyObject
*_args
)
1254 PyObject
*_res
= NULL
;
1257 RgnHandle ioMouseRgn
;
1258 if (!PyArg_ParseTuple(_args
, "O&O&",
1259 PyMac_GetPoint
, &inMouseLoc
,
1260 ResObj_Convert
, &ioMouseRgn
))
1262 _rv
= WEAdjustCursor(inMouseLoc
,
1265 _res
= Py_BuildValue("b",
1270 static PyObject
*wasteObj_WEIdle(wasteObject
*_self
, PyObject
*_args
)
1272 PyObject
*_res
= NULL
;
1274 if (!PyArg_ParseTuple(_args
, ""))
1276 WEIdle(&outMaxSleep
,
1278 _res
= Py_BuildValue("l",
1283 static PyObject
*wasteObj_WEInsert(wasteObject
*_self
, PyObject
*_args
)
1285 PyObject
*_res
= NULL
;
1287 char *inTextPtr__in__
;
1288 long inTextPtr__len__
;
1289 int inTextPtr__in_len__
;
1290 StScrpHandle inStyles
;
1291 WESoupHandle inSoup
;
1292 if (!PyArg_ParseTuple(_args
, "s#O&O&",
1293 &inTextPtr__in__
, &inTextPtr__in_len__
,
1294 OptResObj_Convert
, &inStyles
,
1295 OptResObj_Convert
, &inSoup
))
1297 inTextPtr__len__
= inTextPtr__in_len__
;
1298 _err
= WEInsert(inTextPtr__in__
, inTextPtr__len__
,
1302 if (_err
!= noErr
) return PyMac_Error(_err
);
1308 static PyObject
*wasteObj_WEInsertFormattedText(wasteObject
*_self
, PyObject
*_args
)
1310 PyObject
*_res
= NULL
;
1312 char *inTextPtr__in__
;
1313 long inTextPtr__len__
;
1314 int inTextPtr__in_len__
;
1315 StScrpHandle inStyles
;
1316 WESoupHandle inSoup
;
1317 Handle inParaFormat
;
1318 Handle inRulerScrap
;
1319 if (!PyArg_ParseTuple(_args
, "s#O&O&O&O&",
1320 &inTextPtr__in__
, &inTextPtr__in_len__
,
1321 OptResObj_Convert
, &inStyles
,
1322 OptResObj_Convert
, &inSoup
,
1323 ResObj_Convert
, &inParaFormat
,
1324 ResObj_Convert
, &inRulerScrap
))
1326 inTextPtr__len__
= inTextPtr__in_len__
;
1327 _err
= WEInsertFormattedText(inTextPtr__in__
, inTextPtr__len__
,
1333 if (_err
!= noErr
) return PyMac_Error(_err
);
1339 static PyObject
*wasteObj_WEDelete(wasteObject
*_self
, PyObject
*_args
)
1341 PyObject
*_res
= NULL
;
1343 if (!PyArg_ParseTuple(_args
, ""))
1345 _err
= WEDelete(_self
->ob_itself
);
1346 if (_err
!= noErr
) return PyMac_Error(_err
);
1352 static PyObject
*wasteObj_WEUseText(wasteObject
*_self
, PyObject
*_args
)
1354 PyObject
*_res
= NULL
;
1357 if (!PyArg_ParseTuple(_args
, "O&",
1358 ResObj_Convert
, &inText
))
1360 _err
= WEUseText(inText
,
1362 if (_err
!= noErr
) return PyMac_Error(_err
);
1368 static PyObject
*wasteObj_WEChangeCase(wasteObject
*_self
, PyObject
*_args
)
1370 PyObject
*_res
= NULL
;
1373 if (!PyArg_ParseTuple(_args
, "h",
1376 _err
= WEChangeCase(inCase
,
1378 if (_err
!= noErr
) return PyMac_Error(_err
);
1384 static PyObject
*wasteObj_WESetOneAttribute(wasteObject
*_self
, PyObject
*_args
)
1386 PyObject
*_res
= NULL
;
1388 SInt32 inRangeStart
;
1390 WESelector inAttributeSelector
;
1391 char *inAttributeValue__in__
;
1392 long inAttributeValue__len__
;
1393 int inAttributeValue__in_len__
;
1394 if (!PyArg_ParseTuple(_args
, "llO&s#",
1397 PyMac_GetOSType
, &inAttributeSelector
,
1398 &inAttributeValue__in__
, &inAttributeValue__in_len__
))
1400 inAttributeValue__len__
= inAttributeValue__in_len__
;
1401 _err
= WESetOneAttribute(inRangeStart
,
1403 inAttributeSelector
,
1404 inAttributeValue__in__
, inAttributeValue__len__
,
1406 if (_err
!= noErr
) return PyMac_Error(_err
);
1412 static PyObject
*wasteObj_WESetStyle(wasteObject
*_self
, PyObject
*_args
)
1414 PyObject
*_res
= NULL
;
1417 TextStyle inTextStyle
;
1418 if (!PyArg_ParseTuple(_args
, "HO&",
1420 TextStyle_Convert
, &inTextStyle
))
1422 _err
= WESetStyle(inMode
,
1425 if (_err
!= noErr
) return PyMac_Error(_err
);
1431 static PyObject
*wasteObj_WEUseStyleScrap(wasteObject
*_self
, PyObject
*_args
)
1433 PyObject
*_res
= NULL
;
1435 StScrpHandle inStyles
;
1436 if (!PyArg_ParseTuple(_args
, "O&",
1437 ResObj_Convert
, &inStyles
))
1439 _err
= WEUseStyleScrap(inStyles
,
1441 if (_err
!= noErr
) return PyMac_Error(_err
);
1447 static PyObject
*wasteObj_WEUndo(wasteObject
*_self
, PyObject
*_args
)
1449 PyObject
*_res
= NULL
;
1451 if (!PyArg_ParseTuple(_args
, ""))
1453 _err
= WEUndo(_self
->ob_itself
);
1454 if (_err
!= noErr
) return PyMac_Error(_err
);
1460 static PyObject
*wasteObj_WERedo(wasteObject
*_self
, PyObject
*_args
)
1462 PyObject
*_res
= NULL
;
1464 if (!PyArg_ParseTuple(_args
, ""))
1466 _err
= WERedo(_self
->ob_itself
);
1467 if (_err
!= noErr
) return PyMac_Error(_err
);
1473 static PyObject
*wasteObj_WEClearUndo(wasteObject
*_self
, PyObject
*_args
)
1475 PyObject
*_res
= NULL
;
1476 if (!PyArg_ParseTuple(_args
, ""))
1478 WEClearUndo(_self
->ob_itself
);
1484 static PyObject
*wasteObj_WEGetUndoInfo(wasteObject
*_self
, PyObject
*_args
)
1486 PyObject
*_res
= NULL
;
1488 Boolean outRedoFlag
;
1489 if (!PyArg_ParseTuple(_args
, ""))
1491 _rv
= WEGetUndoInfo(&outRedoFlag
,
1493 _res
= Py_BuildValue("hb",
1499 static PyObject
*wasteObj_WEGetIndUndoInfo(wasteObject
*_self
, PyObject
*_args
)
1501 PyObject
*_res
= NULL
;
1504 if (!PyArg_ParseTuple(_args
, "l",
1507 _rv
= WEGetIndUndoInfo(inUndoLevel
,
1509 _res
= Py_BuildValue("h",
1514 static PyObject
*wasteObj_WEIsTyping(wasteObject
*_self
, PyObject
*_args
)
1516 PyObject
*_res
= NULL
;
1518 if (!PyArg_ParseTuple(_args
, ""))
1520 _rv
= WEIsTyping(_self
->ob_itself
);
1521 _res
= Py_BuildValue("b",
1526 static PyObject
*wasteObj_WEBeginAction(wasteObject
*_self
, PyObject
*_args
)
1528 PyObject
*_res
= NULL
;
1530 if (!PyArg_ParseTuple(_args
, ""))
1532 _err
= WEBeginAction(_self
->ob_itself
);
1533 if (_err
!= noErr
) return PyMac_Error(_err
);
1539 static PyObject
*wasteObj_WEEndAction(wasteObject
*_self
, PyObject
*_args
)
1541 PyObject
*_res
= NULL
;
1543 WEActionKind inActionKind
;
1544 if (!PyArg_ParseTuple(_args
, "h",
1547 _err
= WEEndAction(inActionKind
,
1549 if (_err
!= noErr
) return PyMac_Error(_err
);
1555 static PyObject
*wasteObj_WEGetModCount(wasteObject
*_self
, PyObject
*_args
)
1557 PyObject
*_res
= NULL
;
1559 if (!PyArg_ParseTuple(_args
, ""))
1561 _rv
= WEGetModCount(_self
->ob_itself
);
1562 _res
= Py_BuildValue("l",
1567 static PyObject
*wasteObj_WEResetModCount(wasteObject
*_self
, PyObject
*_args
)
1569 PyObject
*_res
= NULL
;
1570 if (!PyArg_ParseTuple(_args
, ""))
1572 WEResetModCount(_self
->ob_itself
);
1578 static PyObject
*wasteObj_WEInsertObject(wasteObject
*_self
, PyObject
*_args
)
1580 PyObject
*_res
= NULL
;
1582 FlavorType inObjectType
;
1583 Handle inObjectDataHandle
;
1585 if (!PyArg_ParseTuple(_args
, "O&O&O&",
1586 PyMac_GetOSType
, &inObjectType
,
1587 ResObj_Convert
, &inObjectDataHandle
,
1588 PyMac_GetPoint
, &inObjectSize
))
1590 _err
= WEInsertObject(inObjectType
,
1594 if (_err
!= noErr
) return PyMac_Error(_err
);
1600 static PyObject
*wasteObj_WEGetSelectedObject(wasteObject
*_self
, PyObject
*_args
)
1602 PyObject
*_res
= NULL
;
1604 WEObjectReference outObject
;
1605 if (!PyArg_ParseTuple(_args
, ""))
1607 _err
= WEGetSelectedObject(&outObject
,
1609 if (_err
!= noErr
) return PyMac_Error(_err
);
1610 _res
= Py_BuildValue("O&",
1611 WEOObj_New
, outObject
);
1615 static PyObject
*wasteObj_WEGetObjectAtOffset(wasteObject
*_self
, PyObject
*_args
)
1617 PyObject
*_res
= NULL
;
1620 WEObjectReference outObject
;
1621 if (!PyArg_ParseTuple(_args
, "l",
1624 _err
= WEGetObjectAtOffset(inOffset
,
1627 if (_err
!= noErr
) return PyMac_Error(_err
);
1628 _res
= Py_BuildValue("O&",
1629 WEOObj_New
, outObject
);
1633 static PyObject
*wasteObj_WEFindNextObject(wasteObject
*_self
, PyObject
*_args
)
1635 PyObject
*_res
= NULL
;
1638 WEObjectReference outObject
;
1639 if (!PyArg_ParseTuple(_args
, "l",
1642 _rv
= WEFindNextObject(inOffset
,
1645 _res
= Py_BuildValue("lO&",
1647 WEOObj_New
, outObject
);
1651 static PyObject
*wasteObj_WEUseSoup(wasteObject
*_self
, PyObject
*_args
)
1653 PyObject
*_res
= NULL
;
1655 WESoupHandle inSoup
;
1656 if (!PyArg_ParseTuple(_args
, "O&",
1657 ResObj_Convert
, &inSoup
))
1659 _err
= WEUseSoup(inSoup
,
1661 if (_err
!= noErr
) return PyMac_Error(_err
);
1667 static PyObject
*wasteObj_WECut(wasteObject
*_self
, PyObject
*_args
)
1669 PyObject
*_res
= NULL
;
1671 if (!PyArg_ParseTuple(_args
, ""))
1673 _err
= WECut(_self
->ob_itself
);
1674 if (_err
!= noErr
) return PyMac_Error(_err
);
1680 static PyObject
*wasteObj_WECopy(wasteObject
*_self
, PyObject
*_args
)
1682 PyObject
*_res
= NULL
;
1684 if (!PyArg_ParseTuple(_args
, ""))
1686 _err
= WECopy(_self
->ob_itself
);
1687 if (_err
!= noErr
) return PyMac_Error(_err
);
1693 static PyObject
*wasteObj_WEPaste(wasteObject
*_self
, PyObject
*_args
)
1695 PyObject
*_res
= NULL
;
1697 if (!PyArg_ParseTuple(_args
, ""))
1699 _err
= WEPaste(_self
->ob_itself
);
1700 if (_err
!= noErr
) return PyMac_Error(_err
);
1706 static PyObject
*wasteObj_WECanPaste(wasteObject
*_self
, PyObject
*_args
)
1708 PyObject
*_res
= NULL
;
1710 if (!PyArg_ParseTuple(_args
, ""))
1712 _rv
= WECanPaste(_self
->ob_itself
);
1713 _res
= Py_BuildValue("b",
1718 static PyObject
*wasteObj_WEGetHiliteRgn(wasteObject
*_self
, PyObject
*_args
)
1720 PyObject
*_res
= NULL
;
1722 SInt32 inRangeStart
;
1724 if (!PyArg_ParseTuple(_args
, "ll",
1728 _rv
= WEGetHiliteRgn(inRangeStart
,
1731 _res
= Py_BuildValue("O&",
1736 static PyObject
*wasteObj_WECharByte(wasteObject
*_self
, PyObject
*_args
)
1738 PyObject
*_res
= NULL
;
1741 if (!PyArg_ParseTuple(_args
, "l",
1744 _rv
= WECharByte(inOffset
,
1746 _res
= Py_BuildValue("h",
1751 static PyObject
*wasteObj_WECharType(wasteObject
*_self
, PyObject
*_args
)
1753 PyObject
*_res
= NULL
;
1756 if (!PyArg_ParseTuple(_args
, "l",
1759 _rv
= WECharType(inOffset
,
1761 _res
= Py_BuildValue("h",
1766 static PyObject
*wasteObj_WEStopInlineSession(wasteObject
*_self
, PyObject
*_args
)
1768 PyObject
*_res
= NULL
;
1769 if (!PyArg_ParseTuple(_args
, ""))
1771 WEStopInlineSession(_self
->ob_itself
);
1777 static PyObject
*wasteObj_WEFeatureFlag(wasteObject
*_self
, PyObject
*_args
)
1779 PyObject
*_res
= NULL
;
1783 if (!PyArg_ParseTuple(_args
, "hh",
1787 _rv
= WEFeatureFlag(inFeature
,
1790 _res
= Py_BuildValue("h",
1795 static PyObject
*wasteObj_WEGetUserInfo(wasteObject
*_self
, PyObject
*_args
)
1797 PyObject
*_res
= NULL
;
1799 WESelector inUserTag
;
1801 if (!PyArg_ParseTuple(_args
, "O&",
1802 PyMac_GetOSType
, &inUserTag
))
1804 _err
= WEGetUserInfo(inUserTag
,
1807 if (_err
!= noErr
) return PyMac_Error(_err
);
1808 _res
= Py_BuildValue("l",
1813 static PyObject
*wasteObj_WESetUserInfo(wasteObject
*_self
, PyObject
*_args
)
1815 PyObject
*_res
= NULL
;
1817 WESelector inUserTag
;
1819 if (!PyArg_ParseTuple(_args
, "O&l",
1820 PyMac_GetOSType
, &inUserTag
,
1823 _err
= WESetUserInfo(inUserTag
,
1826 if (_err
!= noErr
) return PyMac_Error(_err
);
1832 static PyObject
*wasteObj_WERemoveUserInfo(wasteObject
*_self
, PyObject
*_args
)
1834 PyObject
*_res
= NULL
;
1836 WESelector inUserTag
;
1837 if (!PyArg_ParseTuple(_args
, "O&",
1838 PyMac_GetOSType
, &inUserTag
))
1840 _err
= WERemoveUserInfo(inUserTag
,
1842 if (_err
!= noErr
) return PyMac_Error(_err
);
1848 static PyObject
*wasteObj_WEInstallTabHooks(wasteObject
*_self
, PyObject
*_args
)
1850 PyObject
*_res
= NULL
;
1852 if (!PyArg_ParseTuple(_args
, ""))
1854 _err
= WEInstallTabHooks(_self
->ob_itself
);
1855 if (_err
!= noErr
) return PyMac_Error(_err
);
1861 static PyObject
*wasteObj_WERemoveTabHooks(wasteObject
*_self
, PyObject
*_args
)
1863 PyObject
*_res
= NULL
;
1865 if (!PyArg_ParseTuple(_args
, ""))
1867 _err
= WERemoveTabHooks(_self
->ob_itself
);
1868 if (_err
!= noErr
) return PyMac_Error(_err
);
1874 static PyObject
*wasteObj_WEIsTabHooks(wasteObject
*_self
, PyObject
*_args
)
1876 PyObject
*_res
= NULL
;
1878 if (!PyArg_ParseTuple(_args
, ""))
1880 _rv
= WEIsTabHooks(_self
->ob_itself
);
1881 _res
= Py_BuildValue("b",
1886 static PyObject
*wasteObj_WEGetTabSize(wasteObject
*_self
, PyObject
*_args
)
1888 PyObject
*_res
= NULL
;
1890 if (!PyArg_ParseTuple(_args
, ""))
1892 _rv
= WEGetTabSize(_self
->ob_itself
);
1893 _res
= Py_BuildValue("h",
1898 static PyObject
*wasteObj_WESetTabSize(wasteObject
*_self
, PyObject
*_args
)
1900 PyObject
*_res
= NULL
;
1903 if (!PyArg_ParseTuple(_args
, "h",
1906 _err
= WESetTabSize(tabWidth
,
1908 if (_err
!= noErr
) return PyMac_Error(_err
);
1914 static PyMethodDef wasteObj_methods
[] = {
1915 {"WEGetText", (PyCFunction
)wasteObj_WEGetText
, 1,
1916 PyDoc_STR("() -> (Handle _rv)")},
1917 {"WEGetChar", (PyCFunction
)wasteObj_WEGetChar
, 1,
1918 PyDoc_STR("(SInt32 inOffset) -> (SInt16 _rv)")},
1919 {"WEGetTextLength", (PyCFunction
)wasteObj_WEGetTextLength
, 1,
1920 PyDoc_STR("() -> (SInt32 _rv)")},
1921 {"WEGetSelection", (PyCFunction
)wasteObj_WEGetSelection
, 1,
1922 PyDoc_STR("() -> (SInt32 outSelStart, SInt32 outSelEnd)")},
1923 {"WEGetDestRect", (PyCFunction
)wasteObj_WEGetDestRect
, 1,
1924 PyDoc_STR("() -> (LongRect outDestRect)")},
1925 {"WEGetViewRect", (PyCFunction
)wasteObj_WEGetViewRect
, 1,
1926 PyDoc_STR("() -> (LongRect outViewRect)")},
1927 {"WEIsActive", (PyCFunction
)wasteObj_WEIsActive
, 1,
1928 PyDoc_STR("() -> (Boolean _rv)")},
1929 {"WEGetClickCount", (PyCFunction
)wasteObj_WEGetClickCount
, 1,
1930 PyDoc_STR("() -> (UInt16 _rv)")},
1931 {"WESetSelection", (PyCFunction
)wasteObj_WESetSelection
, 1,
1932 PyDoc_STR("(SInt32 inSelStart, SInt32 inSelEnd) -> None")},
1933 {"WESetDestRect", (PyCFunction
)wasteObj_WESetDestRect
, 1,
1934 PyDoc_STR("(LongRect inDestRect) -> None")},
1935 {"WESetViewRect", (PyCFunction
)wasteObj_WESetViewRect
, 1,
1936 PyDoc_STR("(LongRect inViewRect) -> None")},
1937 {"WEContinuousStyle", (PyCFunction
)wasteObj_WEContinuousStyle
, 1,
1938 PyDoc_STR("(WEStyleMode ioMode) -> (Boolean _rv, WEStyleMode ioMode, TextStyle outTextStyle)")},
1939 {"WECountRuns", (PyCFunction
)wasteObj_WECountRuns
, 1,
1940 PyDoc_STR("() -> (SInt32 _rv)")},
1941 {"WEOffsetToRun", (PyCFunction
)wasteObj_WEOffsetToRun
, 1,
1942 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv)")},
1943 {"WEGetRunRange", (PyCFunction
)wasteObj_WEGetRunRange
, 1,
1944 PyDoc_STR("(SInt32 inStyleRunIndex) -> (SInt32 outStyleRunStart, SInt32 outStyleRunEnd)")},
1945 {"WEGetRunInfo", (PyCFunction
)wasteObj_WEGetRunInfo
, 1,
1946 PyDoc_STR("(SInt32 inOffset) -> (WERunInfo outStyleRunInfo)")},
1947 {"WEGetIndRunInfo", (PyCFunction
)wasteObj_WEGetIndRunInfo
, 1,
1948 PyDoc_STR("(SInt32 inStyleRunIndex) -> (WERunInfo outStyleRunInfo)")},
1949 {"WEGetRunDirection", (PyCFunction
)wasteObj_WEGetRunDirection
, 1,
1950 PyDoc_STR("(SInt32 inOffset) -> (Boolean _rv)")},
1951 {"WECountParaRuns", (PyCFunction
)wasteObj_WECountParaRuns
, 1,
1952 PyDoc_STR("() -> (SInt32 _rv)")},
1953 {"WEOffsetToParaRun", (PyCFunction
)wasteObj_WEOffsetToParaRun
, 1,
1954 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv)")},
1955 {"WEGetParaRunRange", (PyCFunction
)wasteObj_WEGetParaRunRange
, 1,
1956 PyDoc_STR("(SInt32 inParagraphRunIndex) -> (SInt32 outParagraphRunStart, SInt32 outParagraphRunEnd)")},
1957 {"WECountLines", (PyCFunction
)wasteObj_WECountLines
, 1,
1958 PyDoc_STR("() -> (SInt32 _rv)")},
1959 {"WEOffsetToLine", (PyCFunction
)wasteObj_WEOffsetToLine
, 1,
1960 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv)")},
1961 {"WEGetLineRange", (PyCFunction
)wasteObj_WEGetLineRange
, 1,
1962 PyDoc_STR("(SInt32 inLineIndex) -> (SInt32 outLineStart, SInt32 outLineEnd)")},
1963 {"WEGetHeight", (PyCFunction
)wasteObj_WEGetHeight
, 1,
1964 PyDoc_STR("(SInt32 inStartLineIndex, SInt32 inEndLineIndex) -> (SInt32 _rv)")},
1965 {"WEGetOffset", (PyCFunction
)wasteObj_WEGetOffset
, 1,
1966 PyDoc_STR("(LongPt inPoint) -> (SInt32 _rv, WEEdge outEdge)")},
1967 {"WEGetPoint", (PyCFunction
)wasteObj_WEGetPoint
, 1,
1968 PyDoc_STR("(SInt32 inOffset, SInt16 inDirection) -> (LongPt outPoint, SInt16 outLineHeight)")},
1969 {"WEFindWord", (PyCFunction
)wasteObj_WEFindWord
, 1,
1970 PyDoc_STR("(SInt32 inOffset, WEEdge inEdge) -> (SInt32 outWordStart, SInt32 outWordEnd)")},
1971 {"WEFindLine", (PyCFunction
)wasteObj_WEFindLine
, 1,
1972 PyDoc_STR("(SInt32 inOffset, WEEdge inEdge) -> (SInt32 outLineStart, SInt32 outLineEnd)")},
1973 {"WEFindParagraph", (PyCFunction
)wasteObj_WEFindParagraph
, 1,
1974 PyDoc_STR("(SInt32 inOffset, WEEdge inEdge) -> (SInt32 outParagraphStart, SInt32 outParagraphEnd)")},
1975 {"WEFind", (PyCFunction
)wasteObj_WEFind
, 1,
1976 PyDoc_STR("(char* inKey, SInt32 inKeyLength, TextEncoding inKeyEncoding, OptionBits inMatchOptions, SInt32 inRangeStart, SInt32 inRangeEnd) -> (SInt32 outMatchStart, SInt32 outMatchEnd)")},
1977 {"WEStreamRange", (PyCFunction
)wasteObj_WEStreamRange
, 1,
1978 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, FlavorType inRequestedType, OptionBits inStreamOptions, Handle outData) -> None")},
1979 {"WECopyRange", (PyCFunction
)wasteObj_WECopyRange
, 1,
1980 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, Handle outText, StScrpHandle outStyles, WESoupHandle outSoup) -> None")},
1981 {"WEGetTextRangeAsUnicode", (PyCFunction
)wasteObj_WEGetTextRangeAsUnicode
, 1,
1982 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, Handle outUnicodeText, Handle ioCharFormat, Handle ioParaFormat, TextEncodingVariant inUnicodeVariant, TextEncodingFormat inTransformationFormat, OptionBits inGetOptions) -> None")},
1983 {"WEGetAlignment", (PyCFunction
)wasteObj_WEGetAlignment
, 1,
1984 PyDoc_STR("() -> (WEAlignment _rv)")},
1985 {"WESetAlignment", (PyCFunction
)wasteObj_WESetAlignment
, 1,
1986 PyDoc_STR("(WEAlignment inAlignment) -> None")},
1987 {"WEGetDirection", (PyCFunction
)wasteObj_WEGetDirection
, 1,
1988 PyDoc_STR("() -> (WEDirection _rv)")},
1989 {"WESetDirection", (PyCFunction
)wasteObj_WESetDirection
, 1,
1990 PyDoc_STR("(WEDirection inDirection) -> None")},
1991 {"WECalText", (PyCFunction
)wasteObj_WECalText
, 1,
1992 PyDoc_STR("() -> None")},
1993 {"WEUpdate", (PyCFunction
)wasteObj_WEUpdate
, 1,
1994 PyDoc_STR("(RgnHandle inUpdateRgn) -> None")},
1995 {"WEScroll", (PyCFunction
)wasteObj_WEScroll
, 1,
1996 PyDoc_STR("(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> None")},
1997 {"WEPinScroll", (PyCFunction
)wasteObj_WEPinScroll
, 1,
1998 PyDoc_STR("(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> None")},
1999 {"WESelView", (PyCFunction
)wasteObj_WESelView
, 1,
2000 PyDoc_STR("() -> None")},
2001 {"WEActivate", (PyCFunction
)wasteObj_WEActivate
, 1,
2002 PyDoc_STR("() -> None")},
2003 {"WEDeactivate", (PyCFunction
)wasteObj_WEDeactivate
, 1,
2004 PyDoc_STR("() -> None")},
2005 {"WEKey", (PyCFunction
)wasteObj_WEKey
, 1,
2006 PyDoc_STR("(CharParameter inKey, EventModifiers inModifiers) -> None")},
2007 {"WEClick", (PyCFunction
)wasteObj_WEClick
, 1,
2008 PyDoc_STR("(Point inHitPoint, EventModifiers inModifiers, UInt32 inClickTime) -> None")},
2009 {"WEAdjustCursor", (PyCFunction
)wasteObj_WEAdjustCursor
, 1,
2010 PyDoc_STR("(Point inMouseLoc, RgnHandle ioMouseRgn) -> (Boolean _rv)")},
2011 {"WEIdle", (PyCFunction
)wasteObj_WEIdle
, 1,
2012 PyDoc_STR("() -> (UInt32 outMaxSleep)")},
2013 {"WEInsert", (PyCFunction
)wasteObj_WEInsert
, 1,
2014 PyDoc_STR("(Buffer inTextPtr, StScrpHandle inStyles, WESoupHandle inSoup) -> None")},
2015 {"WEInsertFormattedText", (PyCFunction
)wasteObj_WEInsertFormattedText
, 1,
2016 PyDoc_STR("(Buffer inTextPtr, StScrpHandle inStyles, WESoupHandle inSoup, Handle inParaFormat, Handle inRulerScrap) -> None")},
2017 {"WEDelete", (PyCFunction
)wasteObj_WEDelete
, 1,
2018 PyDoc_STR("() -> None")},
2019 {"WEUseText", (PyCFunction
)wasteObj_WEUseText
, 1,
2020 PyDoc_STR("(Handle inText) -> None")},
2021 {"WEChangeCase", (PyCFunction
)wasteObj_WEChangeCase
, 1,
2022 PyDoc_STR("(SInt16 inCase) -> None")},
2023 {"WESetOneAttribute", (PyCFunction
)wasteObj_WESetOneAttribute
, 1,
2024 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd, WESelector inAttributeSelector, Buffer inAttributeValue) -> None")},
2025 {"WESetStyle", (PyCFunction
)wasteObj_WESetStyle
, 1,
2026 PyDoc_STR("(WEStyleMode inMode, TextStyle inTextStyle) -> None")},
2027 {"WEUseStyleScrap", (PyCFunction
)wasteObj_WEUseStyleScrap
, 1,
2028 PyDoc_STR("(StScrpHandle inStyles) -> None")},
2029 {"WEUndo", (PyCFunction
)wasteObj_WEUndo
, 1,
2030 PyDoc_STR("() -> None")},
2031 {"WERedo", (PyCFunction
)wasteObj_WERedo
, 1,
2032 PyDoc_STR("() -> None")},
2033 {"WEClearUndo", (PyCFunction
)wasteObj_WEClearUndo
, 1,
2034 PyDoc_STR("() -> None")},
2035 {"WEGetUndoInfo", (PyCFunction
)wasteObj_WEGetUndoInfo
, 1,
2036 PyDoc_STR("() -> (WEActionKind _rv, Boolean outRedoFlag)")},
2037 {"WEGetIndUndoInfo", (PyCFunction
)wasteObj_WEGetIndUndoInfo
, 1,
2038 PyDoc_STR("(SInt32 inUndoLevel) -> (WEActionKind _rv)")},
2039 {"WEIsTyping", (PyCFunction
)wasteObj_WEIsTyping
, 1,
2040 PyDoc_STR("() -> (Boolean _rv)")},
2041 {"WEBeginAction", (PyCFunction
)wasteObj_WEBeginAction
, 1,
2042 PyDoc_STR("() -> None")},
2043 {"WEEndAction", (PyCFunction
)wasteObj_WEEndAction
, 1,
2044 PyDoc_STR("(WEActionKind inActionKind) -> None")},
2045 {"WEGetModCount", (PyCFunction
)wasteObj_WEGetModCount
, 1,
2046 PyDoc_STR("() -> (UInt32 _rv)")},
2047 {"WEResetModCount", (PyCFunction
)wasteObj_WEResetModCount
, 1,
2048 PyDoc_STR("() -> None")},
2049 {"WEInsertObject", (PyCFunction
)wasteObj_WEInsertObject
, 1,
2050 PyDoc_STR("(FlavorType inObjectType, Handle inObjectDataHandle, Point inObjectSize) -> None")},
2051 {"WEGetSelectedObject", (PyCFunction
)wasteObj_WEGetSelectedObject
, 1,
2052 PyDoc_STR("() -> (WEObjectReference outObject)")},
2053 {"WEGetObjectAtOffset", (PyCFunction
)wasteObj_WEGetObjectAtOffset
, 1,
2054 PyDoc_STR("(SInt32 inOffset) -> (WEObjectReference outObject)")},
2055 {"WEFindNextObject", (PyCFunction
)wasteObj_WEFindNextObject
, 1,
2056 PyDoc_STR("(SInt32 inOffset) -> (SInt32 _rv, WEObjectReference outObject)")},
2057 {"WEUseSoup", (PyCFunction
)wasteObj_WEUseSoup
, 1,
2058 PyDoc_STR("(WESoupHandle inSoup) -> None")},
2059 {"WECut", (PyCFunction
)wasteObj_WECut
, 1,
2060 PyDoc_STR("() -> None")},
2061 {"WECopy", (PyCFunction
)wasteObj_WECopy
, 1,
2062 PyDoc_STR("() -> None")},
2063 {"WEPaste", (PyCFunction
)wasteObj_WEPaste
, 1,
2064 PyDoc_STR("() -> None")},
2065 {"WECanPaste", (PyCFunction
)wasteObj_WECanPaste
, 1,
2066 PyDoc_STR("() -> (Boolean _rv)")},
2067 {"WEGetHiliteRgn", (PyCFunction
)wasteObj_WEGetHiliteRgn
, 1,
2068 PyDoc_STR("(SInt32 inRangeStart, SInt32 inRangeEnd) -> (RgnHandle _rv)")},
2069 {"WECharByte", (PyCFunction
)wasteObj_WECharByte
, 1,
2070 PyDoc_STR("(SInt32 inOffset) -> (SInt16 _rv)")},
2071 {"WECharType", (PyCFunction
)wasteObj_WECharType
, 1,
2072 PyDoc_STR("(SInt32 inOffset) -> (SInt16 _rv)")},
2073 {"WEStopInlineSession", (PyCFunction
)wasteObj_WEStopInlineSession
, 1,
2074 PyDoc_STR("() -> None")},
2075 {"WEFeatureFlag", (PyCFunction
)wasteObj_WEFeatureFlag
, 1,
2076 PyDoc_STR("(SInt16 inFeature, SInt16 inAction) -> (SInt16 _rv)")},
2077 {"WEGetUserInfo", (PyCFunction
)wasteObj_WEGetUserInfo
, 1,
2078 PyDoc_STR("(WESelector inUserTag) -> (SInt32 outUserInfo)")},
2079 {"WESetUserInfo", (PyCFunction
)wasteObj_WESetUserInfo
, 1,
2080 PyDoc_STR("(WESelector inUserTag, SInt32 inUserInfo) -> None")},
2081 {"WERemoveUserInfo", (PyCFunction
)wasteObj_WERemoveUserInfo
, 1,
2082 PyDoc_STR("(WESelector inUserTag) -> None")},
2083 {"WEInstallTabHooks", (PyCFunction
)wasteObj_WEInstallTabHooks
, 1,
2084 PyDoc_STR("() -> None")},
2085 {"WERemoveTabHooks", (PyCFunction
)wasteObj_WERemoveTabHooks
, 1,
2086 PyDoc_STR("() -> None")},
2087 {"WEIsTabHooks", (PyCFunction
)wasteObj_WEIsTabHooks
, 1,
2088 PyDoc_STR("() -> (Boolean _rv)")},
2089 {"WEGetTabSize", (PyCFunction
)wasteObj_WEGetTabSize
, 1,
2090 PyDoc_STR("() -> (SInt16 _rv)")},
2091 {"WESetTabSize", (PyCFunction
)wasteObj_WESetTabSize
, 1,
2092 PyDoc_STR("(SInt16 tabWidth) -> None")},
2096 PyMethodChain wasteObj_chain
= { wasteObj_methods
, NULL
};
2098 static PyObject
*wasteObj_getattr(wasteObject
*self
, char *name
)
2100 return Py_FindMethodInChain(&wasteObj_chain
, (PyObject
*)self
, name
);
2103 #define wasteObj_setattr NULL
2105 #define wasteObj_compare NULL
2107 #define wasteObj_repr NULL
2109 #define wasteObj_hash NULL
2111 PyTypeObject waste_Type
= {
2112 PyObject_HEAD_INIT(NULL
)
2114 "waste.waste", /*tp_name*/
2115 sizeof(wasteObject
), /*tp_basicsize*/
2118 (destructor
) wasteObj_dealloc
, /*tp_dealloc*/
2120 (getattrfunc
) wasteObj_getattr
, /*tp_getattr*/
2121 (setattrfunc
) wasteObj_setattr
, /*tp_setattr*/
2122 (cmpfunc
) wasteObj_compare
, /*tp_compare*/
2123 (reprfunc
) wasteObj_repr
, /*tp_repr*/
2124 (PyNumberMethods
*)0, /* tp_as_number */
2125 (PySequenceMethods
*)0, /* tp_as_sequence */
2126 (PyMappingMethods
*)0, /* tp_as_mapping */
2127 (hashfunc
) wasteObj_hash
, /*tp_hash*/
2130 /* --------------------- End object type waste ---------------------- */
2133 static PyObject
*waste_WENew(PyObject
*_self
, PyObject
*_args
)
2135 PyObject
*_res
= NULL
;
2137 LongRect inDestRect
;
2138 LongRect inViewRect
;
2139 OptionBits inOptions
;
2141 if (!PyArg_ParseTuple(_args
, "O&O&l",
2142 LongRect_Convert
, &inDestRect
,
2143 LongRect_Convert
, &inViewRect
,
2146 _err
= WENew(&inDestRect
,
2150 if (_err
!= noErr
) return PyMac_Error(_err
);
2151 _res
= Py_BuildValue("O&",
2152 wasteObj_New
, outWE
);
2156 static PyObject
*waste_WEUpdateStyleScrap(PyObject
*_self
, PyObject
*_args
)
2158 PyObject
*_res
= NULL
;
2160 StScrpHandle ioStyles
;
2161 WEFontTableHandle inFontTable
;
2162 if (!PyArg_ParseTuple(_args
, "O&O&",
2163 ResObj_Convert
, &ioStyles
,
2164 ResObj_Convert
, &inFontTable
))
2166 _err
= WEUpdateStyleScrap(ioStyles
,
2168 if (_err
!= noErr
) return PyMac_Error(_err
);
2174 static PyObject
*waste_WEInstallTSMHandlers(PyObject
*_self
, PyObject
*_args
)
2176 PyObject
*_res
= NULL
;
2178 if (!PyArg_ParseTuple(_args
, ""))
2180 _err
= WEInstallTSMHandlers();
2181 if (_err
!= noErr
) return PyMac_Error(_err
);
2187 static PyObject
*waste_WERemoveTSMHandlers(PyObject
*_self
, PyObject
*_args
)
2189 PyObject
*_res
= NULL
;
2191 if (!PyArg_ParseTuple(_args
, ""))
2193 _err
= WERemoveTSMHandlers();
2194 if (_err
!= noErr
) return PyMac_Error(_err
);
2200 static PyObject
*waste_WEHandleTSMEvent(PyObject
*_self
, PyObject
*_args
)
2202 PyObject
*_res
= NULL
;
2204 AppleEvent inAppleEvent
;
2206 if (!PyArg_ParseTuple(_args
, "O&",
2207 AEDesc_Convert
, &inAppleEvent
))
2209 _err
= WEHandleTSMEvent(&inAppleEvent
,
2211 if (_err
!= noErr
) return PyMac_Error(_err
);
2212 _res
= Py_BuildValue("O&",
2213 AEDesc_New
, &ioReply
);
2217 static PyObject
*waste_WELongPointToPoint(PyObject
*_self
, PyObject
*_args
)
2219 PyObject
*_res
= NULL
;
2222 if (!PyArg_ParseTuple(_args
, "O&",
2223 LongPt_Convert
, &inLongPoint
))
2225 WELongPointToPoint(&inLongPoint
,
2227 _res
= Py_BuildValue("O&",
2228 PyMac_BuildPoint
, outPoint
);
2232 static PyObject
*waste_WEPointToLongPoint(PyObject
*_self
, PyObject
*_args
)
2234 PyObject
*_res
= NULL
;
2236 LongPt outLongPoint
;
2237 if (!PyArg_ParseTuple(_args
, "O&",
2238 PyMac_GetPoint
, &inPoint
))
2240 WEPointToLongPoint(inPoint
,
2242 _res
= Py_BuildValue("O&",
2243 LongPt_New
, &outLongPoint
);
2247 static PyObject
*waste_WESetLongRect(PyObject
*_self
, PyObject
*_args
)
2249 PyObject
*_res
= NULL
;
2250 LongRect outLongRect
;
2255 if (!PyArg_ParseTuple(_args
, "llll",
2261 WESetLongRect(&outLongRect
,
2266 _res
= Py_BuildValue("O&",
2267 LongRect_New
, &outLongRect
);
2271 static PyObject
*waste_WELongRectToRect(PyObject
*_self
, PyObject
*_args
)
2273 PyObject
*_res
= NULL
;
2274 LongRect inLongRect
;
2276 if (!PyArg_ParseTuple(_args
, "O&",
2277 LongRect_Convert
, &inLongRect
))
2279 WELongRectToRect(&inLongRect
,
2281 _res
= Py_BuildValue("O&",
2282 PyMac_BuildRect
, &outRect
);
2286 static PyObject
*waste_WERectToLongRect(PyObject
*_self
, PyObject
*_args
)
2288 PyObject
*_res
= NULL
;
2290 LongRect outLongRect
;
2291 if (!PyArg_ParseTuple(_args
, "O&",
2292 PyMac_GetRect
, &inRect
))
2294 WERectToLongRect(&inRect
,
2296 _res
= Py_BuildValue("O&",
2297 LongRect_New
, &outLongRect
);
2301 static PyObject
*waste_WEOffsetLongRect(PyObject
*_self
, PyObject
*_args
)
2303 PyObject
*_res
= NULL
;
2304 LongRect ioLongRect
;
2305 SInt32 inHorizontalOffset
;
2306 SInt32 inVerticalOffset
;
2307 if (!PyArg_ParseTuple(_args
, "ll",
2308 &inHorizontalOffset
,
2311 WEOffsetLongRect(&ioLongRect
,
2314 _res
= Py_BuildValue("O&",
2315 LongRect_New
, &ioLongRect
);
2319 static PyObject
*waste_WELongPointInLongRect(PyObject
*_self
, PyObject
*_args
)
2321 PyObject
*_res
= NULL
;
2324 LongRect inLongRect
;
2325 if (!PyArg_ParseTuple(_args
, "O&O&",
2326 LongPt_Convert
, &inLongPoint
,
2327 LongRect_Convert
, &inLongRect
))
2329 _rv
= WELongPointInLongRect(&inLongPoint
,
2331 _res
= Py_BuildValue("b",
2336 static PyObject
*waste_STDObjectHandlers(PyObject
*_self
, PyObject
*_args
)
2338 PyObject
*_res
= NULL
;
2341 // install the sample object handlers for pictures and sounds
2342 #define kTypePicture 'PICT'
2343 #define kTypeSound 'snd '
2345 if ( !PyArg_ParseTuple(_args
, "") ) return NULL
;
2347 if ((err
= WEInstallObjectHandler(kTypePicture
, weNewHandler
,
2348 (UniversalProcPtr
) NewWENewObjectProc(HandleNewPicture
), NULL
)) != noErr
)
2351 if ((err
= WEInstallObjectHandler(kTypePicture
, weDisposeHandler
,
2352 (UniversalProcPtr
) NewWEDisposeObjectProc(HandleDisposePicture
), NULL
)) != noErr
)
2355 if ((err
= WEInstallObjectHandler(kTypePicture
, weDrawHandler
,
2356 (UniversalProcPtr
) NewWEDrawObjectProc(HandleDrawPicture
), NULL
)) != noErr
)
2359 if ((err
= WEInstallObjectHandler(kTypeSound
, weNewHandler
,
2360 (UniversalProcPtr
) NewWENewObjectProc(HandleNewSound
), NULL
)) != noErr
)
2363 if ((err
= WEInstallObjectHandler(kTypeSound
, weDrawHandler
,
2364 (UniversalProcPtr
) NewWEDrawObjectProc(HandleDrawSound
), NULL
)) != noErr
)
2367 if ((err
= WEInstallObjectHandler(kTypeSound
, weClickHandler
,
2368 (UniversalProcPtr
) NewWEClickObjectProc(HandleClickSound
), NULL
)) != noErr
)
2374 return PyMac_Error(err
);
2378 static PyObject
*waste_WEInstallObjectHandler(PyObject
*_self
, PyObject
*_args
)
2380 PyObject
*_res
= NULL
;
2383 FlavorType objectType
;
2384 WESelector selector
;
2385 PyObject
*py_handler
;
2386 UniversalProcPtr handler
;
2387 WEReference we
= NULL
;
2391 if ( !PyArg_ParseTuple(_args
, "O&O&O|O&",
2392 PyMac_GetOSType
, &objectType
,
2393 PyMac_GetOSType
, &selector
,
2395 WEOObj_Convert
, &we
) ) return NULL
;
2397 if ( selector
== weNewHandler
) handler
= (UniversalProcPtr
)upp_new_handler
;
2398 else if ( selector
== weDisposeHandler
) handler
= (UniversalProcPtr
)upp_dispose_handler
;
2399 else if ( selector
== weDrawHandler
) handler
= (UniversalProcPtr
)upp_draw_handler
;
2400 else if ( selector
== weClickHandler
) handler
= (UniversalProcPtr
)upp_click_handler
;
2401 else return PyMac_Error(weUndefinedSelectorErr
);
2403 if ((key
= Py_BuildValue("O&O&",
2404 PyMac_BuildOSType
, objectType
,
2405 PyMac_BuildOSType
, selector
)) == NULL
)
2408 PyDict_SetItem(callbackdict
, key
, py_handler
);
2410 err
= WEInstallObjectHandler(objectType
, selector
, handler
, we
);
2411 if ( err
) return PyMac_Error(err
);
2417 static PyMethodDef waste_methods
[] = {
2418 {"WENew", (PyCFunction
)waste_WENew
, 1,
2419 PyDoc_STR("(LongRect inDestRect, LongRect inViewRect, OptionBits inOptions) -> (WEReference outWE)")},
2420 {"WEUpdateStyleScrap", (PyCFunction
)waste_WEUpdateStyleScrap
, 1,
2421 PyDoc_STR("(StScrpHandle ioStyles, WEFontTableHandle inFontTable) -> None")},
2422 {"WEInstallTSMHandlers", (PyCFunction
)waste_WEInstallTSMHandlers
, 1,
2423 PyDoc_STR("() -> None")},
2424 {"WERemoveTSMHandlers", (PyCFunction
)waste_WERemoveTSMHandlers
, 1,
2425 PyDoc_STR("() -> None")},
2426 {"WEHandleTSMEvent", (PyCFunction
)waste_WEHandleTSMEvent
, 1,
2427 PyDoc_STR("(AppleEvent inAppleEvent) -> (AppleEvent ioReply)")},
2428 {"WELongPointToPoint", (PyCFunction
)waste_WELongPointToPoint
, 1,
2429 PyDoc_STR("(LongPt inLongPoint) -> (Point outPoint)")},
2430 {"WEPointToLongPoint", (PyCFunction
)waste_WEPointToLongPoint
, 1,
2431 PyDoc_STR("(Point inPoint) -> (LongPt outLongPoint)")},
2432 {"WESetLongRect", (PyCFunction
)waste_WESetLongRect
, 1,
2433 PyDoc_STR("(SInt32 inLeft, SInt32 inTop, SInt32 inRight, SInt32 inBottom) -> (LongRect outLongRect)")},
2434 {"WELongRectToRect", (PyCFunction
)waste_WELongRectToRect
, 1,
2435 PyDoc_STR("(LongRect inLongRect) -> (Rect outRect)")},
2436 {"WERectToLongRect", (PyCFunction
)waste_WERectToLongRect
, 1,
2437 PyDoc_STR("(Rect inRect) -> (LongRect outLongRect)")},
2438 {"WEOffsetLongRect", (PyCFunction
)waste_WEOffsetLongRect
, 1,
2439 PyDoc_STR("(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> (LongRect ioLongRect)")},
2440 {"WELongPointInLongRect", (PyCFunction
)waste_WELongPointInLongRect
, 1,
2441 PyDoc_STR("(LongPt inLongPoint, LongRect inLongRect) -> (Boolean _rv)")},
2442 {"STDObjectHandlers", (PyCFunction
)waste_STDObjectHandlers
, 1,
2444 {"WEInstallObjectHandler", (PyCFunction
)waste_WEInstallObjectHandler
, 1,
2451 /* Return the object corresponding to the window, or NULL */
2454 ExistingwasteObj_New(w
)
2457 PyObject
*it
= NULL
;
2462 WEGetInfo(weRefCon
, (void *)&it
, w
);
2463 if (it
== NULL
|| ((wasteObject
*)it
)->ob_itself
!= w
)
2470 void initwaste(void)
2478 m
= Py_InitModule("waste", waste_methods
);
2479 d
= PyModule_GetDict(m
);
2480 waste_Error
= PyMac_GetOSErrException();
2481 if (waste_Error
== NULL
||
2482 PyDict_SetItemString(d
, "Error", waste_Error
) != 0)
2484 WEO_Type
.ob_type
= &PyType_Type
;
2485 Py_INCREF(&WEO_Type
);
2486 if (PyDict_SetItemString(d
, "WEOType", (PyObject
*)&WEO_Type
) != 0)
2487 Py_FatalError("can't initialize WEOType");
2488 waste_Type
.ob_type
= &PyType_Type
;
2489 Py_INCREF(&waste_Type
);
2490 if (PyDict_SetItemString(d
, "wasteType", (PyObject
*)&waste_Type
) != 0)
2491 Py_FatalError("can't initialize wasteType");
2493 callbackdict
= PyDict_New();
2494 if (callbackdict
== NULL
|| PyDict_SetItemString(d
, "callbacks", callbackdict
) != 0)
2496 upp_new_handler
= NewWENewObjectProc(my_new_handler
);
2497 upp_dispose_handler
= NewWEDisposeObjectProc(my_dispose_handler
);
2498 upp_draw_handler
= NewWEDrawObjectProc(my_draw_handler
);
2499 upp_click_handler
= NewWEClickObjectProc(my_click_handler
);
2504 /* ======================== End module waste ======================== */