2 /* ========================== Module Mlte =========================== */
9 #include "pymactoolbox.h"
11 /* Macro to test whether a weak-loaded CFM function exists */
12 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13 PyErr_SetString(PyExc_NotImplementedError, \
14 "Not available in this shared library/OS version"); \
19 #ifdef WITHOUT_FRAMEWORKS
20 #include <MacTextEditor.h>
25 /* For now we declare them forward here. They'll go to mactoolbox later */
26 staticforward PyObject
*TXNObj_New(TXNObject
);
27 staticforward
int TXNObj_Convert(PyObject
*, TXNObject
*);
28 staticforward PyObject
*TXNFontMenuObj_New(TXNFontMenuObject
);
29 staticforward
int TXNFontMenuObj_Convert(PyObject
*, TXNFontMenuObject
*);
32 #ifdef NOTYET_USE_TOOLBOX_OBJECT_GLUE
33 //extern PyObject *_CFTypeRefObj_New(CFTypeRef);
34 //extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
36 //#define CFTypeRefObj_New _CFTypeRefObj_New
37 //#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
41 ** Parse an optional fsspec
44 OptFSSpecPtr_Convert(PyObject
*v
, FSSpec
**p_itself
)
53 return PyMac_GetFSSpec(v
, *p_itself
);
57 ** Parse an optional rect
60 OptRectPtr_Convert(PyObject
*v
, Rect
**p_itself
)
70 return PyMac_GetRect(v
, *p_itself
);
74 ** Parse an optional GWorld
77 OptGWorldObj_Convert(PyObject
*v
, GWorldPtr
*p_itself
)
84 return GWorldObj_Convert(v
, p_itself
);
88 static PyObject
*Mlte_Error
;
90 /* --------------------- Object type TXNObject ---------------------- */
92 PyTypeObject TXNObject_Type
;
94 #define TXNObj_Check(x) ((x)->ob_type == &TXNObject_Type)
96 typedef struct TXNObjectObject
{
101 PyObject
*TXNObj_New(TXNObject itself
)
104 if (itself
== NULL
) return PyMac_Error(resNotFound
);
105 it
= PyObject_NEW(TXNObjectObject
, &TXNObject_Type
);
106 if (it
== NULL
) return NULL
;
107 it
->ob_itself
= itself
;
108 return (PyObject
*)it
;
110 TXNObj_Convert(PyObject
*v
, TXNObject
*p_itself
)
112 if (!TXNObj_Check(v
))
114 PyErr_SetString(PyExc_TypeError
, "TXNObject required");
117 *p_itself
= ((TXNObjectObject
*)v
)->ob_itself
;
121 static void TXNObj_dealloc(TXNObjectObject
*self
)
123 /* Cleanup of self->ob_itself goes here */
127 static PyObject
*TXNObj_TXNDeleteObject(TXNObjectObject
*_self
, PyObject
*_args
)
129 PyObject
*_res
= NULL
;
130 PyMac_PRECHECK(TXNDeleteObject
);
131 if (!PyArg_ParseTuple(_args
, ""))
133 TXNDeleteObject(_self
->ob_itself
);
139 static PyObject
*TXNObj_TXNResizeFrame(TXNObjectObject
*_self
, PyObject
*_args
)
141 PyObject
*_res
= NULL
;
144 TXNFrameID iTXNFrameID
;
145 PyMac_PRECHECK(TXNResizeFrame
);
146 if (!PyArg_ParseTuple(_args
, "lll",
151 TXNResizeFrame(_self
->ob_itself
,
160 static PyObject
*TXNObj_TXNSetFrameBounds(TXNObjectObject
*_self
, PyObject
*_args
)
162 PyObject
*_res
= NULL
;
167 TXNFrameID iTXNFrameID
;
168 PyMac_PRECHECK(TXNSetFrameBounds
);
169 if (!PyArg_ParseTuple(_args
, "lllll",
176 TXNSetFrameBounds(_self
->ob_itself
,
187 static PyObject
*TXNObj_TXNKeyDown(TXNObjectObject
*_self
, PyObject
*_args
)
189 PyObject
*_res
= NULL
;
191 PyMac_PRECHECK(TXNKeyDown
);
192 if (!PyArg_ParseTuple(_args
, "O&",
193 PyMac_GetEventRecord
, &iEvent
))
195 TXNKeyDown(_self
->ob_itself
,
202 static PyObject
*TXNObj_TXNAdjustCursor(TXNObjectObject
*_self
, PyObject
*_args
)
204 PyObject
*_res
= NULL
;
205 RgnHandle ioCursorRgn
;
206 PyMac_PRECHECK(TXNAdjustCursor
);
207 if (!PyArg_ParseTuple(_args
, "O&",
208 OptResObj_Convert
, &ioCursorRgn
))
210 TXNAdjustCursor(_self
->ob_itself
,
217 static PyObject
*TXNObj_TXNClick(TXNObjectObject
*_self
, PyObject
*_args
)
219 PyObject
*_res
= NULL
;
221 PyMac_PRECHECK(TXNClick
);
222 if (!PyArg_ParseTuple(_args
, "O&",
223 PyMac_GetEventRecord
, &iEvent
))
225 TXNClick(_self
->ob_itself
,
232 static PyObject
*TXNObj_TXNTSMCheck(TXNObjectObject
*_self
, PyObject
*_args
)
234 PyObject
*_res
= NULL
;
237 PyMac_PRECHECK(TXNTSMCheck
);
238 if (!PyArg_ParseTuple(_args
, "O&",
239 PyMac_GetEventRecord
, &iEvent
))
241 _rv
= TXNTSMCheck(_self
->ob_itself
,
243 _res
= Py_BuildValue("b",
248 static PyObject
*TXNObj_TXNSelectAll(TXNObjectObject
*_self
, PyObject
*_args
)
250 PyObject
*_res
= NULL
;
251 PyMac_PRECHECK(TXNSelectAll
);
252 if (!PyArg_ParseTuple(_args
, ""))
254 TXNSelectAll(_self
->ob_itself
);
260 static PyObject
*TXNObj_TXNFocus(TXNObjectObject
*_self
, PyObject
*_args
)
262 PyObject
*_res
= NULL
;
263 Boolean iBecomingFocused
;
264 PyMac_PRECHECK(TXNFocus
);
265 if (!PyArg_ParseTuple(_args
, "b",
268 TXNFocus(_self
->ob_itself
,
275 static PyObject
*TXNObj_TXNUpdate(TXNObjectObject
*_self
, PyObject
*_args
)
277 PyObject
*_res
= NULL
;
278 PyMac_PRECHECK(TXNUpdate
);
279 if (!PyArg_ParseTuple(_args
, ""))
281 TXNUpdate(_self
->ob_itself
);
287 static PyObject
*TXNObj_TXNDraw(TXNObjectObject
*_self
, PyObject
*_args
)
289 PyObject
*_res
= NULL
;
291 PyMac_PRECHECK(TXNDraw
);
292 if (!PyArg_ParseTuple(_args
, "O&",
293 OptGWorldObj_Convert
, &iDrawPort
))
295 TXNDraw(_self
->ob_itself
,
302 static PyObject
*TXNObj_TXNForceUpdate(TXNObjectObject
*_self
, PyObject
*_args
)
304 PyObject
*_res
= NULL
;
305 PyMac_PRECHECK(TXNForceUpdate
);
306 if (!PyArg_ParseTuple(_args
, ""))
308 TXNForceUpdate(_self
->ob_itself
);
314 static PyObject
*TXNObj_TXNGetSleepTicks(TXNObjectObject
*_self
, PyObject
*_args
)
316 PyObject
*_res
= NULL
;
318 PyMac_PRECHECK(TXNGetSleepTicks
);
319 if (!PyArg_ParseTuple(_args
, ""))
321 _rv
= TXNGetSleepTicks(_self
->ob_itself
);
322 _res
= Py_BuildValue("l",
327 static PyObject
*TXNObj_TXNIdle(TXNObjectObject
*_self
, PyObject
*_args
)
329 PyObject
*_res
= NULL
;
330 PyMac_PRECHECK(TXNIdle
);
331 if (!PyArg_ParseTuple(_args
, ""))
333 TXNIdle(_self
->ob_itself
);
339 static PyObject
*TXNObj_TXNGrowWindow(TXNObjectObject
*_self
, PyObject
*_args
)
341 PyObject
*_res
= NULL
;
343 PyMac_PRECHECK(TXNGrowWindow
);
344 if (!PyArg_ParseTuple(_args
, "O&",
345 PyMac_GetEventRecord
, &iEvent
))
347 TXNGrowWindow(_self
->ob_itself
,
354 static PyObject
*TXNObj_TXNZoomWindow(TXNObjectObject
*_self
, PyObject
*_args
)
356 PyObject
*_res
= NULL
;
358 PyMac_PRECHECK(TXNZoomWindow
);
359 if (!PyArg_ParseTuple(_args
, "h",
362 TXNZoomWindow(_self
->ob_itself
,
369 static PyObject
*TXNObj_TXNCanUndo(TXNObjectObject
*_self
, PyObject
*_args
)
371 PyObject
*_res
= NULL
;
373 TXNActionKey oTXNActionKey
;
374 PyMac_PRECHECK(TXNCanUndo
);
375 if (!PyArg_ParseTuple(_args
, ""))
377 _rv
= TXNCanUndo(_self
->ob_itself
,
379 _res
= Py_BuildValue("bl",
385 static PyObject
*TXNObj_TXNUndo(TXNObjectObject
*_self
, PyObject
*_args
)
387 PyObject
*_res
= NULL
;
388 PyMac_PRECHECK(TXNUndo
);
389 if (!PyArg_ParseTuple(_args
, ""))
391 TXNUndo(_self
->ob_itself
);
397 static PyObject
*TXNObj_TXNCanRedo(TXNObjectObject
*_self
, PyObject
*_args
)
399 PyObject
*_res
= NULL
;
401 TXNActionKey oTXNActionKey
;
402 PyMac_PRECHECK(TXNCanRedo
);
403 if (!PyArg_ParseTuple(_args
, ""))
405 _rv
= TXNCanRedo(_self
->ob_itself
,
407 _res
= Py_BuildValue("bl",
413 static PyObject
*TXNObj_TXNRedo(TXNObjectObject
*_self
, PyObject
*_args
)
415 PyObject
*_res
= NULL
;
416 PyMac_PRECHECK(TXNRedo
);
417 if (!PyArg_ParseTuple(_args
, ""))
419 TXNRedo(_self
->ob_itself
);
425 static PyObject
*TXNObj_TXNCut(TXNObjectObject
*_self
, PyObject
*_args
)
427 PyObject
*_res
= NULL
;
429 PyMac_PRECHECK(TXNCut
);
430 if (!PyArg_ParseTuple(_args
, ""))
432 _err
= TXNCut(_self
->ob_itself
);
433 if (_err
!= noErr
) return PyMac_Error(_err
);
439 static PyObject
*TXNObj_TXNCopy(TXNObjectObject
*_self
, PyObject
*_args
)
441 PyObject
*_res
= NULL
;
443 PyMac_PRECHECK(TXNCopy
);
444 if (!PyArg_ParseTuple(_args
, ""))
446 _err
= TXNCopy(_self
->ob_itself
);
447 if (_err
!= noErr
) return PyMac_Error(_err
);
453 static PyObject
*TXNObj_TXNPaste(TXNObjectObject
*_self
, PyObject
*_args
)
455 PyObject
*_res
= NULL
;
457 PyMac_PRECHECK(TXNPaste
);
458 if (!PyArg_ParseTuple(_args
, ""))
460 _err
= TXNPaste(_self
->ob_itself
);
461 if (_err
!= noErr
) return PyMac_Error(_err
);
467 static PyObject
*TXNObj_TXNClear(TXNObjectObject
*_self
, PyObject
*_args
)
469 PyObject
*_res
= NULL
;
471 PyMac_PRECHECK(TXNClear
);
472 if (!PyArg_ParseTuple(_args
, ""))
474 _err
= TXNClear(_self
->ob_itself
);
475 if (_err
!= noErr
) return PyMac_Error(_err
);
481 static PyObject
*TXNObj_TXNGetSelection(TXNObjectObject
*_self
, PyObject
*_args
)
483 PyObject
*_res
= NULL
;
484 TXNOffset oStartOffset
;
485 TXNOffset oEndOffset
;
486 PyMac_PRECHECK(TXNGetSelection
);
487 if (!PyArg_ParseTuple(_args
, ""))
489 TXNGetSelection(_self
->ob_itself
,
492 _res
= Py_BuildValue("ll",
498 static PyObject
*TXNObj_TXNShowSelection(TXNObjectObject
*_self
, PyObject
*_args
)
500 PyObject
*_res
= NULL
;
502 PyMac_PRECHECK(TXNShowSelection
);
503 if (!PyArg_ParseTuple(_args
, "b",
506 TXNShowSelection(_self
->ob_itself
,
513 static PyObject
*TXNObj_TXNIsSelectionEmpty(TXNObjectObject
*_self
, PyObject
*_args
)
515 PyObject
*_res
= NULL
;
517 PyMac_PRECHECK(TXNIsSelectionEmpty
);
518 if (!PyArg_ParseTuple(_args
, ""))
520 _rv
= TXNIsSelectionEmpty(_self
->ob_itself
);
521 _res
= Py_BuildValue("b",
526 static PyObject
*TXNObj_TXNSetSelection(TXNObjectObject
*_self
, PyObject
*_args
)
528 PyObject
*_res
= NULL
;
530 TXNOffset iStartOffset
;
531 TXNOffset iEndOffset
;
532 PyMac_PRECHECK(TXNSetSelection
);
533 if (!PyArg_ParseTuple(_args
, "ll",
537 _err
= TXNSetSelection(_self
->ob_itself
,
540 if (_err
!= noErr
) return PyMac_Error(_err
);
546 static PyObject
*TXNObj_TXNCountRunsInRange(TXNObjectObject
*_self
, PyObject
*_args
)
548 PyObject
*_res
= NULL
;
553 PyMac_PRECHECK(TXNCountRunsInRange
);
554 if (!PyArg_ParseTuple(_args
, "ll",
558 _err
= TXNCountRunsInRange(_self
->ob_itself
,
562 if (_err
!= noErr
) return PyMac_Error(_err
);
563 _res
= Py_BuildValue("l",
568 static PyObject
*TXNObj_TXNDataSize(TXNObjectObject
*_self
, PyObject
*_args
)
570 PyObject
*_res
= NULL
;
572 PyMac_PRECHECK(TXNDataSize
);
573 if (!PyArg_ParseTuple(_args
, ""))
575 _rv
= TXNDataSize(_self
->ob_itself
);
576 _res
= Py_BuildValue("l",
581 static PyObject
*TXNObj_TXNGetData(TXNObjectObject
*_self
, PyObject
*_args
)
583 PyObject
*_res
= NULL
;
585 TXNOffset iStartOffset
;
586 TXNOffset iEndOffset
;
588 PyMac_PRECHECK(TXNGetData
);
589 if (!PyArg_ParseTuple(_args
, "ll",
593 _err
= TXNGetData(_self
->ob_itself
,
597 if (_err
!= noErr
) return PyMac_Error(_err
);
598 _res
= Py_BuildValue("O&",
599 ResObj_New
, oDataHandle
);
603 static PyObject
*TXNObj_TXNGetDataEncoded(TXNObjectObject
*_self
, PyObject
*_args
)
605 PyObject
*_res
= NULL
;
607 TXNOffset iStartOffset
;
608 TXNOffset iEndOffset
;
610 TXNDataType iEncoding
;
611 PyMac_PRECHECK(TXNGetDataEncoded
);
612 if (!PyArg_ParseTuple(_args
, "llO&",
615 PyMac_GetOSType
, &iEncoding
))
617 _err
= TXNGetDataEncoded(_self
->ob_itself
,
622 if (_err
!= noErr
) return PyMac_Error(_err
);
623 _res
= Py_BuildValue("O&",
624 ResObj_New
, oDataHandle
);
628 static PyObject
*TXNObj_TXNSetDataFromFile(TXNObjectObject
*_self
, PyObject
*_args
)
630 PyObject
*_res
= NULL
;
634 ByteCount iFileLength
;
635 TXNOffset iStartOffset
;
636 TXNOffset iEndOffset
;
637 PyMac_PRECHECK(TXNSetDataFromFile
);
638 if (!PyArg_ParseTuple(_args
, "hO&lll",
640 PyMac_GetOSType
, &iFileType
,
645 _err
= TXNSetDataFromFile(_self
->ob_itself
,
651 if (_err
!= noErr
) return PyMac_Error(_err
);
657 static PyObject
*TXNObj_TXNSetData(TXNObjectObject
*_self
, PyObject
*_args
)
659 PyObject
*_res
= NULL
;
661 TXNDataType iDataType
;
662 void * *iDataPtr__in__
;
663 ByteCount iDataPtr__len__
;
664 int iDataPtr__in_len__
;
665 TXNOffset iStartOffset
;
666 TXNOffset iEndOffset
;
667 PyMac_PRECHECK(TXNSetData
);
668 if (!PyArg_ParseTuple(_args
, "O&s#ll",
669 PyMac_GetOSType
, &iDataType
,
670 &iDataPtr__in__
, &iDataPtr__in_len__
,
674 iDataPtr__len__
= iDataPtr__in_len__
;
675 _err
= TXNSetData(_self
->ob_itself
,
677 iDataPtr__in__
, iDataPtr__len__
,
680 if (_err
!= noErr
) return PyMac_Error(_err
);
687 static PyObject
*TXNObj_TXNGetChangeCount(TXNObjectObject
*_self
, PyObject
*_args
)
689 PyObject
*_res
= NULL
;
691 PyMac_PRECHECK(TXNGetChangeCount
);
692 if (!PyArg_ParseTuple(_args
, ""))
694 _rv
= TXNGetChangeCount(_self
->ob_itself
);
695 _res
= Py_BuildValue("l",
700 static PyObject
*TXNObj_TXNSave(TXNObjectObject
*_self
, PyObject
*_args
)
702 PyObject
*_res
= NULL
;
706 TXNPermanentTextEncodingType iPermanentEncoding
;
707 FSSpec iFileSpecification
;
708 SInt16 iDataReference
;
709 SInt16 iResourceReference
;
710 PyMac_PRECHECK(TXNSave
);
711 if (!PyArg_ParseTuple(_args
, "O&O&lO&hh",
712 PyMac_GetOSType
, &iType
,
713 PyMac_GetOSType
, &iResType
,
715 PyMac_GetFSSpec
, &iFileSpecification
,
717 &iResourceReference
))
719 _err
= TXNSave(_self
->ob_itself
,
726 if (_err
!= noErr
) return PyMac_Error(_err
);
732 static PyObject
*TXNObj_TXNRevert(TXNObjectObject
*_self
, PyObject
*_args
)
734 PyObject
*_res
= NULL
;
736 PyMac_PRECHECK(TXNRevert
);
737 if (!PyArg_ParseTuple(_args
, ""))
739 _err
= TXNRevert(_self
->ob_itself
);
740 if (_err
!= noErr
) return PyMac_Error(_err
);
746 static PyObject
*TXNObj_TXNPageSetup(TXNObjectObject
*_self
, PyObject
*_args
)
748 PyObject
*_res
= NULL
;
750 PyMac_PRECHECK(TXNPageSetup
);
751 if (!PyArg_ParseTuple(_args
, ""))
753 _err
= TXNPageSetup(_self
->ob_itself
);
754 if (_err
!= noErr
) return PyMac_Error(_err
);
760 static PyObject
*TXNObj_TXNPrint(TXNObjectObject
*_self
, PyObject
*_args
)
762 PyObject
*_res
= NULL
;
764 PyMac_PRECHECK(TXNPrint
);
765 if (!PyArg_ParseTuple(_args
, ""))
767 _err
= TXNPrint(_self
->ob_itself
);
768 if (_err
!= noErr
) return PyMac_Error(_err
);
774 static PyObject
*TXNObj_TXNGetViewRect(TXNObjectObject
*_self
, PyObject
*_args
)
776 PyObject
*_res
= NULL
;
778 PyMac_PRECHECK(TXNGetViewRect
);
779 if (!PyArg_ParseTuple(_args
, ""))
781 TXNGetViewRect(_self
->ob_itself
,
783 _res
= Py_BuildValue("O&",
784 PyMac_BuildRect
, &oViewRect
);
788 static PyObject
*TXNObj_TXNAttachObjectToWindow(TXNObjectObject
*_self
, PyObject
*_args
)
790 PyObject
*_res
= NULL
;
793 Boolean iIsActualWindow
;
794 PyMac_PRECHECK(TXNAttachObjectToWindow
);
795 if (!PyArg_ParseTuple(_args
, "O&b",
796 GWorldObj_Convert
, &iWindow
,
799 _err
= TXNAttachObjectToWindow(_self
->ob_itself
,
802 if (_err
!= noErr
) return PyMac_Error(_err
);
808 static PyObject
*TXNObj_TXNIsObjectAttachedToWindow(TXNObjectObject
*_self
, PyObject
*_args
)
810 PyObject
*_res
= NULL
;
812 PyMac_PRECHECK(TXNIsObjectAttachedToWindow
);
813 if (!PyArg_ParseTuple(_args
, ""))
815 _rv
= TXNIsObjectAttachedToWindow(_self
->ob_itself
);
816 _res
= Py_BuildValue("b",
821 static PyObject
*TXNObj_TXNDragTracker(TXNObjectObject
*_self
, PyObject
*_args
)
823 PyObject
*_res
= NULL
;
825 TXNFrameID iTXNFrameID
;
826 DragTrackingMessage iMessage
;
828 DragReference iDragReference
;
829 Boolean iDifferentObjectSameWindow
;
830 PyMac_PRECHECK(TXNDragTracker
);
831 if (!PyArg_ParseTuple(_args
, "lhO&O&b",
834 WinObj_Convert
, &iWindow
,
835 DragObj_Convert
, &iDragReference
,
836 &iDifferentObjectSameWindow
))
838 _err
= TXNDragTracker(_self
->ob_itself
,
843 iDifferentObjectSameWindow
);
844 if (_err
!= noErr
) return PyMac_Error(_err
);
850 static PyObject
*TXNObj_TXNDragReceiver(TXNObjectObject
*_self
, PyObject
*_args
)
852 PyObject
*_res
= NULL
;
854 TXNFrameID iTXNFrameID
;
856 DragReference iDragReference
;
857 Boolean iDifferentObjectSameWindow
;
858 PyMac_PRECHECK(TXNDragReceiver
);
859 if (!PyArg_ParseTuple(_args
, "lO&O&b",
861 WinObj_Convert
, &iWindow
,
862 DragObj_Convert
, &iDragReference
,
863 &iDifferentObjectSameWindow
))
865 _err
= TXNDragReceiver(_self
->ob_itself
,
869 iDifferentObjectSameWindow
);
870 if (_err
!= noErr
) return PyMac_Error(_err
);
876 static PyObject
*TXNObj_TXNActivate(TXNObjectObject
*_self
, PyObject
*_args
)
878 PyObject
*_res
= NULL
;
880 TXNFrameID iTXNFrameID
;
881 TXNScrollBarState iActiveState
;
882 PyMac_PRECHECK(TXNActivate
);
883 if (!PyArg_ParseTuple(_args
, "ll",
887 _err
= TXNActivate(_self
->ob_itself
,
890 if (_err
!= noErr
) return PyMac_Error(_err
);
896 static PyObject
*TXNObj_TXNDoFontMenuSelection(TXNObjectObject
*_self
, PyObject
*_args
)
898 PyObject
*_res
= NULL
;
900 TXNFontMenuObject iTXNFontMenuObject
;
903 PyMac_PRECHECK(TXNDoFontMenuSelection
);
904 if (!PyArg_ParseTuple(_args
, "O&hh",
905 TXNFontMenuObj_Convert
, &iTXNFontMenuObject
,
909 _err
= TXNDoFontMenuSelection(_self
->ob_itself
,
913 if (_err
!= noErr
) return PyMac_Error(_err
);
919 static PyObject
*TXNObj_TXNPrepareFontMenu(TXNObjectObject
*_self
, PyObject
*_args
)
921 PyObject
*_res
= NULL
;
923 TXNFontMenuObject iTXNFontMenuObject
;
924 PyMac_PRECHECK(TXNPrepareFontMenu
);
925 if (!PyArg_ParseTuple(_args
, "O&",
926 TXNFontMenuObj_Convert
, &iTXNFontMenuObject
))
928 _err
= TXNPrepareFontMenu(_self
->ob_itself
,
930 if (_err
!= noErr
) return PyMac_Error(_err
);
936 static PyMethodDef TXNObj_methods
[] = {
937 {"TXNDeleteObject", (PyCFunction
)TXNObj_TXNDeleteObject
, 1,
939 {"TXNResizeFrame", (PyCFunction
)TXNObj_TXNResizeFrame
, 1,
940 "(UInt32 iWidth, UInt32 iHeight, TXNFrameID iTXNFrameID) -> None"},
941 {"TXNSetFrameBounds", (PyCFunction
)TXNObj_TXNSetFrameBounds
, 1,
942 "(SInt32 iTop, SInt32 iLeft, SInt32 iBottom, SInt32 iRight, TXNFrameID iTXNFrameID) -> None"},
943 {"TXNKeyDown", (PyCFunction
)TXNObj_TXNKeyDown
, 1,
944 "(EventRecord iEvent) -> None"},
945 {"TXNAdjustCursor", (PyCFunction
)TXNObj_TXNAdjustCursor
, 1,
946 "(RgnHandle ioCursorRgn) -> None"},
947 {"TXNClick", (PyCFunction
)TXNObj_TXNClick
, 1,
948 "(EventRecord iEvent) -> None"},
949 {"TXNTSMCheck", (PyCFunction
)TXNObj_TXNTSMCheck
, 1,
950 "(EventRecord iEvent) -> (Boolean _rv)"},
951 {"TXNSelectAll", (PyCFunction
)TXNObj_TXNSelectAll
, 1,
953 {"TXNFocus", (PyCFunction
)TXNObj_TXNFocus
, 1,
954 "(Boolean iBecomingFocused) -> None"},
955 {"TXNUpdate", (PyCFunction
)TXNObj_TXNUpdate
, 1,
957 {"TXNDraw", (PyCFunction
)TXNObj_TXNDraw
, 1,
958 "(GWorldPtr iDrawPort) -> None"},
959 {"TXNForceUpdate", (PyCFunction
)TXNObj_TXNForceUpdate
, 1,
961 {"TXNGetSleepTicks", (PyCFunction
)TXNObj_TXNGetSleepTicks
, 1,
962 "() -> (UInt32 _rv)"},
963 {"TXNIdle", (PyCFunction
)TXNObj_TXNIdle
, 1,
965 {"TXNGrowWindow", (PyCFunction
)TXNObj_TXNGrowWindow
, 1,
966 "(EventRecord iEvent) -> None"},
967 {"TXNZoomWindow", (PyCFunction
)TXNObj_TXNZoomWindow
, 1,
968 "(short iPart) -> None"},
969 {"TXNCanUndo", (PyCFunction
)TXNObj_TXNCanUndo
, 1,
970 "() -> (Boolean _rv, TXNActionKey oTXNActionKey)"},
971 {"TXNUndo", (PyCFunction
)TXNObj_TXNUndo
, 1,
973 {"TXNCanRedo", (PyCFunction
)TXNObj_TXNCanRedo
, 1,
974 "() -> (Boolean _rv, TXNActionKey oTXNActionKey)"},
975 {"TXNRedo", (PyCFunction
)TXNObj_TXNRedo
, 1,
977 {"TXNCut", (PyCFunction
)TXNObj_TXNCut
, 1,
979 {"TXNCopy", (PyCFunction
)TXNObj_TXNCopy
, 1,
981 {"TXNPaste", (PyCFunction
)TXNObj_TXNPaste
, 1,
983 {"TXNClear", (PyCFunction
)TXNObj_TXNClear
, 1,
985 {"TXNGetSelection", (PyCFunction
)TXNObj_TXNGetSelection
, 1,
986 "() -> (TXNOffset oStartOffset, TXNOffset oEndOffset)"},
987 {"TXNShowSelection", (PyCFunction
)TXNObj_TXNShowSelection
, 1,
988 "(Boolean iShowEnd) -> None"},
989 {"TXNIsSelectionEmpty", (PyCFunction
)TXNObj_TXNIsSelectionEmpty
, 1,
990 "() -> (Boolean _rv)"},
991 {"TXNSetSelection", (PyCFunction
)TXNObj_TXNSetSelection
, 1,
992 "(TXNOffset iStartOffset, TXNOffset iEndOffset) -> None"},
993 {"TXNCountRunsInRange", (PyCFunction
)TXNObj_TXNCountRunsInRange
, 1,
994 "(UInt32 iStartOffset, UInt32 iEndOffset) -> (ItemCount oRunCount)"},
995 {"TXNDataSize", (PyCFunction
)TXNObj_TXNDataSize
, 1,
996 "() -> (ByteCount _rv)"},
997 {"TXNGetData", (PyCFunction
)TXNObj_TXNGetData
, 1,
998 "(TXNOffset iStartOffset, TXNOffset iEndOffset) -> (Handle oDataHandle)"},
999 {"TXNGetDataEncoded", (PyCFunction
)TXNObj_TXNGetDataEncoded
, 1,
1000 "(TXNOffset iStartOffset, TXNOffset iEndOffset, TXNDataType iEncoding) -> (Handle oDataHandle)"},
1001 {"TXNSetDataFromFile", (PyCFunction
)TXNObj_TXNSetDataFromFile
, 1,
1002 "(SInt16 iFileRefNum, OSType iFileType, ByteCount iFileLength, TXNOffset iStartOffset, TXNOffset iEndOffset) -> None"},
1003 {"TXNSetData", (PyCFunction
)TXNObj_TXNSetData
, 1,
1004 "(TXNDataType iDataType, Buffer iDataPtr, TXNOffset iStartOffset, TXNOffset iEndOffset) -> None"},
1005 {"TXNGetChangeCount", (PyCFunction
)TXNObj_TXNGetChangeCount
, 1,
1006 "() -> (ItemCount _rv)"},
1007 {"TXNSave", (PyCFunction
)TXNObj_TXNSave
, 1,
1008 "(OSType iType, OSType iResType, TXNPermanentTextEncodingType iPermanentEncoding, FSSpec iFileSpecification, SInt16 iDataReference, SInt16 iResourceReference) -> None"},
1009 {"TXNRevert", (PyCFunction
)TXNObj_TXNRevert
, 1,
1011 {"TXNPageSetup", (PyCFunction
)TXNObj_TXNPageSetup
, 1,
1013 {"TXNPrint", (PyCFunction
)TXNObj_TXNPrint
, 1,
1015 {"TXNGetViewRect", (PyCFunction
)TXNObj_TXNGetViewRect
, 1,
1016 "() -> (Rect oViewRect)"},
1017 {"TXNAttachObjectToWindow", (PyCFunction
)TXNObj_TXNAttachObjectToWindow
, 1,
1018 "(GWorldPtr iWindow, Boolean iIsActualWindow) -> None"},
1019 {"TXNIsObjectAttachedToWindow", (PyCFunction
)TXNObj_TXNIsObjectAttachedToWindow
, 1,
1020 "() -> (Boolean _rv)"},
1021 {"TXNDragTracker", (PyCFunction
)TXNObj_TXNDragTracker
, 1,
1022 "(TXNFrameID iTXNFrameID, DragTrackingMessage iMessage, WindowPtr iWindow, DragReference iDragReference, Boolean iDifferentObjectSameWindow) -> None"},
1023 {"TXNDragReceiver", (PyCFunction
)TXNObj_TXNDragReceiver
, 1,
1024 "(TXNFrameID iTXNFrameID, WindowPtr iWindow, DragReference iDragReference, Boolean iDifferentObjectSameWindow) -> None"},
1025 {"TXNActivate", (PyCFunction
)TXNObj_TXNActivate
, 1,
1026 "(TXNFrameID iTXNFrameID, TXNScrollBarState iActiveState) -> None"},
1027 {"TXNDoFontMenuSelection", (PyCFunction
)TXNObj_TXNDoFontMenuSelection
, 1,
1028 "(TXNFontMenuObject iTXNFontMenuObject, SInt16 iMenuID, SInt16 iMenuItem) -> None"},
1029 {"TXNPrepareFontMenu", (PyCFunction
)TXNObj_TXNPrepareFontMenu
, 1,
1030 "(TXNFontMenuObject iTXNFontMenuObject) -> None"},
1034 PyMethodChain TXNObj_chain
= { TXNObj_methods
, NULL
};
1036 static PyObject
*TXNObj_getattr(TXNObjectObject
*self
, char *name
)
1038 return Py_FindMethodInChain(&TXNObj_chain
, (PyObject
*)self
, name
);
1041 #define TXNObj_setattr NULL
1043 #define TXNObj_compare NULL
1045 #define TXNObj_repr NULL
1047 #define TXNObj_hash NULL
1049 PyTypeObject TXNObject_Type
= {
1050 PyObject_HEAD_INIT(&PyType_Type
)
1052 "TXNObject", /*tp_name*/
1053 sizeof(TXNObjectObject
), /*tp_basicsize*/
1056 (destructor
) TXNObj_dealloc
, /*tp_dealloc*/
1058 (getattrfunc
) TXNObj_getattr
, /*tp_getattr*/
1059 (setattrfunc
) TXNObj_setattr
, /*tp_setattr*/
1060 (cmpfunc
) TXNObj_compare
, /*tp_compare*/
1061 (reprfunc
) TXNObj_repr
, /*tp_repr*/
1062 (PyNumberMethods
*)0, /* tp_as_number */
1063 (PySequenceMethods
*)0, /* tp_as_sequence */
1064 (PyMappingMethods
*)0, /* tp_as_mapping */
1065 (hashfunc
) TXNObj_hash
, /*tp_hash*/
1068 /* ------------------- End object type TXNObject -------------------- */
1071 /* ----------------- Object type TXNFontMenuObject ------------------ */
1073 PyTypeObject TXNFontMenuObject_Type
;
1075 #define TXNFontMenuObj_Check(x) ((x)->ob_type == &TXNFontMenuObject_Type)
1077 typedef struct TXNFontMenuObjectObject
{
1079 TXNFontMenuObject ob_itself
;
1080 } TXNFontMenuObjectObject
;
1082 PyObject
*TXNFontMenuObj_New(TXNFontMenuObject itself
)
1084 TXNFontMenuObjectObject
*it
;
1085 if (itself
== NULL
) return PyMac_Error(resNotFound
);
1086 it
= PyObject_NEW(TXNFontMenuObjectObject
, &TXNFontMenuObject_Type
);
1087 if (it
== NULL
) return NULL
;
1088 it
->ob_itself
= itself
;
1089 return (PyObject
*)it
;
1091 TXNFontMenuObj_Convert(PyObject
*v
, TXNFontMenuObject
*p_itself
)
1093 if (!TXNFontMenuObj_Check(v
))
1095 PyErr_SetString(PyExc_TypeError
, "TXNFontMenuObject required");
1098 *p_itself
= ((TXNFontMenuObjectObject
*)v
)->ob_itself
;
1102 static void TXNFontMenuObj_dealloc(TXNFontMenuObjectObject
*self
)
1104 /* Cleanup of self->ob_itself goes here */
1108 static PyObject
*TXNFontMenuObj_TXNGetFontMenuHandle(TXNFontMenuObjectObject
*_self
, PyObject
*_args
)
1110 PyObject
*_res
= NULL
;
1112 MenuHandle oFontMenuHandle
;
1113 PyMac_PRECHECK(TXNGetFontMenuHandle
);
1114 if (!PyArg_ParseTuple(_args
, ""))
1116 _err
= TXNGetFontMenuHandle(_self
->ob_itself
,
1118 if (_err
!= noErr
) return PyMac_Error(_err
);
1119 _res
= Py_BuildValue("O&",
1120 MenuObj_New
, oFontMenuHandle
);
1124 static PyObject
*TXNFontMenuObj_TXNDisposeFontMenuObject(TXNFontMenuObjectObject
*_self
, PyObject
*_args
)
1126 PyObject
*_res
= NULL
;
1128 PyMac_PRECHECK(TXNDisposeFontMenuObject
);
1129 if (!PyArg_ParseTuple(_args
, ""))
1131 _err
= TXNDisposeFontMenuObject(_self
->ob_itself
);
1132 if (_err
!= noErr
) return PyMac_Error(_err
);
1138 static PyMethodDef TXNFontMenuObj_methods
[] = {
1139 {"TXNGetFontMenuHandle", (PyCFunction
)TXNFontMenuObj_TXNGetFontMenuHandle
, 1,
1140 "() -> (MenuHandle oFontMenuHandle)"},
1141 {"TXNDisposeFontMenuObject", (PyCFunction
)TXNFontMenuObj_TXNDisposeFontMenuObject
, 1,
1146 PyMethodChain TXNFontMenuObj_chain
= { TXNFontMenuObj_methods
, NULL
};
1148 static PyObject
*TXNFontMenuObj_getattr(TXNFontMenuObjectObject
*self
, char *name
)
1150 return Py_FindMethodInChain(&TXNFontMenuObj_chain
, (PyObject
*)self
, name
);
1153 #define TXNFontMenuObj_setattr NULL
1155 #define TXNFontMenuObj_compare NULL
1157 #define TXNFontMenuObj_repr NULL
1159 #define TXNFontMenuObj_hash NULL
1161 PyTypeObject TXNFontMenuObject_Type
= {
1162 PyObject_HEAD_INIT(&PyType_Type
)
1164 "TXNFontMenuObject", /*tp_name*/
1165 sizeof(TXNFontMenuObjectObject
), /*tp_basicsize*/
1168 (destructor
) TXNFontMenuObj_dealloc
, /*tp_dealloc*/
1170 (getattrfunc
) TXNFontMenuObj_getattr
, /*tp_getattr*/
1171 (setattrfunc
) TXNFontMenuObj_setattr
, /*tp_setattr*/
1172 (cmpfunc
) TXNFontMenuObj_compare
, /*tp_compare*/
1173 (reprfunc
) TXNFontMenuObj_repr
, /*tp_repr*/
1174 (PyNumberMethods
*)0, /* tp_as_number */
1175 (PySequenceMethods
*)0, /* tp_as_sequence */
1176 (PyMappingMethods
*)0, /* tp_as_mapping */
1177 (hashfunc
) TXNFontMenuObj_hash
, /*tp_hash*/
1180 /* --------------- End object type TXNFontMenuObject ---------------- */
1183 static PyObject
*Mlte_TXNNewObject(PyObject
*_self
, PyObject
*_args
)
1185 PyObject
*_res
= NULL
;
1190 TXNFrameOptions iFrameOptions
;
1191 TXNFrameType iFrameType
;
1192 TXNFileType iFileType
;
1193 TXNPermanentTextEncodingType iPermanentEncoding
;
1194 TXNObject oTXNObject
;
1195 TXNFrameID oTXNFrameID
;
1196 PyMac_PRECHECK(TXNNewObject
);
1197 if (!PyArg_ParseTuple(_args
, "O&O&O&llO&l",
1198 OptFSSpecPtr_Convert
, &iFileSpec
,
1199 WinObj_Convert
, &iWindow
,
1200 OptRectPtr_Convert
, &iFrame
,
1203 PyMac_GetOSType
, &iFileType
,
1204 &iPermanentEncoding
))
1206 _err
= TXNNewObject(iFileSpec
,
1215 (TXNObjectRefcon
)0);
1216 if (_err
!= noErr
) return PyMac_Error(_err
);
1217 _res
= Py_BuildValue("O&l",
1218 TXNObj_New
, oTXNObject
,
1223 static PyObject
*Mlte_TXNTerminateTextension(PyObject
*_self
, PyObject
*_args
)
1225 PyObject
*_res
= NULL
;
1226 PyMac_PRECHECK(TXNTerminateTextension
);
1227 if (!PyArg_ParseTuple(_args
, ""))
1229 TXNTerminateTextension();
1235 static PyObject
*Mlte_TXNIsScrapPastable(PyObject
*_self
, PyObject
*_args
)
1237 PyObject
*_res
= NULL
;
1239 PyMac_PRECHECK(TXNIsScrapPastable
);
1240 if (!PyArg_ParseTuple(_args
, ""))
1242 _rv
= TXNIsScrapPastable();
1243 _res
= Py_BuildValue("b",
1248 static PyObject
*Mlte_TXNConvertToPublicScrap(PyObject
*_self
, PyObject
*_args
)
1250 PyObject
*_res
= NULL
;
1252 PyMac_PRECHECK(TXNConvertToPublicScrap
);
1253 if (!PyArg_ParseTuple(_args
, ""))
1255 _err
= TXNConvertToPublicScrap();
1256 if (_err
!= noErr
) return PyMac_Error(_err
);
1262 static PyObject
*Mlte_TXNConvertFromPublicScrap(PyObject
*_self
, PyObject
*_args
)
1264 PyObject
*_res
= NULL
;
1266 PyMac_PRECHECK(TXNConvertFromPublicScrap
);
1267 if (!PyArg_ParseTuple(_args
, ""))
1269 _err
= TXNConvertFromPublicScrap();
1270 if (_err
!= noErr
) return PyMac_Error(_err
);
1276 static PyObject
*Mlte_TXNNewFontMenuObject(PyObject
*_self
, PyObject
*_args
)
1278 PyObject
*_res
= NULL
;
1280 MenuHandle iFontMenuHandle
;
1282 SInt16 iStartHierMenuID
;
1283 TXNFontMenuObject oTXNFontMenuObject
;
1284 PyMac_PRECHECK(TXNNewFontMenuObject
);
1285 if (!PyArg_ParseTuple(_args
, "O&hh",
1286 MenuObj_Convert
, &iFontMenuHandle
,
1290 _err
= TXNNewFontMenuObject(iFontMenuHandle
,
1293 &oTXNFontMenuObject
);
1294 if (_err
!= noErr
) return PyMac_Error(_err
);
1295 _res
= Py_BuildValue("O&",
1296 TXNFontMenuObj_New
, oTXNFontMenuObject
);
1300 static PyObject
*Mlte_TXNVersionInformation(PyObject
*_self
, PyObject
*_args
)
1302 PyObject
*_res
= NULL
;
1303 TXNVersionValue _rv
;
1304 TXNFeatureBits oFeatureFlags
;
1305 PyMac_PRECHECK(TXNVersionInformation
);
1306 if (!PyArg_ParseTuple(_args
, ""))
1308 _rv
= TXNVersionInformation(&oFeatureFlags
);
1309 _res
= Py_BuildValue("ll",
1315 static PyObject
*Mlte_TXNInitTextension(PyObject
*_self
, PyObject
*_args
)
1317 PyObject
*_res
= NULL
;
1320 TXNMacOSPreferredFontDescription
* iDefaultFonts
= NULL
;
1321 ItemCount iCountDefaultFonts
= 0;
1322 TXNInitOptions iUsageFlags
;
1323 PyMac_PRECHECK(TXNInitTextension
);
1324 if (!PyArg_ParseTuple(_args
, "l", &iUsageFlags
))
1326 _err
= TXNInitTextension(iDefaultFonts
,
1329 if (_err
!= noErr
) return PyMac_Error(_err
);
1336 static PyMethodDef Mlte_methods
[] = {
1337 {"TXNNewObject", (PyCFunction
)Mlte_TXNNewObject
, 1,
1338 "(FSSpec * iFileSpec, WindowPtr iWindow, Rect * iFrame, TXNFrameOptions iFrameOptions, TXNFrameType iFrameType, TXNFileType iFileType, TXNPermanentTextEncodingType iPermanentEncoding) -> (TXNObject oTXNObject, TXNFrameID oTXNFrameID)"},
1339 {"TXNTerminateTextension", (PyCFunction
)Mlte_TXNTerminateTextension
, 1,
1341 {"TXNIsScrapPastable", (PyCFunction
)Mlte_TXNIsScrapPastable
, 1,
1342 "() -> (Boolean _rv)"},
1343 {"TXNConvertToPublicScrap", (PyCFunction
)Mlte_TXNConvertToPublicScrap
, 1,
1345 {"TXNConvertFromPublicScrap", (PyCFunction
)Mlte_TXNConvertFromPublicScrap
, 1,
1347 {"TXNNewFontMenuObject", (PyCFunction
)Mlte_TXNNewFontMenuObject
, 1,
1348 "(MenuHandle iFontMenuHandle, SInt16 iMenuID, SInt16 iStartHierMenuID) -> (TXNFontMenuObject oTXNFontMenuObject)"},
1349 {"TXNVersionInformation", (PyCFunction
)Mlte_TXNVersionInformation
, 1,
1350 "() -> (TXNVersionValue _rv, TXNFeatureBits oFeatureFlags)"},
1351 {"TXNInitTextension", (PyCFunction
)Mlte_TXNInitTextension
, 1,
1352 "(TXNInitOptions) -> None"},
1366 // PyMac_INIT_TOOLBOX_OBJECT_NEW(xxxx);
1369 m
= Py_InitModule("Mlte", Mlte_methods
);
1370 d
= PyModule_GetDict(m
);
1371 Mlte_Error
= PyMac_GetOSErrException();
1372 if (Mlte_Error
== NULL
||
1373 PyDict_SetItemString(d
, "Error", Mlte_Error
) != 0)
1375 TXNObject_Type
.ob_type
= &PyType_Type
;
1376 Py_INCREF(&TXNObject_Type
);
1377 if (PyDict_SetItemString(d
, "TXNObjectType", (PyObject
*)&TXNObject_Type
) != 0)
1378 Py_FatalError("can't initialize TXNObjectType");
1379 TXNFontMenuObject_Type
.ob_type
= &PyType_Type
;
1380 Py_INCREF(&TXNFontMenuObject_Type
);
1381 if (PyDict_SetItemString(d
, "TXNFontMenuObjectType", (PyObject
*)&TXNFontMenuObject_Type
) != 0)
1382 Py_FatalError("can't initialize TXNFontMenuObjectType");
1385 /* ======================== End module Mlte ========================= */