2 /* ========================== Module _Menu ========================== */
9 #include "pywintoolbox.h"
12 #include "pymactoolbox.h"
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
23 #ifdef WITHOUT_FRAMEWORKS
24 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
27 #include <Carbon/Carbon.h>
31 #ifdef USE_TOOLBOX_OBJECT_GLUE
33 extern PyObject
*_MenuObj_New(MenuHandle
);
34 extern int _MenuObj_Convert(PyObject
*, MenuHandle
*);
36 #define MenuObj_New _MenuObj_New
37 #define MenuObj_Convert _MenuObj_Convert
40 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
41 #define GetMenuID(menu) ((*(menu))->menuID)
42 #define GetMenuWidth(menu) ((*(menu))->menuWidth)
43 #define GetMenuHeight(menu) ((*(menu))->menuHeight)
45 #define SetMenuID(menu, id) ((*(menu))->menuID = (id))
46 #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
47 #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
50 #define as_Menu(h) ((MenuHandle)h)
51 #define as_Resource(h) ((Handle)h)
54 /* Alternative version of MenuObj_New, which returns None for NULL argument */
55 PyObject
*OptMenuObj_New(MenuRef itself
)
61 return MenuObj_New(itself
);
64 /* Alternative version of MenuObj_Convert, which returns NULL for a None argument */
65 int OptMenuObj_Convert(PyObject
*v
, MenuRef
*p_itself
)
73 return MenuObj_Convert(v
, p_itself
);
76 static PyObject
*Menu_Error
;
78 /* ------------------------ Object type Menu ------------------------ */
80 PyTypeObject Menu_Type
;
82 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
84 typedef struct MenuObject
{
89 PyObject
*MenuObj_New(MenuHandle itself
)
92 it
= PyObject_NEW(MenuObject
, &Menu_Type
);
93 if (it
== NULL
) return NULL
;
94 it
->ob_itself
= itself
;
95 return (PyObject
*)it
;
97 int MenuObj_Convert(PyObject
*v
, MenuHandle
*p_itself
)
99 if (!MenuObj_Check(v
))
101 PyErr_SetString(PyExc_TypeError
, "Menu required");
104 *p_itself
= ((MenuObject
*)v
)->ob_itself
;
108 static void MenuObj_dealloc(MenuObject
*self
)
110 /* Cleanup of self->ob_itself goes here */
114 static PyObject
*MenuObj_DisposeMenu(MenuObject
*_self
, PyObject
*_args
)
116 PyObject
*_res
= NULL
;
118 PyMac_PRECHECK(DisposeMenu
);
120 if (!PyArg_ParseTuple(_args
, ""))
122 DisposeMenu(_self
->ob_itself
);
128 static PyObject
*MenuObj_CalcMenuSize(MenuObject
*_self
, PyObject
*_args
)
130 PyObject
*_res
= NULL
;
132 PyMac_PRECHECK(CalcMenuSize
);
134 if (!PyArg_ParseTuple(_args
, ""))
136 CalcMenuSize(_self
->ob_itself
);
142 #if !TARGET_API_MAC_CARBON
144 static PyObject
*MenuObj_CountMItems(MenuObject
*_self
, PyObject
*_args
)
146 PyObject
*_res
= NULL
;
149 PyMac_PRECHECK(CountMItems
);
151 if (!PyArg_ParseTuple(_args
, ""))
153 _rv
= CountMItems(_self
->ob_itself
);
154 _res
= Py_BuildValue("h",
160 static PyObject
*MenuObj_CountMenuItems(MenuObject
*_self
, PyObject
*_args
)
162 PyObject
*_res
= NULL
;
164 #ifndef CountMenuItems
165 PyMac_PRECHECK(CountMenuItems
);
167 if (!PyArg_ParseTuple(_args
, ""))
169 _rv
= CountMenuItems(_self
->ob_itself
);
170 _res
= Py_BuildValue("h",
175 static PyObject
*MenuObj_GetMenuFont(MenuObject
*_self
, PyObject
*_args
)
177 PyObject
*_res
= NULL
;
182 PyMac_PRECHECK(GetMenuFont
);
184 if (!PyArg_ParseTuple(_args
, ""))
186 _err
= GetMenuFont(_self
->ob_itself
,
189 if (_err
!= noErr
) return PyMac_Error(_err
);
190 _res
= Py_BuildValue("hH",
196 static PyObject
*MenuObj_SetMenuFont(MenuObject
*_self
, PyObject
*_args
)
198 PyObject
*_res
= NULL
;
203 PyMac_PRECHECK(SetMenuFont
);
205 if (!PyArg_ParseTuple(_args
, "hH",
209 _err
= SetMenuFont(_self
->ob_itself
,
212 if (_err
!= noErr
) return PyMac_Error(_err
);
218 static PyObject
*MenuObj_GetMenuExcludesMarkColumn(MenuObject
*_self
, PyObject
*_args
)
220 PyObject
*_res
= NULL
;
222 #ifndef GetMenuExcludesMarkColumn
223 PyMac_PRECHECK(GetMenuExcludesMarkColumn
);
225 if (!PyArg_ParseTuple(_args
, ""))
227 _rv
= GetMenuExcludesMarkColumn(_self
->ob_itself
);
228 _res
= Py_BuildValue("b",
233 static PyObject
*MenuObj_SetMenuExcludesMarkColumn(MenuObject
*_self
, PyObject
*_args
)
235 PyObject
*_res
= NULL
;
237 Boolean excludesMark
;
238 #ifndef SetMenuExcludesMarkColumn
239 PyMac_PRECHECK(SetMenuExcludesMarkColumn
);
241 if (!PyArg_ParseTuple(_args
, "b",
244 _err
= SetMenuExcludesMarkColumn(_self
->ob_itself
,
246 if (_err
!= noErr
) return PyMac_Error(_err
);
252 #if TARGET_API_MAC_CARBON
254 static PyObject
*MenuObj_IsValidMenu(MenuObject
*_self
, PyObject
*_args
)
256 PyObject
*_res
= NULL
;
259 PyMac_PRECHECK(IsValidMenu
);
261 if (!PyArg_ParseTuple(_args
, ""))
263 _rv
= IsValidMenu(_self
->ob_itself
);
264 _res
= Py_BuildValue("b",
270 #if TARGET_API_MAC_CARBON
272 static PyObject
*MenuObj_GetMenuRetainCount(MenuObject
*_self
, PyObject
*_args
)
274 PyObject
*_res
= NULL
;
276 #ifndef GetMenuRetainCount
277 PyMac_PRECHECK(GetMenuRetainCount
);
279 if (!PyArg_ParseTuple(_args
, ""))
281 _rv
= GetMenuRetainCount(_self
->ob_itself
);
282 _res
= Py_BuildValue("l",
288 #if TARGET_API_MAC_CARBON
290 static PyObject
*MenuObj_RetainMenu(MenuObject
*_self
, PyObject
*_args
)
292 PyObject
*_res
= NULL
;
295 PyMac_PRECHECK(RetainMenu
);
297 if (!PyArg_ParseTuple(_args
, ""))
299 _err
= RetainMenu(_self
->ob_itself
);
300 if (_err
!= noErr
) return PyMac_Error(_err
);
307 #if TARGET_API_MAC_CARBON
309 static PyObject
*MenuObj_ReleaseMenu(MenuObject
*_self
, PyObject
*_args
)
311 PyObject
*_res
= NULL
;
314 PyMac_PRECHECK(ReleaseMenu
);
316 if (!PyArg_ParseTuple(_args
, ""))
318 _err
= ReleaseMenu(_self
->ob_itself
);
319 if (_err
!= noErr
) return PyMac_Error(_err
);
326 #if TARGET_API_MAC_CARBON
328 static PyObject
*MenuObj_DuplicateMenu(MenuObject
*_self
, PyObject
*_args
)
330 PyObject
*_res
= NULL
;
333 #ifndef DuplicateMenu
334 PyMac_PRECHECK(DuplicateMenu
);
336 if (!PyArg_ParseTuple(_args
, ""))
338 _err
= DuplicateMenu(_self
->ob_itself
,
340 if (_err
!= noErr
) return PyMac_Error(_err
);
341 _res
= Py_BuildValue("O&",
342 MenuObj_New
, outMenu
);
347 #if TARGET_API_MAC_CARBON
349 static PyObject
*MenuObj_CopyMenuTitleAsCFString(MenuObject
*_self
, PyObject
*_args
)
351 PyObject
*_res
= NULL
;
353 CFStringRef outString
;
354 #ifndef CopyMenuTitleAsCFString
355 PyMac_PRECHECK(CopyMenuTitleAsCFString
);
357 if (!PyArg_ParseTuple(_args
, ""))
359 _err
= CopyMenuTitleAsCFString(_self
->ob_itself
,
361 if (_err
!= noErr
) return PyMac_Error(_err
);
362 _res
= Py_BuildValue("O&",
363 CFStringRefObj_New
, outString
);
368 #if TARGET_API_MAC_CARBON
370 static PyObject
*MenuObj_SetMenuTitleWithCFString(MenuObject
*_self
, PyObject
*_args
)
372 PyObject
*_res
= NULL
;
374 CFStringRef inString
;
375 #ifndef SetMenuTitleWithCFString
376 PyMac_PRECHECK(SetMenuTitleWithCFString
);
378 if (!PyArg_ParseTuple(_args
, "O&",
379 CFStringRefObj_Convert
, &inString
))
381 _err
= SetMenuTitleWithCFString(_self
->ob_itself
,
383 if (_err
!= noErr
) return PyMac_Error(_err
);
390 #if TARGET_API_MAC_CARBON
392 static PyObject
*MenuObj_InvalidateMenuSize(MenuObject
*_self
, PyObject
*_args
)
394 PyObject
*_res
= NULL
;
396 #ifndef InvalidateMenuSize
397 PyMac_PRECHECK(InvalidateMenuSize
);
399 if (!PyArg_ParseTuple(_args
, ""))
401 _err
= InvalidateMenuSize(_self
->ob_itself
);
402 if (_err
!= noErr
) return PyMac_Error(_err
);
409 #if TARGET_API_MAC_CARBON
411 static PyObject
*MenuObj_IsMenuSizeInvalid(MenuObject
*_self
, PyObject
*_args
)
413 PyObject
*_res
= NULL
;
415 #ifndef IsMenuSizeInvalid
416 PyMac_PRECHECK(IsMenuSizeInvalid
);
418 if (!PyArg_ParseTuple(_args
, ""))
420 _rv
= IsMenuSizeInvalid(_self
->ob_itself
);
421 _res
= Py_BuildValue("b",
427 static PyObject
*MenuObj_MacAppendMenu(MenuObject
*_self
, PyObject
*_args
)
429 PyObject
*_res
= NULL
;
431 #ifndef MacAppendMenu
432 PyMac_PRECHECK(MacAppendMenu
);
434 if (!PyArg_ParseTuple(_args
, "O&",
435 PyMac_GetStr255
, data
))
437 MacAppendMenu(_self
->ob_itself
,
444 static PyObject
*MenuObj_InsertResMenu(MenuObject
*_self
, PyObject
*_args
)
446 PyObject
*_res
= NULL
;
449 #ifndef InsertResMenu
450 PyMac_PRECHECK(InsertResMenu
);
452 if (!PyArg_ParseTuple(_args
, "O&h",
453 PyMac_GetOSType
, &theType
,
456 InsertResMenu(_self
->ob_itself
,
464 static PyObject
*MenuObj_AppendResMenu(MenuObject
*_self
, PyObject
*_args
)
466 PyObject
*_res
= NULL
;
468 #ifndef AppendResMenu
469 PyMac_PRECHECK(AppendResMenu
);
471 if (!PyArg_ParseTuple(_args
, "O&",
472 PyMac_GetOSType
, &theType
))
474 AppendResMenu(_self
->ob_itself
,
481 static PyObject
*MenuObj_MacInsertMenuItem(MenuObject
*_self
, PyObject
*_args
)
483 PyObject
*_res
= NULL
;
486 #ifndef MacInsertMenuItem
487 PyMac_PRECHECK(MacInsertMenuItem
);
489 if (!PyArg_ParseTuple(_args
, "O&h",
490 PyMac_GetStr255
, itemString
,
493 MacInsertMenuItem(_self
->ob_itself
,
501 static PyObject
*MenuObj_DeleteMenuItem(MenuObject
*_self
, PyObject
*_args
)
503 PyObject
*_res
= NULL
;
505 #ifndef DeleteMenuItem
506 PyMac_PRECHECK(DeleteMenuItem
);
508 if (!PyArg_ParseTuple(_args
, "h",
511 DeleteMenuItem(_self
->ob_itself
,
518 static PyObject
*MenuObj_InsertFontResMenu(MenuObject
*_self
, PyObject
*_args
)
520 PyObject
*_res
= NULL
;
523 #ifndef InsertFontResMenu
524 PyMac_PRECHECK(InsertFontResMenu
);
526 if (!PyArg_ParseTuple(_args
, "hh",
530 InsertFontResMenu(_self
->ob_itself
,
538 static PyObject
*MenuObj_InsertIntlResMenu(MenuObject
*_self
, PyObject
*_args
)
540 PyObject
*_res
= NULL
;
544 #ifndef InsertIntlResMenu
545 PyMac_PRECHECK(InsertIntlResMenu
);
547 if (!PyArg_ParseTuple(_args
, "O&hh",
548 PyMac_GetOSType
, &theType
,
552 InsertIntlResMenu(_self
->ob_itself
,
561 static PyObject
*MenuObj_AppendMenuItemText(MenuObject
*_self
, PyObject
*_args
)
563 PyObject
*_res
= NULL
;
566 #ifndef AppendMenuItemText
567 PyMac_PRECHECK(AppendMenuItemText
);
569 if (!PyArg_ParseTuple(_args
, "O&",
570 PyMac_GetStr255
, inString
))
572 _err
= AppendMenuItemText(_self
->ob_itself
,
574 if (_err
!= noErr
) return PyMac_Error(_err
);
580 static PyObject
*MenuObj_InsertMenuItemText(MenuObject
*_self
, PyObject
*_args
)
582 PyObject
*_res
= NULL
;
585 MenuItemIndex afterItem
;
586 #ifndef InsertMenuItemText
587 PyMac_PRECHECK(InsertMenuItemText
);
589 if (!PyArg_ParseTuple(_args
, "O&h",
590 PyMac_GetStr255
, inString
,
593 _err
= InsertMenuItemText(_self
->ob_itself
,
596 if (_err
!= noErr
) return PyMac_Error(_err
);
602 #if TARGET_API_MAC_CARBON
604 static PyObject
*MenuObj_CopyMenuItems(MenuObject
*_self
, PyObject
*_args
)
606 PyObject
*_res
= NULL
;
608 MenuItemIndex inFirstItem
;
609 ItemCount inNumItems
;
610 MenuHandle inDestMenu
;
611 MenuItemIndex inInsertAfter
;
612 #ifndef CopyMenuItems
613 PyMac_PRECHECK(CopyMenuItems
);
615 if (!PyArg_ParseTuple(_args
, "hlO&h",
618 MenuObj_Convert
, &inDestMenu
,
621 _err
= CopyMenuItems(_self
->ob_itself
,
626 if (_err
!= noErr
) return PyMac_Error(_err
);
633 #if TARGET_API_MAC_CARBON
635 static PyObject
*MenuObj_DeleteMenuItems(MenuObject
*_self
, PyObject
*_args
)
637 PyObject
*_res
= NULL
;
639 MenuItemIndex inFirstItem
;
640 ItemCount inNumItems
;
641 #ifndef DeleteMenuItems
642 PyMac_PRECHECK(DeleteMenuItems
);
644 if (!PyArg_ParseTuple(_args
, "hl",
648 _err
= DeleteMenuItems(_self
->ob_itself
,
651 if (_err
!= noErr
) return PyMac_Error(_err
);
658 #if TARGET_API_MAC_CARBON
660 static PyObject
*MenuObj_AppendMenuItemTextWithCFString(MenuObject
*_self
, PyObject
*_args
)
662 PyObject
*_res
= NULL
;
664 CFStringRef inString
;
665 MenuItemAttributes inAttributes
;
666 MenuCommand inCommandID
;
667 MenuItemIndex outNewItem
;
668 #ifndef AppendMenuItemTextWithCFString
669 PyMac_PRECHECK(AppendMenuItemTextWithCFString
);
671 if (!PyArg_ParseTuple(_args
, "O&ll",
672 CFStringRefObj_Convert
, &inString
,
676 _err
= AppendMenuItemTextWithCFString(_self
->ob_itself
,
681 if (_err
!= noErr
) return PyMac_Error(_err
);
682 _res
= Py_BuildValue("h",
688 #if TARGET_API_MAC_CARBON
690 static PyObject
*MenuObj_InsertMenuItemTextWithCFString(MenuObject
*_self
, PyObject
*_args
)
692 PyObject
*_res
= NULL
;
694 CFStringRef inString
;
695 MenuItemIndex inAfterItem
;
696 MenuItemAttributes inAttributes
;
697 MenuCommand inCommandID
;
698 #ifndef InsertMenuItemTextWithCFString
699 PyMac_PRECHECK(InsertMenuItemTextWithCFString
);
701 if (!PyArg_ParseTuple(_args
, "O&hll",
702 CFStringRefObj_Convert
, &inString
,
707 _err
= InsertMenuItemTextWithCFString(_self
->ob_itself
,
712 if (_err
!= noErr
) return PyMac_Error(_err
);
719 static PyObject
*MenuObj_PopUpMenuSelect(MenuObject
*_self
, PyObject
*_args
)
721 PyObject
*_res
= NULL
;
726 #ifndef PopUpMenuSelect
727 PyMac_PRECHECK(PopUpMenuSelect
);
729 if (!PyArg_ParseTuple(_args
, "hhh",
734 _rv
= PopUpMenuSelect(_self
->ob_itself
,
738 _res
= Py_BuildValue("l",
743 #if TARGET_API_MAC_CARBON
745 static PyObject
*MenuObj_InvalidateMenuEnabling(MenuObject
*_self
, PyObject
*_args
)
747 PyObject
*_res
= NULL
;
749 #ifndef InvalidateMenuEnabling
750 PyMac_PRECHECK(InvalidateMenuEnabling
);
752 if (!PyArg_ParseTuple(_args
, ""))
754 _err
= InvalidateMenuEnabling(_self
->ob_itself
);
755 if (_err
!= noErr
) return PyMac_Error(_err
);
762 #if TARGET_API_MAC_CARBON
764 static PyObject
*MenuObj_IsMenuBarInvalid(MenuObject
*_self
, PyObject
*_args
)
766 PyObject
*_res
= NULL
;
768 #ifndef IsMenuBarInvalid
769 PyMac_PRECHECK(IsMenuBarInvalid
);
771 if (!PyArg_ParseTuple(_args
, ""))
773 _rv
= IsMenuBarInvalid(_self
->ob_itself
);
774 _res
= Py_BuildValue("b",
780 static PyObject
*MenuObj_MacInsertMenu(MenuObject
*_self
, PyObject
*_args
)
782 PyObject
*_res
= NULL
;
784 #ifndef MacInsertMenu
785 PyMac_PRECHECK(MacInsertMenu
);
787 if (!PyArg_ParseTuple(_args
, "h",
790 MacInsertMenu(_self
->ob_itself
,
797 #if TARGET_API_MAC_CARBON
799 static PyObject
*MenuObj_SetRootMenu(MenuObject
*_self
, PyObject
*_args
)
801 PyObject
*_res
= NULL
;
804 PyMac_PRECHECK(SetRootMenu
);
806 if (!PyArg_ParseTuple(_args
, ""))
808 _err
= SetRootMenu(_self
->ob_itself
);
809 if (_err
!= noErr
) return PyMac_Error(_err
);
816 #if !TARGET_API_MAC_CARBON
818 static PyObject
*MenuObj_CheckItem(MenuObject
*_self
, PyObject
*_args
)
820 PyObject
*_res
= NULL
;
824 PyMac_PRECHECK(CheckItem
);
826 if (!PyArg_ParseTuple(_args
, "hb",
830 CheckItem(_self
->ob_itself
,
839 static PyObject
*MenuObj_MacCheckMenuItem(MenuObject
*_self
, PyObject
*_args
)
841 PyObject
*_res
= NULL
;
844 #ifndef MacCheckMenuItem
845 PyMac_PRECHECK(MacCheckMenuItem
);
847 if (!PyArg_ParseTuple(_args
, "hb",
851 MacCheckMenuItem(_self
->ob_itself
,
859 static PyObject
*MenuObj_SetMenuItemText(MenuObject
*_self
, PyObject
*_args
)
861 PyObject
*_res
= NULL
;
864 #ifndef SetMenuItemText
865 PyMac_PRECHECK(SetMenuItemText
);
867 if (!PyArg_ParseTuple(_args
, "hO&",
869 PyMac_GetStr255
, itemString
))
871 SetMenuItemText(_self
->ob_itself
,
879 static PyObject
*MenuObj_GetMenuItemText(MenuObject
*_self
, PyObject
*_args
)
881 PyObject
*_res
= NULL
;
884 #ifndef GetMenuItemText
885 PyMac_PRECHECK(GetMenuItemText
);
887 if (!PyArg_ParseTuple(_args
, "h",
890 GetMenuItemText(_self
->ob_itself
,
893 _res
= Py_BuildValue("O&",
894 PyMac_BuildStr255
, itemString
);
898 static PyObject
*MenuObj_SetItemMark(MenuObject
*_self
, PyObject
*_args
)
900 PyObject
*_res
= NULL
;
902 CharParameter markChar
;
904 PyMac_PRECHECK(SetItemMark
);
906 if (!PyArg_ParseTuple(_args
, "hh",
910 SetItemMark(_self
->ob_itself
,
918 static PyObject
*MenuObj_GetItemMark(MenuObject
*_self
, PyObject
*_args
)
920 PyObject
*_res
= NULL
;
922 CharParameter markChar
;
924 PyMac_PRECHECK(GetItemMark
);
926 if (!PyArg_ParseTuple(_args
, "h",
929 GetItemMark(_self
->ob_itself
,
932 _res
= Py_BuildValue("h",
937 static PyObject
*MenuObj_SetItemCmd(MenuObject
*_self
, PyObject
*_args
)
939 PyObject
*_res
= NULL
;
941 CharParameter cmdChar
;
943 PyMac_PRECHECK(SetItemCmd
);
945 if (!PyArg_ParseTuple(_args
, "hh",
949 SetItemCmd(_self
->ob_itself
,
957 static PyObject
*MenuObj_GetItemCmd(MenuObject
*_self
, PyObject
*_args
)
959 PyObject
*_res
= NULL
;
961 CharParameter cmdChar
;
963 PyMac_PRECHECK(GetItemCmd
);
965 if (!PyArg_ParseTuple(_args
, "h",
968 GetItemCmd(_self
->ob_itself
,
971 _res
= Py_BuildValue("h",
976 static PyObject
*MenuObj_SetItemIcon(MenuObject
*_self
, PyObject
*_args
)
978 PyObject
*_res
= NULL
;
982 PyMac_PRECHECK(SetItemIcon
);
984 if (!PyArg_ParseTuple(_args
, "hh",
988 SetItemIcon(_self
->ob_itself
,
996 static PyObject
*MenuObj_GetItemIcon(MenuObject
*_self
, PyObject
*_args
)
998 PyObject
*_res
= NULL
;
1002 PyMac_PRECHECK(GetItemIcon
);
1004 if (!PyArg_ParseTuple(_args
, "h",
1007 GetItemIcon(_self
->ob_itself
,
1010 _res
= Py_BuildValue("h",
1015 static PyObject
*MenuObj_SetItemStyle(MenuObject
*_self
, PyObject
*_args
)
1017 PyObject
*_res
= NULL
;
1019 StyleParameter chStyle
;
1020 #ifndef SetItemStyle
1021 PyMac_PRECHECK(SetItemStyle
);
1023 if (!PyArg_ParseTuple(_args
, "hh",
1027 SetItemStyle(_self
->ob_itself
,
1035 static PyObject
*MenuObj_GetItemStyle(MenuObject
*_self
, PyObject
*_args
)
1037 PyObject
*_res
= NULL
;
1040 #ifndef GetItemStyle
1041 PyMac_PRECHECK(GetItemStyle
);
1043 if (!PyArg_ParseTuple(_args
, "h",
1046 GetItemStyle(_self
->ob_itself
,
1049 _res
= Py_BuildValue("b",
1054 #if !TARGET_API_MAC_CARBON
1056 static PyObject
*MenuObj_DisableItem(MenuObject
*_self
, PyObject
*_args
)
1058 PyObject
*_res
= NULL
;
1061 PyMac_PRECHECK(DisableItem
);
1063 if (!PyArg_ParseTuple(_args
, "h",
1066 DisableItem(_self
->ob_itself
,
1074 #if !TARGET_API_MAC_CARBON
1076 static PyObject
*MenuObj_EnableItem(MenuObject
*_self
, PyObject
*_args
)
1078 PyObject
*_res
= NULL
;
1081 PyMac_PRECHECK(EnableItem
);
1083 if (!PyArg_ParseTuple(_args
, "h",
1086 EnableItem(_self
->ob_itself
,
1094 static PyObject
*MenuObj_SetMenuItemCommandID(MenuObject
*_self
, PyObject
*_args
)
1096 PyObject
*_res
= NULL
;
1099 MenuCommand inCommandID
;
1100 #ifndef SetMenuItemCommandID
1101 PyMac_PRECHECK(SetMenuItemCommandID
);
1103 if (!PyArg_ParseTuple(_args
, "hl",
1107 _err
= SetMenuItemCommandID(_self
->ob_itself
,
1110 if (_err
!= noErr
) return PyMac_Error(_err
);
1116 static PyObject
*MenuObj_GetMenuItemCommandID(MenuObject
*_self
, PyObject
*_args
)
1118 PyObject
*_res
= NULL
;
1121 MenuCommand outCommandID
;
1122 #ifndef GetMenuItemCommandID
1123 PyMac_PRECHECK(GetMenuItemCommandID
);
1125 if (!PyArg_ParseTuple(_args
, "h",
1128 _err
= GetMenuItemCommandID(_self
->ob_itself
,
1131 if (_err
!= noErr
) return PyMac_Error(_err
);
1132 _res
= Py_BuildValue("l",
1137 static PyObject
*MenuObj_SetMenuItemModifiers(MenuObject
*_self
, PyObject
*_args
)
1139 PyObject
*_res
= NULL
;
1143 #ifndef SetMenuItemModifiers
1144 PyMac_PRECHECK(SetMenuItemModifiers
);
1146 if (!PyArg_ParseTuple(_args
, "hb",
1150 _err
= SetMenuItemModifiers(_self
->ob_itself
,
1153 if (_err
!= noErr
) return PyMac_Error(_err
);
1159 static PyObject
*MenuObj_GetMenuItemModifiers(MenuObject
*_self
, PyObject
*_args
)
1161 PyObject
*_res
= NULL
;
1165 #ifndef GetMenuItemModifiers
1166 PyMac_PRECHECK(GetMenuItemModifiers
);
1168 if (!PyArg_ParseTuple(_args
, "h",
1171 _err
= GetMenuItemModifiers(_self
->ob_itself
,
1174 if (_err
!= noErr
) return PyMac_Error(_err
);
1175 _res
= Py_BuildValue("b",
1180 static PyObject
*MenuObj_SetMenuItemIconHandle(MenuObject
*_self
, PyObject
*_args
)
1182 PyObject
*_res
= NULL
;
1186 Handle inIconHandle
;
1187 #ifndef SetMenuItemIconHandle
1188 PyMac_PRECHECK(SetMenuItemIconHandle
);
1190 if (!PyArg_ParseTuple(_args
, "hbO&",
1193 ResObj_Convert
, &inIconHandle
))
1195 _err
= SetMenuItemIconHandle(_self
->ob_itself
,
1199 if (_err
!= noErr
) return PyMac_Error(_err
);
1205 static PyObject
*MenuObj_GetMenuItemIconHandle(MenuObject
*_self
, PyObject
*_args
)
1207 PyObject
*_res
= NULL
;
1211 Handle outIconHandle
;
1212 #ifndef GetMenuItemIconHandle
1213 PyMac_PRECHECK(GetMenuItemIconHandle
);
1215 if (!PyArg_ParseTuple(_args
, "h",
1218 _err
= GetMenuItemIconHandle(_self
->ob_itself
,
1222 if (_err
!= noErr
) return PyMac_Error(_err
);
1223 _res
= Py_BuildValue("bO&",
1225 ResObj_New
, outIconHandle
);
1229 static PyObject
*MenuObj_SetMenuItemTextEncoding(MenuObject
*_self
, PyObject
*_args
)
1231 PyObject
*_res
= NULL
;
1234 TextEncoding inScriptID
;
1235 #ifndef SetMenuItemTextEncoding
1236 PyMac_PRECHECK(SetMenuItemTextEncoding
);
1238 if (!PyArg_ParseTuple(_args
, "hl",
1242 _err
= SetMenuItemTextEncoding(_self
->ob_itself
,
1245 if (_err
!= noErr
) return PyMac_Error(_err
);
1251 static PyObject
*MenuObj_GetMenuItemTextEncoding(MenuObject
*_self
, PyObject
*_args
)
1253 PyObject
*_res
= NULL
;
1256 TextEncoding outScriptID
;
1257 #ifndef GetMenuItemTextEncoding
1258 PyMac_PRECHECK(GetMenuItemTextEncoding
);
1260 if (!PyArg_ParseTuple(_args
, "h",
1263 _err
= GetMenuItemTextEncoding(_self
->ob_itself
,
1266 if (_err
!= noErr
) return PyMac_Error(_err
);
1267 _res
= Py_BuildValue("l",
1272 static PyObject
*MenuObj_SetMenuItemHierarchicalID(MenuObject
*_self
, PyObject
*_args
)
1274 PyObject
*_res
= NULL
;
1278 #ifndef SetMenuItemHierarchicalID
1279 PyMac_PRECHECK(SetMenuItemHierarchicalID
);
1281 if (!PyArg_ParseTuple(_args
, "hh",
1285 _err
= SetMenuItemHierarchicalID(_self
->ob_itself
,
1288 if (_err
!= noErr
) return PyMac_Error(_err
);
1294 static PyObject
*MenuObj_GetMenuItemHierarchicalID(MenuObject
*_self
, PyObject
*_args
)
1296 PyObject
*_res
= NULL
;
1300 #ifndef GetMenuItemHierarchicalID
1301 PyMac_PRECHECK(GetMenuItemHierarchicalID
);
1303 if (!PyArg_ParseTuple(_args
, "h",
1306 _err
= GetMenuItemHierarchicalID(_self
->ob_itself
,
1309 if (_err
!= noErr
) return PyMac_Error(_err
);
1310 _res
= Py_BuildValue("h",
1315 static PyObject
*MenuObj_SetMenuItemFontID(MenuObject
*_self
, PyObject
*_args
)
1317 PyObject
*_res
= NULL
;
1321 #ifndef SetMenuItemFontID
1322 PyMac_PRECHECK(SetMenuItemFontID
);
1324 if (!PyArg_ParseTuple(_args
, "hh",
1328 _err
= SetMenuItemFontID(_self
->ob_itself
,
1331 if (_err
!= noErr
) return PyMac_Error(_err
);
1337 static PyObject
*MenuObj_GetMenuItemFontID(MenuObject
*_self
, PyObject
*_args
)
1339 PyObject
*_res
= NULL
;
1343 #ifndef GetMenuItemFontID
1344 PyMac_PRECHECK(GetMenuItemFontID
);
1346 if (!PyArg_ParseTuple(_args
, "h",
1349 _err
= GetMenuItemFontID(_self
->ob_itself
,
1352 if (_err
!= noErr
) return PyMac_Error(_err
);
1353 _res
= Py_BuildValue("h",
1358 static PyObject
*MenuObj_SetMenuItemRefCon(MenuObject
*_self
, PyObject
*_args
)
1360 PyObject
*_res
= NULL
;
1364 #ifndef SetMenuItemRefCon
1365 PyMac_PRECHECK(SetMenuItemRefCon
);
1367 if (!PyArg_ParseTuple(_args
, "hl",
1371 _err
= SetMenuItemRefCon(_self
->ob_itself
,
1374 if (_err
!= noErr
) return PyMac_Error(_err
);
1380 static PyObject
*MenuObj_GetMenuItemRefCon(MenuObject
*_self
, PyObject
*_args
)
1382 PyObject
*_res
= NULL
;
1386 #ifndef GetMenuItemRefCon
1387 PyMac_PRECHECK(GetMenuItemRefCon
);
1389 if (!PyArg_ParseTuple(_args
, "h",
1392 _err
= GetMenuItemRefCon(_self
->ob_itself
,
1395 if (_err
!= noErr
) return PyMac_Error(_err
);
1396 _res
= Py_BuildValue("l",
1401 #if !TARGET_API_MAC_CARBON
1403 static PyObject
*MenuObj_SetMenuItemRefCon2(MenuObject
*_self
, PyObject
*_args
)
1405 PyObject
*_res
= NULL
;
1409 #ifndef SetMenuItemRefCon2
1410 PyMac_PRECHECK(SetMenuItemRefCon2
);
1412 if (!PyArg_ParseTuple(_args
, "hl",
1416 _err
= SetMenuItemRefCon2(_self
->ob_itself
,
1419 if (_err
!= noErr
) return PyMac_Error(_err
);
1426 #if !TARGET_API_MAC_CARBON
1428 static PyObject
*MenuObj_GetMenuItemRefCon2(MenuObject
*_self
, PyObject
*_args
)
1430 PyObject
*_res
= NULL
;
1434 #ifndef GetMenuItemRefCon2
1435 PyMac_PRECHECK(GetMenuItemRefCon2
);
1437 if (!PyArg_ParseTuple(_args
, "h",
1440 _err
= GetMenuItemRefCon2(_self
->ob_itself
,
1443 if (_err
!= noErr
) return PyMac_Error(_err
);
1444 _res
= Py_BuildValue("l",
1450 static PyObject
*MenuObj_SetMenuItemKeyGlyph(MenuObject
*_self
, PyObject
*_args
)
1452 PyObject
*_res
= NULL
;
1456 #ifndef SetMenuItemKeyGlyph
1457 PyMac_PRECHECK(SetMenuItemKeyGlyph
);
1459 if (!PyArg_ParseTuple(_args
, "hh",
1463 _err
= SetMenuItemKeyGlyph(_self
->ob_itself
,
1466 if (_err
!= noErr
) return PyMac_Error(_err
);
1472 static PyObject
*MenuObj_GetMenuItemKeyGlyph(MenuObject
*_self
, PyObject
*_args
)
1474 PyObject
*_res
= NULL
;
1478 #ifndef GetMenuItemKeyGlyph
1479 PyMac_PRECHECK(GetMenuItemKeyGlyph
);
1481 if (!PyArg_ParseTuple(_args
, "h",
1484 _err
= GetMenuItemKeyGlyph(_self
->ob_itself
,
1487 if (_err
!= noErr
) return PyMac_Error(_err
);
1488 _res
= Py_BuildValue("h",
1493 static PyObject
*MenuObj_MacEnableMenuItem(MenuObject
*_self
, PyObject
*_args
)
1495 PyObject
*_res
= NULL
;
1497 #ifndef MacEnableMenuItem
1498 PyMac_PRECHECK(MacEnableMenuItem
);
1500 if (!PyArg_ParseTuple(_args
, "h",
1503 MacEnableMenuItem(_self
->ob_itself
,
1510 static PyObject
*MenuObj_DisableMenuItem(MenuObject
*_self
, PyObject
*_args
)
1512 PyObject
*_res
= NULL
;
1514 #ifndef DisableMenuItem
1515 PyMac_PRECHECK(DisableMenuItem
);
1517 if (!PyArg_ParseTuple(_args
, "h",
1520 DisableMenuItem(_self
->ob_itself
,
1527 static PyObject
*MenuObj_IsMenuItemEnabled(MenuObject
*_self
, PyObject
*_args
)
1529 PyObject
*_res
= NULL
;
1532 #ifndef IsMenuItemEnabled
1533 PyMac_PRECHECK(IsMenuItemEnabled
);
1535 if (!PyArg_ParseTuple(_args
, "h",
1538 _rv
= IsMenuItemEnabled(_self
->ob_itself
,
1540 _res
= Py_BuildValue("b",
1545 static PyObject
*MenuObj_EnableMenuItemIcon(MenuObject
*_self
, PyObject
*_args
)
1547 PyObject
*_res
= NULL
;
1549 #ifndef EnableMenuItemIcon
1550 PyMac_PRECHECK(EnableMenuItemIcon
);
1552 if (!PyArg_ParseTuple(_args
, "h",
1555 EnableMenuItemIcon(_self
->ob_itself
,
1562 static PyObject
*MenuObj_DisableMenuItemIcon(MenuObject
*_self
, PyObject
*_args
)
1564 PyObject
*_res
= NULL
;
1566 #ifndef DisableMenuItemIcon
1567 PyMac_PRECHECK(DisableMenuItemIcon
);
1569 if (!PyArg_ParseTuple(_args
, "h",
1572 DisableMenuItemIcon(_self
->ob_itself
,
1579 static PyObject
*MenuObj_IsMenuItemIconEnabled(MenuObject
*_self
, PyObject
*_args
)
1581 PyObject
*_res
= NULL
;
1584 #ifndef IsMenuItemIconEnabled
1585 PyMac_PRECHECK(IsMenuItemIconEnabled
);
1587 if (!PyArg_ParseTuple(_args
, "h",
1590 _rv
= IsMenuItemIconEnabled(_self
->ob_itself
,
1592 _res
= Py_BuildValue("b",
1597 #if TARGET_API_MAC_CARBON
1599 static PyObject
*MenuObj_SetMenuItemHierarchicalMenu(MenuObject
*_self
, PyObject
*_args
)
1601 PyObject
*_res
= NULL
;
1603 MenuItemIndex inItem
;
1604 MenuHandle inHierMenu
;
1605 #ifndef SetMenuItemHierarchicalMenu
1606 PyMac_PRECHECK(SetMenuItemHierarchicalMenu
);
1608 if (!PyArg_ParseTuple(_args
, "hO&",
1610 MenuObj_Convert
, &inHierMenu
))
1612 _err
= SetMenuItemHierarchicalMenu(_self
->ob_itself
,
1615 if (_err
!= noErr
) return PyMac_Error(_err
);
1622 #if TARGET_API_MAC_CARBON
1624 static PyObject
*MenuObj_GetMenuItemHierarchicalMenu(MenuObject
*_self
, PyObject
*_args
)
1626 PyObject
*_res
= NULL
;
1628 MenuItemIndex inItem
;
1629 MenuHandle outHierMenu
;
1630 #ifndef GetMenuItemHierarchicalMenu
1631 PyMac_PRECHECK(GetMenuItemHierarchicalMenu
);
1633 if (!PyArg_ParseTuple(_args
, "h",
1636 _err
= GetMenuItemHierarchicalMenu(_self
->ob_itself
,
1639 if (_err
!= noErr
) return PyMac_Error(_err
);
1640 _res
= Py_BuildValue("O&",
1641 OptMenuObj_New
, outHierMenu
);
1646 #if TARGET_API_MAC_CARBON
1648 static PyObject
*MenuObj_CopyMenuItemTextAsCFString(MenuObject
*_self
, PyObject
*_args
)
1650 PyObject
*_res
= NULL
;
1652 MenuItemIndex inItem
;
1653 CFStringRef outString
;
1654 #ifndef CopyMenuItemTextAsCFString
1655 PyMac_PRECHECK(CopyMenuItemTextAsCFString
);
1657 if (!PyArg_ParseTuple(_args
, "h",
1660 _err
= CopyMenuItemTextAsCFString(_self
->ob_itself
,
1663 if (_err
!= noErr
) return PyMac_Error(_err
);
1664 _res
= Py_BuildValue("O&",
1665 CFStringRefObj_New
, outString
);
1670 #if TARGET_API_MAC_CARBON
1672 static PyObject
*MenuObj_SetMenuItemTextWithCFString(MenuObject
*_self
, PyObject
*_args
)
1674 PyObject
*_res
= NULL
;
1676 MenuItemIndex inItem
;
1677 CFStringRef inString
;
1678 #ifndef SetMenuItemTextWithCFString
1679 PyMac_PRECHECK(SetMenuItemTextWithCFString
);
1681 if (!PyArg_ParseTuple(_args
, "hO&",
1683 CFStringRefObj_Convert
, &inString
))
1685 _err
= SetMenuItemTextWithCFString(_self
->ob_itself
,
1688 if (_err
!= noErr
) return PyMac_Error(_err
);
1695 #if TARGET_API_MAC_CARBON
1697 static PyObject
*MenuObj_GetMenuItemIndent(MenuObject
*_self
, PyObject
*_args
)
1699 PyObject
*_res
= NULL
;
1701 MenuItemIndex inItem
;
1703 #ifndef GetMenuItemIndent
1704 PyMac_PRECHECK(GetMenuItemIndent
);
1706 if (!PyArg_ParseTuple(_args
, "h",
1709 _err
= GetMenuItemIndent(_self
->ob_itself
,
1712 if (_err
!= noErr
) return PyMac_Error(_err
);
1713 _res
= Py_BuildValue("l",
1719 #if TARGET_API_MAC_CARBON
1721 static PyObject
*MenuObj_SetMenuItemIndent(MenuObject
*_self
, PyObject
*_args
)
1723 PyObject
*_res
= NULL
;
1725 MenuItemIndex inItem
;
1727 #ifndef SetMenuItemIndent
1728 PyMac_PRECHECK(SetMenuItemIndent
);
1730 if (!PyArg_ParseTuple(_args
, "hl",
1734 _err
= SetMenuItemIndent(_self
->ob_itself
,
1737 if (_err
!= noErr
) return PyMac_Error(_err
);
1744 #if TARGET_API_MAC_CARBON
1746 static PyObject
*MenuObj_GetMenuItemCommandKey(MenuObject
*_self
, PyObject
*_args
)
1748 PyObject
*_res
= NULL
;
1750 MenuItemIndex inItem
;
1751 Boolean inGetVirtualKey
;
1753 #ifndef GetMenuItemCommandKey
1754 PyMac_PRECHECK(GetMenuItemCommandKey
);
1756 if (!PyArg_ParseTuple(_args
, "hb",
1760 _err
= GetMenuItemCommandKey(_self
->ob_itself
,
1764 if (_err
!= noErr
) return PyMac_Error(_err
);
1765 _res
= Py_BuildValue("H",
1771 #if TARGET_API_MAC_CARBON
1773 static PyObject
*MenuObj_SetMenuItemCommandKey(MenuObject
*_self
, PyObject
*_args
)
1775 PyObject
*_res
= NULL
;
1777 MenuItemIndex inItem
;
1778 Boolean inSetVirtualKey
;
1780 #ifndef SetMenuItemCommandKey
1781 PyMac_PRECHECK(SetMenuItemCommandKey
);
1783 if (!PyArg_ParseTuple(_args
, "hbH",
1788 _err
= SetMenuItemCommandKey(_self
->ob_itself
,
1792 if (_err
!= noErr
) return PyMac_Error(_err
);
1799 #if TARGET_API_MAC_CARBON
1801 static PyObject
*MenuObj_GetMenuItemPropertyAttributes(MenuObject
*_self
, PyObject
*_args
)
1803 PyObject
*_res
= NULL
;
1806 OSType propertyCreator
;
1809 #ifndef GetMenuItemPropertyAttributes
1810 PyMac_PRECHECK(GetMenuItemPropertyAttributes
);
1812 if (!PyArg_ParseTuple(_args
, "hO&O&",
1814 PyMac_GetOSType
, &propertyCreator
,
1815 PyMac_GetOSType
, &propertyTag
))
1817 _err
= GetMenuItemPropertyAttributes(_self
->ob_itself
,
1822 if (_err
!= noErr
) return PyMac_Error(_err
);
1823 _res
= Py_BuildValue("l",
1829 #if TARGET_API_MAC_CARBON
1831 static PyObject
*MenuObj_ChangeMenuItemPropertyAttributes(MenuObject
*_self
, PyObject
*_args
)
1833 PyObject
*_res
= NULL
;
1836 OSType propertyCreator
;
1838 UInt32 attributesToSet
;
1839 UInt32 attributesToClear
;
1840 #ifndef ChangeMenuItemPropertyAttributes
1841 PyMac_PRECHECK(ChangeMenuItemPropertyAttributes
);
1843 if (!PyArg_ParseTuple(_args
, "hO&O&ll",
1845 PyMac_GetOSType
, &propertyCreator
,
1846 PyMac_GetOSType
, &propertyTag
,
1848 &attributesToClear
))
1850 _err
= ChangeMenuItemPropertyAttributes(_self
->ob_itself
,
1856 if (_err
!= noErr
) return PyMac_Error(_err
);
1863 #if TARGET_API_MAC_CARBON
1865 static PyObject
*MenuObj_GetMenuAttributes(MenuObject
*_self
, PyObject
*_args
)
1867 PyObject
*_res
= NULL
;
1869 MenuAttributes outAttributes
;
1870 #ifndef GetMenuAttributes
1871 PyMac_PRECHECK(GetMenuAttributes
);
1873 if (!PyArg_ParseTuple(_args
, ""))
1875 _err
= GetMenuAttributes(_self
->ob_itself
,
1877 if (_err
!= noErr
) return PyMac_Error(_err
);
1878 _res
= Py_BuildValue("l",
1884 #if TARGET_API_MAC_CARBON
1886 static PyObject
*MenuObj_ChangeMenuAttributes(MenuObject
*_self
, PyObject
*_args
)
1888 PyObject
*_res
= NULL
;
1890 MenuAttributes setTheseAttributes
;
1891 MenuAttributes clearTheseAttributes
;
1892 #ifndef ChangeMenuAttributes
1893 PyMac_PRECHECK(ChangeMenuAttributes
);
1895 if (!PyArg_ParseTuple(_args
, "ll",
1896 &setTheseAttributes
,
1897 &clearTheseAttributes
))
1899 _err
= ChangeMenuAttributes(_self
->ob_itself
,
1901 clearTheseAttributes
);
1902 if (_err
!= noErr
) return PyMac_Error(_err
);
1909 #if TARGET_API_MAC_CARBON
1911 static PyObject
*MenuObj_GetMenuItemAttributes(MenuObject
*_self
, PyObject
*_args
)
1913 PyObject
*_res
= NULL
;
1916 MenuItemAttributes outAttributes
;
1917 #ifndef GetMenuItemAttributes
1918 PyMac_PRECHECK(GetMenuItemAttributes
);
1920 if (!PyArg_ParseTuple(_args
, "h",
1923 _err
= GetMenuItemAttributes(_self
->ob_itself
,
1926 if (_err
!= noErr
) return PyMac_Error(_err
);
1927 _res
= Py_BuildValue("l",
1933 #if TARGET_API_MAC_CARBON
1935 static PyObject
*MenuObj_ChangeMenuItemAttributes(MenuObject
*_self
, PyObject
*_args
)
1937 PyObject
*_res
= NULL
;
1940 MenuItemAttributes setTheseAttributes
;
1941 MenuItemAttributes clearTheseAttributes
;
1942 #ifndef ChangeMenuItemAttributes
1943 PyMac_PRECHECK(ChangeMenuItemAttributes
);
1945 if (!PyArg_ParseTuple(_args
, "hll",
1947 &setTheseAttributes
,
1948 &clearTheseAttributes
))
1950 _err
= ChangeMenuItemAttributes(_self
->ob_itself
,
1953 clearTheseAttributes
);
1954 if (_err
!= noErr
) return PyMac_Error(_err
);
1961 #if TARGET_API_MAC_CARBON
1963 static PyObject
*MenuObj_DisableAllMenuItems(MenuObject
*_self
, PyObject
*_args
)
1965 PyObject
*_res
= NULL
;
1966 #ifndef DisableAllMenuItems
1967 PyMac_PRECHECK(DisableAllMenuItems
);
1969 if (!PyArg_ParseTuple(_args
, ""))
1971 DisableAllMenuItems(_self
->ob_itself
);
1978 #if TARGET_API_MAC_CARBON
1980 static PyObject
*MenuObj_EnableAllMenuItems(MenuObject
*_self
, PyObject
*_args
)
1982 PyObject
*_res
= NULL
;
1983 #ifndef EnableAllMenuItems
1984 PyMac_PRECHECK(EnableAllMenuItems
);
1986 if (!PyArg_ParseTuple(_args
, ""))
1988 EnableAllMenuItems(_self
->ob_itself
);
1995 #if TARGET_API_MAC_CARBON
1997 static PyObject
*MenuObj_MenuHasEnabledItems(MenuObject
*_self
, PyObject
*_args
)
1999 PyObject
*_res
= NULL
;
2001 #ifndef MenuHasEnabledItems
2002 PyMac_PRECHECK(MenuHasEnabledItems
);
2004 if (!PyArg_ParseTuple(_args
, ""))
2006 _rv
= MenuHasEnabledItems(_self
->ob_itself
);
2007 _res
= Py_BuildValue("b",
2013 #if TARGET_API_MAC_CARBON
2015 static PyObject
*MenuObj_GetMenuType(MenuObject
*_self
, PyObject
*_args
)
2017 PyObject
*_res
= NULL
;
2021 PyMac_PRECHECK(GetMenuType
);
2023 if (!PyArg_ParseTuple(_args
, ""))
2025 _err
= GetMenuType(_self
->ob_itself
,
2027 if (_err
!= noErr
) return PyMac_Error(_err
);
2028 _res
= Py_BuildValue("H",
2034 #if TARGET_API_MAC_CARBON
2036 static PyObject
*MenuObj_CountMenuItemsWithCommandID(MenuObject
*_self
, PyObject
*_args
)
2038 PyObject
*_res
= NULL
;
2040 MenuCommand inCommandID
;
2041 #ifndef CountMenuItemsWithCommandID
2042 PyMac_PRECHECK(CountMenuItemsWithCommandID
);
2044 if (!PyArg_ParseTuple(_args
, "l",
2047 _rv
= CountMenuItemsWithCommandID(_self
->ob_itself
,
2049 _res
= Py_BuildValue("l",
2055 #if TARGET_API_MAC_CARBON
2057 static PyObject
*MenuObj_GetIndMenuItemWithCommandID(MenuObject
*_self
, PyObject
*_args
)
2059 PyObject
*_res
= NULL
;
2061 MenuCommand inCommandID
;
2064 MenuItemIndex outIndex
;
2065 #ifndef GetIndMenuItemWithCommandID
2066 PyMac_PRECHECK(GetIndMenuItemWithCommandID
);
2068 if (!PyArg_ParseTuple(_args
, "ll",
2072 _err
= GetIndMenuItemWithCommandID(_self
->ob_itself
,
2077 if (_err
!= noErr
) return PyMac_Error(_err
);
2078 _res
= Py_BuildValue("O&h",
2079 MenuObj_New
, outMenu
,
2085 #if TARGET_API_MAC_CARBON
2087 static PyObject
*MenuObj_EnableMenuCommand(MenuObject
*_self
, PyObject
*_args
)
2089 PyObject
*_res
= NULL
;
2090 MenuCommand inCommandID
;
2091 #ifndef EnableMenuCommand
2092 PyMac_PRECHECK(EnableMenuCommand
);
2094 if (!PyArg_ParseTuple(_args
, "l",
2097 EnableMenuCommand(_self
->ob_itself
,
2105 #if TARGET_API_MAC_CARBON
2107 static PyObject
*MenuObj_DisableMenuCommand(MenuObject
*_self
, PyObject
*_args
)
2109 PyObject
*_res
= NULL
;
2110 MenuCommand inCommandID
;
2111 #ifndef DisableMenuCommand
2112 PyMac_PRECHECK(DisableMenuCommand
);
2114 if (!PyArg_ParseTuple(_args
, "l",
2117 DisableMenuCommand(_self
->ob_itself
,
2125 #if TARGET_API_MAC_CARBON
2127 static PyObject
*MenuObj_IsMenuCommandEnabled(MenuObject
*_self
, PyObject
*_args
)
2129 PyObject
*_res
= NULL
;
2131 MenuCommand inCommandID
;
2132 #ifndef IsMenuCommandEnabled
2133 PyMac_PRECHECK(IsMenuCommandEnabled
);
2135 if (!PyArg_ParseTuple(_args
, "l",
2138 _rv
= IsMenuCommandEnabled(_self
->ob_itself
,
2140 _res
= Py_BuildValue("b",
2146 #if TARGET_API_MAC_CARBON
2148 static PyObject
*MenuObj_SetMenuCommandMark(MenuObject
*_self
, PyObject
*_args
)
2150 PyObject
*_res
= NULL
;
2152 MenuCommand inCommandID
;
2154 #ifndef SetMenuCommandMark
2155 PyMac_PRECHECK(SetMenuCommandMark
);
2157 if (!PyArg_ParseTuple(_args
, "lh",
2161 _err
= SetMenuCommandMark(_self
->ob_itself
,
2164 if (_err
!= noErr
) return PyMac_Error(_err
);
2171 #if TARGET_API_MAC_CARBON
2173 static PyObject
*MenuObj_GetMenuCommandMark(MenuObject
*_self
, PyObject
*_args
)
2175 PyObject
*_res
= NULL
;
2177 MenuCommand inCommandID
;
2179 #ifndef GetMenuCommandMark
2180 PyMac_PRECHECK(GetMenuCommandMark
);
2182 if (!PyArg_ParseTuple(_args
, "l",
2185 _err
= GetMenuCommandMark(_self
->ob_itself
,
2188 if (_err
!= noErr
) return PyMac_Error(_err
);
2189 _res
= Py_BuildValue("h",
2195 #if TARGET_API_MAC_CARBON
2197 static PyObject
*MenuObj_GetMenuCommandPropertySize(MenuObject
*_self
, PyObject
*_args
)
2199 PyObject
*_res
= NULL
;
2201 MenuCommand inCommandID
;
2202 OSType inPropertyCreator
;
2203 OSType inPropertyTag
;
2205 #ifndef GetMenuCommandPropertySize
2206 PyMac_PRECHECK(GetMenuCommandPropertySize
);
2208 if (!PyArg_ParseTuple(_args
, "lO&O&",
2210 PyMac_GetOSType
, &inPropertyCreator
,
2211 PyMac_GetOSType
, &inPropertyTag
))
2213 _err
= GetMenuCommandPropertySize(_self
->ob_itself
,
2218 if (_err
!= noErr
) return PyMac_Error(_err
);
2219 _res
= Py_BuildValue("l",
2225 #if TARGET_API_MAC_CARBON
2227 static PyObject
*MenuObj_RemoveMenuCommandProperty(MenuObject
*_self
, PyObject
*_args
)
2229 PyObject
*_res
= NULL
;
2231 MenuCommand inCommandID
;
2232 OSType inPropertyCreator
;
2233 OSType inPropertyTag
;
2234 #ifndef RemoveMenuCommandProperty
2235 PyMac_PRECHECK(RemoveMenuCommandProperty
);
2237 if (!PyArg_ParseTuple(_args
, "lO&O&",
2239 PyMac_GetOSType
, &inPropertyCreator
,
2240 PyMac_GetOSType
, &inPropertyTag
))
2242 _err
= RemoveMenuCommandProperty(_self
->ob_itself
,
2246 if (_err
!= noErr
) return PyMac_Error(_err
);
2253 #if TARGET_API_MAC_CARBON
2255 static PyObject
*MenuObj_IsMenuItemInvalid(MenuObject
*_self
, PyObject
*_args
)
2257 PyObject
*_res
= NULL
;
2260 #ifndef IsMenuItemInvalid
2261 PyMac_PRECHECK(IsMenuItemInvalid
);
2263 if (!PyArg_ParseTuple(_args
, "h",
2266 _rv
= IsMenuItemInvalid(_self
->ob_itself
,
2268 _res
= Py_BuildValue("b",
2274 #if TARGET_API_MAC_CARBON
2276 static PyObject
*MenuObj_InvalidateMenuItems(MenuObject
*_self
, PyObject
*_args
)
2278 PyObject
*_res
= NULL
;
2280 MenuItemIndex firstItem
;
2282 #ifndef InvalidateMenuItems
2283 PyMac_PRECHECK(InvalidateMenuItems
);
2285 if (!PyArg_ParseTuple(_args
, "hl",
2289 _err
= InvalidateMenuItems(_self
->ob_itself
,
2292 if (_err
!= noErr
) return PyMac_Error(_err
);
2299 #if TARGET_API_MAC_CARBON
2301 static PyObject
*MenuObj_UpdateInvalidMenuItems(MenuObject
*_self
, PyObject
*_args
)
2303 PyObject
*_res
= NULL
;
2305 #ifndef UpdateInvalidMenuItems
2306 PyMac_PRECHECK(UpdateInvalidMenuItems
);
2308 if (!PyArg_ParseTuple(_args
, ""))
2310 _err
= UpdateInvalidMenuItems(_self
->ob_itself
);
2311 if (_err
!= noErr
) return PyMac_Error(_err
);
2318 #if TARGET_API_MAC_CARBON
2320 static PyObject
*MenuObj_CreateStandardFontMenu(MenuObject
*_self
, PyObject
*_args
)
2322 PyObject
*_res
= NULL
;
2324 MenuItemIndex afterItem
;
2325 MenuID firstHierMenuID
;
2327 ItemCount outHierMenuCount
;
2328 #ifndef CreateStandardFontMenu
2329 PyMac_PRECHECK(CreateStandardFontMenu
);
2331 if (!PyArg_ParseTuple(_args
, "hhl",
2336 _err
= CreateStandardFontMenu(_self
->ob_itself
,
2341 if (_err
!= noErr
) return PyMac_Error(_err
);
2342 _res
= Py_BuildValue("l",
2348 #if TARGET_API_MAC_CARBON
2350 static PyObject
*MenuObj_UpdateStandardFontMenu(MenuObject
*_self
, PyObject
*_args
)
2352 PyObject
*_res
= NULL
;
2354 ItemCount outHierMenuCount
;
2355 #ifndef UpdateStandardFontMenu
2356 PyMac_PRECHECK(UpdateStandardFontMenu
);
2358 if (!PyArg_ParseTuple(_args
, ""))
2360 _err
= UpdateStandardFontMenu(_self
->ob_itself
,
2362 if (_err
!= noErr
) return PyMac_Error(_err
);
2363 _res
= Py_BuildValue("l",
2369 #if TARGET_API_MAC_CARBON
2371 static PyObject
*MenuObj_GetFontFamilyFromMenuSelection(MenuObject
*_self
, PyObject
*_args
)
2373 PyObject
*_res
= NULL
;
2376 FMFontFamily outFontFamily
;
2377 FMFontStyle outStyle
;
2378 #ifndef GetFontFamilyFromMenuSelection
2379 PyMac_PRECHECK(GetFontFamilyFromMenuSelection
);
2381 if (!PyArg_ParseTuple(_args
, "h",
2384 _err
= GetFontFamilyFromMenuSelection(_self
->ob_itself
,
2388 if (_err
!= noErr
) return PyMac_Error(_err
);
2389 _res
= Py_BuildValue("hh",
2396 static PyObject
*MenuObj_GetMenuID(MenuObject
*_self
, PyObject
*_args
)
2398 PyObject
*_res
= NULL
;
2401 PyMac_PRECHECK(GetMenuID
);
2403 if (!PyArg_ParseTuple(_args
, ""))
2405 _rv
= GetMenuID(_self
->ob_itself
);
2406 _res
= Py_BuildValue("h",
2411 static PyObject
*MenuObj_GetMenuWidth(MenuObject
*_self
, PyObject
*_args
)
2413 PyObject
*_res
= NULL
;
2415 #ifndef GetMenuWidth
2416 PyMac_PRECHECK(GetMenuWidth
);
2418 if (!PyArg_ParseTuple(_args
, ""))
2420 _rv
= GetMenuWidth(_self
->ob_itself
);
2421 _res
= Py_BuildValue("h",
2426 static PyObject
*MenuObj_GetMenuHeight(MenuObject
*_self
, PyObject
*_args
)
2428 PyObject
*_res
= NULL
;
2430 #ifndef GetMenuHeight
2431 PyMac_PRECHECK(GetMenuHeight
);
2433 if (!PyArg_ParseTuple(_args
, ""))
2435 _rv
= GetMenuHeight(_self
->ob_itself
);
2436 _res
= Py_BuildValue("h",
2441 static PyObject
*MenuObj_SetMenuID(MenuObject
*_self
, PyObject
*_args
)
2443 PyObject
*_res
= NULL
;
2446 PyMac_PRECHECK(SetMenuID
);
2448 if (!PyArg_ParseTuple(_args
, "h",
2451 SetMenuID(_self
->ob_itself
,
2458 static PyObject
*MenuObj_SetMenuWidth(MenuObject
*_self
, PyObject
*_args
)
2460 PyObject
*_res
= NULL
;
2462 #ifndef SetMenuWidth
2463 PyMac_PRECHECK(SetMenuWidth
);
2465 if (!PyArg_ParseTuple(_args
, "h",
2468 SetMenuWidth(_self
->ob_itself
,
2475 static PyObject
*MenuObj_SetMenuHeight(MenuObject
*_self
, PyObject
*_args
)
2477 PyObject
*_res
= NULL
;
2479 #ifndef SetMenuHeight
2480 PyMac_PRECHECK(SetMenuHeight
);
2482 if (!PyArg_ParseTuple(_args
, "h",
2485 SetMenuHeight(_self
->ob_itself
,
2492 static PyObject
*MenuObj_as_Resource(MenuObject
*_self
, PyObject
*_args
)
2494 PyObject
*_res
= NULL
;
2497 PyMac_PRECHECK(as_Resource
);
2499 if (!PyArg_ParseTuple(_args
, ""))
2501 _rv
= as_Resource(_self
->ob_itself
);
2502 _res
= Py_BuildValue("O&",
2507 static PyObject
*MenuObj_AppendMenu(MenuObject
*_self
, PyObject
*_args
)
2509 PyObject
*_res
= NULL
;
2512 PyMac_PRECHECK(AppendMenu
);
2514 if (!PyArg_ParseTuple(_args
, "O&",
2515 PyMac_GetStr255
, data
))
2517 AppendMenu(_self
->ob_itself
,
2524 static PyObject
*MenuObj_InsertMenu(MenuObject
*_self
, PyObject
*_args
)
2526 PyObject
*_res
= NULL
;
2529 PyMac_PRECHECK(InsertMenu
);
2531 if (!PyArg_ParseTuple(_args
, "h",
2534 InsertMenu(_self
->ob_itself
,
2541 static PyObject
*MenuObj_InsertMenuItem(MenuObject
*_self
, PyObject
*_args
)
2543 PyObject
*_res
= NULL
;
2546 #ifndef InsertMenuItem
2547 PyMac_PRECHECK(InsertMenuItem
);
2549 if (!PyArg_ParseTuple(_args
, "O&h",
2550 PyMac_GetStr255
, itemString
,
2553 InsertMenuItem(_self
->ob_itself
,
2561 static PyObject
*MenuObj_EnableMenuItem(MenuObject
*_self
, PyObject
*_args
)
2563 PyObject
*_res
= NULL
;
2565 #ifndef EnableMenuItem
2566 PyMac_PRECHECK(EnableMenuItem
);
2568 if (!PyArg_ParseTuple(_args
, "H",
2571 EnableMenuItem(_self
->ob_itself
,
2578 static PyObject
*MenuObj_CheckMenuItem(MenuObject
*_self
, PyObject
*_args
)
2580 PyObject
*_res
= NULL
;
2583 #ifndef CheckMenuItem
2584 PyMac_PRECHECK(CheckMenuItem
);
2586 if (!PyArg_ParseTuple(_args
, "hb",
2590 CheckMenuItem(_self
->ob_itself
,
2598 static PyMethodDef MenuObj_methods
[] = {
2599 {"DisposeMenu", (PyCFunction
)MenuObj_DisposeMenu
, 1,
2601 {"CalcMenuSize", (PyCFunction
)MenuObj_CalcMenuSize
, 1,
2604 #if !TARGET_API_MAC_CARBON
2605 {"CountMItems", (PyCFunction
)MenuObj_CountMItems
, 1,
2606 "() -> (short _rv)"},
2608 {"CountMenuItems", (PyCFunction
)MenuObj_CountMenuItems
, 1,
2609 "() -> (short _rv)"},
2610 {"GetMenuFont", (PyCFunction
)MenuObj_GetMenuFont
, 1,
2611 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
2612 {"SetMenuFont", (PyCFunction
)MenuObj_SetMenuFont
, 1,
2613 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
2614 {"GetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_GetMenuExcludesMarkColumn
, 1,
2615 "() -> (Boolean _rv)"},
2616 {"SetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_SetMenuExcludesMarkColumn
, 1,
2617 "(Boolean excludesMark) -> None"},
2619 #if TARGET_API_MAC_CARBON
2620 {"IsValidMenu", (PyCFunction
)MenuObj_IsValidMenu
, 1,
2621 "() -> (Boolean _rv)"},
2624 #if TARGET_API_MAC_CARBON
2625 {"GetMenuRetainCount", (PyCFunction
)MenuObj_GetMenuRetainCount
, 1,
2626 "() -> (ItemCount _rv)"},
2629 #if TARGET_API_MAC_CARBON
2630 {"RetainMenu", (PyCFunction
)MenuObj_RetainMenu
, 1,
2634 #if TARGET_API_MAC_CARBON
2635 {"ReleaseMenu", (PyCFunction
)MenuObj_ReleaseMenu
, 1,
2639 #if TARGET_API_MAC_CARBON
2640 {"DuplicateMenu", (PyCFunction
)MenuObj_DuplicateMenu
, 1,
2641 "() -> (MenuHandle outMenu)"},
2644 #if TARGET_API_MAC_CARBON
2645 {"CopyMenuTitleAsCFString", (PyCFunction
)MenuObj_CopyMenuTitleAsCFString
, 1,
2646 "() -> (CFStringRef outString)"},
2649 #if TARGET_API_MAC_CARBON
2650 {"SetMenuTitleWithCFString", (PyCFunction
)MenuObj_SetMenuTitleWithCFString
, 1,
2651 "(CFStringRef inString) -> None"},
2654 #if TARGET_API_MAC_CARBON
2655 {"InvalidateMenuSize", (PyCFunction
)MenuObj_InvalidateMenuSize
, 1,
2659 #if TARGET_API_MAC_CARBON
2660 {"IsMenuSizeInvalid", (PyCFunction
)MenuObj_IsMenuSizeInvalid
, 1,
2661 "() -> (Boolean _rv)"},
2663 {"MacAppendMenu", (PyCFunction
)MenuObj_MacAppendMenu
, 1,
2664 "(Str255 data) -> None"},
2665 {"InsertResMenu", (PyCFunction
)MenuObj_InsertResMenu
, 1,
2666 "(ResType theType, short afterItem) -> None"},
2667 {"AppendResMenu", (PyCFunction
)MenuObj_AppendResMenu
, 1,
2668 "(ResType theType) -> None"},
2669 {"MacInsertMenuItem", (PyCFunction
)MenuObj_MacInsertMenuItem
, 1,
2670 "(Str255 itemString, short afterItem) -> None"},
2671 {"DeleteMenuItem", (PyCFunction
)MenuObj_DeleteMenuItem
, 1,
2672 "(short item) -> None"},
2673 {"InsertFontResMenu", (PyCFunction
)MenuObj_InsertFontResMenu
, 1,
2674 "(short afterItem, short scriptFilter) -> None"},
2675 {"InsertIntlResMenu", (PyCFunction
)MenuObj_InsertIntlResMenu
, 1,
2676 "(ResType theType, short afterItem, short scriptFilter) -> None"},
2677 {"AppendMenuItemText", (PyCFunction
)MenuObj_AppendMenuItemText
, 1,
2678 "(Str255 inString) -> None"},
2679 {"InsertMenuItemText", (PyCFunction
)MenuObj_InsertMenuItemText
, 1,
2680 "(Str255 inString, MenuItemIndex afterItem) -> None"},
2682 #if TARGET_API_MAC_CARBON
2683 {"CopyMenuItems", (PyCFunction
)MenuObj_CopyMenuItems
, 1,
2684 "(MenuItemIndex inFirstItem, ItemCount inNumItems, MenuHandle inDestMenu, MenuItemIndex inInsertAfter) -> None"},
2687 #if TARGET_API_MAC_CARBON
2688 {"DeleteMenuItems", (PyCFunction
)MenuObj_DeleteMenuItems
, 1,
2689 "(MenuItemIndex inFirstItem, ItemCount inNumItems) -> None"},
2692 #if TARGET_API_MAC_CARBON
2693 {"AppendMenuItemTextWithCFString", (PyCFunction
)MenuObj_AppendMenuItemTextWithCFString
, 1,
2694 "(CFStringRef inString, MenuItemAttributes inAttributes, MenuCommand inCommandID) -> (MenuItemIndex outNewItem)"},
2697 #if TARGET_API_MAC_CARBON
2698 {"InsertMenuItemTextWithCFString", (PyCFunction
)MenuObj_InsertMenuItemTextWithCFString
, 1,
2699 "(CFStringRef inString, MenuItemIndex inAfterItem, MenuItemAttributes inAttributes, MenuCommand inCommandID) -> None"},
2701 {"PopUpMenuSelect", (PyCFunction
)MenuObj_PopUpMenuSelect
, 1,
2702 "(short top, short left, short popUpItem) -> (long _rv)"},
2704 #if TARGET_API_MAC_CARBON
2705 {"InvalidateMenuEnabling", (PyCFunction
)MenuObj_InvalidateMenuEnabling
, 1,
2709 #if TARGET_API_MAC_CARBON
2710 {"IsMenuBarInvalid", (PyCFunction
)MenuObj_IsMenuBarInvalid
, 1,
2711 "() -> (Boolean _rv)"},
2713 {"MacInsertMenu", (PyCFunction
)MenuObj_MacInsertMenu
, 1,
2714 "(MenuID beforeID) -> None"},
2716 #if TARGET_API_MAC_CARBON
2717 {"SetRootMenu", (PyCFunction
)MenuObj_SetRootMenu
, 1,
2721 #if !TARGET_API_MAC_CARBON
2722 {"CheckItem", (PyCFunction
)MenuObj_CheckItem
, 1,
2723 "(short item, Boolean checked) -> None"},
2725 {"MacCheckMenuItem", (PyCFunction
)MenuObj_MacCheckMenuItem
, 1,
2726 "(short item, Boolean checked) -> None"},
2727 {"SetMenuItemText", (PyCFunction
)MenuObj_SetMenuItemText
, 1,
2728 "(short item, Str255 itemString) -> None"},
2729 {"GetMenuItemText", (PyCFunction
)MenuObj_GetMenuItemText
, 1,
2730 "(short item) -> (Str255 itemString)"},
2731 {"SetItemMark", (PyCFunction
)MenuObj_SetItemMark
, 1,
2732 "(short item, CharParameter markChar) -> None"},
2733 {"GetItemMark", (PyCFunction
)MenuObj_GetItemMark
, 1,
2734 "(short item) -> (CharParameter markChar)"},
2735 {"SetItemCmd", (PyCFunction
)MenuObj_SetItemCmd
, 1,
2736 "(short item, CharParameter cmdChar) -> None"},
2737 {"GetItemCmd", (PyCFunction
)MenuObj_GetItemCmd
, 1,
2738 "(short item) -> (CharParameter cmdChar)"},
2739 {"SetItemIcon", (PyCFunction
)MenuObj_SetItemIcon
, 1,
2740 "(short item, short iconIndex) -> None"},
2741 {"GetItemIcon", (PyCFunction
)MenuObj_GetItemIcon
, 1,
2742 "(short item) -> (short iconIndex)"},
2743 {"SetItemStyle", (PyCFunction
)MenuObj_SetItemStyle
, 1,
2744 "(short item, StyleParameter chStyle) -> None"},
2745 {"GetItemStyle", (PyCFunction
)MenuObj_GetItemStyle
, 1,
2746 "(short item) -> (Style chStyle)"},
2748 #if !TARGET_API_MAC_CARBON
2749 {"DisableItem", (PyCFunction
)MenuObj_DisableItem
, 1,
2750 "(short item) -> None"},
2753 #if !TARGET_API_MAC_CARBON
2754 {"EnableItem", (PyCFunction
)MenuObj_EnableItem
, 1,
2755 "(short item) -> None"},
2757 {"SetMenuItemCommandID", (PyCFunction
)MenuObj_SetMenuItemCommandID
, 1,
2758 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
2759 {"GetMenuItemCommandID", (PyCFunction
)MenuObj_GetMenuItemCommandID
, 1,
2760 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
2761 {"SetMenuItemModifiers", (PyCFunction
)MenuObj_SetMenuItemModifiers
, 1,
2762 "(SInt16 inItem, UInt8 inModifiers) -> None"},
2763 {"GetMenuItemModifiers", (PyCFunction
)MenuObj_GetMenuItemModifiers
, 1,
2764 "(SInt16 inItem) -> (UInt8 outModifiers)"},
2765 {"SetMenuItemIconHandle", (PyCFunction
)MenuObj_SetMenuItemIconHandle
, 1,
2766 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
2767 {"GetMenuItemIconHandle", (PyCFunction
)MenuObj_GetMenuItemIconHandle
, 1,
2768 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
2769 {"SetMenuItemTextEncoding", (PyCFunction
)MenuObj_SetMenuItemTextEncoding
, 1,
2770 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
2771 {"GetMenuItemTextEncoding", (PyCFunction
)MenuObj_GetMenuItemTextEncoding
, 1,
2772 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
2773 {"SetMenuItemHierarchicalID", (PyCFunction
)MenuObj_SetMenuItemHierarchicalID
, 1,
2774 "(SInt16 inItem, MenuID inHierID) -> None"},
2775 {"GetMenuItemHierarchicalID", (PyCFunction
)MenuObj_GetMenuItemHierarchicalID
, 1,
2776 "(SInt16 inItem) -> (MenuID outHierID)"},
2777 {"SetMenuItemFontID", (PyCFunction
)MenuObj_SetMenuItemFontID
, 1,
2778 "(SInt16 inItem, SInt16 inFontID) -> None"},
2779 {"GetMenuItemFontID", (PyCFunction
)MenuObj_GetMenuItemFontID
, 1,
2780 "(SInt16 inItem) -> (SInt16 outFontID)"},
2781 {"SetMenuItemRefCon", (PyCFunction
)MenuObj_SetMenuItemRefCon
, 1,
2782 "(SInt16 inItem, UInt32 inRefCon) -> None"},
2783 {"GetMenuItemRefCon", (PyCFunction
)MenuObj_GetMenuItemRefCon
, 1,
2784 "(SInt16 inItem) -> (UInt32 outRefCon)"},
2786 #if !TARGET_API_MAC_CARBON
2787 {"SetMenuItemRefCon2", (PyCFunction
)MenuObj_SetMenuItemRefCon2
, 1,
2788 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
2791 #if !TARGET_API_MAC_CARBON
2792 {"GetMenuItemRefCon2", (PyCFunction
)MenuObj_GetMenuItemRefCon2
, 1,
2793 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
2795 {"SetMenuItemKeyGlyph", (PyCFunction
)MenuObj_SetMenuItemKeyGlyph
, 1,
2796 "(SInt16 inItem, SInt16 inGlyph) -> None"},
2797 {"GetMenuItemKeyGlyph", (PyCFunction
)MenuObj_GetMenuItemKeyGlyph
, 1,
2798 "(SInt16 inItem) -> (SInt16 outGlyph)"},
2799 {"MacEnableMenuItem", (PyCFunction
)MenuObj_MacEnableMenuItem
, 1,
2800 "(MenuItemIndex item) -> None"},
2801 {"DisableMenuItem", (PyCFunction
)MenuObj_DisableMenuItem
, 1,
2802 "(MenuItemIndex item) -> None"},
2803 {"IsMenuItemEnabled", (PyCFunction
)MenuObj_IsMenuItemEnabled
, 1,
2804 "(MenuItemIndex item) -> (Boolean _rv)"},
2805 {"EnableMenuItemIcon", (PyCFunction
)MenuObj_EnableMenuItemIcon
, 1,
2806 "(MenuItemIndex item) -> None"},
2807 {"DisableMenuItemIcon", (PyCFunction
)MenuObj_DisableMenuItemIcon
, 1,
2808 "(MenuItemIndex item) -> None"},
2809 {"IsMenuItemIconEnabled", (PyCFunction
)MenuObj_IsMenuItemIconEnabled
, 1,
2810 "(MenuItemIndex item) -> (Boolean _rv)"},
2812 #if TARGET_API_MAC_CARBON
2813 {"SetMenuItemHierarchicalMenu", (PyCFunction
)MenuObj_SetMenuItemHierarchicalMenu
, 1,
2814 "(MenuItemIndex inItem, MenuHandle inHierMenu) -> None"},
2817 #if TARGET_API_MAC_CARBON
2818 {"GetMenuItemHierarchicalMenu", (PyCFunction
)MenuObj_GetMenuItemHierarchicalMenu
, 1,
2819 "(MenuItemIndex inItem) -> (MenuHandle outHierMenu)"},
2822 #if TARGET_API_MAC_CARBON
2823 {"CopyMenuItemTextAsCFString", (PyCFunction
)MenuObj_CopyMenuItemTextAsCFString
, 1,
2824 "(MenuItemIndex inItem) -> (CFStringRef outString)"},
2827 #if TARGET_API_MAC_CARBON
2828 {"SetMenuItemTextWithCFString", (PyCFunction
)MenuObj_SetMenuItemTextWithCFString
, 1,
2829 "(MenuItemIndex inItem, CFStringRef inString) -> None"},
2832 #if TARGET_API_MAC_CARBON
2833 {"GetMenuItemIndent", (PyCFunction
)MenuObj_GetMenuItemIndent
, 1,
2834 "(MenuItemIndex inItem) -> (UInt32 outIndent)"},
2837 #if TARGET_API_MAC_CARBON
2838 {"SetMenuItemIndent", (PyCFunction
)MenuObj_SetMenuItemIndent
, 1,
2839 "(MenuItemIndex inItem, UInt32 inIndent) -> None"},
2842 #if TARGET_API_MAC_CARBON
2843 {"GetMenuItemCommandKey", (PyCFunction
)MenuObj_GetMenuItemCommandKey
, 1,
2844 "(MenuItemIndex inItem, Boolean inGetVirtualKey) -> (UInt16 outKey)"},
2847 #if TARGET_API_MAC_CARBON
2848 {"SetMenuItemCommandKey", (PyCFunction
)MenuObj_SetMenuItemCommandKey
, 1,
2849 "(MenuItemIndex inItem, Boolean inSetVirtualKey, UInt16 inKey) -> None"},
2852 #if TARGET_API_MAC_CARBON
2853 {"GetMenuItemPropertyAttributes", (PyCFunction
)MenuObj_GetMenuItemPropertyAttributes
, 1,
2854 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
2857 #if TARGET_API_MAC_CARBON
2858 {"ChangeMenuItemPropertyAttributes", (PyCFunction
)MenuObj_ChangeMenuItemPropertyAttributes
, 1,
2859 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
2862 #if TARGET_API_MAC_CARBON
2863 {"GetMenuAttributes", (PyCFunction
)MenuObj_GetMenuAttributes
, 1,
2864 "() -> (MenuAttributes outAttributes)"},
2867 #if TARGET_API_MAC_CARBON
2868 {"ChangeMenuAttributes", (PyCFunction
)MenuObj_ChangeMenuAttributes
, 1,
2869 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
2872 #if TARGET_API_MAC_CARBON
2873 {"GetMenuItemAttributes", (PyCFunction
)MenuObj_GetMenuItemAttributes
, 1,
2874 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
2877 #if TARGET_API_MAC_CARBON
2878 {"ChangeMenuItemAttributes", (PyCFunction
)MenuObj_ChangeMenuItemAttributes
, 1,
2879 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
2882 #if TARGET_API_MAC_CARBON
2883 {"DisableAllMenuItems", (PyCFunction
)MenuObj_DisableAllMenuItems
, 1,
2887 #if TARGET_API_MAC_CARBON
2888 {"EnableAllMenuItems", (PyCFunction
)MenuObj_EnableAllMenuItems
, 1,
2892 #if TARGET_API_MAC_CARBON
2893 {"MenuHasEnabledItems", (PyCFunction
)MenuObj_MenuHasEnabledItems
, 1,
2894 "() -> (Boolean _rv)"},
2897 #if TARGET_API_MAC_CARBON
2898 {"GetMenuType", (PyCFunction
)MenuObj_GetMenuType
, 1,
2899 "() -> (UInt16 outType)"},
2902 #if TARGET_API_MAC_CARBON
2903 {"CountMenuItemsWithCommandID", (PyCFunction
)MenuObj_CountMenuItemsWithCommandID
, 1,
2904 "(MenuCommand inCommandID) -> (ItemCount _rv)"},
2907 #if TARGET_API_MAC_CARBON
2908 {"GetIndMenuItemWithCommandID", (PyCFunction
)MenuObj_GetIndMenuItemWithCommandID
, 1,
2909 "(MenuCommand inCommandID, UInt32 inItemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
2912 #if TARGET_API_MAC_CARBON
2913 {"EnableMenuCommand", (PyCFunction
)MenuObj_EnableMenuCommand
, 1,
2914 "(MenuCommand inCommandID) -> None"},
2917 #if TARGET_API_MAC_CARBON
2918 {"DisableMenuCommand", (PyCFunction
)MenuObj_DisableMenuCommand
, 1,
2919 "(MenuCommand inCommandID) -> None"},
2922 #if TARGET_API_MAC_CARBON
2923 {"IsMenuCommandEnabled", (PyCFunction
)MenuObj_IsMenuCommandEnabled
, 1,
2924 "(MenuCommand inCommandID) -> (Boolean _rv)"},
2927 #if TARGET_API_MAC_CARBON
2928 {"SetMenuCommandMark", (PyCFunction
)MenuObj_SetMenuCommandMark
, 1,
2929 "(MenuCommand inCommandID, UniChar inMark) -> None"},
2932 #if TARGET_API_MAC_CARBON
2933 {"GetMenuCommandMark", (PyCFunction
)MenuObj_GetMenuCommandMark
, 1,
2934 "(MenuCommand inCommandID) -> (UniChar outMark)"},
2937 #if TARGET_API_MAC_CARBON
2938 {"GetMenuCommandPropertySize", (PyCFunction
)MenuObj_GetMenuCommandPropertySize
, 1,
2939 "(MenuCommand inCommandID, OSType inPropertyCreator, OSType inPropertyTag) -> (ByteCount outSize)"},
2942 #if TARGET_API_MAC_CARBON
2943 {"RemoveMenuCommandProperty", (PyCFunction
)MenuObj_RemoveMenuCommandProperty
, 1,
2944 "(MenuCommand inCommandID, OSType inPropertyCreator, OSType inPropertyTag) -> None"},
2947 #if TARGET_API_MAC_CARBON
2948 {"IsMenuItemInvalid", (PyCFunction
)MenuObj_IsMenuItemInvalid
, 1,
2949 "(MenuItemIndex item) -> (Boolean _rv)"},
2952 #if TARGET_API_MAC_CARBON
2953 {"InvalidateMenuItems", (PyCFunction
)MenuObj_InvalidateMenuItems
, 1,
2954 "(MenuItemIndex firstItem, ItemCount numItems) -> None"},
2957 #if TARGET_API_MAC_CARBON
2958 {"UpdateInvalidMenuItems", (PyCFunction
)MenuObj_UpdateInvalidMenuItems
, 1,
2962 #if TARGET_API_MAC_CARBON
2963 {"CreateStandardFontMenu", (PyCFunction
)MenuObj_CreateStandardFontMenu
, 1,
2964 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
2967 #if TARGET_API_MAC_CARBON
2968 {"UpdateStandardFontMenu", (PyCFunction
)MenuObj_UpdateStandardFontMenu
, 1,
2969 "() -> (ItemCount outHierMenuCount)"},
2972 #if TARGET_API_MAC_CARBON
2973 {"GetFontFamilyFromMenuSelection", (PyCFunction
)MenuObj_GetFontFamilyFromMenuSelection
, 1,
2974 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
2976 {"GetMenuID", (PyCFunction
)MenuObj_GetMenuID
, 1,
2977 "() -> (MenuID _rv)"},
2978 {"GetMenuWidth", (PyCFunction
)MenuObj_GetMenuWidth
, 1,
2979 "() -> (SInt16 _rv)"},
2980 {"GetMenuHeight", (PyCFunction
)MenuObj_GetMenuHeight
, 1,
2981 "() -> (SInt16 _rv)"},
2982 {"SetMenuID", (PyCFunction
)MenuObj_SetMenuID
, 1,
2983 "(MenuID menuID) -> None"},
2984 {"SetMenuWidth", (PyCFunction
)MenuObj_SetMenuWidth
, 1,
2985 "(SInt16 width) -> None"},
2986 {"SetMenuHeight", (PyCFunction
)MenuObj_SetMenuHeight
, 1,
2987 "(SInt16 height) -> None"},
2988 {"as_Resource", (PyCFunction
)MenuObj_as_Resource
, 1,
2989 "() -> (Handle _rv)"},
2990 {"AppendMenu", (PyCFunction
)MenuObj_AppendMenu
, 1,
2991 "(Str255 data) -> None"},
2992 {"InsertMenu", (PyCFunction
)MenuObj_InsertMenu
, 1,
2993 "(short beforeID) -> None"},
2994 {"InsertMenuItem", (PyCFunction
)MenuObj_InsertMenuItem
, 1,
2995 "(Str255 itemString, short afterItem) -> None"},
2996 {"EnableMenuItem", (PyCFunction
)MenuObj_EnableMenuItem
, 1,
2997 "(UInt16 item) -> None"},
2998 {"CheckMenuItem", (PyCFunction
)MenuObj_CheckMenuItem
, 1,
2999 "(short item, Boolean checked) -> None"},
3003 PyMethodChain MenuObj_chain
= { MenuObj_methods
, NULL
};
3005 static PyObject
*MenuObj_getattr(MenuObject
*self
, char *name
)
3007 return Py_FindMethodInChain(&MenuObj_chain
, (PyObject
*)self
, name
);
3010 #define MenuObj_setattr NULL
3012 #define MenuObj_compare NULL
3014 #define MenuObj_repr NULL
3016 #define MenuObj_hash NULL
3018 PyTypeObject Menu_Type
= {
3019 PyObject_HEAD_INIT(NULL
)
3021 "_Menu.Menu", /*tp_name*/
3022 sizeof(MenuObject
), /*tp_basicsize*/
3025 (destructor
) MenuObj_dealloc
, /*tp_dealloc*/
3027 (getattrfunc
) MenuObj_getattr
, /*tp_getattr*/
3028 (setattrfunc
) MenuObj_setattr
, /*tp_setattr*/
3029 (cmpfunc
) MenuObj_compare
, /*tp_compare*/
3030 (reprfunc
) MenuObj_repr
, /*tp_repr*/
3031 (PyNumberMethods
*)0, /* tp_as_number */
3032 (PySequenceMethods
*)0, /* tp_as_sequence */
3033 (PyMappingMethods
*)0, /* tp_as_mapping */
3034 (hashfunc
) MenuObj_hash
, /*tp_hash*/
3037 /* ---------------------- End object type Menu ---------------------- */
3040 #if !TARGET_API_MAC_CARBON
3042 static PyObject
*Menu_InitProcMenu(PyObject
*_self
, PyObject
*_args
)
3044 PyObject
*_res
= NULL
;
3046 #ifndef InitProcMenu
3047 PyMac_PRECHECK(InitProcMenu
);
3049 if (!PyArg_ParseTuple(_args
, "h",
3052 InitProcMenu(resID
);
3059 #if !TARGET_API_MAC_CARBON
3061 static PyObject
*Menu_InitMenus(PyObject
*_self
, PyObject
*_args
)
3063 PyObject
*_res
= NULL
;
3065 PyMac_PRECHECK(InitMenus
);
3067 if (!PyArg_ParseTuple(_args
, ""))
3076 static PyObject
*Menu_NewMenu(PyObject
*_self
, PyObject
*_args
)
3078 PyObject
*_res
= NULL
;
3083 PyMac_PRECHECK(NewMenu
);
3085 if (!PyArg_ParseTuple(_args
, "hO&",
3087 PyMac_GetStr255
, menuTitle
))
3089 _rv
= NewMenu(menuID
,
3091 _res
= Py_BuildValue("O&",
3096 static PyObject
*Menu_MacGetMenu(PyObject
*_self
, PyObject
*_args
)
3098 PyObject
*_res
= NULL
;
3102 PyMac_PRECHECK(MacGetMenu
);
3104 if (!PyArg_ParseTuple(_args
, "h",
3107 _rv
= MacGetMenu(resourceID
);
3108 _res
= Py_BuildValue("O&",
3113 #if TARGET_API_MAC_CARBON
3115 static PyObject
*Menu_CreateNewMenu(PyObject
*_self
, PyObject
*_args
)
3117 PyObject
*_res
= NULL
;
3120 MenuAttributes inMenuAttributes
;
3121 MenuHandle outMenuRef
;
3122 #ifndef CreateNewMenu
3123 PyMac_PRECHECK(CreateNewMenu
);
3125 if (!PyArg_ParseTuple(_args
, "hl",
3129 _err
= CreateNewMenu(inMenuID
,
3132 if (_err
!= noErr
) return PyMac_Error(_err
);
3133 _res
= Py_BuildValue("O&",
3134 MenuObj_New
, outMenuRef
);
3139 static PyObject
*Menu_MenuKey(PyObject
*_self
, PyObject
*_args
)
3141 PyObject
*_res
= NULL
;
3145 PyMac_PRECHECK(MenuKey
);
3147 if (!PyArg_ParseTuple(_args
, "h",
3151 _res
= Py_BuildValue("l",
3156 static PyObject
*Menu_MenuSelect(PyObject
*_self
, PyObject
*_args
)
3158 PyObject
*_res
= NULL
;
3162 PyMac_PRECHECK(MenuSelect
);
3164 if (!PyArg_ParseTuple(_args
, "O&",
3165 PyMac_GetPoint
, &startPt
))
3167 _rv
= MenuSelect(startPt
);
3168 _res
= Py_BuildValue("l",
3173 static PyObject
*Menu_MenuChoice(PyObject
*_self
, PyObject
*_args
)
3175 PyObject
*_res
= NULL
;
3178 PyMac_PRECHECK(MenuChoice
);
3180 if (!PyArg_ParseTuple(_args
, ""))
3183 _res
= Py_BuildValue("l",
3188 static PyObject
*Menu_MenuEvent(PyObject
*_self
, PyObject
*_args
)
3190 PyObject
*_res
= NULL
;
3192 EventRecord inEvent
;
3194 PyMac_PRECHECK(MenuEvent
);
3196 if (!PyArg_ParseTuple(_args
, "O&",
3197 PyMac_GetEventRecord
, &inEvent
))
3199 _rv
= MenuEvent(&inEvent
);
3200 _res
= Py_BuildValue("l",
3205 static PyObject
*Menu_GetMBarHeight(PyObject
*_self
, PyObject
*_args
)
3207 PyObject
*_res
= NULL
;
3209 #ifndef GetMBarHeight
3210 PyMac_PRECHECK(GetMBarHeight
);
3212 if (!PyArg_ParseTuple(_args
, ""))
3214 _rv
= GetMBarHeight();
3215 _res
= Py_BuildValue("h",
3220 static PyObject
*Menu_MacDrawMenuBar(PyObject
*_self
, PyObject
*_args
)
3222 PyObject
*_res
= NULL
;
3223 #ifndef MacDrawMenuBar
3224 PyMac_PRECHECK(MacDrawMenuBar
);
3226 if (!PyArg_ParseTuple(_args
, ""))
3234 static PyObject
*Menu_InvalMenuBar(PyObject
*_self
, PyObject
*_args
)
3236 PyObject
*_res
= NULL
;
3237 #ifndef InvalMenuBar
3238 PyMac_PRECHECK(InvalMenuBar
);
3240 if (!PyArg_ParseTuple(_args
, ""))
3248 static PyObject
*Menu_HiliteMenu(PyObject
*_self
, PyObject
*_args
)
3250 PyObject
*_res
= NULL
;
3253 PyMac_PRECHECK(HiliteMenu
);
3255 if (!PyArg_ParseTuple(_args
, "h",
3264 static PyObject
*Menu_GetNewMBar(PyObject
*_self
, PyObject
*_args
)
3266 PyObject
*_res
= NULL
;
3270 PyMac_PRECHECK(GetNewMBar
);
3272 if (!PyArg_ParseTuple(_args
, "h",
3275 _rv
= GetNewMBar(menuBarID
);
3276 _res
= Py_BuildValue("O&",
3281 static PyObject
*Menu_GetMenuBar(PyObject
*_self
, PyObject
*_args
)
3283 PyObject
*_res
= NULL
;
3286 PyMac_PRECHECK(GetMenuBar
);
3288 if (!PyArg_ParseTuple(_args
, ""))
3291 _res
= Py_BuildValue("O&",
3296 static PyObject
*Menu_SetMenuBar(PyObject
*_self
, PyObject
*_args
)
3298 PyObject
*_res
= NULL
;
3301 PyMac_PRECHECK(SetMenuBar
);
3303 if (!PyArg_ParseTuple(_args
, "O&",
3304 ResObj_Convert
, &mbar
))
3312 #if TARGET_API_MAC_CARBON
3314 static PyObject
*Menu_DuplicateMenuBar(PyObject
*_self
, PyObject
*_args
)
3316 PyObject
*_res
= NULL
;
3318 MenuBarHandle inMbar
;
3319 MenuBarHandle outMbar
;
3320 #ifndef DuplicateMenuBar
3321 PyMac_PRECHECK(DuplicateMenuBar
);
3323 if (!PyArg_ParseTuple(_args
, "O&",
3324 ResObj_Convert
, &inMbar
))
3326 _err
= DuplicateMenuBar(inMbar
,
3328 if (_err
!= noErr
) return PyMac_Error(_err
);
3329 _res
= Py_BuildValue("O&",
3330 ResObj_New
, outMbar
);
3335 #if TARGET_API_MAC_CARBON
3337 static PyObject
*Menu_DisposeMenuBar(PyObject
*_self
, PyObject
*_args
)
3339 PyObject
*_res
= NULL
;
3341 MenuBarHandle inMbar
;
3342 #ifndef DisposeMenuBar
3343 PyMac_PRECHECK(DisposeMenuBar
);
3345 if (!PyArg_ParseTuple(_args
, "O&",
3346 ResObj_Convert
, &inMbar
))
3348 _err
= DisposeMenuBar(inMbar
);
3349 if (_err
!= noErr
) return PyMac_Error(_err
);
3356 static PyObject
*Menu_GetMenuHandle(PyObject
*_self
, PyObject
*_args
)
3358 PyObject
*_res
= NULL
;
3361 #ifndef GetMenuHandle
3362 PyMac_PRECHECK(GetMenuHandle
);
3364 if (!PyArg_ParseTuple(_args
, "h",
3367 _rv
= GetMenuHandle(menuID
);
3368 _res
= Py_BuildValue("O&",
3373 static PyObject
*Menu_MacDeleteMenu(PyObject
*_self
, PyObject
*_args
)
3375 PyObject
*_res
= NULL
;
3377 #ifndef MacDeleteMenu
3378 PyMac_PRECHECK(MacDeleteMenu
);
3380 if (!PyArg_ParseTuple(_args
, "h",
3383 MacDeleteMenu(menuID
);
3389 static PyObject
*Menu_ClearMenuBar(PyObject
*_self
, PyObject
*_args
)
3391 PyObject
*_res
= NULL
;
3392 #ifndef ClearMenuBar
3393 PyMac_PRECHECK(ClearMenuBar
);
3395 if (!PyArg_ParseTuple(_args
, ""))
3403 #if !TARGET_API_MAC_CARBON
3405 static PyObject
*Menu_SetMenuFlash(PyObject
*_self
, PyObject
*_args
)
3407 PyObject
*_res
= NULL
;
3409 #ifndef SetMenuFlash
3410 PyMac_PRECHECK(SetMenuFlash
);
3412 if (!PyArg_ParseTuple(_args
, "h",
3415 SetMenuFlash(count
);
3422 static PyObject
*Menu_SetMenuFlashCount(PyObject
*_self
, PyObject
*_args
)
3424 PyObject
*_res
= NULL
;
3426 #ifndef SetMenuFlashCount
3427 PyMac_PRECHECK(SetMenuFlashCount
);
3429 if (!PyArg_ParseTuple(_args
, "h",
3432 SetMenuFlashCount(count
);
3438 static PyObject
*Menu_FlashMenuBar(PyObject
*_self
, PyObject
*_args
)
3440 PyObject
*_res
= NULL
;
3442 #ifndef FlashMenuBar
3443 PyMac_PRECHECK(FlashMenuBar
);
3445 if (!PyArg_ParseTuple(_args
, "h",
3448 FlashMenuBar(menuID
);
3454 #if !TARGET_API_MAC_CARBON
3456 static PyObject
*Menu_SystemEdit(PyObject
*_self
, PyObject
*_args
)
3458 PyObject
*_res
= NULL
;
3462 PyMac_PRECHECK(SystemEdit
);
3464 if (!PyArg_ParseTuple(_args
, "h",
3467 _rv
= SystemEdit(editCmd
);
3468 _res
= Py_BuildValue("b",
3474 #if !TARGET_API_MAC_CARBON
3476 static PyObject
*Menu_SystemMenu(PyObject
*_self
, PyObject
*_args
)
3478 PyObject
*_res
= NULL
;
3481 PyMac_PRECHECK(SystemMenu
);
3483 if (!PyArg_ParseTuple(_args
, "l",
3486 SystemMenu(menuResult
);
3493 static PyObject
*Menu_IsMenuBarVisible(PyObject
*_self
, PyObject
*_args
)
3495 PyObject
*_res
= NULL
;
3497 #ifndef IsMenuBarVisible
3498 PyMac_PRECHECK(IsMenuBarVisible
);
3500 if (!PyArg_ParseTuple(_args
, ""))
3502 _rv
= IsMenuBarVisible();
3503 _res
= Py_BuildValue("b",
3508 static PyObject
*Menu_ShowMenuBar(PyObject
*_self
, PyObject
*_args
)
3510 PyObject
*_res
= NULL
;
3512 PyMac_PRECHECK(ShowMenuBar
);
3514 if (!PyArg_ParseTuple(_args
, ""))
3522 static PyObject
*Menu_HideMenuBar(PyObject
*_self
, PyObject
*_args
)
3524 PyObject
*_res
= NULL
;
3526 PyMac_PRECHECK(HideMenuBar
);
3528 if (!PyArg_ParseTuple(_args
, ""))
3536 #if TARGET_API_MAC_CARBON
3538 static PyObject
*Menu_AcquireRootMenu(PyObject
*_self
, PyObject
*_args
)
3540 PyObject
*_res
= NULL
;
3542 #ifndef AcquireRootMenu
3543 PyMac_PRECHECK(AcquireRootMenu
);
3545 if (!PyArg_ParseTuple(_args
, ""))
3547 _rv
= AcquireRootMenu();
3548 _res
= Py_BuildValue("O&",
3554 static PyObject
*Menu_DeleteMCEntries(PyObject
*_self
, PyObject
*_args
)
3556 PyObject
*_res
= NULL
;
3559 #ifndef DeleteMCEntries
3560 PyMac_PRECHECK(DeleteMCEntries
);
3562 if (!PyArg_ParseTuple(_args
, "hh",
3566 DeleteMCEntries(menuID
,
3573 static PyObject
*Menu_InitContextualMenus(PyObject
*_self
, PyObject
*_args
)
3575 PyObject
*_res
= NULL
;
3577 #ifndef InitContextualMenus
3578 PyMac_PRECHECK(InitContextualMenus
);
3580 if (!PyArg_ParseTuple(_args
, ""))
3582 _err
= InitContextualMenus();
3583 if (_err
!= noErr
) return PyMac_Error(_err
);
3589 static PyObject
*Menu_IsShowContextualMenuClick(PyObject
*_self
, PyObject
*_args
)
3591 PyObject
*_res
= NULL
;
3593 EventRecord inEvent
;
3594 #ifndef IsShowContextualMenuClick
3595 PyMac_PRECHECK(IsShowContextualMenuClick
);
3597 if (!PyArg_ParseTuple(_args
, "O&",
3598 PyMac_GetEventRecord
, &inEvent
))
3600 _rv
= IsShowContextualMenuClick(&inEvent
);
3601 _res
= Py_BuildValue("b",
3606 static PyObject
*Menu_LMGetTheMenu(PyObject
*_self
, PyObject
*_args
)
3608 PyObject
*_res
= NULL
;
3610 #ifndef LMGetTheMenu
3611 PyMac_PRECHECK(LMGetTheMenu
);
3613 if (!PyArg_ParseTuple(_args
, ""))
3615 _rv
= LMGetTheMenu();
3616 _res
= Py_BuildValue("h",
3621 #if !TARGET_API_MAC_CARBON
3623 static PyObject
*Menu_OpenDeskAcc(PyObject
*_self
, PyObject
*_args
)
3625 PyObject
*_res
= NULL
;
3628 PyMac_PRECHECK(OpenDeskAcc
);
3630 if (!PyArg_ParseTuple(_args
, "O&",
3631 PyMac_GetStr255
, name
))
3640 static PyObject
*Menu_as_Menu(PyObject
*_self
, PyObject
*_args
)
3642 PyObject
*_res
= NULL
;
3646 PyMac_PRECHECK(as_Menu
);
3648 if (!PyArg_ParseTuple(_args
, "O&",
3649 ResObj_Convert
, &h
))
3652 _res
= Py_BuildValue("O&",
3657 static PyObject
*Menu_GetMenu(PyObject
*_self
, PyObject
*_args
)
3659 PyObject
*_res
= NULL
;
3663 PyMac_PRECHECK(GetMenu
);
3665 if (!PyArg_ParseTuple(_args
, "h",
3668 _rv
= GetMenu(resourceID
);
3669 _res
= Py_BuildValue("O&",
3674 static PyObject
*Menu_DeleteMenu(PyObject
*_self
, PyObject
*_args
)
3676 PyObject
*_res
= NULL
;
3679 PyMac_PRECHECK(DeleteMenu
);
3681 if (!PyArg_ParseTuple(_args
, "h",
3690 static PyObject
*Menu_DrawMenuBar(PyObject
*_self
, PyObject
*_args
)
3692 PyObject
*_res
= NULL
;
3694 PyMac_PRECHECK(DrawMenuBar
);
3696 if (!PyArg_ParseTuple(_args
, ""))
3704 #if TARGET_API_MAC_CARBON
3706 static PyObject
*Menu_CountMenuItemsWithCommandID(PyObject
*_self
, PyObject
*_args
)
3708 PyObject
*_res
= NULL
;
3711 MenuCommand inCommandID
;
3712 #ifndef CountMenuItemsWithCommandID
3713 PyMac_PRECHECK(CountMenuItemsWithCommandID
);
3715 if (!PyArg_ParseTuple(_args
, "O&l",
3716 OptMenuObj_Convert
, &inMenu
,
3719 _rv
= CountMenuItemsWithCommandID(inMenu
,
3721 _res
= Py_BuildValue("l",
3727 #if TARGET_API_MAC_CARBON
3729 static PyObject
*Menu_GetIndMenuItemWithCommandID(PyObject
*_self
, PyObject
*_args
)
3731 PyObject
*_res
= NULL
;
3734 MenuCommand inCommandID
;
3737 MenuItemIndex outIndex
;
3738 #ifndef GetIndMenuItemWithCommandID
3739 PyMac_PRECHECK(GetIndMenuItemWithCommandID
);
3741 if (!PyArg_ParseTuple(_args
, "O&ll",
3742 OptMenuObj_Convert
, &inMenu
,
3746 _err
= GetIndMenuItemWithCommandID(inMenu
,
3751 if (_err
!= noErr
) return PyMac_Error(_err
);
3752 _res
= Py_BuildValue("O&h",
3753 MenuObj_New
, outMenu
,
3759 #if TARGET_API_MAC_CARBON
3761 static PyObject
*Menu_EnableMenuCommand(PyObject
*_self
, PyObject
*_args
)
3763 PyObject
*_res
= NULL
;
3765 MenuCommand inCommandID
;
3766 #ifndef EnableMenuCommand
3767 PyMac_PRECHECK(EnableMenuCommand
);
3769 if (!PyArg_ParseTuple(_args
, "O&l",
3770 OptMenuObj_Convert
, &inMenu
,
3773 EnableMenuCommand(inMenu
,
3781 #if TARGET_API_MAC_CARBON
3783 static PyObject
*Menu_DisableMenuCommand(PyObject
*_self
, PyObject
*_args
)
3785 PyObject
*_res
= NULL
;
3787 MenuCommand inCommandID
;
3788 #ifndef DisableMenuCommand
3789 PyMac_PRECHECK(DisableMenuCommand
);
3791 if (!PyArg_ParseTuple(_args
, "O&l",
3792 OptMenuObj_Convert
, &inMenu
,
3795 DisableMenuCommand(inMenu
,
3803 #if TARGET_API_MAC_CARBON
3805 static PyObject
*Menu_IsMenuCommandEnabled(PyObject
*_self
, PyObject
*_args
)
3807 PyObject
*_res
= NULL
;
3810 MenuCommand inCommandID
;
3811 #ifndef IsMenuCommandEnabled
3812 PyMac_PRECHECK(IsMenuCommandEnabled
);
3814 if (!PyArg_ParseTuple(_args
, "O&l",
3815 OptMenuObj_Convert
, &inMenu
,
3818 _rv
= IsMenuCommandEnabled(inMenu
,
3820 _res
= Py_BuildValue("b",
3826 #if TARGET_API_MAC_CARBON
3828 static PyObject
*Menu_SetMenuCommandMark(PyObject
*_self
, PyObject
*_args
)
3830 PyObject
*_res
= NULL
;
3833 MenuCommand inCommandID
;
3835 #ifndef SetMenuCommandMark
3836 PyMac_PRECHECK(SetMenuCommandMark
);
3838 if (!PyArg_ParseTuple(_args
, "O&lh",
3839 OptMenuObj_Convert
, &inMenu
,
3843 _err
= SetMenuCommandMark(inMenu
,
3846 if (_err
!= noErr
) return PyMac_Error(_err
);
3853 #if TARGET_API_MAC_CARBON
3855 static PyObject
*Menu_GetMenuCommandMark(PyObject
*_self
, PyObject
*_args
)
3857 PyObject
*_res
= NULL
;
3860 MenuCommand inCommandID
;
3862 #ifndef GetMenuCommandMark
3863 PyMac_PRECHECK(GetMenuCommandMark
);
3865 if (!PyArg_ParseTuple(_args
, "O&l",
3866 OptMenuObj_Convert
, &inMenu
,
3869 _err
= GetMenuCommandMark(inMenu
,
3872 if (_err
!= noErr
) return PyMac_Error(_err
);
3873 _res
= Py_BuildValue("h",
3879 #if TARGET_API_MAC_CARBON
3881 static PyObject
*Menu_GetMenuCommandPropertySize(PyObject
*_self
, PyObject
*_args
)
3883 PyObject
*_res
= NULL
;
3886 MenuCommand inCommandID
;
3887 OSType inPropertyCreator
;
3888 OSType inPropertyTag
;
3890 #ifndef GetMenuCommandPropertySize
3891 PyMac_PRECHECK(GetMenuCommandPropertySize
);
3893 if (!PyArg_ParseTuple(_args
, "O&lO&O&",
3894 OptMenuObj_Convert
, &inMenu
,
3896 PyMac_GetOSType
, &inPropertyCreator
,
3897 PyMac_GetOSType
, &inPropertyTag
))
3899 _err
= GetMenuCommandPropertySize(inMenu
,
3904 if (_err
!= noErr
) return PyMac_Error(_err
);
3905 _res
= Py_BuildValue("l",
3911 #if TARGET_API_MAC_CARBON
3913 static PyObject
*Menu_RemoveMenuCommandProperty(PyObject
*_self
, PyObject
*_args
)
3915 PyObject
*_res
= NULL
;
3918 MenuCommand inCommandID
;
3919 OSType inPropertyCreator
;
3920 OSType inPropertyTag
;
3921 #ifndef RemoveMenuCommandProperty
3922 PyMac_PRECHECK(RemoveMenuCommandProperty
);
3924 if (!PyArg_ParseTuple(_args
, "O&lO&O&",
3925 OptMenuObj_Convert
, &inMenu
,
3927 PyMac_GetOSType
, &inPropertyCreator
,
3928 PyMac_GetOSType
, &inPropertyTag
))
3930 _err
= RemoveMenuCommandProperty(inMenu
,
3934 if (_err
!= noErr
) return PyMac_Error(_err
);
3941 static PyMethodDef Menu_methods
[] = {
3943 #if !TARGET_API_MAC_CARBON
3944 {"InitProcMenu", (PyCFunction
)Menu_InitProcMenu
, 1,
3945 "(short resID) -> None"},
3948 #if !TARGET_API_MAC_CARBON
3949 {"InitMenus", (PyCFunction
)Menu_InitMenus
, 1,
3952 {"NewMenu", (PyCFunction
)Menu_NewMenu
, 1,
3953 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
3954 {"MacGetMenu", (PyCFunction
)Menu_MacGetMenu
, 1,
3955 "(short resourceID) -> (MenuHandle _rv)"},
3957 #if TARGET_API_MAC_CARBON
3958 {"CreateNewMenu", (PyCFunction
)Menu_CreateNewMenu
, 1,
3959 "(MenuID inMenuID, MenuAttributes inMenuAttributes) -> (MenuHandle outMenuRef)"},
3961 {"MenuKey", (PyCFunction
)Menu_MenuKey
, 1,
3962 "(CharParameter ch) -> (long _rv)"},
3963 {"MenuSelect", (PyCFunction
)Menu_MenuSelect
, 1,
3964 "(Point startPt) -> (long _rv)"},
3965 {"MenuChoice", (PyCFunction
)Menu_MenuChoice
, 1,
3966 "() -> (long _rv)"},
3967 {"MenuEvent", (PyCFunction
)Menu_MenuEvent
, 1,
3968 "(EventRecord inEvent) -> (UInt32 _rv)"},
3969 {"GetMBarHeight", (PyCFunction
)Menu_GetMBarHeight
, 1,
3970 "() -> (short _rv)"},
3971 {"MacDrawMenuBar", (PyCFunction
)Menu_MacDrawMenuBar
, 1,
3973 {"InvalMenuBar", (PyCFunction
)Menu_InvalMenuBar
, 1,
3975 {"HiliteMenu", (PyCFunction
)Menu_HiliteMenu
, 1,
3976 "(MenuID menuID) -> None"},
3977 {"GetNewMBar", (PyCFunction
)Menu_GetNewMBar
, 1,
3978 "(short menuBarID) -> (MenuBarHandle _rv)"},
3979 {"GetMenuBar", (PyCFunction
)Menu_GetMenuBar
, 1,
3980 "() -> (MenuBarHandle _rv)"},
3981 {"SetMenuBar", (PyCFunction
)Menu_SetMenuBar
, 1,
3982 "(MenuBarHandle mbar) -> None"},
3984 #if TARGET_API_MAC_CARBON
3985 {"DuplicateMenuBar", (PyCFunction
)Menu_DuplicateMenuBar
, 1,
3986 "(MenuBarHandle inMbar) -> (MenuBarHandle outMbar)"},
3989 #if TARGET_API_MAC_CARBON
3990 {"DisposeMenuBar", (PyCFunction
)Menu_DisposeMenuBar
, 1,
3991 "(MenuBarHandle inMbar) -> None"},
3993 {"GetMenuHandle", (PyCFunction
)Menu_GetMenuHandle
, 1,
3994 "(MenuID menuID) -> (MenuHandle _rv)"},
3995 {"MacDeleteMenu", (PyCFunction
)Menu_MacDeleteMenu
, 1,
3996 "(MenuID menuID) -> None"},
3997 {"ClearMenuBar", (PyCFunction
)Menu_ClearMenuBar
, 1,
4000 #if !TARGET_API_MAC_CARBON
4001 {"SetMenuFlash", (PyCFunction
)Menu_SetMenuFlash
, 1,
4002 "(short count) -> None"},
4004 {"SetMenuFlashCount", (PyCFunction
)Menu_SetMenuFlashCount
, 1,
4005 "(short count) -> None"},
4006 {"FlashMenuBar", (PyCFunction
)Menu_FlashMenuBar
, 1,
4007 "(MenuID menuID) -> None"},
4009 #if !TARGET_API_MAC_CARBON
4010 {"SystemEdit", (PyCFunction
)Menu_SystemEdit
, 1,
4011 "(short editCmd) -> (Boolean _rv)"},
4014 #if !TARGET_API_MAC_CARBON
4015 {"SystemMenu", (PyCFunction
)Menu_SystemMenu
, 1,
4016 "(long menuResult) -> None"},
4018 {"IsMenuBarVisible", (PyCFunction
)Menu_IsMenuBarVisible
, 1,
4019 "() -> (Boolean _rv)"},
4020 {"ShowMenuBar", (PyCFunction
)Menu_ShowMenuBar
, 1,
4022 {"HideMenuBar", (PyCFunction
)Menu_HideMenuBar
, 1,
4025 #if TARGET_API_MAC_CARBON
4026 {"AcquireRootMenu", (PyCFunction
)Menu_AcquireRootMenu
, 1,
4027 "() -> (MenuHandle _rv)"},
4029 {"DeleteMCEntries", (PyCFunction
)Menu_DeleteMCEntries
, 1,
4030 "(MenuID menuID, short menuItem) -> None"},
4031 {"InitContextualMenus", (PyCFunction
)Menu_InitContextualMenus
, 1,
4033 {"IsShowContextualMenuClick", (PyCFunction
)Menu_IsShowContextualMenuClick
, 1,
4034 "(EventRecord inEvent) -> (Boolean _rv)"},
4035 {"LMGetTheMenu", (PyCFunction
)Menu_LMGetTheMenu
, 1,
4036 "() -> (SInt16 _rv)"},
4038 #if !TARGET_API_MAC_CARBON
4039 {"OpenDeskAcc", (PyCFunction
)Menu_OpenDeskAcc
, 1,
4040 "(Str255 name) -> None"},
4042 {"as_Menu", (PyCFunction
)Menu_as_Menu
, 1,
4043 "(Handle h) -> (MenuHandle _rv)"},
4044 {"GetMenu", (PyCFunction
)Menu_GetMenu
, 1,
4045 "(short resourceID) -> (MenuHandle _rv)"},
4046 {"DeleteMenu", (PyCFunction
)Menu_DeleteMenu
, 1,
4047 "(short menuID) -> None"},
4048 {"DrawMenuBar", (PyCFunction
)Menu_DrawMenuBar
, 1,
4051 #if TARGET_API_MAC_CARBON
4052 {"CountMenuItemsWithCommandID", (PyCFunction
)Menu_CountMenuItemsWithCommandID
, 1,
4053 "(MenuHandle inMenu, MenuCommand inCommandID) -> (ItemCount _rv)"},
4056 #if TARGET_API_MAC_CARBON
4057 {"GetIndMenuItemWithCommandID", (PyCFunction
)Menu_GetIndMenuItemWithCommandID
, 1,
4058 "(MenuHandle inMenu, MenuCommand inCommandID, UInt32 inItemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
4061 #if TARGET_API_MAC_CARBON
4062 {"EnableMenuCommand", (PyCFunction
)Menu_EnableMenuCommand
, 1,
4063 "(MenuHandle inMenu, MenuCommand inCommandID) -> None"},
4066 #if TARGET_API_MAC_CARBON
4067 {"DisableMenuCommand", (PyCFunction
)Menu_DisableMenuCommand
, 1,
4068 "(MenuHandle inMenu, MenuCommand inCommandID) -> None"},
4071 #if TARGET_API_MAC_CARBON
4072 {"IsMenuCommandEnabled", (PyCFunction
)Menu_IsMenuCommandEnabled
, 1,
4073 "(MenuHandle inMenu, MenuCommand inCommandID) -> (Boolean _rv)"},
4076 #if TARGET_API_MAC_CARBON
4077 {"SetMenuCommandMark", (PyCFunction
)Menu_SetMenuCommandMark
, 1,
4078 "(MenuHandle inMenu, MenuCommand inCommandID, UniChar inMark) -> None"},
4081 #if TARGET_API_MAC_CARBON
4082 {"GetMenuCommandMark", (PyCFunction
)Menu_GetMenuCommandMark
, 1,
4083 "(MenuHandle inMenu, MenuCommand inCommandID) -> (UniChar outMark)"},
4086 #if TARGET_API_MAC_CARBON
4087 {"GetMenuCommandPropertySize", (PyCFunction
)Menu_GetMenuCommandPropertySize
, 1,
4088 "(MenuHandle inMenu, MenuCommand inCommandID, OSType inPropertyCreator, OSType inPropertyTag) -> (ByteCount outSize)"},
4091 #if TARGET_API_MAC_CARBON
4092 {"RemoveMenuCommandProperty", (PyCFunction
)Menu_RemoveMenuCommandProperty
, 1,
4093 "(MenuHandle inMenu, MenuCommand inCommandID, OSType inPropertyCreator, OSType inPropertyTag) -> None"},
4101 void init_Menu(void)
4108 PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle
, MenuObj_New
);
4109 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle
, MenuObj_Convert
);
4112 m
= Py_InitModule("_Menu", Menu_methods
);
4113 d
= PyModule_GetDict(m
);
4114 Menu_Error
= PyMac_GetOSErrException();
4115 if (Menu_Error
== NULL
||
4116 PyDict_SetItemString(d
, "Error", Menu_Error
) != 0)
4118 Menu_Type
.ob_type
= &PyType_Type
;
4119 Py_INCREF(&Menu_Type
);
4120 if (PyDict_SetItemString(d
, "MenuType", (PyObject
*)&Menu_Type
) != 0)
4121 Py_FatalError("can't initialize MenuType");
4124 /* ======================== End module _Menu ======================== */