2 /* ========================== Module Menu =========================== */
9 #include "pymactoolbox.h"
11 #ifdef WITHOUT_FRAMEWORKS
12 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
15 #include <Carbon/Carbon.h>
19 #ifdef USE_TOOLBOX_OBJECT_GLUE
21 extern PyObject
*_MenuObj_New(MenuHandle
);
22 extern int _MenuObj_Convert(PyObject
*, MenuHandle
*);
24 #define MenuObj_New _MenuObj_New
25 #define MenuObj_Convert _MenuObj_Convert
28 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
29 #define GetMenuID(menu) ((*(menu))->menuID)
30 #define GetMenuWidth(menu) ((*(menu))->menuWidth)
31 #define GetMenuHeight(menu) ((*(menu))->menuHeight)
33 #define SetMenuID(menu, id) ((*(menu))->menuID = (id))
34 #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
35 #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
38 #define as_Menu(h) ((MenuHandle)h)
39 #define as_Resource(h) ((Handle)h)
41 static PyObject
*Menu_Error
;
43 /* ------------------------ Object type Menu ------------------------ */
45 PyTypeObject Menu_Type
;
47 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
49 typedef struct MenuObject
{
54 PyObject
*MenuObj_New(MenuHandle itself
)
57 it
= PyObject_NEW(MenuObject
, &Menu_Type
);
58 if (it
== NULL
) return NULL
;
59 it
->ob_itself
= itself
;
60 return (PyObject
*)it
;
62 MenuObj_Convert(PyObject
*v
, MenuHandle
*p_itself
)
64 if (!MenuObj_Check(v
))
66 PyErr_SetString(PyExc_TypeError
, "Menu required");
69 *p_itself
= ((MenuObject
*)v
)->ob_itself
;
73 static void MenuObj_dealloc(MenuObject
*self
)
75 /* Cleanup of self->ob_itself goes here */
79 static PyObject
*MenuObj_DisposeMenu(MenuObject
*_self
, PyObject
*_args
)
81 PyObject
*_res
= NULL
;
82 if (!PyArg_ParseTuple(_args
, ""))
84 DisposeMenu(_self
->ob_itself
);
90 static PyObject
*MenuObj_CalcMenuSize(MenuObject
*_self
, PyObject
*_args
)
92 PyObject
*_res
= NULL
;
93 if (!PyArg_ParseTuple(_args
, ""))
95 CalcMenuSize(_self
->ob_itself
);
101 static PyObject
*MenuObj_CountMenuItems(MenuObject
*_self
, PyObject
*_args
)
103 PyObject
*_res
= NULL
;
105 if (!PyArg_ParseTuple(_args
, ""))
107 _rv
= CountMenuItems(_self
->ob_itself
);
108 _res
= Py_BuildValue("h",
113 #if !TARGET_API_MAC_CARBON
115 static PyObject
*MenuObj_CountMItems(MenuObject
*_self
, PyObject
*_args
)
117 PyObject
*_res
= NULL
;
119 if (!PyArg_ParseTuple(_args
, ""))
121 _rv
= CountMItems(_self
->ob_itself
);
122 _res
= Py_BuildValue("h",
128 static PyObject
*MenuObj_GetMenuFont(MenuObject
*_self
, PyObject
*_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(MenuObject
*_self
, PyObject
*_args
)
148 PyObject
*_res
= NULL
;
152 if (!PyArg_ParseTuple(_args
, "hH",
156 _err
= SetMenuFont(_self
->ob_itself
,
159 if (_err
!= noErr
) return PyMac_Error(_err
);
165 static PyObject
*MenuObj_GetMenuExcludesMarkColumn(MenuObject
*_self
, PyObject
*_args
)
167 PyObject
*_res
= NULL
;
169 if (!PyArg_ParseTuple(_args
, ""))
171 _rv
= GetMenuExcludesMarkColumn(_self
->ob_itself
);
172 _res
= Py_BuildValue("b",
177 static PyObject
*MenuObj_SetMenuExcludesMarkColumn(MenuObject
*_self
, PyObject
*_args
)
179 PyObject
*_res
= NULL
;
181 Boolean excludesMark
;
182 if (!PyArg_ParseTuple(_args
, "b",
185 _err
= SetMenuExcludesMarkColumn(_self
->ob_itself
,
187 if (_err
!= noErr
) return PyMac_Error(_err
);
193 static PyObject
*MenuObj_MacAppendMenu(MenuObject
*_self
, PyObject
*_args
)
195 PyObject
*_res
= NULL
;
197 if (!PyArg_ParseTuple(_args
, "O&",
198 PyMac_GetStr255
, data
))
200 MacAppendMenu(_self
->ob_itself
,
207 static PyObject
*MenuObj_InsertResMenu(MenuObject
*_self
, PyObject
*_args
)
209 PyObject
*_res
= NULL
;
212 if (!PyArg_ParseTuple(_args
, "O&h",
213 PyMac_GetOSType
, &theType
,
216 InsertResMenu(_self
->ob_itself
,
224 static PyObject
*MenuObj_AppendResMenu(MenuObject
*_self
, PyObject
*_args
)
226 PyObject
*_res
= NULL
;
228 if (!PyArg_ParseTuple(_args
, "O&",
229 PyMac_GetOSType
, &theType
))
231 AppendResMenu(_self
->ob_itself
,
238 static PyObject
*MenuObj_MacInsertMenuItem(MenuObject
*_self
, PyObject
*_args
)
240 PyObject
*_res
= NULL
;
243 if (!PyArg_ParseTuple(_args
, "O&h",
244 PyMac_GetStr255
, itemString
,
247 MacInsertMenuItem(_self
->ob_itself
,
255 static PyObject
*MenuObj_DeleteMenuItem(MenuObject
*_self
, PyObject
*_args
)
257 PyObject
*_res
= NULL
;
259 if (!PyArg_ParseTuple(_args
, "h",
262 DeleteMenuItem(_self
->ob_itself
,
269 static PyObject
*MenuObj_InsertFontResMenu(MenuObject
*_self
, PyObject
*_args
)
271 PyObject
*_res
= NULL
;
274 if (!PyArg_ParseTuple(_args
, "hh",
278 InsertFontResMenu(_self
->ob_itself
,
286 static PyObject
*MenuObj_InsertIntlResMenu(MenuObject
*_self
, PyObject
*_args
)
288 PyObject
*_res
= NULL
;
292 if (!PyArg_ParseTuple(_args
, "O&hh",
293 PyMac_GetOSType
, &theType
,
297 InsertIntlResMenu(_self
->ob_itself
,
306 static PyObject
*MenuObj_AppendMenuItemText(MenuObject
*_self
, PyObject
*_args
)
308 PyObject
*_res
= NULL
;
311 if (!PyArg_ParseTuple(_args
, "O&",
312 PyMac_GetStr255
, inString
))
314 _err
= AppendMenuItemText(_self
->ob_itself
,
316 if (_err
!= noErr
) return PyMac_Error(_err
);
322 static PyObject
*MenuObj_InsertMenuItemText(MenuObject
*_self
, PyObject
*_args
)
324 PyObject
*_res
= NULL
;
327 MenuItemIndex afterItem
;
328 if (!PyArg_ParseTuple(_args
, "O&h",
329 PyMac_GetStr255
, inString
,
332 _err
= InsertMenuItemText(_self
->ob_itself
,
335 if (_err
!= noErr
) return PyMac_Error(_err
);
341 static PyObject
*MenuObj_PopUpMenuSelect(MenuObject
*_self
, PyObject
*_args
)
343 PyObject
*_res
= NULL
;
348 if (!PyArg_ParseTuple(_args
, "hhh",
353 _rv
= PopUpMenuSelect(_self
->ob_itself
,
357 _res
= Py_BuildValue("l",
362 static PyObject
*MenuObj_MacInsertMenu(MenuObject
*_self
, PyObject
*_args
)
364 PyObject
*_res
= NULL
;
366 if (!PyArg_ParseTuple(_args
, "h",
369 MacInsertMenu(_self
->ob_itself
,
376 static PyObject
*MenuObj_MacCheckMenuItem(MenuObject
*_self
, PyObject
*_args
)
378 PyObject
*_res
= NULL
;
381 if (!PyArg_ParseTuple(_args
, "hb",
385 MacCheckMenuItem(_self
->ob_itself
,
393 #if !TARGET_API_MAC_CARBON
395 static PyObject
*MenuObj_CheckItem(MenuObject
*_self
, PyObject
*_args
)
397 PyObject
*_res
= NULL
;
400 if (!PyArg_ParseTuple(_args
, "hb",
404 CheckItem(_self
->ob_itself
,
413 static PyObject
*MenuObj_SetMenuItemText(MenuObject
*_self
, PyObject
*_args
)
415 PyObject
*_res
= NULL
;
418 if (!PyArg_ParseTuple(_args
, "hO&",
420 PyMac_GetStr255
, itemString
))
422 SetMenuItemText(_self
->ob_itself
,
430 static PyObject
*MenuObj_GetMenuItemText(MenuObject
*_self
, PyObject
*_args
)
432 PyObject
*_res
= NULL
;
435 if (!PyArg_ParseTuple(_args
, "h",
438 GetMenuItemText(_self
->ob_itself
,
441 _res
= Py_BuildValue("O&",
442 PyMac_BuildStr255
, itemString
);
446 static PyObject
*MenuObj_SetItemMark(MenuObject
*_self
, PyObject
*_args
)
448 PyObject
*_res
= NULL
;
450 CharParameter markChar
;
451 if (!PyArg_ParseTuple(_args
, "hh",
455 SetItemMark(_self
->ob_itself
,
463 static PyObject
*MenuObj_GetItemMark(MenuObject
*_self
, PyObject
*_args
)
465 PyObject
*_res
= NULL
;
467 CharParameter markChar
;
468 if (!PyArg_ParseTuple(_args
, "h",
471 GetItemMark(_self
->ob_itself
,
474 _res
= Py_BuildValue("h",
479 static PyObject
*MenuObj_SetItemCmd(MenuObject
*_self
, PyObject
*_args
)
481 PyObject
*_res
= NULL
;
483 CharParameter cmdChar
;
484 if (!PyArg_ParseTuple(_args
, "hh",
488 SetItemCmd(_self
->ob_itself
,
496 static PyObject
*MenuObj_GetItemCmd(MenuObject
*_self
, PyObject
*_args
)
498 PyObject
*_res
= NULL
;
500 CharParameter cmdChar
;
501 if (!PyArg_ParseTuple(_args
, "h",
504 GetItemCmd(_self
->ob_itself
,
507 _res
= Py_BuildValue("h",
512 static PyObject
*MenuObj_SetItemIcon(MenuObject
*_self
, PyObject
*_args
)
514 PyObject
*_res
= NULL
;
517 if (!PyArg_ParseTuple(_args
, "hh",
521 SetItemIcon(_self
->ob_itself
,
529 static PyObject
*MenuObj_GetItemIcon(MenuObject
*_self
, PyObject
*_args
)
531 PyObject
*_res
= NULL
;
534 if (!PyArg_ParseTuple(_args
, "h",
537 GetItemIcon(_self
->ob_itself
,
540 _res
= Py_BuildValue("h",
545 static PyObject
*MenuObj_SetItemStyle(MenuObject
*_self
, PyObject
*_args
)
547 PyObject
*_res
= NULL
;
549 StyleParameter chStyle
;
550 if (!PyArg_ParseTuple(_args
, "hh",
554 SetItemStyle(_self
->ob_itself
,
562 static PyObject
*MenuObj_GetItemStyle(MenuObject
*_self
, PyObject
*_args
)
564 PyObject
*_res
= NULL
;
567 if (!PyArg_ParseTuple(_args
, "h",
570 GetItemStyle(_self
->ob_itself
,
573 _res
= Py_BuildValue("b",
578 #if !TARGET_API_MAC_CARBON
580 static PyObject
*MenuObj_DisableItem(MenuObject
*_self
, PyObject
*_args
)
582 PyObject
*_res
= NULL
;
584 if (!PyArg_ParseTuple(_args
, "h",
587 DisableItem(_self
->ob_itself
,
595 #if !TARGET_API_MAC_CARBON
597 static PyObject
*MenuObj_EnableItem(MenuObject
*_self
, PyObject
*_args
)
599 PyObject
*_res
= NULL
;
601 if (!PyArg_ParseTuple(_args
, "h",
604 EnableItem(_self
->ob_itself
,
612 static PyObject
*MenuObj_SetMenuItemCommandID(MenuObject
*_self
, PyObject
*_args
)
614 PyObject
*_res
= NULL
;
617 MenuCommand inCommandID
;
618 if (!PyArg_ParseTuple(_args
, "hl",
622 _err
= SetMenuItemCommandID(_self
->ob_itself
,
625 if (_err
!= noErr
) return PyMac_Error(_err
);
631 static PyObject
*MenuObj_GetMenuItemCommandID(MenuObject
*_self
, PyObject
*_args
)
633 PyObject
*_res
= NULL
;
636 MenuCommand outCommandID
;
637 if (!PyArg_ParseTuple(_args
, "h",
640 _err
= GetMenuItemCommandID(_self
->ob_itself
,
643 if (_err
!= noErr
) return PyMac_Error(_err
);
644 _res
= Py_BuildValue("l",
649 static PyObject
*MenuObj_SetMenuItemModifiers(MenuObject
*_self
, PyObject
*_args
)
651 PyObject
*_res
= NULL
;
655 if (!PyArg_ParseTuple(_args
, "hb",
659 _err
= SetMenuItemModifiers(_self
->ob_itself
,
662 if (_err
!= noErr
) return PyMac_Error(_err
);
668 static PyObject
*MenuObj_GetMenuItemModifiers(MenuObject
*_self
, PyObject
*_args
)
670 PyObject
*_res
= NULL
;
674 if (!PyArg_ParseTuple(_args
, "h",
677 _err
= GetMenuItemModifiers(_self
->ob_itself
,
680 if (_err
!= noErr
) return PyMac_Error(_err
);
681 _res
= Py_BuildValue("b",
686 static PyObject
*MenuObj_SetMenuItemIconHandle(MenuObject
*_self
, PyObject
*_args
)
688 PyObject
*_res
= NULL
;
693 if (!PyArg_ParseTuple(_args
, "hbO&",
696 ResObj_Convert
, &inIconHandle
))
698 _err
= SetMenuItemIconHandle(_self
->ob_itself
,
702 if (_err
!= noErr
) return PyMac_Error(_err
);
708 static PyObject
*MenuObj_GetMenuItemIconHandle(MenuObject
*_self
, PyObject
*_args
)
710 PyObject
*_res
= NULL
;
714 Handle outIconHandle
;
715 if (!PyArg_ParseTuple(_args
, "h",
718 _err
= GetMenuItemIconHandle(_self
->ob_itself
,
722 if (_err
!= noErr
) return PyMac_Error(_err
);
723 _res
= Py_BuildValue("bO&",
725 ResObj_New
, outIconHandle
);
729 static PyObject
*MenuObj_SetMenuItemTextEncoding(MenuObject
*_self
, PyObject
*_args
)
731 PyObject
*_res
= NULL
;
734 TextEncoding inScriptID
;
735 if (!PyArg_ParseTuple(_args
, "hl",
739 _err
= SetMenuItemTextEncoding(_self
->ob_itself
,
742 if (_err
!= noErr
) return PyMac_Error(_err
);
748 static PyObject
*MenuObj_GetMenuItemTextEncoding(MenuObject
*_self
, PyObject
*_args
)
750 PyObject
*_res
= NULL
;
753 TextEncoding outScriptID
;
754 if (!PyArg_ParseTuple(_args
, "h",
757 _err
= GetMenuItemTextEncoding(_self
->ob_itself
,
760 if (_err
!= noErr
) return PyMac_Error(_err
);
761 _res
= Py_BuildValue("l",
766 static PyObject
*MenuObj_SetMenuItemHierarchicalID(MenuObject
*_self
, PyObject
*_args
)
768 PyObject
*_res
= NULL
;
772 if (!PyArg_ParseTuple(_args
, "hh",
776 _err
= SetMenuItemHierarchicalID(_self
->ob_itself
,
779 if (_err
!= noErr
) return PyMac_Error(_err
);
785 static PyObject
*MenuObj_GetMenuItemHierarchicalID(MenuObject
*_self
, PyObject
*_args
)
787 PyObject
*_res
= NULL
;
791 if (!PyArg_ParseTuple(_args
, "h",
794 _err
= GetMenuItemHierarchicalID(_self
->ob_itself
,
797 if (_err
!= noErr
) return PyMac_Error(_err
);
798 _res
= Py_BuildValue("h",
803 static PyObject
*MenuObj_SetMenuItemFontID(MenuObject
*_self
, PyObject
*_args
)
805 PyObject
*_res
= NULL
;
809 if (!PyArg_ParseTuple(_args
, "hh",
813 _err
= SetMenuItemFontID(_self
->ob_itself
,
816 if (_err
!= noErr
) return PyMac_Error(_err
);
822 static PyObject
*MenuObj_GetMenuItemFontID(MenuObject
*_self
, PyObject
*_args
)
824 PyObject
*_res
= NULL
;
828 if (!PyArg_ParseTuple(_args
, "h",
831 _err
= GetMenuItemFontID(_self
->ob_itself
,
834 if (_err
!= noErr
) return PyMac_Error(_err
);
835 _res
= Py_BuildValue("h",
840 static PyObject
*MenuObj_SetMenuItemRefCon(MenuObject
*_self
, PyObject
*_args
)
842 PyObject
*_res
= NULL
;
846 if (!PyArg_ParseTuple(_args
, "hl",
850 _err
= SetMenuItemRefCon(_self
->ob_itself
,
853 if (_err
!= noErr
) return PyMac_Error(_err
);
859 static PyObject
*MenuObj_GetMenuItemRefCon(MenuObject
*_self
, PyObject
*_args
)
861 PyObject
*_res
= NULL
;
865 if (!PyArg_ParseTuple(_args
, "h",
868 _err
= GetMenuItemRefCon(_self
->ob_itself
,
871 if (_err
!= noErr
) return PyMac_Error(_err
);
872 _res
= Py_BuildValue("l",
877 #if !TARGET_API_MAC_CARBON
879 static PyObject
*MenuObj_SetMenuItemRefCon2(MenuObject
*_self
, PyObject
*_args
)
881 PyObject
*_res
= NULL
;
885 if (!PyArg_ParseTuple(_args
, "hl",
889 _err
= SetMenuItemRefCon2(_self
->ob_itself
,
892 if (_err
!= noErr
) return PyMac_Error(_err
);
899 #if !TARGET_API_MAC_CARBON
901 static PyObject
*MenuObj_GetMenuItemRefCon2(MenuObject
*_self
, PyObject
*_args
)
903 PyObject
*_res
= NULL
;
907 if (!PyArg_ParseTuple(_args
, "h",
910 _err
= GetMenuItemRefCon2(_self
->ob_itself
,
913 if (_err
!= noErr
) return PyMac_Error(_err
);
914 _res
= Py_BuildValue("l",
920 static PyObject
*MenuObj_SetMenuItemKeyGlyph(MenuObject
*_self
, PyObject
*_args
)
922 PyObject
*_res
= NULL
;
926 if (!PyArg_ParseTuple(_args
, "hh",
930 _err
= SetMenuItemKeyGlyph(_self
->ob_itself
,
933 if (_err
!= noErr
) return PyMac_Error(_err
);
939 static PyObject
*MenuObj_GetMenuItemKeyGlyph(MenuObject
*_self
, PyObject
*_args
)
941 PyObject
*_res
= NULL
;
945 if (!PyArg_ParseTuple(_args
, "h",
948 _err
= GetMenuItemKeyGlyph(_self
->ob_itself
,
951 if (_err
!= noErr
) return PyMac_Error(_err
);
952 _res
= Py_BuildValue("h",
957 static PyObject
*MenuObj_MacEnableMenuItem(MenuObject
*_self
, PyObject
*_args
)
959 PyObject
*_res
= NULL
;
961 if (!PyArg_ParseTuple(_args
, "h",
964 MacEnableMenuItem(_self
->ob_itself
,
971 static PyObject
*MenuObj_DisableMenuItem(MenuObject
*_self
, PyObject
*_args
)
973 PyObject
*_res
= NULL
;
975 if (!PyArg_ParseTuple(_args
, "h",
978 DisableMenuItem(_self
->ob_itself
,
985 static PyObject
*MenuObj_IsMenuItemEnabled(MenuObject
*_self
, PyObject
*_args
)
987 PyObject
*_res
= NULL
;
990 if (!PyArg_ParseTuple(_args
, "h",
993 _rv
= IsMenuItemEnabled(_self
->ob_itself
,
995 _res
= Py_BuildValue("b",
1000 static PyObject
*MenuObj_EnableMenuItemIcon(MenuObject
*_self
, PyObject
*_args
)
1002 PyObject
*_res
= NULL
;
1004 if (!PyArg_ParseTuple(_args
, "h",
1007 EnableMenuItemIcon(_self
->ob_itself
,
1014 static PyObject
*MenuObj_DisableMenuItemIcon(MenuObject
*_self
, PyObject
*_args
)
1016 PyObject
*_res
= NULL
;
1018 if (!PyArg_ParseTuple(_args
, "h",
1021 DisableMenuItemIcon(_self
->ob_itself
,
1028 static PyObject
*MenuObj_IsMenuItemIconEnabled(MenuObject
*_self
, PyObject
*_args
)
1030 PyObject
*_res
= NULL
;
1033 if (!PyArg_ParseTuple(_args
, "h",
1036 _rv
= IsMenuItemIconEnabled(_self
->ob_itself
,
1038 _res
= Py_BuildValue("b",
1043 #if TARGET_API_MAC_CARBON
1045 static PyObject
*MenuObj_GetMenuItemPropertyAttributes(MenuObject
*_self
, PyObject
*_args
)
1047 PyObject
*_res
= NULL
;
1050 OSType propertyCreator
;
1053 if (!PyArg_ParseTuple(_args
, "hO&O&",
1055 PyMac_GetOSType
, &propertyCreator
,
1056 PyMac_GetOSType
, &propertyTag
))
1058 _err
= GetMenuItemPropertyAttributes(_self
->ob_itself
,
1063 if (_err
!= noErr
) return PyMac_Error(_err
);
1064 _res
= Py_BuildValue("l",
1070 #if TARGET_API_MAC_CARBON
1072 static PyObject
*MenuObj_ChangeMenuItemPropertyAttributes(MenuObject
*_self
, PyObject
*_args
)
1074 PyObject
*_res
= NULL
;
1077 OSType propertyCreator
;
1079 UInt32 attributesToSet
;
1080 UInt32 attributesToClear
;
1081 if (!PyArg_ParseTuple(_args
, "hO&O&ll",
1083 PyMac_GetOSType
, &propertyCreator
,
1084 PyMac_GetOSType
, &propertyTag
,
1086 &attributesToClear
))
1088 _err
= ChangeMenuItemPropertyAttributes(_self
->ob_itself
,
1094 if (_err
!= noErr
) return PyMac_Error(_err
);
1101 #if TARGET_API_MAC_CARBON
1103 static PyObject
*MenuObj_GetMenuAttributes(MenuObject
*_self
, PyObject
*_args
)
1105 PyObject
*_res
= NULL
;
1107 MenuAttributes outAttributes
;
1108 if (!PyArg_ParseTuple(_args
, ""))
1110 _err
= GetMenuAttributes(_self
->ob_itself
,
1112 if (_err
!= noErr
) return PyMac_Error(_err
);
1113 _res
= Py_BuildValue("l",
1119 #if TARGET_API_MAC_CARBON
1121 static PyObject
*MenuObj_ChangeMenuAttributes(MenuObject
*_self
, PyObject
*_args
)
1123 PyObject
*_res
= NULL
;
1125 MenuAttributes setTheseAttributes
;
1126 MenuAttributes clearTheseAttributes
;
1127 if (!PyArg_ParseTuple(_args
, "ll",
1128 &setTheseAttributes
,
1129 &clearTheseAttributes
))
1131 _err
= ChangeMenuAttributes(_self
->ob_itself
,
1133 clearTheseAttributes
);
1134 if (_err
!= noErr
) return PyMac_Error(_err
);
1141 #if TARGET_API_MAC_CARBON
1143 static PyObject
*MenuObj_GetMenuItemAttributes(MenuObject
*_self
, PyObject
*_args
)
1145 PyObject
*_res
= NULL
;
1148 MenuItemAttributes outAttributes
;
1149 if (!PyArg_ParseTuple(_args
, "h",
1152 _err
= GetMenuItemAttributes(_self
->ob_itself
,
1155 if (_err
!= noErr
) return PyMac_Error(_err
);
1156 _res
= Py_BuildValue("l",
1162 #if TARGET_API_MAC_CARBON
1164 static PyObject
*MenuObj_ChangeMenuItemAttributes(MenuObject
*_self
, PyObject
*_args
)
1166 PyObject
*_res
= NULL
;
1169 MenuItemAttributes setTheseAttributes
;
1170 MenuItemAttributes clearTheseAttributes
;
1171 if (!PyArg_ParseTuple(_args
, "hll",
1173 &setTheseAttributes
,
1174 &clearTheseAttributes
))
1176 _err
= ChangeMenuItemAttributes(_self
->ob_itself
,
1179 clearTheseAttributes
);
1180 if (_err
!= noErr
) return PyMac_Error(_err
);
1187 #if TARGET_API_MAC_CARBON
1189 static PyObject
*MenuObj_DisableAllMenuItems(MenuObject
*_self
, PyObject
*_args
)
1191 PyObject
*_res
= NULL
;
1192 if (!PyArg_ParseTuple(_args
, ""))
1194 DisableAllMenuItems(_self
->ob_itself
);
1201 #if TARGET_API_MAC_CARBON
1203 static PyObject
*MenuObj_EnableAllMenuItems(MenuObject
*_self
, PyObject
*_args
)
1205 PyObject
*_res
= NULL
;
1206 if (!PyArg_ParseTuple(_args
, ""))
1208 EnableAllMenuItems(_self
->ob_itself
);
1215 #if TARGET_API_MAC_CARBON
1217 static PyObject
*MenuObj_MenuHasEnabledItems(MenuObject
*_self
, PyObject
*_args
)
1219 PyObject
*_res
= NULL
;
1221 if (!PyArg_ParseTuple(_args
, ""))
1223 _rv
= MenuHasEnabledItems(_self
->ob_itself
);
1224 _res
= Py_BuildValue("b",
1230 #if TARGET_API_MAC_CARBON
1232 static PyObject
*MenuObj_CountMenuItemsWithCommandID(MenuObject
*_self
, PyObject
*_args
)
1234 PyObject
*_res
= NULL
;
1236 MenuCommand commandID
;
1237 if (!PyArg_ParseTuple(_args
, "l",
1240 _rv
= CountMenuItemsWithCommandID(_self
->ob_itself
,
1242 _res
= Py_BuildValue("l",
1248 #if TARGET_API_MAC_CARBON
1250 static PyObject
*MenuObj_GetIndMenuItemWithCommandID(MenuObject
*_self
, PyObject
*_args
)
1252 PyObject
*_res
= NULL
;
1254 MenuCommand commandID
;
1257 MenuItemIndex outIndex
;
1258 if (!PyArg_ParseTuple(_args
, "ll",
1262 _err
= GetIndMenuItemWithCommandID(_self
->ob_itself
,
1267 if (_err
!= noErr
) return PyMac_Error(_err
);
1268 _res
= Py_BuildValue("O&h",
1269 MenuObj_New
, outMenu
,
1275 #if TARGET_API_MAC_CARBON
1277 static PyObject
*MenuObj_EnableMenuCommand(MenuObject
*_self
, PyObject
*_args
)
1279 PyObject
*_res
= NULL
;
1280 MenuCommand commandID
;
1281 if (!PyArg_ParseTuple(_args
, "l",
1284 EnableMenuCommand(_self
->ob_itself
,
1292 #if TARGET_API_MAC_CARBON
1294 static PyObject
*MenuObj_DisableMenuCommand(MenuObject
*_self
, PyObject
*_args
)
1296 PyObject
*_res
= NULL
;
1297 MenuCommand commandID
;
1298 if (!PyArg_ParseTuple(_args
, "l",
1301 DisableMenuCommand(_self
->ob_itself
,
1309 #if TARGET_API_MAC_CARBON
1311 static PyObject
*MenuObj_IsMenuCommandEnabled(MenuObject
*_self
, PyObject
*_args
)
1313 PyObject
*_res
= NULL
;
1315 MenuCommand commandID
;
1316 if (!PyArg_ParseTuple(_args
, "l",
1319 _rv
= IsMenuCommandEnabled(_self
->ob_itself
,
1321 _res
= Py_BuildValue("b",
1327 #if TARGET_API_MAC_CARBON
1329 static PyObject
*MenuObj_GetMenuCommandPropertySize(MenuObject
*_self
, PyObject
*_args
)
1331 PyObject
*_res
= NULL
;
1333 MenuCommand commandID
;
1334 OSType propertyCreator
;
1337 if (!PyArg_ParseTuple(_args
, "lO&O&",
1339 PyMac_GetOSType
, &propertyCreator
,
1340 PyMac_GetOSType
, &propertyTag
))
1342 _err
= GetMenuCommandPropertySize(_self
->ob_itself
,
1347 if (_err
!= noErr
) return PyMac_Error(_err
);
1348 _res
= Py_BuildValue("l",
1354 #if TARGET_API_MAC_CARBON
1356 static PyObject
*MenuObj_RemoveMenuCommandProperty(MenuObject
*_self
, PyObject
*_args
)
1358 PyObject
*_res
= NULL
;
1360 MenuCommand commandID
;
1361 OSType propertyCreator
;
1363 if (!PyArg_ParseTuple(_args
, "lO&O&",
1365 PyMac_GetOSType
, &propertyCreator
,
1366 PyMac_GetOSType
, &propertyTag
))
1368 _err
= RemoveMenuCommandProperty(_self
->ob_itself
,
1372 if (_err
!= noErr
) return PyMac_Error(_err
);
1379 #if TARGET_API_MAC_CARBON
1381 static PyObject
*MenuObj_CreateStandardFontMenu(MenuObject
*_self
, PyObject
*_args
)
1383 PyObject
*_res
= NULL
;
1385 MenuItemIndex afterItem
;
1386 MenuID firstHierMenuID
;
1388 ItemCount outHierMenuCount
;
1389 if (!PyArg_ParseTuple(_args
, "hhl",
1394 _err
= CreateStandardFontMenu(_self
->ob_itself
,
1399 if (_err
!= noErr
) return PyMac_Error(_err
);
1400 _res
= Py_BuildValue("l",
1406 #if TARGET_API_MAC_CARBON
1408 static PyObject
*MenuObj_UpdateStandardFontMenu(MenuObject
*_self
, PyObject
*_args
)
1410 PyObject
*_res
= NULL
;
1412 ItemCount outHierMenuCount
;
1413 if (!PyArg_ParseTuple(_args
, ""))
1415 _err
= UpdateStandardFontMenu(_self
->ob_itself
,
1417 if (_err
!= noErr
) return PyMac_Error(_err
);
1418 _res
= Py_BuildValue("l",
1424 #if TARGET_API_MAC_CARBON
1426 static PyObject
*MenuObj_GetFontFamilyFromMenuSelection(MenuObject
*_self
, PyObject
*_args
)
1428 PyObject
*_res
= NULL
;
1431 FMFontFamily outFontFamily
;
1432 FMFontStyle outStyle
;
1433 if (!PyArg_ParseTuple(_args
, "h",
1436 _err
= GetFontFamilyFromMenuSelection(_self
->ob_itself
,
1440 if (_err
!= noErr
) return PyMac_Error(_err
);
1441 _res
= Py_BuildValue("hh",
1448 static PyObject
*MenuObj_GetMenuID(MenuObject
*_self
, PyObject
*_args
)
1450 PyObject
*_res
= NULL
;
1452 if (!PyArg_ParseTuple(_args
, ""))
1454 _rv
= GetMenuID(_self
->ob_itself
);
1455 _res
= Py_BuildValue("h",
1460 static PyObject
*MenuObj_GetMenuWidth(MenuObject
*_self
, PyObject
*_args
)
1462 PyObject
*_res
= NULL
;
1464 if (!PyArg_ParseTuple(_args
, ""))
1466 _rv
= GetMenuWidth(_self
->ob_itself
);
1467 _res
= Py_BuildValue("h",
1472 static PyObject
*MenuObj_GetMenuHeight(MenuObject
*_self
, PyObject
*_args
)
1474 PyObject
*_res
= NULL
;
1476 if (!PyArg_ParseTuple(_args
, ""))
1478 _rv
= GetMenuHeight(_self
->ob_itself
);
1479 _res
= Py_BuildValue("h",
1484 static PyObject
*MenuObj_SetMenuID(MenuObject
*_self
, PyObject
*_args
)
1486 PyObject
*_res
= NULL
;
1488 if (!PyArg_ParseTuple(_args
, "h",
1491 SetMenuID(_self
->ob_itself
,
1498 static PyObject
*MenuObj_SetMenuWidth(MenuObject
*_self
, PyObject
*_args
)
1500 PyObject
*_res
= NULL
;
1502 if (!PyArg_ParseTuple(_args
, "h",
1505 SetMenuWidth(_self
->ob_itself
,
1512 static PyObject
*MenuObj_SetMenuHeight(MenuObject
*_self
, PyObject
*_args
)
1514 PyObject
*_res
= NULL
;
1516 if (!PyArg_ParseTuple(_args
, "h",
1519 SetMenuHeight(_self
->ob_itself
,
1526 static PyObject
*MenuObj_as_Resource(MenuObject
*_self
, PyObject
*_args
)
1528 PyObject
*_res
= NULL
;
1530 if (!PyArg_ParseTuple(_args
, ""))
1532 _rv
= as_Resource(_self
->ob_itself
);
1533 _res
= Py_BuildValue("O&",
1538 static PyObject
*MenuObj_AppendMenu(MenuObject
*_self
, PyObject
*_args
)
1540 PyObject
*_res
= NULL
;
1542 if (!PyArg_ParseTuple(_args
, "O&",
1543 PyMac_GetStr255
, data
))
1545 AppendMenu(_self
->ob_itself
,
1552 static PyObject
*MenuObj_InsertMenu(MenuObject
*_self
, PyObject
*_args
)
1554 PyObject
*_res
= NULL
;
1556 if (!PyArg_ParseTuple(_args
, "h",
1559 InsertMenu(_self
->ob_itself
,
1566 static PyObject
*MenuObj_InsertMenuItem(MenuObject
*_self
, PyObject
*_args
)
1568 PyObject
*_res
= NULL
;
1571 if (!PyArg_ParseTuple(_args
, "O&h",
1572 PyMac_GetStr255
, itemString
,
1575 InsertMenuItem(_self
->ob_itself
,
1583 static PyObject
*MenuObj_EnableMenuItem(MenuObject
*_self
, PyObject
*_args
)
1585 PyObject
*_res
= NULL
;
1587 if (!PyArg_ParseTuple(_args
, "H",
1590 EnableMenuItem(_self
->ob_itself
,
1597 static PyObject
*MenuObj_CheckMenuItem(MenuObject
*_self
, PyObject
*_args
)
1599 PyObject
*_res
= NULL
;
1602 if (!PyArg_ParseTuple(_args
, "hb",
1606 CheckMenuItem(_self
->ob_itself
,
1614 static PyMethodDef MenuObj_methods
[] = {
1615 {"DisposeMenu", (PyCFunction
)MenuObj_DisposeMenu
, 1,
1617 {"CalcMenuSize", (PyCFunction
)MenuObj_CalcMenuSize
, 1,
1619 {"CountMenuItems", (PyCFunction
)MenuObj_CountMenuItems
, 1,
1620 "() -> (short _rv)"},
1622 #if !TARGET_API_MAC_CARBON
1623 {"CountMItems", (PyCFunction
)MenuObj_CountMItems
, 1,
1624 "() -> (short _rv)"},
1626 {"GetMenuFont", (PyCFunction
)MenuObj_GetMenuFont
, 1,
1627 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1628 {"SetMenuFont", (PyCFunction
)MenuObj_SetMenuFont
, 1,
1629 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1630 {"GetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_GetMenuExcludesMarkColumn
, 1,
1631 "() -> (Boolean _rv)"},
1632 {"SetMenuExcludesMarkColumn", (PyCFunction
)MenuObj_SetMenuExcludesMarkColumn
, 1,
1633 "(Boolean excludesMark) -> None"},
1634 {"MacAppendMenu", (PyCFunction
)MenuObj_MacAppendMenu
, 1,
1635 "(Str255 data) -> None"},
1636 {"InsertResMenu", (PyCFunction
)MenuObj_InsertResMenu
, 1,
1637 "(ResType theType, short afterItem) -> None"},
1638 {"AppendResMenu", (PyCFunction
)MenuObj_AppendResMenu
, 1,
1639 "(ResType theType) -> None"},
1640 {"MacInsertMenuItem", (PyCFunction
)MenuObj_MacInsertMenuItem
, 1,
1641 "(Str255 itemString, short afterItem) -> None"},
1642 {"DeleteMenuItem", (PyCFunction
)MenuObj_DeleteMenuItem
, 1,
1643 "(short item) -> None"},
1644 {"InsertFontResMenu", (PyCFunction
)MenuObj_InsertFontResMenu
, 1,
1645 "(short afterItem, short scriptFilter) -> None"},
1646 {"InsertIntlResMenu", (PyCFunction
)MenuObj_InsertIntlResMenu
, 1,
1647 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1648 {"AppendMenuItemText", (PyCFunction
)MenuObj_AppendMenuItemText
, 1,
1649 "(Str255 inString) -> None"},
1650 {"InsertMenuItemText", (PyCFunction
)MenuObj_InsertMenuItemText
, 1,
1651 "(Str255 inString, MenuItemIndex afterItem) -> None"},
1652 {"PopUpMenuSelect", (PyCFunction
)MenuObj_PopUpMenuSelect
, 1,
1653 "(short top, short left, short popUpItem) -> (long _rv)"},
1654 {"MacInsertMenu", (PyCFunction
)MenuObj_MacInsertMenu
, 1,
1655 "(MenuID beforeID) -> None"},
1656 {"MacCheckMenuItem", (PyCFunction
)MenuObj_MacCheckMenuItem
, 1,
1657 "(short item, Boolean checked) -> None"},
1659 #if !TARGET_API_MAC_CARBON
1660 {"CheckItem", (PyCFunction
)MenuObj_CheckItem
, 1,
1661 "(short item, Boolean checked) -> None"},
1663 {"SetMenuItemText", (PyCFunction
)MenuObj_SetMenuItemText
, 1,
1664 "(short item, Str255 itemString) -> None"},
1665 {"GetMenuItemText", (PyCFunction
)MenuObj_GetMenuItemText
, 1,
1666 "(short item) -> (Str255 itemString)"},
1667 {"SetItemMark", (PyCFunction
)MenuObj_SetItemMark
, 1,
1668 "(short item, CharParameter markChar) -> None"},
1669 {"GetItemMark", (PyCFunction
)MenuObj_GetItemMark
, 1,
1670 "(short item) -> (CharParameter markChar)"},
1671 {"SetItemCmd", (PyCFunction
)MenuObj_SetItemCmd
, 1,
1672 "(short item, CharParameter cmdChar) -> None"},
1673 {"GetItemCmd", (PyCFunction
)MenuObj_GetItemCmd
, 1,
1674 "(short item) -> (CharParameter cmdChar)"},
1675 {"SetItemIcon", (PyCFunction
)MenuObj_SetItemIcon
, 1,
1676 "(short item, short iconIndex) -> None"},
1677 {"GetItemIcon", (PyCFunction
)MenuObj_GetItemIcon
, 1,
1678 "(short item) -> (short iconIndex)"},
1679 {"SetItemStyle", (PyCFunction
)MenuObj_SetItemStyle
, 1,
1680 "(short item, StyleParameter chStyle) -> None"},
1681 {"GetItemStyle", (PyCFunction
)MenuObj_GetItemStyle
, 1,
1682 "(short item) -> (Style chStyle)"},
1684 #if !TARGET_API_MAC_CARBON
1685 {"DisableItem", (PyCFunction
)MenuObj_DisableItem
, 1,
1686 "(short item) -> None"},
1689 #if !TARGET_API_MAC_CARBON
1690 {"EnableItem", (PyCFunction
)MenuObj_EnableItem
, 1,
1691 "(short item) -> None"},
1693 {"SetMenuItemCommandID", (PyCFunction
)MenuObj_SetMenuItemCommandID
, 1,
1694 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
1695 {"GetMenuItemCommandID", (PyCFunction
)MenuObj_GetMenuItemCommandID
, 1,
1696 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
1697 {"SetMenuItemModifiers", (PyCFunction
)MenuObj_SetMenuItemModifiers
, 1,
1698 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1699 {"GetMenuItemModifiers", (PyCFunction
)MenuObj_GetMenuItemModifiers
, 1,
1700 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1701 {"SetMenuItemIconHandle", (PyCFunction
)MenuObj_SetMenuItemIconHandle
, 1,
1702 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1703 {"GetMenuItemIconHandle", (PyCFunction
)MenuObj_GetMenuItemIconHandle
, 1,
1704 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1705 {"SetMenuItemTextEncoding", (PyCFunction
)MenuObj_SetMenuItemTextEncoding
, 1,
1706 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1707 {"GetMenuItemTextEncoding", (PyCFunction
)MenuObj_GetMenuItemTextEncoding
, 1,
1708 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1709 {"SetMenuItemHierarchicalID", (PyCFunction
)MenuObj_SetMenuItemHierarchicalID
, 1,
1710 "(SInt16 inItem, MenuID inHierID) -> None"},
1711 {"GetMenuItemHierarchicalID", (PyCFunction
)MenuObj_GetMenuItemHierarchicalID
, 1,
1712 "(SInt16 inItem) -> (MenuID outHierID)"},
1713 {"SetMenuItemFontID", (PyCFunction
)MenuObj_SetMenuItemFontID
, 1,
1714 "(SInt16 inItem, SInt16 inFontID) -> None"},
1715 {"GetMenuItemFontID", (PyCFunction
)MenuObj_GetMenuItemFontID
, 1,
1716 "(SInt16 inItem) -> (SInt16 outFontID)"},
1717 {"SetMenuItemRefCon", (PyCFunction
)MenuObj_SetMenuItemRefCon
, 1,
1718 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1719 {"GetMenuItemRefCon", (PyCFunction
)MenuObj_GetMenuItemRefCon
, 1,
1720 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1722 #if !TARGET_API_MAC_CARBON
1723 {"SetMenuItemRefCon2", (PyCFunction
)MenuObj_SetMenuItemRefCon2
, 1,
1724 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1727 #if !TARGET_API_MAC_CARBON
1728 {"GetMenuItemRefCon2", (PyCFunction
)MenuObj_GetMenuItemRefCon2
, 1,
1729 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1731 {"SetMenuItemKeyGlyph", (PyCFunction
)MenuObj_SetMenuItemKeyGlyph
, 1,
1732 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1733 {"GetMenuItemKeyGlyph", (PyCFunction
)MenuObj_GetMenuItemKeyGlyph
, 1,
1734 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1735 {"MacEnableMenuItem", (PyCFunction
)MenuObj_MacEnableMenuItem
, 1,
1736 "(MenuItemIndex item) -> None"},
1737 {"DisableMenuItem", (PyCFunction
)MenuObj_DisableMenuItem
, 1,
1738 "(MenuItemIndex item) -> None"},
1739 {"IsMenuItemEnabled", (PyCFunction
)MenuObj_IsMenuItemEnabled
, 1,
1740 "(MenuItemIndex item) -> (Boolean _rv)"},
1741 {"EnableMenuItemIcon", (PyCFunction
)MenuObj_EnableMenuItemIcon
, 1,
1742 "(MenuItemIndex item) -> None"},
1743 {"DisableMenuItemIcon", (PyCFunction
)MenuObj_DisableMenuItemIcon
, 1,
1744 "(MenuItemIndex item) -> None"},
1745 {"IsMenuItemIconEnabled", (PyCFunction
)MenuObj_IsMenuItemIconEnabled
, 1,
1746 "(MenuItemIndex item) -> (Boolean _rv)"},
1748 #if TARGET_API_MAC_CARBON
1749 {"GetMenuItemPropertyAttributes", (PyCFunction
)MenuObj_GetMenuItemPropertyAttributes
, 1,
1750 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1753 #if TARGET_API_MAC_CARBON
1754 {"ChangeMenuItemPropertyAttributes", (PyCFunction
)MenuObj_ChangeMenuItemPropertyAttributes
, 1,
1755 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1758 #if TARGET_API_MAC_CARBON
1759 {"GetMenuAttributes", (PyCFunction
)MenuObj_GetMenuAttributes
, 1,
1760 "() -> (MenuAttributes outAttributes)"},
1763 #if TARGET_API_MAC_CARBON
1764 {"ChangeMenuAttributes", (PyCFunction
)MenuObj_ChangeMenuAttributes
, 1,
1765 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1768 #if TARGET_API_MAC_CARBON
1769 {"GetMenuItemAttributes", (PyCFunction
)MenuObj_GetMenuItemAttributes
, 1,
1770 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1773 #if TARGET_API_MAC_CARBON
1774 {"ChangeMenuItemAttributes", (PyCFunction
)MenuObj_ChangeMenuItemAttributes
, 1,
1775 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1778 #if TARGET_API_MAC_CARBON
1779 {"DisableAllMenuItems", (PyCFunction
)MenuObj_DisableAllMenuItems
, 1,
1783 #if TARGET_API_MAC_CARBON
1784 {"EnableAllMenuItems", (PyCFunction
)MenuObj_EnableAllMenuItems
, 1,
1788 #if TARGET_API_MAC_CARBON
1789 {"MenuHasEnabledItems", (PyCFunction
)MenuObj_MenuHasEnabledItems
, 1,
1790 "() -> (Boolean _rv)"},
1793 #if TARGET_API_MAC_CARBON
1794 {"CountMenuItemsWithCommandID", (PyCFunction
)MenuObj_CountMenuItemsWithCommandID
, 1,
1795 "(MenuCommand commandID) -> (ItemCount _rv)"},
1798 #if TARGET_API_MAC_CARBON
1799 {"GetIndMenuItemWithCommandID", (PyCFunction
)MenuObj_GetIndMenuItemWithCommandID
, 1,
1800 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1803 #if TARGET_API_MAC_CARBON
1804 {"EnableMenuCommand", (PyCFunction
)MenuObj_EnableMenuCommand
, 1,
1805 "(MenuCommand commandID) -> None"},
1808 #if TARGET_API_MAC_CARBON
1809 {"DisableMenuCommand", (PyCFunction
)MenuObj_DisableMenuCommand
, 1,
1810 "(MenuCommand commandID) -> None"},
1813 #if TARGET_API_MAC_CARBON
1814 {"IsMenuCommandEnabled", (PyCFunction
)MenuObj_IsMenuCommandEnabled
, 1,
1815 "(MenuCommand commandID) -> (Boolean _rv)"},
1818 #if TARGET_API_MAC_CARBON
1819 {"GetMenuCommandPropertySize", (PyCFunction
)MenuObj_GetMenuCommandPropertySize
, 1,
1820 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1823 #if TARGET_API_MAC_CARBON
1824 {"RemoveMenuCommandProperty", (PyCFunction
)MenuObj_RemoveMenuCommandProperty
, 1,
1825 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1828 #if TARGET_API_MAC_CARBON
1829 {"CreateStandardFontMenu", (PyCFunction
)MenuObj_CreateStandardFontMenu
, 1,
1830 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1833 #if TARGET_API_MAC_CARBON
1834 {"UpdateStandardFontMenu", (PyCFunction
)MenuObj_UpdateStandardFontMenu
, 1,
1835 "() -> (ItemCount outHierMenuCount)"},
1838 #if TARGET_API_MAC_CARBON
1839 {"GetFontFamilyFromMenuSelection", (PyCFunction
)MenuObj_GetFontFamilyFromMenuSelection
, 1,
1840 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
1842 {"GetMenuID", (PyCFunction
)MenuObj_GetMenuID
, 1,
1843 "() -> (MenuID _rv)"},
1844 {"GetMenuWidth", (PyCFunction
)MenuObj_GetMenuWidth
, 1,
1845 "() -> (SInt16 _rv)"},
1846 {"GetMenuHeight", (PyCFunction
)MenuObj_GetMenuHeight
, 1,
1847 "() -> (SInt16 _rv)"},
1848 {"SetMenuID", (PyCFunction
)MenuObj_SetMenuID
, 1,
1849 "(MenuID menuID) -> None"},
1850 {"SetMenuWidth", (PyCFunction
)MenuObj_SetMenuWidth
, 1,
1851 "(SInt16 width) -> None"},
1852 {"SetMenuHeight", (PyCFunction
)MenuObj_SetMenuHeight
, 1,
1853 "(SInt16 height) -> None"},
1854 {"as_Resource", (PyCFunction
)MenuObj_as_Resource
, 1,
1855 "() -> (Handle _rv)"},
1856 {"AppendMenu", (PyCFunction
)MenuObj_AppendMenu
, 1,
1857 "(Str255 data) -> None"},
1858 {"InsertMenu", (PyCFunction
)MenuObj_InsertMenu
, 1,
1859 "(short beforeID) -> None"},
1860 {"InsertMenuItem", (PyCFunction
)MenuObj_InsertMenuItem
, 1,
1861 "(Str255 itemString, short afterItem) -> None"},
1862 {"EnableMenuItem", (PyCFunction
)MenuObj_EnableMenuItem
, 1,
1863 "(UInt16 item) -> None"},
1864 {"CheckMenuItem", (PyCFunction
)MenuObj_CheckMenuItem
, 1,
1865 "(short item, Boolean checked) -> None"},
1869 PyMethodChain MenuObj_chain
= { MenuObj_methods
, NULL
};
1871 static PyObject
*MenuObj_getattr(MenuObject
*self
, char *name
)
1873 return Py_FindMethodInChain(&MenuObj_chain
, (PyObject
*)self
, name
);
1876 #define MenuObj_setattr NULL
1878 #define MenuObj_compare NULL
1880 #define MenuObj_repr NULL
1882 #define MenuObj_hash NULL
1884 PyTypeObject Menu_Type
= {
1885 PyObject_HEAD_INIT(&PyType_Type
)
1888 sizeof(MenuObject
), /*tp_basicsize*/
1891 (destructor
) MenuObj_dealloc
, /*tp_dealloc*/
1893 (getattrfunc
) MenuObj_getattr
, /*tp_getattr*/
1894 (setattrfunc
) MenuObj_setattr
, /*tp_setattr*/
1895 (cmpfunc
) MenuObj_compare
, /*tp_compare*/
1896 (reprfunc
) MenuObj_repr
, /*tp_repr*/
1897 (PyNumberMethods
*)0, /* tp_as_number */
1898 (PySequenceMethods
*)0, /* tp_as_sequence */
1899 (PyMappingMethods
*)0, /* tp_as_mapping */
1900 (hashfunc
) MenuObj_hash
, /*tp_hash*/
1903 /* ---------------------- End object type Menu ---------------------- */
1906 #if !TARGET_API_MAC_CARBON
1908 static PyObject
*Menu_InitProcMenu(PyObject
*_self
, PyObject
*_args
)
1910 PyObject
*_res
= NULL
;
1912 if (!PyArg_ParseTuple(_args
, "h",
1915 InitProcMenu(resID
);
1922 #if !TARGET_API_MAC_CARBON
1924 static PyObject
*Menu_InitMenus(PyObject
*_self
, PyObject
*_args
)
1926 PyObject
*_res
= NULL
;
1927 if (!PyArg_ParseTuple(_args
, ""))
1936 static PyObject
*Menu_NewMenu(PyObject
*_self
, PyObject
*_args
)
1938 PyObject
*_res
= NULL
;
1942 if (!PyArg_ParseTuple(_args
, "hO&",
1944 PyMac_GetStr255
, menuTitle
))
1946 _rv
= NewMenu(menuID
,
1948 _res
= Py_BuildValue("O&",
1953 static PyObject
*Menu_MacGetMenu(PyObject
*_self
, PyObject
*_args
)
1955 PyObject
*_res
= NULL
;
1958 if (!PyArg_ParseTuple(_args
, "h",
1961 _rv
= MacGetMenu(resourceID
);
1962 _res
= Py_BuildValue("O&",
1967 #if TARGET_API_MAC_CARBON
1969 static PyObject
*Menu_CreateNewMenu(PyObject
*_self
, PyObject
*_args
)
1971 PyObject
*_res
= NULL
;
1974 MenuAttributes menuAttributes
;
1975 MenuHandle outMenuRef
;
1976 if (!PyArg_ParseTuple(_args
, "hl",
1980 _err
= CreateNewMenu(menuID
,
1983 if (_err
!= noErr
) return PyMac_Error(_err
);
1984 _res
= Py_BuildValue("O&",
1985 MenuObj_New
, outMenuRef
);
1990 static PyObject
*Menu_MenuKey(PyObject
*_self
, PyObject
*_args
)
1992 PyObject
*_res
= NULL
;
1995 if (!PyArg_ParseTuple(_args
, "h",
1999 _res
= Py_BuildValue("l",
2004 static PyObject
*Menu_MenuSelect(PyObject
*_self
, PyObject
*_args
)
2006 PyObject
*_res
= NULL
;
2009 if (!PyArg_ParseTuple(_args
, "O&",
2010 PyMac_GetPoint
, &startPt
))
2012 _rv
= MenuSelect(startPt
);
2013 _res
= Py_BuildValue("l",
2018 static PyObject
*Menu_MenuChoice(PyObject
*_self
, PyObject
*_args
)
2020 PyObject
*_res
= NULL
;
2022 if (!PyArg_ParseTuple(_args
, ""))
2025 _res
= Py_BuildValue("l",
2030 static PyObject
*Menu_MenuEvent(PyObject
*_self
, PyObject
*_args
)
2032 PyObject
*_res
= NULL
;
2034 EventRecord inEvent
;
2035 if (!PyArg_ParseTuple(_args
, "O&",
2036 PyMac_GetEventRecord
, &inEvent
))
2038 _rv
= MenuEvent(&inEvent
);
2039 _res
= Py_BuildValue("l",
2044 static PyObject
*Menu_GetMBarHeight(PyObject
*_self
, PyObject
*_args
)
2046 PyObject
*_res
= NULL
;
2048 if (!PyArg_ParseTuple(_args
, ""))
2050 _rv
= GetMBarHeight();
2051 _res
= Py_BuildValue("h",
2056 static PyObject
*Menu_MacDrawMenuBar(PyObject
*_self
, PyObject
*_args
)
2058 PyObject
*_res
= NULL
;
2059 if (!PyArg_ParseTuple(_args
, ""))
2067 static PyObject
*Menu_InvalMenuBar(PyObject
*_self
, PyObject
*_args
)
2069 PyObject
*_res
= NULL
;
2070 if (!PyArg_ParseTuple(_args
, ""))
2078 static PyObject
*Menu_HiliteMenu(PyObject
*_self
, PyObject
*_args
)
2080 PyObject
*_res
= NULL
;
2082 if (!PyArg_ParseTuple(_args
, "h",
2091 static PyObject
*Menu_GetNewMBar(PyObject
*_self
, PyObject
*_args
)
2093 PyObject
*_res
= NULL
;
2096 if (!PyArg_ParseTuple(_args
, "h",
2099 _rv
= GetNewMBar(menuBarID
);
2100 _res
= Py_BuildValue("O&",
2105 static PyObject
*Menu_GetMenuBar(PyObject
*_self
, PyObject
*_args
)
2107 PyObject
*_res
= NULL
;
2109 if (!PyArg_ParseTuple(_args
, ""))
2112 _res
= Py_BuildValue("O&",
2117 static PyObject
*Menu_SetMenuBar(PyObject
*_self
, PyObject
*_args
)
2119 PyObject
*_res
= NULL
;
2121 if (!PyArg_ParseTuple(_args
, "O&",
2122 ResObj_Convert
, &mbar
))
2130 #if TARGET_API_MAC_CARBON
2132 static PyObject
*Menu_DuplicateMenuBar(PyObject
*_self
, PyObject
*_args
)
2134 PyObject
*_res
= NULL
;
2137 MenuBarHandle outBar
;
2138 if (!PyArg_ParseTuple(_args
, "O&",
2139 ResObj_Convert
, &mbar
))
2141 _err
= DuplicateMenuBar(mbar
,
2143 if (_err
!= noErr
) return PyMac_Error(_err
);
2144 _res
= Py_BuildValue("O&",
2145 ResObj_New
, outBar
);
2150 #if TARGET_API_MAC_CARBON
2152 static PyObject
*Menu_DisposeMenuBar(PyObject
*_self
, PyObject
*_args
)
2154 PyObject
*_res
= NULL
;
2157 if (!PyArg_ParseTuple(_args
, "O&",
2158 ResObj_Convert
, &mbar
))
2160 _err
= DisposeMenuBar(mbar
);
2161 if (_err
!= noErr
) return PyMac_Error(_err
);
2168 static PyObject
*Menu_GetMenuHandle(PyObject
*_self
, PyObject
*_args
)
2170 PyObject
*_res
= NULL
;
2173 if (!PyArg_ParseTuple(_args
, "h",
2176 _rv
= GetMenuHandle(menuID
);
2177 _res
= Py_BuildValue("O&",
2182 static PyObject
*Menu_MacDeleteMenu(PyObject
*_self
, PyObject
*_args
)
2184 PyObject
*_res
= NULL
;
2186 if (!PyArg_ParseTuple(_args
, "h",
2189 MacDeleteMenu(menuID
);
2195 static PyObject
*Menu_ClearMenuBar(PyObject
*_self
, PyObject
*_args
)
2197 PyObject
*_res
= NULL
;
2198 if (!PyArg_ParseTuple(_args
, ""))
2206 static PyObject
*Menu_SetMenuFlashCount(PyObject
*_self
, PyObject
*_args
)
2208 PyObject
*_res
= NULL
;
2210 if (!PyArg_ParseTuple(_args
, "h",
2213 SetMenuFlashCount(count
);
2219 #if !TARGET_API_MAC_CARBON
2221 static PyObject
*Menu_SetMenuFlash(PyObject
*_self
, PyObject
*_args
)
2223 PyObject
*_res
= NULL
;
2225 if (!PyArg_ParseTuple(_args
, "h",
2228 SetMenuFlash(count
);
2235 static PyObject
*Menu_FlashMenuBar(PyObject
*_self
, PyObject
*_args
)
2237 PyObject
*_res
= NULL
;
2239 if (!PyArg_ParseTuple(_args
, "h",
2242 FlashMenuBar(menuID
);
2248 #if !TARGET_API_MAC_CARBON
2250 static PyObject
*Menu_SystemEdit(PyObject
*_self
, PyObject
*_args
)
2252 PyObject
*_res
= NULL
;
2255 if (!PyArg_ParseTuple(_args
, "h",
2258 _rv
= SystemEdit(editCmd
);
2259 _res
= Py_BuildValue("b",
2265 #if !TARGET_API_MAC_CARBON
2267 static PyObject
*Menu_SystemMenu(PyObject
*_self
, PyObject
*_args
)
2269 PyObject
*_res
= NULL
;
2271 if (!PyArg_ParseTuple(_args
, "l",
2274 SystemMenu(menuResult
);
2281 static PyObject
*Menu_IsMenuBarVisible(PyObject
*_self
, PyObject
*_args
)
2283 PyObject
*_res
= NULL
;
2285 if (!PyArg_ParseTuple(_args
, ""))
2287 _rv
= IsMenuBarVisible();
2288 _res
= Py_BuildValue("b",
2293 static PyObject
*Menu_ShowMenuBar(PyObject
*_self
, PyObject
*_args
)
2295 PyObject
*_res
= NULL
;
2296 if (!PyArg_ParseTuple(_args
, ""))
2304 static PyObject
*Menu_HideMenuBar(PyObject
*_self
, PyObject
*_args
)
2306 PyObject
*_res
= NULL
;
2307 if (!PyArg_ParseTuple(_args
, ""))
2315 static PyObject
*Menu_DeleteMCEntries(PyObject
*_self
, PyObject
*_args
)
2317 PyObject
*_res
= NULL
;
2320 if (!PyArg_ParseTuple(_args
, "hh",
2324 DeleteMCEntries(menuID
,
2331 static PyObject
*Menu_InitContextualMenus(PyObject
*_self
, PyObject
*_args
)
2333 PyObject
*_res
= NULL
;
2335 if (!PyArg_ParseTuple(_args
, ""))
2337 _err
= InitContextualMenus();
2338 if (_err
!= noErr
) return PyMac_Error(_err
);
2344 static PyObject
*Menu_IsShowContextualMenuClick(PyObject
*_self
, PyObject
*_args
)
2346 PyObject
*_res
= NULL
;
2348 EventRecord inEvent
;
2349 if (!PyArg_ParseTuple(_args
, "O&",
2350 PyMac_GetEventRecord
, &inEvent
))
2352 _rv
= IsShowContextualMenuClick(&inEvent
);
2353 _res
= Py_BuildValue("b",
2358 #if !TARGET_API_MAC_CARBON
2360 static PyObject
*Menu_OpenDeskAcc(PyObject
*_self
, PyObject
*_args
)
2362 PyObject
*_res
= NULL
;
2364 if (!PyArg_ParseTuple(_args
, "O&",
2365 PyMac_GetStr255
, name
))
2374 static PyObject
*Menu_as_Menu(PyObject
*_self
, PyObject
*_args
)
2376 PyObject
*_res
= NULL
;
2379 if (!PyArg_ParseTuple(_args
, "O&",
2380 ResObj_Convert
, &h
))
2383 _res
= Py_BuildValue("O&",
2388 static PyObject
*Menu_GetMenu(PyObject
*_self
, PyObject
*_args
)
2390 PyObject
*_res
= NULL
;
2393 if (!PyArg_ParseTuple(_args
, "h",
2396 _rv
= GetMenu(resourceID
);
2397 _res
= Py_BuildValue("O&",
2402 static PyObject
*Menu_DeleteMenu(PyObject
*_self
, PyObject
*_args
)
2404 PyObject
*_res
= NULL
;
2406 if (!PyArg_ParseTuple(_args
, "h",
2415 static PyObject
*Menu_DrawMenuBar(PyObject
*_self
, PyObject
*_args
)
2417 PyObject
*_res
= NULL
;
2418 if (!PyArg_ParseTuple(_args
, ""))
2426 static PyMethodDef Menu_methods
[] = {
2428 #if !TARGET_API_MAC_CARBON
2429 {"InitProcMenu", (PyCFunction
)Menu_InitProcMenu
, 1,
2430 "(short resID) -> None"},
2433 #if !TARGET_API_MAC_CARBON
2434 {"InitMenus", (PyCFunction
)Menu_InitMenus
, 1,
2437 {"NewMenu", (PyCFunction
)Menu_NewMenu
, 1,
2438 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
2439 {"MacGetMenu", (PyCFunction
)Menu_MacGetMenu
, 1,
2440 "(short resourceID) -> (MenuHandle _rv)"},
2442 #if TARGET_API_MAC_CARBON
2443 {"CreateNewMenu", (PyCFunction
)Menu_CreateNewMenu
, 1,
2444 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2446 {"MenuKey", (PyCFunction
)Menu_MenuKey
, 1,
2447 "(CharParameter ch) -> (long _rv)"},
2448 {"MenuSelect", (PyCFunction
)Menu_MenuSelect
, 1,
2449 "(Point startPt) -> (long _rv)"},
2450 {"MenuChoice", (PyCFunction
)Menu_MenuChoice
, 1,
2451 "() -> (long _rv)"},
2452 {"MenuEvent", (PyCFunction
)Menu_MenuEvent
, 1,
2453 "(EventRecord inEvent) -> (UInt32 _rv)"},
2454 {"GetMBarHeight", (PyCFunction
)Menu_GetMBarHeight
, 1,
2455 "() -> (short _rv)"},
2456 {"MacDrawMenuBar", (PyCFunction
)Menu_MacDrawMenuBar
, 1,
2458 {"InvalMenuBar", (PyCFunction
)Menu_InvalMenuBar
, 1,
2460 {"HiliteMenu", (PyCFunction
)Menu_HiliteMenu
, 1,
2461 "(MenuID menuID) -> None"},
2462 {"GetNewMBar", (PyCFunction
)Menu_GetNewMBar
, 1,
2463 "(short menuBarID) -> (MenuBarHandle _rv)"},
2464 {"GetMenuBar", (PyCFunction
)Menu_GetMenuBar
, 1,
2465 "() -> (MenuBarHandle _rv)"},
2466 {"SetMenuBar", (PyCFunction
)Menu_SetMenuBar
, 1,
2467 "(MenuBarHandle mbar) -> None"},
2469 #if TARGET_API_MAC_CARBON
2470 {"DuplicateMenuBar", (PyCFunction
)Menu_DuplicateMenuBar
, 1,
2471 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2474 #if TARGET_API_MAC_CARBON
2475 {"DisposeMenuBar", (PyCFunction
)Menu_DisposeMenuBar
, 1,
2476 "(MenuBarHandle mbar) -> None"},
2478 {"GetMenuHandle", (PyCFunction
)Menu_GetMenuHandle
, 1,
2479 "(MenuID menuID) -> (MenuHandle _rv)"},
2480 {"MacDeleteMenu", (PyCFunction
)Menu_MacDeleteMenu
, 1,
2481 "(MenuID menuID) -> None"},
2482 {"ClearMenuBar", (PyCFunction
)Menu_ClearMenuBar
, 1,
2484 {"SetMenuFlashCount", (PyCFunction
)Menu_SetMenuFlashCount
, 1,
2485 "(short count) -> None"},
2487 #if !TARGET_API_MAC_CARBON
2488 {"SetMenuFlash", (PyCFunction
)Menu_SetMenuFlash
, 1,
2489 "(short count) -> None"},
2491 {"FlashMenuBar", (PyCFunction
)Menu_FlashMenuBar
, 1,
2492 "(MenuID menuID) -> None"},
2494 #if !TARGET_API_MAC_CARBON
2495 {"SystemEdit", (PyCFunction
)Menu_SystemEdit
, 1,
2496 "(short editCmd) -> (Boolean _rv)"},
2499 #if !TARGET_API_MAC_CARBON
2500 {"SystemMenu", (PyCFunction
)Menu_SystemMenu
, 1,
2501 "(long menuResult) -> None"},
2503 {"IsMenuBarVisible", (PyCFunction
)Menu_IsMenuBarVisible
, 1,
2504 "() -> (Boolean _rv)"},
2505 {"ShowMenuBar", (PyCFunction
)Menu_ShowMenuBar
, 1,
2507 {"HideMenuBar", (PyCFunction
)Menu_HideMenuBar
, 1,
2509 {"DeleteMCEntries", (PyCFunction
)Menu_DeleteMCEntries
, 1,
2510 "(MenuID menuID, short menuItem) -> None"},
2511 {"InitContextualMenus", (PyCFunction
)Menu_InitContextualMenus
, 1,
2513 {"IsShowContextualMenuClick", (PyCFunction
)Menu_IsShowContextualMenuClick
, 1,
2514 "(EventRecord inEvent) -> (Boolean _rv)"},
2516 #if !TARGET_API_MAC_CARBON
2517 {"OpenDeskAcc", (PyCFunction
)Menu_OpenDeskAcc
, 1,
2518 "(Str255 name) -> None"},
2520 {"as_Menu", (PyCFunction
)Menu_as_Menu
, 1,
2521 "(Handle h) -> (MenuHandle _rv)"},
2522 {"GetMenu", (PyCFunction
)Menu_GetMenu
, 1,
2523 "(short resourceID) -> (MenuHandle _rv)"},
2524 {"DeleteMenu", (PyCFunction
)Menu_DeleteMenu
, 1,
2525 "(short menuID) -> None"},
2526 {"DrawMenuBar", (PyCFunction
)Menu_DrawMenuBar
, 1,
2541 PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle
, MenuObj_New
);
2542 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle
, MenuObj_Convert
);
2545 m
= Py_InitModule("Menu", Menu_methods
);
2546 d
= PyModule_GetDict(m
);
2547 Menu_Error
= PyMac_GetOSErrException();
2548 if (Menu_Error
== NULL
||
2549 PyDict_SetItemString(d
, "Error", Menu_Error
) != 0)
2551 Menu_Type
.ob_type
= &PyType_Type
;
2552 Py_INCREF(&Menu_Type
);
2553 if (PyDict_SetItemString(d
, "MenuType", (PyObject
*)&Menu_Type
) != 0)
2554 Py_FatalError("can't initialize MenuType");
2557 /* ======================== End module Menu ========================= */