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_AppendMenu(_self
, _args
)
109 PyObject
*_res
= NULL
;
111 if (!PyArg_ParseTuple(_args
, "O&",
112 PyMac_GetStr255
, data
))
114 AppendMenu(_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_InsertMenu(_self
, _args
)
144 PyObject
*_res
= NULL
;
146 if (!PyArg_ParseTuple(_args
, "h",
149 InsertMenu(_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_InsertMenuItem(_self
, _args
)
176 PyObject
*_res
= NULL
;
179 if (!PyArg_ParseTuple(_args
, "O&h",
180 PyMac_GetStr255
, itemString
,
183 InsertMenuItem(_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 PyMethodDef MenuObj_methods
[] = {
920 {"DisposeMenu", (PyCFunction
)MenuObj_DisposeMenu
, 1,
922 {"AppendMenu", (PyCFunction
)MenuObj_AppendMenu
, 1,
923 "(Str255 data) -> None"},
924 {"InsertResMenu", (PyCFunction
)MenuObj_InsertResMenu
, 1,
925 "(ResType theType, short afterItem) -> None"},
926 {"InsertMenu", (PyCFunction
)MenuObj_InsertMenu
, 1,
927 "(short beforeID) -> None"},
928 {"AppendResMenu", (PyCFunction
)MenuObj_AppendResMenu
, 1,
929 "(ResType theType) -> None"},
930 {"InsertMenuItem", (PyCFunction
)MenuObj_InsertMenuItem
, 1,
931 "(Str255 itemString, short afterItem) -> None"},
932 {"DeleteMenuItem", (PyCFunction
)MenuObj_DeleteMenuItem
, 1,
933 "(short item) -> None"},
934 {"SetMenuItemText", (PyCFunction
)MenuObj_SetMenuItemText
, 1,
935 "(short item, Str255 itemString) -> None"},
936 {"GetMenuItemText", (PyCFunction
)MenuObj_GetMenuItemText
, 1,
937 "(short item) -> (Str255 itemString)"},
938 {"SetItemMark", (PyCFunction
)MenuObj_SetItemMark
, 1,
939 "(short item, CharParameter markChar) -> None"},
940 {"GetItemMark", (PyCFunction
)MenuObj_GetItemMark
, 1,
941 "(short item) -> (CharParameter markChar)"},
942 {"SetItemCmd", (PyCFunction
)MenuObj_SetItemCmd
, 1,
943 "(short item, CharParameter cmdChar) -> None"},
944 {"GetItemCmd", (PyCFunction
)MenuObj_GetItemCmd
, 1,
945 "(short item) -> (CharParameter cmdChar)"},
946 {"SetItemIcon", (PyCFunction
)MenuObj_SetItemIcon
, 1,
947 "(short item, short iconIndex) -> None"},
948 {"GetItemIcon", (PyCFunction
)MenuObj_GetItemIcon
, 1,
949 "(short item) -> (short iconIndex)"},
950 {"SetItemStyle", (PyCFunction
)MenuObj_SetItemStyle
, 1,
951 "(short item, StyleParameter chStyle) -> None"},
952 {"GetItemStyle", (PyCFunction
)MenuObj_GetItemStyle
, 1,
953 "(short item) -> (Style chStyle)"},
954 {"CalcMenuSize", (PyCFunction
)MenuObj_CalcMenuSize
, 1,
956 {"DisableItem", (PyCFunction
)MenuObj_DisableItem
, 1,
957 "(short item) -> None"},
958 {"EnableItem", (PyCFunction
)MenuObj_EnableItem
, 1,
959 "(short item) -> None"},
960 {"PopUpMenuSelect", (PyCFunction
)MenuObj_PopUpMenuSelect
, 1,
961 "(short top, short left, short popUpItem) -> (long _rv)"},
962 {"CheckItem", (PyCFunction
)MenuObj_CheckItem
, 1,
963 "(short item, Boolean checked) -> None"},
964 {"CountMItems", (PyCFunction
)MenuObj_CountMItems
, 1,
965 "() -> (short _rv)"},
966 {"InsertFontResMenu", (PyCFunction
)MenuObj_InsertFontResMenu
, 1,
967 "(short afterItem, short scriptFilter) -> None"},
968 {"InsertIntlResMenu", (PyCFunction
)MenuObj_InsertIntlResMenu
, 1,
969 "(ResType theType, short afterItem, short scriptFilter) -> None"},
970 {"SetMenuItemCommandID", (PyCFunction
)MenuObj_SetMenuItemCommandID
, 1,
971 "(SInt16 inItem, UInt32 inCommandID) -> None"},
972 {"GetMenuItemCommandID", (PyCFunction
)MenuObj_GetMenuItemCommandID
, 1,
973 "(SInt16 inItem) -> (UInt32 outCommandID)"},
974 {"SetMenuItemModifiers", (PyCFunction
)MenuObj_SetMenuItemModifiers
, 1,
975 "(SInt16 inItem, UInt8 inModifiers) -> None"},
976 {"GetMenuItemModifiers", (PyCFunction
)MenuObj_GetMenuItemModifiers
, 1,
977 "(SInt16 inItem) -> (UInt8 outModifiers)"},
978 {"SetMenuItemIconHandle", (PyCFunction
)MenuObj_SetMenuItemIconHandle
, 1,
979 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
980 {"GetMenuItemIconHandle", (PyCFunction
)MenuObj_GetMenuItemIconHandle
, 1,
981 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
982 {"SetMenuItemTextEncoding", (PyCFunction
)MenuObj_SetMenuItemTextEncoding
, 1,
983 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
984 {"GetMenuItemTextEncoding", (PyCFunction
)MenuObj_GetMenuItemTextEncoding
, 1,
985 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
986 {"SetMenuItemHierarchicalID", (PyCFunction
)MenuObj_SetMenuItemHierarchicalID
, 1,
987 "(SInt16 inItem, SInt16 inHierID) -> None"},
988 {"GetMenuItemHierarchicalID", (PyCFunction
)MenuObj_GetMenuItemHierarchicalID
, 1,
989 "(SInt16 inItem) -> (SInt16 outHierID)"},
990 {"SetMenuItemFontID", (PyCFunction
)MenuObj_SetMenuItemFontID
, 1,
991 "(SInt16 inItem, SInt16 inFontID) -> None"},
992 {"GetMenuItemFontID", (PyCFunction
)MenuObj_GetMenuItemFontID
, 1,
993 "(SInt16 inItem) -> (SInt16 outFontID)"},
994 {"SetMenuItemRefCon", (PyCFunction
)MenuObj_SetMenuItemRefCon
, 1,
995 "(SInt16 inItem, UInt32 inRefCon) -> None"},
996 {"GetMenuItemRefCon", (PyCFunction
)MenuObj_GetMenuItemRefCon
, 1,
997 "(SInt16 inItem) -> (UInt32 outRefCon)"},
998 {"SetMenuItemRefCon2", (PyCFunction
)MenuObj_SetMenuItemRefCon2
, 1,
999 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1000 {"GetMenuItemRefCon2", (PyCFunction
)MenuObj_GetMenuItemRefCon2
, 1,
1001 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1002 {"SetMenuItemKeyGlyph", (PyCFunction
)MenuObj_SetMenuItemKeyGlyph
, 1,
1003 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1004 {"GetMenuItemKeyGlyph", (PyCFunction
)MenuObj_GetMenuItemKeyGlyph
, 1,
1005 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1006 {"as_Resource", (PyCFunction
)MenuObj_as_Resource
, 1,
1007 "Return this Menu as a Resource"},
1011 PyMethodChain MenuObj_chain
= { MenuObj_methods
, NULL
};
1013 static PyObject
*MenuObj_getattr(self
, name
)
1017 return Py_FindMethodInChain(&MenuObj_chain
, (PyObject
*)self
, name
);
1020 #define MenuObj_setattr NULL
1022 PyTypeObject Menu_Type
= {
1023 PyObject_HEAD_INIT(&PyType_Type
)
1026 sizeof(MenuObject
), /*tp_basicsize*/
1029 (destructor
) MenuObj_dealloc
, /*tp_dealloc*/
1031 (getattrfunc
) MenuObj_getattr
, /*tp_getattr*/
1032 (setattrfunc
) MenuObj_setattr
, /*tp_setattr*/
1035 /* ---------------------- End object type Menu ---------------------- */
1038 static PyObject
*Menu_GetMBarHeight(_self
, _args
)
1042 PyObject
*_res
= NULL
;
1044 if (!PyArg_ParseTuple(_args
, ""))
1046 _rv
= GetMBarHeight();
1047 _res
= Py_BuildValue("h",
1052 static PyObject
*Menu_InitMenus(_self
, _args
)
1056 PyObject
*_res
= NULL
;
1057 if (!PyArg_ParseTuple(_args
, ""))
1065 static PyObject
*Menu_NewMenu(_self
, _args
)
1069 PyObject
*_res
= NULL
;
1073 if (!PyArg_ParseTuple(_args
, "hO&",
1075 PyMac_GetStr255
, menuTitle
))
1077 _rv
= NewMenu(menuID
,
1079 _res
= Py_BuildValue("O&",
1084 static PyObject
*Menu_GetMenu(_self
, _args
)
1088 PyObject
*_res
= NULL
;
1091 if (!PyArg_ParseTuple(_args
, "h",
1094 _rv
= GetMenu(resourceID
);
1095 _res
= Py_BuildValue("O&",
1100 static PyObject
*Menu_DeleteMenu(_self
, _args
)
1104 PyObject
*_res
= NULL
;
1106 if (!PyArg_ParseTuple(_args
, "h",
1115 static PyObject
*Menu_MenuKey(_self
, _args
)
1119 PyObject
*_res
= NULL
;
1122 if (!PyArg_ParseTuple(_args
, "h",
1126 _res
= Py_BuildValue("l",
1131 static PyObject
*Menu_HiliteMenu(_self
, _args
)
1135 PyObject
*_res
= NULL
;
1137 if (!PyArg_ParseTuple(_args
, "h",
1146 static PyObject
*Menu_GetMenuHandle(_self
, _args
)
1150 PyObject
*_res
= NULL
;
1153 if (!PyArg_ParseTuple(_args
, "h",
1156 _rv
= GetMenuHandle(menuID
);
1157 _res
= Py_BuildValue("O&",
1162 static PyObject
*Menu_FlashMenuBar(_self
, _args
)
1166 PyObject
*_res
= NULL
;
1168 if (!PyArg_ParseTuple(_args
, "h",
1171 FlashMenuBar(menuID
);
1177 static PyObject
*Menu_MenuChoice(_self
, _args
)
1181 PyObject
*_res
= NULL
;
1183 if (!PyArg_ParseTuple(_args
, ""))
1186 _res
= Py_BuildValue("l",
1191 static PyObject
*Menu_DeleteMCEntries(_self
, _args
)
1195 PyObject
*_res
= NULL
;
1198 if (!PyArg_ParseTuple(_args
, "hh",
1202 DeleteMCEntries(menuID
,
1209 static PyObject
*Menu_DrawMenuBar(_self
, _args
)
1213 PyObject
*_res
= NULL
;
1214 if (!PyArg_ParseTuple(_args
, ""))
1222 static PyObject
*Menu_InvalMenuBar(_self
, _args
)
1226 PyObject
*_res
= NULL
;
1227 if (!PyArg_ParseTuple(_args
, ""))
1235 static PyObject
*Menu_InitProcMenu(_self
, _args
)
1239 PyObject
*_res
= NULL
;
1241 if (!PyArg_ParseTuple(_args
, "h",
1244 InitProcMenu(resID
);
1250 static PyObject
*Menu_GetMenuBar(_self
, _args
)
1254 PyObject
*_res
= NULL
;
1256 if (!PyArg_ParseTuple(_args
, ""))
1259 _res
= Py_BuildValue("O&",
1264 static PyObject
*Menu_SetMenuBar(_self
, _args
)
1268 PyObject
*_res
= NULL
;
1270 if (!PyArg_ParseTuple(_args
, "O&",
1271 ResObj_Convert
, &menuList
))
1273 SetMenuBar(menuList
);
1279 static PyObject
*Menu_SystemEdit(_self
, _args
)
1283 PyObject
*_res
= NULL
;
1286 if (!PyArg_ParseTuple(_args
, "h",
1289 _rv
= SystemEdit(editCmd
);
1290 _res
= Py_BuildValue("b",
1295 static PyObject
*Menu_SystemMenu(_self
, _args
)
1299 PyObject
*_res
= NULL
;
1301 if (!PyArg_ParseTuple(_args
, "l",
1304 SystemMenu(menuResult
);
1310 static PyObject
*Menu_GetNewMBar(_self
, _args
)
1314 PyObject
*_res
= NULL
;
1317 if (!PyArg_ParseTuple(_args
, "h",
1320 _rv
= GetNewMBar(menuBarID
);
1321 _res
= Py_BuildValue("O&",
1326 static PyObject
*Menu_ClearMenuBar(_self
, _args
)
1330 PyObject
*_res
= NULL
;
1331 if (!PyArg_ParseTuple(_args
, ""))
1339 static PyObject
*Menu_SetMenuFlash(_self
, _args
)
1343 PyObject
*_res
= NULL
;
1345 if (!PyArg_ParseTuple(_args
, "h",
1348 SetMenuFlash(count
);
1354 static PyObject
*Menu_MenuSelect(_self
, _args
)
1358 PyObject
*_res
= NULL
;
1361 if (!PyArg_ParseTuple(_args
, "O&",
1362 PyMac_GetPoint
, &startPt
))
1364 _rv
= MenuSelect(startPt
);
1365 _res
= Py_BuildValue("l",
1370 static PyObject
*Menu_MenuEvent(_self
, _args
)
1374 PyObject
*_res
= NULL
;
1376 EventRecord inEvent
;
1377 if (!PyArg_ParseTuple(_args
, "O&",
1378 PyMac_GetEventRecord
, &inEvent
))
1380 _rv
= MenuEvent(&inEvent
);
1381 _res
= Py_BuildValue("l",
1386 static PyObject
*Menu_OpenDeskAcc(_self
, _args
)
1390 PyObject
*_res
= NULL
;
1392 if (!PyArg_ParseTuple(_args
, "O&",
1393 PyMac_GetStr255
, name
))
1401 static PyMethodDef Menu_methods
[] = {
1402 {"GetMBarHeight", (PyCFunction
)Menu_GetMBarHeight
, 1,
1403 "() -> (short _rv)"},
1404 {"InitMenus", (PyCFunction
)Menu_InitMenus
, 1,
1406 {"NewMenu", (PyCFunction
)Menu_NewMenu
, 1,
1407 "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
1408 {"GetMenu", (PyCFunction
)Menu_GetMenu
, 1,
1409 "(short resourceID) -> (MenuHandle _rv)"},
1410 {"DeleteMenu", (PyCFunction
)Menu_DeleteMenu
, 1,
1411 "(short menuID) -> None"},
1412 {"MenuKey", (PyCFunction
)Menu_MenuKey
, 1,
1413 "(CharParameter ch) -> (long _rv)"},
1414 {"HiliteMenu", (PyCFunction
)Menu_HiliteMenu
, 1,
1415 "(short menuID) -> None"},
1416 {"GetMenuHandle", (PyCFunction
)Menu_GetMenuHandle
, 1,
1417 "(short menuID) -> (MenuHandle _rv)"},
1418 {"FlashMenuBar", (PyCFunction
)Menu_FlashMenuBar
, 1,
1419 "(short menuID) -> None"},
1420 {"MenuChoice", (PyCFunction
)Menu_MenuChoice
, 1,
1421 "() -> (long _rv)"},
1422 {"DeleteMCEntries", (PyCFunction
)Menu_DeleteMCEntries
, 1,
1423 "(short menuID, short menuItem) -> None"},
1424 {"DrawMenuBar", (PyCFunction
)Menu_DrawMenuBar
, 1,
1426 {"InvalMenuBar", (PyCFunction
)Menu_InvalMenuBar
, 1,
1428 {"InitProcMenu", (PyCFunction
)Menu_InitProcMenu
, 1,
1429 "(short resID) -> None"},
1430 {"GetMenuBar", (PyCFunction
)Menu_GetMenuBar
, 1,
1431 "() -> (Handle _rv)"},
1432 {"SetMenuBar", (PyCFunction
)Menu_SetMenuBar
, 1,
1433 "(Handle menuList) -> None"},
1434 {"SystemEdit", (PyCFunction
)Menu_SystemEdit
, 1,
1435 "(short editCmd) -> (Boolean _rv)"},
1436 {"SystemMenu", (PyCFunction
)Menu_SystemMenu
, 1,
1437 "(long menuResult) -> None"},
1438 {"GetNewMBar", (PyCFunction
)Menu_GetNewMBar
, 1,
1439 "(short menuBarID) -> (Handle _rv)"},
1440 {"ClearMenuBar", (PyCFunction
)Menu_ClearMenuBar
, 1,
1442 {"SetMenuFlash", (PyCFunction
)Menu_SetMenuFlash
, 1,
1443 "(short count) -> None"},
1444 {"MenuSelect", (PyCFunction
)Menu_MenuSelect
, 1,
1445 "(Point startPt) -> (long _rv)"},
1446 {"MenuEvent", (PyCFunction
)Menu_MenuEvent
, 1,
1447 "(EventRecord inEvent) -> (UInt32 _rv)"},
1448 {"OpenDeskAcc", (PyCFunction
)Menu_OpenDeskAcc
, 1,
1449 "(Str255 name) -> None"},
1464 m
= Py_InitModule("Menu", Menu_methods
);
1465 d
= PyModule_GetDict(m
);
1466 Menu_Error
= PyMac_GetOSErrException();
1467 if (Menu_Error
== NULL
||
1468 PyDict_SetItemString(d
, "Error", Menu_Error
) != 0)
1469 Py_FatalError("can't initialize Menu.Error");
1470 Menu_Type
.ob_type
= &PyType_Type
;
1471 Py_INCREF(&Menu_Type
);
1472 if (PyDict_SetItemString(d
, "MenuType", (PyObject
*)&Menu_Type
) != 0)
1473 Py_FatalError("can't initialize MenuType");
1476 /* ======================== End module Menu ========================= */