]> granicus.if.org Git - python/commitdiff
Emulate a few more non-carbon calls in carbon and the other way around.
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 19 Dec 2000 22:23:06 +0000 (22:23 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 19 Dec 2000 22:23:06 +0000 (22:23 +0000)
Mac/Modules/win/Winmodule.c
Mac/Modules/win/winedit.py
Mac/Modules/win/winsupport.py

index 4dce0e8f2e47bff44b78637fbcc14031f3ed6b34..7984293c9305cf6742dacf49636e62fca98a17e9 100644 (file)
 #include <Windows.h>
 
 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
+/* Carbon calls that we emulate in classic mode */
 #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
 #define GetWindowFromPort(port) ((WindowRef)(port))
 #define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
 #endif
+#if ACCESSOR_CALLS_ARE_FUNCTIONS
+/* Classic calls that we emulate in carbon mode */
+#define GetWindowUpdateRgn(win, rgn) GetWindowRegion((win), kWindowUpdateRgn, (rgn))
+#define GetWindowStructureRgn(win, rgn) GetWindowRegion((win), kWindowStructureRgn, (rgn))
+#define GetWindowContentRgn(win, rgn) GetWindowRegion((win), kWindowContentRgn, (rgn))
+#endif
 
 /* Function to dispose a window, with a "normal" calling sequence */
 static void
@@ -1851,6 +1858,110 @@ static PyObject *WinObj_GetWindowPortBounds(_self, _args)
        return _res;
 }
 
+static PyObject *WinObj_IsWindowVisible(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       Boolean _rv;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _rv = IsWindowVisible(_self->ob_itself);
+       _res = Py_BuildValue("b",
+                            _rv);
+       return _res;
+}
+
+static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       Boolean _rv;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _rv = GetWindowZoomFlag(_self->ob_itself);
+       _res = Py_BuildValue("b",
+                            _rv);
+       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;
+{
+       PyObject *_res = NULL;
+       short _rv;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _rv = GetWindowTitleWidth(_self->ob_itself);
+       _res = Py_BuildValue("h",
+                            _rv);
+       return _res;
+}
+
+static PyObject *WinObj_GetNextWindow(_self, _args)
+       WindowObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+       WindowPtr _rv;
+       if (!PyArg_ParseTuple(_args, ""))
+               return NULL;
+       _rv = GetNextWindow(_self->ob_itself);
+       _res = Py_BuildValue("O&",
+                            WinObj_WhichWindow, _rv);
+       return _res;
+}
+
 #if !TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_CloseWindow(_self, _args)
@@ -2142,6 +2253,20 @@ static PyMethodDef WinObj_methods[] = {
         "() -> None"},
        {"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1,
         "() -> (Rect bounds)"},
+       {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
+        "() -> (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,
+        "() -> (WindowPtr _rv)"},
 
 #if !TARGET_API_MAC_CARBON
        {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
index 42fbcf8f72a29fb8f119a439a9e054fe5c136415..09fd3007611641b0d4b8f91fbf7c9de6fab06d6a 100644 (file)
 # These are inline-routines/defines, so we do them "by hand"
 #
-if 0:
-       f = Method(CGrafPtr, 'GetWindowPort',
-           (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
 
-       f = Method(void, 'SetPortWindowPort',
-           (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
-
-       f = Method(short, 'GetWindowKind',
-           (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
-
-       f = Method(void, 'SetWindowKind',
-           (WindowRef, 'theWindow', InMode),
-           (short, 'wKind', InMode),
-       )
-       methods.append(f)
-
-
-       f = Method(Boolean, 'IsWindowVisible',
-           (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
-
-       f = Method(Boolean, 'IsWindowHilited',
-           (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
-
-       f = Method(Boolean, 'GetWindowGoAwayFlag',
-           (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
-
-       f = Method(Boolean, 'GetWindowZoomFlag',
-           (WindowRef, 'theWindow', InMode),
-           condition='#if !TARGET_API_MAC_CARBON'
-       )
-       methods.append(f)
-
-       f = Method(void, 'GetWindowStructureRgn',
-               (WindowRef, 'theWindow', InMode),
-               (RgnHandle, 'r', InMode),
-           condition='#if !TARGET_API_MAC_CARBON'
-       )
-       methods.append(f)
-
-       f = Method(void, 'GetWindowContentRgn',
-               (WindowRef, 'theWindow', InMode),
-               (RgnHandle, 'r', InMode),
-           condition='#if !TARGET_API_MAC_CARBON'
-       )
-       methods.append(f)
-
-       f = Method(void, 'GetWindowUpdateRgn',
-               (WindowRef, 'theWindow', InMode),
-               (RgnHandle, 'r', InMode),
-           condition='#if !TARGET_API_MAC_CARBON'
-       )
-       methods.append(f)
-
-       f = Method(short, 'GetWindowTitleWidth',
-           (WindowRef, 'theWindow', InMode),
-           condition='#if !TARGET_API_MAC_CARBON'
-       )
-       methods.append(f)
+f = Method(Boolean, 'IsWindowVisible',
+    (WindowRef, 'theWindow', InMode),
+)
+methods.append(f)
 
-       f = Method(ExistingWindowPtr, 'GetNextWindow',
-               (WindowRef, 'theWindow', InMode),
-       )
-       methods.append(f)
+f = Method(Boolean, 'GetWindowZoomFlag',
+    (WindowRef, 'theWindow', InMode),
+)
+methods.append(f)
 
-       f = Method(void, 'GetWindowStandardState',
-               (WindowRef, 'theWindow', InMode),
-               (Rect, 'r', OutMode),
-       )
-       methods.append(f)
+f = Method(void, 'GetWindowStructureRgn',
+       (WindowRef, 'theWindow', InMode),
+       (RgnHandle, 'r', InMode),
+)
+methods.append(f)
 
-       f = Method(void, 'GetWindowUserState',
-               (WindowRef, 'theWindow', InMode),
-               (Rect, 'r', OutMode),
-       )
-       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, 'SetWindowStandardState',
-               (WindowRef, 'theWindow', InMode),
-               (Rect, 'r', InMode),
-       )
-       methods.append(f)
+f = Method(short, 'GetWindowTitleWidth',
+    (WindowRef, 'theWindow', InMode),
+)
+methods.append(f)
 
-       f = Method(void, 'SetWindowUserState',
-               (WindowRef, 'theWindow', InMode),
-               (Rect, 'r', InMode),
-       )
-       methods.append(f)
+f = Method(ExistingWindowPtr, 'GetNextWindow',
+       (WindowRef, 'theWindow', InMode),
+)
+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.
index 74b3bfdb53b41f231badda7365d5bc0fa770c2bb..6b67db1fc1929403f3e828b99214b99e773748e2 100644 (file)
@@ -57,10 +57,17 @@ includestuff = includestuff + """
 #include <%s>""" % MACHEADERFILE + """
 
 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
+/* Carbon calls that we emulate in classic mode */
 #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
 #define GetWindowFromPort(port) ((WindowRef)(port))
 #define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
 #endif
+#if ACCESSOR_CALLS_ARE_FUNCTIONS
+/* Classic calls that we emulate in carbon mode */
+#define GetWindowUpdateRgn(win, rgn) GetWindowRegion((win), kWindowUpdateRgn, (rgn))
+#define GetWindowStructureRgn(win, rgn) GetWindowRegion((win), kWindowStructureRgn, (rgn))
+#define GetWindowContentRgn(win, rgn) GetWindowRegion((win), kWindowContentRgn, (rgn))
+#endif
 
 /* Function to dispose a window, with a "normal" calling sequence */
 static void