]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added support for GrafPort object
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 15 Nov 1995 15:18:47 +0000 (15:18 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 15 Nov 1995 15:18:47 +0000 (15:18 +0000)
Mac/Modules/win/Winmodule.c
Mac/Modules/win/winedit.py
Mac/Modules/win/wingen.py
Mac/Modules/win/winscan.py
Mac/Modules/win/winsupport.py

index 61afed4f365ac575806e4547e8476995dcae07ea..286ef34b128c7f73510d841ff907ffa7a694e151 100644 (file)
@@ -19,6 +19,8 @@ extern int ResObj_Convert(PyObject *, Handle *);
 
 extern PyObject *WinObj_New(WindowPtr);
 extern int WinObj_Convert(PyObject *, WindowPtr *);
+extern PyTypeObject Window_Type;
+#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
 
 extern PyObject *DlgObj_New(DialogPtr);
 extern int DlgObj_Convert(PyObject *, DialogPtr *);
@@ -31,6 +33,9 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
 extern PyObject *CtlObj_New(ControlHandle);
 extern int CtlObj_Convert(PyObject *, ControlHandle *);
 
+extern PyObject *GrafObj_New(GrafPtr);
+extern int GrafObj_Convert(PyObject *, GrafPtr *);
+
 extern PyObject *WinObj_WhichWindow(WindowPtr);
 
 #include <Windows.h>
@@ -412,6 +417,38 @@ static PyObject *WinObj_DrawNew(_self, _args)
        return _res;
 }
 
+static PyObject *WinObj_PaintOne(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle clobberedRgn;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &clobberedRgn))
+               return NULL;
+       PaintOne(_self->ob_itself,
+                clobberedRgn);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *WinObj_PaintBehind(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle clobberedRgn;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &clobberedRgn))
+               return NULL;
+       PaintBehind(_self->ob_itself,
+                   clobberedRgn);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
 static PyObject *WinObj_CalcVis(_self, _args)
        WindowObject *_self;
        PyObject *_args;
@@ -425,6 +462,22 @@ static PyObject *WinObj_CalcVis(_self, _args)
        return _res;
 }
 
+static PyObject *WinObj_CalcVisBehind(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle clobberedRgn;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &clobberedRgn))
+               return NULL;
+       CalcVisBehind(_self->ob_itself,
+                     clobberedRgn);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
 static PyObject *WinObj_GrowWindow(_self, _args)
        WindowObject *_self;
        PyObject *_args;
@@ -531,6 +584,20 @@ static PyObject *WinObj_DragWindow(_self, _args)
        return _res;
 }
 
+static PyObject *WinObj_GetWindowPort(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       CGrafPtr _rv;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _rv = GetWindowPort(_self->ob_itself);
+       _res = Py_BuildValue("O&",
+                            GrafObj_New, _rv);
+       return _res;
+}
+
 static PyObject *WinObj_SetPortWindowPort(_self, _args)
        WindowObject *_self;
        PyObject *_args;
@@ -630,6 +697,54 @@ static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
        return _res;
 }
 
+static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle r;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &r))
+               return NULL;
+       GetWindowStructureRgn(_self->ob_itself,
+                             r);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *WinObj_GetWindowContentRgn(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle r;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &r))
+               return NULL;
+       GetWindowContentRgn(_self->ob_itself,
+                           r);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
+static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle r;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &r))
+               return NULL;
+       GetWindowUpdateRgn(_self->ob_itself,
+                          r);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
 static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
        WindowObject *_self;
        PyObject *_args;
@@ -763,8 +878,14 @@ static PyMethodDef WinObj_methods[] = {
         "() -> None"},
        {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
         "(Boolean update) -> None"},
+       {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
+        "(RgnHandle clobberedRgn) -> None"},
+       {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
+        "(RgnHandle clobberedRgn) -> None"},
        {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
         "() -> None"},
+       {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
+        "(RgnHandle clobberedRgn) -> None"},
        {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
         "(Point startPt, Rect bBox) -> (long _rv)"},
        {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
@@ -777,6 +898,8 @@ static PyMethodDef WinObj_methods[] = {
         "(Point thePt) -> (Boolean _rv)"},
        {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
         "(Point startPt, Rect boundsRect) -> None"},
+       {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
+        "() -> (CGrafPtr _rv)"},
        {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
         "() -> None"},
        {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
@@ -791,6 +914,12 @@ static PyMethodDef WinObj_methods[] = {
         "() -> (Boolean _rv)"},
        {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
         "() -> (Boolean _rv)"},
+       {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
+        "(RgnHandle r) -> None"},
+       {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
+        "(RgnHandle r) -> None"},
+       {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
+        "(RgnHandle r) -> None"},
        {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
         "() -> (short _rv)"},
        {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
@@ -833,6 +962,20 @@ PyTypeObject Window_Type = {
 /* --------------------- End object type Window --------------------- */
 
 
+static PyObject *Win_GetGrayRgn(_self, _args)
+       PyObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle _rv;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _rv = GetGrayRgn();
+       _res = Py_BuildValue("O&",
+                            ResObj_New, _rv);
+       return _res;
+}
+
 static PyObject *Win_InitWindows(_self, _args)
        PyObject *_self;
        PyObject *_args;
@@ -846,6 +989,20 @@ static PyObject *Win_InitWindows(_self, _args)
        return _res;
 }
 
+static PyObject *Win_GetWMgrPort(_self, _args)
+       PyObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       GrafPtr wPort;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       GetWMgrPort(&wPort);
+       _res = Py_BuildValue("O&",
+                            GrafObj_New, wPort);
+       return _res;
+}
+
 static PyObject *Win_NewWindow(_self, _args)
        PyObject *_self;
        PyObject *_args;
@@ -930,6 +1087,21 @@ static PyObject *Win_InvalRect(_self, _args)
        return _res;
 }
 
+static PyObject *Win_InvalRgn(_self, _args)
+       PyObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle badRgn;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &badRgn))
+               return NULL;
+       InvalRgn(badRgn);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
 static PyObject *Win_ValidRect(_self, _args)
        PyObject *_self;
        PyObject *_args;
@@ -945,6 +1117,21 @@ static PyObject *Win_ValidRect(_self, _args)
        return _res;
 }
 
+static PyObject *Win_ValidRgn(_self, _args)
+       PyObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       RgnHandle goodRgn;
+       if (!PyArg_ParseTuple(_args, "O&",
+                             ResObj_Convert, &goodRgn))
+               return NULL;
+       ValidRgn(goodRgn);
+       Py_INCREF(Py_None);
+       _res = Py_None;
+       return _res;
+}
+
 static PyObject *Win_CheckUpdate(_self, _args)
        PyObject *_self;
        PyObject *_args;
@@ -999,6 +1186,20 @@ static PyObject *Win_PinRect(_self, _args)
        return _res;
 }
 
+static PyObject *Win_GetCWMgrPort(_self, _args)
+       PyObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       CGrafPtr wMgrCPort;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       GetCWMgrPort(&wMgrCPort);
+       _res = Py_BuildValue("O&",
+                            GrafObj_New, wMgrCPort);
+       return _res;
+}
+
 static PyObject *Win_NewCWindow(_self, _args)
        PyObject *_self;
        PyObject *_args;
@@ -1069,8 +1270,12 @@ static PyObject *Win_WhichWindow(_self, _args)
 }
 
 static PyMethodDef Win_methods[] = {
+       {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
+        "() -> (RgnHandle _rv)"},
        {"InitWindows", (PyCFunction)Win_InitWindows, 1,
         "() -> None"},
+       {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
+        "() -> (GrafPtr wPort)"},
        {"NewWindow", (PyCFunction)Win_NewWindow, 1,
         "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
        {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
@@ -1079,14 +1284,20 @@ static PyMethodDef Win_methods[] = {
         "() -> (WindowPtr _rv)"},
        {"InvalRect", (PyCFunction)Win_InvalRect, 1,
         "(Rect badRect) -> None"},
+       {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
+        "(RgnHandle badRgn) -> None"},
        {"ValidRect", (PyCFunction)Win_ValidRect, 1,
         "(Rect goodRect) -> None"},
+       {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
+        "(RgnHandle goodRgn) -> None"},
        {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
         "() -> (Boolean _rv, EventRecord theEvent)"},
        {"FindWindow", (PyCFunction)Win_FindWindow, 1,
         "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
        {"PinRect", (PyCFunction)Win_PinRect, 1,
         "(Rect theRect, Point thePt) -> (long _rv)"},
+       {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
+        "() -> (CGrafPtr wMgrCPort)"},
        {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
         "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
        {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
index 08be8bd3576f8797db6660829b47b6cecf0c6075..a5812f13473b4ce2613cade1859afd011e9eae2d 100644 (file)
@@ -1,6 +1,11 @@
 # These are inline-routines/defines, so we do them "by hand"
 #
 
+f = Method(CGrafPtr, 'GetWindowPort',
+    (WindowRef, 'theWindow', InMode),
+)
+methods.append(f)
+
 f = Method(void, 'SetPortWindowPort',
     (WindowRef, 'theWindow', InMode),
 )
@@ -38,25 +43,23 @@ f = Method(Boolean, 'GetWindowZoomFlag',
 )
 methods.append(f)
 
-if 0:
-       # Regions are not implemented yet..
-       f = Method(void, 'GetWindowStructureRgn',
-               (WindowRef, 'theWindow', InMode),
-               (RgnHandle, 'r', InMode),
-       )
-       methods.append(f)
-       
-       f = Method(void, 'GetWindowContentRgn',
-               (WindowRef, 'theWindow', InMode),
-               (RgnHandle, 'r', InMode),
-       )
-       methods.append(f)
-       
-       f = Method(void, 'GetWindowUpdateRgn',
-               (WindowRef, 'theWindow', InMode),
-               (RgnHandle, 'r', InMode),
-       )
-       methods.append(f)
+f = Method(void, 'GetWindowStructureRgn',
+       (WindowRef, 'theWindow', InMode),
+       (RgnHandle, 'r', InMode),
+)
+methods.append(f)
+
+f = Method(void, 'GetWindowContentRgn',
+       (WindowRef, 'theWindow', InMode),
+       (RgnHandle, 'r', InMode),
+)
+methods.append(f)
+
+f = Method(void, 'GetWindowUpdateRgn',
+       (WindowRef, 'theWindow', InMode),
+       (RgnHandle, 'r', InMode),
+)
+methods.append(f)
 
 f = Method(short, 'GetWindowTitleWidth',
     (WindowRef, 'theWindow', InMode),
index 1d0a87591f57d81d52bc9276d6ea9b79e37fdf91..8841b1e5e525b59da1f1a1f8a2ee1bab07783210 100644 (file)
@@ -1,9 +1,18 @@
 # Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Windows.h'
 
+f = Function(RgnHandle, 'GetGrayRgn',
+)
+functions.append(f)
+
 f = Function(void, 'InitWindows',
 )
 functions.append(f)
 
+f = Function(void, 'GetWMgrPort',
+    (GrafPtr, 'wPort', OutMode),
+)
+functions.append(f)
+
 f = Function(WindowRef, 'NewWindow',
     (NullStorage, 'wStorage', InMode),
     (Rect_ptr, 'boundsRect', InMode),
@@ -104,11 +113,21 @@ f = Function(void, 'InvalRect',
 )
 functions.append(f)
 
+f = Function(void, 'InvalRgn',
+    (RgnHandle, 'badRgn', InMode),
+)
+functions.append(f)
+
 f = Function(void, 'ValidRect',
     (Rect_ptr, 'goodRect', InMode),
 )
 functions.append(f)
 
+f = Function(void, 'ValidRgn',
+    (RgnHandle, 'goodRgn', InMode),
+)
+functions.append(f)
+
 f = Method(void, 'BeginUpdate',
     (WindowRef, 'theWindow', InMode),
 )
@@ -162,11 +181,29 @@ f = Method(void, 'DrawNew',
 )
 methods.append(f)
 
+f = Method(void, 'PaintOne',
+    (WindowRef, 'window', InMode),
+    (RgnHandle, 'clobberedRgn', InMode),
+)
+methods.append(f)
+
+f = Method(void, 'PaintBehind',
+    (WindowRef, 'startWindow', InMode),
+    (RgnHandle, 'clobberedRgn', InMode),
+)
+methods.append(f)
+
 f = Method(void, 'CalcVis',
     (WindowRef, 'window', InMode),
 )
 methods.append(f)
 
+f = Method(void, 'CalcVisBehind',
+    (WindowRef, 'startWindow', InMode),
+    (RgnHandle, 'clobberedRgn', InMode),
+)
+methods.append(f)
+
 f = Method(long, 'GrowWindow',
     (WindowRef, 'theWindow', InMode),
     (Point, 'startPt', InMode),
@@ -193,6 +230,11 @@ f = Method(Boolean, 'TrackBox',
 )
 methods.append(f)
 
+f = Function(void, 'GetCWMgrPort',
+    (CGrafPtr, 'wMgrCPort', OutMode),
+)
+functions.append(f)
+
 f = Function(WindowRef, 'NewCWindow',
     (NullStorage, 'wStorage', InMode),
     (Rect_ptr, 'boundsRect', InMode),
index dd3319be550bc609882ad8da2092914fd36d95cc..20771b0efef5b4d7d78f336c416bde4e36e1b074 100644 (file)
@@ -36,13 +36,10 @@ class MyScanner(Scanner):
        def makeblacklisttypes(self):
                return [
                        'ProcPtr',
-                       'GrafPtr',
-                       'CGrafPtr',
-                       'RgnHandle',
-##                     'PicHandle',
                        'WCTabHandle',
                        'AuxWinHandle',
                        'PixPatHandle',
+                       'DragGrayRgnUPP',
                        ]
 
        def makerepairinstructions(self):
index 39d4b7a900d052dea72101fec3a66ba103d8ad49..9aed179a80a633a85d4d11429b4d4cd043f56f76 100644 (file)
@@ -29,9 +29,10 @@ WindowPtr = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX)
 WindowRef = WindowPtr
 WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX)
 WindowPeek.passInput = lambda name: "(WindowPeek)(%s)" % name
-CGrafPtr = WindowPtr
+CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
+GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj")
 
-#RgnHandle = OpaqueByValueType("RgnHandle", "RgnObj")
+RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
 PicHandle = OpaqueByValueType("PicHandle", "ResObj")
 
 includestuff = includestuff + """
@@ -83,7 +84,6 @@ class MyObjectDefinition(GlobalObjectDefinition):
                """)
        def outputFreeIt(self, itselfname):
                Output("DisposeWindow(%s);", itselfname)
-
 # From here on it's basically all boiler plate...
 
 # Create the generator groups and link them