Fix three PyChecker-detected gotchas.
[python/dscho.git] / Mac / Modules / win / Winmodule.c
blob00d58a48ae9d7de17474b514b1a86eeb4714e39a
2 /* =========================== Module Win =========================== */
4 #include "Python.h"
8 #include "macglue.h"
9 #include "pymactoolbox.h"
11 #include <Windows.h>
13 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
14 /* Carbon calls that we emulate in classic mode */
15 #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
16 #define GetWindowFromPort(port) ((WindowRef)(port))
17 #define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
18 #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
26 /* Function to dispose a window, with a "normal" calling sequence */
27 static void
28 PyMac_AutoDisposeWindow(WindowPtr w)
30 DisposeWindow(w);
33 static PyObject *Win_Error;
35 /* ----------------------- Object type Window ----------------------- */
37 PyTypeObject Window_Type;
39 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
41 typedef struct WindowObject {
42 PyObject_HEAD
43 WindowPtr ob_itself;
44 void (*ob_freeit)(WindowPtr ptr);
45 } WindowObject;
47 PyObject *WinObj_New(itself)
48 WindowPtr itself;
50 WindowObject *it;
51 if (itself == NULL) return PyMac_Error(resNotFound);
52 it = PyObject_NEW(WindowObject, &Window_Type);
53 if (it == NULL) return NULL;
54 it->ob_itself = itself;
55 it->ob_freeit = NULL;
56 if (GetWRefCon(itself) == 0)
58 SetWRefCon(itself, (long)it);
59 it->ob_freeit = PyMac_AutoDisposeWindow;
61 return (PyObject *)it;
63 WinObj_Convert(v, p_itself)
64 PyObject *v;
65 WindowPtr *p_itself;
67 if (DlgObj_Check(v)) {
68 *p_itself = DlgObj_ConvertToWindow(v);
69 return 1;
72 if (v == Py_None) { *p_itself = NULL; return 1; }
73 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
75 if (!WinObj_Check(v))
77 PyErr_SetString(PyExc_TypeError, "Window required");
78 return 0;
80 *p_itself = ((WindowObject *)v)->ob_itself;
81 return 1;
84 static void WinObj_dealloc(self)
85 WindowObject *self;
87 if (self->ob_freeit && self->ob_itself)
89 SetWRefCon(self->ob_itself, 0);
90 self->ob_freeit(self->ob_itself);
92 self->ob_itself = NULL;
93 self->ob_freeit = NULL;
94 PyMem_DEL(self);
97 static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
98 WindowObject *_self;
99 PyObject *_args;
101 PyObject *_res = NULL;
102 OSStatus _err;
103 UInt32 outCount;
104 if (!PyArg_ParseTuple(_args, ""))
105 return NULL;
106 _err = GetWindowOwnerCount(_self->ob_itself,
107 &outCount);
108 if (_err != noErr) return PyMac_Error(_err);
109 _res = Py_BuildValue("l",
110 outCount);
111 return _res;
114 static PyObject *WinObj_CloneWindow(_self, _args)
115 WindowObject *_self;
116 PyObject *_args;
118 PyObject *_res = NULL;
119 OSStatus _err;
120 if (!PyArg_ParseTuple(_args, ""))
121 return NULL;
122 _err = CloneWindow(_self->ob_itself);
123 if (_err != noErr) return PyMac_Error(_err);
124 Py_INCREF(Py_None);
125 _res = Py_None;
126 return _res;
129 #if TARGET_API_MAC_CARBON
131 static PyObject *WinObj_ReshapeCustomWindow(_self, _args)
132 WindowObject *_self;
133 PyObject *_args;
135 PyObject *_res = NULL;
136 OSStatus _err;
137 if (!PyArg_ParseTuple(_args, ""))
138 return NULL;
139 _err = ReshapeCustomWindow(_self->ob_itself);
140 if (_err != noErr) return PyMac_Error(_err);
141 Py_INCREF(Py_None);
142 _res = Py_None;
143 return _res;
145 #endif
147 static PyObject *WinObj_GetWindowClass(_self, _args)
148 WindowObject *_self;
149 PyObject *_args;
151 PyObject *_res = NULL;
152 OSStatus _err;
153 WindowClass outClass;
154 if (!PyArg_ParseTuple(_args, ""))
155 return NULL;
156 _err = GetWindowClass(_self->ob_itself,
157 &outClass);
158 if (_err != noErr) return PyMac_Error(_err);
159 _res = Py_BuildValue("l",
160 outClass);
161 return _res;
164 static PyObject *WinObj_GetWindowAttributes(_self, _args)
165 WindowObject *_self;
166 PyObject *_args;
168 PyObject *_res = NULL;
169 OSStatus _err;
170 WindowAttributes outAttributes;
171 if (!PyArg_ParseTuple(_args, ""))
172 return NULL;
173 _err = GetWindowAttributes(_self->ob_itself,
174 &outAttributes);
175 if (_err != noErr) return PyMac_Error(_err);
176 _res = Py_BuildValue("l",
177 outAttributes);
178 return _res;
181 #if TARGET_API_MAC_CARBON
183 static PyObject *WinObj_ChangeWindowAttributes(_self, _args)
184 WindowObject *_self;
185 PyObject *_args;
187 PyObject *_res = NULL;
188 OSStatus _err;
189 WindowAttributes setTheseAttributes;
190 WindowAttributes clearTheseAttributes;
191 if (!PyArg_ParseTuple(_args, "ll",
192 &setTheseAttributes,
193 &clearTheseAttributes))
194 return NULL;
195 _err = ChangeWindowAttributes(_self->ob_itself,
196 setTheseAttributes,
197 clearTheseAttributes);
198 if (_err != noErr) return PyMac_Error(_err);
199 Py_INCREF(Py_None);
200 _res = Py_None;
201 return _res;
203 #endif
205 #if !TARGET_API_MAC_CARBON
207 static PyObject *WinObj_SetWinColor(_self, _args)
208 WindowObject *_self;
209 PyObject *_args;
211 PyObject *_res = NULL;
212 WCTabHandle newColorTable;
213 if (!PyArg_ParseTuple(_args, "O&",
214 ResObj_Convert, &newColorTable))
215 return NULL;
216 SetWinColor(_self->ob_itself,
217 newColorTable);
218 Py_INCREF(Py_None);
219 _res = Py_None;
220 return _res;
222 #endif
224 static PyObject *WinObj_SetWindowContentColor(_self, _args)
225 WindowObject *_self;
226 PyObject *_args;
228 PyObject *_res = NULL;
229 OSStatus _err;
230 RGBColor color;
231 if (!PyArg_ParseTuple(_args, "O&",
232 QdRGB_Convert, &color))
233 return NULL;
234 _err = SetWindowContentColor(_self->ob_itself,
235 &color);
236 if (_err != noErr) return PyMac_Error(_err);
237 Py_INCREF(Py_None);
238 _res = Py_None;
239 return _res;
242 static PyObject *WinObj_GetWindowContentColor(_self, _args)
243 WindowObject *_self;
244 PyObject *_args;
246 PyObject *_res = NULL;
247 OSStatus _err;
248 RGBColor color;
249 if (!PyArg_ParseTuple(_args, ""))
250 return NULL;
251 _err = GetWindowContentColor(_self->ob_itself,
252 &color);
253 if (_err != noErr) return PyMac_Error(_err);
254 _res = Py_BuildValue("O&",
255 QdRGB_New, &color);
256 return _res;
259 static PyObject *WinObj_GetWindowContentPattern(_self, _args)
260 WindowObject *_self;
261 PyObject *_args;
263 PyObject *_res = NULL;
264 OSStatus _err;
265 PixPatHandle outPixPat;
266 if (!PyArg_ParseTuple(_args, "O&",
267 ResObj_Convert, &outPixPat))
268 return NULL;
269 _err = GetWindowContentPattern(_self->ob_itself,
270 outPixPat);
271 if (_err != noErr) return PyMac_Error(_err);
272 Py_INCREF(Py_None);
273 _res = Py_None;
274 return _res;
277 static PyObject *WinObj_SetWindowContentPattern(_self, _args)
278 WindowObject *_self;
279 PyObject *_args;
281 PyObject *_res = NULL;
282 OSStatus _err;
283 PixPatHandle pixPat;
284 if (!PyArg_ParseTuple(_args, "O&",
285 ResObj_Convert, &pixPat))
286 return NULL;
287 _err = SetWindowContentPattern(_self->ob_itself,
288 pixPat);
289 if (_err != noErr) return PyMac_Error(_err);
290 Py_INCREF(Py_None);
291 _res = Py_None;
292 return _res;
295 #if TARGET_API_MAC_CARBON
297 static PyObject *WinObj_ScrollWindowRect(_self, _args)
298 WindowObject *_self;
299 PyObject *_args;
301 PyObject *_res = NULL;
302 OSStatus _err;
303 Rect inScrollRect;
304 SInt16 inHPixels;
305 SInt16 inVPixels;
306 ScrollWindowOptions inOptions;
307 RgnHandle outExposedRgn;
308 if (!PyArg_ParseTuple(_args, "O&hhlO&",
309 PyMac_GetRect, &inScrollRect,
310 &inHPixels,
311 &inVPixels,
312 &inOptions,
313 ResObj_Convert, &outExposedRgn))
314 return NULL;
315 _err = ScrollWindowRect(_self->ob_itself,
316 &inScrollRect,
317 inHPixels,
318 inVPixels,
319 inOptions,
320 outExposedRgn);
321 if (_err != noErr) return PyMac_Error(_err);
322 Py_INCREF(Py_None);
323 _res = Py_None;
324 return _res;
326 #endif
328 #if TARGET_API_MAC_CARBON
330 static PyObject *WinObj_ScrollWindowRegion(_self, _args)
331 WindowObject *_self;
332 PyObject *_args;
334 PyObject *_res = NULL;
335 OSStatus _err;
336 RgnHandle inScrollRgn;
337 SInt16 inHPixels;
338 SInt16 inVPixels;
339 ScrollWindowOptions inOptions;
340 RgnHandle outExposedRgn;
341 if (!PyArg_ParseTuple(_args, "O&hhlO&",
342 ResObj_Convert, &inScrollRgn,
343 &inHPixels,
344 &inVPixels,
345 &inOptions,
346 ResObj_Convert, &outExposedRgn))
347 return NULL;
348 _err = ScrollWindowRegion(_self->ob_itself,
349 inScrollRgn,
350 inHPixels,
351 inVPixels,
352 inOptions,
353 outExposedRgn);
354 if (_err != noErr) return PyMac_Error(_err);
355 Py_INCREF(Py_None);
356 _res = Py_None;
357 return _res;
359 #endif
361 static PyObject *WinObj_ClipAbove(_self, _args)
362 WindowObject *_self;
363 PyObject *_args;
365 PyObject *_res = NULL;
366 if (!PyArg_ParseTuple(_args, ""))
367 return NULL;
368 ClipAbove(_self->ob_itself);
369 Py_INCREF(Py_None);
370 _res = Py_None;
371 return _res;
374 #if !TARGET_API_MAC_CARBON
376 static PyObject *WinObj_SaveOld(_self, _args)
377 WindowObject *_self;
378 PyObject *_args;
380 PyObject *_res = NULL;
381 if (!PyArg_ParseTuple(_args, ""))
382 return NULL;
383 SaveOld(_self->ob_itself);
384 Py_INCREF(Py_None);
385 _res = Py_None;
386 return _res;
388 #endif
390 #if !TARGET_API_MAC_CARBON
392 static PyObject *WinObj_DrawNew(_self, _args)
393 WindowObject *_self;
394 PyObject *_args;
396 PyObject *_res = NULL;
397 Boolean update;
398 if (!PyArg_ParseTuple(_args, "b",
399 &update))
400 return NULL;
401 DrawNew(_self->ob_itself,
402 update);
403 Py_INCREF(Py_None);
404 _res = Py_None;
405 return _res;
407 #endif
409 static PyObject *WinObj_PaintOne(_self, _args)
410 WindowObject *_self;
411 PyObject *_args;
413 PyObject *_res = NULL;
414 RgnHandle clobberedRgn;
415 if (!PyArg_ParseTuple(_args, "O&",
416 ResObj_Convert, &clobberedRgn))
417 return NULL;
418 PaintOne(_self->ob_itself,
419 clobberedRgn);
420 Py_INCREF(Py_None);
421 _res = Py_None;
422 return _res;
425 static PyObject *WinObj_PaintBehind(_self, _args)
426 WindowObject *_self;
427 PyObject *_args;
429 PyObject *_res = NULL;
430 RgnHandle clobberedRgn;
431 if (!PyArg_ParseTuple(_args, "O&",
432 ResObj_Convert, &clobberedRgn))
433 return NULL;
434 PaintBehind(_self->ob_itself,
435 clobberedRgn);
436 Py_INCREF(Py_None);
437 _res = Py_None;
438 return _res;
441 static PyObject *WinObj_CalcVis(_self, _args)
442 WindowObject *_self;
443 PyObject *_args;
445 PyObject *_res = NULL;
446 if (!PyArg_ParseTuple(_args, ""))
447 return NULL;
448 CalcVis(_self->ob_itself);
449 Py_INCREF(Py_None);
450 _res = Py_None;
451 return _res;
454 static PyObject *WinObj_CalcVisBehind(_self, _args)
455 WindowObject *_self;
456 PyObject *_args;
458 PyObject *_res = NULL;
459 RgnHandle clobberedRgn;
460 if (!PyArg_ParseTuple(_args, "O&",
461 ResObj_Convert, &clobberedRgn))
462 return NULL;
463 CalcVisBehind(_self->ob_itself,
464 clobberedRgn);
465 Py_INCREF(Py_None);
466 _res = Py_None;
467 return _res;
470 static PyObject *WinObj_BringToFront(_self, _args)
471 WindowObject *_self;
472 PyObject *_args;
474 PyObject *_res = NULL;
475 if (!PyArg_ParseTuple(_args, ""))
476 return NULL;
477 BringToFront(_self->ob_itself);
478 Py_INCREF(Py_None);
479 _res = Py_None;
480 return _res;
483 static PyObject *WinObj_SendBehind(_self, _args)
484 WindowObject *_self;
485 PyObject *_args;
487 PyObject *_res = NULL;
488 WindowPtr behindWindow;
489 if (!PyArg_ParseTuple(_args, "O&",
490 WinObj_Convert, &behindWindow))
491 return NULL;
492 SendBehind(_self->ob_itself,
493 behindWindow);
494 Py_INCREF(Py_None);
495 _res = Py_None;
496 return _res;
499 static PyObject *WinObj_SelectWindow(_self, _args)
500 WindowObject *_self;
501 PyObject *_args;
503 PyObject *_res = NULL;
504 if (!PyArg_ParseTuple(_args, ""))
505 return NULL;
506 SelectWindow(_self->ob_itself);
507 Py_INCREF(Py_None);
508 _res = Py_None;
509 return _res;
512 #if TARGET_API_MAC_CARBON
514 static PyObject *WinObj_GetNextWindowOfClass(_self, _args)
515 WindowObject *_self;
516 PyObject *_args;
518 PyObject *_res = NULL;
519 WindowPtr _rv;
520 WindowClass inWindowClass;
521 Boolean mustBeVisible;
522 if (!PyArg_ParseTuple(_args, "lb",
523 &inWindowClass,
524 &mustBeVisible))
525 return NULL;
526 _rv = GetNextWindowOfClass(_self->ob_itself,
527 inWindowClass,
528 mustBeVisible);
529 _res = Py_BuildValue("O&",
530 WinObj_New, _rv);
531 return _res;
533 #endif
535 #if !TARGET_API_MAC_CARBON
537 static PyObject *WinObj_IsValidWindowPtr(_self, _args)
538 WindowObject *_self;
539 PyObject *_args;
541 PyObject *_res = NULL;
542 Boolean _rv;
543 if (!PyArg_ParseTuple(_args, ""))
544 return NULL;
545 _rv = IsValidWindowPtr(_self->ob_itself);
546 _res = Py_BuildValue("b",
547 _rv);
548 return _res;
550 #endif
552 static PyObject *WinObj_HiliteWindow(_self, _args)
553 WindowObject *_self;
554 PyObject *_args;
556 PyObject *_res = NULL;
557 Boolean fHilite;
558 if (!PyArg_ParseTuple(_args, "b",
559 &fHilite))
560 return NULL;
561 HiliteWindow(_self->ob_itself,
562 fHilite);
563 Py_INCREF(Py_None);
564 _res = Py_None;
565 return _res;
568 static PyObject *WinObj_SetWRefCon(_self, _args)
569 WindowObject *_self;
570 PyObject *_args;
572 PyObject *_res = NULL;
573 long data;
574 if (!PyArg_ParseTuple(_args, "l",
575 &data))
576 return NULL;
577 SetWRefCon(_self->ob_itself,
578 data);
579 Py_INCREF(Py_None);
580 _res = Py_None;
581 return _res;
584 static PyObject *WinObj_GetWRefCon(_self, _args)
585 WindowObject *_self;
586 PyObject *_args;
588 PyObject *_res = NULL;
589 long _rv;
590 if (!PyArg_ParseTuple(_args, ""))
591 return NULL;
592 _rv = GetWRefCon(_self->ob_itself);
593 _res = Py_BuildValue("l",
594 _rv);
595 return _res;
598 static PyObject *WinObj_SetWindowPic(_self, _args)
599 WindowObject *_self;
600 PyObject *_args;
602 PyObject *_res = NULL;
603 PicHandle pic;
604 if (!PyArg_ParseTuple(_args, "O&",
605 ResObj_Convert, &pic))
606 return NULL;
607 SetWindowPic(_self->ob_itself,
608 pic);
609 Py_INCREF(Py_None);
610 _res = Py_None;
611 return _res;
614 static PyObject *WinObj_GetWindowPic(_self, _args)
615 WindowObject *_self;
616 PyObject *_args;
618 PyObject *_res = NULL;
619 PicHandle _rv;
620 if (!PyArg_ParseTuple(_args, ""))
621 return NULL;
622 _rv = GetWindowPic(_self->ob_itself);
623 _res = Py_BuildValue("O&",
624 ResObj_New, _rv);
625 return _res;
628 static PyObject *WinObj_GetWVariant(_self, _args)
629 WindowObject *_self;
630 PyObject *_args;
632 PyObject *_res = NULL;
633 short _rv;
634 if (!PyArg_ParseTuple(_args, ""))
635 return NULL;
636 _rv = GetWVariant(_self->ob_itself);
637 _res = Py_BuildValue("h",
638 _rv);
639 return _res;
642 static PyObject *WinObj_GetWindowFeatures(_self, _args)
643 WindowObject *_self;
644 PyObject *_args;
646 PyObject *_res = NULL;
647 OSStatus _err;
648 UInt32 outFeatures;
649 if (!PyArg_ParseTuple(_args, ""))
650 return NULL;
651 _err = GetWindowFeatures(_self->ob_itself,
652 &outFeatures);
653 if (_err != noErr) return PyMac_Error(_err);
654 _res = Py_BuildValue("l",
655 outFeatures);
656 return _res;
659 static PyObject *WinObj_GetWindowRegion(_self, _args)
660 WindowObject *_self;
661 PyObject *_args;
663 PyObject *_res = NULL;
664 OSStatus _err;
665 WindowRegionCode inRegionCode;
666 RgnHandle ioWinRgn;
667 if (!PyArg_ParseTuple(_args, "HO&",
668 &inRegionCode,
669 ResObj_Convert, &ioWinRgn))
670 return NULL;
671 _err = GetWindowRegion(_self->ob_itself,
672 inRegionCode,
673 ioWinRgn);
674 if (_err != noErr) return PyMac_Error(_err);
675 Py_INCREF(Py_None);
676 _res = Py_None;
677 return _res;
680 static PyObject *WinObj_BeginUpdate(_self, _args)
681 WindowObject *_self;
682 PyObject *_args;
684 PyObject *_res = NULL;
685 if (!PyArg_ParseTuple(_args, ""))
686 return NULL;
687 BeginUpdate(_self->ob_itself);
688 Py_INCREF(Py_None);
689 _res = Py_None;
690 return _res;
693 static PyObject *WinObj_EndUpdate(_self, _args)
694 WindowObject *_self;
695 PyObject *_args;
697 PyObject *_res = NULL;
698 if (!PyArg_ParseTuple(_args, ""))
699 return NULL;
700 EndUpdate(_self->ob_itself);
701 Py_INCREF(Py_None);
702 _res = Py_None;
703 return _res;
706 static PyObject *WinObj_InvalWindowRgn(_self, _args)
707 WindowObject *_self;
708 PyObject *_args;
710 PyObject *_res = NULL;
711 OSStatus _err;
712 RgnHandle region;
713 if (!PyArg_ParseTuple(_args, "O&",
714 ResObj_Convert, &region))
715 return NULL;
716 _err = InvalWindowRgn(_self->ob_itself,
717 region);
718 if (_err != noErr) return PyMac_Error(_err);
719 Py_INCREF(Py_None);
720 _res = Py_None;
721 return _res;
724 static PyObject *WinObj_InvalWindowRect(_self, _args)
725 WindowObject *_self;
726 PyObject *_args;
728 PyObject *_res = NULL;
729 OSStatus _err;
730 Rect bounds;
731 if (!PyArg_ParseTuple(_args, "O&",
732 PyMac_GetRect, &bounds))
733 return NULL;
734 _err = InvalWindowRect(_self->ob_itself,
735 &bounds);
736 if (_err != noErr) return PyMac_Error(_err);
737 Py_INCREF(Py_None);
738 _res = Py_None;
739 return _res;
742 static PyObject *WinObj_ValidWindowRgn(_self, _args)
743 WindowObject *_self;
744 PyObject *_args;
746 PyObject *_res = NULL;
747 OSStatus _err;
748 RgnHandle region;
749 if (!PyArg_ParseTuple(_args, "O&",
750 ResObj_Convert, &region))
751 return NULL;
752 _err = ValidWindowRgn(_self->ob_itself,
753 region);
754 if (_err != noErr) return PyMac_Error(_err);
755 Py_INCREF(Py_None);
756 _res = Py_None;
757 return _res;
760 static PyObject *WinObj_ValidWindowRect(_self, _args)
761 WindowObject *_self;
762 PyObject *_args;
764 PyObject *_res = NULL;
765 OSStatus _err;
766 Rect bounds;
767 if (!PyArg_ParseTuple(_args, "O&",
768 PyMac_GetRect, &bounds))
769 return NULL;
770 _err = ValidWindowRect(_self->ob_itself,
771 &bounds);
772 if (_err != noErr) return PyMac_Error(_err);
773 Py_INCREF(Py_None);
774 _res = Py_None;
775 return _res;
778 static PyObject *WinObj_DrawGrowIcon(_self, _args)
779 WindowObject *_self;
780 PyObject *_args;
782 PyObject *_res = NULL;
783 if (!PyArg_ParseTuple(_args, ""))
784 return NULL;
785 DrawGrowIcon(_self->ob_itself);
786 Py_INCREF(Py_None);
787 _res = Py_None;
788 return _res;
791 static PyObject *WinObj_SetWTitle(_self, _args)
792 WindowObject *_self;
793 PyObject *_args;
795 PyObject *_res = NULL;
796 Str255 title;
797 if (!PyArg_ParseTuple(_args, "O&",
798 PyMac_GetStr255, title))
799 return NULL;
800 SetWTitle(_self->ob_itself,
801 title);
802 Py_INCREF(Py_None);
803 _res = Py_None;
804 return _res;
807 static PyObject *WinObj_GetWTitle(_self, _args)
808 WindowObject *_self;
809 PyObject *_args;
811 PyObject *_res = NULL;
812 Str255 title;
813 if (!PyArg_ParseTuple(_args, ""))
814 return NULL;
815 GetWTitle(_self->ob_itself,
816 title);
817 _res = Py_BuildValue("O&",
818 PyMac_BuildStr255, title);
819 return _res;
822 static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
823 WindowObject *_self;
824 PyObject *_args;
826 PyObject *_res = NULL;
827 OSStatus _err;
828 FSSpec inFile;
829 if (!PyArg_ParseTuple(_args, "O&",
830 PyMac_GetFSSpec, &inFile))
831 return NULL;
832 _err = SetWindowProxyFSSpec(_self->ob_itself,
833 &inFile);
834 if (_err != noErr) return PyMac_Error(_err);
835 Py_INCREF(Py_None);
836 _res = Py_None;
837 return _res;
840 static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
841 WindowObject *_self;
842 PyObject *_args;
844 PyObject *_res = NULL;
845 OSStatus _err;
846 FSSpec outFile;
847 if (!PyArg_ParseTuple(_args, ""))
848 return NULL;
849 _err = GetWindowProxyFSSpec(_self->ob_itself,
850 &outFile);
851 if (_err != noErr) return PyMac_Error(_err);
852 _res = Py_BuildValue("O&",
853 PyMac_BuildFSSpec, outFile);
854 return _res;
857 static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
858 WindowObject *_self;
859 PyObject *_args;
861 PyObject *_res = NULL;
862 OSStatus _err;
863 AliasHandle alias;
864 if (!PyArg_ParseTuple(_args, "O&",
865 ResObj_Convert, &alias))
866 return NULL;
867 _err = SetWindowProxyAlias(_self->ob_itself,
868 alias);
869 if (_err != noErr) return PyMac_Error(_err);
870 Py_INCREF(Py_None);
871 _res = Py_None;
872 return _res;
875 static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
876 WindowObject *_self;
877 PyObject *_args;
879 PyObject *_res = NULL;
880 OSStatus _err;
881 AliasHandle alias;
882 if (!PyArg_ParseTuple(_args, ""))
883 return NULL;
884 _err = GetWindowProxyAlias(_self->ob_itself,
885 &alias);
886 if (_err != noErr) return PyMac_Error(_err);
887 _res = Py_BuildValue("O&",
888 ResObj_New, alias);
889 return _res;
892 static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
893 WindowObject *_self;
894 PyObject *_args;
896 PyObject *_res = NULL;
897 OSStatus _err;
898 OSType fileCreator;
899 OSType fileType;
900 SInt16 vRefNum;
901 if (!PyArg_ParseTuple(_args, "O&O&h",
902 PyMac_GetOSType, &fileCreator,
903 PyMac_GetOSType, &fileType,
904 &vRefNum))
905 return NULL;
906 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
907 fileCreator,
908 fileType,
909 vRefNum);
910 if (_err != noErr) return PyMac_Error(_err);
911 Py_INCREF(Py_None);
912 _res = Py_None;
913 return _res;
916 static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
917 WindowObject *_self;
918 PyObject *_args;
920 PyObject *_res = NULL;
921 OSStatus _err;
922 IconRef outIcon;
923 if (!PyArg_ParseTuple(_args, ""))
924 return NULL;
925 _err = GetWindowProxyIcon(_self->ob_itself,
926 &outIcon);
927 if (_err != noErr) return PyMac_Error(_err);
928 _res = Py_BuildValue("O&",
929 ResObj_New, outIcon);
930 return _res;
933 static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
934 WindowObject *_self;
935 PyObject *_args;
937 PyObject *_res = NULL;
938 OSStatus _err;
939 IconRef icon;
940 if (!PyArg_ParseTuple(_args, "O&",
941 ResObj_Convert, &icon))
942 return NULL;
943 _err = SetWindowProxyIcon(_self->ob_itself,
944 icon);
945 if (_err != noErr) return PyMac_Error(_err);
946 Py_INCREF(Py_None);
947 _res = Py_None;
948 return _res;
951 static PyObject *WinObj_RemoveWindowProxy(_self, _args)
952 WindowObject *_self;
953 PyObject *_args;
955 PyObject *_res = NULL;
956 OSStatus _err;
957 if (!PyArg_ParseTuple(_args, ""))
958 return NULL;
959 _err = RemoveWindowProxy(_self->ob_itself);
960 if (_err != noErr) return PyMac_Error(_err);
961 Py_INCREF(Py_None);
962 _res = Py_None;
963 return _res;
966 static PyObject *WinObj_BeginWindowProxyDrag(_self, _args)
967 WindowObject *_self;
968 PyObject *_args;
970 PyObject *_res = NULL;
971 OSStatus _err;
972 DragReference outNewDrag;
973 RgnHandle outDragOutlineRgn;
974 if (!PyArg_ParseTuple(_args, "O&",
975 ResObj_Convert, &outDragOutlineRgn))
976 return NULL;
977 _err = BeginWindowProxyDrag(_self->ob_itself,
978 &outNewDrag,
979 outDragOutlineRgn);
980 if (_err != noErr) return PyMac_Error(_err);
981 _res = Py_BuildValue("O&",
982 DragObj_New, outNewDrag);
983 return _res;
986 static PyObject *WinObj_EndWindowProxyDrag(_self, _args)
987 WindowObject *_self;
988 PyObject *_args;
990 PyObject *_res = NULL;
991 OSStatus _err;
992 DragReference theDrag;
993 if (!PyArg_ParseTuple(_args, "O&",
994 DragObj_Convert, &theDrag))
995 return NULL;
996 _err = EndWindowProxyDrag(_self->ob_itself,
997 theDrag);
998 if (_err != noErr) return PyMac_Error(_err);
999 Py_INCREF(Py_None);
1000 _res = Py_None;
1001 return _res;
1004 static PyObject *WinObj_TrackWindowProxyFromExistingDrag(_self, _args)
1005 WindowObject *_self;
1006 PyObject *_args;
1008 PyObject *_res = NULL;
1009 OSStatus _err;
1010 Point startPt;
1011 DragReference drag;
1012 RgnHandle inDragOutlineRgn;
1013 if (!PyArg_ParseTuple(_args, "O&O&O&",
1014 PyMac_GetPoint, &startPt,
1015 DragObj_Convert, &drag,
1016 ResObj_Convert, &inDragOutlineRgn))
1017 return NULL;
1018 _err = TrackWindowProxyFromExistingDrag(_self->ob_itself,
1019 startPt,
1020 drag,
1021 inDragOutlineRgn);
1022 if (_err != noErr) return PyMac_Error(_err);
1023 Py_INCREF(Py_None);
1024 _res = Py_None;
1025 return _res;
1028 static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
1029 WindowObject *_self;
1030 PyObject *_args;
1032 PyObject *_res = NULL;
1033 OSStatus _err;
1034 Point startPt;
1035 if (!PyArg_ParseTuple(_args, "O&",
1036 PyMac_GetPoint, &startPt))
1037 return NULL;
1038 _err = TrackWindowProxyDrag(_self->ob_itself,
1039 startPt);
1040 if (_err != noErr) return PyMac_Error(_err);
1041 Py_INCREF(Py_None);
1042 _res = Py_None;
1043 return _res;
1046 static PyObject *WinObj_IsWindowModified(_self, _args)
1047 WindowObject *_self;
1048 PyObject *_args;
1050 PyObject *_res = NULL;
1051 Boolean _rv;
1052 if (!PyArg_ParseTuple(_args, ""))
1053 return NULL;
1054 _rv = IsWindowModified(_self->ob_itself);
1055 _res = Py_BuildValue("b",
1056 _rv);
1057 return _res;
1060 static PyObject *WinObj_SetWindowModified(_self, _args)
1061 WindowObject *_self;
1062 PyObject *_args;
1064 PyObject *_res = NULL;
1065 OSStatus _err;
1066 Boolean modified;
1067 if (!PyArg_ParseTuple(_args, "b",
1068 &modified))
1069 return NULL;
1070 _err = SetWindowModified(_self->ob_itself,
1071 modified);
1072 if (_err != noErr) return PyMac_Error(_err);
1073 Py_INCREF(Py_None);
1074 _res = Py_None;
1075 return _res;
1078 static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
1079 WindowObject *_self;
1080 PyObject *_args;
1082 PyObject *_res = NULL;
1083 Boolean _rv;
1084 EventRecord event;
1085 if (!PyArg_ParseTuple(_args, "O&",
1086 PyMac_GetEventRecord, &event))
1087 return NULL;
1088 _rv = IsWindowPathSelectClick(_self->ob_itself,
1089 &event);
1090 _res = Py_BuildValue("b",
1091 _rv);
1092 return _res;
1095 static PyObject *WinObj_WindowPathSelect(_self, _args)
1096 WindowObject *_self;
1097 PyObject *_args;
1099 PyObject *_res = NULL;
1100 OSStatus _err;
1101 MenuHandle menu;
1102 SInt32 outMenuResult;
1103 if (!PyArg_ParseTuple(_args, "O&",
1104 MenuObj_Convert, &menu))
1105 return NULL;
1106 _err = WindowPathSelect(_self->ob_itself,
1107 menu,
1108 &outMenuResult);
1109 if (_err != noErr) return PyMac_Error(_err);
1110 _res = Py_BuildValue("l",
1111 outMenuResult);
1112 return _res;
1115 static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
1116 WindowObject *_self;
1117 PyObject *_args;
1119 PyObject *_res = NULL;
1120 OSStatus _err;
1121 Boolean hilited;
1122 if (!PyArg_ParseTuple(_args, "b",
1123 &hilited))
1124 return NULL;
1125 _err = HiliteWindowFrameForDrag(_self->ob_itself,
1126 hilited);
1127 if (_err != noErr) return PyMac_Error(_err);
1128 Py_INCREF(Py_None);
1129 _res = Py_None;
1130 return _res;
1133 static PyObject *WinObj_TransitionWindow(_self, _args)
1134 WindowObject *_self;
1135 PyObject *_args;
1137 PyObject *_res = NULL;
1138 OSStatus _err;
1139 WindowTransitionEffect effect;
1140 WindowTransitionAction action;
1141 Rect rect;
1142 if (!PyArg_ParseTuple(_args, "llO&",
1143 &effect,
1144 &action,
1145 PyMac_GetRect, &rect))
1146 return NULL;
1147 _err = TransitionWindow(_self->ob_itself,
1148 effect,
1149 action,
1150 &rect);
1151 if (_err != noErr) return PyMac_Error(_err);
1152 Py_INCREF(Py_None);
1153 _res = Py_None;
1154 return _res;
1157 static PyObject *WinObj_MacMoveWindow(_self, _args)
1158 WindowObject *_self;
1159 PyObject *_args;
1161 PyObject *_res = NULL;
1162 short hGlobal;
1163 short vGlobal;
1164 Boolean front;
1165 if (!PyArg_ParseTuple(_args, "hhb",
1166 &hGlobal,
1167 &vGlobal,
1168 &front))
1169 return NULL;
1170 MacMoveWindow(_self->ob_itself,
1171 hGlobal,
1172 vGlobal,
1173 front);
1174 Py_INCREF(Py_None);
1175 _res = Py_None;
1176 return _res;
1179 static PyObject *WinObj_SizeWindow(_self, _args)
1180 WindowObject *_self;
1181 PyObject *_args;
1183 PyObject *_res = NULL;
1184 short w;
1185 short h;
1186 Boolean fUpdate;
1187 if (!PyArg_ParseTuple(_args, "hhb",
1190 &fUpdate))
1191 return NULL;
1192 SizeWindow(_self->ob_itself,
1195 fUpdate);
1196 Py_INCREF(Py_None);
1197 _res = Py_None;
1198 return _res;
1201 static PyObject *WinObj_GrowWindow(_self, _args)
1202 WindowObject *_self;
1203 PyObject *_args;
1205 PyObject *_res = NULL;
1206 long _rv;
1207 Point startPt;
1208 Rect bBox;
1209 if (!PyArg_ParseTuple(_args, "O&O&",
1210 PyMac_GetPoint, &startPt,
1211 PyMac_GetRect, &bBox))
1212 return NULL;
1213 _rv = GrowWindow(_self->ob_itself,
1214 startPt,
1215 &bBox);
1216 _res = Py_BuildValue("l",
1217 _rv);
1218 return _res;
1221 static PyObject *WinObj_DragWindow(_self, _args)
1222 WindowObject *_self;
1223 PyObject *_args;
1225 PyObject *_res = NULL;
1226 Point startPt;
1227 Rect boundsRect;
1228 if (!PyArg_ParseTuple(_args, "O&O&",
1229 PyMac_GetPoint, &startPt,
1230 PyMac_GetRect, &boundsRect))
1231 return NULL;
1232 DragWindow(_self->ob_itself,
1233 startPt,
1234 &boundsRect);
1235 Py_INCREF(Py_None);
1236 _res = Py_None;
1237 return _res;
1240 static PyObject *WinObj_ZoomWindow(_self, _args)
1241 WindowObject *_self;
1242 PyObject *_args;
1244 PyObject *_res = NULL;
1245 WindowPartCode partCode;
1246 Boolean front;
1247 if (!PyArg_ParseTuple(_args, "hb",
1248 &partCode,
1249 &front))
1250 return NULL;
1251 ZoomWindow(_self->ob_itself,
1252 partCode,
1253 front);
1254 Py_INCREF(Py_None);
1255 _res = Py_None;
1256 return _res;
1259 static PyObject *WinObj_IsWindowCollapsable(_self, _args)
1260 WindowObject *_self;
1261 PyObject *_args;
1263 PyObject *_res = NULL;
1264 Boolean _rv;
1265 if (!PyArg_ParseTuple(_args, ""))
1266 return NULL;
1267 _rv = IsWindowCollapsable(_self->ob_itself);
1268 _res = Py_BuildValue("b",
1269 _rv);
1270 return _res;
1273 static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1274 WindowObject *_self;
1275 PyObject *_args;
1277 PyObject *_res = NULL;
1278 Boolean _rv;
1279 if (!PyArg_ParseTuple(_args, ""))
1280 return NULL;
1281 _rv = IsWindowCollapsed(_self->ob_itself);
1282 _res = Py_BuildValue("b",
1283 _rv);
1284 return _res;
1287 static PyObject *WinObj_CollapseWindow(_self, _args)
1288 WindowObject *_self;
1289 PyObject *_args;
1291 PyObject *_res = NULL;
1292 OSStatus _err;
1293 Boolean collapse;
1294 if (!PyArg_ParseTuple(_args, "b",
1295 &collapse))
1296 return NULL;
1297 _err = CollapseWindow(_self->ob_itself,
1298 collapse);
1299 if (_err != noErr) return PyMac_Error(_err);
1300 Py_INCREF(Py_None);
1301 _res = Py_None;
1302 return _res;
1305 static PyObject *WinObj_GetWindowBounds(_self, _args)
1306 WindowObject *_self;
1307 PyObject *_args;
1309 PyObject *_res = NULL;
1310 OSStatus _err;
1311 WindowRegionCode regionCode;
1312 Rect globalBounds;
1313 if (!PyArg_ParseTuple(_args, "H",
1314 &regionCode))
1315 return NULL;
1316 _err = GetWindowBounds(_self->ob_itself,
1317 regionCode,
1318 &globalBounds);
1319 if (_err != noErr) return PyMac_Error(_err);
1320 _res = Py_BuildValue("O&",
1321 PyMac_BuildRect, &globalBounds);
1322 return _res;
1325 static PyObject *WinObj_ResizeWindow(_self, _args)
1326 WindowObject *_self;
1327 PyObject *_args;
1329 PyObject *_res = NULL;
1330 Boolean _rv;
1331 Point startPoint;
1332 Rect sizeConstraints;
1333 Rect newContentRect;
1334 if (!PyArg_ParseTuple(_args, "O&O&",
1335 PyMac_GetPoint, &startPoint,
1336 PyMac_GetRect, &sizeConstraints))
1337 return NULL;
1338 _rv = ResizeWindow(_self->ob_itself,
1339 startPoint,
1340 &sizeConstraints,
1341 &newContentRect);
1342 _res = Py_BuildValue("bO&",
1343 _rv,
1344 PyMac_BuildRect, &newContentRect);
1345 return _res;
1348 static PyObject *WinObj_SetWindowBounds(_self, _args)
1349 WindowObject *_self;
1350 PyObject *_args;
1352 PyObject *_res = NULL;
1353 OSStatus _err;
1354 WindowRegionCode regionCode;
1355 Rect globalBounds;
1356 if (!PyArg_ParseTuple(_args, "HO&",
1357 &regionCode,
1358 PyMac_GetRect, &globalBounds))
1359 return NULL;
1360 _err = SetWindowBounds(_self->ob_itself,
1361 regionCode,
1362 &globalBounds);
1363 if (_err != noErr) return PyMac_Error(_err);
1364 Py_INCREF(Py_None);
1365 _res = Py_None;
1366 return _res;
1369 static PyObject *WinObj_RepositionWindow(_self, _args)
1370 WindowObject *_self;
1371 PyObject *_args;
1373 PyObject *_res = NULL;
1374 OSStatus _err;
1375 WindowPtr parentWindow;
1376 WindowPositionMethod method;
1377 if (!PyArg_ParseTuple(_args, "O&l",
1378 WinObj_Convert, &parentWindow,
1379 &method))
1380 return NULL;
1381 _err = RepositionWindow(_self->ob_itself,
1382 parentWindow,
1383 method);
1384 if (_err != noErr) return PyMac_Error(_err);
1385 Py_INCREF(Py_None);
1386 _res = Py_None;
1387 return _res;
1390 static PyObject *WinObj_MoveWindowStructure(_self, _args)
1391 WindowObject *_self;
1392 PyObject *_args;
1394 PyObject *_res = NULL;
1395 OSStatus _err;
1396 short hGlobal;
1397 short vGlobal;
1398 if (!PyArg_ParseTuple(_args, "hh",
1399 &hGlobal,
1400 &vGlobal))
1401 return NULL;
1402 _err = MoveWindowStructure(_self->ob_itself,
1403 hGlobal,
1404 vGlobal);
1405 if (_err != noErr) return PyMac_Error(_err);
1406 Py_INCREF(Py_None);
1407 _res = Py_None;
1408 return _res;
1411 static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1412 WindowObject *_self;
1413 PyObject *_args;
1415 PyObject *_res = NULL;
1416 Boolean _rv;
1417 Point idealSize;
1418 Rect idealStandardState;
1419 if (!PyArg_ParseTuple(_args, ""))
1420 return NULL;
1421 _rv = IsWindowInStandardState(_self->ob_itself,
1422 &idealSize,
1423 &idealStandardState);
1424 _res = Py_BuildValue("bO&O&",
1425 _rv,
1426 PyMac_BuildPoint, idealSize,
1427 PyMac_BuildRect, &idealStandardState);
1428 return _res;
1431 static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1432 WindowObject *_self;
1433 PyObject *_args;
1435 PyObject *_res = NULL;
1436 OSStatus _err;
1437 WindowPartCode partCode;
1438 Point ioIdealSize;
1439 if (!PyArg_ParseTuple(_args, "h",
1440 &partCode))
1441 return NULL;
1442 _err = ZoomWindowIdeal(_self->ob_itself,
1443 partCode,
1444 &ioIdealSize);
1445 if (_err != noErr) return PyMac_Error(_err);
1446 _res = Py_BuildValue("O&",
1447 PyMac_BuildPoint, ioIdealSize);
1448 return _res;
1451 static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1452 WindowObject *_self;
1453 PyObject *_args;
1455 PyObject *_res = NULL;
1456 OSStatus _err;
1457 Rect userState;
1458 if (!PyArg_ParseTuple(_args, ""))
1459 return NULL;
1460 _err = GetWindowIdealUserState(_self->ob_itself,
1461 &userState);
1462 if (_err != noErr) return PyMac_Error(_err);
1463 _res = Py_BuildValue("O&",
1464 PyMac_BuildRect, &userState);
1465 return _res;
1468 static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1469 WindowObject *_self;
1470 PyObject *_args;
1472 PyObject *_res = NULL;
1473 OSStatus _err;
1474 Rect userState;
1475 if (!PyArg_ParseTuple(_args, ""))
1476 return NULL;
1477 _err = SetWindowIdealUserState(_self->ob_itself,
1478 &userState);
1479 if (_err != noErr) return PyMac_Error(_err);
1480 _res = Py_BuildValue("O&",
1481 PyMac_BuildRect, &userState);
1482 return _res;
1485 static PyObject *WinObj_HideWindow(_self, _args)
1486 WindowObject *_self;
1487 PyObject *_args;
1489 PyObject *_res = NULL;
1490 if (!PyArg_ParseTuple(_args, ""))
1491 return NULL;
1492 HideWindow(_self->ob_itself);
1493 Py_INCREF(Py_None);
1494 _res = Py_None;
1495 return _res;
1498 static PyObject *WinObj_MacShowWindow(_self, _args)
1499 WindowObject *_self;
1500 PyObject *_args;
1502 PyObject *_res = NULL;
1503 if (!PyArg_ParseTuple(_args, ""))
1504 return NULL;
1505 MacShowWindow(_self->ob_itself);
1506 Py_INCREF(Py_None);
1507 _res = Py_None;
1508 return _res;
1511 static PyObject *WinObj_ShowHide(_self, _args)
1512 WindowObject *_self;
1513 PyObject *_args;
1515 PyObject *_res = NULL;
1516 Boolean showFlag;
1517 if (!PyArg_ParseTuple(_args, "b",
1518 &showFlag))
1519 return NULL;
1520 ShowHide(_self->ob_itself,
1521 showFlag);
1522 Py_INCREF(Py_None);
1523 _res = Py_None;
1524 return _res;
1527 #if TARGET_API_MAC_CARBON
1529 static PyObject *WinObj_GetWindowPropertyAttributes(_self, _args)
1530 WindowObject *_self;
1531 PyObject *_args;
1533 PyObject *_res = NULL;
1534 OSStatus _err;
1535 OSType propertyCreator;
1536 OSType propertyTag;
1537 UInt32 attributes;
1538 if (!PyArg_ParseTuple(_args, "O&O&",
1539 PyMac_GetOSType, &propertyCreator,
1540 PyMac_GetOSType, &propertyTag))
1541 return NULL;
1542 _err = GetWindowPropertyAttributes(_self->ob_itself,
1543 propertyCreator,
1544 propertyTag,
1545 &attributes);
1546 if (_err != noErr) return PyMac_Error(_err);
1547 _res = Py_BuildValue("l",
1548 attributes);
1549 return _res;
1551 #endif
1553 #if TARGET_API_MAC_CARBON
1555 static PyObject *WinObj_ChangeWindowPropertyAttributes(_self, _args)
1556 WindowObject *_self;
1557 PyObject *_args;
1559 PyObject *_res = NULL;
1560 OSStatus _err;
1561 OSType propertyCreator;
1562 OSType propertyTag;
1563 UInt32 attributesToSet;
1564 UInt32 attributesToClear;
1565 if (!PyArg_ParseTuple(_args, "O&O&ll",
1566 PyMac_GetOSType, &propertyCreator,
1567 PyMac_GetOSType, &propertyTag,
1568 &attributesToSet,
1569 &attributesToClear))
1570 return NULL;
1571 _err = ChangeWindowPropertyAttributes(_self->ob_itself,
1572 propertyCreator,
1573 propertyTag,
1574 attributesToSet,
1575 attributesToClear);
1576 if (_err != noErr) return PyMac_Error(_err);
1577 Py_INCREF(Py_None);
1578 _res = Py_None;
1579 return _res;
1581 #endif
1583 static PyObject *WinObj_TrackBox(_self, _args)
1584 WindowObject *_self;
1585 PyObject *_args;
1587 PyObject *_res = NULL;
1588 Boolean _rv;
1589 Point thePt;
1590 WindowPartCode partCode;
1591 if (!PyArg_ParseTuple(_args, "O&h",
1592 PyMac_GetPoint, &thePt,
1593 &partCode))
1594 return NULL;
1595 _rv = TrackBox(_self->ob_itself,
1596 thePt,
1597 partCode);
1598 _res = Py_BuildValue("b",
1599 _rv);
1600 return _res;
1603 static PyObject *WinObj_TrackGoAway(_self, _args)
1604 WindowObject *_self;
1605 PyObject *_args;
1607 PyObject *_res = NULL;
1608 Boolean _rv;
1609 Point thePt;
1610 if (!PyArg_ParseTuple(_args, "O&",
1611 PyMac_GetPoint, &thePt))
1612 return NULL;
1613 _rv = TrackGoAway(_self->ob_itself,
1614 thePt);
1615 _res = Py_BuildValue("b",
1616 _rv);
1617 return _res;
1620 #if !TARGET_API_MAC_CARBON
1622 static PyObject *WinObj_GetAuxWin(_self, _args)
1623 WindowObject *_self;
1624 PyObject *_args;
1626 PyObject *_res = NULL;
1627 Boolean _rv;
1628 AuxWinHandle awHndl;
1629 if (!PyArg_ParseTuple(_args, ""))
1630 return NULL;
1631 _rv = GetAuxWin(_self->ob_itself,
1632 &awHndl);
1633 _res = Py_BuildValue("bO&",
1634 _rv,
1635 ResObj_New, awHndl);
1636 return _res;
1638 #endif
1640 #if !TARGET_API_MAC_CARBON
1642 static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1643 WindowObject *_self;
1644 PyObject *_args;
1646 PyObject *_res = NULL;
1647 Boolean _rv;
1648 if (!PyArg_ParseTuple(_args, ""))
1649 return NULL;
1650 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1651 _res = Py_BuildValue("b",
1652 _rv);
1653 return _res;
1655 #endif
1657 #if !TARGET_API_MAC_CARBON
1659 static PyObject *WinObj_GetWindowSpareFlag(_self, _args)
1660 WindowObject *_self;
1661 PyObject *_args;
1663 PyObject *_res = NULL;
1664 Boolean _rv;
1665 if (!PyArg_ParseTuple(_args, ""))
1666 return NULL;
1667 _rv = GetWindowSpareFlag(_self->ob_itself);
1668 _res = Py_BuildValue("b",
1669 _rv);
1670 return _res;
1672 #endif
1674 static PyObject *WinObj_GetWindowPort(_self, _args)
1675 WindowObject *_self;
1676 PyObject *_args;
1678 PyObject *_res = NULL;
1679 CGrafPtr _rv;
1680 if (!PyArg_ParseTuple(_args, ""))
1681 return NULL;
1682 _rv = GetWindowPort(_self->ob_itself);
1683 _res = Py_BuildValue("O&",
1684 GrafObj_New, _rv);
1685 return _res;
1688 static PyObject *WinObj_GetWindowKind(_self, _args)
1689 WindowObject *_self;
1690 PyObject *_args;
1692 PyObject *_res = NULL;
1693 short _rv;
1694 if (!PyArg_ParseTuple(_args, ""))
1695 return NULL;
1696 _rv = GetWindowKind(_self->ob_itself);
1697 _res = Py_BuildValue("h",
1698 _rv);
1699 return _res;
1702 static PyObject *WinObj_MacIsWindowVisible(_self, _args)
1703 WindowObject *_self;
1704 PyObject *_args;
1706 PyObject *_res = NULL;
1707 Boolean _rv;
1708 if (!PyArg_ParseTuple(_args, ""))
1709 return NULL;
1710 _rv = MacIsWindowVisible(_self->ob_itself);
1711 _res = Py_BuildValue("b",
1712 _rv);
1713 return _res;
1716 static PyObject *WinObj_IsWindowHilited(_self, _args)
1717 WindowObject *_self;
1718 PyObject *_args;
1720 PyObject *_res = NULL;
1721 Boolean _rv;
1722 if (!PyArg_ParseTuple(_args, ""))
1723 return NULL;
1724 _rv = IsWindowHilited(_self->ob_itself);
1725 _res = Py_BuildValue("b",
1726 _rv);
1727 return _res;
1730 #if TARGET_API_MAC_CARBON
1732 static PyObject *WinObj_IsWindowUpdatePending(_self, _args)
1733 WindowObject *_self;
1734 PyObject *_args;
1736 PyObject *_res = NULL;
1737 Boolean _rv;
1738 if (!PyArg_ParseTuple(_args, ""))
1739 return NULL;
1740 _rv = IsWindowUpdatePending(_self->ob_itself);
1741 _res = Py_BuildValue("b",
1742 _rv);
1743 return _res;
1745 #endif
1747 static PyObject *WinObj_MacGetNextWindow(_self, _args)
1748 WindowObject *_self;
1749 PyObject *_args;
1751 PyObject *_res = NULL;
1752 WindowPtr _rv;
1753 if (!PyArg_ParseTuple(_args, ""))
1754 return NULL;
1755 _rv = MacGetNextWindow(_self->ob_itself);
1756 _res = Py_BuildValue("O&",
1757 WinObj_New, _rv);
1758 return _res;
1761 static PyObject *WinObj_GetWindowStandardState(_self, _args)
1762 WindowObject *_self;
1763 PyObject *_args;
1765 PyObject *_res = NULL;
1766 Rect rect;
1767 if (!PyArg_ParseTuple(_args, ""))
1768 return NULL;
1769 GetWindowStandardState(_self->ob_itself,
1770 &rect);
1771 _res = Py_BuildValue("O&",
1772 PyMac_BuildRect, &rect);
1773 return _res;
1776 static PyObject *WinObj_GetWindowUserState(_self, _args)
1777 WindowObject *_self;
1778 PyObject *_args;
1780 PyObject *_res = NULL;
1781 Rect rect;
1782 if (!PyArg_ParseTuple(_args, ""))
1783 return NULL;
1784 GetWindowUserState(_self->ob_itself,
1785 &rect);
1786 _res = Py_BuildValue("O&",
1787 PyMac_BuildRect, &rect);
1788 return _res;
1791 static PyObject *WinObj_SetWindowKind(_self, _args)
1792 WindowObject *_self;
1793 PyObject *_args;
1795 PyObject *_res = NULL;
1796 short kind;
1797 if (!PyArg_ParseTuple(_args, "h",
1798 &kind))
1799 return NULL;
1800 SetWindowKind(_self->ob_itself,
1801 kind);
1802 Py_INCREF(Py_None);
1803 _res = Py_None;
1804 return _res;
1807 static PyObject *WinObj_SetWindowStandardState(_self, _args)
1808 WindowObject *_self;
1809 PyObject *_args;
1811 PyObject *_res = NULL;
1812 Rect rect;
1813 if (!PyArg_ParseTuple(_args, "O&",
1814 PyMac_GetRect, &rect))
1815 return NULL;
1816 SetWindowStandardState(_self->ob_itself,
1817 &rect);
1818 Py_INCREF(Py_None);
1819 _res = Py_None;
1820 return _res;
1823 static PyObject *WinObj_SetWindowUserState(_self, _args)
1824 WindowObject *_self;
1825 PyObject *_args;
1827 PyObject *_res = NULL;
1828 Rect rect;
1829 if (!PyArg_ParseTuple(_args, "O&",
1830 PyMac_GetRect, &rect))
1831 return NULL;
1832 SetWindowUserState(_self->ob_itself,
1833 &rect);
1834 Py_INCREF(Py_None);
1835 _res = Py_None;
1836 return _res;
1839 static PyObject *WinObj_SetPortWindowPort(_self, _args)
1840 WindowObject *_self;
1841 PyObject *_args;
1843 PyObject *_res = NULL;
1844 if (!PyArg_ParseTuple(_args, ""))
1845 return NULL;
1846 SetPortWindowPort(_self->ob_itself);
1847 Py_INCREF(Py_None);
1848 _res = Py_None;
1849 return _res;
1852 static PyObject *WinObj_GetWindowPortBounds(_self, _args)
1853 WindowObject *_self;
1854 PyObject *_args;
1856 PyObject *_res = NULL;
1857 Rect bounds;
1858 if (!PyArg_ParseTuple(_args, ""))
1859 return NULL;
1860 GetWindowPortBounds(_self->ob_itself,
1861 &bounds);
1862 _res = Py_BuildValue("O&",
1863 PyMac_BuildRect, &bounds);
1864 return _res;
1867 static PyObject *WinObj_IsWindowVisible(_self, _args)
1868 WindowObject *_self;
1869 PyObject *_args;
1871 PyObject *_res = NULL;
1872 Boolean _rv;
1873 if (!PyArg_ParseTuple(_args, ""))
1874 return NULL;
1875 _rv = IsWindowVisible(_self->ob_itself);
1876 _res = Py_BuildValue("b",
1877 _rv);
1878 return _res;
1881 #if !TARGET_API_MAC_CARBON
1883 static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1884 WindowObject *_self;
1885 PyObject *_args;
1887 PyObject *_res = NULL;
1888 Boolean _rv;
1889 if (!PyArg_ParseTuple(_args, ""))
1890 return NULL;
1891 _rv = GetWindowZoomFlag(_self->ob_itself);
1892 _res = Py_BuildValue("b",
1893 _rv);
1894 return _res;
1896 #endif
1898 static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1899 WindowObject *_self;
1900 PyObject *_args;
1902 PyObject *_res = NULL;
1903 RgnHandle r;
1904 if (!PyArg_ParseTuple(_args, "O&",
1905 ResObj_Convert, &r))
1906 return NULL;
1907 GetWindowStructureRgn(_self->ob_itself,
1909 Py_INCREF(Py_None);
1910 _res = Py_None;
1911 return _res;
1914 static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1915 WindowObject *_self;
1916 PyObject *_args;
1918 PyObject *_res = NULL;
1919 RgnHandle r;
1920 if (!PyArg_ParseTuple(_args, "O&",
1921 ResObj_Convert, &r))
1922 return NULL;
1923 GetWindowContentRgn(_self->ob_itself,
1925 Py_INCREF(Py_None);
1926 _res = Py_None;
1927 return _res;
1930 static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1931 WindowObject *_self;
1932 PyObject *_args;
1934 PyObject *_res = NULL;
1935 RgnHandle r;
1936 if (!PyArg_ParseTuple(_args, "O&",
1937 ResObj_Convert, &r))
1938 return NULL;
1939 GetWindowUpdateRgn(_self->ob_itself,
1941 Py_INCREF(Py_None);
1942 _res = Py_None;
1943 return _res;
1946 #if !TARGET_API_MAC_CARBON
1948 static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1949 WindowObject *_self;
1950 PyObject *_args;
1952 PyObject *_res = NULL;
1953 short _rv;
1954 if (!PyArg_ParseTuple(_args, ""))
1955 return NULL;
1956 _rv = GetWindowTitleWidth(_self->ob_itself);
1957 _res = Py_BuildValue("h",
1958 _rv);
1959 return _res;
1961 #endif
1963 static PyObject *WinObj_GetNextWindow(_self, _args)
1964 WindowObject *_self;
1965 PyObject *_args;
1967 PyObject *_res = NULL;
1968 WindowPtr _rv;
1969 if (!PyArg_ParseTuple(_args, ""))
1970 return NULL;
1971 _rv = GetNextWindow(_self->ob_itself);
1972 _res = Py_BuildValue("O&",
1973 WinObj_WhichWindow, _rv);
1974 return _res;
1977 #if !TARGET_API_MAC_CARBON
1979 static PyObject *WinObj_CloseWindow(_self, _args)
1980 WindowObject *_self;
1981 PyObject *_args;
1983 PyObject *_res = NULL;
1984 if (!PyArg_ParseTuple(_args, ""))
1985 return NULL;
1986 CloseWindow(_self->ob_itself);
1987 Py_INCREF(Py_None);
1988 _res = Py_None;
1989 return _res;
1991 #endif
1993 static PyObject *WinObj_MoveWindow(_self, _args)
1994 WindowObject *_self;
1995 PyObject *_args;
1997 PyObject *_res = NULL;
1998 short hGlobal;
1999 short vGlobal;
2000 Boolean front;
2001 if (!PyArg_ParseTuple(_args, "hhb",
2002 &hGlobal,
2003 &vGlobal,
2004 &front))
2005 return NULL;
2006 MoveWindow(_self->ob_itself,
2007 hGlobal,
2008 vGlobal,
2009 front);
2010 Py_INCREF(Py_None);
2011 _res = Py_None;
2012 return _res;
2015 static PyObject *WinObj_ShowWindow(_self, _args)
2016 WindowObject *_self;
2017 PyObject *_args;
2019 PyObject *_res = NULL;
2020 if (!PyArg_ParseTuple(_args, ""))
2021 return NULL;
2022 ShowWindow(_self->ob_itself);
2023 Py_INCREF(Py_None);
2024 _res = Py_None;
2025 return _res;
2028 static PyMethodDef WinObj_methods[] = {
2029 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
2030 "() -> (UInt32 outCount)"},
2031 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
2032 "() -> None"},
2034 #if TARGET_API_MAC_CARBON
2035 {"ReshapeCustomWindow", (PyCFunction)WinObj_ReshapeCustomWindow, 1,
2036 "() -> None"},
2037 #endif
2038 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
2039 "() -> (WindowClass outClass)"},
2040 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
2041 "() -> (WindowAttributes outAttributes)"},
2043 #if TARGET_API_MAC_CARBON
2044 {"ChangeWindowAttributes", (PyCFunction)WinObj_ChangeWindowAttributes, 1,
2045 "(WindowAttributes setTheseAttributes, WindowAttributes clearTheseAttributes) -> None"},
2046 #endif
2048 #if !TARGET_API_MAC_CARBON
2049 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
2050 "(WCTabHandle newColorTable) -> None"},
2051 #endif
2052 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
2053 "(RGBColor color) -> None"},
2054 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
2055 "() -> (RGBColor color)"},
2056 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
2057 "(PixPatHandle outPixPat) -> None"},
2058 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
2059 "(PixPatHandle pixPat) -> None"},
2061 #if TARGET_API_MAC_CARBON
2062 {"ScrollWindowRect", (PyCFunction)WinObj_ScrollWindowRect, 1,
2063 "(Rect inScrollRect, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
2064 #endif
2066 #if TARGET_API_MAC_CARBON
2067 {"ScrollWindowRegion", (PyCFunction)WinObj_ScrollWindowRegion, 1,
2068 "(RgnHandle inScrollRgn, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
2069 #endif
2070 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
2071 "() -> None"},
2073 #if !TARGET_API_MAC_CARBON
2074 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
2075 "() -> None"},
2076 #endif
2078 #if !TARGET_API_MAC_CARBON
2079 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
2080 "(Boolean update) -> None"},
2081 #endif
2082 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
2083 "(RgnHandle clobberedRgn) -> None"},
2084 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
2085 "(RgnHandle clobberedRgn) -> None"},
2086 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
2087 "() -> None"},
2088 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
2089 "(RgnHandle clobberedRgn) -> None"},
2090 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
2091 "() -> None"},
2092 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
2093 "(WindowPtr behindWindow) -> None"},
2094 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
2095 "() -> None"},
2097 #if TARGET_API_MAC_CARBON
2098 {"GetNextWindowOfClass", (PyCFunction)WinObj_GetNextWindowOfClass, 1,
2099 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2100 #endif
2102 #if !TARGET_API_MAC_CARBON
2103 {"IsValidWindowPtr", (PyCFunction)WinObj_IsValidWindowPtr, 1,
2104 "() -> (Boolean _rv)"},
2105 #endif
2106 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
2107 "(Boolean fHilite) -> None"},
2108 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
2109 "(long data) -> None"},
2110 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
2111 "() -> (long _rv)"},
2112 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
2113 "(PicHandle pic) -> None"},
2114 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
2115 "() -> (PicHandle _rv)"},
2116 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
2117 "() -> (short _rv)"},
2118 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
2119 "() -> (UInt32 outFeatures)"},
2120 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
2121 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
2122 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
2123 "() -> None"},
2124 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
2125 "() -> None"},
2126 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
2127 "(RgnHandle region) -> None"},
2128 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
2129 "(Rect bounds) -> None"},
2130 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
2131 "(RgnHandle region) -> None"},
2132 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
2133 "(Rect bounds) -> None"},
2134 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
2135 "() -> None"},
2136 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
2137 "(Str255 title) -> None"},
2138 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
2139 "() -> (Str255 title)"},
2140 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
2141 "(FSSpec inFile) -> None"},
2142 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
2143 "() -> (FSSpec outFile)"},
2144 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
2145 "(AliasHandle alias) -> None"},
2146 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
2147 "() -> (AliasHandle alias)"},
2148 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
2149 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
2150 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
2151 "() -> (IconRef outIcon)"},
2152 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
2153 "(IconRef icon) -> None"},
2154 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
2155 "() -> None"},
2156 {"BeginWindowProxyDrag", (PyCFunction)WinObj_BeginWindowProxyDrag, 1,
2157 "(RgnHandle outDragOutlineRgn) -> (DragReference outNewDrag)"},
2158 {"EndWindowProxyDrag", (PyCFunction)WinObj_EndWindowProxyDrag, 1,
2159 "(DragReference theDrag) -> None"},
2160 {"TrackWindowProxyFromExistingDrag", (PyCFunction)WinObj_TrackWindowProxyFromExistingDrag, 1,
2161 "(Point startPt, DragReference drag, RgnHandle inDragOutlineRgn) -> None"},
2162 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
2163 "(Point startPt) -> None"},
2164 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
2165 "() -> (Boolean _rv)"},
2166 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
2167 "(Boolean modified) -> None"},
2168 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
2169 "(EventRecord event) -> (Boolean _rv)"},
2170 {"WindowPathSelect", (PyCFunction)WinObj_WindowPathSelect, 1,
2171 "(MenuHandle menu) -> (SInt32 outMenuResult)"},
2172 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
2173 "(Boolean hilited) -> None"},
2174 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
2175 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
2176 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
2177 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2178 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
2179 "(short w, short h, Boolean fUpdate) -> None"},
2180 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
2181 "(Point startPt, Rect bBox) -> (long _rv)"},
2182 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
2183 "(Point startPt, Rect boundsRect) -> None"},
2184 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
2185 "(WindowPartCode partCode, Boolean front) -> None"},
2186 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
2187 "() -> (Boolean _rv)"},
2188 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
2189 "() -> (Boolean _rv)"},
2190 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
2191 "(Boolean collapse) -> None"},
2192 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
2193 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
2194 {"ResizeWindow", (PyCFunction)WinObj_ResizeWindow, 1,
2195 "(Point startPoint, Rect sizeConstraints) -> (Boolean _rv, Rect newContentRect)"},
2196 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
2197 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
2198 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
2199 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
2200 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
2201 "(short hGlobal, short vGlobal) -> None"},
2202 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
2203 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
2204 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
2205 "(WindowPartCode partCode) -> (Point ioIdealSize)"},
2206 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
2207 "() -> (Rect userState)"},
2208 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
2209 "() -> (Rect userState)"},
2210 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
2211 "() -> None"},
2212 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
2213 "() -> None"},
2214 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
2215 "(Boolean showFlag) -> None"},
2217 #if TARGET_API_MAC_CARBON
2218 {"GetWindowPropertyAttributes", (PyCFunction)WinObj_GetWindowPropertyAttributes, 1,
2219 "(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
2220 #endif
2222 #if TARGET_API_MAC_CARBON
2223 {"ChangeWindowPropertyAttributes", (PyCFunction)WinObj_ChangeWindowPropertyAttributes, 1,
2224 "(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
2225 #endif
2226 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
2227 "(Point thePt, WindowPartCode partCode) -> (Boolean _rv)"},
2228 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
2229 "(Point thePt) -> (Boolean _rv)"},
2231 #if !TARGET_API_MAC_CARBON
2232 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
2233 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
2234 #endif
2236 #if !TARGET_API_MAC_CARBON
2237 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
2238 "() -> (Boolean _rv)"},
2239 #endif
2241 #if !TARGET_API_MAC_CARBON
2242 {"GetWindowSpareFlag", (PyCFunction)WinObj_GetWindowSpareFlag, 1,
2243 "() -> (Boolean _rv)"},
2244 #endif
2245 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
2246 "() -> (CGrafPtr _rv)"},
2247 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
2248 "() -> (short _rv)"},
2249 {"MacIsWindowVisible", (PyCFunction)WinObj_MacIsWindowVisible, 1,
2250 "() -> (Boolean _rv)"},
2251 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
2252 "() -> (Boolean _rv)"},
2254 #if TARGET_API_MAC_CARBON
2255 {"IsWindowUpdatePending", (PyCFunction)WinObj_IsWindowUpdatePending, 1,
2256 "() -> (Boolean _rv)"},
2257 #endif
2258 {"MacGetNextWindow", (PyCFunction)WinObj_MacGetNextWindow, 1,
2259 "() -> (WindowPtr _rv)"},
2260 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
2261 "() -> (Rect rect)"},
2262 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
2263 "() -> (Rect rect)"},
2264 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
2265 "(short kind) -> None"},
2266 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
2267 "(Rect rect) -> None"},
2268 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
2269 "(Rect rect) -> None"},
2270 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
2271 "() -> None"},
2272 {"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1,
2273 "() -> (Rect bounds)"},
2274 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
2275 "() -> (Boolean _rv)"},
2277 #if !TARGET_API_MAC_CARBON
2278 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
2279 "() -> (Boolean _rv)"},
2280 #endif
2281 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
2282 "(RgnHandle r) -> None"},
2283 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
2284 "(RgnHandle r) -> None"},
2285 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
2286 "(RgnHandle r) -> None"},
2288 #if !TARGET_API_MAC_CARBON
2289 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
2290 "() -> (short _rv)"},
2291 #endif
2292 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
2293 "() -> (WindowPtr _rv)"},
2295 #if !TARGET_API_MAC_CARBON
2296 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
2297 "() -> None"},
2298 #endif
2299 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
2300 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2301 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
2302 "() -> None"},
2303 {NULL, NULL, 0}
2306 PyMethodChain WinObj_chain = { WinObj_methods, NULL };
2308 static PyObject *WinObj_getattr(self, name)
2309 WindowObject *self;
2310 char *name;
2312 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
2315 #define WinObj_setattr NULL
2317 static int WinObj_compare(self, other)
2318 WindowObject *self, *other;
2320 if ( self->ob_itself > other->ob_itself ) return 1;
2321 if ( self->ob_itself < other->ob_itself ) return -1;
2322 return 0;
2325 static PyObject * WinObj_repr(self)
2326 WindowObject *self;
2328 char buf[100];
2329 sprintf(buf, "<Window object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
2330 return PyString_FromString(buf);
2333 static int WinObj_hash(self)
2334 WindowObject *self;
2336 return (int)self->ob_itself;
2339 PyTypeObject Window_Type = {
2340 PyObject_HEAD_INIT(&PyType_Type)
2341 0, /*ob_size*/
2342 "Window", /*tp_name*/
2343 sizeof(WindowObject), /*tp_basicsize*/
2344 0, /*tp_itemsize*/
2345 /* methods */
2346 (destructor) WinObj_dealloc, /*tp_dealloc*/
2347 0, /*tp_print*/
2348 (getattrfunc) WinObj_getattr, /*tp_getattr*/
2349 (setattrfunc) WinObj_setattr, /*tp_setattr*/
2350 (cmpfunc) WinObj_compare, /*tp_compare*/
2351 (reprfunc) WinObj_repr, /*tp_repr*/
2352 (PyNumberMethods *)0, /* tp_as_number */
2353 (PySequenceMethods *)0, /* tp_as_sequence */
2354 (PyMappingMethods *)0, /* tp_as_mapping */
2355 (hashfunc) WinObj_hash, /*tp_hash*/
2358 /* --------------------- End object type Window --------------------- */
2361 static PyObject *Win_GetNewCWindow(_self, _args)
2362 PyObject *_self;
2363 PyObject *_args;
2365 PyObject *_res = NULL;
2366 WindowPtr _rv;
2367 short windowID;
2368 WindowPtr behind;
2369 if (!PyArg_ParseTuple(_args, "hO&",
2370 &windowID,
2371 WinObj_Convert, &behind))
2372 return NULL;
2373 _rv = GetNewCWindow(windowID,
2374 (void *)0,
2375 behind);
2376 _res = Py_BuildValue("O&",
2377 WinObj_New, _rv);
2378 return _res;
2381 static PyObject *Win_NewWindow(_self, _args)
2382 PyObject *_self;
2383 PyObject *_args;
2385 PyObject *_res = NULL;
2386 WindowPtr _rv;
2387 Rect boundsRect;
2388 Str255 title;
2389 Boolean visible;
2390 short theProc;
2391 WindowPtr behind;
2392 Boolean goAwayFlag;
2393 long refCon;
2394 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2395 PyMac_GetRect, &boundsRect,
2396 PyMac_GetStr255, title,
2397 &visible,
2398 &theProc,
2399 WinObj_Convert, &behind,
2400 &goAwayFlag,
2401 &refCon))
2402 return NULL;
2403 _rv = NewWindow((void *)0,
2404 &boundsRect,
2405 title,
2406 visible,
2407 theProc,
2408 behind,
2409 goAwayFlag,
2410 refCon);
2411 _res = Py_BuildValue("O&",
2412 WinObj_New, _rv);
2413 return _res;
2416 static PyObject *Win_GetNewWindow(_self, _args)
2417 PyObject *_self;
2418 PyObject *_args;
2420 PyObject *_res = NULL;
2421 WindowPtr _rv;
2422 short windowID;
2423 WindowPtr behind;
2424 if (!PyArg_ParseTuple(_args, "hO&",
2425 &windowID,
2426 WinObj_Convert, &behind))
2427 return NULL;
2428 _rv = GetNewWindow(windowID,
2429 (void *)0,
2430 behind);
2431 _res = Py_BuildValue("O&",
2432 WinObj_New, _rv);
2433 return _res;
2436 static PyObject *Win_NewCWindow(_self, _args)
2437 PyObject *_self;
2438 PyObject *_args;
2440 PyObject *_res = NULL;
2441 WindowPtr _rv;
2442 Rect boundsRect;
2443 Str255 title;
2444 Boolean visible;
2445 short procID;
2446 WindowPtr behind;
2447 Boolean goAwayFlag;
2448 long refCon;
2449 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2450 PyMac_GetRect, &boundsRect,
2451 PyMac_GetStr255, title,
2452 &visible,
2453 &procID,
2454 WinObj_Convert, &behind,
2455 &goAwayFlag,
2456 &refCon))
2457 return NULL;
2458 _rv = NewCWindow((void *)0,
2459 &boundsRect,
2460 title,
2461 visible,
2462 procID,
2463 behind,
2464 goAwayFlag,
2465 refCon);
2466 _res = Py_BuildValue("O&",
2467 WinObj_New, _rv);
2468 return _res;
2471 static PyObject *Win_CreateNewWindow(_self, _args)
2472 PyObject *_self;
2473 PyObject *_args;
2475 PyObject *_res = NULL;
2476 OSStatus _err;
2477 WindowClass windowClass;
2478 WindowAttributes attributes;
2479 Rect contentBounds;
2480 WindowPtr outWindow;
2481 if (!PyArg_ParseTuple(_args, "llO&",
2482 &windowClass,
2483 &attributes,
2484 PyMac_GetRect, &contentBounds))
2485 return NULL;
2486 _err = CreateNewWindow(windowClass,
2487 attributes,
2488 &contentBounds,
2489 &outWindow);
2490 if (_err != noErr) return PyMac_Error(_err);
2491 _res = Py_BuildValue("O&",
2492 WinObj_WhichWindow, outWindow);
2493 return _res;
2496 static PyObject *Win_CreateWindowFromResource(_self, _args)
2497 PyObject *_self;
2498 PyObject *_args;
2500 PyObject *_res = NULL;
2501 OSStatus _err;
2502 SInt16 resID;
2503 WindowPtr outWindow;
2504 if (!PyArg_ParseTuple(_args, "h",
2505 &resID))
2506 return NULL;
2507 _err = CreateWindowFromResource(resID,
2508 &outWindow);
2509 if (_err != noErr) return PyMac_Error(_err);
2510 _res = Py_BuildValue("O&",
2511 WinObj_WhichWindow, outWindow);
2512 return _res;
2515 static PyObject *Win_ShowFloatingWindows(_self, _args)
2516 PyObject *_self;
2517 PyObject *_args;
2519 PyObject *_res = NULL;
2520 OSStatus _err;
2521 if (!PyArg_ParseTuple(_args, ""))
2522 return NULL;
2523 _err = ShowFloatingWindows();
2524 if (_err != noErr) return PyMac_Error(_err);
2525 Py_INCREF(Py_None);
2526 _res = Py_None;
2527 return _res;
2530 static PyObject *Win_HideFloatingWindows(_self, _args)
2531 PyObject *_self;
2532 PyObject *_args;
2534 PyObject *_res = NULL;
2535 OSStatus _err;
2536 if (!PyArg_ParseTuple(_args, ""))
2537 return NULL;
2538 _err = HideFloatingWindows();
2539 if (_err != noErr) return PyMac_Error(_err);
2540 Py_INCREF(Py_None);
2541 _res = Py_None;
2542 return _res;
2545 static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2546 PyObject *_self;
2547 PyObject *_args;
2549 PyObject *_res = NULL;
2550 Boolean _rv;
2551 if (!PyArg_ParseTuple(_args, ""))
2552 return NULL;
2553 _rv = AreFloatingWindowsVisible();
2554 _res = Py_BuildValue("b",
2555 _rv);
2556 return _res;
2559 #if !TARGET_API_MAC_CARBON
2561 static PyObject *Win_SetDeskCPat(_self, _args)
2562 PyObject *_self;
2563 PyObject *_args;
2565 PyObject *_res = NULL;
2566 PixPatHandle deskPixPat;
2567 if (!PyArg_ParseTuple(_args, "O&",
2568 ResObj_Convert, &deskPixPat))
2569 return NULL;
2570 SetDeskCPat(deskPixPat);
2571 Py_INCREF(Py_None);
2572 _res = Py_None;
2573 return _res;
2575 #endif
2577 static PyObject *Win_CheckUpdate(_self, _args)
2578 PyObject *_self;
2579 PyObject *_args;
2581 PyObject *_res = NULL;
2582 Boolean _rv;
2583 EventRecord theEvent;
2584 if (!PyArg_ParseTuple(_args, ""))
2585 return NULL;
2586 _rv = CheckUpdate(&theEvent);
2587 _res = Py_BuildValue("bO&",
2588 _rv,
2589 PyMac_BuildEventRecord, &theEvent);
2590 return _res;
2593 static PyObject *Win_MacFindWindow(_self, _args)
2594 PyObject *_self;
2595 PyObject *_args;
2597 PyObject *_res = NULL;
2598 WindowPartCode _rv;
2599 Point thePoint;
2600 WindowPtr window;
2601 if (!PyArg_ParseTuple(_args, "O&",
2602 PyMac_GetPoint, &thePoint))
2603 return NULL;
2604 _rv = MacFindWindow(thePoint,
2605 &window);
2606 _res = Py_BuildValue("hO&",
2607 _rv,
2608 WinObj_WhichWindow, window);
2609 return _res;
2612 static PyObject *Win_FrontWindow(_self, _args)
2613 PyObject *_self;
2614 PyObject *_args;
2616 PyObject *_res = NULL;
2617 WindowPtr _rv;
2618 if (!PyArg_ParseTuple(_args, ""))
2619 return NULL;
2620 _rv = FrontWindow();
2621 _res = Py_BuildValue("O&",
2622 WinObj_WhichWindow, _rv);
2623 return _res;
2626 static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2627 PyObject *_self;
2628 PyObject *_args;
2630 PyObject *_res = NULL;
2631 WindowPtr _rv;
2632 if (!PyArg_ParseTuple(_args, ""))
2633 return NULL;
2634 _rv = FrontNonFloatingWindow();
2635 _res = Py_BuildValue("O&",
2636 WinObj_WhichWindow, _rv);
2637 return _res;
2640 #if TARGET_API_MAC_CARBON
2642 static PyObject *Win_GetFrontWindowOfClass(_self, _args)
2643 PyObject *_self;
2644 PyObject *_args;
2646 PyObject *_res = NULL;
2647 WindowPtr _rv;
2648 WindowClass inWindowClass;
2649 Boolean mustBeVisible;
2650 if (!PyArg_ParseTuple(_args, "lb",
2651 &inWindowClass,
2652 &mustBeVisible))
2653 return NULL;
2654 _rv = GetFrontWindowOfClass(inWindowClass,
2655 mustBeVisible);
2656 _res = Py_BuildValue("O&",
2657 WinObj_New, _rv);
2658 return _res;
2660 #endif
2662 #if TARGET_API_MAC_CARBON
2664 static PyObject *Win_FindWindowOfClass(_self, _args)
2665 PyObject *_self;
2666 PyObject *_args;
2668 PyObject *_res = NULL;
2669 OSStatus _err;
2670 Point where;
2671 WindowClass inWindowClass;
2672 WindowPtr outWindow;
2673 WindowPartCode outWindowPart;
2674 if (!PyArg_ParseTuple(_args, "O&l",
2675 PyMac_GetPoint, &where,
2676 &inWindowClass))
2677 return NULL;
2678 _err = FindWindowOfClass(&where,
2679 inWindowClass,
2680 &outWindow,
2681 &outWindowPart);
2682 if (_err != noErr) return PyMac_Error(_err);
2683 _res = Py_BuildValue("O&h",
2684 WinObj_WhichWindow, outWindow,
2685 outWindowPart);
2686 return _res;
2688 #endif
2690 #if !TARGET_API_MAC_CARBON
2692 static PyObject *Win_InitWindows(_self, _args)
2693 PyObject *_self;
2694 PyObject *_args;
2696 PyObject *_res = NULL;
2697 if (!PyArg_ParseTuple(_args, ""))
2698 return NULL;
2699 InitWindows();
2700 Py_INCREF(Py_None);
2701 _res = Py_None;
2702 return _res;
2704 #endif
2706 #if !TARGET_API_MAC_CARBON
2708 static PyObject *Win_GetWMgrPort(_self, _args)
2709 PyObject *_self;
2710 PyObject *_args;
2712 PyObject *_res = NULL;
2713 GrafPtr wPort;
2714 if (!PyArg_ParseTuple(_args, ""))
2715 return NULL;
2716 GetWMgrPort(&wPort);
2717 _res = Py_BuildValue("O&",
2718 GrafObj_New, wPort);
2719 return _res;
2721 #endif
2723 #if !TARGET_API_MAC_CARBON
2725 static PyObject *Win_GetCWMgrPort(_self, _args)
2726 PyObject *_self;
2727 PyObject *_args;
2729 PyObject *_res = NULL;
2730 CGrafPtr wMgrCPort;
2731 if (!PyArg_ParseTuple(_args, ""))
2732 return NULL;
2733 GetCWMgrPort(&wMgrCPort);
2734 _res = Py_BuildValue("O&",
2735 GrafObj_New, wMgrCPort);
2736 return _res;
2738 #endif
2740 #if !TARGET_API_MAC_CARBON
2742 static PyObject *Win_InitFloatingWindows(_self, _args)
2743 PyObject *_self;
2744 PyObject *_args;
2746 PyObject *_res = NULL;
2747 OSStatus _err;
2748 if (!PyArg_ParseTuple(_args, ""))
2749 return NULL;
2750 _err = InitFloatingWindows();
2751 if (_err != noErr) return PyMac_Error(_err);
2752 Py_INCREF(Py_None);
2753 _res = Py_None;
2754 return _res;
2756 #endif
2758 #if !TARGET_API_MAC_CARBON
2760 static PyObject *Win_InvalRect(_self, _args)
2761 PyObject *_self;
2762 PyObject *_args;
2764 PyObject *_res = NULL;
2765 Rect badRect;
2766 if (!PyArg_ParseTuple(_args, "O&",
2767 PyMac_GetRect, &badRect))
2768 return NULL;
2769 InvalRect(&badRect);
2770 Py_INCREF(Py_None);
2771 _res = Py_None;
2772 return _res;
2774 #endif
2776 #if !TARGET_API_MAC_CARBON
2778 static PyObject *Win_InvalRgn(_self, _args)
2779 PyObject *_self;
2780 PyObject *_args;
2782 PyObject *_res = NULL;
2783 RgnHandle badRgn;
2784 if (!PyArg_ParseTuple(_args, "O&",
2785 ResObj_Convert, &badRgn))
2786 return NULL;
2787 InvalRgn(badRgn);
2788 Py_INCREF(Py_None);
2789 _res = Py_None;
2790 return _res;
2792 #endif
2794 #if !TARGET_API_MAC_CARBON
2796 static PyObject *Win_ValidRect(_self, _args)
2797 PyObject *_self;
2798 PyObject *_args;
2800 PyObject *_res = NULL;
2801 Rect goodRect;
2802 if (!PyArg_ParseTuple(_args, "O&",
2803 PyMac_GetRect, &goodRect))
2804 return NULL;
2805 ValidRect(&goodRect);
2806 Py_INCREF(Py_None);
2807 _res = Py_None;
2808 return _res;
2810 #endif
2812 #if !TARGET_API_MAC_CARBON
2814 static PyObject *Win_ValidRgn(_self, _args)
2815 PyObject *_self;
2816 PyObject *_args;
2818 PyObject *_res = NULL;
2819 RgnHandle goodRgn;
2820 if (!PyArg_ParseTuple(_args, "O&",
2821 ResObj_Convert, &goodRgn))
2822 return NULL;
2823 ValidRgn(goodRgn);
2824 Py_INCREF(Py_None);
2825 _res = Py_None;
2826 return _res;
2828 #endif
2830 static PyObject *Win_CollapseAllWindows(_self, _args)
2831 PyObject *_self;
2832 PyObject *_args;
2834 PyObject *_res = NULL;
2835 OSStatus _err;
2836 Boolean collapse;
2837 if (!PyArg_ParseTuple(_args, "b",
2838 &collapse))
2839 return NULL;
2840 _err = CollapseAllWindows(collapse);
2841 if (_err != noErr) return PyMac_Error(_err);
2842 Py_INCREF(Py_None);
2843 _res = Py_None;
2844 return _res;
2847 static PyObject *Win_PinRect(_self, _args)
2848 PyObject *_self;
2849 PyObject *_args;
2851 PyObject *_res = NULL;
2852 long _rv;
2853 Rect theRect;
2854 Point thePt;
2855 if (!PyArg_ParseTuple(_args, "O&O&",
2856 PyMac_GetRect, &theRect,
2857 PyMac_GetPoint, &thePt))
2858 return NULL;
2859 _rv = PinRect(&theRect,
2860 thePt);
2861 _res = Py_BuildValue("l",
2862 _rv);
2863 return _res;
2866 static PyObject *Win_GetGrayRgn(_self, _args)
2867 PyObject *_self;
2868 PyObject *_args;
2870 PyObject *_res = NULL;
2871 RgnHandle _rv;
2872 if (!PyArg_ParseTuple(_args, ""))
2873 return NULL;
2874 _rv = GetGrayRgn();
2875 _res = Py_BuildValue("O&",
2876 ResObj_New, _rv);
2877 return _res;
2880 static PyObject *Win_GetWindowFromPort(_self, _args)
2881 PyObject *_self;
2882 PyObject *_args;
2884 PyObject *_res = NULL;
2885 WindowPtr _rv;
2886 CGrafPtr port;
2887 if (!PyArg_ParseTuple(_args, "O&",
2888 GrafObj_Convert, &port))
2889 return NULL;
2890 _rv = GetWindowFromPort(port);
2891 _res = Py_BuildValue("O&",
2892 WinObj_New, _rv);
2893 return _res;
2896 static PyObject *Win_WhichWindow(_self, _args)
2897 PyObject *_self;
2898 PyObject *_args;
2900 PyObject *_res = NULL;
2902 long ptr;
2904 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2905 return NULL;
2906 return WinObj_WhichWindow((WindowPtr)ptr);
2910 static PyObject *Win_FindWindow(_self, _args)
2911 PyObject *_self;
2912 PyObject *_args;
2914 PyObject *_res = NULL;
2915 short _rv;
2916 Point thePoint;
2917 WindowPtr theWindow;
2918 if (!PyArg_ParseTuple(_args, "O&",
2919 PyMac_GetPoint, &thePoint))
2920 return NULL;
2921 _rv = FindWindow(thePoint,
2922 &theWindow);
2923 _res = Py_BuildValue("hO&",
2924 _rv,
2925 WinObj_WhichWindow, theWindow);
2926 return _res;
2929 static PyMethodDef Win_methods[] = {
2930 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2931 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2932 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2933 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2934 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2935 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2936 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2937 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2938 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
2939 "(WindowClass windowClass, WindowAttributes attributes, Rect contentBounds) -> (WindowPtr outWindow)"},
2940 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2941 "(SInt16 resID) -> (WindowPtr outWindow)"},
2942 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2943 "() -> None"},
2944 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2945 "() -> None"},
2946 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2947 "() -> (Boolean _rv)"},
2949 #if !TARGET_API_MAC_CARBON
2950 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2951 "(PixPatHandle deskPixPat) -> None"},
2952 #endif
2953 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2954 "() -> (Boolean _rv, EventRecord theEvent)"},
2955 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
2956 "(Point thePoint) -> (WindowPartCode _rv, WindowPtr window)"},
2957 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2958 "() -> (WindowPtr _rv)"},
2959 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2960 "() -> (WindowPtr _rv)"},
2962 #if TARGET_API_MAC_CARBON
2963 {"GetFrontWindowOfClass", (PyCFunction)Win_GetFrontWindowOfClass, 1,
2964 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2965 #endif
2967 #if TARGET_API_MAC_CARBON
2968 {"FindWindowOfClass", (PyCFunction)Win_FindWindowOfClass, 1,
2969 "(Point where, WindowClass inWindowClass) -> (WindowPtr outWindow, WindowPartCode outWindowPart)"},
2970 #endif
2972 #if !TARGET_API_MAC_CARBON
2973 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2974 "() -> None"},
2975 #endif
2977 #if !TARGET_API_MAC_CARBON
2978 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2979 "() -> (GrafPtr wPort)"},
2980 #endif
2982 #if !TARGET_API_MAC_CARBON
2983 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2984 "() -> (CGrafPtr wMgrCPort)"},
2985 #endif
2987 #if !TARGET_API_MAC_CARBON
2988 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2989 "() -> None"},
2990 #endif
2992 #if !TARGET_API_MAC_CARBON
2993 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2994 "(Rect badRect) -> None"},
2995 #endif
2997 #if !TARGET_API_MAC_CARBON
2998 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2999 "(RgnHandle badRgn) -> None"},
3000 #endif
3002 #if !TARGET_API_MAC_CARBON
3003 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
3004 "(Rect goodRect) -> None"},
3005 #endif
3007 #if !TARGET_API_MAC_CARBON
3008 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
3009 "(RgnHandle goodRgn) -> None"},
3010 #endif
3011 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
3012 "(Boolean collapse) -> None"},
3013 {"PinRect", (PyCFunction)Win_PinRect, 1,
3014 "(Rect theRect, Point thePt) -> (long _rv)"},
3015 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
3016 "() -> (RgnHandle _rv)"},
3017 {"GetWindowFromPort", (PyCFunction)Win_GetWindowFromPort, 1,
3018 "(CGrafPtr port) -> (WindowPtr _rv)"},
3019 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
3020 "Resolve an integer WindowPtr address to a Window object"},
3021 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
3022 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
3023 {NULL, NULL, 0}
3028 /* Return the object corresponding to the window, or NULL */
3030 PyObject *
3031 WinObj_WhichWindow(w)
3032 WindowPtr w;
3034 PyObject *it;
3036 if (w == NULL) {
3037 it = Py_None;
3038 Py_INCREF(it);
3039 } else {
3040 it = (PyObject *) GetWRefCon(w);
3041 if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
3042 it = WinObj_New(w);
3043 ((WindowObject *)it)->ob_freeit = NULL;
3044 } else {
3045 Py_INCREF(it);
3048 return it;
3052 void initWin()
3054 PyObject *m;
3055 PyObject *d;
3060 m = Py_InitModule("Win", Win_methods);
3061 d = PyModule_GetDict(m);
3062 Win_Error = PyMac_GetOSErrException();
3063 if (Win_Error == NULL ||
3064 PyDict_SetItemString(d, "Error", Win_Error) != 0)
3065 return;
3066 Window_Type.ob_type = &PyType_Type;
3067 Py_INCREF(&Window_Type);
3068 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
3069 Py_FatalError("can't initialize WindowType");
3072 /* ========================= End module Win ========================= */