summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/menu
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1999-02-07 14:02:03 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1999-02-07 14:02:03 (GMT)
commite058189040dcaf951c34d66f99eeb7e4ee91af6a (patch)
tree673cb8b9538f0573222f3577597709bd442a84e5 /Mac/Modules/menu
parentb0687899d7a84c09f00bcf492e76eee3a44143b3 (diff)
downloadcpython-e058189040dcaf951c34d66f99eeb7e4ee91af6a.zip
cpython-e058189040dcaf951c34d66f99eeb7e4ee91af6a.tar.gz
cpython-e058189040dcaf951c34d66f99eeb7e4ee91af6a.tar.bz2
Added Ctl.as_Control and Menu.as_Menu methods, which take a resource as
argument and return a Control or Menu object.
Diffstat (limited to 'Mac/Modules/menu')
-rw-r--r--Mac/Modules/menu/Menumodule.c20
-rw-r--r--Mac/Modules/menu/menuedit.py4
-rw-r--r--Mac/Modules/menu/menusupport.py2
3 files changed, 26 insertions, 0 deletions
diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c
index 3e16440..42490ab 100644
--- a/Mac/Modules/menu/Menumodule.c
+++ b/Mac/Modules/menu/Menumodule.c
@@ -47,6 +47,8 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
+#define as_Menu(h) ((MenuHandle)h)
+
static PyObject *Menu_Error;
/* ------------------------ Object type Menu ------------------------ */
@@ -1455,6 +1457,22 @@ static PyObject *Menu_OpenDeskAcc(_self, _args)
return _res;
}
+static PyObject *Menu_as_Menu(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ MenuHandle _rv;
+ Handle h;
+ if (!PyArg_ParseTuple(_args, "O&",
+ ResObj_Convert, &h))
+ return NULL;
+ _rv = as_Menu(h);
+ _res = Py_BuildValue("O&",
+ MenuObj_New, _rv);
+ return _res;
+}
+
static PyObject *Menu_GetMenu(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -1548,6 +1566,8 @@ static PyMethodDef Menu_methods[] = {
"(EventRecord inEvent) -> (UInt32 _rv)"},
{"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
"(Str255 name) -> None"},
+ {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
+ "(Handle h) -> (MenuHandle _rv)"},
{"GetMenu", (PyCFunction)Menu_GetMenu, 1,
"(short resourceID) -> (MenuHandle _rv)"},
{"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
diff --git a/Mac/Modules/menu/menuedit.py b/Mac/Modules/menu/menuedit.py
index 37aace4..8e7d12b 100644
--- a/Mac/Modules/menu/menuedit.py
+++ b/Mac/Modules/menu/menuedit.py
@@ -3,6 +3,10 @@ f = Function(void, 'OpenDeskAcc',
)
functions.append(f)
+f = Function(MenuHandle, 'as_Menu',
+ (Handle, 'h', InMode))
+functions.append(f)
+
as_resource_body = """
return ResObj_New((Handle)_self->ob_itself);
"""
diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py
index cbd57bf..6424ed9 100644
--- a/Mac/Modules/menu/menusupport.py
+++ b/Mac/Modules/menu/menusupport.py
@@ -32,6 +32,8 @@ includestuff = includestuff + """
#include <%s>""" % MACHEADERFILE + """
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
+
+#define as_Menu(h) ((MenuHandle)h)
"""
class MyObjectDefinition(GlobalObjectDefinition):