summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/menu
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1998-04-24 10:28:20 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1998-04-24 10:28:20 (GMT)
commite180d99280a7b7615d445a52efd63314f330e74b (patch)
tree806d4c6302ec0e534ecbf50b830339571d34bc52 /Mac/Modules/menu
parent6a508aef7d024921b00a1c8fe635f19b0fa6a98f (diff)
downloadcpython-e180d99280a7b7615d445a52efd63314f330e74b.zip
cpython-e180d99280a7b7615d445a52efd63314f330e74b.tar.gz
cpython-e180d99280a7b7615d445a52efd63314f330e74b.tar.bz2
Grmpf, a lot more routines have gotten a "Mac" prefix for their
declaration, probably so the universal headers are useable on windows/unix too. Have to think of a more definite workaround later, for now we manually declare the old names in the *edit.py files.
Diffstat (limited to 'Mac/Modules/menu')
-rw-r--r--Mac/Modules/menu/Menumodule.c107
-rw-r--r--Mac/Modules/menu/menuedit.py36
-rw-r--r--Mac/Modules/menu/menuscan.py3
3 files changed, 146 insertions, 0 deletions
diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c
index 5797149a..3e16440 100644
--- a/Mac/Modules/menu/Menumodule.c
+++ b/Mac/Modules/menu/Menumodule.c
@@ -916,6 +916,57 @@ static PyObject *MenuObj_as_Resource(_self, _args)
}
+static PyObject *MenuObj_AppendMenu(_self, _args)
+ MenuObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ Str255 data;
+ if (!PyArg_ParseTuple(_args, "O&",
+ PyMac_GetStr255, data))
+ return NULL;
+ AppendMenu(_self->ob_itself,
+ data);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
+static PyObject *MenuObj_InsertMenu(_self, _args)
+ MenuObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ short beforeID;
+ if (!PyArg_ParseTuple(_args, "h",
+ &beforeID))
+ return NULL;
+ InsertMenu(_self->ob_itself,
+ beforeID);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
+static PyObject *MenuObj_InsertMenuItem(_self, _args)
+ MenuObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ Str255 itemString;
+ short afterItem;
+ if (!PyArg_ParseTuple(_args, "O&h",
+ PyMac_GetStr255, itemString,
+ &afterItem))
+ return NULL;
+ InsertMenuItem(_self->ob_itself,
+ itemString,
+ afterItem);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyMethodDef MenuObj_methods[] = {
{"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
"() -> None"},
@@ -1005,6 +1056,12 @@ static PyMethodDef MenuObj_methods[] = {
"(SInt16 inItem) -> (SInt16 outGlyph)"},
{"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
"Return this Menu as a Resource"},
+ {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
+ "(Str255 data) -> None"},
+ {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
+ "(short beforeID) -> None"},
+ {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
+ "(Str255 itemString, short afterItem) -> None"},
{NULL, NULL, 0}
};
@@ -1398,6 +1455,50 @@ static PyObject *Menu_OpenDeskAcc(_self, _args)
return _res;
}
+static PyObject *Menu_GetMenu(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ MenuHandle _rv;
+ short resourceID;
+ if (!PyArg_ParseTuple(_args, "h",
+ &resourceID))
+ return NULL;
+ _rv = GetMenu(resourceID);
+ _res = Py_BuildValue("O&",
+ MenuObj_New, _rv);
+ return _res;
+}
+
+static PyObject *Menu_DeleteMenu(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ short menuID;
+ if (!PyArg_ParseTuple(_args, "h",
+ &menuID))
+ return NULL;
+ DeleteMenu(menuID);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
+static PyObject *Menu_DrawMenuBar(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ DrawMenuBar();
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyMethodDef Menu_methods[] = {
{"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
"() -> (short _rv)"},
@@ -1447,6 +1548,12 @@ static PyMethodDef Menu_methods[] = {
"(EventRecord inEvent) -> (UInt32 _rv)"},
{"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
"(Str255 name) -> None"},
+ {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
+ "(short resourceID) -> (MenuHandle _rv)"},
+ {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
+ "(short menuID) -> None"},
+ {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
+ "() -> None"},
{NULL, NULL, 0}
};
diff --git a/Mac/Modules/menu/menuedit.py b/Mac/Modules/menu/menuedit.py
index 7d53cd5..37aace4 100644
--- a/Mac/Modules/menu/menuedit.py
+++ b/Mac/Modules/menu/menuedit.py
@@ -11,3 +11,39 @@ f = ManualGenerator("as_Resource", as_resource_body)
f.docstring = lambda : "Return this Menu as a Resource"
methods.append(f)
+
+# The following have "Mac" prepended to their names in the include file
+# since UH 3.1, sigh...
+f = Function(MenuHandle, 'GetMenu',
+ (short, 'resourceID', InMode),
+)
+functions.append(f)
+
+f = Method(void, 'AppendMenu',
+ (MenuHandle, 'menu', InMode),
+ (ConstStr255Param, 'data', InMode),
+)
+methods.append(f)
+
+f = Method(void, 'InsertMenu',
+ (MenuHandle, 'theMenu', InMode),
+ (short, 'beforeID', InMode),
+)
+methods.append(f)
+
+f = Function(void, 'DeleteMenu',
+ (short, 'menuID', InMode),
+)
+functions.append(f)
+
+f = Method(void, 'InsertMenuItem',
+ (MenuHandle, 'theMenu', InMode),
+ (ConstStr255Param, 'itemString', InMode),
+ (short, 'afterItem', InMode),
+)
+methods.append(f)
+
+f = Function(void, 'DrawMenuBar',
+)
+functions.append(f)
+
diff --git a/Mac/Modules/menu/menuscan.py b/Mac/Modules/menu/menuscan.py
index d5016be..b332657 100644
--- a/Mac/Modules/menu/menuscan.py
+++ b/Mac/Modules/menu/menuscan.py
@@ -58,5 +58,8 @@ class MyScanner(Scanner):
[("VarVarOutBuffer", "*", "InOutMode")]),
]
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+
if __name__ == "__main__":
main()