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

Skip to content

Commit b7abb18

Browse files
committed
Added support for GrafPort object
1 parent 330381c commit b7abb18

5 files changed

Lines changed: 279 additions & 26 deletions

File tree

Mac/Modules/win/Winmodule.c

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ extern int ResObj_Convert(PyObject *, Handle *);
1919

2020
extern PyObject *WinObj_New(WindowPtr);
2121
extern int WinObj_Convert(PyObject *, WindowPtr *);
22+
extern PyTypeObject Window_Type;
23+
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
2224

2325
extern PyObject *DlgObj_New(DialogPtr);
2426
extern int DlgObj_Convert(PyObject *, DialogPtr *);
@@ -31,6 +33,9 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
3133
extern PyObject *CtlObj_New(ControlHandle);
3234
extern int CtlObj_Convert(PyObject *, ControlHandle *);
3335

36+
extern PyObject *GrafObj_New(GrafPtr);
37+
extern int GrafObj_Convert(PyObject *, GrafPtr *);
38+
3439
extern PyObject *WinObj_WhichWindow(WindowPtr);
3540

3641
#include <Windows.h>
@@ -412,6 +417,38 @@ static PyObject *WinObj_DrawNew(_self, _args)
412417
return _res;
413418
}
414419

420+
static PyObject *WinObj_PaintOne(_self, _args)
421+
WindowObject *_self;
422+
PyObject *_args;
423+
{
424+
PyObject *_res = NULL;
425+
RgnHandle clobberedRgn;
426+
if (!PyArg_ParseTuple(_args, "O&",
427+
ResObj_Convert, &clobberedRgn))
428+
return NULL;
429+
PaintOne(_self->ob_itself,
430+
clobberedRgn);
431+
Py_INCREF(Py_None);
432+
_res = Py_None;
433+
return _res;
434+
}
435+
436+
static PyObject *WinObj_PaintBehind(_self, _args)
437+
WindowObject *_self;
438+
PyObject *_args;
439+
{
440+
PyObject *_res = NULL;
441+
RgnHandle clobberedRgn;
442+
if (!PyArg_ParseTuple(_args, "O&",
443+
ResObj_Convert, &clobberedRgn))
444+
return NULL;
445+
PaintBehind(_self->ob_itself,
446+
clobberedRgn);
447+
Py_INCREF(Py_None);
448+
_res = Py_None;
449+
return _res;
450+
}
451+
415452
static PyObject *WinObj_CalcVis(_self, _args)
416453
WindowObject *_self;
417454
PyObject *_args;
@@ -425,6 +462,22 @@ static PyObject *WinObj_CalcVis(_self, _args)
425462
return _res;
426463
}
427464

465+
static PyObject *WinObj_CalcVisBehind(_self, _args)
466+
WindowObject *_self;
467+
PyObject *_args;
468+
{
469+
PyObject *_res = NULL;
470+
RgnHandle clobberedRgn;
471+
if (!PyArg_ParseTuple(_args, "O&",
472+
ResObj_Convert, &clobberedRgn))
473+
return NULL;
474+
CalcVisBehind(_self->ob_itself,
475+
clobberedRgn);
476+
Py_INCREF(Py_None);
477+
_res = Py_None;
478+
return _res;
479+
}
480+
428481
static PyObject *WinObj_GrowWindow(_self, _args)
429482
WindowObject *_self;
430483
PyObject *_args;
@@ -531,6 +584,20 @@ static PyObject *WinObj_DragWindow(_self, _args)
531584
return _res;
532585
}
533586

587+
static PyObject *WinObj_GetWindowPort(_self, _args)
588+
WindowObject *_self;
589+
PyObject *_args;
590+
{
591+
PyObject *_res = NULL;
592+
CGrafPtr _rv;
593+
if (!PyArg_ParseTuple(_args, ""))
594+
return NULL;
595+
_rv = GetWindowPort(_self->ob_itself);
596+
_res = Py_BuildValue("O&",
597+
GrafObj_New, _rv);
598+
return _res;
599+
}
600+
534601
static PyObject *WinObj_SetPortWindowPort(_self, _args)
535602
WindowObject *_self;
536603
PyObject *_args;
@@ -630,6 +697,54 @@ static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
630697
return _res;
631698
}
632699

700+
static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
701+
WindowObject *_self;
702+
PyObject *_args;
703+
{
704+
PyObject *_res = NULL;
705+
RgnHandle r;
706+
if (!PyArg_ParseTuple(_args, "O&",
707+
ResObj_Convert, &r))
708+
return NULL;
709+
GetWindowStructureRgn(_self->ob_itself,
710+
r);
711+
Py_INCREF(Py_None);
712+
_res = Py_None;
713+
return _res;
714+
}
715+
716+
static PyObject *WinObj_GetWindowContentRgn(_self, _args)
717+
WindowObject *_self;
718+
PyObject *_args;
719+
{
720+
PyObject *_res = NULL;
721+
RgnHandle r;
722+
if (!PyArg_ParseTuple(_args, "O&",
723+
ResObj_Convert, &r))
724+
return NULL;
725+
GetWindowContentRgn(_self->ob_itself,
726+
r);
727+
Py_INCREF(Py_None);
728+
_res = Py_None;
729+
return _res;
730+
}
731+
732+
static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
733+
WindowObject *_self;
734+
PyObject *_args;
735+
{
736+
PyObject *_res = NULL;
737+
RgnHandle r;
738+
if (!PyArg_ParseTuple(_args, "O&",
739+
ResObj_Convert, &r))
740+
return NULL;
741+
GetWindowUpdateRgn(_self->ob_itself,
742+
r);
743+
Py_INCREF(Py_None);
744+
_res = Py_None;
745+
return _res;
746+
}
747+
633748
static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
634749
WindowObject *_self;
635750
PyObject *_args;
@@ -763,8 +878,14 @@ static PyMethodDef WinObj_methods[] = {
763878
"() -> None"},
764879
{"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
765880
"(Boolean update) -> None"},
881+
{"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
882+
"(RgnHandle clobberedRgn) -> None"},
883+
{"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
884+
"(RgnHandle clobberedRgn) -> None"},
766885
{"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
767886
"() -> None"},
887+
{"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
888+
"(RgnHandle clobberedRgn) -> None"},
768889
{"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
769890
"(Point startPt, Rect bBox) -> (long _rv)"},
770891
{"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
@@ -777,6 +898,8 @@ static PyMethodDef WinObj_methods[] = {
777898
"(Point thePt) -> (Boolean _rv)"},
778899
{"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
779900
"(Point startPt, Rect boundsRect) -> None"},
901+
{"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
902+
"() -> (CGrafPtr _rv)"},
780903
{"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
781904
"() -> None"},
782905
{"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
@@ -791,6 +914,12 @@ static PyMethodDef WinObj_methods[] = {
791914
"() -> (Boolean _rv)"},
792915
{"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
793916
"() -> (Boolean _rv)"},
917+
{"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
918+
"(RgnHandle r) -> None"},
919+
{"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
920+
"(RgnHandle r) -> None"},
921+
{"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
922+
"(RgnHandle r) -> None"},
794923
{"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
795924
"() -> (short _rv)"},
796925
{"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
@@ -833,6 +962,20 @@ PyTypeObject Window_Type = {
833962
/* --------------------- End object type Window --------------------- */
834963

835964

965+
static PyObject *Win_GetGrayRgn(_self, _args)
966+
PyObject *_self;
967+
PyObject *_args;
968+
{
969+
PyObject *_res = NULL;
970+
RgnHandle _rv;
971+
if (!PyArg_ParseTuple(_args, ""))
972+
return NULL;
973+
_rv = GetGrayRgn();
974+
_res = Py_BuildValue("O&",
975+
ResObj_New, _rv);
976+
return _res;
977+
}
978+
836979
static PyObject *Win_InitWindows(_self, _args)
837980
PyObject *_self;
838981
PyObject *_args;
@@ -846,6 +989,20 @@ static PyObject *Win_InitWindows(_self, _args)
846989
return _res;
847990
}
848991

992+
static PyObject *Win_GetWMgrPort(_self, _args)
993+
PyObject *_self;
994+
PyObject *_args;
995+
{
996+
PyObject *_res = NULL;
997+
GrafPtr wPort;
998+
if (!PyArg_ParseTuple(_args, ""))
999+
return NULL;
1000+
GetWMgrPort(&wPort);
1001+
_res = Py_BuildValue("O&",
1002+
GrafObj_New, wPort);
1003+
return _res;
1004+
}
1005+
8491006
static PyObject *Win_NewWindow(_self, _args)
8501007
PyObject *_self;
8511008
PyObject *_args;
@@ -930,6 +1087,21 @@ static PyObject *Win_InvalRect(_self, _args)
9301087
return _res;
9311088
}
9321089

1090+
static PyObject *Win_InvalRgn(_self, _args)
1091+
PyObject *_self;
1092+
PyObject *_args;
1093+
{
1094+
PyObject *_res = NULL;
1095+
RgnHandle badRgn;
1096+
if (!PyArg_ParseTuple(_args, "O&",
1097+
ResObj_Convert, &badRgn))
1098+
return NULL;
1099+
InvalRgn(badRgn);
1100+
Py_INCREF(Py_None);
1101+
_res = Py_None;
1102+
return _res;
1103+
}
1104+
9331105
static PyObject *Win_ValidRect(_self, _args)
9341106
PyObject *_self;
9351107
PyObject *_args;
@@ -945,6 +1117,21 @@ static PyObject *Win_ValidRect(_self, _args)
9451117
return _res;
9461118
}
9471119

1120+
static PyObject *Win_ValidRgn(_self, _args)
1121+
PyObject *_self;
1122+
PyObject *_args;
1123+
{
1124+
PyObject *_res = NULL;
1125+
RgnHandle goodRgn;
1126+
if (!PyArg_ParseTuple(_args, "O&",
1127+
ResObj_Convert, &goodRgn))
1128+
return NULL;
1129+
ValidRgn(goodRgn);
1130+
Py_INCREF(Py_None);
1131+
_res = Py_None;
1132+
return _res;
1133+
}
1134+
9481135
static PyObject *Win_CheckUpdate(_self, _args)
9491136
PyObject *_self;
9501137
PyObject *_args;
@@ -999,6 +1186,20 @@ static PyObject *Win_PinRect(_self, _args)
9991186
return _res;
10001187
}
10011188

1189+
static PyObject *Win_GetCWMgrPort(_self, _args)
1190+
PyObject *_self;
1191+
PyObject *_args;
1192+
{
1193+
PyObject *_res = NULL;
1194+
CGrafPtr wMgrCPort;
1195+
if (!PyArg_ParseTuple(_args, ""))
1196+
return NULL;
1197+
GetCWMgrPort(&wMgrCPort);
1198+
_res = Py_BuildValue("O&",
1199+
GrafObj_New, wMgrCPort);
1200+
return _res;
1201+
}
1202+
10021203
static PyObject *Win_NewCWindow(_self, _args)
10031204
PyObject *_self;
10041205
PyObject *_args;
@@ -1069,8 +1270,12 @@ static PyObject *Win_WhichWindow(_self, _args)
10691270
}
10701271

10711272
static PyMethodDef Win_methods[] = {
1273+
{"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
1274+
"() -> (RgnHandle _rv)"},
10721275
{"InitWindows", (PyCFunction)Win_InitWindows, 1,
10731276
"() -> None"},
1277+
{"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
1278+
"() -> (GrafPtr wPort)"},
10741279
{"NewWindow", (PyCFunction)Win_NewWindow, 1,
10751280
"(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
10761281
{"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
@@ -1079,14 +1284,20 @@ static PyMethodDef Win_methods[] = {
10791284
"() -> (WindowPtr _rv)"},
10801285
{"InvalRect", (PyCFunction)Win_InvalRect, 1,
10811286
"(Rect badRect) -> None"},
1287+
{"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
1288+
"(RgnHandle badRgn) -> None"},
10821289
{"ValidRect", (PyCFunction)Win_ValidRect, 1,
10831290
"(Rect goodRect) -> None"},
1291+
{"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
1292+
"(RgnHandle goodRgn) -> None"},
10841293
{"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
10851294
"() -> (Boolean _rv, EventRecord theEvent)"},
10861295
{"FindWindow", (PyCFunction)Win_FindWindow, 1,
10871296
"(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
10881297
{"PinRect", (PyCFunction)Win_PinRect, 1,
10891298
"(Rect theRect, Point thePt) -> (long _rv)"},
1299+
{"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
1300+
"() -> (CGrafPtr wMgrCPort)"},
10901301
{"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
10911302
"(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
10921303
{"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,

Mac/Modules/win/winedit.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# These are inline-routines/defines, so we do them "by hand"
22
#
33

4+
f = Method(CGrafPtr, 'GetWindowPort',
5+
(WindowRef, 'theWindow', InMode),
6+
)
7+
methods.append(f)
8+
49
f = Method(void, 'SetPortWindowPort',
510
(WindowRef, 'theWindow', InMode),
611
)
@@ -38,25 +43,23 @@
3843
)
3944
methods.append(f)
4045

41-
if 0:
42-
# Regions are not implemented yet..
43-
f = Method(void, 'GetWindowStructureRgn',
44-
(WindowRef, 'theWindow', InMode),
45-
(RgnHandle, 'r', InMode),
46-
)
47-
methods.append(f)
48-
49-
f = Method(void, 'GetWindowContentRgn',
50-
(WindowRef, 'theWindow', InMode),
51-
(RgnHandle, 'r', InMode),
52-
)
53-
methods.append(f)
54-
55-
f = Method(void, 'GetWindowUpdateRgn',
56-
(WindowRef, 'theWindow', InMode),
57-
(RgnHandle, 'r', InMode),
58-
)
59-
methods.append(f)
46+
f = Method(void, 'GetWindowStructureRgn',
47+
(WindowRef, 'theWindow', InMode),
48+
(RgnHandle, 'r', InMode),
49+
)
50+
methods.append(f)
51+
52+
f = Method(void, 'GetWindowContentRgn',
53+
(WindowRef, 'theWindow', InMode),
54+
(RgnHandle, 'r', InMode),
55+
)
56+
methods.append(f)
57+
58+
f = Method(void, 'GetWindowUpdateRgn',
59+
(WindowRef, 'theWindow', InMode),
60+
(RgnHandle, 'r', InMode),
61+
)
62+
methods.append(f)
6063

6164
f = Method(short, 'GetWindowTitleWidth',
6265
(WindowRef, 'theWindow', InMode),

0 commit comments

Comments
 (0)