2 /* ========================== Module Menu =========================== */
9 #include "pymactoolbox.h"
11 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
14 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
15 #define GetMenuID(menu) ((*(menu))->menuID)
16 #define GetMenuWidth(menu) ((*(menu))->menuWidth)
17 #define GetMenuHeight(menu) ((*(menu))->menuHeight)
19 #define SetMenuID(menu, id) ((*(menu))->menuID = (id))
20 #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
21 #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
24 #define as_Menu(h) ((MenuHandle)h)
25 #define as_Resource(h) ((Handle)h)
27 static PyObject
*Menu_Error
;
29 /* ------------------------ Object type Menu ------------------------ */
31 PyTypeObject Menu_Type
;
33 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
35 typedef struct MenuObject
{
40 PyObject
*MenuObj_New(itself
)
44 it
= PyObject_NEW(MenuObject
, &Menu_Type
);
45 if (it
== NULL
) return NULL
;
46 it
->ob_itself
= itself
;
47 return (PyObject
*)it
;
49 MenuObj_Convert(v
, p_itself
)
53 if (!MenuObj_Check(v
))
55 PyErr_SetString(PyExc_TypeError
, "Menu required");
58 *p_itself
= ((MenuObject
*)v
)->ob_itself
;
62 static void MenuObj_dealloc(self
)
65 /* Cleanup of self->ob_itself goes here */
69 static PyObject
*MenuObj_DisposeMenu(_self
, _args
)
73 PyObject
*_res
= NULL
;
74 if (!PyArg_ParseTuple(_args
, ""))
76 DisposeMenu(_self
->ob_itself
);
82 static PyObject
*MenuObj_CalcMenuSize(_self
, _args
)
86 PyObject
*_res
= NULL
;
87 if (!PyArg_ParseTuple(_args
, ""))
89 CalcMenuSize(_self
->ob_itself
);
95 static PyObject
*MenuObj_CountMenuItems(_self
, _args
)
99 PyObject
*_res
= NULL
;
101 if (!PyArg_ParseTuple(_args
, ""))
103 _rv
= CountMenuItems(_self
->ob_itself
);
104 _res
= Py_BuildValue("h",
109 #if !TARGET_API_MAC_CARBON
111 static PyObject
*MenuObj_CountMItems(_self
, _args
)
115 PyObject
*_res
= NULL
;
117 if (!PyArg_ParseTuple(_args
, ""))
119 _rv
= CountMItems(_self
->ob_itself
);
120 _res
= Py_BuildValue("h",
126 static PyObject
*MenuObj_GetMenuFont(_self
, _args
)
130 PyObject
*_res
= NULL
;
134 if (!PyArg_ParseTuple(_args
, ""))
136 _err
= GetMenuFont(_self
->ob_itself
,
139 if (_err
!= noErr
) return PyMac_Error(_err
);
140 _res
= Py_BuildValue("hH",
146 static PyObject
*MenuObj_SetMenuFont(_self
, _args
)
150 PyObject
*_res
= NULL
;
154 if (!PyArg_ParseTuple(_args
, "hH",
158 _err
= SetMenuFont(_self
->ob_itself
,
161 if (_err
!= noErr
) return PyMac_Error(_err
);
167 static PyObject
*MenuObj_GetMenuExcludesMarkColumn(_self
, _args
)
171 PyObject
*_res
= NULL
;
173 if (!PyArg_ParseTuple(_args
, ""))
175 _rv
= GetMenuExcludesMarkColumn(_self
->ob_itself
);
176 _res
= Py_BuildValue("b",
181 static PyObject
*MenuObj_SetMenuExcludesMarkColumn(_self
, _args
)
185 PyObject
*_res
= NULL
;
187 Boolean excludesMark
;
188 if (!PyArg_ParseTuple(_args
, "b",
191 _err
= SetMenuExcludesMarkColumn(_self
->ob_itself
,
193 if (_err
!= noErr
) return PyMac_Error(_err
);
199 static PyObject
*MenuObj_MacAppendMenu(_self
, _args
)
203 PyObject
*_res
= NULL
;
205 if (!PyArg_ParseTuple(_args
, "O&",
206 PyMac_GetStr255
, data
))
208 MacAppendMenu(_self
->ob_itself
,
215 static PyObject
*MenuObj_InsertResMenu(_self
, _args
)
219 PyObject
*_res
= NULL
;
222 if (!PyArg_ParseTuple(_args
, "O&h",
223 PyMac_GetOSType
, &theType
,
226 InsertResMenu(_self
->ob_itself
,
234 static PyObject
*MenuObj_AppendResMenu(_self
, _args
)
238 PyObject
*_res
= NULL
;
240 if (!PyArg_ParseTuple(_args
, "O&",
241 PyMac_GetOSType
, &theType
))
243 AppendResMenu(_self
->ob_itself
,
250 static PyObject
*MenuObj_MacInsertMenuItem(_self
, _args
)
254 PyObject
*_res
= NULL
;
257 if (!PyArg_ParseTuple(_args
, "O&h",
258 PyMac_GetStr255
, itemString
,
261 MacInsertMenuItem(_self
->ob_itself
,
269 static PyObject
*MenuObj_DeleteMenuItem(_self
, _args
)
273 PyObject
*_res
= NULL
;
275 if (!PyArg_ParseTuple(_args
, "h",
278 DeleteMenuItem(_self
->ob_itself
,
285 static PyObject
*MenuObj_InsertFontResMenu(_self
, _args
)
289 PyObject
*_res
= NULL
;
292 if (!PyArg_ParseTuple(_args
, "hh",
296 InsertFontResMenu(_self
->ob_itself
,
304 static PyObject
*MenuObj_InsertIntlResMenu(_self
, _args
)
308 PyObject
*_res
= NULL
;
312 if (!PyArg_ParseTuple(_args
, "O&hh",
313 PyMac_GetOSType
, &theType
,
317 InsertIntlResMenu(_self
->ob_itself
,
326 static PyObject
*MenuObj_AppendMenuItemText(_self
, _args
)
330 PyObject
*_res
= NULL
;
333 if (!PyArg_ParseTuple(_args
, "O&",
334 PyMac_GetStr255
, inString
))
336 _err
= AppendMenuItemText(_self
->ob_itself
,
338 if (_err
!= noErr
) return PyMac_Error(_err
);
344 static PyObject
*MenuObj_InsertMenuItemText(_self
, _args
)
348 PyObject
*_res
= NULL
;
351 MenuItemIndex afterItem
;
352 if (!PyArg_ParseTuple(_args
, "O&h",
353 PyMac_GetStr255
, inString
,
356 _err
= InsertMenuItemText(_self
->ob_itself
,
359 if (_err
!= noErr
) return PyMac_Error(_err
);
365 static PyObject
*MenuObj_PopUpMenuSelect(_self
, _args
)
369 PyObject
*_res
= NULL
;
374 if (!PyArg_ParseTuple(_args
, "hhh",
379 _rv
= PopUpMenuSelect(_self
->ob_itself
,
383 _res
= Py_BuildValue("l",
388 static PyObject
*MenuObj_MacInsertMenu(_self
, _args
)
392 PyObject
*_res
= NULL
;
394 if (!PyArg_ParseTuple(_args
, "h",
397 MacInsertMenu(_self
->ob_itself
,
404 static PyObject
*MenuObj_MacCheckMenuItem(_self
, _args
)
408 PyObject
*_res
= NULL
;
411 if (!PyArg_ParseTuple(_args
, "hb",
415 MacCheckMenuItem(_self
->ob_itself
,
423 #if !TARGET_API_MAC_CARBON
425 static PyObject
*MenuObj_CheckItem(_self
, _args
)
429 PyObject
*_res
= NULL
;
432 if (!PyArg_ParseTuple(_args
, "hb",
436 CheckItem(_self
->ob_itself
,
445 static PyObject
*MenuObj_SetMenuItemText(_self
, _args
)
449 PyObject
*_res
= NULL
;
452 if (!PyArg_ParseTuple(_args
, "hO&",
454 PyMac_GetStr255
, itemString
))
456 SetMenuItemText(_self
->ob_itself
,
464 static PyObject
*MenuObj_GetMenuItemText(_self
, _args
)
468 PyObject
*_res
= NULL
;
471 if (!PyArg_ParseTuple(_args
, "h",
474 GetMenuItemText(_self
->ob_itself
,
477 _res
= Py_BuildValue("O&",
478 PyMac_BuildStr255
, itemString
);
482 static PyObject
*MenuObj_SetItemMark(_self
, _args
)
486 PyObject
*_res
= NULL
;
488 CharParameter markChar
;
489 if (!PyArg_ParseTuple(_args
, "hh",
493 SetItemMark(_self
->ob_itself
,
501 static PyObject
*MenuObj_GetItemMark(_self
, _args
)
505 PyObject
*_res
= NULL
;
507 CharParameter markChar
;
508 if (!PyArg_ParseTuple(_args
, "h",
511 GetItemMark(_self
->ob_itself
,
514 _res
= Py_BuildValue("h",
519 static PyObject
*MenuObj_SetItemCmd(_self
, _args
)
523 PyObject
*_res
= NULL
;
525 CharParameter cmdChar
;
526 if (!PyArg_ParseTuple(_args
, "hh",
530 SetItemCmd(_self
->ob_itself
,
538 static PyObject
*MenuObj_GetItemCmd(_self
, _args
)
542 PyObject
*_res
= NULL
;
544 CharParameter cmdChar
;
545 if (!PyArg_ParseTuple(_args
, "h",
548 GetItemCmd(_self
->ob_itself
,
551 _res
= Py_BuildValue("h",
556 static PyObject
*MenuObj_SetItemIcon(_self
, _args
)
560 PyObject
*_res
= NULL
;
563 if (!PyArg_ParseTuple(_args
, "hh",
567 SetItemIcon(_self
->ob_itself
,
575 static PyObject
*MenuObj_GetItemIcon(_self
, _args
)
579 PyObject
*_res
= NULL
;
582 if (!PyArg_ParseTuple(_args
, "h",
585 GetItemIcon(_self
->ob_itself
,
588 _res
= Py_BuildValue("h",
593 static PyObject
*MenuObj_SetItemStyle(_self
, _args
)
597 PyObject
*_res
= NULL
;
599 StyleParameter chStyle
;
600 if (!PyArg_ParseTuple(_args
, "hh",
604 SetItemStyle(_self
->ob_itself
,
612 static PyObject
*MenuObj_GetItemStyle(_self
, _args
)
616 PyObject
*_res
= NULL
;
619 if (!PyArg_ParseTuple(_args
, "h",
622 GetItemStyle(_self
->ob_itself
,
625 _res
= Py_BuildValue("b",
630 #if !TARGET_API_MAC_CARBON
632 static PyObject
*MenuObj_DisableItem(_self
, _args
)
636 PyObject
*_res
= NULL
;
638 if (!PyArg_ParseTuple(_args
, "h",
641 DisableItem(_self
->ob_itself
,
649 #if !TARGET_API_MAC_CARBON
651 static PyObject
*MenuObj_EnableItem(_self
, _args
)
655 PyObject
*_res
= NULL
;
657 if (!PyArg_ParseTuple(_args
, "h",
660 EnableItem(_self
->ob_itself
,
668 static PyObject
*MenuObj_SetMenuItemCommandID(_self
, _args
)
672 PyObject
*_res
= NULL
;
675 MenuCommand inCommandID
;
676 if (!PyArg_ParseTuple(_args
, "hl",
680 _err
= SetMenuItemCommandID(_self
->ob_itself
,
683 if (_err
!= noErr
) return PyMac_Error(_err
);
689 static PyObject
*MenuObj_GetMenuItemCommandID(_self
, _args
)
693 PyObject
*_res
= NULL
;
696 MenuCommand outCommandID
;
697 if (!PyArg_ParseTuple(_args
, "h",
700 _err
= GetMenuItemCommandID(_self
->ob_itself
,
703 if (_err
!= noErr
) return PyMac_Error(_err
);
704 _res
= Py_BuildValue("l",
709 static PyObject
*MenuObj_SetMenuItemModifiers(_self
, _args
)
713 PyObject
*_res
= NULL
;
717 if (!PyArg_ParseTuple(_args
, "hb",
721 _err
= SetMenuItemModifiers(_self
->ob_itself
,
724 if (_err
!= noErr
) return PyMac_Error(_err
);
730 static PyObject
*MenuObj_GetMenuItemModifiers(_self
, _args
)
734 PyObject
*_res
= NULL
;
738 if (!PyArg_ParseTuple(_args
, "h",
741 _err
= GetMenuItemModifiers(_self
->ob_itself
,
744 if (_err
!= noErr
) return PyMac_Error(_err
);
745 _res
= Py_BuildValue("b",
750 static PyObject
*MenuObj_SetMenuItemIconHandle(_self
, _args
)
754 PyObject
*_res
= NULL
;
759 if (!PyArg_ParseTuple(_args
, "hbO&",
762 ResObj_Convert
, &inIconHandle
))
764 _err
= SetMenuItemIconHandle(_self
->ob_itself
,
768 if (_err
!= noErr
) return PyMac_Error(_err
);
774 static PyObject
*MenuObj_GetMenuItemIconHandle(_self
, _args
)
778 PyObject
*_res
= NULL
;
782 Handle outIconHandle
;
783 if (!PyArg_ParseTuple(_args
, "h",
786 _err
= GetMenuItemIconHandle(_self
->ob_itself
,
790 if (_err
!= noErr
) return PyMac_Error(_err
);
791 _res
= Py_BuildValue("bO&",
793 ResObj_New
, outIconHandle
);
797 static PyObject
*MenuObj_SetMenuItemTextEncoding(_self
, _args
)
801 PyObject
*_res
= NULL
;
804 TextEncoding inScriptID
;
805 if (!PyArg_ParseTuple(_args
, "hl",
809 _err
= SetMenuItemTextEncoding(_self
->ob_itself
,
812 if (_err
!= noErr
) return PyMac_Error(_err
);
818 static PyObject
*MenuObj_GetMenuItemTextEncoding(_self
, _args
)
822 PyObject
*_res
= NULL
;
825 TextEncoding outScriptID
;
826 if (!PyArg_ParseTuple(_args
, "h",
829 _err
= GetMenuItemTextEncoding(_self
->ob_itself
,
832 if (_err
!= noErr
) return PyMac_Error(_err
);
833 _res
= Py_BuildValue("l",
838 static PyObject
*MenuObj_SetMenuItemHierarchicalID(_self
, _args
)
842 PyObject
*_res
= NULL
;
846 if (!PyArg_ParseTuple(_args
, "hh",
850 _err
= SetMenuItemHierarchicalID(_self
->ob_itself
,
853 if (_err
!= noErr
) return PyMac_Error(_err
);
859 static PyObject
*MenuObj_GetMenuItemHierarchicalID(_self
, _args
)
863 PyObject
*_res
= NULL
;
867 if (!PyArg_ParseTuple(_args
, "h",
870 _err
= GetMenuItemHierarchicalID(_self
->ob_itself
,
873 if (_err
!= noErr
) return PyMac_Error(_err
);
874 _res
= Py_BuildValue("h",
879 static PyObject
*MenuObj_SetMenuItemFontID(_self
, _args
)
883 PyObject
*_res
= NULL
;
887 if (!PyArg_ParseTuple(_args
, "hh",
891 _err
= SetMenuItemFontID(_self
->ob_itself
,
894 if (_err
!= noErr
) return PyMac_Error(_err
);
900 static PyObject
*MenuObj_GetMenuItemFontID(_self
, _args
)
904 PyObject
*_res
= NULL
;
908 if (!PyArg_ParseTuple(_args
, "h",
911 _err
= GetMenuItemFontID(_self
->ob_itself
,
914 if (_err
!= noErr
) return PyMac_Error(_err
);
915 _res
= Py_BuildValue("h",
920 static PyObject
*MenuObj_SetMenuItemRefCon(_self
, _args
)
924 PyObject
*_res
= NULL
;
928 if (!PyArg_ParseTuple(_args
, "hl",
932 _err
= SetMenuItemRefCon(_self
->ob_itself
,
935 if (_err
!= noErr
) return PyMac_Error(_err
);
941 static PyObject
*MenuObj_GetMenuItemRefCon(_self
, _args
)
945 PyObject
*_res
= NULL
;
949 if (!PyArg_ParseTuple(_args
, "h",
952 _err
= GetMenuItemRefCon(_self
->ob_itself
,
955 if (_err
!= noErr
) return PyMac_Error(_err
);
956 _res
= Py_BuildValue("l",
961 #if !TARGET_API_MAC_CARBON
963 static PyObject
*MenuObj_SetMenuItemRefCon2(_self
, _args
)
967 PyObject
*_res
= NULL
;
971 if (!PyArg_ParseTuple(_args
, "hl",
975 _err
= SetMenuItemRefCon2(_self
->ob_itself
,
978 if (_err
!= noErr
) return PyMac_Error(_err
);
985 #if !TARGET_API_MAC_CARBON
987 static PyObject
*MenuObj_GetMenuItemRefCon2(_self
, _args
)
991 PyObject
*_res
= NULL
;
995 if (!PyArg_ParseTuple(_args
, "h",
998 _err
= GetMenuItemRefCon2(_self
->ob_itself
,
1001 if (_err
!= noErr
) return PyMac_Error(_err
);
1002 _res
= Py_BuildValue("l",
1008 static PyObject
*MenuObj_SetMenuItemKeyGlyph(_self
, _args
)
1012 PyObject
*_res
= NULL
;
1016 if (!PyArg_ParseTuple(_args
, "hh",
1020 _err
= SetMenuItemKeyGlyph(_self
->ob_itself
,
1023 if (_err
!= noErr
) return PyMac_Error(_err
);
1029 static PyObject
*MenuObj_GetMenuItemKeyGlyph(_self
, _args
)
1033 PyObject
*_res
= NULL
;
1037 if (!PyArg_ParseTuple(_args
, "h",
1040 _err
= GetMenuItemKeyGlyph(_self
->ob_itself
,
1043 if (_err
!= noErr
) return PyMac_Error(_err
);
1044 _res
= Py_BuildValue("h",
1049 static PyObject
*MenuObj_MacEnableMenuItem(_self
, _args
)
1053 PyObject
*_res
= NULL
;
1055 if (!PyArg_ParseTuple(_args
, "h",
1058 MacEnableMenuItem(_self
->ob_itself
,
1065 static PyObject
*MenuObj_DisableMenuItem(_self
, _args
)
1069 PyObject
*_res
= NULL
;
1071 if (!PyArg_ParseTuple(_args
, "h",
1074 DisableMenuItem(_self
->ob_itself
,
1081 static PyObject
*MenuObj_IsMenuItemEnabled(_self
, _args
)
1085 PyObject
*_res
= NULL
;
1088 if (!PyArg_ParseTuple(_args
, "h",
1091 _rv
= IsMenuItemEnabled(_self
->ob_itself
,
1093 _res
= Py_BuildValue("b",
1098 static PyObject
*MenuObj_EnableMenuItemIcon(_self
, _args
)
1102 PyObject
*_res
= NULL
;
1104 if (!PyArg_ParseTuple(_args
, "h",
1107 EnableMenuItemIcon(_self
->ob_itself
,
1114 static PyObject
*MenuObj_DisableMenuItemIcon(_self
, _args
)
1118 PyObject
*_res
= NULL
;
1120 if (!PyArg_ParseTuple(_args
, "h",
1123 DisableMenuItemIcon(_self
->ob_itself
,
1130 static PyObject
*MenuObj_IsMenuItemIconEnabled(_self
, _args
)
1134 PyObject
*_res
= NULL
;
1137 if (!PyArg_ParseTuple(_args
, "h",
1140 _rv
= IsMenuItemIconEnabled(_self
->ob_itself
,
1142 _res
= Py_BuildValue("b",
1147 #if TARGET_API_MAC_CARBON
1149 static PyObject
*MenuObj_GetMenuItemPropertyAttributes(_self
, _args
)
1153 PyObject
*_res
= NULL
;
1156 OSType propertyCreator
;
1159 if (!PyArg_ParseTuple(_args
, "hO&O&",
1161 PyMac_GetOSType
, &propertyCreator
,
1162 PyMac_GetOSType
, &propertyTag
))
1164 _err
= GetMenuItemPropertyAttributes(_self
->ob_itself
,
1169 if (_err
!= noErr
) return PyMac_Error(_err
);
1170 _res
= Py_BuildValue("l",
1176 #if TARGET_API_MAC_CARBON
1178 static PyObject
*MenuObj_ChangeMenuItemPropertyAttributes(_self
, _args
)
1182 PyObject
*_res
= NULL
;
1185 OSType propertyCreator
;
1187 UInt32 attributesToSet
;
1188 UInt32 attributesToClear
;
1189 if (!PyArg_ParseTuple(_args
, "hO&O&ll",
1191 PyMac_GetOSType
, &propertyCreator
,
1192 PyMac_GetOSType
, &propertyTag
,
1194 &attributesToClear
))
1196 _err
= ChangeMenuItemPropertyAttributes(_self
->ob_itself
,
1202 if (_err
!= noErr
) return PyMac_Error(_err
);
1209 #if TARGET_API_MAC_CARBON
1211 static PyObject
*MenuObj_GetMenuAttributes(_self
, _args
)
1215 PyObject
*_res
= NULL
;
1217 MenuAttributes outAttributes
;
1218 if (!PyArg_ParseTuple(_args
, ""))
1220 _err
= GetMenuAttributes(_self
->ob_itself
,
1222 if (_err
!= noErr
) return PyMac_Error(_err
);
1223 _res
= Py_BuildValue("l",
1229 #if TARGET_API_MAC_CARBON
1231 static PyObject
*MenuObj_ChangeMenuAttributes(_self
, _args
)
1235 PyObject
*_res
= NULL
;
1237 MenuAttributes setTheseAttributes
;
1238 MenuAttributes clearTheseAttributes
;
1239 if (!PyArg_ParseTuple(_args
, "ll",
1240 &setTheseAttributes
,
1241 &clearTheseAttributes
))
1243 _err
= ChangeMenuAttributes(_self
->ob_itself
,
1245 clearTheseAttributes
);
1246 if (_err
!= noErr
) return PyMac_Error(_err
);
1253 #if TARGET_API_MAC_CARBON
1255 static PyObject
*MenuObj_GetMenuItemAttributes(_self
, _args
)
1259 PyObject
*_res
= NULL
;
1262 MenuItemAttributes outAttributes
;
1263 if (!PyArg_ParseTuple(_args
, "h",
1266 _err
= GetMenuItemAttributes(_self
->ob_itself
,
1269 if (_err
!= noErr
) return PyMac_Error(_err
);
1270 _res
= Py_BuildValue("l",
1276 #if TARGET_API_MAC_CARBON
1278 static PyObject
*MenuObj_ChangeMenuItemAttributes(_self
, _args
)
1282 PyObject
*_res
= NULL
;
1285 MenuItemAttributes setTheseAttributes
;
1286 MenuItemAttributes clearTheseAttributes
;
1287 if (!PyArg_ParseTuple(_args
, "hll",
1289 &setTheseAttributes
,
1290 &clearTheseAttributes
))
1292 _err
= ChangeMenuItemAttributes(_self
->ob_itself
,
1295 clearTheseAttributes
);
1296 if (_err
!= noErr
) return PyMac_Error(_err
);
1303 #if TARGET_API_MAC_CARBON
1305 static PyObject
*MenuObj_DisableAllMenuItems(_self
, _args
)
1309 PyObject
*_res
= NULL
;
1310 if (!PyArg_ParseTuple(_args
, ""))
1312 DisableAllMenuItems(_self
->ob_itself
);
1319 #if TARGET_API_MAC_CARBON
1321 static PyObject
*MenuObj_EnableAllMenuItems(_self
, _args
)
1325 PyObject
*_res
= NULL
;
1326 if (!PyArg_ParseTuple(_args
, ""))
1328 EnableAllMenuItems(_self
->ob_itself
);
1335 #if TARGET_API_MAC_CARBON
1337 static PyObject
*MenuObj_MenuHasEnabledItems(_self
, _args
)
1341 PyObject
*_res
= NULL
;
1343 if (!PyArg_ParseTuple(_args
, ""))
1345 _rv
= MenuHasEnabledItems(_self
->ob_itself
);
1346 _res
= Py_BuildValue("b",
1352 #if TARGET_API_MAC_CARBON
1354 static PyObject
*MenuObj_CountMenuItemsWithCommandID(_self
, _args
)
1358 PyObject
*_res
= NULL
;
1360 MenuCommand commandID
;
1361 if (!PyArg_ParseTuple(_args
, "l",
1364 _rv
= CountMenuItemsWithCommandID(_self
->ob_itself
,
1366 _res
= Py_BuildValue("l",
1372 #if TARGET_API_MAC_CARBON
1374 static PyObject
*MenuObj_GetIndMenuItemWithCommandID(_self
, _args
)
1378 PyObject
*_res
= NULL
;
1380 MenuCommand commandID
;
1383 MenuItemIndex outIndex
;
1384 if (!PyArg_ParseTuple(_args
, "ll",
1388 _err
= GetIndMenuItemWithCommandID(_self
->ob_itself
,
1393 if (_err
!= noErr
) return PyMac_Error(_err
);
1394 _res
= Py_BuildValue("O&h",
1395 MenuObj_New
, outMenu
,
1401 #if TARGET_API_MAC_CARBON
1403 static PyObject
*MenuObj_EnableMenuCommand(_self
, _args
)
1407 PyObject
*_res
= NULL
;
1408 MenuCommand commandID
;
1409 if (!PyArg_ParseTuple(_args
, "l",
1412 EnableMenuCommand(_self
->ob_itself
,
1420 #if TARGET_API_MAC_CARBON
1422 static PyObject
*MenuObj_DisableMenuCommand(_self
, _args
)
1426 PyObject
*_res
= NULL
;
1427 MenuCommand commandID
;
1428 if (!PyArg_ParseTuple(_args
, "l",
1431 DisableMenuCommand(_self
->ob_itself
,
1439 #if TARGET_API_MAC_CARBON
1441 static PyObject
*MenuObj_IsMenuCommandEnabled(_self
, _args
)
1445 PyObject
*_res
= NULL
;
1447 MenuCommand commandID
;
1448 if (!PyArg_ParseTuple(_args
, "l",
1451 _rv
= IsMenuCommandEnabled(_self
->ob_itself
,
1453 _res
= Py_BuildValue("b",
1459 #if TARGET_API_MAC_CARBON
1461 static PyObject
*MenuObj_GetMenuCommandPropertySize(_self
, _args
)
1465 PyObject
*_res
= NULL
;
1467 MenuCommand commandID
;
1468 OSType propertyCreator
;
1471 if (!PyArg_ParseTuple(_args
, "lO&O&",
1473 PyMac_GetOSType
, &propertyCreator
,
1474 PyMac_GetOSType
, &propertyTag
))
1476 _err
= GetMenuCommandPropertySize(_self
->ob_itself
,
1481 if (_err
!= noErr
) return PyMac_Error(_err
);
1482 _res
= Py_BuildValue("l",
1488 #if TARGET_API_MAC_CARBON
1490 static PyObject
*MenuObj_RemoveMenuCommandProperty(_self
, _args
)
1494 PyObject
*_res
= NULL
;
1496 MenuCommand commandID
;
1497 OSType propertyCreator
;
1499 if (!PyArg_ParseTuple(_args
, "lO&O&",
1501 PyMac_GetOSType
, &propertyCreator
,
1502 PyMac_GetOSType
, &propertyTag
))
1504 _err
= RemoveMenuCommandProperty(_self
->ob_itself
,
1508 if (_err
!= noErr
) return PyMac_Error(_err
);
1515 #if TARGET_API_MAC_CARBON
1517 static PyObject
*MenuObj_CreateStandardFontMenu(_self
, _args
)
1521 PyObject
*_res
= NULL
;
1523 MenuItemIndex afterItem
;
1524 MenuID firstHierMenuID
;
1526 ItemCount outHierMenuCount
;
1527 if (!PyArg_ParseTuple(_args
, "hhl",
1532 _err
= CreateStandardFontMenu(_self
->ob_itself
,
1537 if (_err
!= noErr
) return PyMac_Error(_err
);
1538 _res
= Py_BuildValue("l",
1544 #if TARGET_API_MAC_CARBON
1546 static PyObject
*MenuObj_UpdateStandardFontMenu(_self
, _args
)
1550 PyObject
*_res
= NULL
;
1552 ItemCount outHierMenuCount
;
1553 if (!PyArg_ParseTuple(_args
, ""))
1555 _err
= UpdateStandardFontMenu(_self
->ob_itself
,
1557 if (_err
!= noErr
) return PyMac_Error(_err
);
1558 _res
= Py_BuildValue("l",
1564 #if TARGET_API_MAC_CARBON
1566 static PyObject
*MenuObj_GetFontFamilyFromMenuSelection(_self
, _args
)
1570 PyObject
*_res
= NULL
;
1573 FMFontFamily outFontFamily
;
1574 FMFontStyle outStyle
;
1575 if (!PyArg_ParseTuple(_args
, "h",
1578 _err
= GetFontFamilyFromMenuSelection(_self
->ob_itself
,
1582 if (_err
!= noErr
) return PyMac_Error(_err
);
1583 _res
= Py_BuildValue("hh",
1590 static PyObject
*MenuObj_GetMenuID(_self
, _args
)
1594 PyObject
*_res
= NULL
;
1596 if (!PyArg_ParseTuple(_args
, ""))
1598 _rv
= GetMenuID(_self
->ob_itself
);
1599 _res
= Py_BuildValue("h",
1604 static PyObject
*MenuObj_GetMenuWidth(_self
, _args
)
1608 PyObject
*_res
= NULL
;
1610 if (!PyArg_ParseTuple(_args
, ""))
1612 _rv
= GetMenuWidth(_self
->ob_itself
);
1613 _res
= Py_BuildValue("h",
1618 static PyObject
*MenuObj_GetMenuHeight(_self
, _args
)
1622 PyObject
*_res
= NULL
;
1624 if (!PyArg_ParseTuple(_args
, ""))
1626 _rv
= GetMenuHeight(_self
->ob_itself
);
1627 _res
= Py_BuildValue("h",
1632 static PyObject
*MenuObj_SetMenuID(_self
, _args
)
1636 PyObject
*_res
= NULL
;
1638 if (!PyArg_ParseTuple(_args
, "h",
1641 SetMenuID(_self
->ob_itself
,
1648 static PyObject
*MenuObj_SetMenuWidth(_self
, _args
)
1652 PyObject
*_res
= NULL
;
1654 if (!PyArg_ParseTuple(_args
, "h",
1657 SetMenuWidth(_self
->ob_itself
,
1664 static PyObject
*MenuObj_SetMenuHeight(_self
, _args
)
1668 PyObject
*_res
= NULL
;
1670 if (!PyArg_ParseTuple(_args
, "h",
1673 SetMenuHeight(_self
->ob_itself
,
1680 static PyObject
*MenuObj_as_Resource(_self
, _args
)
1684 PyObject
*_res
= NULL
;
1686 if (!PyArg_ParseTuple(_args
, ""))
1688 _rv
= as_Resource(_self
->ob_itself
);
1689 _res
= Py_BuildValue("O&",
1694 static PyObject
*MenuObj_AppendMenu(_self
, _args
)
1698 PyObject
*_res
= NULL
;
1700 if (!PyArg_ParseTuple(_args
, "O&",
1701 PyMac_GetStr255
, data
))
1703 AppendMenu(_self
->ob_itself
,
1710 static PyObject
*MenuObj_InsertMenu(_self
, _args
)
1714 PyObject
*_res
= NULL
;
1716 if (!PyArg_ParseTuple(_args
, "h",
1719 InsertMenu(_self
->ob_itself
,
1726 static PyObject
*MenuObj_InsertMenuItem(_self
, _args
)
1730 PyObject
*_res
= NULL
;
1733 if (!PyArg_ParseTuple(_args
, "O&h",
1734 PyMac_GetStr255
, itemString
,
1737 InsertMenuItem(_self
->ob_itself
,
1745 static PyObject
*MenuObj_EnableMenuItem(_self
, _args
)
1749 PyObject
*_res
= NULL
;
1751 if (!PyArg_ParseTuple(_args
, "H",
1754 EnableMenuItem(_self
->ob_itself
,
1761 static PyObject
*MenuObj_CheckMenuItem(_self
, _args
)
1765 PyObject
*_res
= NULL
;
1768 if (!PyArg_ParseTuple(_args
, "hb",
1772 CheckMenuItem(_self
->ob_itself
,
1780 static PyMethodDef MenuObj_methods
[] = {
1781 {"DisposeMenu", (PyCFunction
)MenuObj_DisposeMenu
, 1,
1783 {"CalcMenuSize", (PyCFunction
)MenuObj_CalcMenuSize
, 1,
1785 {"CountMenuItems", (PyCFunction
)MenuObj_CountMenuItems
, 1,
1786 "() -> (short _rv)"},
1788 #if !TARGET_API_MAC_CARBON
1789 {"CountMItems", (PyCFunction
)MenuObj_CountMItems
, 1,
1790 "() -> (short _rv)"},
1792 {"GetMenuFont", (PyCFunction
)MenuObj_GetMenuFont
, 1,
1793 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1794 {"SetMenuFont", (PyCFunction
)MenuObj_SetMenuFont
, 1,
1795 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1796 {"GetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_GetMenuExcludesMarkColumn
, 1,
1797 "() -> (Boolean _rv)"},
1798 {"SetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_SetMenuExcludesMarkColumn
, 1,
1799 "(Boolean excludesMark) -> None"},
1800 {"MacAppendMenu", (PyCFunction
)MenuObj_MacAppendMenu
, 1,
1801 "(Str255 data) -> None"},
1802 {"InsertResMenu", (PyCFunction
)MenuObj_InsertResMenu
, 1,
1803 "(ResType theType, short afterItem) -> None"},
1804 {"AppendResMenu", (PyCFunction
)MenuObj_AppendResMenu
, 1,
1805 "(ResType theType) -> None"},
1806 {"MacInsertMenuItem", (PyCFunction
)MenuObj_MacInsertMenuItem
, 1,
1807 "(Str255 itemString, short afterItem) -> None"},
1808 {"DeleteMenuItem", (PyCFunction
)MenuObj_DeleteMenuItem
, 1,
1809 "(short item) -> None"},
1810 {"InsertFontResMenu", (PyCFunction
)MenuObj_InsertFontResMenu
, 1,
1811 "(short afterItem, short scriptFilter) -> None"},
1812 {"InsertIntlResMenu", (PyCFunction
)MenuObj_InsertIntlResMenu
, 1,
1813 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1814 {"AppendMenuItemText", (PyCFunction
)MenuObj_AppendMenuItemText
, 1,
1815 "(Str255 inString) -> None"},
1816 {"InsertMenuItemText", (PyCFunction
)MenuObj_InsertMenuItemText
, 1,
1817 "(Str255 inString, MenuItemIndex afterItem) -> None"},
1818 {"PopUpMenuSelect", (PyCFunction
)MenuObj_PopUpMenuSelect
, 1,
1819 "(short top, short left, short popUpItem) -> (long _rv)"},
1820 {"MacInsertMenu", (PyCFunction
)MenuObj_MacInsertMenu
, 1,
1821 "(MenuID beforeID) -> None"},
1822 {"MacCheckMenuItem", (PyCFunction
)MenuObj_MacCheckMenuItem
, 1,
1823 "(short item, Boolean checked) -> None"},
1825 #if !TARGET_API_MAC_CARBON
1826 {"CheckItem", (PyCFunction
)MenuObj_CheckItem
, 1,
1827 "(short item, Boolean checked) -> None"},
1829 {"SetMenuItemText", (PyCFunction
)MenuObj_SetMenuItemText
, 1,
1830 "(short item, Str255 itemString) -> None"},
1831 {"GetMenuItemText", (PyCFunction
)MenuObj_GetMenuItemText
, 1,
1832 "(short item) -> (Str255 itemString)"},
1833 {"SetItemMark", (PyCFunction
)MenuObj_SetItemMark
, 1,
1834 "(short item, CharParameter markChar) -> None"},
1835 {"GetItemMark", (PyCFunction
)MenuObj_GetItemMark
, 1,
1836 "(short item) -> (CharParameter markChar)"},
1837 {"SetItemCmd", (PyCFunction
)MenuObj_SetItemCmd
, 1,
1838 "(short item, CharParameter cmdChar) -> None"},
1839 {"GetItemCmd", (PyCFunction
)MenuObj_GetItemCmd
, 1,
1840 "(short item) -> (CharParameter cmdChar)"},
1841 {"SetItemIcon", (PyCFunction
)MenuObj_SetItemIcon
, 1,
1842 "(short item, short iconIndex) -> None"},
1843 {"GetItemIcon", (PyCFunction
)MenuObj_GetItemIcon
, 1,
1844 "(short item) -> (short iconIndex)"},
1845 {"SetItemStyle", (PyCFunction
)MenuObj_SetItemStyle
, 1,
1846 "(short item, StyleParameter chStyle) -> None"},
1847 {"GetItemStyle", (PyCFunction
)MenuObj_GetItemStyle
, 1,
1848 "(short item) -> (Style chStyle)"},
1850 #if !TARGET_API_MAC_CARBON
1851 {"DisableItem", (PyCFunction
)MenuObj_DisableItem
, 1,
1852 "(short item) -> None"},
1855 #if !TARGET_API_MAC_CARBON
1856 {"EnableItem", (PyCFunction
)MenuObj_EnableItem
, 1,
1857 "(short item) -> None"},
1859 {"SetMenuItemCommandID", (PyCFunction
)MenuObj_SetMenuItemCommandID
, 1,
1860 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
1861 {"GetMenuItemCommandID", (PyCFunction
)MenuObj_GetMenuItemCommandID
, 1,
1862 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
1863 {"SetMenuItemModifiers", (PyCFunction
)MenuObj_SetMenuItemModifiers
, 1,
1864 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1865 {"GetMenuItemModifiers", (PyCFunction
)MenuObj_GetMenuItemModifiers
, 1,
1866 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1867 {"SetMenuItemIconHandle", (PyCFunction
)MenuObj_SetMenuItemIconHandle
, 1,
1868 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1869 {"GetMenuItemIconHandle", (PyCFunction
)MenuObj_GetMenuItemIconHandle
, 1,
1870 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1871 {"SetMenuItemTextEncoding", (PyCFunction
)MenuObj_SetMenuItemTextEncoding
, 1,
1872 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1873 {"GetMenuItemTextEncoding", (PyCFunction
)MenuObj_GetMenuItemTextEncoding
, 1,
1874 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1875 {"SetMenuItemHierarchicalID", (PyCFunction
)MenuObj_SetMenuItemHierarchicalID
, 1,
1876 "(SInt16 inItem, MenuID inHierID) -> None"},
1877 {"GetMenuItemHierarchicalID", (PyCFunction
)MenuObj_GetMenuItemHierarchicalID
, 1,
1878 "(SInt16 inItem) -> (MenuID outHierID)"},
1879 {"SetMenuItemFontID", (PyCFunction
)MenuObj_SetMenuItemFontID
, 1,
1880 "(SInt16 inItem, SInt16 inFontID) -> None"},
1881 {"GetMenuItemFontID", (PyCFunction
)MenuObj_GetMenuItemFontID
, 1,
1882 "(SInt16 inItem) -> (SInt16 outFontID)"},
1883 {"SetMenuItemRefCon", (PyCFunction
)MenuObj_SetMenuItemRefCon
, 1,
1884 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1885 {"GetMenuItemRefCon", (PyCFunction
)MenuObj_GetMenuItemRefCon
, 1,
1886 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1888 #if !TARGET_API_MAC_CARBON
1889 {"SetMenuItemRefCon2", (PyCFunction
)MenuObj_SetMenuItemRefCon2
, 1,
1890 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1893 #if !TARGET_API_MAC_CARBON
1894 {"GetMenuItemRefCon2", (PyCFunction
)MenuObj_GetMenuItemRefCon2
, 1,
1895 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1897 {"SetMenuItemKeyGlyph", (PyCFunction
)MenuObj_SetMenuItemKeyGlyph
, 1,
1898 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1899 {"GetMenuItemKeyGlyph", (PyCFunction
)MenuObj_GetMenuItemKeyGlyph
, 1,
1900 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1901 {"MacEnableMenuItem", (PyCFunction
)MenuObj_MacEnableMenuItem
, 1,
1902 "(MenuItemIndex item) -> None"},
1903 {"DisableMenuItem", (PyCFunction
)MenuObj_DisableMenuItem
, 1,
1904 "(MenuItemIndex item) -> None"},
1905 {"IsMenuItemEnabled", (PyCFunction
)MenuObj_IsMenuItemEnabled
, 1,
1906 "(MenuItemIndex item) -> (Boolean _rv)"},
1907 {"EnableMenuItemIcon", (PyCFunction
)MenuObj_EnableMenuItemIcon
, 1,
1908 "(MenuItemIndex item) -> None"},
1909 {"DisableMenuItemIcon", (PyCFunction
)MenuObj_DisableMenuItemIcon
, 1,
1910 "(MenuItemIndex item) -> None"},
1911 {"IsMenuItemIconEnabled", (PyCFunction
)MenuObj_IsMenuItemIconEnabled
, 1,
1912 "(MenuItemIndex item) -> (Boolean _rv)"},
1914 #if TARGET_API_MAC_CARBON
1915 {"GetMenuItemPropertyAttributes", (PyCFunction
)MenuObj_GetMenuItemPropertyAttributes
, 1,
1916 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1919 #if TARGET_API_MAC_CARBON
1920 {"ChangeMenuItemPropertyAttributes", (PyCFunction
)MenuObj_ChangeMenuItemPropertyAttributes
, 1,
1921 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1924 #if TARGET_API_MAC_CARBON
1925 {"GetMenuAttributes", (PyCFunction
)MenuObj_GetMenuAttributes
, 1,
1926 "() -> (MenuAttributes outAttributes)"},
1929 #if TARGET_API_MAC_CARBON
1930 {"ChangeMenuAttributes", (PyCFunction
)MenuObj_ChangeMenuAttributes
, 1,
1931 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1934 #if TARGET_API_MAC_CARBON
1935 {"GetMenuItemAttributes", (PyCFunction
)MenuObj_GetMenuItemAttributes
, 1,
1936 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1939 #if TARGET_API_MAC_CARBON
1940 {"ChangeMenuItemAttributes", (PyCFunction
)MenuObj_ChangeMenuItemAttributes
, 1,
1941 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1944 #if TARGET_API_MAC_CARBON
1945 {"DisableAllMenuItems", (PyCFunction
)MenuObj_DisableAllMenuItems
, 1,
1949 #if TARGET_API_MAC_CARBON
1950 {"EnableAllMenuItems", (PyCFunction
)MenuObj_EnableAllMenuItems
, 1,
1954 #if TARGET_API_MAC_CARBON
1955 {"MenuHasEnabledItems", (PyCFunction
)MenuObj_MenuHasEnabledItems
, 1,
1956 "() -> (Boolean _rv)"},
1959 #if TARGET_API_MAC_CARBON
1960 {"CountMenuItemsWithCommandID", (PyCFunction
)MenuObj_CountMenuItemsWithCommandID
, 1,
1961 "(MenuCommand commandID) -> (ItemCount _rv)"},
1964 #if TARGET_API_MAC_CARBON
1965 {"GetIndMenuItemWithCommandID", (PyCFunction
)MenuObj_GetIndMenuItemWithCommandID
, 1,
1966 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1969 #if TARGET_API_MAC_CARBON
1970 {"EnableMenuCommand", (PyCFunction
)MenuObj_EnableMenuCommand
, 1,
1971 "(MenuCommand commandID) -> None"},
1974 #if TARGET_API_MAC_CARBON
1975 {"DisableMenuCommand", (PyCFunction
)MenuObj_DisableMenuCommand
, 1,
1976 "(MenuCommand commandID) -> None"},
1979 #if TARGET_API_MAC_CARBON
1980 {"IsMenuCommandEnabled", (PyCFunction
)MenuObj_IsMenuCommandEnabled
, 1,
1981 "(MenuCommand commandID) -> (Boolean _rv)"},
1984 #if TARGET_API_MAC_CARBON
1985 {"GetMenuCommandPropertySize", (PyCFunction
)MenuObj_GetMenuCommandPropertySize
, 1,
1986 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1989 #if TARGET_API_MAC_CARBON
1990 {"RemoveMenuCommandProperty", (PyCFunction
)MenuObj_RemoveMenuCommandProperty
, 1,
1991 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1994 #if TARGET_API_MAC_CARBON
1995 {"CreateStandardFontMenu", (PyCFunction
)MenuObj_CreateStandardFontMenu
, 1,
1996 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1999 #if TARGET_API_MAC_CARBON
2000 {"UpdateStandardFontMenu", (PyCFunction
)MenuObj_UpdateStandardFontMenu
, 1,
2001 "() -> (ItemCount outHierMenuCount)"},
2004 #if TARGET_API_MAC_CARBON
2005 {"GetFontFamilyFromMenuSelection", (PyCFunction
)MenuObj_GetFontFamilyFromMenuSelection
, 1,
2006 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
2008 {"GetMenuID", (PyCFunction
)MenuObj_GetMenuID
, 1,
2009 "() -> (MenuID _rv)"},
2010 {"GetMenuWidth", (PyCFunction
)MenuObj_GetMenuWidth
, 1,
2011 "() -> (SInt16 _rv)"},
2012 {"GetMenuHeight", (PyCFunction
)MenuObj_GetMenuHeight
, 1,
2013 "() -> (SInt16 _rv)"},
2014 {"SetMenuID", (PyCFunction
)MenuObj_SetMenuID
, 1,
2015 "(MenuID menuID) -> None"},
2016 {"SetMenuWidth", (PyCFunction
)MenuObj_SetMenuWidth
, 1,
2017 "(SInt16 width) -> None"},
2018 {"SetMenuHeight", (PyCFunction
)MenuObj_SetMenuHeight
, 1,
2019 "(SInt16 height) -> None"},
2020 {"as_Resource", (PyCFunction
)MenuObj_as_Resource
, 1,
2021 "() -> (Handle _rv)"},
2022 {"AppendMenu", (PyCFunction
)MenuObj_AppendMenu
, 1,
2023 "(Str255 data) -> None"},
2024 {"InsertMenu", (PyCFunction
)MenuObj_InsertMenu
, 1,
2025 "(short beforeID) -> None"},
2026 {"InsertMenuItem", (PyCFunction
)MenuObj_InsertMenuItem
, 1,
2027 "(Str255 itemString, short afterItem) -> None"},
2028 {"EnableMenuItem", (PyCFunction
)MenuObj_EnableMenuItem
, 1,
2029 "(UInt16 item) -> None"},
2030 {"CheckMenuItem", (PyCFunction
)MenuObj_CheckMenuItem
, 1,
2031 "(short item, Boolean checked) -> None"},
2035 PyMethodChain MenuObj_chain
= { MenuObj_methods
, NULL
};
2037 static PyObject
*MenuObj_getattr(self
, name
)
2041 return Py_FindMethodInChain(&MenuObj_chain
, (PyObject
*)self
, name
);
2044 #define MenuObj_setattr NULL
2046 #define MenuObj_compare NULL
2048 #define MenuObj_repr NULL
2050 #define MenuObj_hash NULL
2052 PyTypeObject Menu_Type
= {
2053 PyObject_HEAD_INIT(&PyType_Type
)
2056 sizeof(MenuObject
), /*tp_basicsize*/
2059 (destructor
) MenuObj_dealloc
, /*tp_dealloc*/
2061 (getattrfunc
) MenuObj_getattr
, /*tp_getattr*/
2062 (setattrfunc
) MenuObj_setattr
, /*tp_setattr*/
2063 (cmpfunc
) MenuObj_compare
, /*tp_compare*/
2064 (reprfunc
) MenuObj_repr
, /*tp_repr*/
2065 (PyNumberMethods
*)0, /* tp_as_number */
2066 (PySequenceMethods
*)0, /* tp_as_sequence */
2067 (PyMappingMethods
*)0, /* tp_as_mapping */
2068 (hashfunc
) MenuObj_hash
, /*tp_hash*/
2071 /* ---------------------- End object type Menu ---------------------- */
2074 #if !TARGET_API_MAC_CARBON
2076 static PyObject
*Menu_InitProcMenu(_self
, _args
)
2080 PyObject
*_res
= NULL
;
2082 if (!PyArg_ParseTuple(_args
, "h",
2085 InitProcMenu(resID
);
2092 #if !TARGET_API_MAC_CARBON
2094 static PyObject
*Menu_InitMenus(_self
, _args
)
2098 PyObject
*_res
= NULL
;
2099 if (!PyArg_ParseTuple(_args
, ""))
2108 static PyObject
*Menu_NewMenu(_self
, _args
)
2112 PyObject
*_res
= NULL
;
2116 if (!PyArg_ParseTuple(_args
, "hO&",
2118 PyMac_GetStr255
, menuTitle
))
2120 _rv
= NewMenu(menuID
,
2122 _res
= Py_BuildValue("O&",
2127 static PyObject
*Menu_MacGetMenu(_self
, _args
)
2131 PyObject
*_res
= NULL
;
2134 if (!PyArg_ParseTuple(_args
, "h",
2137 _rv
= MacGetMenu(resourceID
);
2138 _res
= Py_BuildValue("O&",
2143 #if TARGET_API_MAC_CARBON
2145 static PyObject
*Menu_CreateNewMenu(_self
, _args
)
2149 PyObject
*_res
= NULL
;
2152 MenuAttributes menuAttributes
;
2153 MenuHandle outMenuRef
;
2154 if (!PyArg_ParseTuple(_args
, "hl",
2158 _err
= CreateNewMenu(menuID
,
2161 if (_err
!= noErr
) return PyMac_Error(_err
);
2162 _res
= Py_BuildValue("O&",
2163 MenuObj_New
, outMenuRef
);
2168 static PyObject
*Menu_MenuKey(_self
, _args
)
2172 PyObject
*_res
= NULL
;
2175 if (!PyArg_ParseTuple(_args
, "h",
2179 _res
= Py_BuildValue("l",
2184 static PyObject
*Menu_MenuSelect(_self
, _args
)
2188 PyObject
*_res
= NULL
;
2191 if (!PyArg_ParseTuple(_args
, "O&",
2192 PyMac_GetPoint
, &startPt
))
2194 _rv
= MenuSelect(startPt
);
2195 _res
= Py_BuildValue("l",
2200 static PyObject
*Menu_MenuChoice(_self
, _args
)
2204 PyObject
*_res
= NULL
;
2206 if (!PyArg_ParseTuple(_args
, ""))
2209 _res
= Py_BuildValue("l",
2214 static PyObject
*Menu_MenuEvent(_self
, _args
)
2218 PyObject
*_res
= NULL
;
2220 EventRecord inEvent
;
2221 if (!PyArg_ParseTuple(_args
, "O&",
2222 PyMac_GetEventRecord
, &inEvent
))
2224 _rv
= MenuEvent(&inEvent
);
2225 _res
= Py_BuildValue("l",
2230 static PyObject
*Menu_GetMBarHeight(_self
, _args
)
2234 PyObject
*_res
= NULL
;
2236 if (!PyArg_ParseTuple(_args
, ""))
2238 _rv
= GetMBarHeight();
2239 _res
= Py_BuildValue("h",
2244 static PyObject
*Menu_MacDrawMenuBar(_self
, _args
)
2248 PyObject
*_res
= NULL
;
2249 if (!PyArg_ParseTuple(_args
, ""))
2257 static PyObject
*Menu_InvalMenuBar(_self
, _args
)
2261 PyObject
*_res
= NULL
;
2262 if (!PyArg_ParseTuple(_args
, ""))
2270 static PyObject
*Menu_HiliteMenu(_self
, _args
)
2274 PyObject
*_res
= NULL
;
2276 if (!PyArg_ParseTuple(_args
, "h",
2285 static PyObject
*Menu_GetNewMBar(_self
, _args
)
2289 PyObject
*_res
= NULL
;
2292 if (!PyArg_ParseTuple(_args
, "h",
2295 _rv
= GetNewMBar(menuBarID
);
2296 _res
= Py_BuildValue("O&",
2301 static PyObject
*Menu_GetMenuBar(_self
, _args
)
2305 PyObject
*_res
= NULL
;
2307 if (!PyArg_ParseTuple(_args
, ""))
2310 _res
= Py_BuildValue("O&",
2315 static PyObject
*Menu_SetMenuBar(_self
, _args
)
2319 PyObject
*_res
= NULL
;
2321 if (!PyArg_ParseTuple(_args
, "O&",
2322 ResObj_Convert
, &mbar
))
2330 #if TARGET_API_MAC_CARBON
2332 static PyObject
*Menu_DuplicateMenuBar(_self
, _args
)
2336 PyObject
*_res
= NULL
;
2339 MenuBarHandle outBar
;
2340 if (!PyArg_ParseTuple(_args
, "O&",
2341 ResObj_Convert
, &mbar
))
2343 _err
= DuplicateMenuBar(mbar
,
2345 if (_err
!= noErr
) return PyMac_Error(_err
);
2346 _res
= Py_BuildValue("O&",
2347 ResObj_New
, outBar
);
2352 #if TARGET_API_MAC_CARBON
2354 static PyObject
*Menu_DisposeMenuBar(_self
, _args
)
2358 PyObject
*_res
= NULL
;
2361 if (!PyArg_ParseTuple(_args
, "O&",
2362 ResObj_Convert
, &mbar
))
2364 _err
= DisposeMenuBar(mbar
);
2365 if (_err
!= noErr
) return PyMac_Error(_err
);
2372 static PyObject
*Menu_GetMenuHandle(_self
, _args
)
2376 PyObject
*_res
= NULL
;
2379 if (!PyArg_ParseTuple(_args
, "h",
2382 _rv
= GetMenuHandle(menuID
);
2383 _res
= Py_BuildValue("O&",
2388 static PyObject
*Menu_MacDeleteMenu(_self
, _args
)
2392 PyObject
*_res
= NULL
;
2394 if (!PyArg_ParseTuple(_args
, "h",
2397 MacDeleteMenu(menuID
);
2403 static PyObject
*Menu_ClearMenuBar(_self
, _args
)
2407 PyObject
*_res
= NULL
;
2408 if (!PyArg_ParseTuple(_args
, ""))
2416 static PyObject
*Menu_SetMenuFlashCount(_self
, _args
)
2420 PyObject
*_res
= NULL
;
2422 if (!PyArg_ParseTuple(_args
, "h",
2425 SetMenuFlashCount(count
);
2431 #if !TARGET_API_MAC_CARBON
2433 static PyObject
*Menu_SetMenuFlash(_self
, _args
)
2437 PyObject
*_res
= NULL
;
2439 if (!PyArg_ParseTuple(_args
, "h",
2442 SetMenuFlash(count
);
2449 static PyObject
*Menu_FlashMenuBar(_self
, _args
)
2453 PyObject
*_res
= NULL
;
2455 if (!PyArg_ParseTuple(_args
, "h",
2458 FlashMenuBar(menuID
);
2464 #if !TARGET_API_MAC_CARBON
2466 static PyObject
*Menu_SystemEdit(_self
, _args
)
2470 PyObject
*_res
= NULL
;
2473 if (!PyArg_ParseTuple(_args
, "h",
2476 _rv
= SystemEdit(editCmd
);
2477 _res
= Py_BuildValue("b",
2483 #if !TARGET_API_MAC_CARBON
2485 static PyObject
*Menu_SystemMenu(_self
, _args
)
2489 PyObject
*_res
= NULL
;
2491 if (!PyArg_ParseTuple(_args
, "l",
2494 SystemMenu(menuResult
);
2501 static PyObject
*Menu_IsMenuBarVisible(_self
, _args
)
2505 PyObject
*_res
= NULL
;
2507 if (!PyArg_ParseTuple(_args
, ""))
2509 _rv
= IsMenuBarVisible();
2510 _res
= Py_BuildValue("b",
2515 static PyObject
*Menu_ShowMenuBar(_self
, _args
)
2519 PyObject
*_res
= NULL
;
2520 if (!PyArg_ParseTuple(_args
, ""))
2528 static PyObject
*Menu_HideMenuBar(_self
, _args
)
2532 PyObject
*_res
= NULL
;
2533 if (!PyArg_ParseTuple(_args
, ""))
2541 static PyObject
*Menu_DeleteMCEntries(_self
, _args
)
2545 PyObject
*_res
= NULL
;
2548 if (!PyArg_ParseTuple(_args
, "hh",
2552 DeleteMCEntries(menuID
,
2559 static PyObject
*Menu_InitContextualMenus(_self
, _args
)
2563 PyObject
*_res
= NULL
;
2565 if (!PyArg_ParseTuple(_args
, ""))
2567 _err
= InitContextualMenus();
2568 if (_err
!= noErr
) return PyMac_Error(_err
);
2574 static PyObject
*Menu_IsShowContextualMenuClick(_self
, _args
)
2578 PyObject
*_res
= NULL
;
2580 EventRecord inEvent
;
2581 if (!PyArg_ParseTuple(_args
, "O&",
2582 PyMac_GetEventRecord
, &inEvent
))
2584 _rv
= IsShowContextualMenuClick(&inEvent
);
2585 _res
= Py_BuildValue("b",
2590 #if !TARGET_API_MAC_CARBON
2592 static PyObject
*Menu_OpenDeskAcc(_self
, _args
)
2596 PyObject
*_res
= NULL
;
2598 if (!PyArg_ParseTuple(_args
, "O&",
2599 PyMac_GetStr255
, name
))
2608 static PyObject
*Menu_as_Menu(_self
, _args
)
2612 PyObject
*_res
= NULL
;
2615 if (!PyArg_ParseTuple(_args
, "O&",
2616 ResObj_Convert
, &h
))
2619 _res
= Py_BuildValue("O&",
2624 static PyObject
*Menu_GetMenu(_self
, _args
)
2628 PyObject
*_res
= NULL
;
2631 if (!PyArg_ParseTuple(_args
, "h",
2634 _rv
= GetMenu(resourceID
);
2635 _res
= Py_BuildValue("O&",
2640 static PyObject
*Menu_DeleteMenu(_self
, _args
)
2644 PyObject
*_res
= NULL
;
2646 if (!PyArg_ParseTuple(_args
, "h",
2655 static PyObject
*Menu_DrawMenuBar(_self
, _args
)
2659 PyObject
*_res
= NULL
;
2660 if (!PyArg_ParseTuple(_args
, ""))
2668 static PyMethodDef Menu_methods
[] = {
2670 #if !TARGET_API_MAC_CARBON
2671 {"InitProcMenu", (PyCFunction
)Menu_InitProcMenu
, 1,
2672 "(short resID) -> None"},
2675 #if !TARGET_API_MAC_CARBON
2676 {"InitMenus", (PyCFunction
)Menu_InitMenus
, 1,
2679 {"NewMenu", (PyCFunction
)Menu_NewMenu
, 1,
2680 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
2681 {"MacGetMenu", (PyCFunction
)Menu_MacGetMenu
, 1,
2682 "(short resourceID) -> (MenuHandle _rv)"},
2684 #if TARGET_API_MAC_CARBON
2685 {"CreateNewMenu", (PyCFunction
)Menu_CreateNewMenu
, 1,
2686 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2688 {"MenuKey", (PyCFunction
)Menu_MenuKey
, 1,
2689 "(CharParameter ch) -> (long _rv)"},
2690 {"MenuSelect", (PyCFunction
)Menu_MenuSelect
, 1,
2691 "(Point startPt) -> (long _rv)"},
2692 {"MenuChoice", (PyCFunction
)Menu_MenuChoice
, 1,
2693 "() -> (long _rv)"},
2694 {"MenuEvent", (PyCFunction
)Menu_MenuEvent
, 1,
2695 "(EventRecord inEvent) -> (UInt32 _rv)"},
2696 {"GetMBarHeight", (PyCFunction
)Menu_GetMBarHeight
, 1,
2697 "() -> (short _rv)"},
2698 {"MacDrawMenuBar", (PyCFunction
)Menu_MacDrawMenuBar
, 1,
2700 {"InvalMenuBar", (PyCFunction
)Menu_InvalMenuBar
, 1,
2702 {"HiliteMenu", (PyCFunction
)Menu_HiliteMenu
, 1,
2703 "(MenuID menuID) -> None"},
2704 {"GetNewMBar", (PyCFunction
)Menu_GetNewMBar
, 1,
2705 "(short menuBarID) -> (MenuBarHandle _rv)"},
2706 {"GetMenuBar", (PyCFunction
)Menu_GetMenuBar
, 1,
2707 "() -> (MenuBarHandle _rv)"},
2708 {"SetMenuBar", (PyCFunction
)Menu_SetMenuBar
, 1,
2709 "(MenuBarHandle mbar) -> None"},
2711 #if TARGET_API_MAC_CARBON
2712 {"DuplicateMenuBar", (PyCFunction
)Menu_DuplicateMenuBar
, 1,
2713 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2716 #if TARGET_API_MAC_CARBON
2717 {"DisposeMenuBar", (PyCFunction
)Menu_DisposeMenuBar
, 1,
2718 "(MenuBarHandle mbar) -> None"},
2720 {"GetMenuHandle", (PyCFunction
)Menu_GetMenuHandle
, 1,
2721 "(MenuID menuID) -> (MenuHandle _rv)"},
2722 {"MacDeleteMenu", (PyCFunction
)Menu_MacDeleteMenu
, 1,
2723 "(MenuID menuID) -> None"},
2724 {"ClearMenuBar", (PyCFunction
)Menu_ClearMenuBar
, 1,
2726 {"SetMenuFlashCount", (PyCFunction
)Menu_SetMenuFlashCount
, 1,
2727 "(short count) -> None"},
2729 #if !TARGET_API_MAC_CARBON
2730 {"SetMenuFlash", (PyCFunction
)Menu_SetMenuFlash
, 1,
2731 "(short count) -> None"},
2733 {"FlashMenuBar", (PyCFunction
)Menu_FlashMenuBar
, 1,
2734 "(MenuID menuID) -> None"},
2736 #if !TARGET_API_MAC_CARBON
2737 {"SystemEdit", (PyCFunction
)Menu_SystemEdit
, 1,
2738 "(short editCmd) -> (Boolean _rv)"},
2741 #if !TARGET_API_MAC_CARBON
2742 {"SystemMenu", (PyCFunction
)Menu_SystemMenu
, 1,
2743 "(long menuResult) -> None"},
2745 {"IsMenuBarVisible", (PyCFunction
)Menu_IsMenuBarVisible
, 1,
2746 "() -> (Boolean _rv)"},
2747 {"ShowMenuBar", (PyCFunction
)Menu_ShowMenuBar
, 1,
2749 {"HideMenuBar", (PyCFunction
)Menu_HideMenuBar
, 1,
2751 {"DeleteMCEntries", (PyCFunction
)Menu_DeleteMCEntries
, 1,
2752 "(MenuID menuID, short menuItem) -> None"},
2753 {"InitContextualMenus", (PyCFunction
)Menu_InitContextualMenus
, 1,
2755 {"IsShowContextualMenuClick", (PyCFunction
)Menu_IsShowContextualMenuClick
, 1,
2756 "(EventRecord inEvent) -> (Boolean _rv)"},
2758 #if !TARGET_API_MAC_CARBON
2759 {"OpenDeskAcc", (PyCFunction
)Menu_OpenDeskAcc
, 1,
2760 "(Str255 name) -> None"},
2762 {"as_Menu", (PyCFunction
)Menu_as_Menu
, 1,
2763 "(Handle h) -> (MenuHandle _rv)"},
2764 {"GetMenu", (PyCFunction
)Menu_GetMenu
, 1,
2765 "(short resourceID) -> (MenuHandle _rv)"},
2766 {"DeleteMenu", (PyCFunction
)Menu_DeleteMenu
, 1,
2767 "(short menuID) -> None"},
2768 {"DrawMenuBar", (PyCFunction
)Menu_DrawMenuBar
, 1,
2784 m
= Py_InitModule("Menu", Menu_methods
);
2785 d
= PyModule_GetDict(m
);
2786 Menu_Error
= PyMac_GetOSErrException();
2787 if (Menu_Error
== NULL
||
2788 PyDict_SetItemString(d
, "Error", Menu_Error
) != 0)
2790 Menu_Type
.ob_type
= &PyType_Type
;
2791 Py_INCREF(&Menu_Type
);
2792 if (PyDict_SetItemString(d
, "MenuType", (PyObject
*)&Menu_Type
) != 0)
2793 Py_FatalError("can't initialize MenuType");
2796 /* ======================== End module Menu ========================= */