Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3224865

Browse files
committed
Emulate a few more non-carbon calls in carbon and the other way around.
1 parent 87a3092 commit 3224865

3 files changed

Lines changed: 163 additions & 93 deletions

File tree

Mac/Modules/win/Winmodule.c

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111
#include <Windows.h>
1212

1313
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
14+
/* Carbon calls that we emulate in classic mode */
1415
#define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
1516
#define GetWindowFromPort(port) ((WindowRef)(port))
1617
#define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
1718
#endif
19+
#if ACCESSOR_CALLS_ARE_FUNCTIONS
20+
/* Classic calls that we emulate in carbon mode */
21+
#define GetWindowUpdateRgn(win, rgn) GetWindowRegion((win), kWindowUpdateRgn, (rgn))
22+
#define GetWindowStructureRgn(win, rgn) GetWindowRegion((win), kWindowStructureRgn, (rgn))
23+
#define GetWindowContentRgn(win, rgn) GetWindowRegion((win), kWindowContentRgn, (rgn))
24+
#endif
1825

1926
/* Function to dispose a window, with a "normal" calling sequence */
2027
static void
@@ -1851,6 +1858,110 @@ static PyObject *WinObj_GetWindowPortBounds(_self, _args)
18511858
return _res;
18521859
}
18531860

1861+
static PyObject *WinObj_IsWindowVisible(_self, _args)
1862+
WindowObject *_self;
1863+
PyObject *_args;
1864+
{
1865+
PyObject *_res = NULL;
1866+
Boolean _rv;
1867+
if (!PyArg_ParseTuple(_args, ""))
1868+
return NULL;
1869+
_rv = IsWindowVisible(_self->ob_itself);
1870+
_res = Py_BuildValue("b",
1871+
_rv);
1872+
return _res;
1873+
}
1874+
1875+
static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1876+
WindowObject *_self;
1877+
PyObject *_args;
1878+
{
1879+
PyObject *_res = NULL;
1880+
Boolean _rv;
1881+
if (!PyArg_ParseTuple(_args, ""))
1882+
return NULL;
1883+
_rv = GetWindowZoomFlag(_self->ob_itself);
1884+
_res = Py_BuildValue("b",
1885+
_rv);
1886+
return _res;
1887+
}
1888+
1889+
static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1890+
WindowObject *_self;
1891+
PyObject *_args;
1892+
{
1893+
PyObject *_res = NULL;
1894+
RgnHandle r;
1895+
if (!PyArg_ParseTuple(_args, "O&",
1896+
ResObj_Convert, &r))
1897+
return NULL;
1898+
GetWindowStructureRgn(_self->ob_itself,
1899+
r);
1900+
Py_INCREF(Py_None);
1901+
_res = Py_None;
1902+
return _res;
1903+
}
1904+
1905+
static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1906+
WindowObject *_self;
1907+
PyObject *_args;
1908+
{
1909+
PyObject *_res = NULL;
1910+
RgnHandle r;
1911+
if (!PyArg_ParseTuple(_args, "O&",
1912+
ResObj_Convert, &r))
1913+
return NULL;
1914+
GetWindowContentRgn(_self->ob_itself,
1915+
r);
1916+
Py_INCREF(Py_None);
1917+
_res = Py_None;
1918+
return _res;
1919+
}
1920+
1921+
static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1922+
WindowObject *_self;
1923+
PyObject *_args;
1924+
{
1925+
PyObject *_res = NULL;
1926+
RgnHandle r;
1927+
if (!PyArg_ParseTuple(_args, "O&",
1928+
ResObj_Convert, &r))
1929+
return NULL;
1930+
GetWindowUpdateRgn(_self->ob_itself,
1931+
r);
1932+
Py_INCREF(Py_None);
1933+
_res = Py_None;
1934+
return _res;
1935+
}
1936+
1937+
static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1938+
WindowObject *_self;
1939+
PyObject *_args;
1940+
{
1941+
PyObject *_res = NULL;
1942+
short _rv;
1943+
if (!PyArg_ParseTuple(_args, ""))
1944+
return NULL;
1945+
_rv = GetWindowTitleWidth(_self->ob_itself);
1946+
_res = Py_BuildValue("h",
1947+
_rv);
1948+
return _res;
1949+
}
1950+
1951+
static PyObject *WinObj_GetNextWindow(_self, _args)
1952+
WindowObject *_self;
1953+
PyObject *_args;
1954+
{
1955+
PyObject *_res = NULL;
1956+
WindowPtr _rv;
1957+
if (!PyArg_ParseTuple(_args, ""))
1958+
return NULL;
1959+
_rv = GetNextWindow(_self->ob_itself);
1960+
_res = Py_BuildValue("O&",
1961+
WinObj_WhichWindow, _rv);
1962+
return _res;
1963+
}
1964+
18541965
#if !TARGET_API_MAC_CARBON
18551966

18561967
static PyObject *WinObj_CloseWindow(_self, _args)
@@ -2142,6 +2253,20 @@ static PyMethodDef WinObj_methods[] = {
21422253
"() -> None"},
21432254
{"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1,
21442255
"() -> (Rect bounds)"},
2256+
{"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
2257+
"() -> (Boolean _rv)"},
2258+
{"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
2259+
"() -> (Boolean _rv)"},
2260+
{"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
2261+
"(RgnHandle r) -> None"},
2262+
{"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
2263+
"(RgnHandle r) -> None"},
2264+
{"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
2265+
"(RgnHandle r) -> None"},
2266+
{"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
2267+
"() -> (short _rv)"},
2268+
{"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
2269+
"() -> (WindowPtr _rv)"},
21452270

21462271
#if !TARGET_API_MAC_CARBON
21472272
{"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,

Mac/Modules/win/winedit.py

Lines changed: 31 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,43 @@
11
# These are inline-routines/defines, so we do them "by hand"
22
#
3-
if 0:
4-
f = Method(CGrafPtr, 'GetWindowPort',
5-
(WindowRef, 'theWindow', InMode),
6-
)
7-
methods.append(f)
83

9-
f = Method(void, 'SetPortWindowPort',
10-
(WindowRef, 'theWindow', InMode),
11-
)
12-
methods.append(f)
13-
14-
f = Method(short, 'GetWindowKind',
15-
(WindowRef, 'theWindow', InMode),
16-
)
17-
methods.append(f)
18-
19-
f = Method(void, 'SetWindowKind',
20-
(WindowRef, 'theWindow', InMode),
21-
(short, 'wKind', InMode),
22-
)
23-
methods.append(f)
24-
25-
26-
f = Method(Boolean, 'IsWindowVisible',
27-
(WindowRef, 'theWindow', InMode),
28-
)
29-
methods.append(f)
30-
31-
f = Method(Boolean, 'IsWindowHilited',
32-
(WindowRef, 'theWindow', InMode),
33-
)
34-
methods.append(f)
35-
36-
f = Method(Boolean, 'GetWindowGoAwayFlag',
37-
(WindowRef, 'theWindow', InMode),
38-
)
39-
methods.append(f)
40-
41-
f = Method(Boolean, 'GetWindowZoomFlag',
42-
(WindowRef, 'theWindow', InMode),
43-
condition='#if !TARGET_API_MAC_CARBON'
44-
)
45-
methods.append(f)
46-
47-
f = Method(void, 'GetWindowStructureRgn',
48-
(WindowRef, 'theWindow', InMode),
49-
(RgnHandle, 'r', InMode),
50-
condition='#if !TARGET_API_MAC_CARBON'
51-
)
52-
methods.append(f)
53-
54-
f = Method(void, 'GetWindowContentRgn',
55-
(WindowRef, 'theWindow', InMode),
56-
(RgnHandle, 'r', InMode),
57-
condition='#if !TARGET_API_MAC_CARBON'
58-
)
59-
methods.append(f)
60-
61-
f = Method(void, 'GetWindowUpdateRgn',
62-
(WindowRef, 'theWindow', InMode),
63-
(RgnHandle, 'r', InMode),
64-
condition='#if !TARGET_API_MAC_CARBON'
65-
)
66-
methods.append(f)
67-
68-
f = Method(short, 'GetWindowTitleWidth',
69-
(WindowRef, 'theWindow', InMode),
70-
condition='#if !TARGET_API_MAC_CARBON'
71-
)
72-
methods.append(f)
4+
f = Method(Boolean, 'IsWindowVisible',
5+
(WindowRef, 'theWindow', InMode),
6+
)
7+
methods.append(f)
738

74-
f = Method(ExistingWindowPtr, 'GetNextWindow',
75-
(WindowRef, 'theWindow', InMode),
76-
)
77-
methods.append(f)
9+
f = Method(Boolean, 'GetWindowZoomFlag',
10+
(WindowRef, 'theWindow', InMode),
11+
)
12+
methods.append(f)
7813

79-
f = Method(void, 'GetWindowStandardState',
80-
(WindowRef, 'theWindow', InMode),
81-
(Rect, 'r', OutMode),
82-
)
83-
methods.append(f)
14+
f = Method(void, 'GetWindowStructureRgn',
15+
(WindowRef, 'theWindow', InMode),
16+
(RgnHandle, 'r', InMode),
17+
)
18+
methods.append(f)
8419

85-
f = Method(void, 'GetWindowUserState',
86-
(WindowRef, 'theWindow', InMode),
87-
(Rect, 'r', OutMode),
88-
)
89-
methods.append(f)
20+
f = Method(void, 'GetWindowContentRgn',
21+
(WindowRef, 'theWindow', InMode),
22+
(RgnHandle, 'r', InMode),
23+
)
24+
methods.append(f)
9025

26+
f = Method(void, 'GetWindowUpdateRgn',
27+
(WindowRef, 'theWindow', InMode),
28+
(RgnHandle, 'r', InMode),
29+
)
30+
methods.append(f)
9131

92-
f = Method(void, 'SetWindowStandardState',
93-
(WindowRef, 'theWindow', InMode),
94-
(Rect, 'r', InMode),
95-
)
96-
methods.append(f)
32+
f = Method(short, 'GetWindowTitleWidth',
33+
(WindowRef, 'theWindow', InMode),
34+
)
35+
methods.append(f)
9736

98-
f = Method(void, 'SetWindowUserState',
99-
(WindowRef, 'theWindow', InMode),
100-
(Rect, 'r', InMode),
101-
)
102-
methods.append(f)
37+
f = Method(ExistingWindowPtr, 'GetNextWindow',
38+
(WindowRef, 'theWindow', InMode),
39+
)
40+
methods.append(f)
10341

10442
# These have Mac prefixed to their name in the 3.1 universal headers,
10543
# so we add the old/real names by hand.

Mac/Modules/win/winsupport.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,17 @@
5757
#include <%s>""" % MACHEADERFILE + """
5858
5959
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
60+
/* Carbon calls that we emulate in classic mode */
6061
#define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
6162
#define GetWindowFromPort(port) ((WindowRef)(port))
6263
#define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
6364
#endif
65+
#if ACCESSOR_CALLS_ARE_FUNCTIONS
66+
/* Classic calls that we emulate in carbon mode */
67+
#define GetWindowUpdateRgn(win, rgn) GetWindowRegion((win), kWindowUpdateRgn, (rgn))
68+
#define GetWindowStructureRgn(win, rgn) GetWindowRegion((win), kWindowStructureRgn, (rgn))
69+
#define GetWindowContentRgn(win, rgn) GetWindowRegion((win), kWindowContentRgn, (rgn))
70+
#endif
6471
6572
/* Function to dispose a window, with a "normal" calling sequence */
6673
static void

0 commit comments

Comments
 (0)