2 /* =========================== Module _TE =========================== */
9 #include "pymactoolbox.h"
11 /* Macro to test whether a weak-loaded CFM function exists */
12 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13 PyErr_SetString(PyExc_NotImplementedError, \
14 "Not available in this shared library/OS version"); \
19 #include <Carbon/Carbon.h>
21 #ifdef USE_TOOLBOX_OBJECT_GLUE
22 extern PyObject
*_TEObj_New(TEHandle
);
23 extern int _TEObj_Convert(PyObject
*, TEHandle
*);
25 #define TEObj_New _TEObj_New
26 #define TEObj_Convert _TEObj_Convert
29 #define as_TE(h) ((TEHandle)h)
30 #define as_Resource(teh) ((Handle)teh)
33 ** Parse/generate TextStyle records
36 TextStyle_New(TextStylePtr itself
)
39 return Py_BuildValue("lllO&", (long)itself
->tsFont
, (long)itself
->tsFace
, (long)itself
->tsSize
, QdRGB_New
,
44 TextStyle_Convert(PyObject
*v
, TextStylePtr p_itself
)
46 long font
, face
, size
;
48 if( !PyArg_ParseTuple(v
, "lllO&", &font
, &face
, &size
, QdRGB_Convert
, &p_itself
->tsColor
) )
50 p_itself
->tsFont
= (short)font
;
51 p_itself
->tsFace
= (Style
)face
;
52 p_itself
->tsSize
= (short)size
;
56 static PyObject
*TE_Error
;
58 /* ------------------------- Object type TE ------------------------- */
62 #define TEObj_Check(x) ((x)->ob_type == &TE_Type || PyObject_TypeCheck((x), &TE_Type))
64 typedef struct TEObject
{
69 PyObject
*TEObj_New(TEHandle itself
)
73 PyErr_SetString(TE_Error
,"Cannot create null TE");
76 it
= PyObject_NEW(TEObject
, &TE_Type
);
77 if (it
== NULL
) return NULL
;
78 it
->ob_itself
= itself
;
79 return (PyObject
*)it
;
82 int TEObj_Convert(PyObject
*v
, TEHandle
*p_itself
)
86 PyErr_SetString(PyExc_TypeError
, "TE required");
89 *p_itself
= ((TEObject
*)v
)->ob_itself
;
93 static void TEObj_dealloc(TEObject
*self
)
95 TEDispose(self
->ob_itself
);
96 self
->ob_type
->tp_free((PyObject
*)self
);
99 static PyObject
*TEObj_TESetText(TEObject
*_self
, PyObject
*_args
)
101 PyObject
*_res
= NULL
;
106 PyMac_PRECHECK(TESetText
);
108 if (!PyArg_ParseTuple(_args
, "s#",
109 &text__in__
, &text__in_len__
))
111 text__len__
= text__in_len__
;
112 TESetText(text__in__
, text__len__
,
119 static PyObject
*TEObj_TEGetText(TEObject
*_self
, PyObject
*_args
)
121 PyObject
*_res
= NULL
;
124 PyMac_PRECHECK(TEGetText
);
126 if (!PyArg_ParseTuple(_args
, ""))
128 _rv
= TEGetText(_self
->ob_itself
);
129 _res
= Py_BuildValue("O&",
134 static PyObject
*TEObj_TEIdle(TEObject
*_self
, PyObject
*_args
)
136 PyObject
*_res
= NULL
;
138 PyMac_PRECHECK(TEIdle
);
140 if (!PyArg_ParseTuple(_args
, ""))
142 TEIdle(_self
->ob_itself
);
148 static PyObject
*TEObj_TESetSelect(TEObject
*_self
, PyObject
*_args
)
150 PyObject
*_res
= NULL
;
154 PyMac_PRECHECK(TESetSelect
);
156 if (!PyArg_ParseTuple(_args
, "ll",
160 TESetSelect(selStart
,
168 static PyObject
*TEObj_TEActivate(TEObject
*_self
, PyObject
*_args
)
170 PyObject
*_res
= NULL
;
172 PyMac_PRECHECK(TEActivate
);
174 if (!PyArg_ParseTuple(_args
, ""))
176 TEActivate(_self
->ob_itself
);
182 static PyObject
*TEObj_TEDeactivate(TEObject
*_self
, PyObject
*_args
)
184 PyObject
*_res
= NULL
;
186 PyMac_PRECHECK(TEDeactivate
);
188 if (!PyArg_ParseTuple(_args
, ""))
190 TEDeactivate(_self
->ob_itself
);
196 static PyObject
*TEObj_TEKey(TEObject
*_self
, PyObject
*_args
)
198 PyObject
*_res
= NULL
;
201 PyMac_PRECHECK(TEKey
);
203 if (!PyArg_ParseTuple(_args
, "h",
213 static PyObject
*TEObj_TECut(TEObject
*_self
, PyObject
*_args
)
215 PyObject
*_res
= NULL
;
217 PyMac_PRECHECK(TECut
);
219 if (!PyArg_ParseTuple(_args
, ""))
221 TECut(_self
->ob_itself
);
227 static PyObject
*TEObj_TECopy(TEObject
*_self
, PyObject
*_args
)
229 PyObject
*_res
= NULL
;
231 PyMac_PRECHECK(TECopy
);
233 if (!PyArg_ParseTuple(_args
, ""))
235 TECopy(_self
->ob_itself
);
241 static PyObject
*TEObj_TEPaste(TEObject
*_self
, PyObject
*_args
)
243 PyObject
*_res
= NULL
;
245 PyMac_PRECHECK(TEPaste
);
247 if (!PyArg_ParseTuple(_args
, ""))
249 TEPaste(_self
->ob_itself
);
255 static PyObject
*TEObj_TEDelete(TEObject
*_self
, PyObject
*_args
)
257 PyObject
*_res
= NULL
;
259 PyMac_PRECHECK(TEDelete
);
261 if (!PyArg_ParseTuple(_args
, ""))
263 TEDelete(_self
->ob_itself
);
269 static PyObject
*TEObj_TEInsert(TEObject
*_self
, PyObject
*_args
)
271 PyObject
*_res
= NULL
;
276 PyMac_PRECHECK(TEInsert
);
278 if (!PyArg_ParseTuple(_args
, "s#",
279 &text__in__
, &text__in_len__
))
281 text__len__
= text__in_len__
;
282 TEInsert(text__in__
, text__len__
,
289 static PyObject
*TEObj_TESetAlignment(TEObject
*_self
, PyObject
*_args
)
291 PyObject
*_res
= NULL
;
293 #ifndef TESetAlignment
294 PyMac_PRECHECK(TESetAlignment
);
296 if (!PyArg_ParseTuple(_args
, "h",
306 static PyObject
*TEObj_TEUpdate(TEObject
*_self
, PyObject
*_args
)
308 PyObject
*_res
= NULL
;
311 PyMac_PRECHECK(TEUpdate
);
313 if (!PyArg_ParseTuple(_args
, "O&",
314 PyMac_GetRect
, &rUpdate
))
323 static PyObject
*TEObj_TEScroll(TEObject
*_self
, PyObject
*_args
)
325 PyObject
*_res
= NULL
;
329 PyMac_PRECHECK(TEScroll
);
331 if (!PyArg_ParseTuple(_args
, "hh",
343 static PyObject
*TEObj_TESelView(TEObject
*_self
, PyObject
*_args
)
345 PyObject
*_res
= NULL
;
347 PyMac_PRECHECK(TESelView
);
349 if (!PyArg_ParseTuple(_args
, ""))
351 TESelView(_self
->ob_itself
);
357 static PyObject
*TEObj_TEPinScroll(TEObject
*_self
, PyObject
*_args
)
359 PyObject
*_res
= NULL
;
363 PyMac_PRECHECK(TEPinScroll
);
365 if (!PyArg_ParseTuple(_args
, "hh",
377 static PyObject
*TEObj_TEAutoView(TEObject
*_self
, PyObject
*_args
)
379 PyObject
*_res
= NULL
;
382 PyMac_PRECHECK(TEAutoView
);
384 if (!PyArg_ParseTuple(_args
, "b",
394 static PyObject
*TEObj_TECalText(TEObject
*_self
, PyObject
*_args
)
396 PyObject
*_res
= NULL
;
398 PyMac_PRECHECK(TECalText
);
400 if (!PyArg_ParseTuple(_args
, ""))
402 TECalText(_self
->ob_itself
);
408 static PyObject
*TEObj_TEGetOffset(TEObject
*_self
, PyObject
*_args
)
410 PyObject
*_res
= NULL
;
414 PyMac_PRECHECK(TEGetOffset
);
416 if (!PyArg_ParseTuple(_args
, "O&",
417 PyMac_GetPoint
, &pt
))
419 _rv
= TEGetOffset(pt
,
421 _res
= Py_BuildValue("h",
426 static PyObject
*TEObj_TEGetPoint(TEObject
*_self
, PyObject
*_args
)
428 PyObject
*_res
= NULL
;
432 PyMac_PRECHECK(TEGetPoint
);
434 if (!PyArg_ParseTuple(_args
, "h",
437 _rv
= TEGetPoint(offset
,
439 _res
= Py_BuildValue("O&",
440 PyMac_BuildPoint
, _rv
);
444 static PyObject
*TEObj_TEClick(TEObject
*_self
, PyObject
*_args
)
446 PyObject
*_res
= NULL
;
450 PyMac_PRECHECK(TEClick
);
452 if (!PyArg_ParseTuple(_args
, "O&b",
464 static PyObject
*TEObj_TESetStyleHandle(TEObject
*_self
, PyObject
*_args
)
466 PyObject
*_res
= NULL
;
467 TEStyleHandle theHandle
;
468 #ifndef TESetStyleHandle
469 PyMac_PRECHECK(TESetStyleHandle
);
471 if (!PyArg_ParseTuple(_args
, "O&",
472 ResObj_Convert
, &theHandle
))
474 TESetStyleHandle(theHandle
,
481 static PyObject
*TEObj_TEGetStyleHandle(TEObject
*_self
, PyObject
*_args
)
483 PyObject
*_res
= NULL
;
485 #ifndef TEGetStyleHandle
486 PyMac_PRECHECK(TEGetStyleHandle
);
488 if (!PyArg_ParseTuple(_args
, ""))
490 _rv
= TEGetStyleHandle(_self
->ob_itself
);
491 _res
= Py_BuildValue("O&",
496 static PyObject
*TEObj_TEGetStyle(TEObject
*_self
, PyObject
*_args
)
498 PyObject
*_res
= NULL
;
504 PyMac_PRECHECK(TEGetStyle
);
506 if (!PyArg_ParseTuple(_args
, "h",
514 _res
= Py_BuildValue("O&hh",
515 TextStyle_New
, &theStyle
,
521 static PyObject
*TEObj_TEStylePaste(TEObject
*_self
, PyObject
*_args
)
523 PyObject
*_res
= NULL
;
525 PyMac_PRECHECK(TEStylePaste
);
527 if (!PyArg_ParseTuple(_args
, ""))
529 TEStylePaste(_self
->ob_itself
);
535 static PyObject
*TEObj_TESetStyle(TEObject
*_self
, PyObject
*_args
)
537 PyObject
*_res
= NULL
;
542 PyMac_PRECHECK(TESetStyle
);
544 if (!PyArg_ParseTuple(_args
, "hO&b",
546 TextStyle_Convert
, &newStyle
,
558 static PyObject
*TEObj_TEReplaceStyle(TEObject
*_self
, PyObject
*_args
)
560 PyObject
*_res
= NULL
;
565 #ifndef TEReplaceStyle
566 PyMac_PRECHECK(TEReplaceStyle
);
568 if (!PyArg_ParseTuple(_args
, "hO&O&b",
570 TextStyle_Convert
, &oldStyle
,
571 TextStyle_Convert
, &newStyle
,
584 static PyObject
*TEObj_TEGetStyleScrapHandle(TEObject
*_self
, PyObject
*_args
)
586 PyObject
*_res
= NULL
;
588 #ifndef TEGetStyleScrapHandle
589 PyMac_PRECHECK(TEGetStyleScrapHandle
);
591 if (!PyArg_ParseTuple(_args
, ""))
593 _rv
= TEGetStyleScrapHandle(_self
->ob_itself
);
594 _res
= Py_BuildValue("O&",
599 static PyObject
*TEObj_TEStyleInsert(TEObject
*_self
, PyObject
*_args
)
601 PyObject
*_res
= NULL
;
606 #ifndef TEStyleInsert
607 PyMac_PRECHECK(TEStyleInsert
);
609 if (!PyArg_ParseTuple(_args
, "s#O&",
610 &text__in__
, &text__in_len__
,
611 ResObj_Convert
, &hST
))
613 text__len__
= text__in_len__
;
614 TEStyleInsert(text__in__
, text__len__
,
622 static PyObject
*TEObj_TEGetHeight(TEObject
*_self
, PyObject
*_args
)
624 PyObject
*_res
= NULL
;
629 PyMac_PRECHECK(TEGetHeight
);
631 if (!PyArg_ParseTuple(_args
, "ll",
635 _rv
= TEGetHeight(endLine
,
638 _res
= Py_BuildValue("l",
643 static PyObject
*TEObj_TEContinuousStyle(TEObject
*_self
, PyObject
*_args
)
645 PyObject
*_res
= NULL
;
649 #ifndef TEContinuousStyle
650 PyMac_PRECHECK(TEContinuousStyle
);
652 if (!PyArg_ParseTuple(_args
, "hO&",
654 TextStyle_Convert
, &aStyle
))
656 _rv
= TEContinuousStyle(&mode
,
659 _res
= Py_BuildValue("bhO&",
662 TextStyle_New
, &aStyle
);
666 static PyObject
*TEObj_TEUseStyleScrap(TEObject
*_self
, PyObject
*_args
)
668 PyObject
*_res
= NULL
;
671 StScrpHandle newStyles
;
673 #ifndef TEUseStyleScrap
674 PyMac_PRECHECK(TEUseStyleScrap
);
676 if (!PyArg_ParseTuple(_args
, "llO&b",
679 ResObj_Convert
, &newStyles
,
682 TEUseStyleScrap(rangeStart
,
692 static PyObject
*TEObj_TENumStyles(TEObject
*_self
, PyObject
*_args
)
694 PyObject
*_res
= NULL
;
699 PyMac_PRECHECK(TENumStyles
);
701 if (!PyArg_ParseTuple(_args
, "ll",
705 _rv
= TENumStyles(rangeStart
,
708 _res
= Py_BuildValue("l",
713 static PyObject
*TEObj_TEFeatureFlag(TEObject
*_self
, PyObject
*_args
)
715 PyObject
*_res
= NULL
;
719 #ifndef TEFeatureFlag
720 PyMac_PRECHECK(TEFeatureFlag
);
722 if (!PyArg_ParseTuple(_args
, "hh",
726 _rv
= TEFeatureFlag(feature
,
729 _res
= Py_BuildValue("h",
734 static PyObject
*TEObj_TEGetHiliteRgn(TEObject
*_self
, PyObject
*_args
)
736 PyObject
*_res
= NULL
;
739 #ifndef TEGetHiliteRgn
740 PyMac_PRECHECK(TEGetHiliteRgn
);
742 if (!PyArg_ParseTuple(_args
, "O&",
743 ResObj_Convert
, ®ion
))
745 _err
= TEGetHiliteRgn(region
,
747 if (_err
!= noErr
) return PyMac_Error(_err
);
753 static PyObject
*TEObj_as_Resource(TEObject
*_self
, PyObject
*_args
)
755 PyObject
*_res
= NULL
;
758 PyMac_PRECHECK(as_Resource
);
760 if (!PyArg_ParseTuple(_args
, ""))
762 _rv
= as_Resource(_self
->ob_itself
);
763 _res
= Py_BuildValue("O&",
768 static PyMethodDef TEObj_methods
[] = {
769 {"TESetText", (PyCFunction
)TEObj_TESetText
, 1,
770 PyDoc_STR("(Buffer text) -> None")},
771 {"TEGetText", (PyCFunction
)TEObj_TEGetText
, 1,
772 PyDoc_STR("() -> (CharsHandle _rv)")},
773 {"TEIdle", (PyCFunction
)TEObj_TEIdle
, 1,
774 PyDoc_STR("() -> None")},
775 {"TESetSelect", (PyCFunction
)TEObj_TESetSelect
, 1,
776 PyDoc_STR("(long selStart, long selEnd) -> None")},
777 {"TEActivate", (PyCFunction
)TEObj_TEActivate
, 1,
778 PyDoc_STR("() -> None")},
779 {"TEDeactivate", (PyCFunction
)TEObj_TEDeactivate
, 1,
780 PyDoc_STR("() -> None")},
781 {"TEKey", (PyCFunction
)TEObj_TEKey
, 1,
782 PyDoc_STR("(CharParameter key) -> None")},
783 {"TECut", (PyCFunction
)TEObj_TECut
, 1,
784 PyDoc_STR("() -> None")},
785 {"TECopy", (PyCFunction
)TEObj_TECopy
, 1,
786 PyDoc_STR("() -> None")},
787 {"TEPaste", (PyCFunction
)TEObj_TEPaste
, 1,
788 PyDoc_STR("() -> None")},
789 {"TEDelete", (PyCFunction
)TEObj_TEDelete
, 1,
790 PyDoc_STR("() -> None")},
791 {"TEInsert", (PyCFunction
)TEObj_TEInsert
, 1,
792 PyDoc_STR("(Buffer text) -> None")},
793 {"TESetAlignment", (PyCFunction
)TEObj_TESetAlignment
, 1,
794 PyDoc_STR("(short just) -> None")},
795 {"TEUpdate", (PyCFunction
)TEObj_TEUpdate
, 1,
796 PyDoc_STR("(Rect rUpdate) -> None")},
797 {"TEScroll", (PyCFunction
)TEObj_TEScroll
, 1,
798 PyDoc_STR("(short dh, short dv) -> None")},
799 {"TESelView", (PyCFunction
)TEObj_TESelView
, 1,
800 PyDoc_STR("() -> None")},
801 {"TEPinScroll", (PyCFunction
)TEObj_TEPinScroll
, 1,
802 PyDoc_STR("(short dh, short dv) -> None")},
803 {"TEAutoView", (PyCFunction
)TEObj_TEAutoView
, 1,
804 PyDoc_STR("(Boolean fAuto) -> None")},
805 {"TECalText", (PyCFunction
)TEObj_TECalText
, 1,
806 PyDoc_STR("() -> None")},
807 {"TEGetOffset", (PyCFunction
)TEObj_TEGetOffset
, 1,
808 PyDoc_STR("(Point pt) -> (short _rv)")},
809 {"TEGetPoint", (PyCFunction
)TEObj_TEGetPoint
, 1,
810 PyDoc_STR("(short offset) -> (Point _rv)")},
811 {"TEClick", (PyCFunction
)TEObj_TEClick
, 1,
812 PyDoc_STR("(Point pt, Boolean fExtend) -> None")},
813 {"TESetStyleHandle", (PyCFunction
)TEObj_TESetStyleHandle
, 1,
814 PyDoc_STR("(TEStyleHandle theHandle) -> None")},
815 {"TEGetStyleHandle", (PyCFunction
)TEObj_TEGetStyleHandle
, 1,
816 PyDoc_STR("() -> (TEStyleHandle _rv)")},
817 {"TEGetStyle", (PyCFunction
)TEObj_TEGetStyle
, 1,
818 PyDoc_STR("(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)")},
819 {"TEStylePaste", (PyCFunction
)TEObj_TEStylePaste
, 1,
820 PyDoc_STR("() -> None")},
821 {"TESetStyle", (PyCFunction
)TEObj_TESetStyle
, 1,
822 PyDoc_STR("(short mode, TextStyle newStyle, Boolean fRedraw) -> None")},
823 {"TEReplaceStyle", (PyCFunction
)TEObj_TEReplaceStyle
, 1,
824 PyDoc_STR("(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None")},
825 {"TEGetStyleScrapHandle", (PyCFunction
)TEObj_TEGetStyleScrapHandle
, 1,
826 PyDoc_STR("() -> (StScrpHandle _rv)")},
827 {"TEStyleInsert", (PyCFunction
)TEObj_TEStyleInsert
, 1,
828 PyDoc_STR("(Buffer text, StScrpHandle hST) -> None")},
829 {"TEGetHeight", (PyCFunction
)TEObj_TEGetHeight
, 1,
830 PyDoc_STR("(long endLine, long startLine) -> (long _rv)")},
831 {"TEContinuousStyle", (PyCFunction
)TEObj_TEContinuousStyle
, 1,
832 PyDoc_STR("(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)")},
833 {"TEUseStyleScrap", (PyCFunction
)TEObj_TEUseStyleScrap
, 1,
834 PyDoc_STR("(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None")},
835 {"TENumStyles", (PyCFunction
)TEObj_TENumStyles
, 1,
836 PyDoc_STR("(long rangeStart, long rangeEnd) -> (long _rv)")},
837 {"TEFeatureFlag", (PyCFunction
)TEObj_TEFeatureFlag
, 1,
838 PyDoc_STR("(short feature, short action) -> (short _rv)")},
839 {"TEGetHiliteRgn", (PyCFunction
)TEObj_TEGetHiliteRgn
, 1,
840 PyDoc_STR("(RgnHandle region) -> None")},
841 {"as_Resource", (PyCFunction
)TEObj_as_Resource
, 1,
842 PyDoc_STR("() -> (Handle _rv)")},
846 static PyObject
*TEObj_get_destRect(TEObject
*self
, void *closure
)
848 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->destRect
);
851 #define TEObj_set_destRect NULL
853 static PyObject
*TEObj_get_viewRect(TEObject
*self
, void *closure
)
855 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->viewRect
);
858 #define TEObj_set_viewRect NULL
860 static PyObject
*TEObj_get_selRect(TEObject
*self
, void *closure
)
862 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->selRect
);
865 #define TEObj_set_selRect NULL
867 static PyObject
*TEObj_get_lineHeight(TEObject
*self
, void *closure
)
869 return Py_BuildValue("h", (*self
->ob_itself
)->lineHeight
);
872 #define TEObj_set_lineHeight NULL
874 static PyObject
*TEObj_get_fontAscent(TEObject
*self
, void *closure
)
876 return Py_BuildValue("h", (*self
->ob_itself
)->fontAscent
);
879 #define TEObj_set_fontAscent NULL
881 static PyObject
*TEObj_get_selPoint(TEObject
*self
, void *closure
)
883 return Py_BuildValue("O&", PyMac_BuildPoint
, (*self
->ob_itself
)->selPoint
);
886 #define TEObj_set_selPoint NULL
888 static PyObject
*TEObj_get_selStart(TEObject
*self
, void *closure
)
890 return Py_BuildValue("h", (*self
->ob_itself
)->selStart
);
893 #define TEObj_set_selStart NULL
895 static PyObject
*TEObj_get_selEnd(TEObject
*self
, void *closure
)
897 return Py_BuildValue("h", (*self
->ob_itself
)->selEnd
);
900 #define TEObj_set_selEnd NULL
902 static PyObject
*TEObj_get_active(TEObject
*self
, void *closure
)
904 return Py_BuildValue("h", (*self
->ob_itself
)->active
);
907 #define TEObj_set_active NULL
909 static PyObject
*TEObj_get_just(TEObject
*self
, void *closure
)
911 return Py_BuildValue("h", (*self
->ob_itself
)->just
);
914 #define TEObj_set_just NULL
916 static PyObject
*TEObj_get_teLength(TEObject
*self
, void *closure
)
918 return Py_BuildValue("h", (*self
->ob_itself
)->teLength
);
921 #define TEObj_set_teLength NULL
923 static PyObject
*TEObj_get_txFont(TEObject
*self
, void *closure
)
925 return Py_BuildValue("h", (*self
->ob_itself
)->txFont
);
928 #define TEObj_set_txFont NULL
930 static PyObject
*TEObj_get_txFace(TEObject
*self
, void *closure
)
932 return Py_BuildValue("h", (*self
->ob_itself
)->txFace
);
935 #define TEObj_set_txFace NULL
937 static PyObject
*TEObj_get_txMode(TEObject
*self
, void *closure
)
939 return Py_BuildValue("h", (*self
->ob_itself
)->txMode
);
942 #define TEObj_set_txMode NULL
944 static PyObject
*TEObj_get_txSize(TEObject
*self
, void *closure
)
946 return Py_BuildValue("h", (*self
->ob_itself
)->txSize
);
949 #define TEObj_set_txSize NULL
951 static PyObject
*TEObj_get_nLines(TEObject
*self
, void *closure
)
953 return Py_BuildValue("h", (*self
->ob_itself
)->nLines
);
956 #define TEObj_set_nLines NULL
958 static PyGetSetDef TEObj_getsetlist
[] = {
959 {"destRect", (getter
)TEObj_get_destRect
, (setter
)TEObj_set_destRect
, "Destination rectangle"},
960 {"viewRect", (getter
)TEObj_get_viewRect
, (setter
)TEObj_set_viewRect
, "Viewing rectangle"},
961 {"selRect", (getter
)TEObj_get_selRect
, (setter
)TEObj_set_selRect
, "Selection rectangle"},
962 {"lineHeight", (getter
)TEObj_get_lineHeight
, (setter
)TEObj_set_lineHeight
, "Height of a line"},
963 {"fontAscent", (getter
)TEObj_get_fontAscent
, (setter
)TEObj_set_fontAscent
, "Ascent of a line"},
964 {"selPoint", (getter
)TEObj_get_selPoint
, (setter
)TEObj_set_selPoint
, "Selection Point"},
965 {"selStart", (getter
)TEObj_get_selStart
, (setter
)TEObj_set_selStart
, "Start of selection"},
966 {"selEnd", (getter
)TEObj_get_selEnd
, (setter
)TEObj_set_selEnd
, "End of selection"},
967 {"active", (getter
)TEObj_get_active
, (setter
)TEObj_set_active
, "TBD"},
968 {"just", (getter
)TEObj_get_just
, (setter
)TEObj_set_just
, "Justification"},
969 {"teLength", (getter
)TEObj_get_teLength
, (setter
)TEObj_set_teLength
, "TBD"},
970 {"txFont", (getter
)TEObj_get_txFont
, (setter
)TEObj_set_txFont
, "Current font"},
971 {"txFace", (getter
)TEObj_get_txFace
, (setter
)TEObj_set_txFace
, "Current font variant"},
972 {"txMode", (getter
)TEObj_get_txMode
, (setter
)TEObj_set_txMode
, "Current text-drawing mode"},
973 {"txSize", (getter
)TEObj_get_txSize
, (setter
)TEObj_set_txSize
, "Current font size"},
974 {"nLines", (getter
)TEObj_get_nLines
, (setter
)TEObj_set_nLines
, "TBD"},
975 {NULL
, NULL
, NULL
, NULL
},
979 #define TEObj_compare NULL
981 #define TEObj_repr NULL
983 #define TEObj_hash NULL
984 #define TEObj_tp_init 0
986 #define TEObj_tp_alloc PyType_GenericAlloc
988 static PyObject
*TEObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
992 char *kw
[] = {"itself", 0};
994 if (!PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, TEObj_Convert
, &itself
)) return NULL
;
995 if ((_self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
996 ((TEObject
*)_self
)->ob_itself
= itself
;
1000 #define TEObj_tp_free PyObject_Del
1003 PyTypeObject TE_Type
= {
1004 PyObject_HEAD_INIT(NULL
)
1006 "_TE.TE", /*tp_name*/
1007 sizeof(TEObject
), /*tp_basicsize*/
1010 (destructor
) TEObj_dealloc
, /*tp_dealloc*/
1012 (getattrfunc
)0, /*tp_getattr*/
1013 (setattrfunc
)0, /*tp_setattr*/
1014 (cmpfunc
) TEObj_compare
, /*tp_compare*/
1015 (reprfunc
) TEObj_repr
, /*tp_repr*/
1016 (PyNumberMethods
*)0, /* tp_as_number */
1017 (PySequenceMethods
*)0, /* tp_as_sequence */
1018 (PyMappingMethods
*)0, /* tp_as_mapping */
1019 (hashfunc
) TEObj_hash
, /*tp_hash*/
1022 PyObject_GenericGetAttr
, /*tp_getattro*/
1023 PyObject_GenericSetAttr
, /*tp_setattro */
1025 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1029 0, /*tp_richcompare*/
1030 0, /*tp_weaklistoffset*/
1033 TEObj_methods
, /* tp_methods */
1035 TEObj_getsetlist
, /*tp_getset*/
1040 0, /*tp_dictoffset*/
1041 TEObj_tp_init
, /* tp_init */
1042 TEObj_tp_alloc
, /* tp_alloc */
1043 TEObj_tp_new
, /* tp_new */
1044 TEObj_tp_free
, /* tp_free */
1047 /* ----------------------- End object type TE ----------------------- */
1050 static PyObject
*TE_TEScrapHandle(PyObject
*_self
, PyObject
*_args
)
1052 PyObject
*_res
= NULL
;
1054 #ifndef TEScrapHandle
1055 PyMac_PRECHECK(TEScrapHandle
);
1057 if (!PyArg_ParseTuple(_args
, ""))
1059 _rv
= TEScrapHandle();
1060 _res
= Py_BuildValue("O&",
1065 static PyObject
*TE_TEGetScrapLength(PyObject
*_self
, PyObject
*_args
)
1067 PyObject
*_res
= NULL
;
1069 #ifndef TEGetScrapLength
1070 PyMac_PRECHECK(TEGetScrapLength
);
1072 if (!PyArg_ParseTuple(_args
, ""))
1074 _rv
= TEGetScrapLength();
1075 _res
= Py_BuildValue("l",
1080 static PyObject
*TE_TENew(PyObject
*_self
, PyObject
*_args
)
1082 PyObject
*_res
= NULL
;
1087 PyMac_PRECHECK(TENew
);
1089 if (!PyArg_ParseTuple(_args
, "O&O&",
1090 PyMac_GetRect
, &destRect
,
1091 PyMac_GetRect
, &viewRect
))
1093 _rv
= TENew(&destRect
,
1095 _res
= Py_BuildValue("O&",
1100 static PyObject
*TE_TETextBox(PyObject
*_self
, PyObject
*_args
)
1102 PyObject
*_res
= NULL
;
1109 PyMac_PRECHECK(TETextBox
);
1111 if (!PyArg_ParseTuple(_args
, "s#O&h",
1112 &text__in__
, &text__in_len__
,
1113 PyMac_GetRect
, &box
,
1116 text__len__
= text__in_len__
;
1117 TETextBox(text__in__
, text__len__
,
1125 static PyObject
*TE_TEStyleNew(PyObject
*_self
, PyObject
*_args
)
1127 PyObject
*_res
= NULL
;
1132 PyMac_PRECHECK(TEStyleNew
);
1134 if (!PyArg_ParseTuple(_args
, "O&O&",
1135 PyMac_GetRect
, &destRect
,
1136 PyMac_GetRect
, &viewRect
))
1138 _rv
= TEStyleNew(&destRect
,
1140 _res
= Py_BuildValue("O&",
1145 static PyObject
*TE_TESetScrapLength(PyObject
*_self
, PyObject
*_args
)
1147 PyObject
*_res
= NULL
;
1149 #ifndef TESetScrapLength
1150 PyMac_PRECHECK(TESetScrapLength
);
1152 if (!PyArg_ParseTuple(_args
, "l",
1155 TESetScrapLength(length
);
1161 static PyObject
*TE_TEFromScrap(PyObject
*_self
, PyObject
*_args
)
1163 PyObject
*_res
= NULL
;
1166 PyMac_PRECHECK(TEFromScrap
);
1168 if (!PyArg_ParseTuple(_args
, ""))
1170 _err
= TEFromScrap();
1171 if (_err
!= noErr
) return PyMac_Error(_err
);
1177 static PyObject
*TE_TEToScrap(PyObject
*_self
, PyObject
*_args
)
1179 PyObject
*_res
= NULL
;
1182 PyMac_PRECHECK(TEToScrap
);
1184 if (!PyArg_ParseTuple(_args
, ""))
1187 if (_err
!= noErr
) return PyMac_Error(_err
);
1193 static PyObject
*TE_TEGetScrapHandle(PyObject
*_self
, PyObject
*_args
)
1195 PyObject
*_res
= NULL
;
1197 #ifndef TEGetScrapHandle
1198 PyMac_PRECHECK(TEGetScrapHandle
);
1200 if (!PyArg_ParseTuple(_args
, ""))
1202 _rv
= TEGetScrapHandle();
1203 _res
= Py_BuildValue("O&",
1208 static PyObject
*TE_TESetScrapHandle(PyObject
*_self
, PyObject
*_args
)
1210 PyObject
*_res
= NULL
;
1212 #ifndef TESetScrapHandle
1213 PyMac_PRECHECK(TESetScrapHandle
);
1215 if (!PyArg_ParseTuple(_args
, "O&",
1216 ResObj_Convert
, &value
))
1218 TESetScrapHandle(value
);
1224 static PyObject
*TE_LMGetWordRedraw(PyObject
*_self
, PyObject
*_args
)
1226 PyObject
*_res
= NULL
;
1228 #ifndef LMGetWordRedraw
1229 PyMac_PRECHECK(LMGetWordRedraw
);
1231 if (!PyArg_ParseTuple(_args
, ""))
1233 _rv
= LMGetWordRedraw();
1234 _res
= Py_BuildValue("b",
1239 static PyObject
*TE_LMSetWordRedraw(PyObject
*_self
, PyObject
*_args
)
1241 PyObject
*_res
= NULL
;
1243 #ifndef LMSetWordRedraw
1244 PyMac_PRECHECK(LMSetWordRedraw
);
1246 if (!PyArg_ParseTuple(_args
, "b",
1249 LMSetWordRedraw(value
);
1255 static PyObject
*TE_as_TE(PyObject
*_self
, PyObject
*_args
)
1257 PyObject
*_res
= NULL
;
1261 PyMac_PRECHECK(as_TE
);
1263 if (!PyArg_ParseTuple(_args
, "O&",
1264 ResObj_Convert
, &h
))
1267 _res
= Py_BuildValue("O&",
1271 #endif /* __LP64__ */
1273 static PyMethodDef TE_methods
[] = {
1275 {"TEScrapHandle", (PyCFunction
)TE_TEScrapHandle
, 1,
1276 PyDoc_STR("() -> (Handle _rv)")},
1277 {"TEGetScrapLength", (PyCFunction
)TE_TEGetScrapLength
, 1,
1278 PyDoc_STR("() -> (long _rv)")},
1279 {"TENew", (PyCFunction
)TE_TENew
, 1,
1280 PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
1281 {"TETextBox", (PyCFunction
)TE_TETextBox
, 1,
1282 PyDoc_STR("(Buffer text, Rect box, short just) -> None")},
1283 {"TEStyleNew", (PyCFunction
)TE_TEStyleNew
, 1,
1284 PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
1285 {"TESetScrapLength", (PyCFunction
)TE_TESetScrapLength
, 1,
1286 PyDoc_STR("(long length) -> None")},
1287 {"TEFromScrap", (PyCFunction
)TE_TEFromScrap
, 1,
1288 PyDoc_STR("() -> None")},
1289 {"TEToScrap", (PyCFunction
)TE_TEToScrap
, 1,
1290 PyDoc_STR("() -> None")},
1291 {"TEGetScrapHandle", (PyCFunction
)TE_TEGetScrapHandle
, 1,
1292 PyDoc_STR("() -> (Handle _rv)")},
1293 {"TESetScrapHandle", (PyCFunction
)TE_TESetScrapHandle
, 1,
1294 PyDoc_STR("(Handle value) -> None")},
1295 {"LMGetWordRedraw", (PyCFunction
)TE_LMGetWordRedraw
, 1,
1296 PyDoc_STR("() -> (UInt8 _rv)")},
1297 {"LMSetWordRedraw", (PyCFunction
)TE_LMSetWordRedraw
, 1,
1298 PyDoc_STR("(UInt8 value) -> None")},
1299 {"as_TE", (PyCFunction
)TE_as_TE
, 1,
1300 PyDoc_STR("(Handle h) -> (TEHandle _rv)")},
1301 #endif /* __LP64__ */
1316 PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle
, TEObj_New
);
1317 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle
, TEObj_Convert
);
1319 #endif /* __LP64__ */
1321 m
= Py_InitModule("_TE", TE_methods
);
1323 d
= PyModule_GetDict(m
);
1324 TE_Error
= PyMac_GetOSErrException();
1325 if (TE_Error
== NULL
||
1326 PyDict_SetItemString(d
, "Error", TE_Error
) != 0)
1328 TE_Type
.ob_type
= &PyType_Type
;
1329 if (PyType_Ready(&TE_Type
) < 0) return;
1330 Py_INCREF(&TE_Type
);
1331 PyModule_AddObject(m
, "TE", (PyObject
*)&TE_Type
);
1332 /* Backward-compatible name */
1333 Py_INCREF(&TE_Type
);
1334 PyModule_AddObject(m
, "TEType", (PyObject
*)&TE_Type
);
1335 #endif /* __LP64__ */
1338 /* ========================= End module _TE ========================= */