2 /* ========================== Module Menu =========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
45 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
48 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
50 static PyObject
*Menu_Error
;
52 /* ------------------------ Object type Menu ------------------------ */
54 PyTypeObject Menu_Type
;
56 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
58 typedef struct MenuObject
{
63 PyObject
*MenuObj_New(itself
)
67 it
= PyObject_NEW(MenuObject
, &Menu_Type
);
68 if (it
== NULL
) return NULL
;
69 it
->ob_itself
= itself
;
70 return (PyObject
*)it
;
72 MenuObj_Convert(v
, p_itself
)
76 if (!MenuObj_Check(v
))
78 PyErr_SetString(PyExc_TypeError
, "Menu required");
81 *p_itself
= ((MenuObject
*)v
)->ob_itself
;
85 static void MenuObj_dealloc(self
)
88 /* Cleanup of self->ob_itself goes here */
92 static PyObject
*MenuObj_DisposeMenu(_self
, _args
)
96 PyObject
*_res
= NULL
;
97 if (!PyArg_ParseTuple(_args
, ""))
99 DisposeMenu(_self
->ob_itself
);
105 static PyObject
*MenuObj_MacAppendMenu(_self
, _args
)
109 PyObject
*_res
= NULL
;
111 if (!PyArg_ParseTuple(_args
, "O&",
112 PyMac_GetStr255
, data
))
114 MacAppendMenu(_self
->ob_itself
,
121 static PyObject
*MenuObj_InsertResMenu(_self
, _args
)
125 PyObject
*_res
= NULL
;
128 if (!PyArg_ParseTuple(_args
, "O&h",
129 PyMac_GetOSType
, &theType
,
132 InsertResMenu(_self
->ob_itself
,
140 static PyObject
*MenuObj_MacInsertMenu(_self
, _args
)
144 PyObject
*_res
= NULL
;
146 if (!PyArg_ParseTuple(_args
, "h",
149 MacInsertMenu(_self
->ob_itself
,
156 static PyObject
*MenuObj_AppendResMenu(_self
, _args
)
160 PyObject
*_res
= NULL
;
162 if (!PyArg_ParseTuple(_args
, "O&",
163 PyMac_GetOSType
, &theType
))
165 AppendResMenu(_self
->ob_itself
,
172 static PyObject
*MenuObj_MacInsertMenuItem(_self
, _args
)
176 PyObject
*_res
= NULL
;
179 if (!PyArg_ParseTuple(_args
, "O&h",
180 PyMac_GetStr255
, itemString
,
183 MacInsertMenuItem(_self
->ob_itself
,
191 static PyObject
*MenuObj_DeleteMenuItem(_self
, _args
)
195 PyObject
*_res
= NULL
;
197 if (!PyArg_ParseTuple(_args
, "h",
200 DeleteMenuItem(_self
->ob_itself
,
207 static PyObject
*MenuObj_SetMenuItemText(_self
, _args
)
211 PyObject
*_res
= NULL
;
214 if (!PyArg_ParseTuple(_args
, "hO&",
216 PyMac_GetStr255
, itemString
))
218 SetMenuItemText(_self
->ob_itself
,
226 static PyObject
*MenuObj_GetMenuItemText(_self
, _args
)
230 PyObject
*_res
= NULL
;
233 if (!PyArg_ParseTuple(_args
, "h",
236 GetMenuItemText(_self
->ob_itself
,
239 _res
= Py_BuildValue("O&",
240 PyMac_BuildStr255
, itemString
);
244 static PyObject
*MenuObj_SetItemMark(_self
, _args
)
248 PyObject
*_res
= NULL
;
250 CharParameter markChar
;
251 if (!PyArg_ParseTuple(_args
, "hh",
255 SetItemMark(_self
->ob_itself
,
263 static PyObject
*MenuObj_GetItemMark(_self
, _args
)
267 PyObject
*_res
= NULL
;
269 CharParameter markChar
;
270 if (!PyArg_ParseTuple(_args
, "h",
273 GetItemMark(_self
->ob_itself
,
276 _res
= Py_BuildValue("h",
281 static PyObject
*MenuObj_SetItemCmd(_self
, _args
)
285 PyObject
*_res
= NULL
;
287 CharParameter cmdChar
;
288 if (!PyArg_ParseTuple(_args
, "hh",
292 SetItemCmd(_self
->ob_itself
,
300 static PyObject
*MenuObj_GetItemCmd(_self
, _args
)
304 PyObject
*_res
= NULL
;
306 CharParameter cmdChar
;
307 if (!PyArg_ParseTuple(_args
, "h",
310 GetItemCmd(_self
->ob_itself
,
313 _res
= Py_BuildValue("h",
318 static PyObject
*MenuObj_SetItemIcon(_self
, _args
)
322 PyObject
*_res
= NULL
;
325 if (!PyArg_ParseTuple(_args
, "hh",
329 SetItemIcon(_self
->ob_itself
,
337 static PyObject
*MenuObj_GetItemIcon(_self
, _args
)
341 PyObject
*_res
= NULL
;
344 if (!PyArg_ParseTuple(_args
, "h",
347 GetItemIcon(_self
->ob_itself
,
350 _res
= Py_BuildValue("h",
355 static PyObject
*MenuObj_SetItemStyle(_self
, _args
)
359 PyObject
*_res
= NULL
;
361 StyleParameter chStyle
;
362 if (!PyArg_ParseTuple(_args
, "hh",
366 SetItemStyle(_self
->ob_itself
,
374 static PyObject
*MenuObj_GetItemStyle(_self
, _args
)
378 PyObject
*_res
= NULL
;
381 if (!PyArg_ParseTuple(_args
, "h",
384 GetItemStyle(_self
->ob_itself
,
387 _res
= Py_BuildValue("b",
392 static PyObject
*MenuObj_CalcMenuSize(_self
, _args
)
396 PyObject
*_res
= NULL
;
397 if (!PyArg_ParseTuple(_args
, ""))
399 CalcMenuSize(_self
->ob_itself
);
405 static PyObject
*MenuObj_DisableItem(_self
, _args
)
409 PyObject
*_res
= NULL
;
411 if (!PyArg_ParseTuple(_args
, "h",
414 DisableItem(_self
->ob_itself
,
421 static PyObject
*MenuObj_EnableItem(_self
, _args
)
425 PyObject
*_res
= NULL
;
427 if (!PyArg_ParseTuple(_args
, "h",
430 EnableItem(_self
->ob_itself
,
437 static PyObject
*MenuObj_PopUpMenuSelect(_self
, _args
)
441 PyObject
*_res
= NULL
;
446 if (!PyArg_ParseTuple(_args
, "hhh",
451 _rv
= PopUpMenuSelect(_self
->ob_itself
,
455 _res
= Py_BuildValue("l",
460 static PyObject
*MenuObj_CheckItem(_self
, _args
)
464 PyObject
*_res
= NULL
;
467 if (!PyArg_ParseTuple(_args
, "hb",
471 CheckItem(_self
->ob_itself
,
479 static PyObject
*MenuObj_CountMItems(_self
, _args
)
483 PyObject
*_res
= NULL
;
485 if (!PyArg_ParseTuple(_args
, ""))
487 _rv
= CountMItems(_self
->ob_itself
);
488 _res
= Py_BuildValue("h",
493 static PyObject
*MenuObj_InsertFontResMenu(_self
, _args
)
497 PyObject
*_res
= NULL
;
500 if (!PyArg_ParseTuple(_args
, "hh",
504 InsertFontResMenu(_self
->ob_itself
,
512 static PyObject
*MenuObj_InsertIntlResMenu(_self
, _args
)
516 PyObject
*_res
= NULL
;
520 if (!PyArg_ParseTuple(_args
, "O&hh",
521 PyMac_GetOSType
, &theType
,
525 InsertIntlResMenu(_self
->ob_itself
,
534 static PyObject
*MenuObj_SetMenuItemCommandID(_self
, _args
)
538 PyObject
*_res
= NULL
;
542 if (!PyArg_ParseTuple(_args
, "hl",
546 _err
= SetMenuItemCommandID(_self
->ob_itself
,
549 if (_err
!= noErr
) return PyMac_Error(_err
);
555 static PyObject
*MenuObj_GetMenuItemCommandID(_self
, _args
)
559 PyObject
*_res
= NULL
;
563 if (!PyArg_ParseTuple(_args
, "h",
566 _err
= GetMenuItemCommandID(_self
->ob_itself
,
569 if (_err
!= noErr
) return PyMac_Error(_err
);
570 _res
= Py_BuildValue("l",
575 static PyObject
*MenuObj_SetMenuItemModifiers(_self
, _args
)
579 PyObject
*_res
= NULL
;
583 if (!PyArg_ParseTuple(_args
, "hb",
587 _err
= SetMenuItemModifiers(_self
->ob_itself
,
590 if (_err
!= noErr
) return PyMac_Error(_err
);
596 static PyObject
*MenuObj_GetMenuItemModifiers(_self
, _args
)
600 PyObject
*_res
= NULL
;
604 if (!PyArg_ParseTuple(_args
, "h",
607 _err
= GetMenuItemModifiers(_self
->ob_itself
,
610 if (_err
!= noErr
) return PyMac_Error(_err
);
611 _res
= Py_BuildValue("b",
616 static PyObject
*MenuObj_SetMenuItemIconHandle(_self
, _args
)
620 PyObject
*_res
= NULL
;
625 if (!PyArg_ParseTuple(_args
, "hbO&",
628 ResObj_Convert
, &inIconHandle
))
630 _err
= SetMenuItemIconHandle(_self
->ob_itself
,
634 if (_err
!= noErr
) return PyMac_Error(_err
);
640 static PyObject
*MenuObj_GetMenuItemIconHandle(_self
, _args
)
644 PyObject
*_res
= NULL
;
648 Handle outIconHandle
;
649 if (!PyArg_ParseTuple(_args
, "h",
652 _err
= GetMenuItemIconHandle(_self
->ob_itself
,
656 if (_err
!= noErr
) return PyMac_Error(_err
);
657 _res
= Py_BuildValue("bO&",
659 ResObj_New
, outIconHandle
);
663 static PyObject
*MenuObj_SetMenuItemTextEncoding(_self
, _args
)
667 PyObject
*_res
= NULL
;
670 TextEncoding inScriptID
;
671 if (!PyArg_ParseTuple(_args
, "hl",
675 _err
= SetMenuItemTextEncoding(_self
->ob_itself
,
678 if (_err
!= noErr
) return PyMac_Error(_err
);
684 static PyObject
*MenuObj_GetMenuItemTextEncoding(_self
, _args
)
688 PyObject
*_res
= NULL
;
691 TextEncoding outScriptID
;
692 if (!PyArg_ParseTuple(_args
, "h",
695 _err
= GetMenuItemTextEncoding(_self
->ob_itself
,
698 if (_err
!= noErr
) return PyMac_Error(_err
);
699 _res
= Py_BuildValue("l",
704 static PyObject
*MenuObj_SetMenuItemHierarchicalID(_self
, _args
)
708 PyObject
*_res
= NULL
;
712 if (!PyArg_ParseTuple(_args
, "hh",
716 _err
= SetMenuItemHierarchicalID(_self
->ob_itself
,
719 if (_err
!= noErr
) return PyMac_Error(_err
);
725 static PyObject
*MenuObj_GetMenuItemHierarchicalID(_self
, _args
)
729 PyObject
*_res
= NULL
;
733 if (!PyArg_ParseTuple(_args
, "h",
736 _err
= GetMenuItemHierarchicalID(_self
->ob_itself
,
739 if (_err
!= noErr
) return PyMac_Error(_err
);
740 _res
= Py_BuildValue("h",
745 static PyObject
*MenuObj_SetMenuItemFontID(_self
, _args
)
749 PyObject
*_res
= NULL
;
753 if (!PyArg_ParseTuple(_args
, "hh",
757 _err
= SetMenuItemFontID(_self
->ob_itself
,
760 if (_err
!= noErr
) return PyMac_Error(_err
);
766 static PyObject
*MenuObj_GetMenuItemFontID(_self
, _args
)
770 PyObject
*_res
= NULL
;
774 if (!PyArg_ParseTuple(_args
, "h",
777 _err
= GetMenuItemFontID(_self
->ob_itself
,
780 if (_err
!= noErr
) return PyMac_Error(_err
);
781 _res
= Py_BuildValue("h",
786 static PyObject
*MenuObj_SetMenuItemRefCon(_self
, _args
)
790 PyObject
*_res
= NULL
;
794 if (!PyArg_ParseTuple(_args
, "hl",
798 _err
= SetMenuItemRefCon(_self
->ob_itself
,
801 if (_err
!= noErr
) return PyMac_Error(_err
);
807 static PyObject
*MenuObj_GetMenuItemRefCon(_self
, _args
)
811 PyObject
*_res
= NULL
;
815 if (!PyArg_ParseTuple(_args
, "h",
818 _err
= GetMenuItemRefCon(_self
->ob_itself
,
821 if (_err
!= noErr
) return PyMac_Error(_err
);
822 _res
= Py_BuildValue("l",
827 static PyObject
*MenuObj_SetMenuItemRefCon2(_self
, _args
)
831 PyObject
*_res
= NULL
;
835 if (!PyArg_ParseTuple(_args
, "hl",
839 _err
= SetMenuItemRefCon2(_self
->ob_itself
,
842 if (_err
!= noErr
) return PyMac_Error(_err
);
848 static PyObject
*MenuObj_GetMenuItemRefCon2(_self
, _args
)
852 PyObject
*_res
= NULL
;
856 if (!PyArg_ParseTuple(_args
, "h",
859 _err
= GetMenuItemRefCon2(_self
->ob_itself
,
862 if (_err
!= noErr
) return PyMac_Error(_err
);
863 _res
= Py_BuildValue("l",
868 static PyObject
*MenuObj_SetMenuItemKeyGlyph(_self
, _args
)
872 PyObject
*_res
= NULL
;
876 if (!PyArg_ParseTuple(_args
, "hh",
880 _err
= SetMenuItemKeyGlyph(_self
->ob_itself
,
883 if (_err
!= noErr
) return PyMac_Error(_err
);
889 static PyObject
*MenuObj_GetMenuItemKeyGlyph(_self
, _args
)
893 PyObject
*_res
= NULL
;
897 if (!PyArg_ParseTuple(_args
, "h",
900 _err
= GetMenuItemKeyGlyph(_self
->ob_itself
,
903 if (_err
!= noErr
) return PyMac_Error(_err
);
904 _res
= Py_BuildValue("h",
909 static PyObject
*MenuObj_as_Resource(_self
, _args
)
913 PyObject
*_res
= NULL
;
915 return ResObj_New((Handle
)_self
->ob_itself
);
919 static PyObject
*MenuObj_AppendMenu(_self
, _args
)
923 PyObject
*_res
= NULL
;
925 if (!PyArg_ParseTuple(_args
, "O&",
926 PyMac_GetStr255
, data
))
928 AppendMenu(_self
->ob_itself
,
935 static PyObject
*MenuObj_InsertMenu(_self
, _args
)
939 PyObject
*_res
= NULL
;
941 if (!PyArg_ParseTuple(_args
, "h",
944 InsertMenu(_self
->ob_itself
,
951 static PyObject
*MenuObj_InsertMenuItem(_self
, _args
)
955 PyObject
*_res
= NULL
;
958 if (!PyArg_ParseTuple(_args
, "O&h",
959 PyMac_GetStr255
, itemString
,
962 InsertMenuItem(_self
->ob_itself
,
970 static PyMethodDef MenuObj_methods
[] = {
971 {"DisposeMenu", (PyCFunction
)MenuObj_DisposeMenu
, 1,
973 {"MacAppendMenu", (PyCFunction
)MenuObj_MacAppendMenu
, 1,
974 "(Str255 data) -> None"},
975 {"InsertResMenu", (PyCFunction
)MenuObj_InsertResMenu
, 1,
976 "(ResType theType, short afterItem) -> None"},
977 {"MacInsertMenu", (PyCFunction
)MenuObj_MacInsertMenu
, 1,
978 "(short beforeID) -> None"},
979 {"AppendResMenu", (PyCFunction
)MenuObj_AppendResMenu
, 1,
980 "(ResType theType) -> None"},
981 {"MacInsertMenuItem", (PyCFunction
)MenuObj_MacInsertMenuItem
, 1,
982 "(Str255 itemString, short afterItem) -> None"},
983 {"DeleteMenuItem", (PyCFunction
)MenuObj_DeleteMenuItem
, 1,
984 "(short item) -> None"},
985 {"SetMenuItemText", (PyCFunction
)MenuObj_SetMenuItemText
, 1,
986 "(short item, Str255 itemString) -> None"},
987 {"GetMenuItemText", (PyCFunction
)MenuObj_GetMenuItemText
, 1,
988 "(short item) -> (Str255 itemString)"},
989 {"SetItemMark", (PyCFunction
)MenuObj_SetItemMark
, 1,
990 "(short item, CharParameter markChar) -> None"},
991 {"GetItemMark", (PyCFunction
)MenuObj_GetItemMark
, 1,
992 "(short item) -> (CharParameter markChar)"},
993 {"SetItemCmd", (PyCFunction
)MenuObj_SetItemCmd
, 1,
994 "(short item, CharParameter cmdChar) -> None"},
995 {"GetItemCmd", (PyCFunction
)MenuObj_GetItemCmd
, 1,
996 "(short item) -> (CharParameter cmdChar)"},
997 {"SetItemIcon", (PyCFunction
)MenuObj_SetItemIcon
, 1,
998 "(short item, short iconIndex) -> None"},
999 {"GetItemIcon", (PyCFunction
)MenuObj_GetItemIcon
, 1,
1000 "(short item) -> (short iconIndex)"},
1001 {"SetItemStyle", (PyCFunction
)MenuObj_SetItemStyle
, 1,
1002 "(short item, StyleParameter chStyle) -> None"},
1003 {"GetItemStyle", (PyCFunction
)MenuObj_GetItemStyle
, 1,
1004 "(short item) -> (Style chStyle)"},
1005 {"CalcMenuSize", (PyCFunction
)MenuObj_CalcMenuSize
, 1,
1007 {"DisableItem", (PyCFunction
)MenuObj_DisableItem
, 1,
1008 "(short item) -> None"},
1009 {"EnableItem", (PyCFunction
)MenuObj_EnableItem
, 1,
1010 "(short item) -> None"},
1011 {"PopUpMenuSelect", (PyCFunction
)MenuObj_PopUpMenuSelect
, 1,
1012 "(short top, short left, short popUpItem) -> (long _rv)"},
1013 {"CheckItem", (PyCFunction
)MenuObj_CheckItem
, 1,
1014 "(short item, Boolean checked) -> None"},
1015 {"CountMItems", (PyCFunction
)MenuObj_CountMItems
, 1,
1016 "() -> (short _rv)"},
1017 {"InsertFontResMenu", (PyCFunction
)MenuObj_InsertFontResMenu
, 1,
1018 "(short afterItem, short scriptFilter) -> None"},
1019 {"InsertIntlResMenu", (PyCFunction
)MenuObj_InsertIntlResMenu
, 1,
1020 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1021 {"SetMenuItemCommandID", (PyCFunction
)MenuObj_SetMenuItemCommandID
, 1,
1022 "(SInt16 inItem, UInt32 inCommandID) -> None"},
1023 {"GetMenuItemCommandID", (PyCFunction
)MenuObj_GetMenuItemCommandID
, 1,
1024 "(SInt16 inItem) -> (UInt32 outCommandID)"},
1025 {"SetMenuItemModifiers", (PyCFunction
)MenuObj_SetMenuItemModifiers
, 1,
1026 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1027 {"GetMenuItemModifiers", (PyCFunction
)MenuObj_GetMenuItemModifiers
, 1,
1028 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1029 {"SetMenuItemIconHandle", (PyCFunction
)MenuObj_SetMenuItemIconHandle
, 1,
1030 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1031 {"GetMenuItemIconHandle", (PyCFunction
)MenuObj_GetMenuItemIconHandle
, 1,
1032 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1033 {"SetMenuItemTextEncoding", (PyCFunction
)MenuObj_SetMenuItemTextEncoding
, 1,
1034 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1035 {"GetMenuItemTextEncoding", (PyCFunction
)MenuObj_GetMenuItemTextEncoding
, 1,
1036 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1037 {"SetMenuItemHierarchicalID", (PyCFunction
)MenuObj_SetMenuItemHierarchicalID
, 1,
1038 "(SInt16 inItem, SInt16 inHierID) -> None"},
1039 {"GetMenuItemHierarchicalID", (PyCFunction
)MenuObj_GetMenuItemHierarchicalID
, 1,
1040 "(SInt16 inItem) -> (SInt16 outHierID)"},
1041 {"SetMenuItemFontID", (PyCFunction
)MenuObj_SetMenuItemFontID
, 1,
1042 "(SInt16 inItem, SInt16 inFontID) -> None"},
1043 {"GetMenuItemFontID", (PyCFunction
)MenuObj_GetMenuItemFontID
, 1,
1044 "(SInt16 inItem) -> (SInt16 outFontID)"},
1045 {"SetMenuItemRefCon", (PyCFunction
)MenuObj_SetMenuItemRefCon
, 1,
1046 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1047 {"GetMenuItemRefCon", (PyCFunction
)MenuObj_GetMenuItemRefCon
, 1,
1048 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1049 {"SetMenuItemRefCon2", (PyCFunction
)MenuObj_SetMenuItemRefCon2
, 1,
1050 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1051 {"GetMenuItemRefCon2", (PyCFunction
)MenuObj_GetMenuItemRefCon2
, 1,
1052 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1053 {"SetMenuItemKeyGlyph", (PyCFunction
)MenuObj_SetMenuItemKeyGlyph
, 1,
1054 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1055 {"GetMenuItemKeyGlyph", (PyCFunction
)MenuObj_GetMenuItemKeyGlyph
, 1,
1056 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1057 {"as_Resource", (PyCFunction
)MenuObj_as_Resource
, 1,
1058 "Return this Menu as a Resource"},
1059 {"AppendMenu", (PyCFunction
)MenuObj_AppendMenu
, 1,
1060 "(Str255 data) -> None"},
1061 {"InsertMenu", (PyCFunction
)MenuObj_InsertMenu
, 1,
1062 "(short beforeID) -> None"},
1063 {"InsertMenuItem", (PyCFunction
)MenuObj_InsertMenuItem
, 1,
1064 "(Str255 itemString, short afterItem) -> None"},
1068 PyMethodChain MenuObj_chain
= { MenuObj_methods
, NULL
};
1070 static PyObject
*MenuObj_getattr(self
, name
)
1074 return Py_FindMethodInChain(&MenuObj_chain
, (PyObject
*)self
, name
);
1077 #define MenuObj_setattr NULL
1079 PyTypeObject Menu_Type
= {
1080 PyObject_HEAD_INIT(&PyType_Type
)
1083 sizeof(MenuObject
), /*tp_basicsize*/
1086 (destructor
) MenuObj_dealloc
, /*tp_dealloc*/
1088 (getattrfunc
) MenuObj_getattr
, /*tp_getattr*/
1089 (setattrfunc
) MenuObj_setattr
, /*tp_setattr*/
1092 /* ---------------------- End object type Menu ---------------------- */
1095 static PyObject
*Menu_GetMBarHeight(_self
, _args
)
1099 PyObject
*_res
= NULL
;
1101 if (!PyArg_ParseTuple(_args
, ""))
1103 _rv
= GetMBarHeight();
1104 _res
= Py_BuildValue("h",
1109 static PyObject
*Menu_InitMenus(_self
, _args
)
1113 PyObject
*_res
= NULL
;
1114 if (!PyArg_ParseTuple(_args
, ""))
1122 static PyObject
*Menu_NewMenu(_self
, _args
)
1126 PyObject
*_res
= NULL
;
1130 if (!PyArg_ParseTuple(_args
, "hO&",
1132 PyMac_GetStr255
, menuTitle
))
1134 _rv
= NewMenu(menuID
,
1136 _res
= Py_BuildValue("O&",
1141 static PyObject
*Menu_MacGetMenu(_self
, _args
)
1145 PyObject
*_res
= NULL
;
1148 if (!PyArg_ParseTuple(_args
, "h",
1151 _rv
= MacGetMenu(resourceID
);
1152 _res
= Py_BuildValue("O&",
1157 static PyObject
*Menu_MacDeleteMenu(_self
, _args
)
1161 PyObject
*_res
= NULL
;
1163 if (!PyArg_ParseTuple(_args
, "h",
1166 MacDeleteMenu(menuID
);
1172 static PyObject
*Menu_MenuKey(_self
, _args
)
1176 PyObject
*_res
= NULL
;
1179 if (!PyArg_ParseTuple(_args
, "h",
1183 _res
= Py_BuildValue("l",
1188 static PyObject
*Menu_HiliteMenu(_self
, _args
)
1192 PyObject
*_res
= NULL
;
1194 if (!PyArg_ParseTuple(_args
, "h",
1203 static PyObject
*Menu_GetMenuHandle(_self
, _args
)
1207 PyObject
*_res
= NULL
;
1210 if (!PyArg_ParseTuple(_args
, "h",
1213 _rv
= GetMenuHandle(menuID
);
1214 _res
= Py_BuildValue("O&",
1219 static PyObject
*Menu_FlashMenuBar(_self
, _args
)
1223 PyObject
*_res
= NULL
;
1225 if (!PyArg_ParseTuple(_args
, "h",
1228 FlashMenuBar(menuID
);
1234 static PyObject
*Menu_MenuChoice(_self
, _args
)
1238 PyObject
*_res
= NULL
;
1240 if (!PyArg_ParseTuple(_args
, ""))
1243 _res
= Py_BuildValue("l",
1248 static PyObject
*Menu_DeleteMCEntries(_self
, _args
)
1252 PyObject
*_res
= NULL
;
1255 if (!PyArg_ParseTuple(_args
, "hh",
1259 DeleteMCEntries(menuID
,
1266 static PyObject
*Menu_MacDrawMenuBar(_self
, _args
)
1270 PyObject
*_res
= NULL
;
1271 if (!PyArg_ParseTuple(_args
, ""))
1279 static PyObject
*Menu_InvalMenuBar(_self
, _args
)
1283 PyObject
*_res
= NULL
;
1284 if (!PyArg_ParseTuple(_args
, ""))
1292 static PyObject
*Menu_InitProcMenu(_self
, _args
)
1296 PyObject
*_res
= NULL
;
1298 if (!PyArg_ParseTuple(_args
, "h",
1301 InitProcMenu(resID
);
1307 static PyObject
*Menu_GetMenuBar(_self
, _args
)
1311 PyObject
*_res
= NULL
;
1313 if (!PyArg_ParseTuple(_args
, ""))
1316 _res
= Py_BuildValue("O&",
1321 static PyObject
*Menu_SetMenuBar(_self
, _args
)
1325 PyObject
*_res
= NULL
;
1327 if (!PyArg_ParseTuple(_args
, "O&",
1328 ResObj_Convert
, &menuList
))
1330 SetMenuBar(menuList
);
1336 static PyObject
*Menu_SystemEdit(_self
, _args
)
1340 PyObject
*_res
= NULL
;
1343 if (!PyArg_ParseTuple(_args
, "h",
1346 _rv
= SystemEdit(editCmd
);
1347 _res
= Py_BuildValue("b",
1352 static PyObject
*Menu_SystemMenu(_self
, _args
)
1356 PyObject
*_res
= NULL
;
1358 if (!PyArg_ParseTuple(_args
, "l",
1361 SystemMenu(menuResult
);
1367 static PyObject
*Menu_GetNewMBar(_self
, _args
)
1371 PyObject
*_res
= NULL
;
1374 if (!PyArg_ParseTuple(_args
, "h",
1377 _rv
= GetNewMBar(menuBarID
);
1378 _res
= Py_BuildValue("O&",
1383 static PyObject
*Menu_ClearMenuBar(_self
, _args
)
1387 PyObject
*_res
= NULL
;
1388 if (!PyArg_ParseTuple(_args
, ""))
1396 static PyObject
*Menu_SetMenuFlash(_self
, _args
)
1400 PyObject
*_res
= NULL
;
1402 if (!PyArg_ParseTuple(_args
, "h",
1405 SetMenuFlash(count
);
1411 static PyObject
*Menu_MenuSelect(_self
, _args
)
1415 PyObject
*_res
= NULL
;
1418 if (!PyArg_ParseTuple(_args
, "O&",
1419 PyMac_GetPoint
, &startPt
))
1421 _rv
= MenuSelect(startPt
);
1422 _res
= Py_BuildValue("l",
1427 static PyObject
*Menu_MenuEvent(_self
, _args
)
1431 PyObject
*_res
= NULL
;
1433 EventRecord inEvent
;
1434 if (!PyArg_ParseTuple(_args
, "O&",
1435 PyMac_GetEventRecord
, &inEvent
))
1437 _rv
= MenuEvent(&inEvent
);
1438 _res
= Py_BuildValue("l",
1443 static PyObject
*Menu_OpenDeskAcc(_self
, _args
)
1447 PyObject
*_res
= NULL
;
1449 if (!PyArg_ParseTuple(_args
, "O&",
1450 PyMac_GetStr255
, name
))
1458 static PyObject
*Menu_GetMenu(_self
, _args
)
1462 PyObject
*_res
= NULL
;
1465 if (!PyArg_ParseTuple(_args
, "h",
1468 _rv
= GetMenu(resourceID
);
1469 _res
= Py_BuildValue("O&",
1474 static PyObject
*Menu_DeleteMenu(_self
, _args
)
1478 PyObject
*_res
= NULL
;
1480 if (!PyArg_ParseTuple(_args
, "h",
1489 static PyObject
*Menu_DrawMenuBar(_self
, _args
)
1493 PyObject
*_res
= NULL
;
1494 if (!PyArg_ParseTuple(_args
, ""))
1502 static PyMethodDef Menu_methods
[] = {
1503 {"GetMBarHeight", (PyCFunction
)Menu_GetMBarHeight
, 1,
1504 "() -> (short _rv)"},
1505 {"InitMenus", (PyCFunction
)Menu_InitMenus
, 1,
1507 {"NewMenu", (PyCFunction
)Menu_NewMenu
, 1,
1508 "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
1509 {"MacGetMenu", (PyCFunction
)Menu_MacGetMenu
, 1,
1510 "(short resourceID) -> (MenuHandle _rv)"},
1511 {"MacDeleteMenu", (PyCFunction
)Menu_MacDeleteMenu
, 1,
1512 "(short menuID) -> None"},
1513 {"MenuKey", (PyCFunction
)Menu_MenuKey
, 1,
1514 "(CharParameter ch) -> (long _rv)"},
1515 {"HiliteMenu", (PyCFunction
)Menu_HiliteMenu
, 1,
1516 "(short menuID) -> None"},
1517 {"GetMenuHandle", (PyCFunction
)Menu_GetMenuHandle
, 1,
1518 "(short menuID) -> (MenuHandle _rv)"},
1519 {"FlashMenuBar", (PyCFunction
)Menu_FlashMenuBar
, 1,
1520 "(short menuID) -> None"},
1521 {"MenuChoice", (PyCFunction
)Menu_MenuChoice
, 1,
1522 "() -> (long _rv)"},
1523 {"DeleteMCEntries", (PyCFunction
)Menu_DeleteMCEntries
, 1,
1524 "(short menuID, short menuItem) -> None"},
1525 {"MacDrawMenuBar", (PyCFunction
)Menu_MacDrawMenuBar
, 1,
1527 {"InvalMenuBar", (PyCFunction
)Menu_InvalMenuBar
, 1,
1529 {"InitProcMenu", (PyCFunction
)Menu_InitProcMenu
, 1,
1530 "(short resID) -> None"},
1531 {"GetMenuBar", (PyCFunction
)Menu_GetMenuBar
, 1,
1532 "() -> (Handle _rv)"},
1533 {"SetMenuBar", (PyCFunction
)Menu_SetMenuBar
, 1,
1534 "(Handle menuList) -> None"},
1535 {"SystemEdit", (PyCFunction
)Menu_SystemEdit
, 1,
1536 "(short editCmd) -> (Boolean _rv)"},
1537 {"SystemMenu", (PyCFunction
)Menu_SystemMenu
, 1,
1538 "(long menuResult) -> None"},
1539 {"GetNewMBar", (PyCFunction
)Menu_GetNewMBar
, 1,
1540 "(short menuBarID) -> (Handle _rv)"},
1541 {"ClearMenuBar", (PyCFunction
)Menu_ClearMenuBar
, 1,
1543 {"SetMenuFlash", (PyCFunction
)Menu_SetMenuFlash
, 1,
1544 "(short count) -> None"},
1545 {"MenuSelect", (PyCFunction
)Menu_MenuSelect
, 1,
1546 "(Point startPt) -> (long _rv)"},
1547 {"MenuEvent", (PyCFunction
)Menu_MenuEvent
, 1,
1548 "(EventRecord inEvent) -> (UInt32 _rv)"},
1549 {"OpenDeskAcc", (PyCFunction
)Menu_OpenDeskAcc
, 1,
1550 "(Str255 name) -> None"},
1551 {"GetMenu", (PyCFunction
)Menu_GetMenu
, 1,
1552 "(short resourceID) -> (MenuHandle _rv)"},
1553 {"DeleteMenu", (PyCFunction
)Menu_DeleteMenu
, 1,
1554 "(short menuID) -> None"},
1555 {"DrawMenuBar", (PyCFunction
)Menu_DrawMenuBar
, 1,
1571 m
= Py_InitModule("Menu", Menu_methods
);
1572 d
= PyModule_GetDict(m
);
1573 Menu_Error
= PyMac_GetOSErrException();
1574 if (Menu_Error
== NULL
||
1575 PyDict_SetItemString(d
, "Error", Menu_Error
) != 0)
1576 Py_FatalError("can't initialize Menu.Error");
1577 Menu_Type
.ob_type
= &PyType_Type
;
1578 Py_INCREF(&Menu_Type
);
1579 if (PyDict_SetItemString(d
, "MenuType", (PyObject
*)&Menu_Type
) != 0)
1580 Py_FatalError("can't initialize MenuType");
1583 /* ======================== End module Menu ========================= */