Commit 73ce115a authored by Jack Jansen's avatar Jack Jansen

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.
parent 067d59ce
......@@ -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}
};
......
......@@ -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)
......@@ -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()
This diff is collapsed.
......@@ -3,7 +3,157 @@ f = Function(void, 'SetPort',
)
functions.append(f)
f = Function(void, 'OpenDeskAcc',
(Str255, 'name', InMode),
f = Function(CursHandle, 'GetCursor',
(short, 'cursorID', InMode),
)
functions.append(f)
f = Function(void, 'SetCursor',
(Cursor_ptr, 'crsr', InMode),
)
functions.append(f)
f = Function(void, 'ShowCursor',
)
functions.append(f)
f = Function(void, 'LineTo',
(short, 'h', InMode),
(short, 'v', InMode),
)
functions.append(f)
f = Function(void, 'SetRect',
(Rect, 'r', OutMode),
(short, 'left', InMode),
(short, 'top', InMode),
(short, 'right', InMode),
(short, 'bottom', InMode),
)
functions.append(f)
f = Function(void, 'OffsetRect',
(Rect, 'r', InOutMode),
(short, 'dh', InMode),
(short, 'dv', InMode),
)
functions.append(f)
f = Function(void, 'InsetRect',
(Rect, 'r', InOutMode),
(short, 'dh', InMode),
(short, 'dv', InMode),
)
functions.append(f)
f = Function(void, 'UnionRect',
(Rect_ptr, 'src1', InMode),
(Rect_ptr, 'src2', InMode),
(Rect, 'dstRect', OutMode),
)
functions.append(f)
f = Function(Boolean, 'EqualRect',
(Rect_ptr, 'rect1', InMode),
(Rect_ptr, 'rect2', InMode),
)
functions.append(f)
f = Function(void, 'FrameRect',
(Rect_ptr, 'r', InMode),
)
functions.append(f)
f = Function(void, 'InvertRect',
(Rect_ptr, 'r', InMode),
)
functions.append(f)
f = Function(void, 'FillRect',
(Rect_ptr, 'r', InMode),
(Pattern_ptr, 'pat', InMode),
)
functions.append(f)
f = Function(void, 'CopyRgn',
(RgnHandle, 'srcRgn', InMode),
(RgnHandle, 'dstRgn', InMode),
)
functions.append(f)
f = Function(void, 'SetRectRgn',
(RgnHandle, 'rgn', InMode),
(short, 'left', InMode),
(short, 'top', InMode),
(short, 'right', InMode),
(short, 'bottom', InMode),
)
functions.append(f)
f = Function(void, 'OffsetRgn',
(RgnHandle, 'rgn', InMode),
(short, 'dh', InMode),
(short, 'dv', InMode),
)
functions.append(f)
f = Function(void, 'UnionRgn',
(RgnHandle, 'srcRgnA', InMode),
(RgnHandle, 'srcRgnB', InMode),
(RgnHandle, 'dstRgn', InMode),
)
functions.append(f)
f = Function(void, 'XorRgn',
(RgnHandle, 'srcRgnA', InMode),
(RgnHandle, 'srcRgnB', InMode),
(RgnHandle, 'dstRgn', InMode),
)
functions.append(f)
f = Function(Boolean, 'EqualRgn',
(RgnHandle, 'rgnA', InMode),
(RgnHandle, 'rgnB', InMode),
)
functions.append(f)
f = Function(void, 'FrameRgn',
(RgnHandle, 'rgn', InMode),
)
functions.append(f)
f = Function(void, 'PaintRgn',
(RgnHandle, 'rgn', InMode),
)
functions.append(f)
f = Function(void, 'InvertRgn',
(RgnHandle, 'rgn', InMode),
)
functions.append(f)
f = Function(void, 'FillRgn',
(RgnHandle, 'rgn', InMode),
(Pattern_ptr, 'pat', InMode),
)
functions.append(f)
f = Function(Boolean, 'GetPixel',
(short, 'h', InMode),
(short, 'v', InMode),
)
functions.append(f)
f = Function(Boolean, 'PtInRect',
(Point, 'pt', InMode),
(Rect_ptr, 'r', InMode),
)
functions.append(f)
f = Function(void, 'DrawText',
(TextThingie, 'textBuf', InMode),
(short, 'firstByte', InMode),
(short, 'byteCount', InMode),
)
functions.append(f)
......@@ -434,6 +434,23 @@ static PyObject *ResObj_as_Menu(_self, _args)
}
static PyObject *ResObj_LoadResource(_self, _args)
ResourceObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
LoadResource(_self->ob_itself);
{
OSErr _err = ResError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyMethodDef ResObj_methods[] = {
{"HomeResFile", (PyCFunction)ResObj_HomeResFile, 1,
"() -> (short _rv)"},
......@@ -473,6 +490,8 @@ static PyMethodDef ResObj_methods[] = {
"Return this resource/handle as a Control"},
{"as_Menu", (PyCFunction)ResObj_as_Menu, 1,
"Return this resource/handle as a Menu"},
{"LoadResource", (PyCFunction)ResObj_LoadResource, 1,
"() -> None"},
{NULL, NULL, 0}
};
......
......@@ -39,3 +39,10 @@ def genresconverter(longname, shortname):
resmethods.append(genresconverter("Control", "Ctl"))
resmethods.append(genresconverter("Menu", "Menu"))
# The definition of this one is MacLoadResource, so we do it by hand...
f = ResMethod(void, 'LoadResource',
(Handle, 'theResource', InMode),
)
resmethods.append(f)
......@@ -967,6 +967,54 @@ static PyObject *WinObj_SetWindowUserState(_self, _args)
return _res;
}
static PyObject *WinObj_CloseWindow(_self, _args)
WindowObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
CloseWindow(_self->ob_itself);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *WinObj_MoveWindow(_self, _args)
WindowObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
short hGlobal;
short vGlobal;
Boolean front;
if (!PyArg_ParseTuple(_args, "hhb",
&hGlobal,
&vGlobal,
&front))
return NULL;
MoveWindow(_self->ob_itself,
hGlobal,
vGlobal,
front);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *WinObj_ShowWindow(_self, _args)
WindowObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
ShowWindow(_self->ob_itself);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyMethodDef WinObj_methods[] = {
{"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
"() -> None"},
......@@ -1080,6 +1128,12 @@ static PyMethodDef WinObj_methods[] = {
"(Rect r) -> None"},
{"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
"(Rect r) -> None"},
{"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
"() -> None"},
{"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
"(short hGlobal, short vGlobal, Boolean front) -> None"},
{"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
"() -> None"},
{NULL, NULL, 0}
};
......@@ -1448,6 +1502,25 @@ static PyObject *Win_WhichWindow(_self, _args)
}
static PyObject *Win_FindWindow(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
short _rv;
Point thePoint;
WindowPtr theWindow;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetPoint, &thePoint))
return NULL;
_rv = FindWindow(thePoint,
&theWindow);
_res = Py_BuildValue("hO&",
_rv,
WinObj_WhichWindow, theWindow);
return _res;
}
static PyMethodDef Win_methods[] = {
{"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
"(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
......@@ -1487,6 +1560,8 @@ static PyMethodDef Win_methods[] = {
"() -> (RgnHandle _rv)"},
{"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
"Resolve an integer WindowPtr address to a Window object"},
{"FindWindow", (PyCFunction)Win_FindWindow, 1,
"(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
{NULL, NULL, 0}
};
......
......@@ -96,3 +96,31 @@ f = Method(void, 'SetWindowUserState',
)
methods.append(f)
# These have Mac prefixed to their name in the 3.1 universal headers,
# so we add the old/real names by hand.
f = Method(void, 'CloseWindow',
(WindowPtr, 'theWindow', InMode),
)
methods.append(f)
f = Function(short, 'FindWindow',
(Point, 'thePoint', InMode),
(ExistingWindowPtr, 'theWindow', OutMode),
)
functions.append(f)
f = Method(void, 'MoveWindow',
(WindowPtr, 'theWindow', InMode),
(short, 'hGlobal', InMode),
(short, 'vGlobal', InMode),
(Boolean, 'front', InMode),
)
methods.append(f)
f = Method(void, 'ShowWindow',
(WindowPtr, 'theWindow', InMode),
)
methods.append(f)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment