mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
Added Ctl.as_Control and Menu.as_Menu methods, which take a resource as
argument and return a Control or Menu object.
This commit is contained in:
parent
b0687899d7
commit
e058189040
6 changed files with 52 additions and 0 deletions
|
@ -44,6 +44,8 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||||
|
|
||||||
#include <Controls.h>
|
#include <Controls.h>
|
||||||
|
|
||||||
|
#define as_Control(h) ((ControlHandle)h)
|
||||||
|
|
||||||
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
||||||
|
|
||||||
extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */
|
extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */
|
||||||
|
@ -1333,6 +1335,22 @@ static PyObject *Ctl_ClearKeyboardFocus(_self, _args)
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *Ctl_as_Control(_self, _args)
|
||||||
|
PyObject *_self;
|
||||||
|
PyObject *_args;
|
||||||
|
{
|
||||||
|
PyObject *_res = NULL;
|
||||||
|
ControlHandle _rv;
|
||||||
|
Handle h;
|
||||||
|
if (!PyArg_ParseTuple(_args, "O&",
|
||||||
|
ResObj_Convert, &h))
|
||||||
|
return NULL;
|
||||||
|
_rv = as_Control(h);
|
||||||
|
_res = Py_BuildValue("O&",
|
||||||
|
CtlObj_New, _rv);
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
|
||||||
static PyMethodDef Ctl_methods[] = {
|
static PyMethodDef Ctl_methods[] = {
|
||||||
{"NewControl", (PyCFunction)Ctl_NewControl, 1,
|
{"NewControl", (PyCFunction)Ctl_NewControl, 1,
|
||||||
"(WindowPtr owningWindow, Rect boundsRect, Str255 controlTitle, Boolean initiallyVisible, SInt16 initialValue, SInt16 minimumValue, SInt16 maximumValue, SInt16 procID, SInt32 controlReference) -> (ControlHandle _rv)"},
|
"(WindowPtr owningWindow, Rect boundsRect, Str255 controlTitle, Boolean initiallyVisible, SInt16 initialValue, SInt16 minimumValue, SInt16 maximumValue, SInt16 procID, SInt32 controlReference) -> (ControlHandle _rv)"},
|
||||||
|
@ -1364,6 +1382,8 @@ static PyMethodDef Ctl_methods[] = {
|
||||||
"(WindowPtr inWindow) -> None"},
|
"(WindowPtr inWindow) -> None"},
|
||||||
{"ClearKeyboardFocus", (PyCFunction)Ctl_ClearKeyboardFocus, 1,
|
{"ClearKeyboardFocus", (PyCFunction)Ctl_ClearKeyboardFocus, 1,
|
||||||
"(WindowPtr inWindow) -> None"},
|
"(WindowPtr inWindow) -> None"},
|
||||||
|
{"as_Control", (PyCFunction)Ctl_as_Control, 1,
|
||||||
|
"(Handle h) -> (ControlHandle _rv)"},
|
||||||
{NULL, NULL, 0}
|
{NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
f = Function(ControlHandle, 'as_Control',
|
||||||
|
(Handle, 'h', InMode))
|
||||||
|
functions.append(f)
|
||||||
|
|
||||||
as_resource_body = """
|
as_resource_body = """
|
||||||
return ResObj_New((Handle)_self->ob_itself);
|
return ResObj_New((Handle)_self->ob_itself);
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -44,6 +44,8 @@ ControlFontStyleRec_ptr = ControlFontStyleRec
|
||||||
includestuff = includestuff + """
|
includestuff = includestuff + """
|
||||||
#include <%s>""" % MACHEADERFILE + """
|
#include <%s>""" % MACHEADERFILE + """
|
||||||
|
|
||||||
|
#define as_Control(h) ((ControlHandle)h)
|
||||||
|
|
||||||
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
||||||
|
|
||||||
extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */
|
extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */
|
||||||
|
|
|
@ -47,6 +47,8 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||||
|
|
||||||
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
||||||
|
|
||||||
|
#define as_Menu(h) ((MenuHandle)h)
|
||||||
|
|
||||||
static PyObject *Menu_Error;
|
static PyObject *Menu_Error;
|
||||||
|
|
||||||
/* ------------------------ Object type Menu ------------------------ */
|
/* ------------------------ Object type Menu ------------------------ */
|
||||||
|
@ -1455,6 +1457,22 @@ static PyObject *Menu_OpenDeskAcc(_self, _args)
|
||||||
return _res;
|
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)
|
static PyObject *Menu_GetMenu(_self, _args)
|
||||||
PyObject *_self;
|
PyObject *_self;
|
||||||
PyObject *_args;
|
PyObject *_args;
|
||||||
|
@ -1548,6 +1566,8 @@ static PyMethodDef Menu_methods[] = {
|
||||||
"(EventRecord inEvent) -> (UInt32 _rv)"},
|
"(EventRecord inEvent) -> (UInt32 _rv)"},
|
||||||
{"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
|
{"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
|
||||||
"(Str255 name) -> None"},
|
"(Str255 name) -> None"},
|
||||||
|
{"as_Menu", (PyCFunction)Menu_as_Menu, 1,
|
||||||
|
"(Handle h) -> (MenuHandle _rv)"},
|
||||||
{"GetMenu", (PyCFunction)Menu_GetMenu, 1,
|
{"GetMenu", (PyCFunction)Menu_GetMenu, 1,
|
||||||
"(short resourceID) -> (MenuHandle _rv)"},
|
"(short resourceID) -> (MenuHandle _rv)"},
|
||||||
{"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
|
{"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
|
||||||
|
|
|
@ -3,6 +3,10 @@ f = Function(void, 'OpenDeskAcc',
|
||||||
)
|
)
|
||||||
functions.append(f)
|
functions.append(f)
|
||||||
|
|
||||||
|
f = Function(MenuHandle, 'as_Menu',
|
||||||
|
(Handle, 'h', InMode))
|
||||||
|
functions.append(f)
|
||||||
|
|
||||||
as_resource_body = """
|
as_resource_body = """
|
||||||
return ResObj_New((Handle)_self->ob_itself);
|
return ResObj_New((Handle)_self->ob_itself);
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -32,6 +32,8 @@ includestuff = includestuff + """
|
||||||
#include <%s>""" % MACHEADERFILE + """
|
#include <%s>""" % MACHEADERFILE + """
|
||||||
|
|
||||||
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
||||||
|
|
||||||
|
#define as_Menu(h) ((MenuHandle)h)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class MyObjectDefinition(GlobalObjectDefinition):
|
class MyObjectDefinition(GlobalObjectDefinition):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue