2 /* =========================== Module _TE =========================== */
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"); \
23 #ifdef WITHOUT_FRAMEWORKS
26 #include <Carbon/Carbon.h>
29 #ifdef USE_TOOLBOX_OBJECT_GLUE
30 extern PyObject
*_TEObj_New(TEHandle
);
31 extern int _TEObj_Convert(PyObject
*, TEHandle
*);
33 #define TEObj_New _TEObj_New
34 #define TEObj_Convert _TEObj_Convert
37 #define as_TE(h) ((TEHandle)h)
38 #define as_Resource(teh) ((Handle)teh)
41 ** Parse/generate TextStyle records
44 TextStyle_New(TextStylePtr itself
)
47 return Py_BuildValue("lllO&", (long)itself
->tsFont
, (long)itself
->tsFace
, (long)itself
->tsSize
, QdRGB_New
,
52 TextStyle_Convert(PyObject
*v
, TextStylePtr p_itself
)
54 long font
, face
, size
;
56 if( !PyArg_ParseTuple(v
, "lllO&", &font
, &face
, &size
, QdRGB_Convert
, &p_itself
->tsColor
) )
58 p_itself
->tsFont
= (short)font
;
59 p_itself
->tsFace
= (Style
)face
;
60 p_itself
->tsSize
= (short)size
;
64 static PyObject
*TE_Error
;
66 /* ------------------------- Object type TE ------------------------- */
70 #define TEObj_Check(x) ((x)->ob_type == &TE_Type || PyObject_TypeCheck((x), &TE_Type))
72 typedef struct TEObject
{
77 PyObject
*TEObj_New(TEHandle itself
)
81 PyErr_SetString(TE_Error
,"Cannot create null TE");
84 it
= PyObject_NEW(TEObject
, &TE_Type
);
85 if (it
== NULL
) return NULL
;
86 it
->ob_itself
= itself
;
87 return (PyObject
*)it
;
89 int TEObj_Convert(PyObject
*v
, TEHandle
*p_itself
)
93 PyErr_SetString(PyExc_TypeError
, "TE required");
96 *p_itself
= ((TEObject
*)v
)->ob_itself
;
100 static void TEObj_dealloc(TEObject
*self
)
102 TEDispose(self
->ob_itself
);
103 self
->ob_type
->tp_free((PyObject
*)self
);
106 static PyObject
*TEObj_TESetText(TEObject
*_self
, PyObject
*_args
)
108 PyObject
*_res
= NULL
;
113 PyMac_PRECHECK(TESetText
);
115 if (!PyArg_ParseTuple(_args
, "s#",
116 &text__in__
, &text__in_len__
))
118 text__len__
= text__in_len__
;
119 TESetText(text__in__
, text__len__
,
126 static PyObject
*TEObj_TEGetText(TEObject
*_self
, PyObject
*_args
)
128 PyObject
*_res
= NULL
;
131 PyMac_PRECHECK(TEGetText
);
133 if (!PyArg_ParseTuple(_args
, ""))
135 _rv
= TEGetText(_self
->ob_itself
);
136 _res
= Py_BuildValue("O&",
141 static PyObject
*TEObj_TEIdle(TEObject
*_self
, PyObject
*_args
)
143 PyObject
*_res
= NULL
;
145 PyMac_PRECHECK(TEIdle
);
147 if (!PyArg_ParseTuple(_args
, ""))
149 TEIdle(_self
->ob_itself
);
155 static PyObject
*TEObj_TESetSelect(TEObject
*_self
, PyObject
*_args
)
157 PyObject
*_res
= NULL
;
161 PyMac_PRECHECK(TESetSelect
);
163 if (!PyArg_ParseTuple(_args
, "ll",
167 TESetSelect(selStart
,
175 static PyObject
*TEObj_TEActivate(TEObject
*_self
, PyObject
*_args
)
177 PyObject
*_res
= NULL
;
179 PyMac_PRECHECK(TEActivate
);
181 if (!PyArg_ParseTuple(_args
, ""))
183 TEActivate(_self
->ob_itself
);
189 static PyObject
*TEObj_TEDeactivate(TEObject
*_self
, PyObject
*_args
)
191 PyObject
*_res
= NULL
;
193 PyMac_PRECHECK(TEDeactivate
);
195 if (!PyArg_ParseTuple(_args
, ""))
197 TEDeactivate(_self
->ob_itself
);
203 static PyObject
*TEObj_TEKey(TEObject
*_self
, PyObject
*_args
)
205 PyObject
*_res
= NULL
;
208 PyMac_PRECHECK(TEKey
);
210 if (!PyArg_ParseTuple(_args
, "h",
220 static PyObject
*TEObj_TECut(TEObject
*_self
, PyObject
*_args
)
222 PyObject
*_res
= NULL
;
224 PyMac_PRECHECK(TECut
);
226 if (!PyArg_ParseTuple(_args
, ""))
228 TECut(_self
->ob_itself
);
234 static PyObject
*TEObj_TECopy(TEObject
*_self
, PyObject
*_args
)
236 PyObject
*_res
= NULL
;
238 PyMac_PRECHECK(TECopy
);
240 if (!PyArg_ParseTuple(_args
, ""))
242 TECopy(_self
->ob_itself
);
248 static PyObject
*TEObj_TEPaste(TEObject
*_self
, PyObject
*_args
)
250 PyObject
*_res
= NULL
;
252 PyMac_PRECHECK(TEPaste
);
254 if (!PyArg_ParseTuple(_args
, ""))
256 TEPaste(_self
->ob_itself
);
262 static PyObject
*TEObj_TEDelete(TEObject
*_self
, PyObject
*_args
)
264 PyObject
*_res
= NULL
;
266 PyMac_PRECHECK(TEDelete
);
268 if (!PyArg_ParseTuple(_args
, ""))
270 TEDelete(_self
->ob_itself
);
276 static PyObject
*TEObj_TEInsert(TEObject
*_self
, PyObject
*_args
)
278 PyObject
*_res
= NULL
;
283 PyMac_PRECHECK(TEInsert
);
285 if (!PyArg_ParseTuple(_args
, "s#",
286 &text__in__
, &text__in_len__
))
288 text__len__
= text__in_len__
;
289 TEInsert(text__in__
, text__len__
,
296 static PyObject
*TEObj_TESetAlignment(TEObject
*_self
, PyObject
*_args
)
298 PyObject
*_res
= NULL
;
300 #ifndef TESetAlignment
301 PyMac_PRECHECK(TESetAlignment
);
303 if (!PyArg_ParseTuple(_args
, "h",
313 static PyObject
*TEObj_TEUpdate(TEObject
*_self
, PyObject
*_args
)
315 PyObject
*_res
= NULL
;
318 PyMac_PRECHECK(TEUpdate
);
320 if (!PyArg_ParseTuple(_args
, "O&",
321 PyMac_GetRect
, &rUpdate
))
330 static PyObject
*TEObj_TEScroll(TEObject
*_self
, PyObject
*_args
)
332 PyObject
*_res
= NULL
;
336 PyMac_PRECHECK(TEScroll
);
338 if (!PyArg_ParseTuple(_args
, "hh",
350 static PyObject
*TEObj_TESelView(TEObject
*_self
, PyObject
*_args
)
352 PyObject
*_res
= NULL
;
354 PyMac_PRECHECK(TESelView
);
356 if (!PyArg_ParseTuple(_args
, ""))
358 TESelView(_self
->ob_itself
);
364 static PyObject
*TEObj_TEPinScroll(TEObject
*_self
, PyObject
*_args
)
366 PyObject
*_res
= NULL
;
370 PyMac_PRECHECK(TEPinScroll
);
372 if (!PyArg_ParseTuple(_args
, "hh",
384 static PyObject
*TEObj_TEAutoView(TEObject
*_self
, PyObject
*_args
)
386 PyObject
*_res
= NULL
;
389 PyMac_PRECHECK(TEAutoView
);
391 if (!PyArg_ParseTuple(_args
, "b",
401 static PyObject
*TEObj_TECalText(TEObject
*_self
, PyObject
*_args
)
403 PyObject
*_res
= NULL
;
405 PyMac_PRECHECK(TECalText
);
407 if (!PyArg_ParseTuple(_args
, ""))
409 TECalText(_self
->ob_itself
);
415 static PyObject
*TEObj_TEGetOffset(TEObject
*_self
, PyObject
*_args
)
417 PyObject
*_res
= NULL
;
421 PyMac_PRECHECK(TEGetOffset
);
423 if (!PyArg_ParseTuple(_args
, "O&",
424 PyMac_GetPoint
, &pt
))
426 _rv
= TEGetOffset(pt
,
428 _res
= Py_BuildValue("h",
433 static PyObject
*TEObj_TEGetPoint(TEObject
*_self
, PyObject
*_args
)
435 PyObject
*_res
= NULL
;
439 PyMac_PRECHECK(TEGetPoint
);
441 if (!PyArg_ParseTuple(_args
, "h",
444 _rv
= TEGetPoint(offset
,
446 _res
= Py_BuildValue("O&",
447 PyMac_BuildPoint
, _rv
);
451 static PyObject
*TEObj_TEClick(TEObject
*_self
, PyObject
*_args
)
453 PyObject
*_res
= NULL
;
457 PyMac_PRECHECK(TEClick
);
459 if (!PyArg_ParseTuple(_args
, "O&b",
471 static PyObject
*TEObj_TESetStyleHandle(TEObject
*_self
, PyObject
*_args
)
473 PyObject
*_res
= NULL
;
474 TEStyleHandle theHandle
;
475 #ifndef TESetStyleHandle
476 PyMac_PRECHECK(TESetStyleHandle
);
478 if (!PyArg_ParseTuple(_args
, "O&",
479 ResObj_Convert
, &theHandle
))
481 TESetStyleHandle(theHandle
,
488 static PyObject
*TEObj_TEGetStyleHandle(TEObject
*_self
, PyObject
*_args
)
490 PyObject
*_res
= NULL
;
492 #ifndef TEGetStyleHandle
493 PyMac_PRECHECK(TEGetStyleHandle
);
495 if (!PyArg_ParseTuple(_args
, ""))
497 _rv
= TEGetStyleHandle(_self
->ob_itself
);
498 _res
= Py_BuildValue("O&",
503 static PyObject
*TEObj_TEGetStyle(TEObject
*_self
, PyObject
*_args
)
505 PyObject
*_res
= NULL
;
511 PyMac_PRECHECK(TEGetStyle
);
513 if (!PyArg_ParseTuple(_args
, "h",
521 _res
= Py_BuildValue("O&hh",
522 TextStyle_New
, &theStyle
,
528 static PyObject
*TEObj_TEStylePaste(TEObject
*_self
, PyObject
*_args
)
530 PyObject
*_res
= NULL
;
532 PyMac_PRECHECK(TEStylePaste
);
534 if (!PyArg_ParseTuple(_args
, ""))
536 TEStylePaste(_self
->ob_itself
);
542 static PyObject
*TEObj_TESetStyle(TEObject
*_self
, PyObject
*_args
)
544 PyObject
*_res
= NULL
;
549 PyMac_PRECHECK(TESetStyle
);
551 if (!PyArg_ParseTuple(_args
, "hO&b",
553 TextStyle_Convert
, &newStyle
,
565 static PyObject
*TEObj_TEReplaceStyle(TEObject
*_self
, PyObject
*_args
)
567 PyObject
*_res
= NULL
;
572 #ifndef TEReplaceStyle
573 PyMac_PRECHECK(TEReplaceStyle
);
575 if (!PyArg_ParseTuple(_args
, "hO&O&b",
577 TextStyle_Convert
, &oldStyle
,
578 TextStyle_Convert
, &newStyle
,
591 static PyObject
*TEObj_TEGetStyleScrapHandle(TEObject
*_self
, PyObject
*_args
)
593 PyObject
*_res
= NULL
;
595 #ifndef TEGetStyleScrapHandle
596 PyMac_PRECHECK(TEGetStyleScrapHandle
);
598 if (!PyArg_ParseTuple(_args
, ""))
600 _rv
= TEGetStyleScrapHandle(_self
->ob_itself
);
601 _res
= Py_BuildValue("O&",
606 static PyObject
*TEObj_TEStyleInsert(TEObject
*_self
, PyObject
*_args
)
608 PyObject
*_res
= NULL
;
613 #ifndef TEStyleInsert
614 PyMac_PRECHECK(TEStyleInsert
);
616 if (!PyArg_ParseTuple(_args
, "s#O&",
617 &text__in__
, &text__in_len__
,
618 ResObj_Convert
, &hST
))
620 text__len__
= text__in_len__
;
621 TEStyleInsert(text__in__
, text__len__
,
629 static PyObject
*TEObj_TEGetHeight(TEObject
*_self
, PyObject
*_args
)
631 PyObject
*_res
= NULL
;
636 PyMac_PRECHECK(TEGetHeight
);
638 if (!PyArg_ParseTuple(_args
, "ll",
642 _rv
= TEGetHeight(endLine
,
645 _res
= Py_BuildValue("l",
650 static PyObject
*TEObj_TEContinuousStyle(TEObject
*_self
, PyObject
*_args
)
652 PyObject
*_res
= NULL
;
656 #ifndef TEContinuousStyle
657 PyMac_PRECHECK(TEContinuousStyle
);
659 if (!PyArg_ParseTuple(_args
, "hO&",
661 TextStyle_Convert
, &aStyle
))
663 _rv
= TEContinuousStyle(&mode
,
666 _res
= Py_BuildValue("bhO&",
669 TextStyle_New
, &aStyle
);
673 static PyObject
*TEObj_TEUseStyleScrap(TEObject
*_self
, PyObject
*_args
)
675 PyObject
*_res
= NULL
;
678 StScrpHandle newStyles
;
680 #ifndef TEUseStyleScrap
681 PyMac_PRECHECK(TEUseStyleScrap
);
683 if (!PyArg_ParseTuple(_args
, "llO&b",
686 ResObj_Convert
, &newStyles
,
689 TEUseStyleScrap(rangeStart
,
699 static PyObject
*TEObj_TENumStyles(TEObject
*_self
, PyObject
*_args
)
701 PyObject
*_res
= NULL
;
706 PyMac_PRECHECK(TENumStyles
);
708 if (!PyArg_ParseTuple(_args
, "ll",
712 _rv
= TENumStyles(rangeStart
,
715 _res
= Py_BuildValue("l",
720 static PyObject
*TEObj_TEFeatureFlag(TEObject
*_self
, PyObject
*_args
)
722 PyObject
*_res
= NULL
;
726 #ifndef TEFeatureFlag
727 PyMac_PRECHECK(TEFeatureFlag
);
729 if (!PyArg_ParseTuple(_args
, "hh",
733 _rv
= TEFeatureFlag(feature
,
736 _res
= Py_BuildValue("h",
741 static PyObject
*TEObj_TEGetHiliteRgn(TEObject
*_self
, PyObject
*_args
)
743 PyObject
*_res
= NULL
;
746 #ifndef TEGetHiliteRgn
747 PyMac_PRECHECK(TEGetHiliteRgn
);
749 if (!PyArg_ParseTuple(_args
, "O&",
750 ResObj_Convert
, ®ion
))
752 _err
= TEGetHiliteRgn(region
,
754 if (_err
!= noErr
) return PyMac_Error(_err
);
760 static PyObject
*TEObj_as_Resource(TEObject
*_self
, PyObject
*_args
)
762 PyObject
*_res
= NULL
;
765 PyMac_PRECHECK(as_Resource
);
767 if (!PyArg_ParseTuple(_args
, ""))
769 _rv
= as_Resource(_self
->ob_itself
);
770 _res
= Py_BuildValue("O&",
775 static PyMethodDef TEObj_methods
[] = {
776 {"TESetText", (PyCFunction
)TEObj_TESetText
, 1,
777 PyDoc_STR("(Buffer text) -> None")},
778 {"TEGetText", (PyCFunction
)TEObj_TEGetText
, 1,
779 PyDoc_STR("() -> (CharsHandle _rv)")},
780 {"TEIdle", (PyCFunction
)TEObj_TEIdle
, 1,
781 PyDoc_STR("() -> None")},
782 {"TESetSelect", (PyCFunction
)TEObj_TESetSelect
, 1,
783 PyDoc_STR("(long selStart, long selEnd) -> None")},
784 {"TEActivate", (PyCFunction
)TEObj_TEActivate
, 1,
785 PyDoc_STR("() -> None")},
786 {"TEDeactivate", (PyCFunction
)TEObj_TEDeactivate
, 1,
787 PyDoc_STR("() -> None")},
788 {"TEKey", (PyCFunction
)TEObj_TEKey
, 1,
789 PyDoc_STR("(CharParameter key) -> None")},
790 {"TECut", (PyCFunction
)TEObj_TECut
, 1,
791 PyDoc_STR("() -> None")},
792 {"TECopy", (PyCFunction
)TEObj_TECopy
, 1,
793 PyDoc_STR("() -> None")},
794 {"TEPaste", (PyCFunction
)TEObj_TEPaste
, 1,
795 PyDoc_STR("() -> None")},
796 {"TEDelete", (PyCFunction
)TEObj_TEDelete
, 1,
797 PyDoc_STR("() -> None")},
798 {"TEInsert", (PyCFunction
)TEObj_TEInsert
, 1,
799 PyDoc_STR("(Buffer text) -> None")},
800 {"TESetAlignment", (PyCFunction
)TEObj_TESetAlignment
, 1,
801 PyDoc_STR("(short just) -> None")},
802 {"TEUpdate", (PyCFunction
)TEObj_TEUpdate
, 1,
803 PyDoc_STR("(Rect rUpdate) -> None")},
804 {"TEScroll", (PyCFunction
)TEObj_TEScroll
, 1,
805 PyDoc_STR("(short dh, short dv) -> None")},
806 {"TESelView", (PyCFunction
)TEObj_TESelView
, 1,
807 PyDoc_STR("() -> None")},
808 {"TEPinScroll", (PyCFunction
)TEObj_TEPinScroll
, 1,
809 PyDoc_STR("(short dh, short dv) -> None")},
810 {"TEAutoView", (PyCFunction
)TEObj_TEAutoView
, 1,
811 PyDoc_STR("(Boolean fAuto) -> None")},
812 {"TECalText", (PyCFunction
)TEObj_TECalText
, 1,
813 PyDoc_STR("() -> None")},
814 {"TEGetOffset", (PyCFunction
)TEObj_TEGetOffset
, 1,
815 PyDoc_STR("(Point pt) -> (short _rv)")},
816 {"TEGetPoint", (PyCFunction
)TEObj_TEGetPoint
, 1,
817 PyDoc_STR("(short offset) -> (Point _rv)")},
818 {"TEClick", (PyCFunction
)TEObj_TEClick
, 1,
819 PyDoc_STR("(Point pt, Boolean fExtend) -> None")},
820 {"TESetStyleHandle", (PyCFunction
)TEObj_TESetStyleHandle
, 1,
821 PyDoc_STR("(TEStyleHandle theHandle) -> None")},
822 {"TEGetStyleHandle", (PyCFunction
)TEObj_TEGetStyleHandle
, 1,
823 PyDoc_STR("() -> (TEStyleHandle _rv)")},
824 {"TEGetStyle", (PyCFunction
)TEObj_TEGetStyle
, 1,
825 PyDoc_STR("(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)")},
826 {"TEStylePaste", (PyCFunction
)TEObj_TEStylePaste
, 1,
827 PyDoc_STR("() -> None")},
828 {"TESetStyle", (PyCFunction
)TEObj_TESetStyle
, 1,
829 PyDoc_STR("(short mode, TextStyle newStyle, Boolean fRedraw) -> None")},
830 {"TEReplaceStyle", (PyCFunction
)TEObj_TEReplaceStyle
, 1,
831 PyDoc_STR("(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None")},
832 {"TEGetStyleScrapHandle", (PyCFunction
)TEObj_TEGetStyleScrapHandle
, 1,
833 PyDoc_STR("() -> (StScrpHandle _rv)")},
834 {"TEStyleInsert", (PyCFunction
)TEObj_TEStyleInsert
, 1,
835 PyDoc_STR("(Buffer text, StScrpHandle hST) -> None")},
836 {"TEGetHeight", (PyCFunction
)TEObj_TEGetHeight
, 1,
837 PyDoc_STR("(long endLine, long startLine) -> (long _rv)")},
838 {"TEContinuousStyle", (PyCFunction
)TEObj_TEContinuousStyle
, 1,
839 PyDoc_STR("(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)")},
840 {"TEUseStyleScrap", (PyCFunction
)TEObj_TEUseStyleScrap
, 1,
841 PyDoc_STR("(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None")},
842 {"TENumStyles", (PyCFunction
)TEObj_TENumStyles
, 1,
843 PyDoc_STR("(long rangeStart, long rangeEnd) -> (long _rv)")},
844 {"TEFeatureFlag", (PyCFunction
)TEObj_TEFeatureFlag
, 1,
845 PyDoc_STR("(short feature, short action) -> (short _rv)")},
846 {"TEGetHiliteRgn", (PyCFunction
)TEObj_TEGetHiliteRgn
, 1,
847 PyDoc_STR("(RgnHandle region) -> None")},
848 {"as_Resource", (PyCFunction
)TEObj_as_Resource
, 1,
849 PyDoc_STR("() -> (Handle _rv)")},
853 static PyObject
*TEObj_get_destRect(TEObject
*self
, void *closure
)
855 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->destRect
);
858 #define TEObj_set_destRect NULL
860 static PyObject
*TEObj_get_viewRect(TEObject
*self
, void *closure
)
862 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->viewRect
);
865 #define TEObj_set_viewRect NULL
867 static PyObject
*TEObj_get_selRect(TEObject
*self
, void *closure
)
869 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->selRect
);
872 #define TEObj_set_selRect NULL
874 static PyObject
*TEObj_get_lineHeight(TEObject
*self
, void *closure
)
876 return Py_BuildValue("h", (*self
->ob_itself
)->lineHeight
);
879 #define TEObj_set_lineHeight NULL
881 static PyObject
*TEObj_get_fontAscent(TEObject
*self
, void *closure
)
883 return Py_BuildValue("h", (*self
->ob_itself
)->fontAscent
);
886 #define TEObj_set_fontAscent NULL
888 static PyObject
*TEObj_get_selPoint(TEObject
*self
, void *closure
)
890 return Py_BuildValue("O&", PyMac_BuildPoint
, (*self
->ob_itself
)->selPoint
);
893 #define TEObj_set_selPoint NULL
895 static PyObject
*TEObj_get_selStart(TEObject
*self
, void *closure
)
897 return Py_BuildValue("h", (*self
->ob_itself
)->selStart
);
900 #define TEObj_set_selStart NULL
902 static PyObject
*TEObj_get_selEnd(TEObject
*self
, void *closure
)
904 return Py_BuildValue("h", (*self
->ob_itself
)->selEnd
);
907 #define TEObj_set_selEnd NULL
909 static PyObject
*TEObj_get_active(TEObject
*self
, void *closure
)
911 return Py_BuildValue("h", (*self
->ob_itself
)->active
);
914 #define TEObj_set_active NULL
916 static PyObject
*TEObj_get_just(TEObject
*self
, void *closure
)
918 return Py_BuildValue("h", (*self
->ob_itself
)->just
);
921 #define TEObj_set_just NULL
923 static PyObject
*TEObj_get_teLength(TEObject
*self
, void *closure
)
925 return Py_BuildValue("h", (*self
->ob_itself
)->teLength
);
928 #define TEObj_set_teLength NULL
930 static PyObject
*TEObj_get_txFont(TEObject
*self
, void *closure
)
932 return Py_BuildValue("h", (*self
->ob_itself
)->txFont
);
935 #define TEObj_set_txFont NULL
937 static PyObject
*TEObj_get_txFace(TEObject
*self
, void *closure
)
939 return Py_BuildValue("h", (*self
->ob_itself
)->txFace
);
942 #define TEObj_set_txFace NULL
944 static PyObject
*TEObj_get_txMode(TEObject
*self
, void *closure
)
946 return Py_BuildValue("h", (*self
->ob_itself
)->txMode
);
949 #define TEObj_set_txMode NULL
951 static PyObject
*TEObj_get_txSize(TEObject
*self
, void *closure
)
953 return Py_BuildValue("h", (*self
->ob_itself
)->txSize
);
956 #define TEObj_set_txSize NULL
958 static PyObject
*TEObj_get_nLines(TEObject
*self
, void *closure
)
960 return Py_BuildValue("h", (*self
->ob_itself
)->nLines
);
963 #define TEObj_set_nLines NULL
965 static PyGetSetDef TEObj_getsetlist
[] = {
966 {"destRect", (getter
)TEObj_get_destRect
, (setter
)TEObj_set_destRect
, "Destination rectangle"},
967 {"viewRect", (getter
)TEObj_get_viewRect
, (setter
)TEObj_set_viewRect
, "Viewing rectangle"},
968 {"selRect", (getter
)TEObj_get_selRect
, (setter
)TEObj_set_selRect
, "Selection rectangle"},
969 {"lineHeight", (getter
)TEObj_get_lineHeight
, (setter
)TEObj_set_lineHeight
, "Height of a line"},
970 {"fontAscent", (getter
)TEObj_get_fontAscent
, (setter
)TEObj_set_fontAscent
, "Ascent of a line"},
971 {"selPoint", (getter
)TEObj_get_selPoint
, (setter
)TEObj_set_selPoint
, "Selection Point"},
972 {"selStart", (getter
)TEObj_get_selStart
, (setter
)TEObj_set_selStart
, "Start of selection"},
973 {"selEnd", (getter
)TEObj_get_selEnd
, (setter
)TEObj_set_selEnd
, "End of selection"},
974 {"active", (getter
)TEObj_get_active
, (setter
)TEObj_set_active
, "TBD"},
975 {"just", (getter
)TEObj_get_just
, (setter
)TEObj_set_just
, "Justification"},
976 {"teLength", (getter
)TEObj_get_teLength
, (setter
)TEObj_set_teLength
, "TBD"},
977 {"txFont", (getter
)TEObj_get_txFont
, (setter
)TEObj_set_txFont
, "Current font"},
978 {"txFace", (getter
)TEObj_get_txFace
, (setter
)TEObj_set_txFace
, "Current font variant"},
979 {"txMode", (getter
)TEObj_get_txMode
, (setter
)TEObj_set_txMode
, "Current text-drawing mode"},
980 {"txSize", (getter
)TEObj_get_txSize
, (setter
)TEObj_set_txSize
, "Current font size"},
981 {"nLines", (getter
)TEObj_get_nLines
, (setter
)TEObj_set_nLines
, "TBD"},
982 {NULL
, NULL
, NULL
, NULL
},
986 #define TEObj_compare NULL
988 #define TEObj_repr NULL
990 #define TEObj_hash NULL
991 #define TEObj_tp_init 0
993 #define TEObj_tp_alloc PyType_GenericAlloc
995 static PyObject
*TEObj_tp_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
)
999 char *kw
[] = {"itself", 0};
1001 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&", kw
, TEObj_Convert
, &itself
)) return NULL
;
1002 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1003 ((TEObject
*)self
)->ob_itself
= itself
;
1007 #define TEObj_tp_free PyObject_Del
1010 PyTypeObject TE_Type
= {
1011 PyObject_HEAD_INIT(NULL
)
1013 "_TE.TE", /*tp_name*/
1014 sizeof(TEObject
), /*tp_basicsize*/
1017 (destructor
) TEObj_dealloc
, /*tp_dealloc*/
1019 (getattrfunc
)0, /*tp_getattr*/
1020 (setattrfunc
)0, /*tp_setattr*/
1021 (cmpfunc
) TEObj_compare
, /*tp_compare*/
1022 (reprfunc
) TEObj_repr
, /*tp_repr*/
1023 (PyNumberMethods
*)0, /* tp_as_number */
1024 (PySequenceMethods
*)0, /* tp_as_sequence */
1025 (PyMappingMethods
*)0, /* tp_as_mapping */
1026 (hashfunc
) TEObj_hash
, /*tp_hash*/
1029 PyObject_GenericGetAttr
, /*tp_getattro*/
1030 PyObject_GenericSetAttr
, /*tp_setattro */
1032 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1036 0, /*tp_richcompare*/
1037 0, /*tp_weaklistoffset*/
1040 TEObj_methods
, /* tp_methods */
1042 TEObj_getsetlist
, /*tp_getset*/
1047 0, /*tp_dictoffset*/
1048 TEObj_tp_init
, /* tp_init */
1049 TEObj_tp_alloc
, /* tp_alloc */
1050 TEObj_tp_new
, /* tp_new */
1051 TEObj_tp_free
, /* tp_free */
1054 /* ----------------------- End object type TE ----------------------- */
1057 static PyObject
*TE_TEScrapHandle(PyObject
*_self
, PyObject
*_args
)
1059 PyObject
*_res
= NULL
;
1061 #ifndef TEScrapHandle
1062 PyMac_PRECHECK(TEScrapHandle
);
1064 if (!PyArg_ParseTuple(_args
, ""))
1066 _rv
= TEScrapHandle();
1067 _res
= Py_BuildValue("O&",
1072 static PyObject
*TE_TEGetScrapLength(PyObject
*_self
, PyObject
*_args
)
1074 PyObject
*_res
= NULL
;
1076 #ifndef TEGetScrapLength
1077 PyMac_PRECHECK(TEGetScrapLength
);
1079 if (!PyArg_ParseTuple(_args
, ""))
1081 _rv
= TEGetScrapLength();
1082 _res
= Py_BuildValue("l",
1087 static PyObject
*TE_TENew(PyObject
*_self
, PyObject
*_args
)
1089 PyObject
*_res
= NULL
;
1094 PyMac_PRECHECK(TENew
);
1096 if (!PyArg_ParseTuple(_args
, "O&O&",
1097 PyMac_GetRect
, &destRect
,
1098 PyMac_GetRect
, &viewRect
))
1100 _rv
= TENew(&destRect
,
1102 _res
= Py_BuildValue("O&",
1107 static PyObject
*TE_TETextBox(PyObject
*_self
, PyObject
*_args
)
1109 PyObject
*_res
= NULL
;
1116 PyMac_PRECHECK(TETextBox
);
1118 if (!PyArg_ParseTuple(_args
, "s#O&h",
1119 &text__in__
, &text__in_len__
,
1120 PyMac_GetRect
, &box
,
1123 text__len__
= text__in_len__
;
1124 TETextBox(text__in__
, text__len__
,
1132 static PyObject
*TE_TEStyleNew(PyObject
*_self
, PyObject
*_args
)
1134 PyObject
*_res
= NULL
;
1139 PyMac_PRECHECK(TEStyleNew
);
1141 if (!PyArg_ParseTuple(_args
, "O&O&",
1142 PyMac_GetRect
, &destRect
,
1143 PyMac_GetRect
, &viewRect
))
1145 _rv
= TEStyleNew(&destRect
,
1147 _res
= Py_BuildValue("O&",
1152 static PyObject
*TE_TESetScrapLength(PyObject
*_self
, PyObject
*_args
)
1154 PyObject
*_res
= NULL
;
1156 #ifndef TESetScrapLength
1157 PyMac_PRECHECK(TESetScrapLength
);
1159 if (!PyArg_ParseTuple(_args
, "l",
1162 TESetScrapLength(length
);
1168 static PyObject
*TE_TEFromScrap(PyObject
*_self
, PyObject
*_args
)
1170 PyObject
*_res
= NULL
;
1173 PyMac_PRECHECK(TEFromScrap
);
1175 if (!PyArg_ParseTuple(_args
, ""))
1177 _err
= TEFromScrap();
1178 if (_err
!= noErr
) return PyMac_Error(_err
);
1184 static PyObject
*TE_TEToScrap(PyObject
*_self
, PyObject
*_args
)
1186 PyObject
*_res
= NULL
;
1189 PyMac_PRECHECK(TEToScrap
);
1191 if (!PyArg_ParseTuple(_args
, ""))
1194 if (_err
!= noErr
) return PyMac_Error(_err
);
1200 static PyObject
*TE_TEGetScrapHandle(PyObject
*_self
, PyObject
*_args
)
1202 PyObject
*_res
= NULL
;
1204 #ifndef TEGetScrapHandle
1205 PyMac_PRECHECK(TEGetScrapHandle
);
1207 if (!PyArg_ParseTuple(_args
, ""))
1209 _rv
= TEGetScrapHandle();
1210 _res
= Py_BuildValue("O&",
1215 static PyObject
*TE_TESetScrapHandle(PyObject
*_self
, PyObject
*_args
)
1217 PyObject
*_res
= NULL
;
1219 #ifndef TESetScrapHandle
1220 PyMac_PRECHECK(TESetScrapHandle
);
1222 if (!PyArg_ParseTuple(_args
, "O&",
1223 ResObj_Convert
, &value
))
1225 TESetScrapHandle(value
);
1231 static PyObject
*TE_LMGetWordRedraw(PyObject
*_self
, PyObject
*_args
)
1233 PyObject
*_res
= NULL
;
1235 #ifndef LMGetWordRedraw
1236 PyMac_PRECHECK(LMGetWordRedraw
);
1238 if (!PyArg_ParseTuple(_args
, ""))
1240 _rv
= LMGetWordRedraw();
1241 _res
= Py_BuildValue("b",
1246 static PyObject
*TE_LMSetWordRedraw(PyObject
*_self
, PyObject
*_args
)
1248 PyObject
*_res
= NULL
;
1250 #ifndef LMSetWordRedraw
1251 PyMac_PRECHECK(LMSetWordRedraw
);
1253 if (!PyArg_ParseTuple(_args
, "b",
1256 LMSetWordRedraw(value
);
1262 static PyObject
*TE_as_TE(PyObject
*_self
, PyObject
*_args
)
1264 PyObject
*_res
= NULL
;
1268 PyMac_PRECHECK(as_TE
);
1270 if (!PyArg_ParseTuple(_args
, "O&",
1271 ResObj_Convert
, &h
))
1274 _res
= Py_BuildValue("O&",
1279 static PyMethodDef TE_methods
[] = {
1280 {"TEScrapHandle", (PyCFunction
)TE_TEScrapHandle
, 1,
1281 PyDoc_STR("() -> (Handle _rv)")},
1282 {"TEGetScrapLength", (PyCFunction
)TE_TEGetScrapLength
, 1,
1283 PyDoc_STR("() -> (long _rv)")},
1284 {"TENew", (PyCFunction
)TE_TENew
, 1,
1285 PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
1286 {"TETextBox", (PyCFunction
)TE_TETextBox
, 1,
1287 PyDoc_STR("(Buffer text, Rect box, short just) -> None")},
1288 {"TEStyleNew", (PyCFunction
)TE_TEStyleNew
, 1,
1289 PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
1290 {"TESetScrapLength", (PyCFunction
)TE_TESetScrapLength
, 1,
1291 PyDoc_STR("(long length) -> None")},
1292 {"TEFromScrap", (PyCFunction
)TE_TEFromScrap
, 1,
1293 PyDoc_STR("() -> None")},
1294 {"TEToScrap", (PyCFunction
)TE_TEToScrap
, 1,
1295 PyDoc_STR("() -> None")},
1296 {"TEGetScrapHandle", (PyCFunction
)TE_TEGetScrapHandle
, 1,
1297 PyDoc_STR("() -> (Handle _rv)")},
1298 {"TESetScrapHandle", (PyCFunction
)TE_TESetScrapHandle
, 1,
1299 PyDoc_STR("(Handle value) -> None")},
1300 {"LMGetWordRedraw", (PyCFunction
)TE_LMGetWordRedraw
, 1,
1301 PyDoc_STR("() -> (UInt8 _rv)")},
1302 {"LMSetWordRedraw", (PyCFunction
)TE_LMSetWordRedraw
, 1,
1303 PyDoc_STR("(UInt8 value) -> None")},
1304 {"as_TE", (PyCFunction
)TE_as_TE
, 1,
1305 PyDoc_STR("(Handle h) -> (TEHandle _rv)")},
1319 PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle
, TEObj_New
);
1320 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle
, TEObj_Convert
);
1323 m
= Py_InitModule("_TE", TE_methods
);
1324 d
= PyModule_GetDict(m
);
1325 TE_Error
= PyMac_GetOSErrException();
1326 if (TE_Error
== NULL
||
1327 PyDict_SetItemString(d
, "Error", TE_Error
) != 0)
1329 TE_Type
.ob_type
= &PyType_Type
;
1330 if (PyType_Ready(&TE_Type
) < 0) return;
1331 Py_INCREF(&TE_Type
);
1332 PyModule_AddObject(m
, "TE", (PyObject
*)&TE_Type
);
1333 /* Backward-compatible name */
1334 Py_INCREF(&TE_Type
);
1335 PyModule_AddObject(m
, "TEType", (PyObject
*)&TE_Type
);
1338 /* ========================= End module _TE ========================= */