2 /* ========================== Module Menu =========================== */
9 #include "pymactoolbox.h"
11 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
14 #define as_Menu(h) ((MenuHandle)h)
15 #define as_Resource(h) ((Handle)h)
17 static PyObject
*Menu_Error
;
19 /* ------------------------ Object type Menu ------------------------ */
21 PyTypeObject Menu_Type
;
23 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
25 typedef struct MenuObject
{
30 PyObject
*MenuObj_New(itself
)
34 it
= PyObject_NEW(MenuObject
, &Menu_Type
);
35 if (it
== NULL
) return NULL
;
36 it
->ob_itself
= itself
;
37 return (PyObject
*)it
;
39 MenuObj_Convert(v
, p_itself
)
43 if (!MenuObj_Check(v
))
45 PyErr_SetString(PyExc_TypeError
, "Menu required");
48 *p_itself
= ((MenuObject
*)v
)->ob_itself
;
52 static void MenuObj_dealloc(self
)
55 /* Cleanup of self->ob_itself goes here */
59 static PyObject
*MenuObj_DisposeMenu(_self
, _args
)
63 PyObject
*_res
= NULL
;
64 if (!PyArg_ParseTuple(_args
, ""))
66 DisposeMenu(_self
->ob_itself
);
72 static PyObject
*MenuObj_CalcMenuSize(_self
, _args
)
76 PyObject
*_res
= NULL
;
77 if (!PyArg_ParseTuple(_args
, ""))
79 CalcMenuSize(_self
->ob_itself
);
85 #if !TARGET_API_MAC_CARBON
87 static PyObject
*MenuObj_CountMItems(_self
, _args
)
91 PyObject
*_res
= NULL
;
93 if (!PyArg_ParseTuple(_args
, ""))
95 _rv
= CountMItems(_self
->ob_itself
);
96 _res
= Py_BuildValue("h",
102 static PyObject
*MenuObj_GetMenuFont(_self
, _args
)
106 PyObject
*_res
= NULL
;
110 if (!PyArg_ParseTuple(_args
, ""))
112 _err
= GetMenuFont(_self
->ob_itself
,
115 if (_err
!= noErr
) return PyMac_Error(_err
);
116 _res
= Py_BuildValue("hH",
122 static PyObject
*MenuObj_SetMenuFont(_self
, _args
)
126 PyObject
*_res
= NULL
;
130 if (!PyArg_ParseTuple(_args
, "hH",
134 _err
= SetMenuFont(_self
->ob_itself
,
137 if (_err
!= noErr
) return PyMac_Error(_err
);
143 static PyObject
*MenuObj_GetMenuExcludesMarkColumn(_self
, _args
)
147 PyObject
*_res
= NULL
;
149 if (!PyArg_ParseTuple(_args
, ""))
151 _rv
= GetMenuExcludesMarkColumn(_self
->ob_itself
);
152 _res
= Py_BuildValue("b",
157 static PyObject
*MenuObj_SetMenuExcludesMarkColumn(_self
, _args
)
161 PyObject
*_res
= NULL
;
163 Boolean excludesMark
;
164 if (!PyArg_ParseTuple(_args
, "b",
167 _err
= SetMenuExcludesMarkColumn(_self
->ob_itself
,
169 if (_err
!= noErr
) return PyMac_Error(_err
);
175 static PyObject
*MenuObj_MacAppendMenu(_self
, _args
)
179 PyObject
*_res
= NULL
;
181 if (!PyArg_ParseTuple(_args
, "O&",
182 PyMac_GetStr255
, data
))
184 MacAppendMenu(_self
->ob_itself
,
191 static PyObject
*MenuObj_InsertResMenu(_self
, _args
)
195 PyObject
*_res
= NULL
;
198 if (!PyArg_ParseTuple(_args
, "O&h",
199 PyMac_GetOSType
, &theType
,
202 InsertResMenu(_self
->ob_itself
,
210 static PyObject
*MenuObj_AppendResMenu(_self
, _args
)
214 PyObject
*_res
= NULL
;
216 if (!PyArg_ParseTuple(_args
, "O&",
217 PyMac_GetOSType
, &theType
))
219 AppendResMenu(_self
->ob_itself
,
226 static PyObject
*MenuObj_MacInsertMenuItem(_self
, _args
)
230 PyObject
*_res
= NULL
;
233 if (!PyArg_ParseTuple(_args
, "O&h",
234 PyMac_GetStr255
, itemString
,
237 MacInsertMenuItem(_self
->ob_itself
,
245 static PyObject
*MenuObj_DeleteMenuItem(_self
, _args
)
249 PyObject
*_res
= NULL
;
251 if (!PyArg_ParseTuple(_args
, "h",
254 DeleteMenuItem(_self
->ob_itself
,
261 static PyObject
*MenuObj_InsertFontResMenu(_self
, _args
)
265 PyObject
*_res
= NULL
;
268 if (!PyArg_ParseTuple(_args
, "hh",
272 InsertFontResMenu(_self
->ob_itself
,
280 static PyObject
*MenuObj_InsertIntlResMenu(_self
, _args
)
284 PyObject
*_res
= NULL
;
288 if (!PyArg_ParseTuple(_args
, "O&hh",
289 PyMac_GetOSType
, &theType
,
293 InsertIntlResMenu(_self
->ob_itself
,
302 static PyObject
*MenuObj_AppendMenuItemText(_self
, _args
)
306 PyObject
*_res
= NULL
;
309 if (!PyArg_ParseTuple(_args
, "O&",
310 PyMac_GetStr255
, inString
))
312 _err
= AppendMenuItemText(_self
->ob_itself
,
314 if (_err
!= noErr
) return PyMac_Error(_err
);
320 static PyObject
*MenuObj_InsertMenuItemText(_self
, _args
)
324 PyObject
*_res
= NULL
;
328 if (!PyArg_ParseTuple(_args
, "O&H",
329 PyMac_GetStr255
, inString
,
332 _err
= InsertMenuItemText(_self
->ob_itself
,
335 if (_err
!= noErr
) return PyMac_Error(_err
);
341 static PyObject
*MenuObj_PopUpMenuSelect(_self
, _args
)
345 PyObject
*_res
= NULL
;
350 if (!PyArg_ParseTuple(_args
, "hhh",
355 _rv
= PopUpMenuSelect(_self
->ob_itself
,
359 _res
= Py_BuildValue("l",
364 static PyObject
*MenuObj_MacInsertMenu(_self
, _args
)
368 PyObject
*_res
= NULL
;
370 if (!PyArg_ParseTuple(_args
, "h",
373 MacInsertMenu(_self
->ob_itself
,
380 #if !TARGET_API_MAC_CARBON
382 static PyObject
*MenuObj_CheckItem(_self
, _args
)
386 PyObject
*_res
= NULL
;
389 if (!PyArg_ParseTuple(_args
, "hb",
393 CheckItem(_self
->ob_itself
,
402 static PyObject
*MenuObj_SetMenuItemText(_self
, _args
)
406 PyObject
*_res
= NULL
;
409 if (!PyArg_ParseTuple(_args
, "hO&",
411 PyMac_GetStr255
, itemString
))
413 SetMenuItemText(_self
->ob_itself
,
421 static PyObject
*MenuObj_GetMenuItemText(_self
, _args
)
425 PyObject
*_res
= NULL
;
428 if (!PyArg_ParseTuple(_args
, "h",
431 GetMenuItemText(_self
->ob_itself
,
434 _res
= Py_BuildValue("O&",
435 PyMac_BuildStr255
, itemString
);
439 static PyObject
*MenuObj_SetItemMark(_self
, _args
)
443 PyObject
*_res
= NULL
;
445 CharParameter markChar
;
446 if (!PyArg_ParseTuple(_args
, "hh",
450 SetItemMark(_self
->ob_itself
,
458 static PyObject
*MenuObj_GetItemMark(_self
, _args
)
462 PyObject
*_res
= NULL
;
464 CharParameter markChar
;
465 if (!PyArg_ParseTuple(_args
, "h",
468 GetItemMark(_self
->ob_itself
,
471 _res
= Py_BuildValue("h",
476 static PyObject
*MenuObj_SetItemCmd(_self
, _args
)
480 PyObject
*_res
= NULL
;
482 CharParameter cmdChar
;
483 if (!PyArg_ParseTuple(_args
, "hh",
487 SetItemCmd(_self
->ob_itself
,
495 static PyObject
*MenuObj_GetItemCmd(_self
, _args
)
499 PyObject
*_res
= NULL
;
501 CharParameter cmdChar
;
502 if (!PyArg_ParseTuple(_args
, "h",
505 GetItemCmd(_self
->ob_itself
,
508 _res
= Py_BuildValue("h",
513 static PyObject
*MenuObj_SetItemIcon(_self
, _args
)
517 PyObject
*_res
= NULL
;
520 if (!PyArg_ParseTuple(_args
, "hh",
524 SetItemIcon(_self
->ob_itself
,
532 static PyObject
*MenuObj_GetItemIcon(_self
, _args
)
536 PyObject
*_res
= NULL
;
539 if (!PyArg_ParseTuple(_args
, "h",
542 GetItemIcon(_self
->ob_itself
,
545 _res
= Py_BuildValue("h",
550 static PyObject
*MenuObj_SetItemStyle(_self
, _args
)
554 PyObject
*_res
= NULL
;
556 StyleParameter chStyle
;
557 if (!PyArg_ParseTuple(_args
, "hh",
561 SetItemStyle(_self
->ob_itself
,
569 static PyObject
*MenuObj_GetItemStyle(_self
, _args
)
573 PyObject
*_res
= NULL
;
576 if (!PyArg_ParseTuple(_args
, "h",
579 GetItemStyle(_self
->ob_itself
,
582 _res
= Py_BuildValue("b",
587 #if !TARGET_API_MAC_CARBON
589 static PyObject
*MenuObj_DisableItem(_self
, _args
)
593 PyObject
*_res
= NULL
;
595 if (!PyArg_ParseTuple(_args
, "h",
598 DisableItem(_self
->ob_itself
,
606 #if !TARGET_API_MAC_CARBON
608 static PyObject
*MenuObj_EnableItem(_self
, _args
)
612 PyObject
*_res
= NULL
;
614 if (!PyArg_ParseTuple(_args
, "h",
617 EnableItem(_self
->ob_itself
,
625 static PyObject
*MenuObj_SetMenuItemCommandID(_self
, _args
)
629 PyObject
*_res
= NULL
;
633 if (!PyArg_ParseTuple(_args
, "hl",
637 _err
= SetMenuItemCommandID(_self
->ob_itself
,
640 if (_err
!= noErr
) return PyMac_Error(_err
);
646 static PyObject
*MenuObj_GetMenuItemCommandID(_self
, _args
)
650 PyObject
*_res
= NULL
;
654 if (!PyArg_ParseTuple(_args
, "h",
657 _err
= GetMenuItemCommandID(_self
->ob_itself
,
660 if (_err
!= noErr
) return PyMac_Error(_err
);
661 _res
= Py_BuildValue("l",
666 static PyObject
*MenuObj_SetMenuItemModifiers(_self
, _args
)
670 PyObject
*_res
= NULL
;
674 if (!PyArg_ParseTuple(_args
, "hb",
678 _err
= SetMenuItemModifiers(_self
->ob_itself
,
681 if (_err
!= noErr
) return PyMac_Error(_err
);
687 static PyObject
*MenuObj_GetMenuItemModifiers(_self
, _args
)
691 PyObject
*_res
= NULL
;
695 if (!PyArg_ParseTuple(_args
, "h",
698 _err
= GetMenuItemModifiers(_self
->ob_itself
,
701 if (_err
!= noErr
) return PyMac_Error(_err
);
702 _res
= Py_BuildValue("b",
707 static PyObject
*MenuObj_SetMenuItemIconHandle(_self
, _args
)
711 PyObject
*_res
= NULL
;
716 if (!PyArg_ParseTuple(_args
, "hbO&",
719 ResObj_Convert
, &inIconHandle
))
721 _err
= SetMenuItemIconHandle(_self
->ob_itself
,
725 if (_err
!= noErr
) return PyMac_Error(_err
);
731 static PyObject
*MenuObj_GetMenuItemIconHandle(_self
, _args
)
735 PyObject
*_res
= NULL
;
739 Handle outIconHandle
;
740 if (!PyArg_ParseTuple(_args
, "h",
743 _err
= GetMenuItemIconHandle(_self
->ob_itself
,
747 if (_err
!= noErr
) return PyMac_Error(_err
);
748 _res
= Py_BuildValue("bO&",
750 ResObj_New
, outIconHandle
);
754 static PyObject
*MenuObj_SetMenuItemTextEncoding(_self
, _args
)
758 PyObject
*_res
= NULL
;
761 TextEncoding inScriptID
;
762 if (!PyArg_ParseTuple(_args
, "hl",
766 _err
= SetMenuItemTextEncoding(_self
->ob_itself
,
769 if (_err
!= noErr
) return PyMac_Error(_err
);
775 static PyObject
*MenuObj_GetMenuItemTextEncoding(_self
, _args
)
779 PyObject
*_res
= NULL
;
782 TextEncoding outScriptID
;
783 if (!PyArg_ParseTuple(_args
, "h",
786 _err
= GetMenuItemTextEncoding(_self
->ob_itself
,
789 if (_err
!= noErr
) return PyMac_Error(_err
);
790 _res
= Py_BuildValue("l",
795 static PyObject
*MenuObj_SetMenuItemHierarchicalID(_self
, _args
)
799 PyObject
*_res
= NULL
;
803 if (!PyArg_ParseTuple(_args
, "hh",
807 _err
= SetMenuItemHierarchicalID(_self
->ob_itself
,
810 if (_err
!= noErr
) return PyMac_Error(_err
);
816 static PyObject
*MenuObj_GetMenuItemHierarchicalID(_self
, _args
)
820 PyObject
*_res
= NULL
;
824 if (!PyArg_ParseTuple(_args
, "h",
827 _err
= GetMenuItemHierarchicalID(_self
->ob_itself
,
830 if (_err
!= noErr
) return PyMac_Error(_err
);
831 _res
= Py_BuildValue("h",
836 static PyObject
*MenuObj_SetMenuItemFontID(_self
, _args
)
840 PyObject
*_res
= NULL
;
844 if (!PyArg_ParseTuple(_args
, "hh",
848 _err
= SetMenuItemFontID(_self
->ob_itself
,
851 if (_err
!= noErr
) return PyMac_Error(_err
);
857 static PyObject
*MenuObj_GetMenuItemFontID(_self
, _args
)
861 PyObject
*_res
= NULL
;
865 if (!PyArg_ParseTuple(_args
, "h",
868 _err
= GetMenuItemFontID(_self
->ob_itself
,
871 if (_err
!= noErr
) return PyMac_Error(_err
);
872 _res
= Py_BuildValue("h",
877 static PyObject
*MenuObj_SetMenuItemRefCon(_self
, _args
)
881 PyObject
*_res
= NULL
;
885 if (!PyArg_ParseTuple(_args
, "hl",
889 _err
= SetMenuItemRefCon(_self
->ob_itself
,
892 if (_err
!= noErr
) return PyMac_Error(_err
);
898 static PyObject
*MenuObj_GetMenuItemRefCon(_self
, _args
)
902 PyObject
*_res
= NULL
;
906 if (!PyArg_ParseTuple(_args
, "h",
909 _err
= GetMenuItemRefCon(_self
->ob_itself
,
912 if (_err
!= noErr
) return PyMac_Error(_err
);
913 _res
= Py_BuildValue("l",
918 #if !TARGET_API_MAC_CARBON
920 static PyObject
*MenuObj_SetMenuItemRefCon2(_self
, _args
)
924 PyObject
*_res
= NULL
;
928 if (!PyArg_ParseTuple(_args
, "hl",
932 _err
= SetMenuItemRefCon2(_self
->ob_itself
,
935 if (_err
!= noErr
) return PyMac_Error(_err
);
942 #if !TARGET_API_MAC_CARBON
944 static PyObject
*MenuObj_GetMenuItemRefCon2(_self
, _args
)
948 PyObject
*_res
= NULL
;
952 if (!PyArg_ParseTuple(_args
, "h",
955 _err
= GetMenuItemRefCon2(_self
->ob_itself
,
958 if (_err
!= noErr
) return PyMac_Error(_err
);
959 _res
= Py_BuildValue("l",
965 static PyObject
*MenuObj_SetMenuItemKeyGlyph(_self
, _args
)
969 PyObject
*_res
= NULL
;
973 if (!PyArg_ParseTuple(_args
, "hh",
977 _err
= SetMenuItemKeyGlyph(_self
->ob_itself
,
980 if (_err
!= noErr
) return PyMac_Error(_err
);
986 static PyObject
*MenuObj_GetMenuItemKeyGlyph(_self
, _args
)
990 PyObject
*_res
= NULL
;
994 if (!PyArg_ParseTuple(_args
, "h",
997 _err
= GetMenuItemKeyGlyph(_self
->ob_itself
,
1000 if (_err
!= noErr
) return PyMac_Error(_err
);
1001 _res
= Py_BuildValue("h",
1006 static PyObject
*MenuObj_MacEnableMenuItem(_self
, _args
)
1010 PyObject
*_res
= NULL
;
1012 if (!PyArg_ParseTuple(_args
, "H",
1015 MacEnableMenuItem(_self
->ob_itself
,
1022 static PyObject
*MenuObj_DisableMenuItem(_self
, _args
)
1026 PyObject
*_res
= NULL
;
1028 if (!PyArg_ParseTuple(_args
, "H",
1031 DisableMenuItem(_self
->ob_itself
,
1038 static PyObject
*MenuObj_IsMenuItemEnabled(_self
, _args
)
1042 PyObject
*_res
= NULL
;
1045 if (!PyArg_ParseTuple(_args
, "H",
1048 _rv
= IsMenuItemEnabled(_self
->ob_itself
,
1050 _res
= Py_BuildValue("b",
1055 static PyObject
*MenuObj_EnableMenuItemIcon(_self
, _args
)
1059 PyObject
*_res
= NULL
;
1061 if (!PyArg_ParseTuple(_args
, "H",
1064 EnableMenuItemIcon(_self
->ob_itself
,
1071 static PyObject
*MenuObj_DisableMenuItemIcon(_self
, _args
)
1075 PyObject
*_res
= NULL
;
1077 if (!PyArg_ParseTuple(_args
, "H",
1080 DisableMenuItemIcon(_self
->ob_itself
,
1087 static PyObject
*MenuObj_IsMenuItemIconEnabled(_self
, _args
)
1091 PyObject
*_res
= NULL
;
1094 if (!PyArg_ParseTuple(_args
, "H",
1097 _rv
= IsMenuItemIconEnabled(_self
->ob_itself
,
1099 _res
= Py_BuildValue("b",
1104 static PyObject
*MenuObj_as_Resource(_self
, _args
)
1108 PyObject
*_res
= NULL
;
1110 if (!PyArg_ParseTuple(_args
, ""))
1112 _rv
= as_Resource(_self
->ob_itself
);
1113 _res
= Py_BuildValue("O&",
1118 static PyObject
*MenuObj_AppendMenu(_self
, _args
)
1122 PyObject
*_res
= NULL
;
1124 if (!PyArg_ParseTuple(_args
, "O&",
1125 PyMac_GetStr255
, data
))
1127 AppendMenu(_self
->ob_itself
,
1134 static PyObject
*MenuObj_InsertMenu(_self
, _args
)
1138 PyObject
*_res
= NULL
;
1140 if (!PyArg_ParseTuple(_args
, "h",
1143 InsertMenu(_self
->ob_itself
,
1150 static PyObject
*MenuObj_InsertMenuItem(_self
, _args
)
1154 PyObject
*_res
= NULL
;
1157 if (!PyArg_ParseTuple(_args
, "O&h",
1158 PyMac_GetStr255
, itemString
,
1161 InsertMenuItem(_self
->ob_itself
,
1169 static PyMethodDef MenuObj_methods
[] = {
1170 {"DisposeMenu", (PyCFunction
)MenuObj_DisposeMenu
, 1,
1172 {"CalcMenuSize", (PyCFunction
)MenuObj_CalcMenuSize
, 1,
1175 #if !TARGET_API_MAC_CARBON
1176 {"CountMItems", (PyCFunction
)MenuObj_CountMItems
, 1,
1177 "() -> (short _rv)"},
1179 {"GetMenuFont", (PyCFunction
)MenuObj_GetMenuFont
, 1,
1180 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1181 {"SetMenuFont", (PyCFunction
)MenuObj_SetMenuFont
, 1,
1182 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1183 {"GetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_GetMenuExcludesMarkColumn
, 1,
1184 "() -> (Boolean _rv)"},
1185 {"SetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_SetMenuExcludesMarkColumn
, 1,
1186 "(Boolean excludesMark) -> None"},
1187 {"MacAppendMenu", (PyCFunction
)MenuObj_MacAppendMenu
, 1,
1188 "(Str255 data) -> None"},
1189 {"InsertResMenu", (PyCFunction
)MenuObj_InsertResMenu
, 1,
1190 "(ResType theType, short afterItem) -> None"},
1191 {"AppendResMenu", (PyCFunction
)MenuObj_AppendResMenu
, 1,
1192 "(ResType theType) -> None"},
1193 {"MacInsertMenuItem", (PyCFunction
)MenuObj_MacInsertMenuItem
, 1,
1194 "(Str255 itemString, short afterItem) -> None"},
1195 {"DeleteMenuItem", (PyCFunction
)MenuObj_DeleteMenuItem
, 1,
1196 "(short item) -> None"},
1197 {"InsertFontResMenu", (PyCFunction
)MenuObj_InsertFontResMenu
, 1,
1198 "(short afterItem, short scriptFilter) -> None"},
1199 {"InsertIntlResMenu", (PyCFunction
)MenuObj_InsertIntlResMenu
, 1,
1200 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1201 {"AppendMenuItemText", (PyCFunction
)MenuObj_AppendMenuItemText
, 1,
1202 "(Str255 inString) -> None"},
1203 {"InsertMenuItemText", (PyCFunction
)MenuObj_InsertMenuItemText
, 1,
1204 "(Str255 inString, UInt16 afterItem) -> None"},
1205 {"PopUpMenuSelect", (PyCFunction
)MenuObj_PopUpMenuSelect
, 1,
1206 "(short top, short left, short popUpItem) -> (long _rv)"},
1207 {"MacInsertMenu", (PyCFunction
)MenuObj_MacInsertMenu
, 1,
1208 "(short beforeID) -> None"},
1210 #if !TARGET_API_MAC_CARBON
1211 {"CheckItem", (PyCFunction
)MenuObj_CheckItem
, 1,
1212 "(short item, Boolean checked) -> None"},
1214 {"SetMenuItemText", (PyCFunction
)MenuObj_SetMenuItemText
, 1,
1215 "(short item, Str255 itemString) -> None"},
1216 {"GetMenuItemText", (PyCFunction
)MenuObj_GetMenuItemText
, 1,
1217 "(short item) -> (Str255 itemString)"},
1218 {"SetItemMark", (PyCFunction
)MenuObj_SetItemMark
, 1,
1219 "(short item, CharParameter markChar) -> None"},
1220 {"GetItemMark", (PyCFunction
)MenuObj_GetItemMark
, 1,
1221 "(short item) -> (CharParameter markChar)"},
1222 {"SetItemCmd", (PyCFunction
)MenuObj_SetItemCmd
, 1,
1223 "(short item, CharParameter cmdChar) -> None"},
1224 {"GetItemCmd", (PyCFunction
)MenuObj_GetItemCmd
, 1,
1225 "(short item) -> (CharParameter cmdChar)"},
1226 {"SetItemIcon", (PyCFunction
)MenuObj_SetItemIcon
, 1,
1227 "(short item, short iconIndex) -> None"},
1228 {"GetItemIcon", (PyCFunction
)MenuObj_GetItemIcon
, 1,
1229 "(short item) -> (short iconIndex)"},
1230 {"SetItemStyle", (PyCFunction
)MenuObj_SetItemStyle
, 1,
1231 "(short item, StyleParameter chStyle) -> None"},
1232 {"GetItemStyle", (PyCFunction
)MenuObj_GetItemStyle
, 1,
1233 "(short item) -> (Style chStyle)"},
1235 #if !TARGET_API_MAC_CARBON
1236 {"DisableItem", (PyCFunction
)MenuObj_DisableItem
, 1,
1237 "(short item) -> None"},
1240 #if !TARGET_API_MAC_CARBON
1241 {"EnableItem", (PyCFunction
)MenuObj_EnableItem
, 1,
1242 "(short item) -> None"},
1244 {"SetMenuItemCommandID", (PyCFunction
)MenuObj_SetMenuItemCommandID
, 1,
1245 "(SInt16 inItem, UInt32 inCommandID) -> None"},
1246 {"GetMenuItemCommandID", (PyCFunction
)MenuObj_GetMenuItemCommandID
, 1,
1247 "(SInt16 inItem) -> (UInt32 outCommandID)"},
1248 {"SetMenuItemModifiers", (PyCFunction
)MenuObj_SetMenuItemModifiers
, 1,
1249 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1250 {"GetMenuItemModifiers", (PyCFunction
)MenuObj_GetMenuItemModifiers
, 1,
1251 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1252 {"SetMenuItemIconHandle", (PyCFunction
)MenuObj_SetMenuItemIconHandle
, 1,
1253 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1254 {"GetMenuItemIconHandle", (PyCFunction
)MenuObj_GetMenuItemIconHandle
, 1,
1255 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1256 {"SetMenuItemTextEncoding", (PyCFunction
)MenuObj_SetMenuItemTextEncoding
, 1,
1257 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1258 {"GetMenuItemTextEncoding", (PyCFunction
)MenuObj_GetMenuItemTextEncoding
, 1,
1259 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1260 {"SetMenuItemHierarchicalID", (PyCFunction
)MenuObj_SetMenuItemHierarchicalID
, 1,
1261 "(SInt16 inItem, SInt16 inHierID) -> None"},
1262 {"GetMenuItemHierarchicalID", (PyCFunction
)MenuObj_GetMenuItemHierarchicalID
, 1,
1263 "(SInt16 inItem) -> (SInt16 outHierID)"},
1264 {"SetMenuItemFontID", (PyCFunction
)MenuObj_SetMenuItemFontID
, 1,
1265 "(SInt16 inItem, SInt16 inFontID) -> None"},
1266 {"GetMenuItemFontID", (PyCFunction
)MenuObj_GetMenuItemFontID
, 1,
1267 "(SInt16 inItem) -> (SInt16 outFontID)"},
1268 {"SetMenuItemRefCon", (PyCFunction
)MenuObj_SetMenuItemRefCon
, 1,
1269 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1270 {"GetMenuItemRefCon", (PyCFunction
)MenuObj_GetMenuItemRefCon
, 1,
1271 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1273 #if !TARGET_API_MAC_CARBON
1274 {"SetMenuItemRefCon2", (PyCFunction
)MenuObj_SetMenuItemRefCon2
, 1,
1275 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1278 #if !TARGET_API_MAC_CARBON
1279 {"GetMenuItemRefCon2", (PyCFunction
)MenuObj_GetMenuItemRefCon2
, 1,
1280 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1282 {"SetMenuItemKeyGlyph", (PyCFunction
)MenuObj_SetMenuItemKeyGlyph
, 1,
1283 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1284 {"GetMenuItemKeyGlyph", (PyCFunction
)MenuObj_GetMenuItemKeyGlyph
, 1,
1285 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1286 {"MacEnableMenuItem", (PyCFunction
)MenuObj_MacEnableMenuItem
, 1,
1287 "(UInt16 item) -> None"},
1288 {"DisableMenuItem", (PyCFunction
)MenuObj_DisableMenuItem
, 1,
1289 "(UInt16 item) -> None"},
1290 {"IsMenuItemEnabled", (PyCFunction
)MenuObj_IsMenuItemEnabled
, 1,
1291 "(UInt16 item) -> (Boolean _rv)"},
1292 {"EnableMenuItemIcon", (PyCFunction
)MenuObj_EnableMenuItemIcon
, 1,
1293 "(UInt16 item) -> None"},
1294 {"DisableMenuItemIcon", (PyCFunction
)MenuObj_DisableMenuItemIcon
, 1,
1295 "(UInt16 item) -> None"},
1296 {"IsMenuItemIconEnabled", (PyCFunction
)MenuObj_IsMenuItemIconEnabled
, 1,
1297 "(UInt16 item) -> (Boolean _rv)"},
1298 {"as_Resource", (PyCFunction
)MenuObj_as_Resource
, 1,
1299 "() -> (Handle _rv)"},
1300 {"AppendMenu", (PyCFunction
)MenuObj_AppendMenu
, 1,
1301 "(Str255 data) -> None"},
1302 {"InsertMenu", (PyCFunction
)MenuObj_InsertMenu
, 1,
1303 "(short beforeID) -> None"},
1304 {"InsertMenuItem", (PyCFunction
)MenuObj_InsertMenuItem
, 1,
1305 "(Str255 itemString, short afterItem) -> None"},
1309 PyMethodChain MenuObj_chain
= { MenuObj_methods
, NULL
};
1311 static PyObject
*MenuObj_getattr(self
, name
)
1315 return Py_FindMethodInChain(&MenuObj_chain
, (PyObject
*)self
, name
);
1318 #define MenuObj_setattr NULL
1320 #define MenuObj_compare NULL
1322 #define MenuObj_repr NULL
1324 #define MenuObj_hash NULL
1326 PyTypeObject Menu_Type
= {
1327 PyObject_HEAD_INIT(&PyType_Type
)
1330 sizeof(MenuObject
), /*tp_basicsize*/
1333 (destructor
) MenuObj_dealloc
, /*tp_dealloc*/
1335 (getattrfunc
) MenuObj_getattr
, /*tp_getattr*/
1336 (setattrfunc
) MenuObj_setattr
, /*tp_setattr*/
1337 (cmpfunc
) MenuObj_compare
, /*tp_compare*/
1338 (reprfunc
) MenuObj_repr
, /*tp_repr*/
1339 (PyNumberMethods
*)0, /* tp_as_number */
1340 (PySequenceMethods
*)0, /* tp_as_sequence */
1341 (PyMappingMethods
*)0, /* tp_as_mapping */
1342 (hashfunc
) MenuObj_hash
, /*tp_hash*/
1345 /* ---------------------- End object type Menu ---------------------- */
1348 #if !TARGET_API_MAC_CARBON
1350 static PyObject
*Menu_InitProcMenu(_self
, _args
)
1354 PyObject
*_res
= NULL
;
1356 if (!PyArg_ParseTuple(_args
, "h",
1359 InitProcMenu(resID
);
1366 #if !TARGET_API_MAC_CARBON
1368 static PyObject
*Menu_InitMenus(_self
, _args
)
1372 PyObject
*_res
= NULL
;
1373 if (!PyArg_ParseTuple(_args
, ""))
1382 static PyObject
*Menu_NewMenu(_self
, _args
)
1386 PyObject
*_res
= NULL
;
1390 if (!PyArg_ParseTuple(_args
, "hO&",
1392 PyMac_GetStr255
, menuTitle
))
1394 _rv
= NewMenu(menuID
,
1396 _res
= Py_BuildValue("O&",
1401 static PyObject
*Menu_MacGetMenu(_self
, _args
)
1405 PyObject
*_res
= NULL
;
1408 if (!PyArg_ParseTuple(_args
, "h",
1411 _rv
= MacGetMenu(resourceID
);
1412 _res
= Py_BuildValue("O&",
1417 static PyObject
*Menu_MenuKey(_self
, _args
)
1421 PyObject
*_res
= NULL
;
1424 if (!PyArg_ParseTuple(_args
, "h",
1428 _res
= Py_BuildValue("l",
1433 static PyObject
*Menu_MenuSelect(_self
, _args
)
1437 PyObject
*_res
= NULL
;
1440 if (!PyArg_ParseTuple(_args
, "O&",
1441 PyMac_GetPoint
, &startPt
))
1443 _rv
= MenuSelect(startPt
);
1444 _res
= Py_BuildValue("l",
1449 static PyObject
*Menu_MenuChoice(_self
, _args
)
1453 PyObject
*_res
= NULL
;
1455 if (!PyArg_ParseTuple(_args
, ""))
1458 _res
= Py_BuildValue("l",
1463 static PyObject
*Menu_MenuEvent(_self
, _args
)
1467 PyObject
*_res
= NULL
;
1469 EventRecord inEvent
;
1470 if (!PyArg_ParseTuple(_args
, "O&",
1471 PyMac_GetEventRecord
, &inEvent
))
1473 _rv
= MenuEvent(&inEvent
);
1474 _res
= Py_BuildValue("l",
1479 static PyObject
*Menu_GetMBarHeight(_self
, _args
)
1483 PyObject
*_res
= NULL
;
1485 if (!PyArg_ParseTuple(_args
, ""))
1487 _rv
= GetMBarHeight();
1488 _res
= Py_BuildValue("h",
1493 static PyObject
*Menu_MacDrawMenuBar(_self
, _args
)
1497 PyObject
*_res
= NULL
;
1498 if (!PyArg_ParseTuple(_args
, ""))
1506 static PyObject
*Menu_InvalMenuBar(_self
, _args
)
1510 PyObject
*_res
= NULL
;
1511 if (!PyArg_ParseTuple(_args
, ""))
1519 static PyObject
*Menu_HiliteMenu(_self
, _args
)
1523 PyObject
*_res
= NULL
;
1525 if (!PyArg_ParseTuple(_args
, "h",
1534 static PyObject
*Menu_GetNewMBar(_self
, _args
)
1538 PyObject
*_res
= NULL
;
1541 if (!PyArg_ParseTuple(_args
, "h",
1544 _rv
= GetNewMBar(menuBarID
);
1545 _res
= Py_BuildValue("O&",
1550 static PyObject
*Menu_GetMenuBar(_self
, _args
)
1554 PyObject
*_res
= NULL
;
1556 if (!PyArg_ParseTuple(_args
, ""))
1559 _res
= Py_BuildValue("O&",
1564 static PyObject
*Menu_SetMenuBar(_self
, _args
)
1568 PyObject
*_res
= NULL
;
1570 if (!PyArg_ParseTuple(_args
, "O&",
1571 ResObj_Convert
, &menuList
))
1573 SetMenuBar(menuList
);
1579 static PyObject
*Menu_GetMenuHandle(_self
, _args
)
1583 PyObject
*_res
= NULL
;
1586 if (!PyArg_ParseTuple(_args
, "h",
1589 _rv
= GetMenuHandle(menuID
);
1590 _res
= Py_BuildValue("O&",
1595 static PyObject
*Menu_MacDeleteMenu(_self
, _args
)
1599 PyObject
*_res
= NULL
;
1601 if (!PyArg_ParseTuple(_args
, "h",
1604 MacDeleteMenu(menuID
);
1610 static PyObject
*Menu_ClearMenuBar(_self
, _args
)
1614 PyObject
*_res
= NULL
;
1615 if (!PyArg_ParseTuple(_args
, ""))
1623 #if !TARGET_API_MAC_CARBON
1625 static PyObject
*Menu_SetMenuFlash(_self
, _args
)
1629 PyObject
*_res
= NULL
;
1631 if (!PyArg_ParseTuple(_args
, "h",
1634 SetMenuFlash(count
);
1641 static PyObject
*Menu_FlashMenuBar(_self
, _args
)
1645 PyObject
*_res
= NULL
;
1647 if (!PyArg_ParseTuple(_args
, "h",
1650 FlashMenuBar(menuID
);
1656 #if !TARGET_API_MAC_CARBON
1658 static PyObject
*Menu_SystemEdit(_self
, _args
)
1662 PyObject
*_res
= NULL
;
1665 if (!PyArg_ParseTuple(_args
, "h",
1668 _rv
= SystemEdit(editCmd
);
1669 _res
= Py_BuildValue("b",
1675 #if !TARGET_API_MAC_CARBON
1677 static PyObject
*Menu_SystemMenu(_self
, _args
)
1681 PyObject
*_res
= NULL
;
1683 if (!PyArg_ParseTuple(_args
, "l",
1686 SystemMenu(menuResult
);
1693 static PyObject
*Menu_IsMenuBarVisible(_self
, _args
)
1697 PyObject
*_res
= NULL
;
1699 if (!PyArg_ParseTuple(_args
, ""))
1701 _rv
= IsMenuBarVisible();
1702 _res
= Py_BuildValue("b",
1707 static PyObject
*Menu_ShowMenuBar(_self
, _args
)
1711 PyObject
*_res
= NULL
;
1712 if (!PyArg_ParseTuple(_args
, ""))
1720 static PyObject
*Menu_HideMenuBar(_self
, _args
)
1724 PyObject
*_res
= NULL
;
1725 if (!PyArg_ParseTuple(_args
, ""))
1733 static PyObject
*Menu_DeleteMCEntries(_self
, _args
)
1737 PyObject
*_res
= NULL
;
1740 if (!PyArg_ParseTuple(_args
, "hh",
1744 DeleteMCEntries(menuID
,
1751 static PyObject
*Menu_InitContextualMenus(_self
, _args
)
1755 PyObject
*_res
= NULL
;
1757 if (!PyArg_ParseTuple(_args
, ""))
1759 _err
= InitContextualMenus();
1760 if (_err
!= noErr
) return PyMac_Error(_err
);
1766 static PyObject
*Menu_IsShowContextualMenuClick(_self
, _args
)
1770 PyObject
*_res
= NULL
;
1772 EventRecord inEvent
;
1773 if (!PyArg_ParseTuple(_args
, "O&",
1774 PyMac_GetEventRecord
, &inEvent
))
1776 _rv
= IsShowContextualMenuClick(&inEvent
);
1777 _res
= Py_BuildValue("b",
1782 #if !TARGET_API_MAC_CARBON
1784 static PyObject
*Menu_OpenDeskAcc(_self
, _args
)
1788 PyObject
*_res
= NULL
;
1790 if (!PyArg_ParseTuple(_args
, "O&",
1791 PyMac_GetStr255
, name
))
1800 static PyObject
*Menu_as_Menu(_self
, _args
)
1804 PyObject
*_res
= NULL
;
1807 if (!PyArg_ParseTuple(_args
, "O&",
1808 ResObj_Convert
, &h
))
1811 _res
= Py_BuildValue("O&",
1816 static PyObject
*Menu_GetMenu(_self
, _args
)
1820 PyObject
*_res
= NULL
;
1823 if (!PyArg_ParseTuple(_args
, "h",
1826 _rv
= GetMenu(resourceID
);
1827 _res
= Py_BuildValue("O&",
1832 static PyObject
*Menu_DeleteMenu(_self
, _args
)
1836 PyObject
*_res
= NULL
;
1838 if (!PyArg_ParseTuple(_args
, "h",
1847 static PyObject
*Menu_DrawMenuBar(_self
, _args
)
1851 PyObject
*_res
= NULL
;
1852 if (!PyArg_ParseTuple(_args
, ""))
1860 static PyMethodDef Menu_methods
[] = {
1862 #if !TARGET_API_MAC_CARBON
1863 {"InitProcMenu", (PyCFunction
)Menu_InitProcMenu
, 1,
1864 "(short resID) -> None"},
1867 #if !TARGET_API_MAC_CARBON
1868 {"InitMenus", (PyCFunction
)Menu_InitMenus
, 1,
1871 {"NewMenu", (PyCFunction
)Menu_NewMenu
, 1,
1872 "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
1873 {"MacGetMenu", (PyCFunction
)Menu_MacGetMenu
, 1,
1874 "(short resourceID) -> (MenuHandle _rv)"},
1875 {"MenuKey", (PyCFunction
)Menu_MenuKey
, 1,
1876 "(CharParameter ch) -> (long _rv)"},
1877 {"MenuSelect", (PyCFunction
)Menu_MenuSelect
, 1,
1878 "(Point startPt) -> (long _rv)"},
1879 {"MenuChoice", (PyCFunction
)Menu_MenuChoice
, 1,
1880 "() -> (long _rv)"},
1881 {"MenuEvent", (PyCFunction
)Menu_MenuEvent
, 1,
1882 "(EventRecord inEvent) -> (UInt32 _rv)"},
1883 {"GetMBarHeight", (PyCFunction
)Menu_GetMBarHeight
, 1,
1884 "() -> (short _rv)"},
1885 {"MacDrawMenuBar", (PyCFunction
)Menu_MacDrawMenuBar
, 1,
1887 {"InvalMenuBar", (PyCFunction
)Menu_InvalMenuBar
, 1,
1889 {"HiliteMenu", (PyCFunction
)Menu_HiliteMenu
, 1,
1890 "(short menuID) -> None"},
1891 {"GetNewMBar", (PyCFunction
)Menu_GetNewMBar
, 1,
1892 "(short menuBarID) -> (Handle _rv)"},
1893 {"GetMenuBar", (PyCFunction
)Menu_GetMenuBar
, 1,
1894 "() -> (Handle _rv)"},
1895 {"SetMenuBar", (PyCFunction
)Menu_SetMenuBar
, 1,
1896 "(Handle menuList) -> None"},
1897 {"GetMenuHandle", (PyCFunction
)Menu_GetMenuHandle
, 1,
1898 "(short menuID) -> (MenuHandle _rv)"},
1899 {"MacDeleteMenu", (PyCFunction
)Menu_MacDeleteMenu
, 1,
1900 "(short menuID) -> None"},
1901 {"ClearMenuBar", (PyCFunction
)Menu_ClearMenuBar
, 1,
1904 #if !TARGET_API_MAC_CARBON
1905 {"SetMenuFlash", (PyCFunction
)Menu_SetMenuFlash
, 1,
1906 "(short count) -> None"},
1908 {"FlashMenuBar", (PyCFunction
)Menu_FlashMenuBar
, 1,
1909 "(short menuID) -> None"},
1911 #if !TARGET_API_MAC_CARBON
1912 {"SystemEdit", (PyCFunction
)Menu_SystemEdit
, 1,
1913 "(short editCmd) -> (Boolean _rv)"},
1916 #if !TARGET_API_MAC_CARBON
1917 {"SystemMenu", (PyCFunction
)Menu_SystemMenu
, 1,
1918 "(long menuResult) -> None"},
1920 {"IsMenuBarVisible", (PyCFunction
)Menu_IsMenuBarVisible
, 1,
1921 "() -> (Boolean _rv)"},
1922 {"ShowMenuBar", (PyCFunction
)Menu_ShowMenuBar
, 1,
1924 {"HideMenuBar", (PyCFunction
)Menu_HideMenuBar
, 1,
1926 {"DeleteMCEntries", (PyCFunction
)Menu_DeleteMCEntries
, 1,
1927 "(short menuID, short menuItem) -> None"},
1928 {"InitContextualMenus", (PyCFunction
)Menu_InitContextualMenus
, 1,
1930 {"IsShowContextualMenuClick", (PyCFunction
)Menu_IsShowContextualMenuClick
, 1,
1931 "(EventRecord inEvent) -> (Boolean _rv)"},
1933 #if !TARGET_API_MAC_CARBON
1934 {"OpenDeskAcc", (PyCFunction
)Menu_OpenDeskAcc
, 1,
1935 "(Str255 name) -> None"},
1937 {"as_Menu", (PyCFunction
)Menu_as_Menu
, 1,
1938 "(Handle h) -> (MenuHandle _rv)"},
1939 {"GetMenu", (PyCFunction
)Menu_GetMenu
, 1,
1940 "(short resourceID) -> (MenuHandle _rv)"},
1941 {"DeleteMenu", (PyCFunction
)Menu_DeleteMenu
, 1,
1942 "(short menuID) -> None"},
1943 {"DrawMenuBar", (PyCFunction
)Menu_DrawMenuBar
, 1,
1959 m
= Py_InitModule("Menu", Menu_methods
);
1960 d
= PyModule_GetDict(m
);
1961 Menu_Error
= PyMac_GetOSErrException();
1962 if (Menu_Error
== NULL
||
1963 PyDict_SetItemString(d
, "Error", Menu_Error
) != 0)
1964 Py_FatalError("can't initialize Menu.Error");
1965 Menu_Type
.ob_type
= &PyType_Type
;
1966 Py_INCREF(&Menu_Type
);
1967 if (PyDict_SetItemString(d
, "MenuType", (PyObject
*)&Menu_Type
) != 0)
1968 Py_FatalError("can't initialize MenuType");
1971 /* ======================== End module Menu ========================= */