2 /* =========================== Module _TE =========================== */
8 #include "pymactoolbox.h"
10 /* Macro to test whether a weak-loaded CFM function exists */
11 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
12 PyErr_SetString(PyExc_NotImplementedError, \
13 "Not available in this shared library/OS version"); \
18 #include <Carbon/Carbon.h>
20 #ifdef USE_TOOLBOX_OBJECT_GLUE
21 extern PyObject
*_TEObj_New(TEHandle
);
22 extern int _TEObj_Convert(PyObject
*, TEHandle
*);
24 #define TEObj_New _TEObj_New
25 #define TEObj_Convert _TEObj_Convert
28 #define as_TE(h) ((TEHandle)h)
29 #define as_Resource(teh) ((Handle)teh)
32 ** Parse/generate TextStyle records
35 TextStyle_New(TextStylePtr itself
)
38 return Py_BuildValue("lllO&", (long)itself
->tsFont
, (long)itself
->tsFace
, (long)itself
->tsSize
, QdRGB_New
,
43 TextStyle_Convert(PyObject
*v
, TextStylePtr p_itself
)
45 long font
, face
, size
;
47 if( !PyArg_ParseTuple(v
, "lllO&", &font
, &face
, &size
, QdRGB_Convert
, &p_itself
->tsColor
) )
49 p_itself
->tsFont
= (short)font
;
50 p_itself
->tsFace
= (Style
)face
;
51 p_itself
->tsSize
= (short)size
;
55 static PyObject
*TE_Error
;
57 /* ------------------------- Object type TE ------------------------- */
61 #define TEObj_Check(x) ((x)->ob_type == &TE_Type || PyObject_TypeCheck((x), &TE_Type))
63 typedef struct TEObject
{
68 PyObject
*TEObj_New(TEHandle itself
)
72 PyErr_SetString(TE_Error
,"Cannot create null TE");
75 it
= PyObject_NEW(TEObject
, &TE_Type
);
76 if (it
== NULL
) return NULL
;
77 it
->ob_itself
= itself
;
78 return (PyObject
*)it
;
81 int TEObj_Convert(PyObject
*v
, TEHandle
*p_itself
)
85 PyErr_SetString(PyExc_TypeError
, "TE required");
88 *p_itself
= ((TEObject
*)v
)->ob_itself
;
92 static void TEObj_dealloc(TEObject
*self
)
94 TEDispose(self
->ob_itself
);
95 self
->ob_type
->tp_free((PyObject
*)self
);
98 static PyObject
*TEObj_TESetText(TEObject
*_self
, PyObject
*_args
)
100 PyObject
*_res
= NULL
;
105 PyMac_PRECHECK(TESetText
);
107 if (!PyArg_ParseTuple(_args
, "s#",
108 &text__in__
, &text__in_len__
))
110 text__len__
= text__in_len__
;
111 TESetText(text__in__
, text__len__
,
118 static PyObject
*TEObj_TEGetText(TEObject
*_self
, PyObject
*_args
)
120 PyObject
*_res
= NULL
;
123 PyMac_PRECHECK(TEGetText
);
125 if (!PyArg_ParseTuple(_args
, ""))
127 _rv
= TEGetText(_self
->ob_itself
);
128 _res
= Py_BuildValue("O&",
133 static PyObject
*TEObj_TEIdle(TEObject
*_self
, PyObject
*_args
)
135 PyObject
*_res
= NULL
;
137 PyMac_PRECHECK(TEIdle
);
139 if (!PyArg_ParseTuple(_args
, ""))
141 TEIdle(_self
->ob_itself
);
147 static PyObject
*TEObj_TESetSelect(TEObject
*_self
, PyObject
*_args
)
149 PyObject
*_res
= NULL
;
153 PyMac_PRECHECK(TESetSelect
);
155 if (!PyArg_ParseTuple(_args
, "ll",
159 TESetSelect(selStart
,
167 static PyObject
*TEObj_TEActivate(TEObject
*_self
, PyObject
*_args
)
169 PyObject
*_res
= NULL
;
171 PyMac_PRECHECK(TEActivate
);
173 if (!PyArg_ParseTuple(_args
, ""))
175 TEActivate(_self
->ob_itself
);
181 static PyObject
*TEObj_TEDeactivate(TEObject
*_self
, PyObject
*_args
)
183 PyObject
*_res
= NULL
;
185 PyMac_PRECHECK(TEDeactivate
);
187 if (!PyArg_ParseTuple(_args
, ""))
189 TEDeactivate(_self
->ob_itself
);
195 static PyObject
*TEObj_TEKey(TEObject
*_self
, PyObject
*_args
)
197 PyObject
*_res
= NULL
;
200 PyMac_PRECHECK(TEKey
);
202 if (!PyArg_ParseTuple(_args
, "h",
212 static PyObject
*TEObj_TECut(TEObject
*_self
, PyObject
*_args
)
214 PyObject
*_res
= NULL
;
216 PyMac_PRECHECK(TECut
);
218 if (!PyArg_ParseTuple(_args
, ""))
220 TECut(_self
->ob_itself
);
226 static PyObject
*TEObj_TECopy(TEObject
*_self
, PyObject
*_args
)
228 PyObject
*_res
= NULL
;
230 PyMac_PRECHECK(TECopy
);
232 if (!PyArg_ParseTuple(_args
, ""))
234 TECopy(_self
->ob_itself
);
240 static PyObject
*TEObj_TEPaste(TEObject
*_self
, PyObject
*_args
)
242 PyObject
*_res
= NULL
;
244 PyMac_PRECHECK(TEPaste
);
246 if (!PyArg_ParseTuple(_args
, ""))
248 TEPaste(_self
->ob_itself
);
254 static PyObject
*TEObj_TEDelete(TEObject
*_self
, PyObject
*_args
)
256 PyObject
*_res
= NULL
;
258 PyMac_PRECHECK(TEDelete
);
260 if (!PyArg_ParseTuple(_args
, ""))
262 TEDelete(_self
->ob_itself
);
268 static PyObject
*TEObj_TEInsert(TEObject
*_self
, PyObject
*_args
)
270 PyObject
*_res
= NULL
;
275 PyMac_PRECHECK(TEInsert
);
277 if (!PyArg_ParseTuple(_args
, "s#",
278 &text__in__
, &text__in_len__
))
280 text__len__
= text__in_len__
;
281 TEInsert(text__in__
, text__len__
,
288 static PyObject
*TEObj_TESetAlignment(TEObject
*_self
, PyObject
*_args
)
290 PyObject
*_res
= NULL
;
292 #ifndef TESetAlignment
293 PyMac_PRECHECK(TESetAlignment
);
295 if (!PyArg_ParseTuple(_args
, "h",
305 static PyObject
*TEObj_TEUpdate(TEObject
*_self
, PyObject
*_args
)
307 PyObject
*_res
= NULL
;
310 PyMac_PRECHECK(TEUpdate
);
312 if (!PyArg_ParseTuple(_args
, "O&",
313 PyMac_GetRect
, &rUpdate
))
322 static PyObject
*TEObj_TEScroll(TEObject
*_self
, PyObject
*_args
)
324 PyObject
*_res
= NULL
;
328 PyMac_PRECHECK(TEScroll
);
330 if (!PyArg_ParseTuple(_args
, "hh",
342 static PyObject
*TEObj_TESelView(TEObject
*_self
, PyObject
*_args
)
344 PyObject
*_res
= NULL
;
346 PyMac_PRECHECK(TESelView
);
348 if (!PyArg_ParseTuple(_args
, ""))
350 TESelView(_self
->ob_itself
);
356 static PyObject
*TEObj_TEPinScroll(TEObject
*_self
, PyObject
*_args
)
358 PyObject
*_res
= NULL
;
362 PyMac_PRECHECK(TEPinScroll
);
364 if (!PyArg_ParseTuple(_args
, "hh",
376 static PyObject
*TEObj_TEAutoView(TEObject
*_self
, PyObject
*_args
)
378 PyObject
*_res
= NULL
;
381 PyMac_PRECHECK(TEAutoView
);
383 if (!PyArg_ParseTuple(_args
, "b",
393 static PyObject
*TEObj_TECalText(TEObject
*_self
, PyObject
*_args
)
395 PyObject
*_res
= NULL
;
397 PyMac_PRECHECK(TECalText
);
399 if (!PyArg_ParseTuple(_args
, ""))
401 TECalText(_self
->ob_itself
);
407 static PyObject
*TEObj_TEGetOffset(TEObject
*_self
, PyObject
*_args
)
409 PyObject
*_res
= NULL
;
413 PyMac_PRECHECK(TEGetOffset
);
415 if (!PyArg_ParseTuple(_args
, "O&",
416 PyMac_GetPoint
, &pt
))
418 _rv
= TEGetOffset(pt
,
420 _res
= Py_BuildValue("h",
425 static PyObject
*TEObj_TEGetPoint(TEObject
*_self
, PyObject
*_args
)
427 PyObject
*_res
= NULL
;
431 PyMac_PRECHECK(TEGetPoint
);
433 if (!PyArg_ParseTuple(_args
, "h",
436 _rv
= TEGetPoint(offset
,
438 _res
= Py_BuildValue("O&",
439 PyMac_BuildPoint
, _rv
);
443 static PyObject
*TEObj_TEClick(TEObject
*_self
, PyObject
*_args
)
445 PyObject
*_res
= NULL
;
449 PyMac_PRECHECK(TEClick
);
451 if (!PyArg_ParseTuple(_args
, "O&b",
463 static PyObject
*TEObj_TESetStyleHandle(TEObject
*_self
, PyObject
*_args
)
465 PyObject
*_res
= NULL
;
466 TEStyleHandle theHandle
;
467 #ifndef TESetStyleHandle
468 PyMac_PRECHECK(TESetStyleHandle
);
470 if (!PyArg_ParseTuple(_args
, "O&",
471 ResObj_Convert
, &theHandle
))
473 TESetStyleHandle(theHandle
,
480 static PyObject
*TEObj_TEGetStyleHandle(TEObject
*_self
, PyObject
*_args
)
482 PyObject
*_res
= NULL
;
484 #ifndef TEGetStyleHandle
485 PyMac_PRECHECK(TEGetStyleHandle
);
487 if (!PyArg_ParseTuple(_args
, ""))
489 _rv
= TEGetStyleHandle(_self
->ob_itself
);
490 _res
= Py_BuildValue("O&",
495 static PyObject
*TEObj_TEGetStyle(TEObject
*_self
, PyObject
*_args
)
497 PyObject
*_res
= NULL
;
503 PyMac_PRECHECK(TEGetStyle
);
505 if (!PyArg_ParseTuple(_args
, "h",
513 _res
= Py_BuildValue("O&hh",
514 TextStyle_New
, &theStyle
,
520 static PyObject
*TEObj_TEStylePaste(TEObject
*_self
, PyObject
*_args
)
522 PyObject
*_res
= NULL
;
524 PyMac_PRECHECK(TEStylePaste
);
526 if (!PyArg_ParseTuple(_args
, ""))
528 TEStylePaste(_self
->ob_itself
);
534 static PyObject
*TEObj_TESetStyle(TEObject
*_self
, PyObject
*_args
)
536 PyObject
*_res
= NULL
;
541 PyMac_PRECHECK(TESetStyle
);
543 if (!PyArg_ParseTuple(_args
, "hO&b",
545 TextStyle_Convert
, &newStyle
,
557 static PyObject
*TEObj_TEReplaceStyle(TEObject
*_self
, PyObject
*_args
)
559 PyObject
*_res
= NULL
;
564 #ifndef TEReplaceStyle
565 PyMac_PRECHECK(TEReplaceStyle
);
567 if (!PyArg_ParseTuple(_args
, "hO&O&b",
569 TextStyle_Convert
, &oldStyle
,
570 TextStyle_Convert
, &newStyle
,
583 static PyObject
*TEObj_TEGetStyleScrapHandle(TEObject
*_self
, PyObject
*_args
)
585 PyObject
*_res
= NULL
;
587 #ifndef TEGetStyleScrapHandle
588 PyMac_PRECHECK(TEGetStyleScrapHandle
);
590 if (!PyArg_ParseTuple(_args
, ""))
592 _rv
= TEGetStyleScrapHandle(_self
->ob_itself
);
593 _res
= Py_BuildValue("O&",
598 static PyObject
*TEObj_TEStyleInsert(TEObject
*_self
, PyObject
*_args
)
600 PyObject
*_res
= NULL
;
605 #ifndef TEStyleInsert
606 PyMac_PRECHECK(TEStyleInsert
);
608 if (!PyArg_ParseTuple(_args
, "s#O&",
609 &text__in__
, &text__in_len__
,
610 ResObj_Convert
, &hST
))
612 text__len__
= text__in_len__
;
613 TEStyleInsert(text__in__
, text__len__
,
621 static PyObject
*TEObj_TEGetHeight(TEObject
*_self
, PyObject
*_args
)
623 PyObject
*_res
= NULL
;
628 PyMac_PRECHECK(TEGetHeight
);
630 if (!PyArg_ParseTuple(_args
, "ll",
634 _rv
= TEGetHeight(endLine
,
637 _res
= Py_BuildValue("l",
642 static PyObject
*TEObj_TEContinuousStyle(TEObject
*_self
, PyObject
*_args
)
644 PyObject
*_res
= NULL
;
648 #ifndef TEContinuousStyle
649 PyMac_PRECHECK(TEContinuousStyle
);
651 if (!PyArg_ParseTuple(_args
, "hO&",
653 TextStyle_Convert
, &aStyle
))
655 _rv
= TEContinuousStyle(&mode
,
658 _res
= Py_BuildValue("bhO&",
661 TextStyle_New
, &aStyle
);
665 static PyObject
*TEObj_TEUseStyleScrap(TEObject
*_self
, PyObject
*_args
)
667 PyObject
*_res
= NULL
;
670 StScrpHandle newStyles
;
672 #ifndef TEUseStyleScrap
673 PyMac_PRECHECK(TEUseStyleScrap
);
675 if (!PyArg_ParseTuple(_args
, "llO&b",
678 ResObj_Convert
, &newStyles
,
681 TEUseStyleScrap(rangeStart
,
691 static PyObject
*TEObj_TENumStyles(TEObject
*_self
, PyObject
*_args
)
693 PyObject
*_res
= NULL
;
698 PyMac_PRECHECK(TENumStyles
);
700 if (!PyArg_ParseTuple(_args
, "ll",
704 _rv
= TENumStyles(rangeStart
,
707 _res
= Py_BuildValue("l",
712 static PyObject
*TEObj_TEFeatureFlag(TEObject
*_self
, PyObject
*_args
)
714 PyObject
*_res
= NULL
;
718 #ifndef TEFeatureFlag
719 PyMac_PRECHECK(TEFeatureFlag
);
721 if (!PyArg_ParseTuple(_args
, "hh",
725 _rv
= TEFeatureFlag(feature
,
728 _res
= Py_BuildValue("h",
733 static PyObject
*TEObj_TEGetHiliteRgn(TEObject
*_self
, PyObject
*_args
)
735 PyObject
*_res
= NULL
;
738 #ifndef TEGetHiliteRgn
739 PyMac_PRECHECK(TEGetHiliteRgn
);
741 if (!PyArg_ParseTuple(_args
, "O&",
742 ResObj_Convert
, ®ion
))
744 _err
= TEGetHiliteRgn(region
,
746 if (_err
!= noErr
) return PyMac_Error(_err
);
752 static PyObject
*TEObj_as_Resource(TEObject
*_self
, PyObject
*_args
)
754 PyObject
*_res
= NULL
;
757 PyMac_PRECHECK(as_Resource
);
759 if (!PyArg_ParseTuple(_args
, ""))
761 _rv
= as_Resource(_self
->ob_itself
);
762 _res
= Py_BuildValue("O&",
767 static PyMethodDef TEObj_methods
[] = {
768 {"TESetText", (PyCFunction
)TEObj_TESetText
, 1,
769 PyDoc_STR("(Buffer text) -> None")},
770 {"TEGetText", (PyCFunction
)TEObj_TEGetText
, 1,
771 PyDoc_STR("() -> (CharsHandle _rv)")},
772 {"TEIdle", (PyCFunction
)TEObj_TEIdle
, 1,
773 PyDoc_STR("() -> None")},
774 {"TESetSelect", (PyCFunction
)TEObj_TESetSelect
, 1,
775 PyDoc_STR("(long selStart, long selEnd) -> None")},
776 {"TEActivate", (PyCFunction
)TEObj_TEActivate
, 1,
777 PyDoc_STR("() -> None")},
778 {"TEDeactivate", (PyCFunction
)TEObj_TEDeactivate
, 1,
779 PyDoc_STR("() -> None")},
780 {"TEKey", (PyCFunction
)TEObj_TEKey
, 1,
781 PyDoc_STR("(CharParameter key) -> None")},
782 {"TECut", (PyCFunction
)TEObj_TECut
, 1,
783 PyDoc_STR("() -> None")},
784 {"TECopy", (PyCFunction
)TEObj_TECopy
, 1,
785 PyDoc_STR("() -> None")},
786 {"TEPaste", (PyCFunction
)TEObj_TEPaste
, 1,
787 PyDoc_STR("() -> None")},
788 {"TEDelete", (PyCFunction
)TEObj_TEDelete
, 1,
789 PyDoc_STR("() -> None")},
790 {"TEInsert", (PyCFunction
)TEObj_TEInsert
, 1,
791 PyDoc_STR("(Buffer text) -> None")},
792 {"TESetAlignment", (PyCFunction
)TEObj_TESetAlignment
, 1,
793 PyDoc_STR("(short just) -> None")},
794 {"TEUpdate", (PyCFunction
)TEObj_TEUpdate
, 1,
795 PyDoc_STR("(Rect rUpdate) -> None")},
796 {"TEScroll", (PyCFunction
)TEObj_TEScroll
, 1,
797 PyDoc_STR("(short dh, short dv) -> None")},
798 {"TESelView", (PyCFunction
)TEObj_TESelView
, 1,
799 PyDoc_STR("() -> None")},
800 {"TEPinScroll", (PyCFunction
)TEObj_TEPinScroll
, 1,
801 PyDoc_STR("(short dh, short dv) -> None")},
802 {"TEAutoView", (PyCFunction
)TEObj_TEAutoView
, 1,
803 PyDoc_STR("(Boolean fAuto) -> None")},
804 {"TECalText", (PyCFunction
)TEObj_TECalText
, 1,
805 PyDoc_STR("() -> None")},
806 {"TEGetOffset", (PyCFunction
)TEObj_TEGetOffset
, 1,
807 PyDoc_STR("(Point pt) -> (short _rv)")},
808 {"TEGetPoint", (PyCFunction
)TEObj_TEGetPoint
, 1,
809 PyDoc_STR("(short offset) -> (Point _rv)")},
810 {"TEClick", (PyCFunction
)TEObj_TEClick
, 1,
811 PyDoc_STR("(Point pt, Boolean fExtend) -> None")},
812 {"TESetStyleHandle", (PyCFunction
)TEObj_TESetStyleHandle
, 1,
813 PyDoc_STR("(TEStyleHandle theHandle) -> None")},
814 {"TEGetStyleHandle", (PyCFunction
)TEObj_TEGetStyleHandle
, 1,
815 PyDoc_STR("() -> (TEStyleHandle _rv)")},
816 {"TEGetStyle", (PyCFunction
)TEObj_TEGetStyle
, 1,
817 PyDoc_STR("(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)")},
818 {"TEStylePaste", (PyCFunction
)TEObj_TEStylePaste
, 1,
819 PyDoc_STR("() -> None")},
820 {"TESetStyle", (PyCFunction
)TEObj_TESetStyle
, 1,
821 PyDoc_STR("(short mode, TextStyle newStyle, Boolean fRedraw) -> None")},
822 {"TEReplaceStyle", (PyCFunction
)TEObj_TEReplaceStyle
, 1,
823 PyDoc_STR("(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None")},
824 {"TEGetStyleScrapHandle", (PyCFunction
)TEObj_TEGetStyleScrapHandle
, 1,
825 PyDoc_STR("() -> (StScrpHandle _rv)")},
826 {"TEStyleInsert", (PyCFunction
)TEObj_TEStyleInsert
, 1,
827 PyDoc_STR("(Buffer text, StScrpHandle hST) -> None")},
828 {"TEGetHeight", (PyCFunction
)TEObj_TEGetHeight
, 1,
829 PyDoc_STR("(long endLine, long startLine) -> (long _rv)")},
830 {"TEContinuousStyle", (PyCFunction
)TEObj_TEContinuousStyle
, 1,
831 PyDoc_STR("(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)")},
832 {"TEUseStyleScrap", (PyCFunction
)TEObj_TEUseStyleScrap
, 1,
833 PyDoc_STR("(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None")},
834 {"TENumStyles", (PyCFunction
)TEObj_TENumStyles
, 1,
835 PyDoc_STR("(long rangeStart, long rangeEnd) -> (long _rv)")},
836 {"TEFeatureFlag", (PyCFunction
)TEObj_TEFeatureFlag
, 1,
837 PyDoc_STR("(short feature, short action) -> (short _rv)")},
838 {"TEGetHiliteRgn", (PyCFunction
)TEObj_TEGetHiliteRgn
, 1,
839 PyDoc_STR("(RgnHandle region) -> None")},
840 {"as_Resource", (PyCFunction
)TEObj_as_Resource
, 1,
841 PyDoc_STR("() -> (Handle _rv)")},
845 static PyObject
*TEObj_get_destRect(TEObject
*self
, void *closure
)
847 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->destRect
);
850 #define TEObj_set_destRect NULL
852 static PyObject
*TEObj_get_viewRect(TEObject
*self
, void *closure
)
854 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->viewRect
);
857 #define TEObj_set_viewRect NULL
859 static PyObject
*TEObj_get_selRect(TEObject
*self
, void *closure
)
861 return Py_BuildValue("O&", PyMac_BuildRect
, &(*self
->ob_itself
)->selRect
);
864 #define TEObj_set_selRect NULL
866 static PyObject
*TEObj_get_lineHeight(TEObject
*self
, void *closure
)
868 return Py_BuildValue("h", (*self
->ob_itself
)->lineHeight
);
871 #define TEObj_set_lineHeight NULL
873 static PyObject
*TEObj_get_fontAscent(TEObject
*self
, void *closure
)
875 return Py_BuildValue("h", (*self
->ob_itself
)->fontAscent
);
878 #define TEObj_set_fontAscent NULL
880 static PyObject
*TEObj_get_selPoint(TEObject
*self
, void *closure
)
882 return Py_BuildValue("O&", PyMac_BuildPoint
, (*self
->ob_itself
)->selPoint
);
885 #define TEObj_set_selPoint NULL
887 static PyObject
*TEObj_get_selStart(TEObject
*self
, void *closure
)
889 return Py_BuildValue("h", (*self
->ob_itself
)->selStart
);
892 #define TEObj_set_selStart NULL
894 static PyObject
*TEObj_get_selEnd(TEObject
*self
, void *closure
)
896 return Py_BuildValue("h", (*self
->ob_itself
)->selEnd
);
899 #define TEObj_set_selEnd NULL
901 static PyObject
*TEObj_get_active(TEObject
*self
, void *closure
)
903 return Py_BuildValue("h", (*self
->ob_itself
)->active
);
906 #define TEObj_set_active NULL
908 static PyObject
*TEObj_get_just(TEObject
*self
, void *closure
)
910 return Py_BuildValue("h", (*self
->ob_itself
)->just
);
913 #define TEObj_set_just NULL
915 static PyObject
*TEObj_get_teLength(TEObject
*self
, void *closure
)
917 return Py_BuildValue("h", (*self
->ob_itself
)->teLength
);
920 #define TEObj_set_teLength NULL
922 static PyObject
*TEObj_get_txFont(TEObject
*self
, void *closure
)
924 return Py_BuildValue("h", (*self
->ob_itself
)->txFont
);
927 #define TEObj_set_txFont NULL
929 static PyObject
*TEObj_get_txFace(TEObject
*self
, void *closure
)
931 return Py_BuildValue("h", (*self
->ob_itself
)->txFace
);
934 #define TEObj_set_txFace NULL
936 static PyObject
*TEObj_get_txMode(TEObject
*self
, void *closure
)
938 return Py_BuildValue("h", (*self
->ob_itself
)->txMode
);
941 #define TEObj_set_txMode NULL
943 static PyObject
*TEObj_get_txSize(TEObject
*self
, void *closure
)
945 return Py_BuildValue("h", (*self
->ob_itself
)->txSize
);
948 #define TEObj_set_txSize NULL
950 static PyObject
*TEObj_get_nLines(TEObject
*self
, void *closure
)
952 return Py_BuildValue("h", (*self
->ob_itself
)->nLines
);
955 #define TEObj_set_nLines NULL
957 static PyGetSetDef TEObj_getsetlist
[] = {
958 {"destRect", (getter
)TEObj_get_destRect
, (setter
)TEObj_set_destRect
, "Destination rectangle"},
959 {"viewRect", (getter
)TEObj_get_viewRect
, (setter
)TEObj_set_viewRect
, "Viewing rectangle"},
960 {"selRect", (getter
)TEObj_get_selRect
, (setter
)TEObj_set_selRect
, "Selection rectangle"},
961 {"lineHeight", (getter
)TEObj_get_lineHeight
, (setter
)TEObj_set_lineHeight
, "Height of a line"},
962 {"fontAscent", (getter
)TEObj_get_fontAscent
, (setter
)TEObj_set_fontAscent
, "Ascent of a line"},
963 {"selPoint", (getter
)TEObj_get_selPoint
, (setter
)TEObj_set_selPoint
, "Selection Point"},
964 {"selStart", (getter
)TEObj_get_selStart
, (setter
)TEObj_set_selStart
, "Start of selection"},
965 {"selEnd", (getter
)TEObj_get_selEnd
, (setter
)TEObj_set_selEnd
, "End of selection"},
966 {"active", (getter
)TEObj_get_active
, (setter
)TEObj_set_active
, "TBD"},
967 {"just", (getter
)TEObj_get_just
, (setter
)TEObj_set_just
, "Justification"},
968 {"teLength", (getter
)TEObj_get_teLength
, (setter
)TEObj_set_teLength
, "TBD"},
969 {"txFont", (getter
)TEObj_get_txFont
, (setter
)TEObj_set_txFont
, "Current font"},
970 {"txFace", (getter
)TEObj_get_txFace
, (setter
)TEObj_set_txFace
, "Current font variant"},
971 {"txMode", (getter
)TEObj_get_txMode
, (setter
)TEObj_set_txMode
, "Current text-drawing mode"},
972 {"txSize", (getter
)TEObj_get_txSize
, (setter
)TEObj_set_txSize
, "Current font size"},
973 {"nLines", (getter
)TEObj_get_nLines
, (setter
)TEObj_set_nLines
, "TBD"},
974 {NULL
, NULL
, NULL
, NULL
},
978 #define TEObj_compare NULL
980 #define TEObj_repr NULL
982 #define TEObj_hash NULL
983 #define TEObj_tp_init 0
985 #define TEObj_tp_alloc PyType_GenericAlloc
987 static PyObject
*TEObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
991 char *kw
[] = {"itself", 0};
993 if (!PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, TEObj_Convert
, &itself
)) return NULL
;
994 if ((_self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
995 ((TEObject
*)_self
)->ob_itself
= itself
;
999 #define TEObj_tp_free PyObject_Del
1002 PyTypeObject TE_Type
= {
1003 PyObject_HEAD_INIT(NULL
)
1005 "_TE.TE", /*tp_name*/
1006 sizeof(TEObject
), /*tp_basicsize*/
1009 (destructor
) TEObj_dealloc
, /*tp_dealloc*/
1011 (getattrfunc
)0, /*tp_getattr*/
1012 (setattrfunc
)0, /*tp_setattr*/
1013 (cmpfunc
) TEObj_compare
, /*tp_compare*/
1014 (reprfunc
) TEObj_repr
, /*tp_repr*/
1015 (PyNumberMethods
*)0, /* tp_as_number */
1016 (PySequenceMethods
*)0, /* tp_as_sequence */
1017 (PyMappingMethods
*)0, /* tp_as_mapping */
1018 (hashfunc
) TEObj_hash
, /*tp_hash*/
1021 PyObject_GenericGetAttr
, /*tp_getattro*/
1022 PyObject_GenericSetAttr
, /*tp_setattro */
1024 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1028 0, /*tp_richcompare*/
1029 0, /*tp_weaklistoffset*/
1032 TEObj_methods
, /* tp_methods */
1034 TEObj_getsetlist
, /*tp_getset*/
1039 0, /*tp_dictoffset*/
1040 TEObj_tp_init
, /* tp_init */
1041 TEObj_tp_alloc
, /* tp_alloc */
1042 TEObj_tp_new
, /* tp_new */
1043 TEObj_tp_free
, /* tp_free */
1046 /* ----------------------- End object type TE ----------------------- */
1049 static PyObject
*TE_TEScrapHandle(PyObject
*_self
, PyObject
*_args
)
1051 PyObject
*_res
= NULL
;
1053 #ifndef TEScrapHandle
1054 PyMac_PRECHECK(TEScrapHandle
);
1056 if (!PyArg_ParseTuple(_args
, ""))
1058 _rv
= TEScrapHandle();
1059 _res
= Py_BuildValue("O&",
1064 static PyObject
*TE_TEGetScrapLength(PyObject
*_self
, PyObject
*_args
)
1066 PyObject
*_res
= NULL
;
1068 #ifndef TEGetScrapLength
1069 PyMac_PRECHECK(TEGetScrapLength
);
1071 if (!PyArg_ParseTuple(_args
, ""))
1073 _rv
= TEGetScrapLength();
1074 _res
= Py_BuildValue("l",
1079 static PyObject
*TE_TENew(PyObject
*_self
, PyObject
*_args
)
1081 PyObject
*_res
= NULL
;
1086 PyMac_PRECHECK(TENew
);
1088 if (!PyArg_ParseTuple(_args
, "O&O&",
1089 PyMac_GetRect
, &destRect
,
1090 PyMac_GetRect
, &viewRect
))
1092 _rv
= TENew(&destRect
,
1094 _res
= Py_BuildValue("O&",
1099 static PyObject
*TE_TETextBox(PyObject
*_self
, PyObject
*_args
)
1101 PyObject
*_res
= NULL
;
1108 PyMac_PRECHECK(TETextBox
);
1110 if (!PyArg_ParseTuple(_args
, "s#O&h",
1111 &text__in__
, &text__in_len__
,
1112 PyMac_GetRect
, &box
,
1115 text__len__
= text__in_len__
;
1116 TETextBox(text__in__
, text__len__
,
1124 static PyObject
*TE_TEStyleNew(PyObject
*_self
, PyObject
*_args
)
1126 PyObject
*_res
= NULL
;
1131 PyMac_PRECHECK(TEStyleNew
);
1133 if (!PyArg_ParseTuple(_args
, "O&O&",
1134 PyMac_GetRect
, &destRect
,
1135 PyMac_GetRect
, &viewRect
))
1137 _rv
= TEStyleNew(&destRect
,
1139 _res
= Py_BuildValue("O&",
1144 static PyObject
*TE_TESetScrapLength(PyObject
*_self
, PyObject
*_args
)
1146 PyObject
*_res
= NULL
;
1148 #ifndef TESetScrapLength
1149 PyMac_PRECHECK(TESetScrapLength
);
1151 if (!PyArg_ParseTuple(_args
, "l",
1154 TESetScrapLength(length
);
1160 static PyObject
*TE_TEFromScrap(PyObject
*_self
, PyObject
*_args
)
1162 PyObject
*_res
= NULL
;
1165 PyMac_PRECHECK(TEFromScrap
);
1167 if (!PyArg_ParseTuple(_args
, ""))
1169 _err
= TEFromScrap();
1170 if (_err
!= noErr
) return PyMac_Error(_err
);
1176 static PyObject
*TE_TEToScrap(PyObject
*_self
, PyObject
*_args
)
1178 PyObject
*_res
= NULL
;
1181 PyMac_PRECHECK(TEToScrap
);
1183 if (!PyArg_ParseTuple(_args
, ""))
1186 if (_err
!= noErr
) return PyMac_Error(_err
);
1192 static PyObject
*TE_TEGetScrapHandle(PyObject
*_self
, PyObject
*_args
)
1194 PyObject
*_res
= NULL
;
1196 #ifndef TEGetScrapHandle
1197 PyMac_PRECHECK(TEGetScrapHandle
);
1199 if (!PyArg_ParseTuple(_args
, ""))
1201 _rv
= TEGetScrapHandle();
1202 _res
= Py_BuildValue("O&",
1207 static PyObject
*TE_TESetScrapHandle(PyObject
*_self
, PyObject
*_args
)
1209 PyObject
*_res
= NULL
;
1211 #ifndef TESetScrapHandle
1212 PyMac_PRECHECK(TESetScrapHandle
);
1214 if (!PyArg_ParseTuple(_args
, "O&",
1215 ResObj_Convert
, &value
))
1217 TESetScrapHandle(value
);
1223 static PyObject
*TE_LMGetWordRedraw(PyObject
*_self
, PyObject
*_args
)
1225 PyObject
*_res
= NULL
;
1227 #ifndef LMGetWordRedraw
1228 PyMac_PRECHECK(LMGetWordRedraw
);
1230 if (!PyArg_ParseTuple(_args
, ""))
1232 _rv
= LMGetWordRedraw();
1233 _res
= Py_BuildValue("b",
1238 static PyObject
*TE_LMSetWordRedraw(PyObject
*_self
, PyObject
*_args
)
1240 PyObject
*_res
= NULL
;
1242 #ifndef LMSetWordRedraw
1243 PyMac_PRECHECK(LMSetWordRedraw
);
1245 if (!PyArg_ParseTuple(_args
, "b",
1248 LMSetWordRedraw(value
);
1254 static PyObject
*TE_as_TE(PyObject
*_self
, PyObject
*_args
)
1256 PyObject
*_res
= NULL
;
1260 PyMac_PRECHECK(as_TE
);
1262 if (!PyArg_ParseTuple(_args
, "O&",
1263 ResObj_Convert
, &h
))
1266 _res
= Py_BuildValue("O&",
1271 static PyMethodDef TE_methods
[] = {
1272 {"TEScrapHandle", (PyCFunction
)TE_TEScrapHandle
, 1,
1273 PyDoc_STR("() -> (Handle _rv)")},
1274 {"TEGetScrapLength", (PyCFunction
)TE_TEGetScrapLength
, 1,
1275 PyDoc_STR("() -> (long _rv)")},
1276 {"TENew", (PyCFunction
)TE_TENew
, 1,
1277 PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
1278 {"TETextBox", (PyCFunction
)TE_TETextBox
, 1,
1279 PyDoc_STR("(Buffer text, Rect box, short just) -> None")},
1280 {"TEStyleNew", (PyCFunction
)TE_TEStyleNew
, 1,
1281 PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
1282 {"TESetScrapLength", (PyCFunction
)TE_TESetScrapLength
, 1,
1283 PyDoc_STR("(long length) -> None")},
1284 {"TEFromScrap", (PyCFunction
)TE_TEFromScrap
, 1,
1285 PyDoc_STR("() -> None")},
1286 {"TEToScrap", (PyCFunction
)TE_TEToScrap
, 1,
1287 PyDoc_STR("() -> None")},
1288 {"TEGetScrapHandle", (PyCFunction
)TE_TEGetScrapHandle
, 1,
1289 PyDoc_STR("() -> (Handle _rv)")},
1290 {"TESetScrapHandle", (PyCFunction
)TE_TESetScrapHandle
, 1,
1291 PyDoc_STR("(Handle value) -> None")},
1292 {"LMGetWordRedraw", (PyCFunction
)TE_LMGetWordRedraw
, 1,
1293 PyDoc_STR("() -> (UInt8 _rv)")},
1294 {"LMSetWordRedraw", (PyCFunction
)TE_LMSetWordRedraw
, 1,
1295 PyDoc_STR("(UInt8 value) -> None")},
1296 {"as_TE", (PyCFunction
)TE_as_TE
, 1,
1297 PyDoc_STR("(Handle h) -> (TEHandle _rv)")},
1311 PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle
, TEObj_New
);
1312 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle
, TEObj_Convert
);
1315 m
= Py_InitModule("_TE", TE_methods
);
1316 d
= PyModule_GetDict(m
);
1317 TE_Error
= PyMac_GetOSErrException();
1318 if (TE_Error
== NULL
||
1319 PyDict_SetItemString(d
, "Error", TE_Error
) != 0)
1321 TE_Type
.ob_type
= &PyType_Type
;
1322 if (PyType_Ready(&TE_Type
) < 0) return;
1323 Py_INCREF(&TE_Type
);
1324 PyModule_AddObject(m
, "TE", (PyObject
*)&TE_Type
);
1325 /* Backward-compatible name */
1326 Py_INCREF(&TE_Type
);
1327 PyModule_AddObject(m
, "TEType", (PyObject
*)&TE_Type
);
1330 /* ========================= End module _TE ========================= */