2 /* ========================== Module waste ========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
46 #include <WEObjectHandlers.h>
48 /* Exported by Qdmodule.c: */
49 extern PyObject
*QdRGB_New(RGBColor
*);
50 extern int QdRGB_Convert(PyObject
*, RGBColor
*);
52 /* Forward declaration */
53 staticforward PyObject
*WEOObj_New(WEObjectReference
);
54 staticforward PyObject
*ExistingwasteObj_New(WEReference
);
57 ** Parse/generate TextStyle records
60 PyObject
*TextStyle_New(itself
)
64 return Py_BuildValue("lllO&", (long)itself
->tsFont
, (long)itself
->tsFace
, (long)itself
->tsSize
, QdRGB_New
,
69 TextStyle_Convert(v
, p_itself
)
71 TextStylePtr p_itself
;
73 long font
, face
, size
;
75 if( !PyArg_ParseTuple(v
, "lllO&", &font
, &face
, &size
, QdRGB_Convert
, &p_itself
->tsColor
) )
77 p_itself
->tsFont
= (short)font
;
78 p_itself
->tsFace
= (Style
)face
;
79 p_itself
->tsSize
= (short)size
;
84 ** Parse/generate RunInfo records
87 PyObject
*RunInfo_New(itself
)
91 return Py_BuildValue("llhhO&O&", itself
->runStart
, itself
->runEnd
, itself
->runHeight
,
92 itself
->runAscent
, TextStyle_New
, &itself
->runStyle
, WEOObj_New
, itself
->runObject
);
95 /* Conversion of long points and rects */
97 LongRect_Convert(PyObject
*v
, LongRect
*r
)
99 return PyArg_Parse(v
, "(llll)", &r
->left
, &r
->top
, &r
->right
, &r
->bottom
);
103 LongRect_New(LongRect
*r
)
105 return Py_BuildValue("(llll)", r
->left
, r
->top
, r
->right
, r
->bottom
);
109 LongPt_Convert(PyObject
*v
, LongPt
*p
)
111 return PyArg_Parse(v
, "(ll)", &p
->h
, &p
->v
);
115 LongPt_New(LongPt
*p
)
117 return Py_BuildValue("(ll)", p
->h
, p
->v
);
120 /* Stuff for the callbacks: */
121 static PyObject
*callbackdict
;
122 WENewObjectUPP upp_new_handler
;
123 WEDisposeObjectUPP upp_dispose_handler
;
124 WEDrawObjectUPP upp_draw_handler
;
125 WEClickObjectUPP upp_click_handler
;
128 any_handler(WESelector what
, WEObjectReference who
, PyObject
*args
, PyObject
**rv
)
131 PyObject
*key
, *func
;
133 if ( args
== NULL
) return errAECorruptData
;
135 tp
= WEGetObjectType(who
);
137 if( (key
=Py_BuildValue("O&O&", PyMac_BuildOSType
, tp
, PyMac_BuildOSType
, what
)) == NULL
)
138 return errAECorruptData
;
139 if( (func
= PyDict_GetItem(callbackdict
, key
)) == NULL
) {
141 return errAEHandlerNotFound
;
144 *rv
= PyEval_CallObject(func
, args
);
148 fprintf(stderr
, "--Exception in callback: ");
150 return errAEReplyNotArrived
;
156 my_new_handler(Point
*objectSize
, WEObjectReference objref
)
158 PyObject
*args
=NULL
, *rv
=NULL
;
161 args
=Py_BuildValue("(O&)", WEOObj_New
, objref
);
162 err
= any_handler(weNewHandler
, objref
, args
, &rv
);
164 if (!PyMac_GetPoint(rv
, objectSize
) )
165 err
= errAECoercionFail
;
167 if ( args
) Py_DECREF(args
);
168 if ( rv
) Py_DECREF(rv
);
173 my_dispose_handler(WEObjectReference objref
)
175 PyObject
*args
=NULL
, *rv
=NULL
;
178 args
=Py_BuildValue("(O&)", WEOObj_New
, objref
);
179 err
= any_handler(weDisposeHandler
, objref
, args
, &rv
);
180 if ( args
) Py_DECREF(args
);
181 if ( rv
) Py_DECREF(rv
);
186 my_draw_handler(Rect
*destRect
, WEObjectReference objref
)
188 PyObject
*args
=NULL
, *rv
=NULL
;
191 args
=Py_BuildValue("O&O&", PyMac_BuildRect
, destRect
, WEOObj_New
, objref
);
192 err
= any_handler(weDrawHandler
, objref
, args
, &rv
);
193 if ( args
) Py_DECREF(args
);
194 if ( rv
) Py_DECREF(rv
);
198 static pascal Boolean
199 my_click_handler(Point hitPt
, EventModifiers modifiers
,
200 unsigned long clickTime
, WEObjectReference objref
)
202 PyObject
*args
=NULL
, *rv
=NULL
;
206 args
=Py_BuildValue("O&llO&", PyMac_BuildPoint
, hitPt
,
207 (long)modifiers
, (long)clickTime
, WEOObj_New
, objref
);
208 err
= any_handler(weClickHandler
, objref
, args
, &rv
);
210 retvalue
= PyInt_AsLong(rv
);
213 if ( args
) Py_DECREF(args
);
214 if ( rv
) Py_DECREF(rv
);
220 static PyObject
*waste_Error
;
222 /* ------------------------ Object type WEO ------------------------- */
224 PyTypeObject WEO_Type
;
226 #define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
228 typedef struct WEOObject
{
230 WEObjectReference ob_itself
;
233 PyObject
*WEOObj_New(itself
)
234 WEObjectReference itself
;
237 if (itself
== NULL
) {
241 it
= PyObject_NEW(WEOObject
, &WEO_Type
);
242 if (it
== NULL
) return NULL
;
243 it
->ob_itself
= itself
;
244 return (PyObject
*)it
;
246 WEOObj_Convert(v
, p_itself
)
248 WEObjectReference
*p_itself
;
250 if (!WEOObj_Check(v
))
252 PyErr_SetString(PyExc_TypeError
, "WEO required");
255 *p_itself
= ((WEOObject
*)v
)->ob_itself
;
259 static void WEOObj_dealloc(self
)
262 /* Cleanup of self->ob_itself goes here */
266 static PyObject
*WEOObj_WEGetObjectType(_self
, _args
)
270 PyObject
*_res
= NULL
;
272 if (!PyArg_ParseTuple(_args
, ""))
274 _rv
= WEGetObjectType(_self
->ob_itself
);
275 _res
= Py_BuildValue("O&",
276 PyMac_BuildOSType
, _rv
);
280 static PyObject
*WEOObj_WEGetObjectDataHandle(_self
, _args
)
284 PyObject
*_res
= NULL
;
286 if (!PyArg_ParseTuple(_args
, ""))
288 _rv
= WEGetObjectDataHandle(_self
->ob_itself
);
289 _res
= Py_BuildValue("O&",
294 static PyObject
*WEOObj_WEGetObjectSize(_self
, _args
)
298 PyObject
*_res
= NULL
;
300 if (!PyArg_ParseTuple(_args
, ""))
302 _rv
= WEGetObjectSize(_self
->ob_itself
);
303 _res
= Py_BuildValue("O&",
304 PyMac_BuildPoint
, _rv
);
308 static PyObject
*WEOObj_WEGetObjectOwner(_self
, _args
)
312 PyObject
*_res
= NULL
;
314 if (!PyArg_ParseTuple(_args
, ""))
316 _rv
= WEGetObjectOwner(_self
->ob_itself
);
317 _res
= Py_BuildValue("O&",
318 ExistingwasteObj_New
, _rv
);
322 static PyObject
*WEOObj_WEGetObjectRefCon(_self
, _args
)
326 PyObject
*_res
= NULL
;
328 if (!PyArg_ParseTuple(_args
, ""))
330 _rv
= WEGetObjectRefCon(_self
->ob_itself
);
331 _res
= Py_BuildValue("l",
336 static PyObject
*WEOObj_WESetObjectRefCon(_self
, _args
)
340 PyObject
*_res
= NULL
;
342 if (!PyArg_ParseTuple(_args
, "l",
345 WESetObjectRefCon(_self
->ob_itself
,
352 static PyMethodDef WEOObj_methods
[] = {
353 {"WEGetObjectType", (PyCFunction
)WEOObj_WEGetObjectType
, 1,
354 "() -> (FlavorType _rv)"},
355 {"WEGetObjectDataHandle", (PyCFunction
)WEOObj_WEGetObjectDataHandle
, 1,
356 "() -> (Handle _rv)"},
357 {"WEGetObjectSize", (PyCFunction
)WEOObj_WEGetObjectSize
, 1,
358 "() -> (Point _rv)"},
359 {"WEGetObjectOwner", (PyCFunction
)WEOObj_WEGetObjectOwner
, 1,
360 "() -> (WEReference _rv)"},
361 {"WEGetObjectRefCon", (PyCFunction
)WEOObj_WEGetObjectRefCon
, 1,
362 "() -> (SInt32 _rv)"},
363 {"WESetObjectRefCon", (PyCFunction
)WEOObj_WESetObjectRefCon
, 1,
364 "(SInt32 refCon) -> None"},
368 PyMethodChain WEOObj_chain
= { WEOObj_methods
, NULL
};
370 static PyObject
*WEOObj_getattr(self
, name
)
374 return Py_FindMethodInChain(&WEOObj_chain
, (PyObject
*)self
, name
);
377 #define WEOObj_setattr NULL
379 PyTypeObject WEO_Type
= {
380 PyObject_HEAD_INIT(&PyType_Type
)
383 sizeof(WEOObject
), /*tp_basicsize*/
386 (destructor
) WEOObj_dealloc
, /*tp_dealloc*/
388 (getattrfunc
) WEOObj_getattr
, /*tp_getattr*/
389 (setattrfunc
) WEOObj_setattr
, /*tp_setattr*/
392 /* ---------------------- End object type WEO ----------------------- */
395 /* ----------------------- Object type waste ------------------------ */
397 PyTypeObject waste_Type
;
399 #define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
401 typedef struct wasteObject
{
403 WEReference ob_itself
;
406 PyObject
*wasteObj_New(itself
)
410 if (itself
== NULL
) {
411 PyErr_SetString(waste_Error
,"Cannot create null WE");
414 it
= PyObject_NEW(wasteObject
, &waste_Type
);
415 if (it
== NULL
) return NULL
;
416 it
->ob_itself
= itself
;
417 WESetInfo(weRefCon
, (void *)&it
, itself
);
418 return (PyObject
*)it
;
420 wasteObj_Convert(v
, p_itself
)
422 WEReference
*p_itself
;
424 if (!wasteObj_Check(v
))
426 PyErr_SetString(PyExc_TypeError
, "waste required");
429 *p_itself
= ((wasteObject
*)v
)->ob_itself
;
433 static void wasteObj_dealloc(self
)
436 WEDispose(self
->ob_itself
);
440 static PyObject
*wasteObj_WEGetText(_self
, _args
)
444 PyObject
*_res
= NULL
;
446 if (!PyArg_ParseTuple(_args
, ""))
448 _rv
= WEGetText(_self
->ob_itself
);
449 _res
= Py_BuildValue("O&",
454 static PyObject
*wasteObj_WEGetChar(_self
, _args
)
458 PyObject
*_res
= NULL
;
461 if (!PyArg_ParseTuple(_args
, "l",
464 _rv
= WEGetChar(offset
,
466 _res
= Py_BuildValue("h",
471 static PyObject
*wasteObj_WEGetTextLength(_self
, _args
)
475 PyObject
*_res
= NULL
;
477 if (!PyArg_ParseTuple(_args
, ""))
479 _rv
= WEGetTextLength(_self
->ob_itself
);
480 _res
= Py_BuildValue("l",
485 static PyObject
*wasteObj_WECountLines(_self
, _args
)
489 PyObject
*_res
= NULL
;
491 if (!PyArg_ParseTuple(_args
, ""))
493 _rv
= WECountLines(_self
->ob_itself
);
494 _res
= Py_BuildValue("l",
499 static PyObject
*wasteObj_WEGetHeight(_self
, _args
)
503 PyObject
*_res
= NULL
;
507 if (!PyArg_ParseTuple(_args
, "ll",
511 _rv
= WEGetHeight(startLine
,
514 _res
= Py_BuildValue("l",
519 static PyObject
*wasteObj_WEGetSelection(_self
, _args
)
523 PyObject
*_res
= NULL
;
526 if (!PyArg_ParseTuple(_args
, ""))
528 WEGetSelection(&selStart
,
531 _res
= Py_BuildValue("ll",
537 static PyObject
*wasteObj_WEGetDestRect(_self
, _args
)
541 PyObject
*_res
= NULL
;
543 if (!PyArg_ParseTuple(_args
, ""))
545 WEGetDestRect(&destRect
,
547 _res
= Py_BuildValue("O&",
548 LongRect_New
, &destRect
);
552 static PyObject
*wasteObj_WEGetViewRect(_self
, _args
)
556 PyObject
*_res
= NULL
;
558 if (!PyArg_ParseTuple(_args
, ""))
560 WEGetViewRect(&viewRect
,
562 _res
= Py_BuildValue("O&",
563 LongRect_New
, &viewRect
);
567 static PyObject
*wasteObj_WEIsActive(_self
, _args
)
571 PyObject
*_res
= NULL
;
573 if (!PyArg_ParseTuple(_args
, ""))
575 _rv
= WEIsActive(_self
->ob_itself
);
576 _res
= Py_BuildValue("b",
581 static PyObject
*wasteObj_WEOffsetToLine(_self
, _args
)
585 PyObject
*_res
= NULL
;
588 if (!PyArg_ParseTuple(_args
, "l",
591 _rv
= WEOffsetToLine(offset
,
593 _res
= Py_BuildValue("l",
598 static PyObject
*wasteObj_WEGetLineRange(_self
, _args
)
602 PyObject
*_res
= NULL
;
606 if (!PyArg_ParseTuple(_args
, "l",
609 WEGetLineRange(lineNo
,
613 _res
= Py_BuildValue("ll",
619 static PyObject
*wasteObj_WEGetClickCount(_self
, _args
)
623 PyObject
*_res
= NULL
;
625 if (!PyArg_ParseTuple(_args
, ""))
627 _rv
= WEGetClickCount(_self
->ob_itself
);
628 _res
= Py_BuildValue("h",
633 static PyObject
*wasteObj_WESetSelection(_self
, _args
)
637 PyObject
*_res
= NULL
;
640 if (!PyArg_ParseTuple(_args
, "ll",
644 WESetSelection(selStart
,
652 static PyObject
*wasteObj_WESetDestRect(_self
, _args
)
656 PyObject
*_res
= NULL
;
658 if (!PyArg_ParseTuple(_args
, "O&",
659 LongRect_Convert
, &destRect
))
661 WESetDestRect(&destRect
,
668 static PyObject
*wasteObj_WESetViewRect(_self
, _args
)
672 PyObject
*_res
= NULL
;
674 if (!PyArg_ParseTuple(_args
, "O&",
675 LongRect_Convert
, &viewRect
))
677 WESetViewRect(&viewRect
,
684 static PyObject
*wasteObj_WEContinuousStyle(_self
, _args
)
688 PyObject
*_res
= NULL
;
692 if (!PyArg_ParseTuple(_args
, "h",
695 _rv
= WEContinuousStyle(&mode
,
698 _res
= Py_BuildValue("bhO&",
705 static PyObject
*wasteObj_WEGetRunInfo(_self
, _args
)
709 PyObject
*_res
= NULL
;
712 if (!PyArg_ParseTuple(_args
, "l",
718 _res
= Py_BuildValue("O&",
719 RunInfo_New
, &runInfo
);
723 static PyObject
*wasteObj_WEGetOffset(_self
, _args
)
727 PyObject
*_res
= NULL
;
731 if (!PyArg_ParseTuple(_args
, "O&",
732 LongPt_Convert
, &thePoint
))
734 _rv
= WEGetOffset(&thePoint
,
737 _res
= Py_BuildValue("lb",
743 static PyObject
*wasteObj_WEGetPoint(_self
, _args
)
747 PyObject
*_res
= NULL
;
752 if (!PyArg_ParseTuple(_args
, "lh",
761 _res
= Py_BuildValue("O&h",
762 LongPt_New
, &thePoint
,
767 static PyObject
*wasteObj_WEFindWord(_self
, _args
)
771 PyObject
*_res
= NULL
;
776 if (!PyArg_ParseTuple(_args
, "lb",
785 _res
= Py_BuildValue("ll",
791 static PyObject
*wasteObj_WEFindLine(_self
, _args
)
795 PyObject
*_res
= NULL
;
800 if (!PyArg_ParseTuple(_args
, "lb",
809 _res
= Py_BuildValue("ll",
815 static PyObject
*wasteObj_WECopyRange(_self
, _args
)
819 PyObject
*_res
= NULL
;
824 StScrpHandle hStyles
;
826 if (!PyArg_ParseTuple(_args
, "llO&O&O&",
829 OptResObj_Convert
, &hText
,
830 OptResObj_Convert
, &hStyles
,
831 OptResObj_Convert
, &hSoup
))
833 _err
= WECopyRange(rangeStart
,
839 if (_err
!= noErr
) return PyMac_Error(_err
);
845 static PyObject
*wasteObj_WEGetAlignment(_self
, _args
)
849 PyObject
*_res
= NULL
;
851 if (!PyArg_ParseTuple(_args
, ""))
853 _rv
= WEGetAlignment(_self
->ob_itself
);
854 _res
= Py_BuildValue("b",
859 static PyObject
*wasteObj_WESetAlignment(_self
, _args
)
863 PyObject
*_res
= NULL
;
864 WEAlignment alignment
;
865 if (!PyArg_ParseTuple(_args
, "b",
868 WESetAlignment(alignment
,
875 static PyObject
*wasteObj_WECalText(_self
, _args
)
879 PyObject
*_res
= NULL
;
881 if (!PyArg_ParseTuple(_args
, ""))
883 _err
= WECalText(_self
->ob_itself
);
884 if (_err
!= noErr
) return PyMac_Error(_err
);
890 static PyObject
*wasteObj_WEUpdate(_self
, _args
)
894 PyObject
*_res
= NULL
;
896 if (!PyArg_ParseTuple(_args
, "O&",
897 ResObj_Convert
, &updateRgn
))
906 static PyObject
*wasteObj_WEScroll(_self
, _args
)
910 PyObject
*_res
= NULL
;
913 if (!PyArg_ParseTuple(_args
, "ll",
925 static PyObject
*wasteObj_WESelView(_self
, _args
)
929 PyObject
*_res
= NULL
;
930 if (!PyArg_ParseTuple(_args
, ""))
932 WESelView(_self
->ob_itself
);
938 static PyObject
*wasteObj_WEActivate(_self
, _args
)
942 PyObject
*_res
= NULL
;
943 if (!PyArg_ParseTuple(_args
, ""))
945 WEActivate(_self
->ob_itself
);
951 static PyObject
*wasteObj_WEDeactivate(_self
, _args
)
955 PyObject
*_res
= NULL
;
956 if (!PyArg_ParseTuple(_args
, ""))
958 WEDeactivate(_self
->ob_itself
);
964 static PyObject
*wasteObj_WEKey(_self
, _args
)
968 PyObject
*_res
= NULL
;
970 EventModifiers modifiers
;
971 if (!PyArg_ParseTuple(_args
, "hh",
983 static PyObject
*wasteObj_WEClick(_self
, _args
)
987 PyObject
*_res
= NULL
;
989 EventModifiers modifiers
;
991 if (!PyArg_ParseTuple(_args
, "O&hl",
992 PyMac_GetPoint
, &hitPt
,
1005 static PyObject
*wasteObj_WEAdjustCursor(_self
, _args
)
1009 PyObject
*_res
= NULL
;
1013 if (!PyArg_ParseTuple(_args
, "O&O&",
1014 PyMac_GetPoint
, &mouseLoc
,
1015 ResObj_Convert
, &mouseRgn
))
1017 _rv
= WEAdjustCursor(mouseLoc
,
1020 _res
= Py_BuildValue("b",
1025 static PyObject
*wasteObj_WEIdle(_self
, _args
)
1029 PyObject
*_res
= NULL
;
1031 if (!PyArg_ParseTuple(_args
, ""))
1035 _res
= Py_BuildValue("l",
1040 static PyObject
*wasteObj_WEInsert(_self
, _args
)
1044 PyObject
*_res
= NULL
;
1048 int pText__in_len__
;
1049 StScrpHandle hStyles
;
1051 if (!PyArg_ParseTuple(_args
, "s#O&O&",
1052 &pText__in__
, &pText__in_len__
,
1053 OptResObj_Convert
, &hStyles
,
1054 OptResObj_Convert
, &hSoup
))
1056 pText__len__
= pText__in_len__
;
1057 _err
= WEInsert(pText__in__
, pText__len__
,
1061 if (_err
!= noErr
) return PyMac_Error(_err
);
1068 static PyObject
*wasteObj_WEDelete(_self
, _args
)
1072 PyObject
*_res
= NULL
;
1074 if (!PyArg_ParseTuple(_args
, ""))
1076 _err
= WEDelete(_self
->ob_itself
);
1077 if (_err
!= noErr
) return PyMac_Error(_err
);
1083 static PyObject
*wasteObj_WESetStyle(_self
, _args
)
1087 PyObject
*_res
= NULL
;
1091 if (!PyArg_ParseTuple(_args
, "hO&",
1093 TextStyle_Convert
, &ts
))
1095 _err
= WESetStyle(mode
,
1098 if (_err
!= noErr
) return PyMac_Error(_err
);
1104 static PyObject
*wasteObj_WEUseStyleScrap(_self
, _args
)
1108 PyObject
*_res
= NULL
;
1110 StScrpHandle hStyles
;
1111 if (!PyArg_ParseTuple(_args
, "O&",
1112 ResObj_Convert
, &hStyles
))
1114 _err
= WEUseStyleScrap(hStyles
,
1116 if (_err
!= noErr
) return PyMac_Error(_err
);
1122 static PyObject
*wasteObj_WEUseText(_self
, _args
)
1126 PyObject
*_res
= NULL
;
1129 if (!PyArg_ParseTuple(_args
, "O&",
1130 ResObj_Convert
, &hText
))
1132 _err
= WEUseText(hText
,
1134 if (_err
!= noErr
) return PyMac_Error(_err
);
1140 static PyObject
*wasteObj_WEUndo(_self
, _args
)
1144 PyObject
*_res
= NULL
;
1146 if (!PyArg_ParseTuple(_args
, ""))
1148 _err
= WEUndo(_self
->ob_itself
);
1149 if (_err
!= noErr
) return PyMac_Error(_err
);
1155 static PyObject
*wasteObj_WEClearUndo(_self
, _args
)
1159 PyObject
*_res
= NULL
;
1160 if (!PyArg_ParseTuple(_args
, ""))
1162 WEClearUndo(_self
->ob_itself
);
1168 static PyObject
*wasteObj_WEGetUndoInfo(_self
, _args
)
1172 PyObject
*_res
= NULL
;
1175 if (!PyArg_ParseTuple(_args
, ""))
1177 _rv
= WEGetUndoInfo(&redoFlag
,
1179 _res
= Py_BuildValue("hb",
1185 static PyObject
*wasteObj_WEIsTyping(_self
, _args
)
1189 PyObject
*_res
= NULL
;
1191 if (!PyArg_ParseTuple(_args
, ""))
1193 _rv
= WEIsTyping(_self
->ob_itself
);
1194 _res
= Py_BuildValue("b",
1199 static PyObject
*wasteObj_WEGetModCount(_self
, _args
)
1203 PyObject
*_res
= NULL
;
1205 if (!PyArg_ParseTuple(_args
, ""))
1207 _rv
= WEGetModCount(_self
->ob_itself
);
1208 _res
= Py_BuildValue("l",
1213 static PyObject
*wasteObj_WEResetModCount(_self
, _args
)
1217 PyObject
*_res
= NULL
;
1218 if (!PyArg_ParseTuple(_args
, ""))
1220 WEResetModCount(_self
->ob_itself
);
1226 static PyObject
*wasteObj_WEInsertObject(_self
, _args
)
1230 PyObject
*_res
= NULL
;
1232 FlavorType objectType
;
1233 Handle objectDataHandle
;
1235 if (!PyArg_ParseTuple(_args
, "O&O&O&",
1236 PyMac_GetOSType
, &objectType
,
1237 ResObj_Convert
, &objectDataHandle
,
1238 PyMac_GetPoint
, &objectSize
))
1240 _err
= WEInsertObject(objectType
,
1244 if (_err
!= noErr
) return PyMac_Error(_err
);
1250 static PyObject
*wasteObj_WEGetSelectedObject(_self
, _args
)
1254 PyObject
*_res
= NULL
;
1256 WEObjectReference obj
;
1257 if (!PyArg_ParseTuple(_args
, ""))
1259 _err
= WEGetSelectedObject(&obj
,
1261 if (_err
!= noErr
) return PyMac_Error(_err
);
1262 _res
= Py_BuildValue("O&",
1267 static PyObject
*wasteObj_WEFindNextObject(_self
, _args
)
1271 PyObject
*_res
= NULL
;
1274 WEObjectReference obj
;
1275 if (!PyArg_ParseTuple(_args
, "l",
1278 _rv
= WEFindNextObject(offset
,
1281 _res
= Py_BuildValue("lO&",
1287 static PyObject
*wasteObj_WEUseSoup(_self
, _args
)
1291 PyObject
*_res
= NULL
;
1294 if (!PyArg_ParseTuple(_args
, "O&",
1295 ResObj_Convert
, &hSoup
))
1297 _err
= WEUseSoup(hSoup
,
1299 if (_err
!= noErr
) return PyMac_Error(_err
);
1305 static PyObject
*wasteObj_WECut(_self
, _args
)
1309 PyObject
*_res
= NULL
;
1311 if (!PyArg_ParseTuple(_args
, ""))
1313 _err
= WECut(_self
->ob_itself
);
1314 if (_err
!= noErr
) return PyMac_Error(_err
);
1320 static PyObject
*wasteObj_WECopy(_self
, _args
)
1324 PyObject
*_res
= NULL
;
1326 if (!PyArg_ParseTuple(_args
, ""))
1328 _err
= WECopy(_self
->ob_itself
);
1329 if (_err
!= noErr
) return PyMac_Error(_err
);
1335 static PyObject
*wasteObj_WEPaste(_self
, _args
)
1339 PyObject
*_res
= NULL
;
1341 if (!PyArg_ParseTuple(_args
, ""))
1343 _err
= WEPaste(_self
->ob_itself
);
1344 if (_err
!= noErr
) return PyMac_Error(_err
);
1350 static PyObject
*wasteObj_WECanPaste(_self
, _args
)
1354 PyObject
*_res
= NULL
;
1356 if (!PyArg_ParseTuple(_args
, ""))
1358 _rv
= WECanPaste(_self
->ob_itself
);
1359 _res
= Py_BuildValue("b",
1364 static PyObject
*wasteObj_WEGetHiliteRgn(_self
, _args
)
1368 PyObject
*_res
= NULL
;
1372 if (!PyArg_ParseTuple(_args
, "ll",
1376 _rv
= WEGetHiliteRgn(rangeStart
,
1379 _res
= Py_BuildValue("O&",
1384 static PyObject
*wasteObj_WECharByte(_self
, _args
)
1388 PyObject
*_res
= NULL
;
1391 if (!PyArg_ParseTuple(_args
, "l",
1394 _rv
= WECharByte(offset
,
1396 _res
= Py_BuildValue("h",
1401 static PyObject
*wasteObj_WECharType(_self
, _args
)
1405 PyObject
*_res
= NULL
;
1408 if (!PyArg_ParseTuple(_args
, "l",
1411 _rv
= WECharType(offset
,
1413 _res
= Py_BuildValue("h",
1418 static PyObject
*wasteObj_WEStopInlineSession(_self
, _args
)
1422 PyObject
*_res
= NULL
;
1423 if (!PyArg_ParseTuple(_args
, ""))
1425 WEStopInlineSession(_self
->ob_itself
);
1431 static PyObject
*wasteObj_WEFeatureFlag(_self
, _args
)
1435 PyObject
*_res
= NULL
;
1439 if (!PyArg_ParseTuple(_args
, "hh",
1443 _rv
= WEFeatureFlag(feature
,
1446 _res
= Py_BuildValue("h",
1451 static PyMethodDef wasteObj_methods
[] = {
1452 {"WEGetText", (PyCFunction
)wasteObj_WEGetText
, 1,
1453 "() -> (Handle _rv)"},
1454 {"WEGetChar", (PyCFunction
)wasteObj_WEGetChar
, 1,
1455 "(SInt32 offset) -> (SInt16 _rv)"},
1456 {"WEGetTextLength", (PyCFunction
)wasteObj_WEGetTextLength
, 1,
1457 "() -> (SInt32 _rv)"},
1458 {"WECountLines", (PyCFunction
)wasteObj_WECountLines
, 1,
1459 "() -> (SInt32 _rv)"},
1460 {"WEGetHeight", (PyCFunction
)wasteObj_WEGetHeight
, 1,
1461 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
1462 {"WEGetSelection", (PyCFunction
)wasteObj_WEGetSelection
, 1,
1463 "() -> (SInt32 selStart, SInt32 selEnd)"},
1464 {"WEGetDestRect", (PyCFunction
)wasteObj_WEGetDestRect
, 1,
1465 "() -> (LongRect destRect)"},
1466 {"WEGetViewRect", (PyCFunction
)wasteObj_WEGetViewRect
, 1,
1467 "() -> (LongRect viewRect)"},
1468 {"WEIsActive", (PyCFunction
)wasteObj_WEIsActive
, 1,
1469 "() -> (Boolean _rv)"},
1470 {"WEOffsetToLine", (PyCFunction
)wasteObj_WEOffsetToLine
, 1,
1471 "(SInt32 offset) -> (SInt32 _rv)"},
1472 {"WEGetLineRange", (PyCFunction
)wasteObj_WEGetLineRange
, 1,
1473 "(SInt32 lineNo) -> (SInt32 lineStart, SInt32 lineEnd)"},
1474 {"WEGetClickCount", (PyCFunction
)wasteObj_WEGetClickCount
, 1,
1475 "() -> (UInt16 _rv)"},
1476 {"WESetSelection", (PyCFunction
)wasteObj_WESetSelection
, 1,
1477 "(SInt32 selStart, SInt32 selEnd) -> None"},
1478 {"WESetDestRect", (PyCFunction
)wasteObj_WESetDestRect
, 1,
1479 "(LongRect destRect) -> None"},
1480 {"WESetViewRect", (PyCFunction
)wasteObj_WESetViewRect
, 1,
1481 "(LongRect viewRect) -> None"},
1482 {"WEContinuousStyle", (PyCFunction
)wasteObj_WEContinuousStyle
, 1,
1483 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
1484 {"WEGetRunInfo", (PyCFunction
)wasteObj_WEGetRunInfo
, 1,
1485 "(SInt32 offset) -> (WERunInfo runInfo)"},
1486 {"WEGetOffset", (PyCFunction
)wasteObj_WEGetOffset
, 1,
1487 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
1488 {"WEGetPoint", (PyCFunction
)wasteObj_WEGetPoint
, 1,
1489 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
1490 {"WEFindWord", (PyCFunction
)wasteObj_WEFindWord
, 1,
1491 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
1492 {"WEFindLine", (PyCFunction
)wasteObj_WEFindLine
, 1,
1493 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
1494 {"WECopyRange", (PyCFunction
)wasteObj_WECopyRange
, 1,
1495 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1496 {"WEGetAlignment", (PyCFunction
)wasteObj_WEGetAlignment
, 1,
1497 "() -> (WEAlignment _rv)"},
1498 {"WESetAlignment", (PyCFunction
)wasteObj_WESetAlignment
, 1,
1499 "(WEAlignment alignment) -> None"},
1500 {"WECalText", (PyCFunction
)wasteObj_WECalText
, 1,
1502 {"WEUpdate", (PyCFunction
)wasteObj_WEUpdate
, 1,
1503 "(RgnHandle updateRgn) -> None"},
1504 {"WEScroll", (PyCFunction
)wasteObj_WEScroll
, 1,
1505 "(SInt32 hOffset, SInt32 vOffset) -> None"},
1506 {"WESelView", (PyCFunction
)wasteObj_WESelView
, 1,
1508 {"WEActivate", (PyCFunction
)wasteObj_WEActivate
, 1,
1510 {"WEDeactivate", (PyCFunction
)wasteObj_WEDeactivate
, 1,
1512 {"WEKey", (PyCFunction
)wasteObj_WEKey
, 1,
1513 "(SInt16 key, EventModifiers modifiers) -> None"},
1514 {"WEClick", (PyCFunction
)wasteObj_WEClick
, 1,
1515 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
1516 {"WEAdjustCursor", (PyCFunction
)wasteObj_WEAdjustCursor
, 1,
1517 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1518 {"WEIdle", (PyCFunction
)wasteObj_WEIdle
, 1,
1519 "() -> (UInt32 maxSleep)"},
1520 {"WEInsert", (PyCFunction
)wasteObj_WEInsert
, 1,
1521 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1522 {"WEDelete", (PyCFunction
)wasteObj_WEDelete
, 1,
1524 {"WESetStyle", (PyCFunction
)wasteObj_WESetStyle
, 1,
1525 "(WEStyleMode mode, TextStyle ts) -> None"},
1526 {"WEUseStyleScrap", (PyCFunction
)wasteObj_WEUseStyleScrap
, 1,
1527 "(StScrpHandle hStyles) -> None"},
1528 {"WEUseText", (PyCFunction
)wasteObj_WEUseText
, 1,
1529 "(Handle hText) -> None"},
1530 {"WEUndo", (PyCFunction
)wasteObj_WEUndo
, 1,
1532 {"WEClearUndo", (PyCFunction
)wasteObj_WEClearUndo
, 1,
1534 {"WEGetUndoInfo", (PyCFunction
)wasteObj_WEGetUndoInfo
, 1,
1535 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1536 {"WEIsTyping", (PyCFunction
)wasteObj_WEIsTyping
, 1,
1537 "() -> (Boolean _rv)"},
1538 {"WEGetModCount", (PyCFunction
)wasteObj_WEGetModCount
, 1,
1539 "() -> (UInt32 _rv)"},
1540 {"WEResetModCount", (PyCFunction
)wasteObj_WEResetModCount
, 1,
1542 {"WEInsertObject", (PyCFunction
)wasteObj_WEInsertObject
, 1,
1543 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1544 {"WEGetSelectedObject", (PyCFunction
)wasteObj_WEGetSelectedObject
, 1,
1545 "() -> (WEObjectReference obj)"},
1546 {"WEFindNextObject", (PyCFunction
)wasteObj_WEFindNextObject
, 1,
1547 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
1548 {"WEUseSoup", (PyCFunction
)wasteObj_WEUseSoup
, 1,
1549 "(WESoupHandle hSoup) -> None"},
1550 {"WECut", (PyCFunction
)wasteObj_WECut
, 1,
1552 {"WECopy", (PyCFunction
)wasteObj_WECopy
, 1,
1554 {"WEPaste", (PyCFunction
)wasteObj_WEPaste
, 1,
1556 {"WECanPaste", (PyCFunction
)wasteObj_WECanPaste
, 1,
1557 "() -> (Boolean _rv)"},
1558 {"WEGetHiliteRgn", (PyCFunction
)wasteObj_WEGetHiliteRgn
, 1,
1559 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
1560 {"WECharByte", (PyCFunction
)wasteObj_WECharByte
, 1,
1561 "(SInt32 offset) -> (SInt16 _rv)"},
1562 {"WECharType", (PyCFunction
)wasteObj_WECharType
, 1,
1563 "(SInt32 offset) -> (SInt16 _rv)"},
1564 {"WEStopInlineSession", (PyCFunction
)wasteObj_WEStopInlineSession
, 1,
1566 {"WEFeatureFlag", (PyCFunction
)wasteObj_WEFeatureFlag
, 1,
1567 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
1571 PyMethodChain wasteObj_chain
= { wasteObj_methods
, NULL
};
1573 static PyObject
*wasteObj_getattr(self
, name
)
1577 return Py_FindMethodInChain(&wasteObj_chain
, (PyObject
*)self
, name
);
1580 #define wasteObj_setattr NULL
1582 PyTypeObject waste_Type
= {
1583 PyObject_HEAD_INIT(&PyType_Type
)
1585 "waste", /*tp_name*/
1586 sizeof(wasteObject
), /*tp_basicsize*/
1589 (destructor
) wasteObj_dealloc
, /*tp_dealloc*/
1591 (getattrfunc
) wasteObj_getattr
, /*tp_getattr*/
1592 (setattrfunc
) wasteObj_setattr
, /*tp_setattr*/
1595 /* --------------------- End object type waste ---------------------- */
1598 static PyObject
*waste_WENew(_self
, _args
)
1602 PyObject
*_res
= NULL
;
1608 if (!PyArg_ParseTuple(_args
, "O&O&l",
1609 LongRect_Convert
, &destRect
,
1610 LongRect_Convert
, &viewRect
,
1613 _err
= WENew(&destRect
,
1617 if (_err
!= noErr
) return PyMac_Error(_err
);
1618 _res
= Py_BuildValue("O&",
1623 static PyObject
*waste_WEInstallTSMHandlers(_self
, _args
)
1627 PyObject
*_res
= NULL
;
1629 if (!PyArg_ParseTuple(_args
, ""))
1631 _err
= WEInstallTSMHandlers();
1632 if (_err
!= noErr
) return PyMac_Error(_err
);
1638 static PyObject
*waste_WERemoveTSMHandlers(_self
, _args
)
1642 PyObject
*_res
= NULL
;
1644 if (!PyArg_ParseTuple(_args
, ""))
1646 _err
= WERemoveTSMHandlers();
1647 if (_err
!= noErr
) return PyMac_Error(_err
);
1653 static PyObject
*waste_WELongPointToPoint(_self
, _args
)
1657 PyObject
*_res
= NULL
;
1660 if (!PyArg_ParseTuple(_args
, "O&",
1661 LongPt_Convert
, &lp
))
1663 WELongPointToPoint(&lp
,
1665 _res
= Py_BuildValue("O&",
1666 PyMac_BuildPoint
, p
);
1670 static PyObject
*waste_WEPointToLongPoint(_self
, _args
)
1674 PyObject
*_res
= NULL
;
1677 if (!PyArg_ParseTuple(_args
, "O&",
1678 PyMac_GetPoint
, &p
))
1680 WEPointToLongPoint(p
,
1682 _res
= Py_BuildValue("O&",
1687 static PyObject
*waste_WESetLongRect(_self
, _args
)
1691 PyObject
*_res
= NULL
;
1697 if (!PyArg_ParseTuple(_args
, "llll",
1708 _res
= Py_BuildValue("O&",
1713 static PyObject
*waste_WELongRectToRect(_self
, _args
)
1717 PyObject
*_res
= NULL
;
1720 if (!PyArg_ParseTuple(_args
, "O&",
1721 LongRect_Convert
, &lr
))
1723 WELongRectToRect(&lr
,
1725 _res
= Py_BuildValue("O&",
1726 PyMac_BuildRect
, &r
);
1730 static PyObject
*waste_WERectToLongRect(_self
, _args
)
1734 PyObject
*_res
= NULL
;
1737 if (!PyArg_ParseTuple(_args
, "O&",
1740 WERectToLongRect(&r
,
1742 _res
= Py_BuildValue("O&",
1747 static PyObject
*waste_WEOffsetLongRect(_self
, _args
)
1751 PyObject
*_res
= NULL
;
1755 if (!PyArg_ParseTuple(_args
, "ll",
1759 WEOffsetLongRect(&lr
,
1762 _res
= Py_BuildValue("O&",
1767 static PyObject
*waste_WELongPointInLongRect(_self
, _args
)
1771 PyObject
*_res
= NULL
;
1775 if (!PyArg_ParseTuple(_args
, "O&O&",
1776 LongPt_Convert
, &lp
,
1777 LongRect_Convert
, &lr
))
1779 _rv
= WELongPointInLongRect(&lp
,
1781 _res
= Py_BuildValue("b",
1786 static PyObject
*waste_STDObjectHandlers(_self
, _args
)
1790 PyObject
*_res
= NULL
;
1793 // install the sample object handlers for pictures and sounds
1794 #define kTypePicture 'PICT'
1795 #define kTypeSound 'snd '
1797 if ( !PyArg_ParseTuple(_args
, "") ) return NULL
;
1799 if ((err
= WEInstallObjectHandler(kTypePicture
, weNewHandler
,
1800 (UniversalProcPtr
) NewWENewObjectProc(HandleNewPicture
), NULL
)) != noErr
)
1803 if ((err
= WEInstallObjectHandler(kTypePicture
, weDisposeHandler
,
1804 (UniversalProcPtr
) NewWEDisposeObjectProc(HandleDisposePicture
), NULL
)) != noErr
)
1807 if ((err
= WEInstallObjectHandler(kTypePicture
, weDrawHandler
,
1808 (UniversalProcPtr
) NewWEDrawObjectProc(HandleDrawPicture
), NULL
)) != noErr
)
1811 if ((err
= WEInstallObjectHandler(kTypeSound
, weNewHandler
,
1812 (UniversalProcPtr
) NewWENewObjectProc(HandleNewSound
), NULL
)) != noErr
)
1815 if ((err
= WEInstallObjectHandler(kTypeSound
, weDrawHandler
,
1816 (UniversalProcPtr
) NewWEDrawObjectProc(HandleDrawSound
), NULL
)) != noErr
)
1819 if ((err
= WEInstallObjectHandler(kTypeSound
, weClickHandler
,
1820 (UniversalProcPtr
) NewWEClickObjectProc(HandleClickSound
), NULL
)) != noErr
)
1826 return PyMac_Error(err
);
1830 static PyObject
*waste_WEInstallObjectHandler(_self
, _args
)
1834 PyObject
*_res
= NULL
;
1837 FlavorType objectType
;
1838 WESelector selector
;
1839 PyObject
*py_handler
;
1840 UniversalProcPtr handler
;
1841 WEReference we
= NULL
;
1845 if ( !PyArg_ParseTuple(_args
, "O&O&O|O&",
1846 PyMac_GetOSType
, &objectType
,
1847 PyMac_GetOSType
, &selector
,
1849 ExistingwasteObj_New
, &we
) ) return NULL
;
1851 if ( selector
== weNewHandler
) handler
= (UniversalProcPtr
)upp_new_handler
;
1852 else if ( selector
== weDisposeHandler
) handler
= (UniversalProcPtr
)upp_dispose_handler
;
1853 else if ( selector
== weDrawHandler
) handler
= (UniversalProcPtr
)upp_draw_handler
;
1854 else if ( selector
== weClickHandler
) handler
= (UniversalProcPtr
)upp_click_handler
;
1855 else return PyMac_Error(weUndefinedSelectorErr
);
1857 if ((key
= Py_BuildValue("O&O&",
1858 PyMac_BuildOSType
, objectType
,
1859 PyMac_BuildOSType
, selector
)) == NULL
)
1862 PyDict_SetItem(callbackdict
, key
, py_handler
);
1864 err
= WEInstallObjectHandler(objectType
, selector
, handler
, we
);
1865 if ( err
) return PyMac_Error(err
);
1871 static PyMethodDef waste_methods
[] = {
1872 {"WENew", (PyCFunction
)waste_WENew
, 1,
1873 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
1874 {"WEInstallTSMHandlers", (PyCFunction
)waste_WEInstallTSMHandlers
, 1,
1876 {"WERemoveTSMHandlers", (PyCFunction
)waste_WERemoveTSMHandlers
, 1,
1878 {"WELongPointToPoint", (PyCFunction
)waste_WELongPointToPoint
, 1,
1879 "(LongPt lp) -> (Point p)"},
1880 {"WEPointToLongPoint", (PyCFunction
)waste_WEPointToLongPoint
, 1,
1881 "(Point p) -> (LongPt lp)"},
1882 {"WESetLongRect", (PyCFunction
)waste_WESetLongRect
, 1,
1883 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
1884 {"WELongRectToRect", (PyCFunction
)waste_WELongRectToRect
, 1,
1885 "(LongRect lr) -> (Rect r)"},
1886 {"WERectToLongRect", (PyCFunction
)waste_WERectToLongRect
, 1,
1887 "(Rect r) -> (LongRect lr)"},
1888 {"WEOffsetLongRect", (PyCFunction
)waste_WEOffsetLongRect
, 1,
1889 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
1890 {"WELongPointInLongRect", (PyCFunction
)waste_WELongPointInLongRect
, 1,
1891 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
1892 {"STDObjectHandlers", (PyCFunction
)waste_STDObjectHandlers
, 1,
1894 {"WEInstallObjectHandler", (PyCFunction
)waste_WEInstallObjectHandler
, 1,
1901 /* Return the object corresponding to the window, or NULL */
1904 ExistingwasteObj_New(w
)
1907 PyObject
*it
= NULL
;
1912 WEGetInfo(weRefCon
, (void *)&it
, w
);
1913 if (it
== NULL
|| ((wasteObject
*)it
)->ob_itself
!= w
)
1928 m
= Py_InitModule("waste", waste_methods
);
1929 d
= PyModule_GetDict(m
);
1930 waste_Error
= PyMac_GetOSErrException();
1931 if (waste_Error
== NULL
||
1932 PyDict_SetItemString(d
, "Error", waste_Error
) != 0)
1933 Py_FatalError("can't initialize waste.Error");
1935 callbackdict
= PyDict_New();
1936 if (callbackdict
== NULL
|| PyDict_SetItemString(d
, "callbacks", callbackdict
) != 0)
1937 Py_FatalError("can't initialize Waste.callbackdict");
1938 upp_new_handler
= NewWENewObjectProc(my_new_handler
);
1939 upp_dispose_handler
= NewWEDisposeObjectProc(my_dispose_handler
);
1940 upp_draw_handler
= NewWEDrawObjectProc(my_draw_handler
);
1941 upp_click_handler
= NewWEClickObjectProc(my_click_handler
);
1946 /* ======================== End module waste ======================== */