Bump version to 1.0.
[python/dscho.git] / Mac / Modules / te / TEmodule.c
blob789b157a44a1640f5c00008150a342604c93a64e
2 /* =========================== Module TE ============================ */
4 #include "Python.h"
8 #include "macglue.h"
9 #include "pymactoolbox.h"
11 #include <TextEdit.h>
13 #define as_TE(h) ((TEHandle)h)
14 #define as_Resource(teh) ((Handle)teh)
17 ** Parse/generate TextStyle records
19 static PyObject *
20 TextStyle_New(itself)
21 TextStylePtr itself;
24 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
25 &itself->tsColor);
28 static int
29 TextStyle_Convert(v, p_itself)
30 PyObject *v;
31 TextStylePtr p_itself;
33 long font, face, size;
35 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
36 return 0;
37 p_itself->tsFont = (short)font;
38 p_itself->tsFace = (Style)face;
39 p_itself->tsSize = (short)size;
40 return 1;
43 static PyObject *TE_Error;
45 /* ------------------------- Object type TE ------------------------- */
47 PyTypeObject TE_Type;
49 #define TEObj_Check(x) ((x)->ob_type == &TE_Type)
51 typedef struct TEObject {
52 PyObject_HEAD
53 TEHandle ob_itself;
54 } TEObject;
56 PyObject *TEObj_New(itself)
57 TEHandle itself;
59 TEObject *it;
60 if (itself == NULL) {
61 PyErr_SetString(TE_Error,"Cannot create null TE");
62 return NULL;
64 it = PyObject_NEW(TEObject, &TE_Type);
65 if (it == NULL) return NULL;
66 it->ob_itself = itself;
67 return (PyObject *)it;
69 TEObj_Convert(v, p_itself)
70 PyObject *v;
71 TEHandle *p_itself;
73 if (!TEObj_Check(v))
75 PyErr_SetString(PyExc_TypeError, "TE required");
76 return 0;
78 *p_itself = ((TEObject *)v)->ob_itself;
79 return 1;
82 static void TEObj_dealloc(self)
83 TEObject *self;
85 TEDispose(self->ob_itself);
86 PyMem_DEL(self);
89 static PyObject *TEObj_TESetText(_self, _args)
90 TEObject *_self;
91 PyObject *_args;
93 PyObject *_res = NULL;
94 char *text__in__;
95 long text__len__;
96 int text__in_len__;
97 if (!PyArg_ParseTuple(_args, "s#",
98 &text__in__, &text__in_len__))
99 return NULL;
100 text__len__ = text__in_len__;
101 TESetText(text__in__, text__len__,
102 _self->ob_itself);
103 Py_INCREF(Py_None);
104 _res = Py_None;
105 text__error__: ;
106 return _res;
109 static PyObject *TEObj_TEGetText(_self, _args)
110 TEObject *_self;
111 PyObject *_args;
113 PyObject *_res = NULL;
114 CharsHandle _rv;
115 if (!PyArg_ParseTuple(_args, ""))
116 return NULL;
117 _rv = TEGetText(_self->ob_itself);
118 _res = Py_BuildValue("O&",
119 ResObj_New, _rv);
120 return _res;
123 static PyObject *TEObj_TEIdle(_self, _args)
124 TEObject *_self;
125 PyObject *_args;
127 PyObject *_res = NULL;
128 if (!PyArg_ParseTuple(_args, ""))
129 return NULL;
130 TEIdle(_self->ob_itself);
131 Py_INCREF(Py_None);
132 _res = Py_None;
133 return _res;
136 static PyObject *TEObj_TESetSelect(_self, _args)
137 TEObject *_self;
138 PyObject *_args;
140 PyObject *_res = NULL;
141 long selStart;
142 long selEnd;
143 if (!PyArg_ParseTuple(_args, "ll",
144 &selStart,
145 &selEnd))
146 return NULL;
147 TESetSelect(selStart,
148 selEnd,
149 _self->ob_itself);
150 Py_INCREF(Py_None);
151 _res = Py_None;
152 return _res;
155 static PyObject *TEObj_TEActivate(_self, _args)
156 TEObject *_self;
157 PyObject *_args;
159 PyObject *_res = NULL;
160 if (!PyArg_ParseTuple(_args, ""))
161 return NULL;
162 TEActivate(_self->ob_itself);
163 Py_INCREF(Py_None);
164 _res = Py_None;
165 return _res;
168 static PyObject *TEObj_TEDeactivate(_self, _args)
169 TEObject *_self;
170 PyObject *_args;
172 PyObject *_res = NULL;
173 if (!PyArg_ParseTuple(_args, ""))
174 return NULL;
175 TEDeactivate(_self->ob_itself);
176 Py_INCREF(Py_None);
177 _res = Py_None;
178 return _res;
181 static PyObject *TEObj_TEKey(_self, _args)
182 TEObject *_self;
183 PyObject *_args;
185 PyObject *_res = NULL;
186 CharParameter key;
187 if (!PyArg_ParseTuple(_args, "h",
188 &key))
189 return NULL;
190 TEKey(key,
191 _self->ob_itself);
192 Py_INCREF(Py_None);
193 _res = Py_None;
194 return _res;
197 static PyObject *TEObj_TECut(_self, _args)
198 TEObject *_self;
199 PyObject *_args;
201 PyObject *_res = NULL;
202 if (!PyArg_ParseTuple(_args, ""))
203 return NULL;
204 TECut(_self->ob_itself);
205 Py_INCREF(Py_None);
206 _res = Py_None;
207 return _res;
210 static PyObject *TEObj_TECopy(_self, _args)
211 TEObject *_self;
212 PyObject *_args;
214 PyObject *_res = NULL;
215 if (!PyArg_ParseTuple(_args, ""))
216 return NULL;
217 TECopy(_self->ob_itself);
218 Py_INCREF(Py_None);
219 _res = Py_None;
220 return _res;
223 static PyObject *TEObj_TEPaste(_self, _args)
224 TEObject *_self;
225 PyObject *_args;
227 PyObject *_res = NULL;
228 if (!PyArg_ParseTuple(_args, ""))
229 return NULL;
230 TEPaste(_self->ob_itself);
231 Py_INCREF(Py_None);
232 _res = Py_None;
233 return _res;
236 static PyObject *TEObj_TEDelete(_self, _args)
237 TEObject *_self;
238 PyObject *_args;
240 PyObject *_res = NULL;
241 if (!PyArg_ParseTuple(_args, ""))
242 return NULL;
243 TEDelete(_self->ob_itself);
244 Py_INCREF(Py_None);
245 _res = Py_None;
246 return _res;
249 static PyObject *TEObj_TEInsert(_self, _args)
250 TEObject *_self;
251 PyObject *_args;
253 PyObject *_res = NULL;
254 char *text__in__;
255 long text__len__;
256 int text__in_len__;
257 if (!PyArg_ParseTuple(_args, "s#",
258 &text__in__, &text__in_len__))
259 return NULL;
260 text__len__ = text__in_len__;
261 TEInsert(text__in__, text__len__,
262 _self->ob_itself);
263 Py_INCREF(Py_None);
264 _res = Py_None;
265 text__error__: ;
266 return _res;
269 static PyObject *TEObj_TESetAlignment(_self, _args)
270 TEObject *_self;
271 PyObject *_args;
273 PyObject *_res = NULL;
274 short just;
275 if (!PyArg_ParseTuple(_args, "h",
276 &just))
277 return NULL;
278 TESetAlignment(just,
279 _self->ob_itself);
280 Py_INCREF(Py_None);
281 _res = Py_None;
282 return _res;
285 static PyObject *TEObj_TEUpdate(_self, _args)
286 TEObject *_self;
287 PyObject *_args;
289 PyObject *_res = NULL;
290 Rect rUpdate;
291 if (!PyArg_ParseTuple(_args, "O&",
292 PyMac_GetRect, &rUpdate))
293 return NULL;
294 TEUpdate(&rUpdate,
295 _self->ob_itself);
296 Py_INCREF(Py_None);
297 _res = Py_None;
298 return _res;
301 static PyObject *TEObj_TEScroll(_self, _args)
302 TEObject *_self;
303 PyObject *_args;
305 PyObject *_res = NULL;
306 short dh;
307 short dv;
308 if (!PyArg_ParseTuple(_args, "hh",
309 &dh,
310 &dv))
311 return NULL;
312 TEScroll(dh,
314 _self->ob_itself);
315 Py_INCREF(Py_None);
316 _res = Py_None;
317 return _res;
320 static PyObject *TEObj_TESelView(_self, _args)
321 TEObject *_self;
322 PyObject *_args;
324 PyObject *_res = NULL;
325 if (!PyArg_ParseTuple(_args, ""))
326 return NULL;
327 TESelView(_self->ob_itself);
328 Py_INCREF(Py_None);
329 _res = Py_None;
330 return _res;
333 static PyObject *TEObj_TEPinScroll(_self, _args)
334 TEObject *_self;
335 PyObject *_args;
337 PyObject *_res = NULL;
338 short dh;
339 short dv;
340 if (!PyArg_ParseTuple(_args, "hh",
341 &dh,
342 &dv))
343 return NULL;
344 TEPinScroll(dh,
346 _self->ob_itself);
347 Py_INCREF(Py_None);
348 _res = Py_None;
349 return _res;
352 static PyObject *TEObj_TEAutoView(_self, _args)
353 TEObject *_self;
354 PyObject *_args;
356 PyObject *_res = NULL;
357 Boolean fAuto;
358 if (!PyArg_ParseTuple(_args, "b",
359 &fAuto))
360 return NULL;
361 TEAutoView(fAuto,
362 _self->ob_itself);
363 Py_INCREF(Py_None);
364 _res = Py_None;
365 return _res;
368 static PyObject *TEObj_TECalText(_self, _args)
369 TEObject *_self;
370 PyObject *_args;
372 PyObject *_res = NULL;
373 if (!PyArg_ParseTuple(_args, ""))
374 return NULL;
375 TECalText(_self->ob_itself);
376 Py_INCREF(Py_None);
377 _res = Py_None;
378 return _res;
381 static PyObject *TEObj_TEGetOffset(_self, _args)
382 TEObject *_self;
383 PyObject *_args;
385 PyObject *_res = NULL;
386 short _rv;
387 Point pt;
388 if (!PyArg_ParseTuple(_args, "O&",
389 PyMac_GetPoint, &pt))
390 return NULL;
391 _rv = TEGetOffset(pt,
392 _self->ob_itself);
393 _res = Py_BuildValue("h",
394 _rv);
395 return _res;
398 static PyObject *TEObj_TEGetPoint(_self, _args)
399 TEObject *_self;
400 PyObject *_args;
402 PyObject *_res = NULL;
403 Point _rv;
404 short offset;
405 if (!PyArg_ParseTuple(_args, "h",
406 &offset))
407 return NULL;
408 _rv = TEGetPoint(offset,
409 _self->ob_itself);
410 _res = Py_BuildValue("O&",
411 PyMac_BuildPoint, _rv);
412 return _res;
415 static PyObject *TEObj_TEClick(_self, _args)
416 TEObject *_self;
417 PyObject *_args;
419 PyObject *_res = NULL;
420 Point pt;
421 Boolean fExtend;
422 if (!PyArg_ParseTuple(_args, "O&b",
423 PyMac_GetPoint, &pt,
424 &fExtend))
425 return NULL;
426 TEClick(pt,
427 fExtend,
428 _self->ob_itself);
429 Py_INCREF(Py_None);
430 _res = Py_None;
431 return _res;
434 static PyObject *TEObj_TESetStyleHandle(_self, _args)
435 TEObject *_self;
436 PyObject *_args;
438 PyObject *_res = NULL;
439 TEStyleHandle theHandle;
440 if (!PyArg_ParseTuple(_args, "O&",
441 ResObj_Convert, &theHandle))
442 return NULL;
443 TESetStyleHandle(theHandle,
444 _self->ob_itself);
445 Py_INCREF(Py_None);
446 _res = Py_None;
447 return _res;
450 static PyObject *TEObj_TEGetStyleHandle(_self, _args)
451 TEObject *_self;
452 PyObject *_args;
454 PyObject *_res = NULL;
455 TEStyleHandle _rv;
456 if (!PyArg_ParseTuple(_args, ""))
457 return NULL;
458 _rv = TEGetStyleHandle(_self->ob_itself);
459 _res = Py_BuildValue("O&",
460 ResObj_New, _rv);
461 return _res;
464 static PyObject *TEObj_TEGetStyle(_self, _args)
465 TEObject *_self;
466 PyObject *_args;
468 PyObject *_res = NULL;
469 short offset;
470 TextStyle theStyle;
471 short lineHeight;
472 short fontAscent;
473 if (!PyArg_ParseTuple(_args, "h",
474 &offset))
475 return NULL;
476 TEGetStyle(offset,
477 &theStyle,
478 &lineHeight,
479 &fontAscent,
480 _self->ob_itself);
481 _res = Py_BuildValue("O&hh",
482 TextStyle_New, &theStyle,
483 lineHeight,
484 fontAscent);
485 return _res;
488 static PyObject *TEObj_TEStylePaste(_self, _args)
489 TEObject *_self;
490 PyObject *_args;
492 PyObject *_res = NULL;
493 if (!PyArg_ParseTuple(_args, ""))
494 return NULL;
495 TEStylePaste(_self->ob_itself);
496 Py_INCREF(Py_None);
497 _res = Py_None;
498 return _res;
501 static PyObject *TEObj_TESetStyle(_self, _args)
502 TEObject *_self;
503 PyObject *_args;
505 PyObject *_res = NULL;
506 short mode;
507 TextStyle newStyle;
508 Boolean fRedraw;
509 if (!PyArg_ParseTuple(_args, "hO&b",
510 &mode,
511 TextStyle_Convert, &newStyle,
512 &fRedraw))
513 return NULL;
514 TESetStyle(mode,
515 &newStyle,
516 fRedraw,
517 _self->ob_itself);
518 Py_INCREF(Py_None);
519 _res = Py_None;
520 return _res;
523 static PyObject *TEObj_TEReplaceStyle(_self, _args)
524 TEObject *_self;
525 PyObject *_args;
527 PyObject *_res = NULL;
528 short mode;
529 TextStyle oldStyle;
530 TextStyle newStyle;
531 Boolean fRedraw;
532 if (!PyArg_ParseTuple(_args, "hO&O&b",
533 &mode,
534 TextStyle_Convert, &oldStyle,
535 TextStyle_Convert, &newStyle,
536 &fRedraw))
537 return NULL;
538 TEReplaceStyle(mode,
539 &oldStyle,
540 &newStyle,
541 fRedraw,
542 _self->ob_itself);
543 Py_INCREF(Py_None);
544 _res = Py_None;
545 return _res;
548 static PyObject *TEObj_TEGetStyleScrapHandle(_self, _args)
549 TEObject *_self;
550 PyObject *_args;
552 PyObject *_res = NULL;
553 StScrpHandle _rv;
554 if (!PyArg_ParseTuple(_args, ""))
555 return NULL;
556 _rv = TEGetStyleScrapHandle(_self->ob_itself);
557 _res = Py_BuildValue("O&",
558 ResObj_New, _rv);
559 return _res;
562 static PyObject *TEObj_TEStyleInsert(_self, _args)
563 TEObject *_self;
564 PyObject *_args;
566 PyObject *_res = NULL;
567 char *text__in__;
568 long text__len__;
569 int text__in_len__;
570 StScrpHandle hST;
571 if (!PyArg_ParseTuple(_args, "s#O&",
572 &text__in__, &text__in_len__,
573 ResObj_Convert, &hST))
574 return NULL;
575 text__len__ = text__in_len__;
576 TEStyleInsert(text__in__, text__len__,
577 hST,
578 _self->ob_itself);
579 Py_INCREF(Py_None);
580 _res = Py_None;
581 text__error__: ;
582 return _res;
585 static PyObject *TEObj_TEGetHeight(_self, _args)
586 TEObject *_self;
587 PyObject *_args;
589 PyObject *_res = NULL;
590 long _rv;
591 long endLine;
592 long startLine;
593 if (!PyArg_ParseTuple(_args, "ll",
594 &endLine,
595 &startLine))
596 return NULL;
597 _rv = TEGetHeight(endLine,
598 startLine,
599 _self->ob_itself);
600 _res = Py_BuildValue("l",
601 _rv);
602 return _res;
605 static PyObject *TEObj_TEContinuousStyle(_self, _args)
606 TEObject *_self;
607 PyObject *_args;
609 PyObject *_res = NULL;
610 Boolean _rv;
611 short mode;
612 TextStyle aStyle;
613 if (!PyArg_ParseTuple(_args, "hO&",
614 &mode,
615 TextStyle_Convert, &aStyle))
616 return NULL;
617 _rv = TEContinuousStyle(&mode,
618 &aStyle,
619 _self->ob_itself);
620 _res = Py_BuildValue("bhO&",
621 _rv,
622 mode,
623 TextStyle_New, &aStyle);
624 return _res;
627 static PyObject *TEObj_TEUseStyleScrap(_self, _args)
628 TEObject *_self;
629 PyObject *_args;
631 PyObject *_res = NULL;
632 long rangeStart;
633 long rangeEnd;
634 StScrpHandle newStyles;
635 Boolean fRedraw;
636 if (!PyArg_ParseTuple(_args, "llO&b",
637 &rangeStart,
638 &rangeEnd,
639 ResObj_Convert, &newStyles,
640 &fRedraw))
641 return NULL;
642 TEUseStyleScrap(rangeStart,
643 rangeEnd,
644 newStyles,
645 fRedraw,
646 _self->ob_itself);
647 Py_INCREF(Py_None);
648 _res = Py_None;
649 return _res;
652 static PyObject *TEObj_TENumStyles(_self, _args)
653 TEObject *_self;
654 PyObject *_args;
656 PyObject *_res = NULL;
657 long _rv;
658 long rangeStart;
659 long rangeEnd;
660 if (!PyArg_ParseTuple(_args, "ll",
661 &rangeStart,
662 &rangeEnd))
663 return NULL;
664 _rv = TENumStyles(rangeStart,
665 rangeEnd,
666 _self->ob_itself);
667 _res = Py_BuildValue("l",
668 _rv);
669 return _res;
672 static PyObject *TEObj_TEFeatureFlag(_self, _args)
673 TEObject *_self;
674 PyObject *_args;
676 PyObject *_res = NULL;
677 short _rv;
678 short feature;
679 short action;
680 if (!PyArg_ParseTuple(_args, "hh",
681 &feature,
682 &action))
683 return NULL;
684 _rv = TEFeatureFlag(feature,
685 action,
686 _self->ob_itself);
687 _res = Py_BuildValue("h",
688 _rv);
689 return _res;
692 static PyObject *TEObj_TEGetHiliteRgn(_self, _args)
693 TEObject *_self;
694 PyObject *_args;
696 PyObject *_res = NULL;
697 OSErr _err;
698 RgnHandle region;
699 if (!PyArg_ParseTuple(_args, "O&",
700 ResObj_Convert, &region))
701 return NULL;
702 _err = TEGetHiliteRgn(region,
703 _self->ob_itself);
704 if (_err != noErr) return PyMac_Error(_err);
705 Py_INCREF(Py_None);
706 _res = Py_None;
707 return _res;
710 static PyObject *TEObj_as_Resource(_self, _args)
711 TEObject *_self;
712 PyObject *_args;
714 PyObject *_res = NULL;
715 Handle _rv;
716 if (!PyArg_ParseTuple(_args, ""))
717 return NULL;
718 _rv = as_Resource(_self->ob_itself);
719 _res = Py_BuildValue("O&",
720 ResObj_New, _rv);
721 return _res;
724 static PyMethodDef TEObj_methods[] = {
725 {"TESetText", (PyCFunction)TEObj_TESetText, 1,
726 "(Buffer text) -> None"},
727 {"TEGetText", (PyCFunction)TEObj_TEGetText, 1,
728 "() -> (CharsHandle _rv)"},
729 {"TEIdle", (PyCFunction)TEObj_TEIdle, 1,
730 "() -> None"},
731 {"TESetSelect", (PyCFunction)TEObj_TESetSelect, 1,
732 "(long selStart, long selEnd) -> None"},
733 {"TEActivate", (PyCFunction)TEObj_TEActivate, 1,
734 "() -> None"},
735 {"TEDeactivate", (PyCFunction)TEObj_TEDeactivate, 1,
736 "() -> None"},
737 {"TEKey", (PyCFunction)TEObj_TEKey, 1,
738 "(CharParameter key) -> None"},
739 {"TECut", (PyCFunction)TEObj_TECut, 1,
740 "() -> None"},
741 {"TECopy", (PyCFunction)TEObj_TECopy, 1,
742 "() -> None"},
743 {"TEPaste", (PyCFunction)TEObj_TEPaste, 1,
744 "() -> None"},
745 {"TEDelete", (PyCFunction)TEObj_TEDelete, 1,
746 "() -> None"},
747 {"TEInsert", (PyCFunction)TEObj_TEInsert, 1,
748 "(Buffer text) -> None"},
749 {"TESetAlignment", (PyCFunction)TEObj_TESetAlignment, 1,
750 "(short just) -> None"},
751 {"TEUpdate", (PyCFunction)TEObj_TEUpdate, 1,
752 "(Rect rUpdate) -> None"},
753 {"TEScroll", (PyCFunction)TEObj_TEScroll, 1,
754 "(short dh, short dv) -> None"},
755 {"TESelView", (PyCFunction)TEObj_TESelView, 1,
756 "() -> None"},
757 {"TEPinScroll", (PyCFunction)TEObj_TEPinScroll, 1,
758 "(short dh, short dv) -> None"},
759 {"TEAutoView", (PyCFunction)TEObj_TEAutoView, 1,
760 "(Boolean fAuto) -> None"},
761 {"TECalText", (PyCFunction)TEObj_TECalText, 1,
762 "() -> None"},
763 {"TEGetOffset", (PyCFunction)TEObj_TEGetOffset, 1,
764 "(Point pt) -> (short _rv)"},
765 {"TEGetPoint", (PyCFunction)TEObj_TEGetPoint, 1,
766 "(short offset) -> (Point _rv)"},
767 {"TEClick", (PyCFunction)TEObj_TEClick, 1,
768 "(Point pt, Boolean fExtend) -> None"},
769 {"TESetStyleHandle", (PyCFunction)TEObj_TESetStyleHandle, 1,
770 "(TEStyleHandle theHandle) -> None"},
771 {"TEGetStyleHandle", (PyCFunction)TEObj_TEGetStyleHandle, 1,
772 "() -> (TEStyleHandle _rv)"},
773 {"TEGetStyle", (PyCFunction)TEObj_TEGetStyle, 1,
774 "(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)"},
775 {"TEStylePaste", (PyCFunction)TEObj_TEStylePaste, 1,
776 "() -> None"},
777 {"TESetStyle", (PyCFunction)TEObj_TESetStyle, 1,
778 "(short mode, TextStyle newStyle, Boolean fRedraw) -> None"},
779 {"TEReplaceStyle", (PyCFunction)TEObj_TEReplaceStyle, 1,
780 "(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None"},
781 {"TEGetStyleScrapHandle", (PyCFunction)TEObj_TEGetStyleScrapHandle, 1,
782 "() -> (StScrpHandle _rv)"},
783 {"TEStyleInsert", (PyCFunction)TEObj_TEStyleInsert, 1,
784 "(Buffer text, StScrpHandle hST) -> None"},
785 {"TEGetHeight", (PyCFunction)TEObj_TEGetHeight, 1,
786 "(long endLine, long startLine) -> (long _rv)"},
787 {"TEContinuousStyle", (PyCFunction)TEObj_TEContinuousStyle, 1,
788 "(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)"},
789 {"TEUseStyleScrap", (PyCFunction)TEObj_TEUseStyleScrap, 1,
790 "(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None"},
791 {"TENumStyles", (PyCFunction)TEObj_TENumStyles, 1,
792 "(long rangeStart, long rangeEnd) -> (long _rv)"},
793 {"TEFeatureFlag", (PyCFunction)TEObj_TEFeatureFlag, 1,
794 "(short feature, short action) -> (short _rv)"},
795 {"TEGetHiliteRgn", (PyCFunction)TEObj_TEGetHiliteRgn, 1,
796 "(RgnHandle region) -> None"},
797 {"as_Resource", (PyCFunction)TEObj_as_Resource, 1,
798 "() -> (Handle _rv)"},
799 {NULL, NULL, 0}
802 PyMethodChain TEObj_chain = { TEObj_methods, NULL };
804 static PyObject *TEObj_getattr(self, name)
805 TEObject *self;
806 char *name;
809 if( strcmp(name, "destRect") == 0 )
810 return Py_BuildValue("O&", PyMac_BuildRect,
811 &(*self->ob_itself)->destRect);
812 if( strcmp(name, "viewRect") == 0 )
813 return Py_BuildValue("O&", PyMac_BuildRect,
814 &(*self->ob_itself)->viewRect);
815 if( strcmp(name, "selRect") == 0 )
816 return Py_BuildValue("O&", PyMac_BuildRect,
817 &(*self->ob_itself)->selRect);
818 if( strcmp(name, "lineHeight") == 0 )
819 return Py_BuildValue("h", (*self->ob_itself)->lineHeight);
820 if( strcmp(name, "fontAscent") == 0 )
821 return Py_BuildValue("h", (*self->ob_itself)->fontAscent);
822 if( strcmp(name, "selPoint") == 0 )
823 return Py_BuildValue("O&", PyMac_BuildPoint,
824 (*self->ob_itself)->selPoint);
825 if( strcmp(name, "selStart") == 0 )
826 return Py_BuildValue("h", (*self->ob_itself)->selStart);
827 if( strcmp(name, "selEnd") == 0 )
828 return Py_BuildValue("h", (*self->ob_itself)->selEnd);
829 if( strcmp(name, "active") == 0 )
830 return Py_BuildValue("h", (*self->ob_itself)->active);
831 if( strcmp(name, "just") == 0 )
832 return Py_BuildValue("h", (*self->ob_itself)->just);
833 if( strcmp(name, "teLength") == 0 )
834 return Py_BuildValue("h", (*self->ob_itself)->teLength);
835 if( strcmp(name, "txFont") == 0 )
836 return Py_BuildValue("h", (*self->ob_itself)->txFont);
837 if( strcmp(name, "txFace") == 0 )
838 return Py_BuildValue("h", (*self->ob_itself)->txFace);
839 if( strcmp(name, "txMode") == 0 )
840 return Py_BuildValue("h", (*self->ob_itself)->txMode);
841 if( strcmp(name, "txSize") == 0 )
842 return Py_BuildValue("h", (*self->ob_itself)->txSize);
843 if( strcmp(name, "nLines") == 0 )
844 return Py_BuildValue("h", (*self->ob_itself)->nLines);
846 return Py_FindMethodInChain(&TEObj_chain, (PyObject *)self, name);
849 #define TEObj_setattr NULL
851 #define TEObj_compare NULL
853 #define TEObj_repr NULL
855 #define TEObj_hash NULL
857 PyTypeObject TE_Type = {
858 PyObject_HEAD_INIT(&PyType_Type)
859 0, /*ob_size*/
860 "TE", /*tp_name*/
861 sizeof(TEObject), /*tp_basicsize*/
862 0, /*tp_itemsize*/
863 /* methods */
864 (destructor) TEObj_dealloc, /*tp_dealloc*/
865 0, /*tp_print*/
866 (getattrfunc) TEObj_getattr, /*tp_getattr*/
867 (setattrfunc) TEObj_setattr, /*tp_setattr*/
868 (cmpfunc) TEObj_compare, /*tp_compare*/
869 (reprfunc) TEObj_repr, /*tp_repr*/
870 (PyNumberMethods *)0, /* tp_as_number */
871 (PySequenceMethods *)0, /* tp_as_sequence */
872 (PyMappingMethods *)0, /* tp_as_mapping */
873 (hashfunc) TEObj_hash, /*tp_hash*/
876 /* ----------------------- End object type TE ----------------------- */
879 static PyObject *TE_TEScrapHandle(_self, _args)
880 PyObject *_self;
881 PyObject *_args;
883 PyObject *_res = NULL;
884 Handle _rv;
885 if (!PyArg_ParseTuple(_args, ""))
886 return NULL;
887 _rv = TEScrapHandle();
888 _res = Py_BuildValue("O&",
889 ResObj_New, _rv);
890 return _res;
893 static PyObject *TE_TEGetScrapLength(_self, _args)
894 PyObject *_self;
895 PyObject *_args;
897 PyObject *_res = NULL;
898 long _rv;
899 if (!PyArg_ParseTuple(_args, ""))
900 return NULL;
901 _rv = TEGetScrapLength();
902 _res = Py_BuildValue("l",
903 _rv);
904 return _res;
907 static PyObject *TE_TENew(_self, _args)
908 PyObject *_self;
909 PyObject *_args;
911 PyObject *_res = NULL;
912 TEHandle _rv;
913 Rect destRect;
914 Rect viewRect;
915 if (!PyArg_ParseTuple(_args, "O&O&",
916 PyMac_GetRect, &destRect,
917 PyMac_GetRect, &viewRect))
918 return NULL;
919 _rv = TENew(&destRect,
920 &viewRect);
921 _res = Py_BuildValue("O&",
922 TEObj_New, _rv);
923 return _res;
926 static PyObject *TE_TETextBox(_self, _args)
927 PyObject *_self;
928 PyObject *_args;
930 PyObject *_res = NULL;
931 char *text__in__;
932 long text__len__;
933 int text__in_len__;
934 Rect box;
935 short just;
936 if (!PyArg_ParseTuple(_args, "s#O&h",
937 &text__in__, &text__in_len__,
938 PyMac_GetRect, &box,
939 &just))
940 return NULL;
941 text__len__ = text__in_len__;
942 TETextBox(text__in__, text__len__,
943 &box,
944 just);
945 Py_INCREF(Py_None);
946 _res = Py_None;
947 text__error__: ;
948 return _res;
951 static PyObject *TE_TEStyleNew(_self, _args)
952 PyObject *_self;
953 PyObject *_args;
955 PyObject *_res = NULL;
956 TEHandle _rv;
957 Rect destRect;
958 Rect viewRect;
959 if (!PyArg_ParseTuple(_args, "O&O&",
960 PyMac_GetRect, &destRect,
961 PyMac_GetRect, &viewRect))
962 return NULL;
963 _rv = TEStyleNew(&destRect,
964 &viewRect);
965 _res = Py_BuildValue("O&",
966 TEObj_New, _rv);
967 return _res;
970 static PyObject *TE_TESetScrapLength(_self, _args)
971 PyObject *_self;
972 PyObject *_args;
974 PyObject *_res = NULL;
975 long length;
976 if (!PyArg_ParseTuple(_args, "l",
977 &length))
978 return NULL;
979 TESetScrapLength(length);
980 Py_INCREF(Py_None);
981 _res = Py_None;
982 return _res;
985 static PyObject *TE_TEFromScrap(_self, _args)
986 PyObject *_self;
987 PyObject *_args;
989 PyObject *_res = NULL;
990 OSErr _err;
991 if (!PyArg_ParseTuple(_args, ""))
992 return NULL;
993 _err = TEFromScrap();
994 if (_err != noErr) return PyMac_Error(_err);
995 Py_INCREF(Py_None);
996 _res = Py_None;
997 return _res;
1000 static PyObject *TE_TEToScrap(_self, _args)
1001 PyObject *_self;
1002 PyObject *_args;
1004 PyObject *_res = NULL;
1005 OSErr _err;
1006 if (!PyArg_ParseTuple(_args, ""))
1007 return NULL;
1008 _err = TEToScrap();
1009 if (_err != noErr) return PyMac_Error(_err);
1010 Py_INCREF(Py_None);
1011 _res = Py_None;
1012 return _res;
1015 static PyObject *TE_as_TE(_self, _args)
1016 PyObject *_self;
1017 PyObject *_args;
1019 PyObject *_res = NULL;
1020 TEHandle _rv;
1021 Handle h;
1022 if (!PyArg_ParseTuple(_args, "O&",
1023 ResObj_Convert, &h))
1024 return NULL;
1025 _rv = as_TE(h);
1026 _res = Py_BuildValue("O&",
1027 TEObj_New, _rv);
1028 return _res;
1031 static PyMethodDef TE_methods[] = {
1032 {"TEScrapHandle", (PyCFunction)TE_TEScrapHandle, 1,
1033 "() -> (Handle _rv)"},
1034 {"TEGetScrapLength", (PyCFunction)TE_TEGetScrapLength, 1,
1035 "() -> (long _rv)"},
1036 {"TENew", (PyCFunction)TE_TENew, 1,
1037 "(Rect destRect, Rect viewRect) -> (TEHandle _rv)"},
1038 {"TETextBox", (PyCFunction)TE_TETextBox, 1,
1039 "(Buffer text, Rect box, short just) -> None"},
1040 {"TEStyleNew", (PyCFunction)TE_TEStyleNew, 1,
1041 "(Rect destRect, Rect viewRect) -> (TEHandle _rv)"},
1042 {"TESetScrapLength", (PyCFunction)TE_TESetScrapLength, 1,
1043 "(long length) -> None"},
1044 {"TEFromScrap", (PyCFunction)TE_TEFromScrap, 1,
1045 "() -> None"},
1046 {"TEToScrap", (PyCFunction)TE_TEToScrap, 1,
1047 "() -> None"},
1048 {"as_TE", (PyCFunction)TE_as_TE, 1,
1049 "(Handle h) -> (TEHandle _rv)"},
1050 {NULL, NULL, 0}
1056 void initTE()
1058 PyObject *m;
1059 PyObject *d;
1064 m = Py_InitModule("TE", TE_methods);
1065 d = PyModule_GetDict(m);
1066 TE_Error = PyMac_GetOSErrException();
1067 if (TE_Error == NULL ||
1068 PyDict_SetItemString(d, "Error", TE_Error) != 0)
1069 Py_FatalError("can't initialize TE.Error");
1070 TE_Type.ob_type = &PyType_Type;
1071 Py_INCREF(&TE_Type);
1072 if (PyDict_SetItemString(d, "TEType", (PyObject *)&TE_Type) != 0)
1073 Py_FatalError("can't initialize TEType");
1076 /* ========================= End module TE ========================== */