diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-10 23:43:49 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-10 23:43:49 (GMT) |
commit | f7d5aa61d34cb7816ead2757860e5a66f7da0dcb (patch) | |
tree | faba3f23c2f0fdfa74a156d441f6fa8945c337f8 /Mac/Modules/menu | |
parent | c6c283840316dec54244b311657511e95e742eb0 (diff) | |
download | cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.zip cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.tar.gz cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.tar.bz2 |
Adapted to Universal Headers 3.3.2. More to follow.
Diffstat (limited to 'Mac/Modules/menu')
-rw-r--r-- | Mac/Modules/menu/Menumodule.c | 890 | ||||
-rw-r--r-- | Mac/Modules/menu/menuscan.py | 32 | ||||
-rw-r--r-- | Mac/Modules/menu/menusupport.py | 19 |
3 files changed, 888 insertions, 53 deletions
diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c index a47c88a..7f15330 100644 --- a/Mac/Modules/menu/Menumodule.c +++ b/Mac/Modules/menu/Menumodule.c @@ -11,6 +11,16 @@ #include <Devices.h> /* Defines OpenDeskAcc in universal headers */ #include <Menus.h> +#if !ACCESSOR_CALLS_ARE_FUNCTIONS +#define GetMenuID(menu) ((*(menu))->menuID) +#define GetMenuWidth(menu) ((*(menu))->menuWidth) +#define GetMenuHeight(menu) ((*(menu))->menuHeight) + +#define SetMenuID(menu, id) ((*(menu))->menuID = (id)) +#define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width)) +#define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height)) +#endif + #define as_Menu(h) ((MenuHandle)h) #define as_Resource(h) ((Handle)h) @@ -82,6 +92,20 @@ static PyObject *MenuObj_CalcMenuSize(_self, _args) return _res; } +static PyObject *MenuObj_CountMenuItems(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + short _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = CountMenuItems(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); + return _res; +} + #if !TARGET_API_MAC_CARBON static PyObject *MenuObj_CountMItems(_self, _args) @@ -324,8 +348,8 @@ static PyObject *MenuObj_InsertMenuItemText(_self, _args) PyObject *_res = NULL; OSStatus _err; Str255 inString; - UInt16 afterItem; - if (!PyArg_ParseTuple(_args, "O&H", + MenuItemIndex afterItem; + if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetStr255, inString, &afterItem)) return NULL; @@ -366,7 +390,7 @@ static PyObject *MenuObj_MacInsertMenu(_self, _args) PyObject *_args; { PyObject *_res = NULL; - short beforeID; + MenuID beforeID; if (!PyArg_ParseTuple(_args, "h", &beforeID)) return NULL; @@ -377,6 +401,25 @@ static PyObject *MenuObj_MacInsertMenu(_self, _args) return _res; } +static PyObject *MenuObj_MacCheckMenuItem(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + short item; + Boolean checked; + if (!PyArg_ParseTuple(_args, "hb", + &item, + &checked)) + return NULL; + MacCheckMenuItem(_self->ob_itself, + item, + checked); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + #if !TARGET_API_MAC_CARBON static PyObject *MenuObj_CheckItem(_self, _args) @@ -629,7 +672,7 @@ static PyObject *MenuObj_SetMenuItemCommandID(_self, _args) PyObject *_res = NULL; OSErr _err; SInt16 inItem; - UInt32 inCommandID; + MenuCommand inCommandID; if (!PyArg_ParseTuple(_args, "hl", &inItem, &inCommandID)) @@ -650,7 +693,7 @@ static PyObject *MenuObj_GetMenuItemCommandID(_self, _args) PyObject *_res = NULL; OSErr _err; SInt16 inItem; - UInt32 outCommandID; + MenuCommand outCommandID; if (!PyArg_ParseTuple(_args, "h", &inItem)) return NULL; @@ -799,7 +842,7 @@ static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args) PyObject *_res = NULL; OSErr _err; SInt16 inItem; - SInt16 inHierID; + MenuID inHierID; if (!PyArg_ParseTuple(_args, "hh", &inItem, &inHierID)) @@ -820,7 +863,7 @@ static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args) PyObject *_res = NULL; OSErr _err; SInt16 inItem; - SInt16 outHierID; + MenuID outHierID; if (!PyArg_ParseTuple(_args, "h", &inItem)) return NULL; @@ -1008,8 +1051,8 @@ static PyObject *MenuObj_MacEnableMenuItem(_self, _args) PyObject *_args; { PyObject *_res = NULL; - UInt16 item; - if (!PyArg_ParseTuple(_args, "H", + MenuItemIndex item; + if (!PyArg_ParseTuple(_args, "h", &item)) return NULL; MacEnableMenuItem(_self->ob_itself, @@ -1024,8 +1067,8 @@ static PyObject *MenuObj_DisableMenuItem(_self, _args) PyObject *_args; { PyObject *_res = NULL; - UInt16 item; - if (!PyArg_ParseTuple(_args, "H", + MenuItemIndex item; + if (!PyArg_ParseTuple(_args, "h", &item)) return NULL; DisableMenuItem(_self->ob_itself, @@ -1041,8 +1084,8 @@ static PyObject *MenuObj_IsMenuItemEnabled(_self, _args) { PyObject *_res = NULL; Boolean _rv; - UInt16 item; - if (!PyArg_ParseTuple(_args, "H", + MenuItemIndex item; + if (!PyArg_ParseTuple(_args, "h", &item)) return NULL; _rv = IsMenuItemEnabled(_self->ob_itself, @@ -1057,8 +1100,8 @@ static PyObject *MenuObj_EnableMenuItemIcon(_self, _args) PyObject *_args; { PyObject *_res = NULL; - UInt16 item; - if (!PyArg_ParseTuple(_args, "H", + MenuItemIndex item; + if (!PyArg_ParseTuple(_args, "h", &item)) return NULL; EnableMenuItemIcon(_self->ob_itself, @@ -1073,8 +1116,8 @@ static PyObject *MenuObj_DisableMenuItemIcon(_self, _args) PyObject *_args; { PyObject *_res = NULL; - UInt16 item; - if (!PyArg_ParseTuple(_args, "H", + MenuItemIndex item; + if (!PyArg_ParseTuple(_args, "h", &item)) return NULL; DisableMenuItemIcon(_self->ob_itself, @@ -1090,8 +1133,8 @@ static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args) { PyObject *_res = NULL; Boolean _rv; - UInt16 item; - if (!PyArg_ParseTuple(_args, "H", + MenuItemIndex item; + if (!PyArg_ParseTuple(_args, "h", &item)) return NULL; _rv = IsMenuItemIconEnabled(_self->ob_itself, @@ -1101,6 +1144,539 @@ static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args) return _res; } +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_GetMenuItemPropertyAttributes(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuItemIndex item; + OSType propertyCreator; + OSType propertyTag; + UInt32 attributes; + if (!PyArg_ParseTuple(_args, "hO&O&", + &item, + PyMac_GetOSType, &propertyCreator, + PyMac_GetOSType, &propertyTag)) + return NULL; + _err = GetMenuItemPropertyAttributes(_self->ob_itself, + item, + propertyCreator, + propertyTag, + &attributes); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("l", + attributes); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuItemIndex item; + OSType propertyCreator; + OSType propertyTag; + UInt32 attributesToSet; + UInt32 attributesToClear; + if (!PyArg_ParseTuple(_args, "hO&O&ll", + &item, + PyMac_GetOSType, &propertyCreator, + PyMac_GetOSType, &propertyTag, + &attributesToSet, + &attributesToClear)) + return NULL; + _err = ChangeMenuItemPropertyAttributes(_self->ob_itself, + item, + propertyCreator, + propertyTag, + attributesToSet, + attributesToClear); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_GetMenuAttributes(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuAttributes outAttributes; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetMenuAttributes(_self->ob_itself, + &outAttributes); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("l", + outAttributes); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_ChangeMenuAttributes(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuAttributes setTheseAttributes; + MenuAttributes clearTheseAttributes; + if (!PyArg_ParseTuple(_args, "ll", + &setTheseAttributes, + &clearTheseAttributes)) + return NULL; + _err = ChangeMenuAttributes(_self->ob_itself, + setTheseAttributes, + clearTheseAttributes); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_GetMenuItemAttributes(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuItemIndex item; + MenuItemAttributes outAttributes; + if (!PyArg_ParseTuple(_args, "h", + &item)) + return NULL; + _err = GetMenuItemAttributes(_self->ob_itself, + item, + &outAttributes); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("l", + outAttributes); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_ChangeMenuItemAttributes(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuItemIndex item; + MenuItemAttributes setTheseAttributes; + MenuItemAttributes clearTheseAttributes; + if (!PyArg_ParseTuple(_args, "hll", + &item, + &setTheseAttributes, + &clearTheseAttributes)) + return NULL; + _err = ChangeMenuItemAttributes(_self->ob_itself, + item, + setTheseAttributes, + clearTheseAttributes); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_DisableAllMenuItems(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + DisableAllMenuItems(_self->ob_itself); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_EnableAllMenuItems(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + EnableAllMenuItems(_self->ob_itself); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_MenuHasEnabledItems(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Boolean _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = MenuHasEnabledItems(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_CountMenuItemsWithCommandID(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + ItemCount _rv; + MenuCommand commandID; + if (!PyArg_ParseTuple(_args, "l", + &commandID)) + return NULL; + _rv = CountMenuItemsWithCommandID(_self->ob_itself, + commandID); + _res = Py_BuildValue("l", + _rv); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_GetIndMenuItemWithCommandID(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuCommand commandID; + UInt32 itemIndex; + MenuHandle outMenu; + MenuItemIndex outIndex; + if (!PyArg_ParseTuple(_args, "ll", + &commandID, + &itemIndex)) + return NULL; + _err = GetIndMenuItemWithCommandID(_self->ob_itself, + commandID, + itemIndex, + &outMenu, + &outIndex); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&h", + MenuObj_New, outMenu, + outIndex); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_EnableMenuCommand(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + MenuCommand commandID; + if (!PyArg_ParseTuple(_args, "l", + &commandID)) + return NULL; + EnableMenuCommand(_self->ob_itself, + commandID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_DisableMenuCommand(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + MenuCommand commandID; + if (!PyArg_ParseTuple(_args, "l", + &commandID)) + return NULL; + DisableMenuCommand(_self->ob_itself, + commandID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_IsMenuCommandEnabled(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Boolean _rv; + MenuCommand commandID; + if (!PyArg_ParseTuple(_args, "l", + &commandID)) + return NULL; + _rv = IsMenuCommandEnabled(_self->ob_itself, + commandID); + _res = Py_BuildValue("b", + _rv); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_GetMenuCommandPropertySize(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuCommand commandID; + OSType propertyCreator; + OSType propertyTag; + ByteCount size; + if (!PyArg_ParseTuple(_args, "lO&O&", + &commandID, + PyMac_GetOSType, &propertyCreator, + PyMac_GetOSType, &propertyTag)) + return NULL; + _err = GetMenuCommandPropertySize(_self->ob_itself, + commandID, + propertyCreator, + propertyTag, + &size); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("l", + size); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_RemoveMenuCommandProperty(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuCommand commandID; + OSType propertyCreator; + OSType propertyTag; + if (!PyArg_ParseTuple(_args, "lO&O&", + &commandID, + PyMac_GetOSType, &propertyCreator, + PyMac_GetOSType, &propertyTag)) + return NULL; + _err = RemoveMenuCommandProperty(_self->ob_itself, + commandID, + propertyCreator, + propertyTag); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_CreateStandardFontMenu(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuItemIndex afterItem; + MenuID firstHierMenuID; + OptionBits options; + ItemCount outHierMenuCount; + if (!PyArg_ParseTuple(_args, "hhl", + &afterItem, + &firstHierMenuID, + &options)) + return NULL; + _err = CreateStandardFontMenu(_self->ob_itself, + afterItem, + firstHierMenuID, + options, + &outHierMenuCount); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("l", + outHierMenuCount); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_UpdateStandardFontMenu(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + ItemCount outHierMenuCount; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = UpdateStandardFontMenu(_self->ob_itself, + &outHierMenuCount); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("l", + outHierMenuCount); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *MenuObj_GetFontFamilyFromMenuSelection(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuItemIndex item; + FMFontFamily outFontFamily; + FMFontStyle outStyle; + if (!PyArg_ParseTuple(_args, "h", + &item)) + return NULL; + _err = GetFontFamilyFromMenuSelection(_self->ob_itself, + item, + &outFontFamily, + &outStyle); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("hh", + outFontFamily, + outStyle); + return _res; +} +#endif + +static PyObject *MenuObj_GetMenuID(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + MenuID _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetMenuID(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); + return _res; +} + +static PyObject *MenuObj_GetMenuWidth(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + SInt16 _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetMenuWidth(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); + return _res; +} + +static PyObject *MenuObj_GetMenuHeight(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + SInt16 _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetMenuHeight(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); + return _res; +} + +static PyObject *MenuObj_SetMenuID(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + MenuID menuID; + if (!PyArg_ParseTuple(_args, "h", + &menuID)) + return NULL; + SetMenuID(_self->ob_itself, + menuID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *MenuObj_SetMenuWidth(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + SInt16 width; + if (!PyArg_ParseTuple(_args, "h", + &width)) + return NULL; + SetMenuWidth(_self->ob_itself, + width); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *MenuObj_SetMenuHeight(_self, _args) + MenuObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + SInt16 height; + if (!PyArg_ParseTuple(_args, "h", + &height)) + return NULL; + SetMenuHeight(_self->ob_itself, + height); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + static PyObject *MenuObj_as_Resource(_self, _args) MenuObject *_self; PyObject *_args; @@ -1171,6 +1747,8 @@ static PyMethodDef MenuObj_methods[] = { "() -> None"}, {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1, "() -> None"}, + {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1, + "() -> (short _rv)"}, #if !TARGET_API_MAC_CARBON {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1, @@ -1201,11 +1779,13 @@ static PyMethodDef MenuObj_methods[] = { {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1, "(Str255 inString) -> None"}, {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1, - "(Str255 inString, UInt16 afterItem) -> None"}, + "(Str255 inString, MenuItemIndex afterItem) -> None"}, {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1, "(short top, short left, short popUpItem) -> (long _rv)"}, {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1, - "(short beforeID) -> None"}, + "(MenuID beforeID) -> None"}, + {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1, + "(short item, Boolean checked) -> None"}, #if !TARGET_API_MAC_CARBON {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1, @@ -1242,9 +1822,9 @@ static PyMethodDef MenuObj_methods[] = { "(short item) -> None"}, #endif {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1, - "(SInt16 inItem, UInt32 inCommandID) -> None"}, + "(SInt16 inItem, MenuCommand inCommandID) -> None"}, {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1, - "(SInt16 inItem) -> (UInt32 outCommandID)"}, + "(SInt16 inItem) -> (MenuCommand outCommandID)"}, {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1, "(SInt16 inItem, UInt8 inModifiers) -> None"}, {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1, @@ -1258,9 +1838,9 @@ static PyMethodDef MenuObj_methods[] = { {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1, "(SInt16 inItem) -> (TextEncoding outScriptID)"}, {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1, - "(SInt16 inItem, SInt16 inHierID) -> None"}, + "(SInt16 inItem, MenuID inHierID) -> None"}, {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1, - "(SInt16 inItem) -> (SInt16 outHierID)"}, + "(SInt16 inItem) -> (MenuID outHierID)"}, {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1, "(SInt16 inItem, SInt16 inFontID) -> None"}, {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1, @@ -1284,17 +1864,124 @@ static PyMethodDef MenuObj_methods[] = { {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1, "(SInt16 inItem) -> (SInt16 outGlyph)"}, {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1, - "(UInt16 item) -> None"}, + "(MenuItemIndex item) -> None"}, {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1, - "(UInt16 item) -> None"}, + "(MenuItemIndex item) -> None"}, {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1, - "(UInt16 item) -> (Boolean _rv)"}, + "(MenuItemIndex item) -> (Boolean _rv)"}, {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1, - "(UInt16 item) -> None"}, + "(MenuItemIndex item) -> None"}, {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1, - "(UInt16 item) -> None"}, + "(MenuItemIndex item) -> None"}, {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1, - "(UInt16 item) -> (Boolean _rv)"}, + "(MenuItemIndex item) -> (Boolean _rv)"}, + +#if TARGET_API_MAC_CARBON + {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1, + "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1, + "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1, + "() -> (MenuAttributes outAttributes)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1, + "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1, + "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1, + "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1, + "() -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1, + "() -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1, + "() -> (Boolean _rv)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1, + "(MenuCommand commandID) -> (ItemCount _rv)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1, + "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1, + "(MenuCommand commandID) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1, + "(MenuCommand commandID) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1, + "(MenuCommand commandID) -> (Boolean _rv)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1, + "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1, + "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"}, +#endif + +#if TARGET_API_MAC_CARBON + {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1, + "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1, + "() -> (ItemCount outHierMenuCount)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1, + "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"}, +#endif + {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1, + "() -> (MenuID _rv)"}, + {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1, + "() -> (SInt16 _rv)"}, + {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1, + "() -> (SInt16 _rv)"}, + {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1, + "(MenuID menuID) -> None"}, + {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1, + "(SInt16 width) -> None"}, + {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1, + "(SInt16 height) -> None"}, {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1, "() -> (Handle _rv)"}, {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1, @@ -1385,7 +2072,7 @@ static PyObject *Menu_NewMenu(_self, _args) { PyObject *_res = NULL; MenuHandle _rv; - short menuID; + MenuID menuID; Str255 menuTitle; if (!PyArg_ParseTuple(_args, "hO&", &menuID, @@ -1414,6 +2101,31 @@ static PyObject *Menu_MacGetMenu(_self, _args) return _res; } +#if TARGET_API_MAC_CARBON + +static PyObject *Menu_CreateNewMenu(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuID menuID; + MenuAttributes menuAttributes; + MenuHandle outMenuRef; + if (!PyArg_ParseTuple(_args, "hl", + &menuID, + &menuAttributes)) + return NULL; + _err = CreateNewMenu(menuID, + menuAttributes, + &outMenuRef); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + MenuObj_New, outMenuRef); + return _res; +} +#endif + static PyObject *Menu_MenuKey(_self, _args) PyObject *_self; PyObject *_args; @@ -1521,7 +2233,7 @@ static PyObject *Menu_HiliteMenu(_self, _args) PyObject *_args; { PyObject *_res = NULL; - short menuID; + MenuID menuID; if (!PyArg_ParseTuple(_args, "h", &menuID)) return NULL; @@ -1536,7 +2248,7 @@ static PyObject *Menu_GetNewMBar(_self, _args) PyObject *_args; { PyObject *_res = NULL; - Handle _rv; + MenuBarHandle _rv; short menuBarID; if (!PyArg_ParseTuple(_args, "h", &menuBarID)) @@ -1552,7 +2264,7 @@ static PyObject *Menu_GetMenuBar(_self, _args) PyObject *_args; { PyObject *_res = NULL; - Handle _rv; + MenuBarHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetMenuBar(); @@ -1566,23 +2278,65 @@ static PyObject *Menu_SetMenuBar(_self, _args) PyObject *_args; { PyObject *_res = NULL; - Handle menuList; + MenuBarHandle mbar; if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &menuList)) + ResObj_Convert, &mbar)) return NULL; - SetMenuBar(menuList); + SetMenuBar(mbar); Py_INCREF(Py_None); _res = Py_None; return _res; } +#if TARGET_API_MAC_CARBON + +static PyObject *Menu_DuplicateMenuBar(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuBarHandle mbar; + MenuBarHandle outBar; + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &mbar)) + return NULL; + _err = DuplicateMenuBar(mbar, + &outBar); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + ResObj_New, outBar); + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *Menu_DisposeMenuBar(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSStatus _err; + MenuBarHandle mbar; + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &mbar)) + return NULL; + _err = DisposeMenuBar(mbar); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + static PyObject *Menu_GetMenuHandle(_self, _args) PyObject *_self; PyObject *_args; { PyObject *_res = NULL; MenuHandle _rv; - short menuID; + MenuID menuID; if (!PyArg_ParseTuple(_args, "h", &menuID)) return NULL; @@ -1597,7 +2351,7 @@ static PyObject *Menu_MacDeleteMenu(_self, _args) PyObject *_args; { PyObject *_res = NULL; - short menuID; + MenuID menuID; if (!PyArg_ParseTuple(_args, "h", &menuID)) return NULL; @@ -1620,6 +2374,21 @@ static PyObject *Menu_ClearMenuBar(_self, _args) return _res; } +static PyObject *Menu_SetMenuFlashCount(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + short count; + if (!PyArg_ParseTuple(_args, "h", + &count)) + return NULL; + SetMenuFlashCount(count); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + #if !TARGET_API_MAC_CARBON static PyObject *Menu_SetMenuFlash(_self, _args) @@ -1643,7 +2412,7 @@ static PyObject *Menu_FlashMenuBar(_self, _args) PyObject *_args; { PyObject *_res = NULL; - short menuID; + MenuID menuID; if (!PyArg_ParseTuple(_args, "h", &menuID)) return NULL; @@ -1735,7 +2504,7 @@ static PyObject *Menu_DeleteMCEntries(_self, _args) PyObject *_args; { PyObject *_res = NULL; - short menuID; + MenuID menuID; short menuItem; if (!PyArg_ParseTuple(_args, "hh", &menuID, @@ -1869,9 +2638,14 @@ static PyMethodDef Menu_methods[] = { "() -> None"}, #endif {"NewMenu", (PyCFunction)Menu_NewMenu, 1, - "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, + "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1, "(short resourceID) -> (MenuHandle _rv)"}, + +#if TARGET_API_MAC_CARBON + {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1, + "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"}, +#endif {"MenuKey", (PyCFunction)Menu_MenuKey, 1, "(CharParameter ch) -> (long _rv)"}, {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1, @@ -1887,26 +2661,38 @@ static PyMethodDef Menu_methods[] = { {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1, "() -> None"}, {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1, - "(short menuID) -> None"}, + "(MenuID menuID) -> None"}, {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1, - "(short menuBarID) -> (Handle _rv)"}, + "(short menuBarID) -> (MenuBarHandle _rv)"}, {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1, - "() -> (Handle _rv)"}, + "() -> (MenuBarHandle _rv)"}, {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1, - "(Handle menuList) -> None"}, + "(MenuBarHandle mbar) -> None"}, + +#if TARGET_API_MAC_CARBON + {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1, + "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"}, +#endif + +#if TARGET_API_MAC_CARBON + {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1, + "(MenuBarHandle mbar) -> None"}, +#endif {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1, - "(short menuID) -> (MenuHandle _rv)"}, + "(MenuID menuID) -> (MenuHandle _rv)"}, {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1, - "(short menuID) -> None"}, + "(MenuID menuID) -> None"}, {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1, "() -> None"}, + {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1, + "(short count) -> None"}, #if !TARGET_API_MAC_CARBON {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1, "(short count) -> None"}, #endif {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1, - "(short menuID) -> None"}, + "(MenuID menuID) -> None"}, #if !TARGET_API_MAC_CARBON {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1, @@ -1924,7 +2710,7 @@ static PyMethodDef Menu_methods[] = { {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1, "() -> None"}, {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1, - "(short menuID, short menuItem) -> None"}, + "(MenuID menuID, short menuItem) -> None"}, {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1, "() -> None"}, {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1, @@ -1961,7 +2747,7 @@ void initMenu() Menu_Error = PyMac_GetOSErrException(); if (Menu_Error == NULL || PyDict_SetItemString(d, "Error", Menu_Error) != 0) - Py_FatalError("can't initialize Menu.Error"); + return; Menu_Type.ob_type = &PyType_Type; Py_INCREF(&Menu_Type); if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0) diff --git a/Mac/Modules/menu/menuscan.py b/Mac/Modules/menu/menuscan.py index 965172a..c9b1b42 100644 --- a/Mac/Modules/menu/menuscan.py +++ b/Mac/Modules/menu/menuscan.py @@ -38,6 +38,10 @@ class MyScanner(Scanner): "GetMenuItemPropertySize", "SetMenuItemProperty", "RemoveMenuItemProperty", + "SetMenuCommandProperty", + "GetMenuCommandProperty", + "GetMenuTitle", # Funny arg/returnvalue + "SetMenuTitle", ] def makegreylist(self): @@ -55,6 +59,31 @@ class MyScanner(Scanner): 'SetMenuFlash', 'InitMenus', 'InitProcMenu', + ]), + ('#if TARGET_API_MAC_CARBON', [ + 'DisposeMenuBar', + 'DuplicateMenuBar', + 'CreateNewMenu', + 'GetFontFamilyFromMenuSelection', + 'UpdateStandardFontMenu', + 'CreateStandardFontMenu', + 'RemoveMenuCommandProperty', + 'GetMenuCommandPropertySize', + 'IsMenuCommandEnabled', + 'DisableMenuCommand', + 'EnableMenuCommand', + 'GetIndMenuItemWithCommandID', + 'CountMenuItemsWithCommandID', + 'MenuHasEnabledItems', + 'EnableAllMenuItems', + 'DisableAllMenuItems', + 'ChangeMenuItemAttributes', + 'GetMenuItemAttributes', + 'ChangeMenuAttributes', + 'GetMenuAttributes', + 'ChangeMenuItemPropertyAttributes', + 'GetMenuItemPropertyAttributes', + ])] def makeblacklisttypes(self): @@ -64,6 +93,9 @@ class MyScanner(Scanner): 'MCTablePtr', 'AEDesc_ptr', # For now: doable, but not easy 'ProcessSerialNumber', # ditto + "MenuDefSpecPtr", # Too difficult for now + "MenuDefSpec_ptr", # ditto + "MenuTrackingData", ] def makerepairinstructions(self): diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py index 1325e10..20b4f36 100644 --- a/Mac/Modules/menu/menusupport.py +++ b/Mac/Modules/menu/menusupport.py @@ -25,13 +25,30 @@ from macsupport import * MenuHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) MenuRef = MenuHandle Handle = OpaqueByValueType("Handle", "ResObj") - +MenuBarHandle = OpaqueByValueType("MenuBarHandle", "ResObj") +MenuID = Type("MenuID", "h") +MenuItemIndex = Type("MenuItemIndex", "h") +MenuCommand = Type("MenuCommand", "l") +MenuAttributes = Type("MenuAttributes", "l") +MenuItemAttributes = Type("MenuItemAttributes", "l") unsigned_char = Type('unsigned char', 'b') +FMFontFamily = Type("FMFontFamily", "h") +FMFontStyle = Type("FMFontStyle", "h") includestuff = includestuff + """ #include <Devices.h> /* Defines OpenDeskAcc in universal headers */ #include <%s>""" % MACHEADERFILE + """ +#if !ACCESSOR_CALLS_ARE_FUNCTIONS +#define GetMenuID(menu) ((*(menu))->menuID) +#define GetMenuWidth(menu) ((*(menu))->menuWidth) +#define GetMenuHeight(menu) ((*(menu))->menuHeight) + +#define SetMenuID(menu, id) ((*(menu))->menuID = (id)) +#define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width)) +#define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height)) +#endif + #define as_Menu(h) ((MenuHandle)h) #define as_Resource(h) ((Handle)h) """ |