Exceptions raised during renaming in rotating file handlers are now passed to handleE...
[python.git] / Mac / Modules / te / _TEmodule.c
blob047b87210465f98fcbb893a352727e882de5c5a7
2 /* =========================== Module _TE =========================== */
4 #include "Python.h"
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"); \
14 return NULL; \
15 }} while(0)
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
26 #endif
28 #define as_TE(h) ((TEHandle)h)
29 #define as_Resource(teh) ((Handle)teh)
32 ** Parse/generate TextStyle records
34 static PyObject *
35 TextStyle_New(TextStylePtr itself)
38 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
39 &itself->tsColor);
42 static int
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) )
48 return 0;
49 p_itself->tsFont = (short)font;
50 p_itself->tsFace = (Style)face;
51 p_itself->tsSize = (short)size;
52 return 1;
55 static PyObject *TE_Error;
57 /* ------------------------- Object type TE ------------------------- */
59 PyTypeObject TE_Type;
61 #define TEObj_Check(x) ((x)->ob_type == &TE_Type || PyObject_TypeCheck((x), &TE_Type))
63 typedef struct TEObject {
64 PyObject_HEAD
65 TEHandle ob_itself;
66 } TEObject;
68 PyObject *TEObj_New(TEHandle itself)
70 TEObject *it;
71 if (itself == NULL) {
72 PyErr_SetString(TE_Error,"Cannot create null TE");
73 return NULL;
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)
83 if (!TEObj_Check(v))
85 PyErr_SetString(PyExc_TypeError, "TE required");
86 return 0;
88 *p_itself = ((TEObject *)v)->ob_itself;
89 return 1;
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;
101 char *text__in__;
102 long text__len__;
103 int text__in_len__;
104 #ifndef TESetText
105 PyMac_PRECHECK(TESetText);
106 #endif
107 if (!PyArg_ParseTuple(_args, "s#",
108 &text__in__, &text__in_len__))
109 return NULL;
110 text__len__ = text__in_len__;
111 TESetText(text__in__, text__len__,
112 _self->ob_itself);
113 Py_INCREF(Py_None);
114 _res = Py_None;
115 return _res;
118 static PyObject *TEObj_TEGetText(TEObject *_self, PyObject *_args)
120 PyObject *_res = NULL;
121 CharsHandle _rv;
122 #ifndef TEGetText
123 PyMac_PRECHECK(TEGetText);
124 #endif
125 if (!PyArg_ParseTuple(_args, ""))
126 return NULL;
127 _rv = TEGetText(_self->ob_itself);
128 _res = Py_BuildValue("O&",
129 ResObj_New, _rv);
130 return _res;
133 static PyObject *TEObj_TEIdle(TEObject *_self, PyObject *_args)
135 PyObject *_res = NULL;
136 #ifndef TEIdle
137 PyMac_PRECHECK(TEIdle);
138 #endif
139 if (!PyArg_ParseTuple(_args, ""))
140 return NULL;
141 TEIdle(_self->ob_itself);
142 Py_INCREF(Py_None);
143 _res = Py_None;
144 return _res;
147 static PyObject *TEObj_TESetSelect(TEObject *_self, PyObject *_args)
149 PyObject *_res = NULL;
150 long selStart;
151 long selEnd;
152 #ifndef TESetSelect
153 PyMac_PRECHECK(TESetSelect);
154 #endif
155 if (!PyArg_ParseTuple(_args, "ll",
156 &selStart,
157 &selEnd))
158 return NULL;
159 TESetSelect(selStart,
160 selEnd,
161 _self->ob_itself);
162 Py_INCREF(Py_None);
163 _res = Py_None;
164 return _res;
167 static PyObject *TEObj_TEActivate(TEObject *_self, PyObject *_args)
169 PyObject *_res = NULL;
170 #ifndef TEActivate
171 PyMac_PRECHECK(TEActivate);
172 #endif
173 if (!PyArg_ParseTuple(_args, ""))
174 return NULL;
175 TEActivate(_self->ob_itself);
176 Py_INCREF(Py_None);
177 _res = Py_None;
178 return _res;
181 static PyObject *TEObj_TEDeactivate(TEObject *_self, PyObject *_args)
183 PyObject *_res = NULL;
184 #ifndef TEDeactivate
185 PyMac_PRECHECK(TEDeactivate);
186 #endif
187 if (!PyArg_ParseTuple(_args, ""))
188 return NULL;
189 TEDeactivate(_self->ob_itself);
190 Py_INCREF(Py_None);
191 _res = Py_None;
192 return _res;
195 static PyObject *TEObj_TEKey(TEObject *_self, PyObject *_args)
197 PyObject *_res = NULL;
198 CharParameter key;
199 #ifndef TEKey
200 PyMac_PRECHECK(TEKey);
201 #endif
202 if (!PyArg_ParseTuple(_args, "h",
203 &key))
204 return NULL;
205 TEKey(key,
206 _self->ob_itself);
207 Py_INCREF(Py_None);
208 _res = Py_None;
209 return _res;
212 static PyObject *TEObj_TECut(TEObject *_self, PyObject *_args)
214 PyObject *_res = NULL;
215 #ifndef TECut
216 PyMac_PRECHECK(TECut);
217 #endif
218 if (!PyArg_ParseTuple(_args, ""))
219 return NULL;
220 TECut(_self->ob_itself);
221 Py_INCREF(Py_None);
222 _res = Py_None;
223 return _res;
226 static PyObject *TEObj_TECopy(TEObject *_self, PyObject *_args)
228 PyObject *_res = NULL;
229 #ifndef TECopy
230 PyMac_PRECHECK(TECopy);
231 #endif
232 if (!PyArg_ParseTuple(_args, ""))
233 return NULL;
234 TECopy(_self->ob_itself);
235 Py_INCREF(Py_None);
236 _res = Py_None;
237 return _res;
240 static PyObject *TEObj_TEPaste(TEObject *_self, PyObject *_args)
242 PyObject *_res = NULL;
243 #ifndef TEPaste
244 PyMac_PRECHECK(TEPaste);
245 #endif
246 if (!PyArg_ParseTuple(_args, ""))
247 return NULL;
248 TEPaste(_self->ob_itself);
249 Py_INCREF(Py_None);
250 _res = Py_None;
251 return _res;
254 static PyObject *TEObj_TEDelete(TEObject *_self, PyObject *_args)
256 PyObject *_res = NULL;
257 #ifndef TEDelete
258 PyMac_PRECHECK(TEDelete);
259 #endif
260 if (!PyArg_ParseTuple(_args, ""))
261 return NULL;
262 TEDelete(_self->ob_itself);
263 Py_INCREF(Py_None);
264 _res = Py_None;
265 return _res;
268 static PyObject *TEObj_TEInsert(TEObject *_self, PyObject *_args)
270 PyObject *_res = NULL;
271 char *text__in__;
272 long text__len__;
273 int text__in_len__;
274 #ifndef TEInsert
275 PyMac_PRECHECK(TEInsert);
276 #endif
277 if (!PyArg_ParseTuple(_args, "s#",
278 &text__in__, &text__in_len__))
279 return NULL;
280 text__len__ = text__in_len__;
281 TEInsert(text__in__, text__len__,
282 _self->ob_itself);
283 Py_INCREF(Py_None);
284 _res = Py_None;
285 return _res;
288 static PyObject *TEObj_TESetAlignment(TEObject *_self, PyObject *_args)
290 PyObject *_res = NULL;
291 short just;
292 #ifndef TESetAlignment
293 PyMac_PRECHECK(TESetAlignment);
294 #endif
295 if (!PyArg_ParseTuple(_args, "h",
296 &just))
297 return NULL;
298 TESetAlignment(just,
299 _self->ob_itself);
300 Py_INCREF(Py_None);
301 _res = Py_None;
302 return _res;
305 static PyObject *TEObj_TEUpdate(TEObject *_self, PyObject *_args)
307 PyObject *_res = NULL;
308 Rect rUpdate;
309 #ifndef TEUpdate
310 PyMac_PRECHECK(TEUpdate);
311 #endif
312 if (!PyArg_ParseTuple(_args, "O&",
313 PyMac_GetRect, &rUpdate))
314 return NULL;
315 TEUpdate(&rUpdate,
316 _self->ob_itself);
317 Py_INCREF(Py_None);
318 _res = Py_None;
319 return _res;
322 static PyObject *TEObj_TEScroll(TEObject *_self, PyObject *_args)
324 PyObject *_res = NULL;
325 short dh;
326 short dv;
327 #ifndef TEScroll
328 PyMac_PRECHECK(TEScroll);
329 #endif
330 if (!PyArg_ParseTuple(_args, "hh",
331 &dh,
332 &dv))
333 return NULL;
334 TEScroll(dh,
336 _self->ob_itself);
337 Py_INCREF(Py_None);
338 _res = Py_None;
339 return _res;
342 static PyObject *TEObj_TESelView(TEObject *_self, PyObject *_args)
344 PyObject *_res = NULL;
345 #ifndef TESelView
346 PyMac_PRECHECK(TESelView);
347 #endif
348 if (!PyArg_ParseTuple(_args, ""))
349 return NULL;
350 TESelView(_self->ob_itself);
351 Py_INCREF(Py_None);
352 _res = Py_None;
353 return _res;
356 static PyObject *TEObj_TEPinScroll(TEObject *_self, PyObject *_args)
358 PyObject *_res = NULL;
359 short dh;
360 short dv;
361 #ifndef TEPinScroll
362 PyMac_PRECHECK(TEPinScroll);
363 #endif
364 if (!PyArg_ParseTuple(_args, "hh",
365 &dh,
366 &dv))
367 return NULL;
368 TEPinScroll(dh,
370 _self->ob_itself);
371 Py_INCREF(Py_None);
372 _res = Py_None;
373 return _res;
376 static PyObject *TEObj_TEAutoView(TEObject *_self, PyObject *_args)
378 PyObject *_res = NULL;
379 Boolean fAuto;
380 #ifndef TEAutoView
381 PyMac_PRECHECK(TEAutoView);
382 #endif
383 if (!PyArg_ParseTuple(_args, "b",
384 &fAuto))
385 return NULL;
386 TEAutoView(fAuto,
387 _self->ob_itself);
388 Py_INCREF(Py_None);
389 _res = Py_None;
390 return _res;
393 static PyObject *TEObj_TECalText(TEObject *_self, PyObject *_args)
395 PyObject *_res = NULL;
396 #ifndef TECalText
397 PyMac_PRECHECK(TECalText);
398 #endif
399 if (!PyArg_ParseTuple(_args, ""))
400 return NULL;
401 TECalText(_self->ob_itself);
402 Py_INCREF(Py_None);
403 _res = Py_None;
404 return _res;
407 static PyObject *TEObj_TEGetOffset(TEObject *_self, PyObject *_args)
409 PyObject *_res = NULL;
410 short _rv;
411 Point pt;
412 #ifndef TEGetOffset
413 PyMac_PRECHECK(TEGetOffset);
414 #endif
415 if (!PyArg_ParseTuple(_args, "O&",
416 PyMac_GetPoint, &pt))
417 return NULL;
418 _rv = TEGetOffset(pt,
419 _self->ob_itself);
420 _res = Py_BuildValue("h",
421 _rv);
422 return _res;
425 static PyObject *TEObj_TEGetPoint(TEObject *_self, PyObject *_args)
427 PyObject *_res = NULL;
428 Point _rv;
429 short offset;
430 #ifndef TEGetPoint
431 PyMac_PRECHECK(TEGetPoint);
432 #endif
433 if (!PyArg_ParseTuple(_args, "h",
434 &offset))
435 return NULL;
436 _rv = TEGetPoint(offset,
437 _self->ob_itself);
438 _res = Py_BuildValue("O&",
439 PyMac_BuildPoint, _rv);
440 return _res;
443 static PyObject *TEObj_TEClick(TEObject *_self, PyObject *_args)
445 PyObject *_res = NULL;
446 Point pt;
447 Boolean fExtend;
448 #ifndef TEClick
449 PyMac_PRECHECK(TEClick);
450 #endif
451 if (!PyArg_ParseTuple(_args, "O&b",
452 PyMac_GetPoint, &pt,
453 &fExtend))
454 return NULL;
455 TEClick(pt,
456 fExtend,
457 _self->ob_itself);
458 Py_INCREF(Py_None);
459 _res = Py_None;
460 return _res;
463 static PyObject *TEObj_TESetStyleHandle(TEObject *_self, PyObject *_args)
465 PyObject *_res = NULL;
466 TEStyleHandle theHandle;
467 #ifndef TESetStyleHandle
468 PyMac_PRECHECK(TESetStyleHandle);
469 #endif
470 if (!PyArg_ParseTuple(_args, "O&",
471 ResObj_Convert, &theHandle))
472 return NULL;
473 TESetStyleHandle(theHandle,
474 _self->ob_itself);
475 Py_INCREF(Py_None);
476 _res = Py_None;
477 return _res;
480 static PyObject *TEObj_TEGetStyleHandle(TEObject *_self, PyObject *_args)
482 PyObject *_res = NULL;
483 TEStyleHandle _rv;
484 #ifndef TEGetStyleHandle
485 PyMac_PRECHECK(TEGetStyleHandle);
486 #endif
487 if (!PyArg_ParseTuple(_args, ""))
488 return NULL;
489 _rv = TEGetStyleHandle(_self->ob_itself);
490 _res = Py_BuildValue("O&",
491 ResObj_New, _rv);
492 return _res;
495 static PyObject *TEObj_TEGetStyle(TEObject *_self, PyObject *_args)
497 PyObject *_res = NULL;
498 short offset;
499 TextStyle theStyle;
500 short lineHeight;
501 short fontAscent;
502 #ifndef TEGetStyle
503 PyMac_PRECHECK(TEGetStyle);
504 #endif
505 if (!PyArg_ParseTuple(_args, "h",
506 &offset))
507 return NULL;
508 TEGetStyle(offset,
509 &theStyle,
510 &lineHeight,
511 &fontAscent,
512 _self->ob_itself);
513 _res = Py_BuildValue("O&hh",
514 TextStyle_New, &theStyle,
515 lineHeight,
516 fontAscent);
517 return _res;
520 static PyObject *TEObj_TEStylePaste(TEObject *_self, PyObject *_args)
522 PyObject *_res = NULL;
523 #ifndef TEStylePaste
524 PyMac_PRECHECK(TEStylePaste);
525 #endif
526 if (!PyArg_ParseTuple(_args, ""))
527 return NULL;
528 TEStylePaste(_self->ob_itself);
529 Py_INCREF(Py_None);
530 _res = Py_None;
531 return _res;
534 static PyObject *TEObj_TESetStyle(TEObject *_self, PyObject *_args)
536 PyObject *_res = NULL;
537 short mode;
538 TextStyle newStyle;
539 Boolean fRedraw;
540 #ifndef TESetStyle
541 PyMac_PRECHECK(TESetStyle);
542 #endif
543 if (!PyArg_ParseTuple(_args, "hO&b",
544 &mode,
545 TextStyle_Convert, &newStyle,
546 &fRedraw))
547 return NULL;
548 TESetStyle(mode,
549 &newStyle,
550 fRedraw,
551 _self->ob_itself);
552 Py_INCREF(Py_None);
553 _res = Py_None;
554 return _res;
557 static PyObject *TEObj_TEReplaceStyle(TEObject *_self, PyObject *_args)
559 PyObject *_res = NULL;
560 short mode;
561 TextStyle oldStyle;
562 TextStyle newStyle;
563 Boolean fRedraw;
564 #ifndef TEReplaceStyle
565 PyMac_PRECHECK(TEReplaceStyle);
566 #endif
567 if (!PyArg_ParseTuple(_args, "hO&O&b",
568 &mode,
569 TextStyle_Convert, &oldStyle,
570 TextStyle_Convert, &newStyle,
571 &fRedraw))
572 return NULL;
573 TEReplaceStyle(mode,
574 &oldStyle,
575 &newStyle,
576 fRedraw,
577 _self->ob_itself);
578 Py_INCREF(Py_None);
579 _res = Py_None;
580 return _res;
583 static PyObject *TEObj_TEGetStyleScrapHandle(TEObject *_self, PyObject *_args)
585 PyObject *_res = NULL;
586 StScrpHandle _rv;
587 #ifndef TEGetStyleScrapHandle
588 PyMac_PRECHECK(TEGetStyleScrapHandle);
589 #endif
590 if (!PyArg_ParseTuple(_args, ""))
591 return NULL;
592 _rv = TEGetStyleScrapHandle(_self->ob_itself);
593 _res = Py_BuildValue("O&",
594 ResObj_New, _rv);
595 return _res;
598 static PyObject *TEObj_TEStyleInsert(TEObject *_self, PyObject *_args)
600 PyObject *_res = NULL;
601 char *text__in__;
602 long text__len__;
603 int text__in_len__;
604 StScrpHandle hST;
605 #ifndef TEStyleInsert
606 PyMac_PRECHECK(TEStyleInsert);
607 #endif
608 if (!PyArg_ParseTuple(_args, "s#O&",
609 &text__in__, &text__in_len__,
610 ResObj_Convert, &hST))
611 return NULL;
612 text__len__ = text__in_len__;
613 TEStyleInsert(text__in__, text__len__,
614 hST,
615 _self->ob_itself);
616 Py_INCREF(Py_None);
617 _res = Py_None;
618 return _res;
621 static PyObject *TEObj_TEGetHeight(TEObject *_self, PyObject *_args)
623 PyObject *_res = NULL;
624 long _rv;
625 long endLine;
626 long startLine;
627 #ifndef TEGetHeight
628 PyMac_PRECHECK(TEGetHeight);
629 #endif
630 if (!PyArg_ParseTuple(_args, "ll",
631 &endLine,
632 &startLine))
633 return NULL;
634 _rv = TEGetHeight(endLine,
635 startLine,
636 _self->ob_itself);
637 _res = Py_BuildValue("l",
638 _rv);
639 return _res;
642 static PyObject *TEObj_TEContinuousStyle(TEObject *_self, PyObject *_args)
644 PyObject *_res = NULL;
645 Boolean _rv;
646 short mode;
647 TextStyle aStyle;
648 #ifndef TEContinuousStyle
649 PyMac_PRECHECK(TEContinuousStyle);
650 #endif
651 if (!PyArg_ParseTuple(_args, "hO&",
652 &mode,
653 TextStyle_Convert, &aStyle))
654 return NULL;
655 _rv = TEContinuousStyle(&mode,
656 &aStyle,
657 _self->ob_itself);
658 _res = Py_BuildValue("bhO&",
659 _rv,
660 mode,
661 TextStyle_New, &aStyle);
662 return _res;
665 static PyObject *TEObj_TEUseStyleScrap(TEObject *_self, PyObject *_args)
667 PyObject *_res = NULL;
668 long rangeStart;
669 long rangeEnd;
670 StScrpHandle newStyles;
671 Boolean fRedraw;
672 #ifndef TEUseStyleScrap
673 PyMac_PRECHECK(TEUseStyleScrap);
674 #endif
675 if (!PyArg_ParseTuple(_args, "llO&b",
676 &rangeStart,
677 &rangeEnd,
678 ResObj_Convert, &newStyles,
679 &fRedraw))
680 return NULL;
681 TEUseStyleScrap(rangeStart,
682 rangeEnd,
683 newStyles,
684 fRedraw,
685 _self->ob_itself);
686 Py_INCREF(Py_None);
687 _res = Py_None;
688 return _res;
691 static PyObject *TEObj_TENumStyles(TEObject *_self, PyObject *_args)
693 PyObject *_res = NULL;
694 long _rv;
695 long rangeStart;
696 long rangeEnd;
697 #ifndef TENumStyles
698 PyMac_PRECHECK(TENumStyles);
699 #endif
700 if (!PyArg_ParseTuple(_args, "ll",
701 &rangeStart,
702 &rangeEnd))
703 return NULL;
704 _rv = TENumStyles(rangeStart,
705 rangeEnd,
706 _self->ob_itself);
707 _res = Py_BuildValue("l",
708 _rv);
709 return _res;
712 static PyObject *TEObj_TEFeatureFlag(TEObject *_self, PyObject *_args)
714 PyObject *_res = NULL;
715 short _rv;
716 short feature;
717 short action;
718 #ifndef TEFeatureFlag
719 PyMac_PRECHECK(TEFeatureFlag);
720 #endif
721 if (!PyArg_ParseTuple(_args, "hh",
722 &feature,
723 &action))
724 return NULL;
725 _rv = TEFeatureFlag(feature,
726 action,
727 _self->ob_itself);
728 _res = Py_BuildValue("h",
729 _rv);
730 return _res;
733 static PyObject *TEObj_TEGetHiliteRgn(TEObject *_self, PyObject *_args)
735 PyObject *_res = NULL;
736 OSErr _err;
737 RgnHandle region;
738 #ifndef TEGetHiliteRgn
739 PyMac_PRECHECK(TEGetHiliteRgn);
740 #endif
741 if (!PyArg_ParseTuple(_args, "O&",
742 ResObj_Convert, &region))
743 return NULL;
744 _err = TEGetHiliteRgn(region,
745 _self->ob_itself);
746 if (_err != noErr) return PyMac_Error(_err);
747 Py_INCREF(Py_None);
748 _res = Py_None;
749 return _res;
752 static PyObject *TEObj_as_Resource(TEObject *_self, PyObject *_args)
754 PyObject *_res = NULL;
755 Handle _rv;
756 #ifndef as_Resource
757 PyMac_PRECHECK(as_Resource);
758 #endif
759 if (!PyArg_ParseTuple(_args, ""))
760 return NULL;
761 _rv = as_Resource(_self->ob_itself);
762 _res = Py_BuildValue("O&",
763 ResObj_New, _rv);
764 return _res;
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)")},
842 {NULL, NULL, 0}
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)
989 PyObject *_self;
990 TEHandle itself;
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;
996 return _self;
999 #define TEObj_tp_free PyObject_Del
1002 PyTypeObject TE_Type = {
1003 PyObject_HEAD_INIT(NULL)
1004 0, /*ob_size*/
1005 "_TE.TE", /*tp_name*/
1006 sizeof(TEObject), /*tp_basicsize*/
1007 0, /*tp_itemsize*/
1008 /* methods */
1009 (destructor) TEObj_dealloc, /*tp_dealloc*/
1010 0, /*tp_print*/
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*/
1019 0, /*tp_call*/
1020 0, /*tp_str*/
1021 PyObject_GenericGetAttr, /*tp_getattro*/
1022 PyObject_GenericSetAttr, /*tp_setattro */
1023 0, /*tp_as_buffer*/
1024 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
1025 0, /*tp_doc*/
1026 0, /*tp_traverse*/
1027 0, /*tp_clear*/
1028 0, /*tp_richcompare*/
1029 0, /*tp_weaklistoffset*/
1030 0, /*tp_iter*/
1031 0, /*tp_iternext*/
1032 TEObj_methods, /* tp_methods */
1033 0, /*tp_members*/
1034 TEObj_getsetlist, /*tp_getset*/
1035 0, /*tp_base*/
1036 0, /*tp_dict*/
1037 0, /*tp_descr_get*/
1038 0, /*tp_descr_set*/
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;
1052 Handle _rv;
1053 #ifndef TEScrapHandle
1054 PyMac_PRECHECK(TEScrapHandle);
1055 #endif
1056 if (!PyArg_ParseTuple(_args, ""))
1057 return NULL;
1058 _rv = TEScrapHandle();
1059 _res = Py_BuildValue("O&",
1060 ResObj_New, _rv);
1061 return _res;
1064 static PyObject *TE_TEGetScrapLength(PyObject *_self, PyObject *_args)
1066 PyObject *_res = NULL;
1067 long _rv;
1068 #ifndef TEGetScrapLength
1069 PyMac_PRECHECK(TEGetScrapLength);
1070 #endif
1071 if (!PyArg_ParseTuple(_args, ""))
1072 return NULL;
1073 _rv = TEGetScrapLength();
1074 _res = Py_BuildValue("l",
1075 _rv);
1076 return _res;
1079 static PyObject *TE_TENew(PyObject *_self, PyObject *_args)
1081 PyObject *_res = NULL;
1082 TEHandle _rv;
1083 Rect destRect;
1084 Rect viewRect;
1085 #ifndef TENew
1086 PyMac_PRECHECK(TENew);
1087 #endif
1088 if (!PyArg_ParseTuple(_args, "O&O&",
1089 PyMac_GetRect, &destRect,
1090 PyMac_GetRect, &viewRect))
1091 return NULL;
1092 _rv = TENew(&destRect,
1093 &viewRect);
1094 _res = Py_BuildValue("O&",
1095 TEObj_New, _rv);
1096 return _res;
1099 static PyObject *TE_TETextBox(PyObject *_self, PyObject *_args)
1101 PyObject *_res = NULL;
1102 char *text__in__;
1103 long text__len__;
1104 int text__in_len__;
1105 Rect box;
1106 short just;
1107 #ifndef TETextBox
1108 PyMac_PRECHECK(TETextBox);
1109 #endif
1110 if (!PyArg_ParseTuple(_args, "s#O&h",
1111 &text__in__, &text__in_len__,
1112 PyMac_GetRect, &box,
1113 &just))
1114 return NULL;
1115 text__len__ = text__in_len__;
1116 TETextBox(text__in__, text__len__,
1117 &box,
1118 just);
1119 Py_INCREF(Py_None);
1120 _res = Py_None;
1121 return _res;
1124 static PyObject *TE_TEStyleNew(PyObject *_self, PyObject *_args)
1126 PyObject *_res = NULL;
1127 TEHandle _rv;
1128 Rect destRect;
1129 Rect viewRect;
1130 #ifndef TEStyleNew
1131 PyMac_PRECHECK(TEStyleNew);
1132 #endif
1133 if (!PyArg_ParseTuple(_args, "O&O&",
1134 PyMac_GetRect, &destRect,
1135 PyMac_GetRect, &viewRect))
1136 return NULL;
1137 _rv = TEStyleNew(&destRect,
1138 &viewRect);
1139 _res = Py_BuildValue("O&",
1140 TEObj_New, _rv);
1141 return _res;
1144 static PyObject *TE_TESetScrapLength(PyObject *_self, PyObject *_args)
1146 PyObject *_res = NULL;
1147 long length;
1148 #ifndef TESetScrapLength
1149 PyMac_PRECHECK(TESetScrapLength);
1150 #endif
1151 if (!PyArg_ParseTuple(_args, "l",
1152 &length))
1153 return NULL;
1154 TESetScrapLength(length);
1155 Py_INCREF(Py_None);
1156 _res = Py_None;
1157 return _res;
1160 static PyObject *TE_TEFromScrap(PyObject *_self, PyObject *_args)
1162 PyObject *_res = NULL;
1163 OSErr _err;
1164 #ifndef TEFromScrap
1165 PyMac_PRECHECK(TEFromScrap);
1166 #endif
1167 if (!PyArg_ParseTuple(_args, ""))
1168 return NULL;
1169 _err = TEFromScrap();
1170 if (_err != noErr) return PyMac_Error(_err);
1171 Py_INCREF(Py_None);
1172 _res = Py_None;
1173 return _res;
1176 static PyObject *TE_TEToScrap(PyObject *_self, PyObject *_args)
1178 PyObject *_res = NULL;
1179 OSErr _err;
1180 #ifndef TEToScrap
1181 PyMac_PRECHECK(TEToScrap);
1182 #endif
1183 if (!PyArg_ParseTuple(_args, ""))
1184 return NULL;
1185 _err = TEToScrap();
1186 if (_err != noErr) return PyMac_Error(_err);
1187 Py_INCREF(Py_None);
1188 _res = Py_None;
1189 return _res;
1192 static PyObject *TE_TEGetScrapHandle(PyObject *_self, PyObject *_args)
1194 PyObject *_res = NULL;
1195 Handle _rv;
1196 #ifndef TEGetScrapHandle
1197 PyMac_PRECHECK(TEGetScrapHandle);
1198 #endif
1199 if (!PyArg_ParseTuple(_args, ""))
1200 return NULL;
1201 _rv = TEGetScrapHandle();
1202 _res = Py_BuildValue("O&",
1203 ResObj_New, _rv);
1204 return _res;
1207 static PyObject *TE_TESetScrapHandle(PyObject *_self, PyObject *_args)
1209 PyObject *_res = NULL;
1210 Handle value;
1211 #ifndef TESetScrapHandle
1212 PyMac_PRECHECK(TESetScrapHandle);
1213 #endif
1214 if (!PyArg_ParseTuple(_args, "O&",
1215 ResObj_Convert, &value))
1216 return NULL;
1217 TESetScrapHandle(value);
1218 Py_INCREF(Py_None);
1219 _res = Py_None;
1220 return _res;
1223 static PyObject *TE_LMGetWordRedraw(PyObject *_self, PyObject *_args)
1225 PyObject *_res = NULL;
1226 UInt8 _rv;
1227 #ifndef LMGetWordRedraw
1228 PyMac_PRECHECK(LMGetWordRedraw);
1229 #endif
1230 if (!PyArg_ParseTuple(_args, ""))
1231 return NULL;
1232 _rv = LMGetWordRedraw();
1233 _res = Py_BuildValue("b",
1234 _rv);
1235 return _res;
1238 static PyObject *TE_LMSetWordRedraw(PyObject *_self, PyObject *_args)
1240 PyObject *_res = NULL;
1241 UInt8 value;
1242 #ifndef LMSetWordRedraw
1243 PyMac_PRECHECK(LMSetWordRedraw);
1244 #endif
1245 if (!PyArg_ParseTuple(_args, "b",
1246 &value))
1247 return NULL;
1248 LMSetWordRedraw(value);
1249 Py_INCREF(Py_None);
1250 _res = Py_None;
1251 return _res;
1254 static PyObject *TE_as_TE(PyObject *_self, PyObject *_args)
1256 PyObject *_res = NULL;
1257 TEHandle _rv;
1258 Handle h;
1259 #ifndef as_TE
1260 PyMac_PRECHECK(as_TE);
1261 #endif
1262 if (!PyArg_ParseTuple(_args, "O&",
1263 ResObj_Convert, &h))
1264 return NULL;
1265 _rv = as_TE(h);
1266 _res = Py_BuildValue("O&",
1267 TEObj_New, _rv);
1268 return _res;
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)")},
1298 {NULL, NULL, 0}
1304 void init_TE(void)
1306 PyObject *m;
1307 PyObject *d;
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)
1320 return;
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 ========================= */