From e180d99280a7b7615d445a52efd63314f330e74b Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 24 Apr 1998 10:28:20 +0000 Subject: 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. --- Mac/Modules/menu/Menumodule.c | 107 +++++++++ Mac/Modules/menu/menuedit.py | 36 +++ Mac/Modules/menu/menuscan.py | 3 + Mac/Modules/qd/Qdmodule.c | 535 +++++++++++++++++++++++++++++++++++++++++- Mac/Modules/qd/qdedit.py | 154 +++++++++++- Mac/Modules/res/Resmodule.c | 19 ++ Mac/Modules/res/resedit.py | 7 + Mac/Modules/win/Winmodule.c | 75 ++++++ Mac/Modules/win/winedit.py | 28 +++ 9 files changed, 956 insertions(+), 8 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() diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c index 9c73bc8..97a2789 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -3848,21 +3848,496 @@ static PyObject *Qd_SetPort(_self, _args) return _res; } -static PyObject *Qd_OpenDeskAcc(_self, _args) +static PyObject *Qd_GetCursor(_self, _args) PyObject *_self; PyObject *_args; { PyObject *_res = NULL; - Str255 name; + CursHandle _rv; + short cursorID; + if (!PyArg_ParseTuple(_args, "h", + &cursorID)) + return NULL; + _rv = GetCursor(cursorID); + _res = Py_BuildValue("O&", + ResObj_New, _rv); + return _res; +} + +static PyObject *Qd_SetCursor(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Cursor *crsr__in__; + int crsr__in_len__; + if (!PyArg_ParseTuple(_args, "s#", + (char **)&crsr__in__, &crsr__in_len__)) + return NULL; + if (crsr__in_len__ != sizeof(Cursor)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); + goto crsr__error__; + } + SetCursor(crsr__in__); + Py_INCREF(Py_None); + _res = Py_None; + crsr__error__: ; + return _res; +} + +static PyObject *Qd_ShowCursor(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + ShowCursor(); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_LineTo(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + short h; + short v; + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) + return NULL; + LineTo(h, + v); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_SetRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect r; + short left; + short top; + short right; + short bottom; + if (!PyArg_ParseTuple(_args, "hhhh", + &left, + &top, + &right, + &bottom)) + return NULL; + SetRect(&r, + left, + top, + right, + bottom); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &r); + return _res; +} + +static PyObject *Qd_OffsetRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect r; + short dh; + short dv; + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &dh, + &dv)) + return NULL; + OffsetRect(&r, + dh, + dv); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &r); + return _res; +} + +static PyObject *Qd_InsetRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect r; + short dh; + short dv; + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &dh, + &dv)) + return NULL; + InsetRect(&r, + dh, + dv); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &r); + return _res; +} + +static PyObject *Qd_UnionRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect src1; + Rect src2; + Rect dstRect; + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &src1, + PyMac_GetRect, &src2)) + return NULL; + UnionRect(&src1, + &src2, + &dstRect); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &dstRect); + return _res; +} + +static PyObject *Qd_EqualRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Boolean _rv; + Rect rect1; + Rect rect2; + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &rect1, + PyMac_GetRect, &rect2)) + return NULL; + _rv = EqualRect(&rect1, + &rect2); + _res = Py_BuildValue("b", + _rv); + return _res; +} + +static PyObject *Qd_FrameRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect r; + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &r)) + return NULL; + FrameRect(&r); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_InvertRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect r; + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &r)) + return NULL; + InvertRect(&r); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_FillRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Rect r; + Pattern *pat__in__; + int pat__in_len__; + if (!PyArg_ParseTuple(_args, "O&s#", + PyMac_GetRect, &r, + (char **)&pat__in__, &pat__in_len__)) + return NULL; + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + FillRect(&r, + pat__in__); + Py_INCREF(Py_None); + _res = Py_None; + pat__error__: ; + return _res; +} + +static PyObject *Qd_CopyRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle srcRgn; + RgnHandle dstRgn; + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &srcRgn, + ResObj_Convert, &dstRgn)) + return NULL; + CopyRgn(srcRgn, + dstRgn); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_SetRectRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle rgn; + short left; + short top; + short right; + short bottom; + if (!PyArg_ParseTuple(_args, "O&hhhh", + ResObj_Convert, &rgn, + &left, + &top, + &right, + &bottom)) + return NULL; + SetRectRgn(rgn, + left, + top, + right, + bottom); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_OffsetRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle rgn; + short dh; + short dv; + if (!PyArg_ParseTuple(_args, "O&hh", + ResObj_Convert, &rgn, + &dh, + &dv)) + return NULL; + OffsetRgn(rgn, + dh, + dv); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_UnionRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle srcRgnA; + RgnHandle srcRgnB; + RgnHandle dstRgn; + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &srcRgnA, + ResObj_Convert, &srcRgnB, + ResObj_Convert, &dstRgn)) + return NULL; + UnionRgn(srcRgnA, + srcRgnB, + dstRgn); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_XorRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle srcRgnA; + RgnHandle srcRgnB; + RgnHandle dstRgn; + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &srcRgnA, + ResObj_Convert, &srcRgnB, + ResObj_Convert, &dstRgn)) + return NULL; + XorRgn(srcRgnA, + srcRgnB, + dstRgn); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_EqualRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Boolean _rv; + RgnHandle rgnA; + RgnHandle rgnB; + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &rgnA, + ResObj_Convert, &rgnB)) + return NULL; + _rv = EqualRgn(rgnA, + rgnB); + _res = Py_BuildValue("b", + _rv); + return _res; +} + +static PyObject *Qd_FrameRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetStr255, name)) + ResObj_Convert, &rgn)) return NULL; - OpenDeskAcc(name); + FrameRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } +static PyObject *Qd_PaintRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle rgn; + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) + return NULL; + PaintRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_InvertRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle rgn; + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) + return NULL; + InvertRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_FillRgn(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + RgnHandle rgn; + Pattern *pat__in__; + int pat__in_len__; + if (!PyArg_ParseTuple(_args, "O&s#", + ResObj_Convert, &rgn, + (char **)&pat__in__, &pat__in_len__)) + return NULL; + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + FillRgn(rgn, + pat__in__); + Py_INCREF(Py_None); + _res = Py_None; + pat__error__: ; + return _res; +} + +static PyObject *Qd_GetPixel(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Boolean _rv; + short h; + short v; + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) + return NULL; + _rv = GetPixel(h, + v); + _res = Py_BuildValue("b", + _rv); + return _res; +} + +static PyObject *Qd_PtInRect(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + Boolean _rv; + Point pt; + Rect r; + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &pt, + PyMac_GetRect, &r)) + return NULL; + _rv = PtInRect(pt, + &r); + _res = Py_BuildValue("b", + _rv); + return _res; +} + +static PyObject *Qd_DrawText(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + char *textBuf__in__; + int textBuf__len__; + int textBuf__in_len__; + short firstByte; + short byteCount; + if (!PyArg_ParseTuple(_args, "s#hh", + &textBuf__in__, &textBuf__in_len__, + &firstByte, + &byteCount)) + return NULL; + DrawText(textBuf__in__, + firstByte, + byteCount); + Py_INCREF(Py_None); + _res = Py_None; + textBuf__error__: ; + return _res; +} + static PyObject *Qd_BitMap(_self, _args) PyObject *_self; PyObject *_args; @@ -4309,8 +4784,56 @@ static PyMethodDef Qd_methods[] = { "(Fixed extra) -> None"}, {"SetPort", (PyCFunction)Qd_SetPort, 1, "(WindowPtr thePort) -> None"}, - {"OpenDeskAcc", (PyCFunction)Qd_OpenDeskAcc, 1, - "(Str255 name) -> None"}, + {"GetCursor", (PyCFunction)Qd_GetCursor, 1, + "(short cursorID) -> (CursHandle _rv)"}, + {"SetCursor", (PyCFunction)Qd_SetCursor, 1, + "(Cursor crsr) -> None"}, + {"ShowCursor", (PyCFunction)Qd_ShowCursor, 1, + "() -> None"}, + {"LineTo", (PyCFunction)Qd_LineTo, 1, + "(short h, short v) -> None"}, + {"SetRect", (PyCFunction)Qd_SetRect, 1, + "(short left, short top, short right, short bottom) -> (Rect r)"}, + {"OffsetRect", (PyCFunction)Qd_OffsetRect, 1, + "(Rect r, short dh, short dv) -> (Rect r)"}, + {"InsetRect", (PyCFunction)Qd_InsetRect, 1, + "(Rect r, short dh, short dv) -> (Rect r)"}, + {"UnionRect", (PyCFunction)Qd_UnionRect, 1, + "(Rect src1, Rect src2) -> (Rect dstRect)"}, + {"EqualRect", (PyCFunction)Qd_EqualRect, 1, + "(Rect rect1, Rect rect2) -> (Boolean _rv)"}, + {"FrameRect", (PyCFunction)Qd_FrameRect, 1, + "(Rect r) -> None"}, + {"InvertRect", (PyCFunction)Qd_InvertRect, 1, + "(Rect r) -> None"}, + {"FillRect", (PyCFunction)Qd_FillRect, 1, + "(Rect r, Pattern pat) -> None"}, + {"CopyRgn", (PyCFunction)Qd_CopyRgn, 1, + "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"}, + {"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1, + "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"}, + {"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1, + "(RgnHandle rgn, short dh, short dv) -> None"}, + {"UnionRgn", (PyCFunction)Qd_UnionRgn, 1, + "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, + {"XorRgn", (PyCFunction)Qd_XorRgn, 1, + "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, + {"EqualRgn", (PyCFunction)Qd_EqualRgn, 1, + "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"}, + {"FrameRgn", (PyCFunction)Qd_FrameRgn, 1, + "(RgnHandle rgn) -> None"}, + {"PaintRgn", (PyCFunction)Qd_PaintRgn, 1, + "(RgnHandle rgn) -> None"}, + {"InvertRgn", (PyCFunction)Qd_InvertRgn, 1, + "(RgnHandle rgn) -> None"}, + {"FillRgn", (PyCFunction)Qd_FillRgn, 1, + "(RgnHandle rgn, Pattern pat) -> None"}, + {"GetPixel", (PyCFunction)Qd_GetPixel, 1, + "(short h, short v) -> (Boolean _rv)"}, + {"PtInRect", (PyCFunction)Qd_PtInRect, 1, + "(Point pt, Rect r) -> (Boolean _rv)"}, + {"DrawText", (PyCFunction)Qd_DrawText, 1, + "(Buffer textBuf, short firstByte, short byteCount) -> None"}, {"BitMap", (PyCFunction)Qd_BitMap, 1, "Take (string, int, Rect) argument and create BitMap"}, {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1, diff --git a/Mac/Modules/qd/qdedit.py b/Mac/Modules/qd/qdedit.py index 3139168..ea4d828 100644 --- a/Mac/Modules/qd/qdedit.py +++ b/Mac/Modules/qd/qdedit.py @@ -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) + diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c index 45e16a6..6eeb3b8 100644 --- a/Mac/Modules/res/Resmodule.c +++ b/Mac/Modules/res/Resmodule.c @@ -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} }; diff --git a/Mac/Modules/res/resedit.py b/Mac/Modules/res/resedit.py index bffec5f..42966e4 100644 --- a/Mac/Modules/res/resedit.py +++ b/Mac/Modules/res/resedit.py @@ -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) diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c index f57928e..58da8fd 100644 --- a/Mac/Modules/win/Winmodule.c +++ b/Mac/Modules/win/Winmodule.c @@ -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} }; diff --git a/Mac/Modules/win/winedit.py b/Mac/Modules/win/winedit.py index a5812f1..b7c2a97 100644 --- a/Mac/Modules/win/winedit.py +++ b/Mac/Modules/win/winedit.py @@ -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) + + + -- cgit v0.12