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 extern PyObject
*QdRGB_New(RGBColor
*);
48 extern int QdRGB_Convert(PyObject
*, RGBColor
*);
50 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
53 static PyObject
*Win_Error
;
55 /* ----------------------- Object type Window ----------------------- */
57 PyTypeObject Window_Type
;
59 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
61 typedef struct WindowObject
{
66 PyObject
*WinObj_New(itself
)
70 if (itself
== NULL
) return PyMac_Error(resNotFound
);
71 it
= PyObject_NEW(WindowObject
, &Window_Type
);
72 if (it
== NULL
) return NULL
;
73 it
->ob_itself
= itself
;
74 SetWRefCon(itself
, (long)it
);
75 return (PyObject
*)it
;
77 WinObj_Convert(v
, p_itself
)
81 if (DlgObj_Check(v
)) {
82 *p_itself
= ((WindowObject
*)v
)->ob_itself
;
86 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
87 if (PyInt_Check(v
)) { *p_itself
= (WindowPtr
)PyInt_AsLong(v
); return 1; }
91 PyErr_SetString(PyExc_TypeError
, "Window required");
94 *p_itself
= ((WindowObject
*)v
)->ob_itself
;
98 static void WinObj_dealloc(self
)
101 DisposeWindow(self
->ob_itself
);
105 static PyObject
*WinObj_MacCloseWindow(_self
, _args
)
109 PyObject
*_res
= NULL
;
110 if (!PyArg_ParseTuple(_args
, ""))
112 MacCloseWindow(_self
->ob_itself
);
118 static PyObject
*WinObj_GetWindowOwnerCount(_self
, _args
)
122 PyObject
*_res
= NULL
;
125 if (!PyArg_ParseTuple(_args
, ""))
127 _err
= GetWindowOwnerCount(_self
->ob_itself
,
129 if (_err
!= noErr
) return PyMac_Error(_err
);
130 _res
= Py_BuildValue("l",
135 static PyObject
*WinObj_CloneWindow(_self
, _args
)
139 PyObject
*_res
= NULL
;
141 if (!PyArg_ParseTuple(_args
, ""))
143 _err
= CloneWindow(_self
->ob_itself
);
144 if (_err
!= noErr
) return PyMac_Error(_err
);
150 static PyObject
*WinObj_GetWindowClass(_self
, _args
)
154 PyObject
*_res
= NULL
;
156 WindowClass outClass
;
157 if (!PyArg_ParseTuple(_args
, ""))
159 _err
= GetWindowClass(_self
->ob_itself
,
161 if (_err
!= noErr
) return PyMac_Error(_err
);
162 _res
= Py_BuildValue("l",
167 static PyObject
*WinObj_GetWindowAttributes(_self
, _args
)
171 PyObject
*_res
= NULL
;
173 WindowAttributes outAttributes
;
174 if (!PyArg_ParseTuple(_args
, ""))
176 _err
= GetWindowAttributes(_self
->ob_itself
,
178 if (_err
!= noErr
) return PyMac_Error(_err
);
179 _res
= Py_BuildValue("l",
184 static PyObject
*WinObj_SetWinColor(_self
, _args
)
188 PyObject
*_res
= NULL
;
189 WCTabHandle newColorTable
;
190 if (!PyArg_ParseTuple(_args
, "O&",
191 ResObj_Convert
, &newColorTable
))
193 SetWinColor(_self
->ob_itself
,
200 static PyObject
*WinObj_SetWindowContentColor(_self
, _args
)
204 PyObject
*_res
= NULL
;
207 if (!PyArg_ParseTuple(_args
, ""))
209 _err
= SetWindowContentColor(_self
->ob_itself
,
211 if (_err
!= noErr
) return PyMac_Error(_err
);
212 _res
= Py_BuildValue("O&",
217 static PyObject
*WinObj_GetWindowContentColor(_self
, _args
)
221 PyObject
*_res
= NULL
;
224 if (!PyArg_ParseTuple(_args
, ""))
226 _err
= GetWindowContentColor(_self
->ob_itself
,
228 if (_err
!= noErr
) return PyMac_Error(_err
);
229 _res
= Py_BuildValue("O&",
234 static PyObject
*WinObj_GetWindowContentPattern(_self
, _args
)
238 PyObject
*_res
= NULL
;
240 PixPatHandle outPixPat
;
241 if (!PyArg_ParseTuple(_args
, "O&",
242 ResObj_Convert
, &outPixPat
))
244 _err
= GetWindowContentPattern(_self
->ob_itself
,
246 if (_err
!= noErr
) return PyMac_Error(_err
);
252 static PyObject
*WinObj_SetWindowContentPattern(_self
, _args
)
256 PyObject
*_res
= NULL
;
259 if (!PyArg_ParseTuple(_args
, "O&",
260 ResObj_Convert
, &pixPat
))
262 _err
= SetWindowContentPattern(_self
->ob_itself
,
264 if (_err
!= noErr
) return PyMac_Error(_err
);
270 static PyObject
*WinObj_ClipAbove(_self
, _args
)
274 PyObject
*_res
= NULL
;
275 if (!PyArg_ParseTuple(_args
, ""))
277 ClipAbove(_self
->ob_itself
);
283 static PyObject
*WinObj_SaveOld(_self
, _args
)
287 PyObject
*_res
= NULL
;
288 if (!PyArg_ParseTuple(_args
, ""))
290 SaveOld(_self
->ob_itself
);
296 static PyObject
*WinObj_DrawNew(_self
, _args
)
300 PyObject
*_res
= NULL
;
302 if (!PyArg_ParseTuple(_args
, "b",
305 DrawNew(_self
->ob_itself
,
312 static PyObject
*WinObj_PaintOne(_self
, _args
)
316 PyObject
*_res
= NULL
;
317 RgnHandle clobberedRgn
;
318 if (!PyArg_ParseTuple(_args
, "O&",
319 ResObj_Convert
, &clobberedRgn
))
321 PaintOne(_self
->ob_itself
,
328 static PyObject
*WinObj_PaintBehind(_self
, _args
)
332 PyObject
*_res
= NULL
;
333 RgnHandle clobberedRgn
;
334 if (!PyArg_ParseTuple(_args
, "O&",
335 ResObj_Convert
, &clobberedRgn
))
337 PaintBehind(_self
->ob_itself
,
344 static PyObject
*WinObj_CalcVis(_self
, _args
)
348 PyObject
*_res
= NULL
;
349 if (!PyArg_ParseTuple(_args
, ""))
351 CalcVis(_self
->ob_itself
);
357 static PyObject
*WinObj_CalcVisBehind(_self
, _args
)
361 PyObject
*_res
= NULL
;
362 RgnHandle clobberedRgn
;
363 if (!PyArg_ParseTuple(_args
, "O&",
364 ResObj_Convert
, &clobberedRgn
))
366 CalcVisBehind(_self
->ob_itself
,
373 static PyObject
*WinObj_BringToFront(_self
, _args
)
377 PyObject
*_res
= NULL
;
378 if (!PyArg_ParseTuple(_args
, ""))
380 BringToFront(_self
->ob_itself
);
386 static PyObject
*WinObj_SendBehind(_self
, _args
)
390 PyObject
*_res
= NULL
;
391 WindowPtr behindWindow
;
392 if (!PyArg_ParseTuple(_args
, "O&",
393 WinObj_Convert
, &behindWindow
))
395 SendBehind(_self
->ob_itself
,
402 static PyObject
*WinObj_SelectWindow(_self
, _args
)
406 PyObject
*_res
= NULL
;
407 if (!PyArg_ParseTuple(_args
, ""))
409 SelectWindow(_self
->ob_itself
);
415 static PyObject
*WinObj_HiliteWindow(_self
, _args
)
419 PyObject
*_res
= NULL
;
421 if (!PyArg_ParseTuple(_args
, "b",
424 HiliteWindow(_self
->ob_itself
,
431 static PyObject
*WinObj_SetWRefCon(_self
, _args
)
435 PyObject
*_res
= NULL
;
437 if (!PyArg_ParseTuple(_args
, "l",
440 SetWRefCon(_self
->ob_itself
,
447 static PyObject
*WinObj_GetWRefCon(_self
, _args
)
451 PyObject
*_res
= NULL
;
453 if (!PyArg_ParseTuple(_args
, ""))
455 _rv
= GetWRefCon(_self
->ob_itself
);
456 _res
= Py_BuildValue("l",
461 static PyObject
*WinObj_SetWindowPic(_self
, _args
)
465 PyObject
*_res
= NULL
;
467 if (!PyArg_ParseTuple(_args
, "O&",
468 ResObj_Convert
, &pic
))
470 SetWindowPic(_self
->ob_itself
,
477 static PyObject
*WinObj_GetWindowPic(_self
, _args
)
481 PyObject
*_res
= NULL
;
483 if (!PyArg_ParseTuple(_args
, ""))
485 _rv
= GetWindowPic(_self
->ob_itself
);
486 _res
= Py_BuildValue("O&",
491 static PyObject
*WinObj_GetWVariant(_self
, _args
)
495 PyObject
*_res
= NULL
;
497 if (!PyArg_ParseTuple(_args
, ""))
499 _rv
= GetWVariant(_self
->ob_itself
);
500 _res
= Py_BuildValue("h",
505 static PyObject
*WinObj_GetWindowFeatures(_self
, _args
)
509 PyObject
*_res
= NULL
;
512 if (!PyArg_ParseTuple(_args
, ""))
514 _err
= GetWindowFeatures(_self
->ob_itself
,
516 if (_err
!= noErr
) return PyMac_Error(_err
);
517 _res
= Py_BuildValue("l",
522 static PyObject
*WinObj_GetWindowRegion(_self
, _args
)
526 PyObject
*_res
= NULL
;
528 WindowRegionCode inRegionCode
;
530 if (!PyArg_ParseTuple(_args
, "hO&",
532 ResObj_Convert
, &ioWinRgn
))
534 _err
= GetWindowRegion(_self
->ob_itself
,
537 if (_err
!= noErr
) return PyMac_Error(_err
);
543 static PyObject
*WinObj_BeginUpdate(_self
, _args
)
547 PyObject
*_res
= NULL
;
548 if (!PyArg_ParseTuple(_args
, ""))
550 BeginUpdate(_self
->ob_itself
);
556 static PyObject
*WinObj_EndUpdate(_self
, _args
)
560 PyObject
*_res
= NULL
;
561 if (!PyArg_ParseTuple(_args
, ""))
563 EndUpdate(_self
->ob_itself
);
569 static PyObject
*WinObj_InvalWindowRgn(_self
, _args
)
573 PyObject
*_res
= NULL
;
576 if (!PyArg_ParseTuple(_args
, "O&",
577 ResObj_Convert
, ®ion
))
579 _err
= InvalWindowRgn(_self
->ob_itself
,
581 if (_err
!= noErr
) return PyMac_Error(_err
);
587 static PyObject
*WinObj_InvalWindowRect(_self
, _args
)
591 PyObject
*_res
= NULL
;
594 if (!PyArg_ParseTuple(_args
, "O&",
595 PyMac_GetRect
, &bounds
))
597 _err
= InvalWindowRect(_self
->ob_itself
,
599 if (_err
!= noErr
) return PyMac_Error(_err
);
605 static PyObject
*WinObj_ValidWindowRgn(_self
, _args
)
609 PyObject
*_res
= NULL
;
612 if (!PyArg_ParseTuple(_args
, "O&",
613 ResObj_Convert
, ®ion
))
615 _err
= ValidWindowRgn(_self
->ob_itself
,
617 if (_err
!= noErr
) return PyMac_Error(_err
);
623 static PyObject
*WinObj_ValidWindowRect(_self
, _args
)
627 PyObject
*_res
= NULL
;
630 if (!PyArg_ParseTuple(_args
, "O&",
631 PyMac_GetRect
, &bounds
))
633 _err
= ValidWindowRect(_self
->ob_itself
,
635 if (_err
!= noErr
) return PyMac_Error(_err
);
641 static PyObject
*WinObj_DrawGrowIcon(_self
, _args
)
645 PyObject
*_res
= NULL
;
646 if (!PyArg_ParseTuple(_args
, ""))
648 DrawGrowIcon(_self
->ob_itself
);
654 static PyObject
*WinObj_SetWTitle(_self
, _args
)
658 PyObject
*_res
= NULL
;
660 if (!PyArg_ParseTuple(_args
, "O&",
661 PyMac_GetStr255
, title
))
663 SetWTitle(_self
->ob_itself
,
670 static PyObject
*WinObj_GetWTitle(_self
, _args
)
674 PyObject
*_res
= NULL
;
676 if (!PyArg_ParseTuple(_args
, ""))
678 GetWTitle(_self
->ob_itself
,
680 _res
= Py_BuildValue("O&",
681 PyMac_BuildStr255
, title
);
685 static PyObject
*WinObj_SetWindowProxyFSSpec(_self
, _args
)
689 PyObject
*_res
= NULL
;
692 if (!PyArg_ParseTuple(_args
, "O&",
693 PyMac_GetFSSpec
, &inFile
))
695 _err
= SetWindowProxyFSSpec(_self
->ob_itself
,
697 if (_err
!= noErr
) return PyMac_Error(_err
);
703 static PyObject
*WinObj_GetWindowProxyFSSpec(_self
, _args
)
707 PyObject
*_res
= NULL
;
710 if (!PyArg_ParseTuple(_args
, ""))
712 _err
= GetWindowProxyFSSpec(_self
->ob_itself
,
714 if (_err
!= noErr
) return PyMac_Error(_err
);
715 _res
= Py_BuildValue("O&",
716 PyMac_BuildFSSpec
, &outFile
);
720 static PyObject
*WinObj_SetWindowProxyAlias(_self
, _args
)
724 PyObject
*_res
= NULL
;
727 if (!PyArg_ParseTuple(_args
, "O&",
728 ResObj_Convert
, &alias
))
730 _err
= SetWindowProxyAlias(_self
->ob_itself
,
732 if (_err
!= noErr
) return PyMac_Error(_err
);
738 static PyObject
*WinObj_GetWindowProxyAlias(_self
, _args
)
742 PyObject
*_res
= NULL
;
745 if (!PyArg_ParseTuple(_args
, ""))
747 _err
= GetWindowProxyAlias(_self
->ob_itself
,
749 if (_err
!= noErr
) return PyMac_Error(_err
);
750 _res
= Py_BuildValue("O&",
755 static PyObject
*WinObj_SetWindowProxyCreatorAndType(_self
, _args
)
759 PyObject
*_res
= NULL
;
764 if (!PyArg_ParseTuple(_args
, "O&O&h",
765 PyMac_GetOSType
, &fileCreator
,
766 PyMac_GetOSType
, &fileType
,
769 _err
= SetWindowProxyCreatorAndType(_self
->ob_itself
,
773 if (_err
!= noErr
) return PyMac_Error(_err
);
779 static PyObject
*WinObj_GetWindowProxyIcon(_self
, _args
)
783 PyObject
*_res
= NULL
;
786 if (!PyArg_ParseTuple(_args
, ""))
788 _err
= GetWindowProxyIcon(_self
->ob_itself
,
790 if (_err
!= noErr
) return PyMac_Error(_err
);
791 _res
= Py_BuildValue("O&",
792 ResObj_New
, outIcon
);
796 static PyObject
*WinObj_SetWindowProxyIcon(_self
, _args
)
800 PyObject
*_res
= NULL
;
803 if (!PyArg_ParseTuple(_args
, "O&",
804 ResObj_Convert
, &icon
))
806 _err
= SetWindowProxyIcon(_self
->ob_itself
,
808 if (_err
!= noErr
) return PyMac_Error(_err
);
814 static PyObject
*WinObj_RemoveWindowProxy(_self
, _args
)
818 PyObject
*_res
= NULL
;
820 if (!PyArg_ParseTuple(_args
, ""))
822 _err
= RemoveWindowProxy(_self
->ob_itself
);
823 if (_err
!= noErr
) return PyMac_Error(_err
);
829 static PyObject
*WinObj_TrackWindowProxyDrag(_self
, _args
)
833 PyObject
*_res
= NULL
;
836 if (!PyArg_ParseTuple(_args
, "O&",
837 PyMac_GetPoint
, &startPt
))
839 _err
= TrackWindowProxyDrag(_self
->ob_itself
,
841 if (_err
!= noErr
) return PyMac_Error(_err
);
847 static PyObject
*WinObj_IsWindowModified(_self
, _args
)
851 PyObject
*_res
= NULL
;
853 if (!PyArg_ParseTuple(_args
, ""))
855 _rv
= IsWindowModified(_self
->ob_itself
);
856 _res
= Py_BuildValue("b",
861 static PyObject
*WinObj_SetWindowModified(_self
, _args
)
865 PyObject
*_res
= NULL
;
868 if (!PyArg_ParseTuple(_args
, "b",
871 _err
= SetWindowModified(_self
->ob_itself
,
873 if (_err
!= noErr
) return PyMac_Error(_err
);
879 static PyObject
*WinObj_IsWindowPathSelectClick(_self
, _args
)
883 PyObject
*_res
= NULL
;
886 if (!PyArg_ParseTuple(_args
, ""))
888 _rv
= IsWindowPathSelectClick(_self
->ob_itself
,
890 _res
= Py_BuildValue("bO&",
892 PyMac_BuildEventRecord
, &event
);
896 static PyObject
*WinObj_HiliteWindowFrameForDrag(_self
, _args
)
900 PyObject
*_res
= NULL
;
903 if (!PyArg_ParseTuple(_args
, "b",
906 _err
= HiliteWindowFrameForDrag(_self
->ob_itself
,
908 if (_err
!= noErr
) return PyMac_Error(_err
);
914 static PyObject
*WinObj_TransitionWindow(_self
, _args
)
918 PyObject
*_res
= NULL
;
920 WindowTransitionEffect effect
;
921 WindowTransitionAction action
;
923 if (!PyArg_ParseTuple(_args
, "llO&",
926 PyMac_GetRect
, &rect
))
928 _err
= TransitionWindow(_self
->ob_itself
,
932 if (_err
!= noErr
) return PyMac_Error(_err
);
938 static PyObject
*WinObj_MacMoveWindow(_self
, _args
)
942 PyObject
*_res
= NULL
;
946 if (!PyArg_ParseTuple(_args
, "hhb",
951 MacMoveWindow(_self
->ob_itself
,
960 static PyObject
*WinObj_SizeWindow(_self
, _args
)
964 PyObject
*_res
= NULL
;
968 if (!PyArg_ParseTuple(_args
, "hhb",
973 SizeWindow(_self
->ob_itself
,
982 static PyObject
*WinObj_GrowWindow(_self
, _args
)
986 PyObject
*_res
= NULL
;
990 if (!PyArg_ParseTuple(_args
, "O&O&",
991 PyMac_GetPoint
, &startPt
,
992 PyMac_GetRect
, &bBox
))
994 _rv
= GrowWindow(_self
->ob_itself
,
997 _res
= Py_BuildValue("l",
1002 static PyObject
*WinObj_DragWindow(_self
, _args
)
1003 WindowObject
*_self
;
1006 PyObject
*_res
= NULL
;
1009 if (!PyArg_ParseTuple(_args
, "O&O&",
1010 PyMac_GetPoint
, &startPt
,
1011 PyMac_GetRect
, &boundsRect
))
1013 DragWindow(_self
->ob_itself
,
1021 static PyObject
*WinObj_ZoomWindow(_self
, _args
)
1022 WindowObject
*_self
;
1025 PyObject
*_res
= NULL
;
1028 if (!PyArg_ParseTuple(_args
, "hb",
1032 ZoomWindow(_self
->ob_itself
,
1040 static PyObject
*WinObj_IsWindowCollapsable(_self
, _args
)
1041 WindowObject
*_self
;
1044 PyObject
*_res
= NULL
;
1046 if (!PyArg_ParseTuple(_args
, ""))
1048 _rv
= IsWindowCollapsable(_self
->ob_itself
);
1049 _res
= Py_BuildValue("b",
1054 static PyObject
*WinObj_IsWindowCollapsed(_self
, _args
)
1055 WindowObject
*_self
;
1058 PyObject
*_res
= NULL
;
1060 if (!PyArg_ParseTuple(_args
, ""))
1062 _rv
= IsWindowCollapsed(_self
->ob_itself
);
1063 _res
= Py_BuildValue("b",
1068 static PyObject
*WinObj_CollapseWindow(_self
, _args
)
1069 WindowObject
*_self
;
1072 PyObject
*_res
= NULL
;
1075 if (!PyArg_ParseTuple(_args
, "b",
1078 _err
= CollapseWindow(_self
->ob_itself
,
1080 if (_err
!= noErr
) return PyMac_Error(_err
);
1086 static PyObject
*WinObj_RepositionWindow(_self
, _args
)
1087 WindowObject
*_self
;
1090 PyObject
*_res
= NULL
;
1092 WindowPtr parentWindow
;
1093 WindowPositionMethod method
;
1094 if (!PyArg_ParseTuple(_args
, "O&l",
1095 WinObj_Convert
, &parentWindow
,
1098 _err
= RepositionWindow(_self
->ob_itself
,
1101 if (_err
!= noErr
) return PyMac_Error(_err
);
1107 static PyObject
*WinObj_SetWindowBounds(_self
, _args
)
1108 WindowObject
*_self
;
1111 PyObject
*_res
= NULL
;
1113 WindowRegionCode regionCode
;
1115 if (!PyArg_ParseTuple(_args
, "hO&",
1117 PyMac_GetRect
, &globalBounds
))
1119 _err
= SetWindowBounds(_self
->ob_itself
,
1122 if (_err
!= noErr
) return PyMac_Error(_err
);
1128 static PyObject
*WinObj_GetWindowBounds(_self
, _args
)
1129 WindowObject
*_self
;
1132 PyObject
*_res
= NULL
;
1134 WindowRegionCode regionCode
;
1136 if (!PyArg_ParseTuple(_args
, "h",
1139 _err
= GetWindowBounds(_self
->ob_itself
,
1142 if (_err
!= noErr
) return PyMac_Error(_err
);
1143 _res
= Py_BuildValue("O&",
1144 PyMac_BuildRect
, &globalBounds
);
1148 static PyObject
*WinObj_MoveWindowStructure(_self
, _args
)
1149 WindowObject
*_self
;
1152 PyObject
*_res
= NULL
;
1156 if (!PyArg_ParseTuple(_args
, "hh",
1160 _err
= MoveWindowStructure(_self
->ob_itself
,
1163 if (_err
!= noErr
) return PyMac_Error(_err
);
1169 static PyObject
*WinObj_IsWindowInStandardState(_self
, _args
)
1170 WindowObject
*_self
;
1173 PyObject
*_res
= NULL
;
1176 Rect idealStandardState
;
1177 if (!PyArg_ParseTuple(_args
, ""))
1179 _rv
= IsWindowInStandardState(_self
->ob_itself
,
1181 &idealStandardState
);
1182 _res
= Py_BuildValue("bO&O&",
1184 PyMac_BuildPoint
, idealSize
,
1185 PyMac_BuildRect
, &idealStandardState
);
1189 static PyObject
*WinObj_ZoomWindowIdeal(_self
, _args
)
1190 WindowObject
*_self
;
1193 PyObject
*_res
= NULL
;
1197 if (!PyArg_ParseTuple(_args
, "h",
1200 _err
= ZoomWindowIdeal(_self
->ob_itself
,
1203 if (_err
!= noErr
) return PyMac_Error(_err
);
1204 _res
= Py_BuildValue("O&",
1205 PyMac_BuildPoint
, ioIdealSize
);
1209 static PyObject
*WinObj_GetWindowIdealUserState(_self
, _args
)
1210 WindowObject
*_self
;
1213 PyObject
*_res
= NULL
;
1216 if (!PyArg_ParseTuple(_args
, ""))
1218 _err
= GetWindowIdealUserState(_self
->ob_itself
,
1220 if (_err
!= noErr
) return PyMac_Error(_err
);
1221 _res
= Py_BuildValue("O&",
1222 PyMac_BuildRect
, &userState
);
1226 static PyObject
*WinObj_SetWindowIdealUserState(_self
, _args
)
1227 WindowObject
*_self
;
1230 PyObject
*_res
= NULL
;
1233 if (!PyArg_ParseTuple(_args
, ""))
1235 _err
= SetWindowIdealUserState(_self
->ob_itself
,
1237 if (_err
!= noErr
) return PyMac_Error(_err
);
1238 _res
= Py_BuildValue("O&",
1239 PyMac_BuildRect
, &userState
);
1243 static PyObject
*WinObj_HideWindow(_self
, _args
)
1244 WindowObject
*_self
;
1247 PyObject
*_res
= NULL
;
1248 if (!PyArg_ParseTuple(_args
, ""))
1250 HideWindow(_self
->ob_itself
);
1256 static PyObject
*WinObj_MacShowWindow(_self
, _args
)
1257 WindowObject
*_self
;
1260 PyObject
*_res
= NULL
;
1261 if (!PyArg_ParseTuple(_args
, ""))
1263 MacShowWindow(_self
->ob_itself
);
1269 static PyObject
*WinObj_ShowHide(_self
, _args
)
1270 WindowObject
*_self
;
1273 PyObject
*_res
= NULL
;
1275 if (!PyArg_ParseTuple(_args
, "b",
1278 ShowHide(_self
->ob_itself
,
1285 static PyObject
*WinObj_TrackBox(_self
, _args
)
1286 WindowObject
*_self
;
1289 PyObject
*_res
= NULL
;
1293 if (!PyArg_ParseTuple(_args
, "O&h",
1294 PyMac_GetPoint
, &thePt
,
1297 _rv
= TrackBox(_self
->ob_itself
,
1300 _res
= Py_BuildValue("b",
1305 static PyObject
*WinObj_TrackGoAway(_self
, _args
)
1306 WindowObject
*_self
;
1309 PyObject
*_res
= NULL
;
1312 if (!PyArg_ParseTuple(_args
, "O&",
1313 PyMac_GetPoint
, &thePt
))
1315 _rv
= TrackGoAway(_self
->ob_itself
,
1317 _res
= Py_BuildValue("b",
1322 static PyObject
*WinObj_GetAuxWin(_self
, _args
)
1323 WindowObject
*_self
;
1326 PyObject
*_res
= NULL
;
1328 AuxWinHandle awHndl
;
1329 if (!PyArg_ParseTuple(_args
, ""))
1331 _rv
= GetAuxWin(_self
->ob_itself
,
1333 _res
= Py_BuildValue("bO&",
1335 ResObj_New
, awHndl
);
1339 static PyObject
*WinObj_GetWindowPort(_self
, _args
)
1340 WindowObject
*_self
;
1343 PyObject
*_res
= NULL
;
1345 if (!PyArg_ParseTuple(_args
, ""))
1347 _rv
= GetWindowPort(_self
->ob_itself
);
1348 _res
= Py_BuildValue("O&",
1353 static PyObject
*WinObj_SetPortWindowPort(_self
, _args
)
1354 WindowObject
*_self
;
1357 PyObject
*_res
= NULL
;
1358 if (!PyArg_ParseTuple(_args
, ""))
1360 SetPortWindowPort(_self
->ob_itself
);
1366 static PyObject
*WinObj_GetWindowKind(_self
, _args
)
1367 WindowObject
*_self
;
1370 PyObject
*_res
= NULL
;
1372 if (!PyArg_ParseTuple(_args
, ""))
1374 _rv
= GetWindowKind(_self
->ob_itself
);
1375 _res
= Py_BuildValue("h",
1380 static PyObject
*WinObj_SetWindowKind(_self
, _args
)
1381 WindowObject
*_self
;
1384 PyObject
*_res
= NULL
;
1386 if (!PyArg_ParseTuple(_args
, "h",
1389 SetWindowKind(_self
->ob_itself
,
1396 static PyObject
*WinObj_IsWindowVisible(_self
, _args
)
1397 WindowObject
*_self
;
1400 PyObject
*_res
= NULL
;
1402 if (!PyArg_ParseTuple(_args
, ""))
1404 _rv
= IsWindowVisible(_self
->ob_itself
);
1405 _res
= Py_BuildValue("b",
1410 static PyObject
*WinObj_IsWindowHilited(_self
, _args
)
1411 WindowObject
*_self
;
1414 PyObject
*_res
= NULL
;
1416 if (!PyArg_ParseTuple(_args
, ""))
1418 _rv
= IsWindowHilited(_self
->ob_itself
);
1419 _res
= Py_BuildValue("b",
1424 static PyObject
*WinObj_GetWindowGoAwayFlag(_self
, _args
)
1425 WindowObject
*_self
;
1428 PyObject
*_res
= NULL
;
1430 if (!PyArg_ParseTuple(_args
, ""))
1432 _rv
= GetWindowGoAwayFlag(_self
->ob_itself
);
1433 _res
= Py_BuildValue("b",
1438 static PyObject
*WinObj_GetWindowZoomFlag(_self
, _args
)
1439 WindowObject
*_self
;
1442 PyObject
*_res
= NULL
;
1444 if (!PyArg_ParseTuple(_args
, ""))
1446 _rv
= GetWindowZoomFlag(_self
->ob_itself
);
1447 _res
= Py_BuildValue("b",
1452 static PyObject
*WinObj_GetWindowStructureRgn(_self
, _args
)
1453 WindowObject
*_self
;
1456 PyObject
*_res
= NULL
;
1458 if (!PyArg_ParseTuple(_args
, "O&",
1459 ResObj_Convert
, &r
))
1461 GetWindowStructureRgn(_self
->ob_itself
,
1468 static PyObject
*WinObj_GetWindowContentRgn(_self
, _args
)
1469 WindowObject
*_self
;
1472 PyObject
*_res
= NULL
;
1474 if (!PyArg_ParseTuple(_args
, "O&",
1475 ResObj_Convert
, &r
))
1477 GetWindowContentRgn(_self
->ob_itself
,
1484 static PyObject
*WinObj_GetWindowUpdateRgn(_self
, _args
)
1485 WindowObject
*_self
;
1488 PyObject
*_res
= NULL
;
1490 if (!PyArg_ParseTuple(_args
, "O&",
1491 ResObj_Convert
, &r
))
1493 GetWindowUpdateRgn(_self
->ob_itself
,
1500 static PyObject
*WinObj_GetWindowTitleWidth(_self
, _args
)
1501 WindowObject
*_self
;
1504 PyObject
*_res
= NULL
;
1506 if (!PyArg_ParseTuple(_args
, ""))
1508 _rv
= GetWindowTitleWidth(_self
->ob_itself
);
1509 _res
= Py_BuildValue("h",
1514 static PyObject
*WinObj_GetNextWindow(_self
, _args
)
1515 WindowObject
*_self
;
1518 PyObject
*_res
= NULL
;
1520 if (!PyArg_ParseTuple(_args
, ""))
1522 _rv
= GetNextWindow(_self
->ob_itself
);
1523 _res
= Py_BuildValue("O&",
1524 WinObj_WhichWindow
, _rv
);
1528 static PyObject
*WinObj_GetWindowStandardState(_self
, _args
)
1529 WindowObject
*_self
;
1532 PyObject
*_res
= NULL
;
1534 if (!PyArg_ParseTuple(_args
, ""))
1536 GetWindowStandardState(_self
->ob_itself
,
1538 _res
= Py_BuildValue("O&",
1539 PyMac_BuildRect
, &r
);
1543 static PyObject
*WinObj_GetWindowUserState(_self
, _args
)
1544 WindowObject
*_self
;
1547 PyObject
*_res
= NULL
;
1549 if (!PyArg_ParseTuple(_args
, ""))
1551 GetWindowUserState(_self
->ob_itself
,
1553 _res
= Py_BuildValue("O&",
1554 PyMac_BuildRect
, &r
);
1558 static PyObject
*WinObj_SetWindowStandardState(_self
, _args
)
1559 WindowObject
*_self
;
1562 PyObject
*_res
= NULL
;
1564 if (!PyArg_ParseTuple(_args
, "O&",
1567 SetWindowStandardState(_self
->ob_itself
,
1574 static PyObject
*WinObj_SetWindowUserState(_self
, _args
)
1575 WindowObject
*_self
;
1578 PyObject
*_res
= NULL
;
1580 if (!PyArg_ParseTuple(_args
, "O&",
1583 SetWindowUserState(_self
->ob_itself
,
1590 static PyObject
*WinObj_GetWindowDataHandle(_self
, _args
)
1591 WindowObject
*_self
;
1594 PyObject
*_res
= NULL
;
1596 if (!PyArg_ParseTuple(_args
, ""))
1598 _rv
= GetWindowDataHandle(_self
->ob_itself
);
1599 _res
= Py_BuildValue("O&",
1604 static PyObject
*WinObj_SetWindowDataHandle(_self
, _args
)
1605 WindowObject
*_self
;
1608 PyObject
*_res
= NULL
;
1610 if (!PyArg_ParseTuple(_args
, "O&",
1611 ResObj_Convert
, &data
))
1613 SetWindowDataHandle(_self
->ob_itself
,
1620 static PyObject
*WinObj_CloseWindow(_self
, _args
)
1621 WindowObject
*_self
;
1624 PyObject
*_res
= NULL
;
1625 if (!PyArg_ParseTuple(_args
, ""))
1627 CloseWindow(_self
->ob_itself
);
1633 static PyObject
*WinObj_MoveWindow(_self
, _args
)
1634 WindowObject
*_self
;
1637 PyObject
*_res
= NULL
;
1641 if (!PyArg_ParseTuple(_args
, "hhb",
1646 MoveWindow(_self
->ob_itself
,
1655 static PyObject
*WinObj_ShowWindow(_self
, _args
)
1656 WindowObject
*_self
;
1659 PyObject
*_res
= NULL
;
1660 if (!PyArg_ParseTuple(_args
, ""))
1662 ShowWindow(_self
->ob_itself
);
1668 static PyMethodDef WinObj_methods
[] = {
1669 {"MacCloseWindow", (PyCFunction
)WinObj_MacCloseWindow
, 1,
1671 {"GetWindowOwnerCount", (PyCFunction
)WinObj_GetWindowOwnerCount
, 1,
1672 "() -> (UInt32 outCount)"},
1673 {"CloneWindow", (PyCFunction
)WinObj_CloneWindow
, 1,
1675 {"GetWindowClass", (PyCFunction
)WinObj_GetWindowClass
, 1,
1676 "() -> (WindowClass outClass)"},
1677 {"GetWindowAttributes", (PyCFunction
)WinObj_GetWindowAttributes
, 1,
1678 "() -> (WindowAttributes outAttributes)"},
1679 {"SetWinColor", (PyCFunction
)WinObj_SetWinColor
, 1,
1680 "(WCTabHandle newColorTable) -> None"},
1681 {"SetWindowContentColor", (PyCFunction
)WinObj_SetWindowContentColor
, 1,
1682 "() -> (RGBColor color)"},
1683 {"GetWindowContentColor", (PyCFunction
)WinObj_GetWindowContentColor
, 1,
1684 "() -> (RGBColor color)"},
1685 {"GetWindowContentPattern", (PyCFunction
)WinObj_GetWindowContentPattern
, 1,
1686 "(PixPatHandle outPixPat) -> None"},
1687 {"SetWindowContentPattern", (PyCFunction
)WinObj_SetWindowContentPattern
, 1,
1688 "(PixPatHandle pixPat) -> None"},
1689 {"ClipAbove", (PyCFunction
)WinObj_ClipAbove
, 1,
1691 {"SaveOld", (PyCFunction
)WinObj_SaveOld
, 1,
1693 {"DrawNew", (PyCFunction
)WinObj_DrawNew
, 1,
1694 "(Boolean update) -> None"},
1695 {"PaintOne", (PyCFunction
)WinObj_PaintOne
, 1,
1696 "(RgnHandle clobberedRgn) -> None"},
1697 {"PaintBehind", (PyCFunction
)WinObj_PaintBehind
, 1,
1698 "(RgnHandle clobberedRgn) -> None"},
1699 {"CalcVis", (PyCFunction
)WinObj_CalcVis
, 1,
1701 {"CalcVisBehind", (PyCFunction
)WinObj_CalcVisBehind
, 1,
1702 "(RgnHandle clobberedRgn) -> None"},
1703 {"BringToFront", (PyCFunction
)WinObj_BringToFront
, 1,
1705 {"SendBehind", (PyCFunction
)WinObj_SendBehind
, 1,
1706 "(WindowPtr behindWindow) -> None"},
1707 {"SelectWindow", (PyCFunction
)WinObj_SelectWindow
, 1,
1709 {"HiliteWindow", (PyCFunction
)WinObj_HiliteWindow
, 1,
1710 "(Boolean fHilite) -> None"},
1711 {"SetWRefCon", (PyCFunction
)WinObj_SetWRefCon
, 1,
1712 "(long data) -> None"},
1713 {"GetWRefCon", (PyCFunction
)WinObj_GetWRefCon
, 1,
1714 "() -> (long _rv)"},
1715 {"SetWindowPic", (PyCFunction
)WinObj_SetWindowPic
, 1,
1716 "(PicHandle pic) -> None"},
1717 {"GetWindowPic", (PyCFunction
)WinObj_GetWindowPic
, 1,
1718 "() -> (PicHandle _rv)"},
1719 {"GetWVariant", (PyCFunction
)WinObj_GetWVariant
, 1,
1720 "() -> (short _rv)"},
1721 {"GetWindowFeatures", (PyCFunction
)WinObj_GetWindowFeatures
, 1,
1722 "() -> (UInt32 outFeatures)"},
1723 {"GetWindowRegion", (PyCFunction
)WinObj_GetWindowRegion
, 1,
1724 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
1725 {"BeginUpdate", (PyCFunction
)WinObj_BeginUpdate
, 1,
1727 {"EndUpdate", (PyCFunction
)WinObj_EndUpdate
, 1,
1729 {"InvalWindowRgn", (PyCFunction
)WinObj_InvalWindowRgn
, 1,
1730 "(RgnHandle region) -> None"},
1731 {"InvalWindowRect", (PyCFunction
)WinObj_InvalWindowRect
, 1,
1732 "(Rect bounds) -> None"},
1733 {"ValidWindowRgn", (PyCFunction
)WinObj_ValidWindowRgn
, 1,
1734 "(RgnHandle region) -> None"},
1735 {"ValidWindowRect", (PyCFunction
)WinObj_ValidWindowRect
, 1,
1736 "(Rect bounds) -> None"},
1737 {"DrawGrowIcon", (PyCFunction
)WinObj_DrawGrowIcon
, 1,
1739 {"SetWTitle", (PyCFunction
)WinObj_SetWTitle
, 1,
1740 "(Str255 title) -> None"},
1741 {"GetWTitle", (PyCFunction
)WinObj_GetWTitle
, 1,
1742 "() -> (Str255 title)"},
1743 {"SetWindowProxyFSSpec", (PyCFunction
)WinObj_SetWindowProxyFSSpec
, 1,
1744 "(FSSpec inFile) -> None"},
1745 {"GetWindowProxyFSSpec", (PyCFunction
)WinObj_GetWindowProxyFSSpec
, 1,
1746 "() -> (FSSpec outFile)"},
1747 {"SetWindowProxyAlias", (PyCFunction
)WinObj_SetWindowProxyAlias
, 1,
1748 "(AliasHandle alias) -> None"},
1749 {"GetWindowProxyAlias", (PyCFunction
)WinObj_GetWindowProxyAlias
, 1,
1750 "() -> (AliasHandle alias)"},
1751 {"SetWindowProxyCreatorAndType", (PyCFunction
)WinObj_SetWindowProxyCreatorAndType
, 1,
1752 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
1753 {"GetWindowProxyIcon", (PyCFunction
)WinObj_GetWindowProxyIcon
, 1,
1754 "() -> (IconRef outIcon)"},
1755 {"SetWindowProxyIcon", (PyCFunction
)WinObj_SetWindowProxyIcon
, 1,
1756 "(IconRef icon) -> None"},
1757 {"RemoveWindowProxy", (PyCFunction
)WinObj_RemoveWindowProxy
, 1,
1759 {"TrackWindowProxyDrag", (PyCFunction
)WinObj_TrackWindowProxyDrag
, 1,
1760 "(Point startPt) -> None"},
1761 {"IsWindowModified", (PyCFunction
)WinObj_IsWindowModified
, 1,
1762 "() -> (Boolean _rv)"},
1763 {"SetWindowModified", (PyCFunction
)WinObj_SetWindowModified
, 1,
1764 "(Boolean modified) -> None"},
1765 {"IsWindowPathSelectClick", (PyCFunction
)WinObj_IsWindowPathSelectClick
, 1,
1766 "() -> (Boolean _rv, EventRecord event)"},
1767 {"HiliteWindowFrameForDrag", (PyCFunction
)WinObj_HiliteWindowFrameForDrag
, 1,
1768 "(Boolean hilited) -> None"},
1769 {"TransitionWindow", (PyCFunction
)WinObj_TransitionWindow
, 1,
1770 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
1771 {"MacMoveWindow", (PyCFunction
)WinObj_MacMoveWindow
, 1,
1772 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1773 {"SizeWindow", (PyCFunction
)WinObj_SizeWindow
, 1,
1774 "(short w, short h, Boolean fUpdate) -> None"},
1775 {"GrowWindow", (PyCFunction
)WinObj_GrowWindow
, 1,
1776 "(Point startPt, Rect bBox) -> (long _rv)"},
1777 {"DragWindow", (PyCFunction
)WinObj_DragWindow
, 1,
1778 "(Point startPt, Rect boundsRect) -> None"},
1779 {"ZoomWindow", (PyCFunction
)WinObj_ZoomWindow
, 1,
1780 "(short partCode, Boolean front) -> None"},
1781 {"IsWindowCollapsable", (PyCFunction
)WinObj_IsWindowCollapsable
, 1,
1782 "() -> (Boolean _rv)"},
1783 {"IsWindowCollapsed", (PyCFunction
)WinObj_IsWindowCollapsed
, 1,
1784 "() -> (Boolean _rv)"},
1785 {"CollapseWindow", (PyCFunction
)WinObj_CollapseWindow
, 1,
1786 "(Boolean collapse) -> None"},
1787 {"RepositionWindow", (PyCFunction
)WinObj_RepositionWindow
, 1,
1788 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
1789 {"SetWindowBounds", (PyCFunction
)WinObj_SetWindowBounds
, 1,
1790 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
1791 {"GetWindowBounds", (PyCFunction
)WinObj_GetWindowBounds
, 1,
1792 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
1793 {"MoveWindowStructure", (PyCFunction
)WinObj_MoveWindowStructure
, 1,
1794 "(short hGlobal, short vGlobal) -> None"},
1795 {"IsWindowInStandardState", (PyCFunction
)WinObj_IsWindowInStandardState
, 1,
1796 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
1797 {"ZoomWindowIdeal", (PyCFunction
)WinObj_ZoomWindowIdeal
, 1,
1798 "(SInt16 partCode) -> (Point ioIdealSize)"},
1799 {"GetWindowIdealUserState", (PyCFunction
)WinObj_GetWindowIdealUserState
, 1,
1800 "() -> (Rect userState)"},
1801 {"SetWindowIdealUserState", (PyCFunction
)WinObj_SetWindowIdealUserState
, 1,
1802 "() -> (Rect userState)"},
1803 {"HideWindow", (PyCFunction
)WinObj_HideWindow
, 1,
1805 {"MacShowWindow", (PyCFunction
)WinObj_MacShowWindow
, 1,
1807 {"ShowHide", (PyCFunction
)WinObj_ShowHide
, 1,
1808 "(Boolean showFlag) -> None"},
1809 {"TrackBox", (PyCFunction
)WinObj_TrackBox
, 1,
1810 "(Point thePt, short partCode) -> (Boolean _rv)"},
1811 {"TrackGoAway", (PyCFunction
)WinObj_TrackGoAway
, 1,
1812 "(Point thePt) -> (Boolean _rv)"},
1813 {"GetAuxWin", (PyCFunction
)WinObj_GetAuxWin
, 1,
1814 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
1815 {"GetWindowPort", (PyCFunction
)WinObj_GetWindowPort
, 1,
1816 "() -> (CGrafPtr _rv)"},
1817 {"SetPortWindowPort", (PyCFunction
)WinObj_SetPortWindowPort
, 1,
1819 {"GetWindowKind", (PyCFunction
)WinObj_GetWindowKind
, 1,
1820 "() -> (short _rv)"},
1821 {"SetWindowKind", (PyCFunction
)WinObj_SetWindowKind
, 1,
1822 "(short wKind) -> None"},
1823 {"IsWindowVisible", (PyCFunction
)WinObj_IsWindowVisible
, 1,
1824 "() -> (Boolean _rv)"},
1825 {"IsWindowHilited", (PyCFunction
)WinObj_IsWindowHilited
, 1,
1826 "() -> (Boolean _rv)"},
1827 {"GetWindowGoAwayFlag", (PyCFunction
)WinObj_GetWindowGoAwayFlag
, 1,
1828 "() -> (Boolean _rv)"},
1829 {"GetWindowZoomFlag", (PyCFunction
)WinObj_GetWindowZoomFlag
, 1,
1830 "() -> (Boolean _rv)"},
1831 {"GetWindowStructureRgn", (PyCFunction
)WinObj_GetWindowStructureRgn
, 1,
1832 "(RgnHandle r) -> None"},
1833 {"GetWindowContentRgn", (PyCFunction
)WinObj_GetWindowContentRgn
, 1,
1834 "(RgnHandle r) -> None"},
1835 {"GetWindowUpdateRgn", (PyCFunction
)WinObj_GetWindowUpdateRgn
, 1,
1836 "(RgnHandle r) -> None"},
1837 {"GetWindowTitleWidth", (PyCFunction
)WinObj_GetWindowTitleWidth
, 1,
1838 "() -> (short _rv)"},
1839 {"GetNextWindow", (PyCFunction
)WinObj_GetNextWindow
, 1,
1840 "() -> (WindowPtr _rv)"},
1841 {"GetWindowStandardState", (PyCFunction
)WinObj_GetWindowStandardState
, 1,
1843 {"GetWindowUserState", (PyCFunction
)WinObj_GetWindowUserState
, 1,
1845 {"SetWindowStandardState", (PyCFunction
)WinObj_SetWindowStandardState
, 1,
1846 "(Rect r) -> None"},
1847 {"SetWindowUserState", (PyCFunction
)WinObj_SetWindowUserState
, 1,
1848 "(Rect r) -> None"},
1849 {"GetWindowDataHandle", (PyCFunction
)WinObj_GetWindowDataHandle
, 1,
1850 "() -> (Handle _rv)"},
1851 {"SetWindowDataHandle", (PyCFunction
)WinObj_SetWindowDataHandle
, 1,
1852 "(Handle data) -> None"},
1853 {"CloseWindow", (PyCFunction
)WinObj_CloseWindow
, 1,
1855 {"MoveWindow", (PyCFunction
)WinObj_MoveWindow
, 1,
1856 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1857 {"ShowWindow", (PyCFunction
)WinObj_ShowWindow
, 1,
1862 PyMethodChain WinObj_chain
= { WinObj_methods
, NULL
};
1864 static PyObject
*WinObj_getattr(self
, name
)
1868 return Py_FindMethodInChain(&WinObj_chain
, (PyObject
*)self
, name
);
1871 #define WinObj_setattr NULL
1873 #define WinObj_compare NULL
1875 #define WinObj_repr NULL
1877 #define WinObj_hash NULL
1879 PyTypeObject Window_Type
= {
1880 PyObject_HEAD_INIT(&PyType_Type
)
1882 "Window", /*tp_name*/
1883 sizeof(WindowObject
), /*tp_basicsize*/
1886 (destructor
) WinObj_dealloc
, /*tp_dealloc*/
1888 (getattrfunc
) WinObj_getattr
, /*tp_getattr*/
1889 (setattrfunc
) WinObj_setattr
, /*tp_setattr*/
1890 (cmpfunc
) WinObj_compare
, /*tp_compare*/
1891 (reprfunc
) WinObj_repr
, /*tp_repr*/
1892 (PyNumberMethods
*)0, /* tp_as_number */
1893 (PySequenceMethods
*)0, /* tp_as_sequence */
1894 (PyMappingMethods
*)0, /* tp_as_mapping */
1895 (hashfunc
) WinObj_hash
, /*tp_hash*/
1898 /* --------------------- End object type Window --------------------- */
1901 static PyObject
*Win_GetNewCWindow(_self
, _args
)
1905 PyObject
*_res
= NULL
;
1909 if (!PyArg_ParseTuple(_args
, "hO&",
1911 WinObj_Convert
, &behind
))
1913 _rv
= GetNewCWindow(windowID
,
1916 _res
= Py_BuildValue("O&",
1921 static PyObject
*Win_NewWindow(_self
, _args
)
1925 PyObject
*_res
= NULL
;
1934 if (!PyArg_ParseTuple(_args
, "O&O&bhO&bl",
1935 PyMac_GetRect
, &boundsRect
,
1936 PyMac_GetStr255
, title
,
1939 WinObj_Convert
, &behind
,
1943 _rv
= NewWindow((void *)0,
1951 _res
= Py_BuildValue("O&",
1956 static PyObject
*Win_GetNewWindow(_self
, _args
)
1960 PyObject
*_res
= NULL
;
1964 if (!PyArg_ParseTuple(_args
, "hO&",
1966 WinObj_Convert
, &behind
))
1968 _rv
= GetNewWindow(windowID
,
1971 _res
= Py_BuildValue("O&",
1976 static PyObject
*Win_NewCWindow(_self
, _args
)
1980 PyObject
*_res
= NULL
;
1989 if (!PyArg_ParseTuple(_args
, "O&O&bhO&bl",
1990 PyMac_GetRect
, &boundsRect
,
1991 PyMac_GetStr255
, title
,
1994 WinObj_Convert
, &behind
,
1998 _rv
= NewCWindow((void *)0,
2006 _res
= Py_BuildValue("O&",
2011 static PyObject
*Win_CreateNewWindow(_self
, _args
)
2015 PyObject
*_res
= NULL
;
2017 WindowClass windowClass
;
2018 WindowAttributes attributes
;
2020 WindowPtr outWindow
;
2021 if (!PyArg_ParseTuple(_args
, "llO&",
2024 PyMac_GetRect
, &bounds
))
2026 _err
= CreateNewWindow(windowClass
,
2030 if (_err
!= noErr
) return PyMac_Error(_err
);
2031 _res
= Py_BuildValue("O&",
2032 WinObj_WhichWindow
, outWindow
);
2036 static PyObject
*Win_CreateWindowFromResource(_self
, _args
)
2040 PyObject
*_res
= NULL
;
2043 WindowPtr outWindow
;
2044 if (!PyArg_ParseTuple(_args
, "h",
2047 _err
= CreateWindowFromResource(resID
,
2049 if (_err
!= noErr
) return PyMac_Error(_err
);
2050 _res
= Py_BuildValue("O&",
2051 WinObj_WhichWindow
, outWindow
);
2055 static PyObject
*Win_ShowFloatingWindows(_self
, _args
)
2059 PyObject
*_res
= NULL
;
2061 if (!PyArg_ParseTuple(_args
, ""))
2063 _err
= ShowFloatingWindows();
2064 if (_err
!= noErr
) return PyMac_Error(_err
);
2070 static PyObject
*Win_HideFloatingWindows(_self
, _args
)
2074 PyObject
*_res
= NULL
;
2076 if (!PyArg_ParseTuple(_args
, ""))
2078 _err
= HideFloatingWindows();
2079 if (_err
!= noErr
) return PyMac_Error(_err
);
2085 static PyObject
*Win_AreFloatingWindowsVisible(_self
, _args
)
2089 PyObject
*_res
= NULL
;
2091 if (!PyArg_ParseTuple(_args
, ""))
2093 _rv
= AreFloatingWindowsVisible();
2094 _res
= Py_BuildValue("b",
2099 static PyObject
*Win_FrontNonFloatingWindow(_self
, _args
)
2103 PyObject
*_res
= NULL
;
2105 if (!PyArg_ParseTuple(_args
, ""))
2107 _rv
= FrontNonFloatingWindow();
2108 _res
= Py_BuildValue("O&",
2113 static PyObject
*Win_SetDeskCPat(_self
, _args
)
2117 PyObject
*_res
= NULL
;
2118 PixPatHandle deskPixPat
;
2119 if (!PyArg_ParseTuple(_args
, "O&",
2120 ResObj_Convert
, &deskPixPat
))
2122 SetDeskCPat(deskPixPat
);
2128 static PyObject
*Win_CheckUpdate(_self
, _args
)
2132 PyObject
*_res
= NULL
;
2134 EventRecord theEvent
;
2135 if (!PyArg_ParseTuple(_args
, ""))
2137 _rv
= CheckUpdate(&theEvent
);
2138 _res
= Py_BuildValue("bO&",
2140 PyMac_BuildEventRecord
, &theEvent
);
2144 static PyObject
*Win_MacFindWindow(_self
, _args
)
2148 PyObject
*_res
= NULL
;
2152 if (!PyArg_ParseTuple(_args
, "O&",
2153 PyMac_GetPoint
, &thePoint
))
2155 _rv
= MacFindWindow(thePoint
,
2157 _res
= Py_BuildValue("hO&",
2159 WinObj_WhichWindow
, window
);
2163 static PyObject
*Win_FrontWindow(_self
, _args
)
2167 PyObject
*_res
= NULL
;
2169 if (!PyArg_ParseTuple(_args
, ""))
2171 _rv
= FrontWindow();
2172 _res
= Py_BuildValue("O&",
2173 WinObj_WhichWindow
, _rv
);
2177 static PyObject
*Win_InitWindows(_self
, _args
)
2181 PyObject
*_res
= NULL
;
2182 if (!PyArg_ParseTuple(_args
, ""))
2190 static PyObject
*Win_GetWMgrPort(_self
, _args
)
2194 PyObject
*_res
= NULL
;
2196 if (!PyArg_ParseTuple(_args
, ""))
2198 GetWMgrPort(&wPort
);
2199 _res
= Py_BuildValue("O&",
2200 GrafObj_New
, wPort
);
2204 static PyObject
*Win_GetCWMgrPort(_self
, _args
)
2208 PyObject
*_res
= NULL
;
2210 if (!PyArg_ParseTuple(_args
, ""))
2212 GetCWMgrPort(&wMgrCPort
);
2213 _res
= Py_BuildValue("O&",
2214 GrafObj_New
, wMgrCPort
);
2218 static PyObject
*Win_IsValidWindowPtr(_self
, _args
)
2222 PyObject
*_res
= NULL
;
2225 if (!PyArg_ParseTuple(_args
, "O&",
2226 GrafObj_Convert
, &grafPort
))
2228 _rv
= IsValidWindowPtr(grafPort
);
2229 _res
= Py_BuildValue("b",
2234 static PyObject
*Win_InitFloatingWindows(_self
, _args
)
2238 PyObject
*_res
= NULL
;
2240 if (!PyArg_ParseTuple(_args
, ""))
2242 _err
= InitFloatingWindows();
2243 if (_err
!= noErr
) return PyMac_Error(_err
);
2249 static PyObject
*Win_InvalRect(_self
, _args
)
2253 PyObject
*_res
= NULL
;
2255 if (!PyArg_ParseTuple(_args
, "O&",
2256 PyMac_GetRect
, &badRect
))
2258 InvalRect(&badRect
);
2264 static PyObject
*Win_InvalRgn(_self
, _args
)
2268 PyObject
*_res
= NULL
;
2270 if (!PyArg_ParseTuple(_args
, "O&",
2271 ResObj_Convert
, &badRgn
))
2279 static PyObject
*Win_ValidRect(_self
, _args
)
2283 PyObject
*_res
= NULL
;
2285 if (!PyArg_ParseTuple(_args
, "O&",
2286 PyMac_GetRect
, &goodRect
))
2288 ValidRect(&goodRect
);
2294 static PyObject
*Win_ValidRgn(_self
, _args
)
2298 PyObject
*_res
= NULL
;
2300 if (!PyArg_ParseTuple(_args
, "O&",
2301 ResObj_Convert
, &goodRgn
))
2309 static PyObject
*Win_CollapseAllWindows(_self
, _args
)
2313 PyObject
*_res
= NULL
;
2316 if (!PyArg_ParseTuple(_args
, "b",
2319 _err
= CollapseAllWindows(collapse
);
2320 if (_err
!= noErr
) return PyMac_Error(_err
);
2326 static PyObject
*Win_PinRect(_self
, _args
)
2330 PyObject
*_res
= NULL
;
2334 if (!PyArg_ParseTuple(_args
, "O&O&",
2335 PyMac_GetRect
, &theRect
,
2336 PyMac_GetPoint
, &thePt
))
2338 _rv
= PinRect(&theRect
,
2340 _res
= Py_BuildValue("l",
2345 static PyObject
*Win_GetGrayRgn(_self
, _args
)
2349 PyObject
*_res
= NULL
;
2351 if (!PyArg_ParseTuple(_args
, ""))
2354 _res
= Py_BuildValue("O&",
2359 static PyObject
*Win_WhichWindow(_self
, _args
)
2363 PyObject
*_res
= NULL
;
2367 if ( !PyArg_ParseTuple(_args
, "i", &ptr
) )
2369 return WinObj_WhichWindow((WindowPtr
)ptr
);
2373 static PyObject
*Win_FindWindow(_self
, _args
)
2377 PyObject
*_res
= NULL
;
2380 WindowPtr theWindow
;
2381 if (!PyArg_ParseTuple(_args
, "O&",
2382 PyMac_GetPoint
, &thePoint
))
2384 _rv
= FindWindow(thePoint
,
2386 _res
= Py_BuildValue("hO&",
2388 WinObj_WhichWindow
, theWindow
);
2392 static PyMethodDef Win_methods
[] = {
2393 {"GetNewCWindow", (PyCFunction
)Win_GetNewCWindow
, 1,
2394 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2395 {"NewWindow", (PyCFunction
)Win_NewWindow
, 1,
2396 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2397 {"GetNewWindow", (PyCFunction
)Win_GetNewWindow
, 1,
2398 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2399 {"NewCWindow", (PyCFunction
)Win_NewCWindow
, 1,
2400 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2401 {"CreateNewWindow", (PyCFunction
)Win_CreateNewWindow
, 1,
2402 "(WindowClass windowClass, WindowAttributes attributes, Rect bounds) -> (WindowPtr outWindow)"},
2403 {"CreateWindowFromResource", (PyCFunction
)Win_CreateWindowFromResource
, 1,
2404 "(SInt16 resID) -> (WindowPtr outWindow)"},
2405 {"ShowFloatingWindows", (PyCFunction
)Win_ShowFloatingWindows
, 1,
2407 {"HideFloatingWindows", (PyCFunction
)Win_HideFloatingWindows
, 1,
2409 {"AreFloatingWindowsVisible", (PyCFunction
)Win_AreFloatingWindowsVisible
, 1,
2410 "() -> (Boolean _rv)"},
2411 {"FrontNonFloatingWindow", (PyCFunction
)Win_FrontNonFloatingWindow
, 1,
2412 "() -> (WindowPtr _rv)"},
2413 {"SetDeskCPat", (PyCFunction
)Win_SetDeskCPat
, 1,
2414 "(PixPatHandle deskPixPat) -> None"},
2415 {"CheckUpdate", (PyCFunction
)Win_CheckUpdate
, 1,
2416 "() -> (Boolean _rv, EventRecord theEvent)"},
2417 {"MacFindWindow", (PyCFunction
)Win_MacFindWindow
, 1,
2418 "(Point thePoint) -> (short _rv, WindowPtr window)"},
2419 {"FrontWindow", (PyCFunction
)Win_FrontWindow
, 1,
2420 "() -> (WindowPtr _rv)"},
2421 {"InitWindows", (PyCFunction
)Win_InitWindows
, 1,
2423 {"GetWMgrPort", (PyCFunction
)Win_GetWMgrPort
, 1,
2424 "() -> (GrafPtr wPort)"},
2425 {"GetCWMgrPort", (PyCFunction
)Win_GetCWMgrPort
, 1,
2426 "() -> (CGrafPtr wMgrCPort)"},
2427 {"IsValidWindowPtr", (PyCFunction
)Win_IsValidWindowPtr
, 1,
2428 "(GrafPtr grafPort) -> (Boolean _rv)"},
2429 {"InitFloatingWindows", (PyCFunction
)Win_InitFloatingWindows
, 1,
2431 {"InvalRect", (PyCFunction
)Win_InvalRect
, 1,
2432 "(Rect badRect) -> None"},
2433 {"InvalRgn", (PyCFunction
)Win_InvalRgn
, 1,
2434 "(RgnHandle badRgn) -> None"},
2435 {"ValidRect", (PyCFunction
)Win_ValidRect
, 1,
2436 "(Rect goodRect) -> None"},
2437 {"ValidRgn", (PyCFunction
)Win_ValidRgn
, 1,
2438 "(RgnHandle goodRgn) -> None"},
2439 {"CollapseAllWindows", (PyCFunction
)Win_CollapseAllWindows
, 1,
2440 "(Boolean collapse) -> None"},
2441 {"PinRect", (PyCFunction
)Win_PinRect
, 1,
2442 "(Rect theRect, Point thePt) -> (long _rv)"},
2443 {"GetGrayRgn", (PyCFunction
)Win_GetGrayRgn
, 1,
2444 "() -> (RgnHandle _rv)"},
2445 {"WhichWindow", (PyCFunction
)Win_WhichWindow
, 1,
2446 "Resolve an integer WindowPtr address to a Window object"},
2447 {"FindWindow", (PyCFunction
)Win_FindWindow
, 1,
2448 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
2454 /* Return the object corresponding to the window, or NULL */
2457 WinObj_WhichWindow(w
)
2462 /* XXX What if we find a stdwin window or a window belonging
2463 to some other package? */
2467 it
= (PyObject
*) GetWRefCon(w
);
2468 if (it
== NULL
|| ((WindowObject
*)it
)->ob_itself
!= w
)
2483 m
= Py_InitModule("Win", Win_methods
);
2484 d
= PyModule_GetDict(m
);
2485 Win_Error
= PyMac_GetOSErrException();
2486 if (Win_Error
== NULL
||
2487 PyDict_SetItemString(d
, "Error", Win_Error
) != 0)
2488 Py_FatalError("can't initialize Win.Error");
2489 Window_Type
.ob_type
= &PyType_Type
;
2490 Py_INCREF(&Window_Type
);
2491 if (PyDict_SetItemString(d
, "WindowType", (PyObject
*)&Window_Type
) != 0)
2492 Py_FatalError("can't initialize WindowType");
2495 /* ========================= End module Win ========================= */