2 /* =========================== Module Win =========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
47 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
50 static PyObject
*Win_Error
;
52 /* ----------------------- Object type Window ----------------------- */
54 PyTypeObject Window_Type
;
56 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
58 typedef struct WindowObject
{
63 PyObject
*WinObj_New(itself
)
67 if (itself
== NULL
) return PyMac_Error(resNotFound
);
68 it
= PyObject_NEW(WindowObject
, &Window_Type
);
69 if (it
== NULL
) return NULL
;
70 it
->ob_itself
= itself
;
71 SetWRefCon(itself
, (long)it
);
72 return (PyObject
*)it
;
74 WinObj_Convert(v
, p_itself
)
78 if (DlgObj_Check(v
)) {
79 *p_itself
= ((WindowObject
*)v
)->ob_itself
;
83 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
84 if (PyInt_Check(v
)) { *p_itself
= (WindowPtr
)PyInt_AsLong(v
); return 1; }
88 PyErr_SetString(PyExc_TypeError
, "Window required");
91 *p_itself
= ((WindowObject
*)v
)->ob_itself
;
95 static void WinObj_dealloc(self
)
98 DisposeWindow(self
->ob_itself
);
102 static PyObject
*WinObj_MacCloseWindow(_self
, _args
)
106 PyObject
*_res
= NULL
;
107 if (!PyArg_ParseTuple(_args
, ""))
109 MacCloseWindow(_self
->ob_itself
);
115 static PyObject
*WinObj_SetWinColor(_self
, _args
)
119 PyObject
*_res
= NULL
;
120 WCTabHandle newColorTable
;
121 if (!PyArg_ParseTuple(_args
, "O&",
122 ResObj_Convert
, &newColorTable
))
124 SetWinColor(_self
->ob_itself
,
131 static PyObject
*WinObj_ClipAbove(_self
, _args
)
135 PyObject
*_res
= NULL
;
136 if (!PyArg_ParseTuple(_args
, ""))
138 ClipAbove(_self
->ob_itself
);
144 static PyObject
*WinObj_SaveOld(_self
, _args
)
148 PyObject
*_res
= NULL
;
149 if (!PyArg_ParseTuple(_args
, ""))
151 SaveOld(_self
->ob_itself
);
157 static PyObject
*WinObj_DrawNew(_self
, _args
)
161 PyObject
*_res
= NULL
;
163 if (!PyArg_ParseTuple(_args
, "b",
166 DrawNew(_self
->ob_itself
,
173 static PyObject
*WinObj_PaintOne(_self
, _args
)
177 PyObject
*_res
= NULL
;
178 RgnHandle clobberedRgn
;
179 if (!PyArg_ParseTuple(_args
, "O&",
180 ResObj_Convert
, &clobberedRgn
))
182 PaintOne(_self
->ob_itself
,
189 static PyObject
*WinObj_PaintBehind(_self
, _args
)
193 PyObject
*_res
= NULL
;
194 RgnHandle clobberedRgn
;
195 if (!PyArg_ParseTuple(_args
, "O&",
196 ResObj_Convert
, &clobberedRgn
))
198 PaintBehind(_self
->ob_itself
,
205 static PyObject
*WinObj_CalcVis(_self
, _args
)
209 PyObject
*_res
= NULL
;
210 if (!PyArg_ParseTuple(_args
, ""))
212 CalcVis(_self
->ob_itself
);
218 static PyObject
*WinObj_CalcVisBehind(_self
, _args
)
222 PyObject
*_res
= NULL
;
223 RgnHandle clobberedRgn
;
224 if (!PyArg_ParseTuple(_args
, "O&",
225 ResObj_Convert
, &clobberedRgn
))
227 CalcVisBehind(_self
->ob_itself
,
234 static PyObject
*WinObj_BringToFront(_self
, _args
)
238 PyObject
*_res
= NULL
;
239 if (!PyArg_ParseTuple(_args
, ""))
241 BringToFront(_self
->ob_itself
);
247 static PyObject
*WinObj_SendBehind(_self
, _args
)
251 PyObject
*_res
= NULL
;
252 WindowPtr behindWindow
;
253 if (!PyArg_ParseTuple(_args
, "O&",
254 WinObj_Convert
, &behindWindow
))
256 SendBehind(_self
->ob_itself
,
263 static PyObject
*WinObj_SelectWindow(_self
, _args
)
267 PyObject
*_res
= NULL
;
268 if (!PyArg_ParseTuple(_args
, ""))
270 SelectWindow(_self
->ob_itself
);
276 static PyObject
*WinObj_HiliteWindow(_self
, _args
)
280 PyObject
*_res
= NULL
;
282 if (!PyArg_ParseTuple(_args
, "b",
285 HiliteWindow(_self
->ob_itself
,
292 static PyObject
*WinObj_GetWindowFeatures(_self
, _args
)
296 PyObject
*_res
= NULL
;
299 if (!PyArg_ParseTuple(_args
, ""))
301 _rv
= GetWindowFeatures(_self
->ob_itself
,
303 _res
= Py_BuildValue("ll",
309 static PyObject
*WinObj_GetWindowRegion(_self
, _args
)
313 PyObject
*_res
= NULL
;
315 WindowRegionCode inRegionCode
;
317 if (!PyArg_ParseTuple(_args
, "hO&",
319 ResObj_Convert
, &ioWinRgn
))
321 _rv
= GetWindowRegion(_self
->ob_itself
,
324 _res
= Py_BuildValue("l",
329 static PyObject
*WinObj_SetWRefCon(_self
, _args
)
333 PyObject
*_res
= NULL
;
335 if (!PyArg_ParseTuple(_args
, "l",
338 SetWRefCon(_self
->ob_itself
,
345 static PyObject
*WinObj_GetWRefCon(_self
, _args
)
349 PyObject
*_res
= NULL
;
351 if (!PyArg_ParseTuple(_args
, ""))
353 _rv
= GetWRefCon(_self
->ob_itself
);
354 _res
= Py_BuildValue("l",
359 static PyObject
*WinObj_SetWindowPic(_self
, _args
)
363 PyObject
*_res
= NULL
;
365 if (!PyArg_ParseTuple(_args
, "O&",
366 ResObj_Convert
, &pic
))
368 SetWindowPic(_self
->ob_itself
,
375 static PyObject
*WinObj_GetWindowPic(_self
, _args
)
379 PyObject
*_res
= NULL
;
381 if (!PyArg_ParseTuple(_args
, ""))
383 _rv
= GetWindowPic(_self
->ob_itself
);
384 _res
= Py_BuildValue("O&",
389 static PyObject
*WinObj_GetWVariant(_self
, _args
)
393 PyObject
*_res
= NULL
;
395 if (!PyArg_ParseTuple(_args
, ""))
397 _rv
= GetWVariant(_self
->ob_itself
);
398 _res
= Py_BuildValue("h",
403 static PyObject
*WinObj_BeginUpdate(_self
, _args
)
407 PyObject
*_res
= NULL
;
408 if (!PyArg_ParseTuple(_args
, ""))
410 BeginUpdate(_self
->ob_itself
);
416 static PyObject
*WinObj_EndUpdate(_self
, _args
)
420 PyObject
*_res
= NULL
;
421 if (!PyArg_ParseTuple(_args
, ""))
423 EndUpdate(_self
->ob_itself
);
429 static PyObject
*WinObj_DrawGrowIcon(_self
, _args
)
433 PyObject
*_res
= NULL
;
434 if (!PyArg_ParseTuple(_args
, ""))
436 DrawGrowIcon(_self
->ob_itself
);
442 static PyObject
*WinObj_SetWTitle(_self
, _args
)
446 PyObject
*_res
= NULL
;
448 if (!PyArg_ParseTuple(_args
, "O&",
449 PyMac_GetStr255
, title
))
451 SetWTitle(_self
->ob_itself
,
458 static PyObject
*WinObj_GetWTitle(_self
, _args
)
462 PyObject
*_res
= NULL
;
464 if (!PyArg_ParseTuple(_args
, ""))
466 GetWTitle(_self
->ob_itself
,
468 _res
= Py_BuildValue("O&",
469 PyMac_BuildStr255
, title
);
473 static PyObject
*WinObj_IsWindowCollapsable(_self
, _args
)
477 PyObject
*_res
= NULL
;
479 if (!PyArg_ParseTuple(_args
, ""))
481 _rv
= IsWindowCollapsable(_self
->ob_itself
);
482 _res
= Py_BuildValue("b",
487 static PyObject
*WinObj_IsWindowCollapsed(_self
, _args
)
491 PyObject
*_res
= NULL
;
493 if (!PyArg_ParseTuple(_args
, ""))
495 _rv
= IsWindowCollapsed(_self
->ob_itself
);
496 _res
= Py_BuildValue("b",
501 static PyObject
*WinObj_CollapseWindow(_self
, _args
)
505 PyObject
*_res
= NULL
;
507 Boolean inCollapseIt
;
508 if (!PyArg_ParseTuple(_args
, "b",
511 _rv
= CollapseWindow(_self
->ob_itself
,
513 _res
= Py_BuildValue("l",
518 static PyObject
*WinObj_MacMoveWindow(_self
, _args
)
522 PyObject
*_res
= NULL
;
526 if (!PyArg_ParseTuple(_args
, "hhb",
531 MacMoveWindow(_self
->ob_itself
,
540 static PyObject
*WinObj_SizeWindow(_self
, _args
)
544 PyObject
*_res
= NULL
;
548 if (!PyArg_ParseTuple(_args
, "hhb",
553 SizeWindow(_self
->ob_itself
,
562 static PyObject
*WinObj_ZoomWindow(_self
, _args
)
566 PyObject
*_res
= NULL
;
569 if (!PyArg_ParseTuple(_args
, "hb",
573 ZoomWindow(_self
->ob_itself
,
581 static PyObject
*WinObj_GrowWindow(_self
, _args
)
585 PyObject
*_res
= NULL
;
589 if (!PyArg_ParseTuple(_args
, "O&O&",
590 PyMac_GetPoint
, &startPt
,
591 PyMac_GetRect
, &bBox
))
593 _rv
= GrowWindow(_self
->ob_itself
,
596 _res
= Py_BuildValue("l",
601 static PyObject
*WinObj_DragWindow(_self
, _args
)
605 PyObject
*_res
= NULL
;
608 if (!PyArg_ParseTuple(_args
, "O&O&",
609 PyMac_GetPoint
, &startPt
,
610 PyMac_GetRect
, &boundsRect
))
612 DragWindow(_self
->ob_itself
,
620 static PyObject
*WinObj_HideWindow(_self
, _args
)
624 PyObject
*_res
= NULL
;
625 if (!PyArg_ParseTuple(_args
, ""))
627 HideWindow(_self
->ob_itself
);
633 static PyObject
*WinObj_MacShowWindow(_self
, _args
)
637 PyObject
*_res
= NULL
;
638 if (!PyArg_ParseTuple(_args
, ""))
640 MacShowWindow(_self
->ob_itself
);
646 static PyObject
*WinObj_ShowHide(_self
, _args
)
650 PyObject
*_res
= NULL
;
652 if (!PyArg_ParseTuple(_args
, "b",
655 ShowHide(_self
->ob_itself
,
662 static PyObject
*WinObj_TrackBox(_self
, _args
)
666 PyObject
*_res
= NULL
;
670 if (!PyArg_ParseTuple(_args
, "O&h",
671 PyMac_GetPoint
, &thePt
,
674 _rv
= TrackBox(_self
->ob_itself
,
677 _res
= Py_BuildValue("b",
682 static PyObject
*WinObj_TrackGoAway(_self
, _args
)
686 PyObject
*_res
= NULL
;
689 if (!PyArg_ParseTuple(_args
, "O&",
690 PyMac_GetPoint
, &thePt
))
692 _rv
= TrackGoAway(_self
->ob_itself
,
694 _res
= Py_BuildValue("b",
699 static PyObject
*WinObj_GetAuxWin(_self
, _args
)
703 PyObject
*_res
= NULL
;
706 if (!PyArg_ParseTuple(_args
, ""))
708 _rv
= GetAuxWin(_self
->ob_itself
,
710 _res
= Py_BuildValue("bO&",
716 static PyObject
*WinObj_GetWindowPort(_self
, _args
)
720 PyObject
*_res
= NULL
;
722 if (!PyArg_ParseTuple(_args
, ""))
724 _rv
= GetWindowPort(_self
->ob_itself
);
725 _res
= Py_BuildValue("O&",
730 static PyObject
*WinObj_SetPortWindowPort(_self
, _args
)
734 PyObject
*_res
= NULL
;
735 if (!PyArg_ParseTuple(_args
, ""))
737 SetPortWindowPort(_self
->ob_itself
);
743 static PyObject
*WinObj_GetWindowKind(_self
, _args
)
747 PyObject
*_res
= NULL
;
749 if (!PyArg_ParseTuple(_args
, ""))
751 _rv
= GetWindowKind(_self
->ob_itself
);
752 _res
= Py_BuildValue("h",
757 static PyObject
*WinObj_SetWindowKind(_self
, _args
)
761 PyObject
*_res
= NULL
;
763 if (!PyArg_ParseTuple(_args
, "h",
766 SetWindowKind(_self
->ob_itself
,
773 static PyObject
*WinObj_IsWindowVisible(_self
, _args
)
777 PyObject
*_res
= NULL
;
779 if (!PyArg_ParseTuple(_args
, ""))
781 _rv
= IsWindowVisible(_self
->ob_itself
);
782 _res
= Py_BuildValue("b",
787 static PyObject
*WinObj_IsWindowHilited(_self
, _args
)
791 PyObject
*_res
= NULL
;
793 if (!PyArg_ParseTuple(_args
, ""))
795 _rv
= IsWindowHilited(_self
->ob_itself
);
796 _res
= Py_BuildValue("b",
801 static PyObject
*WinObj_GetWindowGoAwayFlag(_self
, _args
)
805 PyObject
*_res
= NULL
;
807 if (!PyArg_ParseTuple(_args
, ""))
809 _rv
= GetWindowGoAwayFlag(_self
->ob_itself
);
810 _res
= Py_BuildValue("b",
815 static PyObject
*WinObj_GetWindowZoomFlag(_self
, _args
)
819 PyObject
*_res
= NULL
;
821 if (!PyArg_ParseTuple(_args
, ""))
823 _rv
= GetWindowZoomFlag(_self
->ob_itself
);
824 _res
= Py_BuildValue("b",
829 static PyObject
*WinObj_GetWindowStructureRgn(_self
, _args
)
833 PyObject
*_res
= NULL
;
835 if (!PyArg_ParseTuple(_args
, "O&",
838 GetWindowStructureRgn(_self
->ob_itself
,
845 static PyObject
*WinObj_GetWindowContentRgn(_self
, _args
)
849 PyObject
*_res
= NULL
;
851 if (!PyArg_ParseTuple(_args
, "O&",
854 GetWindowContentRgn(_self
->ob_itself
,
861 static PyObject
*WinObj_GetWindowUpdateRgn(_self
, _args
)
865 PyObject
*_res
= NULL
;
867 if (!PyArg_ParseTuple(_args
, "O&",
870 GetWindowUpdateRgn(_self
->ob_itself
,
877 static PyObject
*WinObj_GetWindowTitleWidth(_self
, _args
)
881 PyObject
*_res
= NULL
;
883 if (!PyArg_ParseTuple(_args
, ""))
885 _rv
= GetWindowTitleWidth(_self
->ob_itself
);
886 _res
= Py_BuildValue("h",
891 static PyObject
*WinObj_GetNextWindow(_self
, _args
)
895 PyObject
*_res
= NULL
;
897 if (!PyArg_ParseTuple(_args
, ""))
899 _rv
= GetNextWindow(_self
->ob_itself
);
900 _res
= Py_BuildValue("O&",
901 WinObj_WhichWindow
, _rv
);
905 static PyObject
*WinObj_GetWindowStandardState(_self
, _args
)
909 PyObject
*_res
= NULL
;
911 if (!PyArg_ParseTuple(_args
, ""))
913 GetWindowStandardState(_self
->ob_itself
,
915 _res
= Py_BuildValue("O&",
916 PyMac_BuildRect
, &r
);
920 static PyObject
*WinObj_GetWindowUserState(_self
, _args
)
924 PyObject
*_res
= NULL
;
926 if (!PyArg_ParseTuple(_args
, ""))
928 GetWindowUserState(_self
->ob_itself
,
930 _res
= Py_BuildValue("O&",
931 PyMac_BuildRect
, &r
);
935 static PyObject
*WinObj_SetWindowStandardState(_self
, _args
)
939 PyObject
*_res
= NULL
;
941 if (!PyArg_ParseTuple(_args
, "O&",
944 SetWindowStandardState(_self
->ob_itself
,
951 static PyObject
*WinObj_SetWindowUserState(_self
, _args
)
955 PyObject
*_res
= NULL
;
957 if (!PyArg_ParseTuple(_args
, "O&",
960 SetWindowUserState(_self
->ob_itself
,
967 static PyObject
*WinObj_GetWindowDataHandle(_self
, _args
)
971 PyObject
*_res
= NULL
;
973 if (!PyArg_ParseTuple(_args
, ""))
975 _rv
= GetWindowDataHandle(_self
->ob_itself
);
976 _res
= Py_BuildValue("O&",
981 static PyObject
*WinObj_SetWindowDataHandle(_self
, _args
)
985 PyObject
*_res
= NULL
;
987 if (!PyArg_ParseTuple(_args
, "O&",
988 ResObj_Convert
, &data
))
990 SetWindowDataHandle(_self
->ob_itself
,
997 static PyObject
*WinObj_CloseWindow(_self
, _args
)
1001 PyObject
*_res
= NULL
;
1002 if (!PyArg_ParseTuple(_args
, ""))
1004 CloseWindow(_self
->ob_itself
);
1010 static PyObject
*WinObj_MoveWindow(_self
, _args
)
1011 WindowObject
*_self
;
1014 PyObject
*_res
= NULL
;
1018 if (!PyArg_ParseTuple(_args
, "hhb",
1023 MoveWindow(_self
->ob_itself
,
1032 static PyObject
*WinObj_ShowWindow(_self
, _args
)
1033 WindowObject
*_self
;
1036 PyObject
*_res
= NULL
;
1037 if (!PyArg_ParseTuple(_args
, ""))
1039 ShowWindow(_self
->ob_itself
);
1045 static PyMethodDef WinObj_methods
[] = {
1046 {"MacCloseWindow", (PyCFunction
)WinObj_MacCloseWindow
, 1,
1048 {"SetWinColor", (PyCFunction
)WinObj_SetWinColor
, 1,
1049 "(WCTabHandle newColorTable) -> None"},
1050 {"ClipAbove", (PyCFunction
)WinObj_ClipAbove
, 1,
1052 {"SaveOld", (PyCFunction
)WinObj_SaveOld
, 1,
1054 {"DrawNew", (PyCFunction
)WinObj_DrawNew
, 1,
1055 "(Boolean update) -> None"},
1056 {"PaintOne", (PyCFunction
)WinObj_PaintOne
, 1,
1057 "(RgnHandle clobberedRgn) -> None"},
1058 {"PaintBehind", (PyCFunction
)WinObj_PaintBehind
, 1,
1059 "(RgnHandle clobberedRgn) -> None"},
1060 {"CalcVis", (PyCFunction
)WinObj_CalcVis
, 1,
1062 {"CalcVisBehind", (PyCFunction
)WinObj_CalcVisBehind
, 1,
1063 "(RgnHandle clobberedRgn) -> None"},
1064 {"BringToFront", (PyCFunction
)WinObj_BringToFront
, 1,
1066 {"SendBehind", (PyCFunction
)WinObj_SendBehind
, 1,
1067 "(WindowPtr behindWindow) -> None"},
1068 {"SelectWindow", (PyCFunction
)WinObj_SelectWindow
, 1,
1070 {"HiliteWindow", (PyCFunction
)WinObj_HiliteWindow
, 1,
1071 "(Boolean fHilite) -> None"},
1072 {"GetWindowFeatures", (PyCFunction
)WinObj_GetWindowFeatures
, 1,
1073 "() -> (OSStatus _rv, UInt32 outFeatures)"},
1074 {"GetWindowRegion", (PyCFunction
)WinObj_GetWindowRegion
, 1,
1075 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> (OSStatus _rv)"},
1076 {"SetWRefCon", (PyCFunction
)WinObj_SetWRefCon
, 1,
1077 "(long data) -> None"},
1078 {"GetWRefCon", (PyCFunction
)WinObj_GetWRefCon
, 1,
1079 "() -> (long _rv)"},
1080 {"SetWindowPic", (PyCFunction
)WinObj_SetWindowPic
, 1,
1081 "(PicHandle pic) -> None"},
1082 {"GetWindowPic", (PyCFunction
)WinObj_GetWindowPic
, 1,
1083 "() -> (PicHandle _rv)"},
1084 {"GetWVariant", (PyCFunction
)WinObj_GetWVariant
, 1,
1085 "() -> (short _rv)"},
1086 {"BeginUpdate", (PyCFunction
)WinObj_BeginUpdate
, 1,
1088 {"EndUpdate", (PyCFunction
)WinObj_EndUpdate
, 1,
1090 {"DrawGrowIcon", (PyCFunction
)WinObj_DrawGrowIcon
, 1,
1092 {"SetWTitle", (PyCFunction
)WinObj_SetWTitle
, 1,
1093 "(Str255 title) -> None"},
1094 {"GetWTitle", (PyCFunction
)WinObj_GetWTitle
, 1,
1095 "() -> (Str255 title)"},
1096 {"IsWindowCollapsable", (PyCFunction
)WinObj_IsWindowCollapsable
, 1,
1097 "() -> (Boolean _rv)"},
1098 {"IsWindowCollapsed", (PyCFunction
)WinObj_IsWindowCollapsed
, 1,
1099 "() -> (Boolean _rv)"},
1100 {"CollapseWindow", (PyCFunction
)WinObj_CollapseWindow
, 1,
1101 "(Boolean inCollapseIt) -> (OSStatus _rv)"},
1102 {"MacMoveWindow", (PyCFunction
)WinObj_MacMoveWindow
, 1,
1103 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1104 {"SizeWindow", (PyCFunction
)WinObj_SizeWindow
, 1,
1105 "(short w, short h, Boolean fUpdate) -> None"},
1106 {"ZoomWindow", (PyCFunction
)WinObj_ZoomWindow
, 1,
1107 "(short partCode, Boolean front) -> None"},
1108 {"GrowWindow", (PyCFunction
)WinObj_GrowWindow
, 1,
1109 "(Point startPt, Rect bBox) -> (long _rv)"},
1110 {"DragWindow", (PyCFunction
)WinObj_DragWindow
, 1,
1111 "(Point startPt, Rect boundsRect) -> None"},
1112 {"HideWindow", (PyCFunction
)WinObj_HideWindow
, 1,
1114 {"MacShowWindow", (PyCFunction
)WinObj_MacShowWindow
, 1,
1116 {"ShowHide", (PyCFunction
)WinObj_ShowHide
, 1,
1117 "(Boolean showFlag) -> None"},
1118 {"TrackBox", (PyCFunction
)WinObj_TrackBox
, 1,
1119 "(Point thePt, short partCode) -> (Boolean _rv)"},
1120 {"TrackGoAway", (PyCFunction
)WinObj_TrackGoAway
, 1,
1121 "(Point thePt) -> (Boolean _rv)"},
1122 {"GetAuxWin", (PyCFunction
)WinObj_GetAuxWin
, 1,
1123 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
1124 {"GetWindowPort", (PyCFunction
)WinObj_GetWindowPort
, 1,
1125 "() -> (CGrafPtr _rv)"},
1126 {"SetPortWindowPort", (PyCFunction
)WinObj_SetPortWindowPort
, 1,
1128 {"GetWindowKind", (PyCFunction
)WinObj_GetWindowKind
, 1,
1129 "() -> (short _rv)"},
1130 {"SetWindowKind", (PyCFunction
)WinObj_SetWindowKind
, 1,
1131 "(short wKind) -> None"},
1132 {"IsWindowVisible", (PyCFunction
)WinObj_IsWindowVisible
, 1,
1133 "() -> (Boolean _rv)"},
1134 {"IsWindowHilited", (PyCFunction
)WinObj_IsWindowHilited
, 1,
1135 "() -> (Boolean _rv)"},
1136 {"GetWindowGoAwayFlag", (PyCFunction
)WinObj_GetWindowGoAwayFlag
, 1,
1137 "() -> (Boolean _rv)"},
1138 {"GetWindowZoomFlag", (PyCFunction
)WinObj_GetWindowZoomFlag
, 1,
1139 "() -> (Boolean _rv)"},
1140 {"GetWindowStructureRgn", (PyCFunction
)WinObj_GetWindowStructureRgn
, 1,
1141 "(RgnHandle r) -> None"},
1142 {"GetWindowContentRgn", (PyCFunction
)WinObj_GetWindowContentRgn
, 1,
1143 "(RgnHandle r) -> None"},
1144 {"GetWindowUpdateRgn", (PyCFunction
)WinObj_GetWindowUpdateRgn
, 1,
1145 "(RgnHandle r) -> None"},
1146 {"GetWindowTitleWidth", (PyCFunction
)WinObj_GetWindowTitleWidth
, 1,
1147 "() -> (short _rv)"},
1148 {"GetNextWindow", (PyCFunction
)WinObj_GetNextWindow
, 1,
1149 "() -> (WindowPtr _rv)"},
1150 {"GetWindowStandardState", (PyCFunction
)WinObj_GetWindowStandardState
, 1,
1152 {"GetWindowUserState", (PyCFunction
)WinObj_GetWindowUserState
, 1,
1154 {"SetWindowStandardState", (PyCFunction
)WinObj_SetWindowStandardState
, 1,
1155 "(Rect r) -> None"},
1156 {"SetWindowUserState", (PyCFunction
)WinObj_SetWindowUserState
, 1,
1157 "(Rect r) -> None"},
1158 {"GetWindowDataHandle", (PyCFunction
)WinObj_GetWindowDataHandle
, 1,
1159 "() -> (Handle _rv)"},
1160 {"SetWindowDataHandle", (PyCFunction
)WinObj_SetWindowDataHandle
, 1,
1161 "(Handle data) -> None"},
1162 {"CloseWindow", (PyCFunction
)WinObj_CloseWindow
, 1,
1164 {"MoveWindow", (PyCFunction
)WinObj_MoveWindow
, 1,
1165 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1166 {"ShowWindow", (PyCFunction
)WinObj_ShowWindow
, 1,
1171 PyMethodChain WinObj_chain
= { WinObj_methods
, NULL
};
1173 static PyObject
*WinObj_getattr(self
, name
)
1177 return Py_FindMethodInChain(&WinObj_chain
, (PyObject
*)self
, name
);
1180 #define WinObj_setattr NULL
1182 PyTypeObject Window_Type
= {
1183 PyObject_HEAD_INIT(&PyType_Type
)
1185 "Window", /*tp_name*/
1186 sizeof(WindowObject
), /*tp_basicsize*/
1189 (destructor
) WinObj_dealloc
, /*tp_dealloc*/
1191 (getattrfunc
) WinObj_getattr
, /*tp_getattr*/
1192 (setattrfunc
) WinObj_setattr
, /*tp_setattr*/
1195 /* --------------------- End object type Window --------------------- */
1198 static PyObject
*Win_GetNewCWindow(_self
, _args
)
1202 PyObject
*_res
= NULL
;
1206 if (!PyArg_ParseTuple(_args
, "hO&",
1208 WinObj_Convert
, &behind
))
1210 _rv
= GetNewCWindow(windowID
,
1213 _res
= Py_BuildValue("O&",
1218 static PyObject
*Win_NewWindow(_self
, _args
)
1222 PyObject
*_res
= NULL
;
1231 if (!PyArg_ParseTuple(_args
, "O&O&bhO&bl",
1232 PyMac_GetRect
, &boundsRect
,
1233 PyMac_GetStr255
, title
,
1236 WinObj_Convert
, &behind
,
1240 _rv
= NewWindow((void *)0,
1248 _res
= Py_BuildValue("O&",
1253 static PyObject
*Win_GetNewWindow(_self
, _args
)
1257 PyObject
*_res
= NULL
;
1261 if (!PyArg_ParseTuple(_args
, "hO&",
1263 WinObj_Convert
, &behind
))
1265 _rv
= GetNewWindow(windowID
,
1268 _res
= Py_BuildValue("O&",
1273 static PyObject
*Win_NewCWindow(_self
, _args
)
1277 PyObject
*_res
= NULL
;
1286 if (!PyArg_ParseTuple(_args
, "O&O&bhO&bl",
1287 PyMac_GetRect
, &boundsRect
,
1288 PyMac_GetStr255
, title
,
1291 WinObj_Convert
, &behind
,
1295 _rv
= NewCWindow((void *)0,
1303 _res
= Py_BuildValue("O&",
1308 static PyObject
*Win_SetDeskCPat(_self
, _args
)
1312 PyObject
*_res
= NULL
;
1313 PixPatHandle deskPixPat
;
1314 if (!PyArg_ParseTuple(_args
, "O&",
1315 ResObj_Convert
, &deskPixPat
))
1317 SetDeskCPat(deskPixPat
);
1323 static PyObject
*Win_CheckUpdate(_self
, _args
)
1327 PyObject
*_res
= NULL
;
1329 EventRecord theEvent
;
1330 if (!PyArg_ParseTuple(_args
, ""))
1332 _rv
= CheckUpdate(&theEvent
);
1333 _res
= Py_BuildValue("bO&",
1335 PyMac_BuildEventRecord
, &theEvent
);
1339 static PyObject
*Win_MacFindWindow(_self
, _args
)
1343 PyObject
*_res
= NULL
;
1346 WindowPtr theWindow
;
1347 if (!PyArg_ParseTuple(_args
, "O&",
1348 PyMac_GetPoint
, &thePoint
))
1350 _rv
= MacFindWindow(thePoint
,
1352 _res
= Py_BuildValue("hO&",
1354 WinObj_WhichWindow
, theWindow
);
1358 static PyObject
*Win_FrontWindow(_self
, _args
)
1362 PyObject
*_res
= NULL
;
1364 if (!PyArg_ParseTuple(_args
, ""))
1366 _rv
= FrontWindow();
1367 _res
= Py_BuildValue("O&",
1368 WinObj_WhichWindow
, _rv
);
1372 static PyObject
*Win_InitWindows(_self
, _args
)
1376 PyObject
*_res
= NULL
;
1377 if (!PyArg_ParseTuple(_args
, ""))
1385 static PyObject
*Win_GetWMgrPort(_self
, _args
)
1389 PyObject
*_res
= NULL
;
1391 if (!PyArg_ParseTuple(_args
, ""))
1393 GetWMgrPort(&wPort
);
1394 _res
= Py_BuildValue("O&",
1395 GrafObj_New
, wPort
);
1399 static PyObject
*Win_GetCWMgrPort(_self
, _args
)
1403 PyObject
*_res
= NULL
;
1405 if (!PyArg_ParseTuple(_args
, ""))
1407 GetCWMgrPort(&wMgrCPort
);
1408 _res
= Py_BuildValue("O&",
1409 GrafObj_New
, wMgrCPort
);
1413 static PyObject
*Win_InvalRect(_self
, _args
)
1417 PyObject
*_res
= NULL
;
1419 if (!PyArg_ParseTuple(_args
, "O&",
1420 PyMac_GetRect
, &badRect
))
1422 InvalRect(&badRect
);
1428 static PyObject
*Win_InvalRgn(_self
, _args
)
1432 PyObject
*_res
= NULL
;
1434 if (!PyArg_ParseTuple(_args
, "O&",
1435 ResObj_Convert
, &badRgn
))
1443 static PyObject
*Win_ValidRect(_self
, _args
)
1447 PyObject
*_res
= NULL
;
1449 if (!PyArg_ParseTuple(_args
, "O&",
1450 PyMac_GetRect
, &goodRect
))
1452 ValidRect(&goodRect
);
1458 static PyObject
*Win_ValidRgn(_self
, _args
)
1462 PyObject
*_res
= NULL
;
1464 if (!PyArg_ParseTuple(_args
, "O&",
1465 ResObj_Convert
, &goodRgn
))
1473 static PyObject
*Win_CollapseAllWindows(_self
, _args
)
1477 PyObject
*_res
= NULL
;
1479 Boolean inCollapseEm
;
1480 if (!PyArg_ParseTuple(_args
, "b",
1483 _rv
= CollapseAllWindows(inCollapseEm
);
1484 _res
= Py_BuildValue("l",
1489 static PyObject
*Win_PinRect(_self
, _args
)
1493 PyObject
*_res
= NULL
;
1497 if (!PyArg_ParseTuple(_args
, "O&O&",
1498 PyMac_GetRect
, &theRect
,
1499 PyMac_GetPoint
, &thePt
))
1501 _rv
= PinRect(&theRect
,
1503 _res
= Py_BuildValue("l",
1508 static PyObject
*Win_GetGrayRgn(_self
, _args
)
1512 PyObject
*_res
= NULL
;
1514 if (!PyArg_ParseTuple(_args
, ""))
1517 _res
= Py_BuildValue("O&",
1522 static PyObject
*Win_WhichWindow(_self
, _args
)
1526 PyObject
*_res
= NULL
;
1530 if ( !PyArg_ParseTuple(_args
, "i", &ptr
) )
1532 return WinObj_WhichWindow((WindowPtr
)ptr
);
1536 static PyObject
*Win_FindWindow(_self
, _args
)
1540 PyObject
*_res
= NULL
;
1543 WindowPtr theWindow
;
1544 if (!PyArg_ParseTuple(_args
, "O&",
1545 PyMac_GetPoint
, &thePoint
))
1547 _rv
= FindWindow(thePoint
,
1549 _res
= Py_BuildValue("hO&",
1551 WinObj_WhichWindow
, theWindow
);
1555 static PyMethodDef Win_methods
[] = {
1556 {"GetNewCWindow", (PyCFunction
)Win_GetNewCWindow
, 1,
1557 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
1558 {"NewWindow", (PyCFunction
)Win_NewWindow
, 1,
1559 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1560 {"GetNewWindow", (PyCFunction
)Win_GetNewWindow
, 1,
1561 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
1562 {"NewCWindow", (PyCFunction
)Win_NewCWindow
, 1,
1563 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1564 {"SetDeskCPat", (PyCFunction
)Win_SetDeskCPat
, 1,
1565 "(PixPatHandle deskPixPat) -> None"},
1566 {"CheckUpdate", (PyCFunction
)Win_CheckUpdate
, 1,
1567 "() -> (Boolean _rv, EventRecord theEvent)"},
1568 {"MacFindWindow", (PyCFunction
)Win_MacFindWindow
, 1,
1569 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
1570 {"FrontWindow", (PyCFunction
)Win_FrontWindow
, 1,
1571 "() -> (WindowPtr _rv)"},
1572 {"InitWindows", (PyCFunction
)Win_InitWindows
, 1,
1574 {"GetWMgrPort", (PyCFunction
)Win_GetWMgrPort
, 1,
1575 "() -> (GrafPtr wPort)"},
1576 {"GetCWMgrPort", (PyCFunction
)Win_GetCWMgrPort
, 1,
1577 "() -> (CGrafPtr wMgrCPort)"},
1578 {"InvalRect", (PyCFunction
)Win_InvalRect
, 1,
1579 "(Rect badRect) -> None"},
1580 {"InvalRgn", (PyCFunction
)Win_InvalRgn
, 1,
1581 "(RgnHandle badRgn) -> None"},
1582 {"ValidRect", (PyCFunction
)Win_ValidRect
, 1,
1583 "(Rect goodRect) -> None"},
1584 {"ValidRgn", (PyCFunction
)Win_ValidRgn
, 1,
1585 "(RgnHandle goodRgn) -> None"},
1586 {"CollapseAllWindows", (PyCFunction
)Win_CollapseAllWindows
, 1,
1587 "(Boolean inCollapseEm) -> (OSStatus _rv)"},
1588 {"PinRect", (PyCFunction
)Win_PinRect
, 1,
1589 "(Rect theRect, Point thePt) -> (long _rv)"},
1590 {"GetGrayRgn", (PyCFunction
)Win_GetGrayRgn
, 1,
1591 "() -> (RgnHandle _rv)"},
1592 {"WhichWindow", (PyCFunction
)Win_WhichWindow
, 1,
1593 "Resolve an integer WindowPtr address to a Window object"},
1594 {"FindWindow", (PyCFunction
)Win_FindWindow
, 1,
1595 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
1601 /* Return the object corresponding to the window, or NULL */
1604 WinObj_WhichWindow(w
)
1609 /* XXX What if we find a stdwin window or a window belonging
1610 to some other package? */
1614 it
= (PyObject
*) GetWRefCon(w
);
1615 if (it
== NULL
|| ((WindowObject
*)it
)->ob_itself
!= w
)
1630 m
= Py_InitModule("Win", Win_methods
);
1631 d
= PyModule_GetDict(m
);
1632 Win_Error
= PyMac_GetOSErrException();
1633 if (Win_Error
== NULL
||
1634 PyDict_SetItemString(d
, "Error", Win_Error
) != 0)
1635 Py_FatalError("can't initialize Win.Error");
1636 Window_Type
.ob_type
= &PyType_Type
;
1637 Py_INCREF(&Window_Type
);
1638 if (PyDict_SetItemString(d
, "WindowType", (PyObject
*)&Window_Type
) != 0)
1639 Py_FatalError("can't initialize WindowType");
1642 /* ========================= End module Win ========================= */