Null commit with -f option to force an uprev and put HEADs firmly on the trunk.
[python/dscho.git] / Mac / Modules / win / Winmodule.c
blobd8072513c208c87683f55eb61691cc6d1f847b14
2 /* =========================== Module Win =========================== */
4 #include "Python.h"
8 #include "macglue.h"
9 #include "pymactoolbox.h"
11 #ifdef WITHOUT_FRAMEWORKS
12 #include <Windows.h>
13 #else
14 #include <Carbon/Carbon.h>
15 #endif
17 #ifdef USE_TOOLBOX_OBJECT_GLUE
18 extern PyObject *_WinObj_New(WindowRef);
19 extern PyObject *_WinObj_WhichWindow(WindowRef);
20 extern int _WinObj_Convert(PyObject *, WindowRef *);
22 #define WinObj_New _WinObj_New
23 #define WinObj_WhichWindow _WinObj_WhichWindow
24 #define WinObj_Convert _WinObj_Convert
25 #endif
27 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
28 /* Carbon calls that we emulate in classic mode */
29 #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
30 #define GetWindowFromPort(port) ((WindowRef)(port))
31 #define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
32 #define IsPointerValid(p) (((long)p&3) == 0)
33 #endif
34 #if ACCESSOR_CALLS_ARE_FUNCTIONS
35 /* Classic calls that we emulate in carbon mode */
36 #define GetWindowUpdateRgn(win, rgn) GetWindowRegion((win), kWindowUpdateRgn, (rgn))
37 #define GetWindowStructureRgn(win, rgn) GetWindowRegion((win), kWindowStructureRgn, (rgn))
38 #define GetWindowContentRgn(win, rgn) GetWindowRegion((win), kWindowContentRgn, (rgn))
39 #endif
41 /* Function to dispose a window, with a "normal" calling sequence */
42 static void
43 PyMac_AutoDisposeWindow(WindowPtr w)
45 DisposeWindow(w);
48 static PyObject *Win_Error;
50 /* ----------------------- Object type Window ----------------------- */
52 PyTypeObject Window_Type;
54 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
56 typedef struct WindowObject {
57 PyObject_HEAD
58 WindowPtr ob_itself;
59 void (*ob_freeit)(WindowPtr ptr);
60 } WindowObject;
62 PyObject *WinObj_New(WindowPtr itself)
64 WindowObject *it;
65 if (itself == NULL) return PyMac_Error(resNotFound);
66 it = PyObject_NEW(WindowObject, &Window_Type);
67 if (it == NULL) return NULL;
68 it->ob_itself = itself;
69 it->ob_freeit = NULL;
70 if (GetWRefCon(itself) == 0)
72 SetWRefCon(itself, (long)it);
73 it->ob_freeit = PyMac_AutoDisposeWindow;
75 return (PyObject *)it;
77 WinObj_Convert(PyObject *v, WindowPtr *p_itself)
80 if (v == Py_None) { *p_itself = NULL; return 1; }
81 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
84 DialogRef dlg;
85 if (DlgObj_Convert(v, &dlg) && dlg) {
86 *p_itself = GetDialogWindow(dlg);
87 return 1;
89 PyErr_Clear();
91 if (!WinObj_Check(v))
93 PyErr_SetString(PyExc_TypeError, "Window required");
94 return 0;
96 *p_itself = ((WindowObject *)v)->ob_itself;
97 return 1;
100 static void WinObj_dealloc(WindowObject *self)
102 if (self->ob_freeit && self->ob_itself)
104 SetWRefCon(self->ob_itself, 0);
105 self->ob_freeit(self->ob_itself);
107 self->ob_itself = NULL;
108 self->ob_freeit = NULL;
109 PyMem_DEL(self);
112 static PyObject *WinObj_GetWindowOwnerCount(WindowObject *_self, PyObject *_args)
114 PyObject *_res = NULL;
115 OSStatus _err;
116 UInt32 outCount;
117 if (!PyArg_ParseTuple(_args, ""))
118 return NULL;
119 _err = GetWindowOwnerCount(_self->ob_itself,
120 &outCount);
121 if (_err != noErr) return PyMac_Error(_err);
122 _res = Py_BuildValue("l",
123 outCount);
124 return _res;
127 static PyObject *WinObj_CloneWindow(WindowObject *_self, PyObject *_args)
129 PyObject *_res = NULL;
130 OSStatus _err;
131 if (!PyArg_ParseTuple(_args, ""))
132 return NULL;
133 _err = CloneWindow(_self->ob_itself);
134 if (_err != noErr) return PyMac_Error(_err);
135 Py_INCREF(Py_None);
136 _res = Py_None;
137 return _res;
140 #if TARGET_API_MAC_CARBON
142 static PyObject *WinObj_ReshapeCustomWindow(WindowObject *_self, PyObject *_args)
144 PyObject *_res = NULL;
145 OSStatus _err;
146 if (!PyArg_ParseTuple(_args, ""))
147 return NULL;
148 _err = ReshapeCustomWindow(_self->ob_itself);
149 if (_err != noErr) return PyMac_Error(_err);
150 Py_INCREF(Py_None);
151 _res = Py_None;
152 return _res;
154 #endif
156 static PyObject *WinObj_GetWindowClass(WindowObject *_self, PyObject *_args)
158 PyObject *_res = NULL;
159 OSStatus _err;
160 WindowClass outClass;
161 if (!PyArg_ParseTuple(_args, ""))
162 return NULL;
163 _err = GetWindowClass(_self->ob_itself,
164 &outClass);
165 if (_err != noErr) return PyMac_Error(_err);
166 _res = Py_BuildValue("l",
167 outClass);
168 return _res;
171 static PyObject *WinObj_GetWindowAttributes(WindowObject *_self, PyObject *_args)
173 PyObject *_res = NULL;
174 OSStatus _err;
175 WindowAttributes outAttributes;
176 if (!PyArg_ParseTuple(_args, ""))
177 return NULL;
178 _err = GetWindowAttributes(_self->ob_itself,
179 &outAttributes);
180 if (_err != noErr) return PyMac_Error(_err);
181 _res = Py_BuildValue("l",
182 outAttributes);
183 return _res;
186 #if TARGET_API_MAC_CARBON
188 static PyObject *WinObj_ChangeWindowAttributes(WindowObject *_self, PyObject *_args)
190 PyObject *_res = NULL;
191 OSStatus _err;
192 WindowAttributes setTheseAttributes;
193 WindowAttributes clearTheseAttributes;
194 if (!PyArg_ParseTuple(_args, "ll",
195 &setTheseAttributes,
196 &clearTheseAttributes))
197 return NULL;
198 _err = ChangeWindowAttributes(_self->ob_itself,
199 setTheseAttributes,
200 clearTheseAttributes);
201 if (_err != noErr) return PyMac_Error(_err);
202 Py_INCREF(Py_None);
203 _res = Py_None;
204 return _res;
206 #endif
208 #if !TARGET_API_MAC_CARBON
210 static PyObject *WinObj_SetWinColor(WindowObject *_self, PyObject *_args)
212 PyObject *_res = NULL;
213 WCTabHandle newColorTable;
214 if (!PyArg_ParseTuple(_args, "O&",
215 ResObj_Convert, &newColorTable))
216 return NULL;
217 SetWinColor(_self->ob_itself,
218 newColorTable);
219 Py_INCREF(Py_None);
220 _res = Py_None;
221 return _res;
223 #endif
225 static PyObject *WinObj_SetWindowContentColor(WindowObject *_self, PyObject *_args)
227 PyObject *_res = NULL;
228 OSStatus _err;
229 RGBColor color;
230 if (!PyArg_ParseTuple(_args, "O&",
231 QdRGB_Convert, &color))
232 return NULL;
233 _err = SetWindowContentColor(_self->ob_itself,
234 &color);
235 if (_err != noErr) return PyMac_Error(_err);
236 Py_INCREF(Py_None);
237 _res = Py_None;
238 return _res;
241 static PyObject *WinObj_GetWindowContentColor(WindowObject *_self, PyObject *_args)
243 PyObject *_res = NULL;
244 OSStatus _err;
245 RGBColor color;
246 if (!PyArg_ParseTuple(_args, ""))
247 return NULL;
248 _err = GetWindowContentColor(_self->ob_itself,
249 &color);
250 if (_err != noErr) return PyMac_Error(_err);
251 _res = Py_BuildValue("O&",
252 QdRGB_New, &color);
253 return _res;
256 static PyObject *WinObj_GetWindowContentPattern(WindowObject *_self, PyObject *_args)
258 PyObject *_res = NULL;
259 OSStatus _err;
260 PixPatHandle outPixPat;
261 if (!PyArg_ParseTuple(_args, "O&",
262 ResObj_Convert, &outPixPat))
263 return NULL;
264 _err = GetWindowContentPattern(_self->ob_itself,
265 outPixPat);
266 if (_err != noErr) return PyMac_Error(_err);
267 Py_INCREF(Py_None);
268 _res = Py_None;
269 return _res;
272 static PyObject *WinObj_SetWindowContentPattern(WindowObject *_self, PyObject *_args)
274 PyObject *_res = NULL;
275 OSStatus _err;
276 PixPatHandle pixPat;
277 if (!PyArg_ParseTuple(_args, "O&",
278 ResObj_Convert, &pixPat))
279 return NULL;
280 _err = SetWindowContentPattern(_self->ob_itself,
281 pixPat);
282 if (_err != noErr) return PyMac_Error(_err);
283 Py_INCREF(Py_None);
284 _res = Py_None;
285 return _res;
288 #if TARGET_API_MAC_CARBON
290 static PyObject *WinObj_ScrollWindowRect(WindowObject *_self, PyObject *_args)
292 PyObject *_res = NULL;
293 OSStatus _err;
294 Rect inScrollRect;
295 SInt16 inHPixels;
296 SInt16 inVPixels;
297 ScrollWindowOptions inOptions;
298 RgnHandle outExposedRgn;
299 if (!PyArg_ParseTuple(_args, "O&hhlO&",
300 PyMac_GetRect, &inScrollRect,
301 &inHPixels,
302 &inVPixels,
303 &inOptions,
304 ResObj_Convert, &outExposedRgn))
305 return NULL;
306 _err = ScrollWindowRect(_self->ob_itself,
307 &inScrollRect,
308 inHPixels,
309 inVPixels,
310 inOptions,
311 outExposedRgn);
312 if (_err != noErr) return PyMac_Error(_err);
313 Py_INCREF(Py_None);
314 _res = Py_None;
315 return _res;
317 #endif
319 #if TARGET_API_MAC_CARBON
321 static PyObject *WinObj_ScrollWindowRegion(WindowObject *_self, PyObject *_args)
323 PyObject *_res = NULL;
324 OSStatus _err;
325 RgnHandle inScrollRgn;
326 SInt16 inHPixels;
327 SInt16 inVPixels;
328 ScrollWindowOptions inOptions;
329 RgnHandle outExposedRgn;
330 if (!PyArg_ParseTuple(_args, "O&hhlO&",
331 ResObj_Convert, &inScrollRgn,
332 &inHPixels,
333 &inVPixels,
334 &inOptions,
335 ResObj_Convert, &outExposedRgn))
336 return NULL;
337 _err = ScrollWindowRegion(_self->ob_itself,
338 inScrollRgn,
339 inHPixels,
340 inVPixels,
341 inOptions,
342 outExposedRgn);
343 if (_err != noErr) return PyMac_Error(_err);
344 Py_INCREF(Py_None);
345 _res = Py_None;
346 return _res;
348 #endif
350 static PyObject *WinObj_ClipAbove(WindowObject *_self, PyObject *_args)
352 PyObject *_res = NULL;
353 if (!PyArg_ParseTuple(_args, ""))
354 return NULL;
355 ClipAbove(_self->ob_itself);
356 Py_INCREF(Py_None);
357 _res = Py_None;
358 return _res;
361 #if !TARGET_API_MAC_CARBON
363 static PyObject *WinObj_SaveOld(WindowObject *_self, PyObject *_args)
365 PyObject *_res = NULL;
366 if (!PyArg_ParseTuple(_args, ""))
367 return NULL;
368 SaveOld(_self->ob_itself);
369 Py_INCREF(Py_None);
370 _res = Py_None;
371 return _res;
373 #endif
375 #if !TARGET_API_MAC_CARBON
377 static PyObject *WinObj_DrawNew(WindowObject *_self, PyObject *_args)
379 PyObject *_res = NULL;
380 Boolean update;
381 if (!PyArg_ParseTuple(_args, "b",
382 &update))
383 return NULL;
384 DrawNew(_self->ob_itself,
385 update);
386 Py_INCREF(Py_None);
387 _res = Py_None;
388 return _res;
390 #endif
392 static PyObject *WinObj_PaintOne(WindowObject *_self, PyObject *_args)
394 PyObject *_res = NULL;
395 RgnHandle clobberedRgn;
396 if (!PyArg_ParseTuple(_args, "O&",
397 ResObj_Convert, &clobberedRgn))
398 return NULL;
399 PaintOne(_self->ob_itself,
400 clobberedRgn);
401 Py_INCREF(Py_None);
402 _res = Py_None;
403 return _res;
406 static PyObject *WinObj_PaintBehind(WindowObject *_self, PyObject *_args)
408 PyObject *_res = NULL;
409 RgnHandle clobberedRgn;
410 if (!PyArg_ParseTuple(_args, "O&",
411 ResObj_Convert, &clobberedRgn))
412 return NULL;
413 PaintBehind(_self->ob_itself,
414 clobberedRgn);
415 Py_INCREF(Py_None);
416 _res = Py_None;
417 return _res;
420 static PyObject *WinObj_CalcVis(WindowObject *_self, PyObject *_args)
422 PyObject *_res = NULL;
423 if (!PyArg_ParseTuple(_args, ""))
424 return NULL;
425 CalcVis(_self->ob_itself);
426 Py_INCREF(Py_None);
427 _res = Py_None;
428 return _res;
431 static PyObject *WinObj_CalcVisBehind(WindowObject *_self, PyObject *_args)
433 PyObject *_res = NULL;
434 RgnHandle clobberedRgn;
435 if (!PyArg_ParseTuple(_args, "O&",
436 ResObj_Convert, &clobberedRgn))
437 return NULL;
438 CalcVisBehind(_self->ob_itself,
439 clobberedRgn);
440 Py_INCREF(Py_None);
441 _res = Py_None;
442 return _res;
445 static PyObject *WinObj_BringToFront(WindowObject *_self, PyObject *_args)
447 PyObject *_res = NULL;
448 if (!PyArg_ParseTuple(_args, ""))
449 return NULL;
450 BringToFront(_self->ob_itself);
451 Py_INCREF(Py_None);
452 _res = Py_None;
453 return _res;
456 static PyObject *WinObj_SendBehind(WindowObject *_self, PyObject *_args)
458 PyObject *_res = NULL;
459 WindowPtr behindWindow;
460 if (!PyArg_ParseTuple(_args, "O&",
461 WinObj_Convert, &behindWindow))
462 return NULL;
463 SendBehind(_self->ob_itself,
464 behindWindow);
465 Py_INCREF(Py_None);
466 _res = Py_None;
467 return _res;
470 static PyObject *WinObj_SelectWindow(WindowObject *_self, PyObject *_args)
472 PyObject *_res = NULL;
473 if (!PyArg_ParseTuple(_args, ""))
474 return NULL;
475 SelectWindow(_self->ob_itself);
476 Py_INCREF(Py_None);
477 _res = Py_None;
478 return _res;
481 #if TARGET_API_MAC_CARBON
483 static PyObject *WinObj_GetNextWindowOfClass(WindowObject *_self, PyObject *_args)
485 PyObject *_res = NULL;
486 WindowPtr _rv;
487 WindowClass inWindowClass;
488 Boolean mustBeVisible;
489 if (!PyArg_ParseTuple(_args, "lb",
490 &inWindowClass,
491 &mustBeVisible))
492 return NULL;
493 _rv = GetNextWindowOfClass(_self->ob_itself,
494 inWindowClass,
495 mustBeVisible);
496 _res = Py_BuildValue("O&",
497 WinObj_New, _rv);
498 return _res;
500 #endif
502 #if !TARGET_API_MAC_CARBON
504 static PyObject *WinObj_IsValidWindowPtr(WindowObject *_self, PyObject *_args)
506 PyObject *_res = NULL;
507 Boolean _rv;
508 if (!PyArg_ParseTuple(_args, ""))
509 return NULL;
510 _rv = IsValidWindowPtr(_self->ob_itself);
511 _res = Py_BuildValue("b",
512 _rv);
513 return _res;
515 #endif
517 static PyObject *WinObj_HiliteWindow(WindowObject *_self, PyObject *_args)
519 PyObject *_res = NULL;
520 Boolean fHilite;
521 if (!PyArg_ParseTuple(_args, "b",
522 &fHilite))
523 return NULL;
524 HiliteWindow(_self->ob_itself,
525 fHilite);
526 Py_INCREF(Py_None);
527 _res = Py_None;
528 return _res;
531 static PyObject *WinObj_SetWRefCon(WindowObject *_self, PyObject *_args)
533 PyObject *_res = NULL;
534 long data;
535 if (!PyArg_ParseTuple(_args, "l",
536 &data))
537 return NULL;
538 SetWRefCon(_self->ob_itself,
539 data);
540 Py_INCREF(Py_None);
541 _res = Py_None;
542 return _res;
545 static PyObject *WinObj_GetWRefCon(WindowObject *_self, PyObject *_args)
547 PyObject *_res = NULL;
548 long _rv;
549 if (!PyArg_ParseTuple(_args, ""))
550 return NULL;
551 _rv = GetWRefCon(_self->ob_itself);
552 _res = Py_BuildValue("l",
553 _rv);
554 return _res;
557 static PyObject *WinObj_SetWindowPic(WindowObject *_self, PyObject *_args)
559 PyObject *_res = NULL;
560 PicHandle pic;
561 if (!PyArg_ParseTuple(_args, "O&",
562 ResObj_Convert, &pic))
563 return NULL;
564 SetWindowPic(_self->ob_itself,
565 pic);
566 Py_INCREF(Py_None);
567 _res = Py_None;
568 return _res;
571 static PyObject *WinObj_GetWindowPic(WindowObject *_self, PyObject *_args)
573 PyObject *_res = NULL;
574 PicHandle _rv;
575 if (!PyArg_ParseTuple(_args, ""))
576 return NULL;
577 _rv = GetWindowPic(_self->ob_itself);
578 _res = Py_BuildValue("O&",
579 ResObj_New, _rv);
580 return _res;
583 static PyObject *WinObj_GetWVariant(WindowObject *_self, PyObject *_args)
585 PyObject *_res = NULL;
586 short _rv;
587 if (!PyArg_ParseTuple(_args, ""))
588 return NULL;
589 _rv = GetWVariant(_self->ob_itself);
590 _res = Py_BuildValue("h",
591 _rv);
592 return _res;
595 static PyObject *WinObj_GetWindowFeatures(WindowObject *_self, PyObject *_args)
597 PyObject *_res = NULL;
598 OSStatus _err;
599 UInt32 outFeatures;
600 if (!PyArg_ParseTuple(_args, ""))
601 return NULL;
602 _err = GetWindowFeatures(_self->ob_itself,
603 &outFeatures);
604 if (_err != noErr) return PyMac_Error(_err);
605 _res = Py_BuildValue("l",
606 outFeatures);
607 return _res;
610 static PyObject *WinObj_GetWindowRegion(WindowObject *_self, PyObject *_args)
612 PyObject *_res = NULL;
613 OSStatus _err;
614 WindowRegionCode inRegionCode;
615 RgnHandle ioWinRgn;
616 if (!PyArg_ParseTuple(_args, "HO&",
617 &inRegionCode,
618 ResObj_Convert, &ioWinRgn))
619 return NULL;
620 _err = GetWindowRegion(_self->ob_itself,
621 inRegionCode,
622 ioWinRgn);
623 if (_err != noErr) return PyMac_Error(_err);
624 Py_INCREF(Py_None);
625 _res = Py_None;
626 return _res;
629 static PyObject *WinObj_BeginUpdate(WindowObject *_self, PyObject *_args)
631 PyObject *_res = NULL;
632 if (!PyArg_ParseTuple(_args, ""))
633 return NULL;
634 BeginUpdate(_self->ob_itself);
635 Py_INCREF(Py_None);
636 _res = Py_None;
637 return _res;
640 static PyObject *WinObj_EndUpdate(WindowObject *_self, PyObject *_args)
642 PyObject *_res = NULL;
643 if (!PyArg_ParseTuple(_args, ""))
644 return NULL;
645 EndUpdate(_self->ob_itself);
646 Py_INCREF(Py_None);
647 _res = Py_None;
648 return _res;
651 static PyObject *WinObj_InvalWindowRgn(WindowObject *_self, PyObject *_args)
653 PyObject *_res = NULL;
654 OSStatus _err;
655 RgnHandle region;
656 if (!PyArg_ParseTuple(_args, "O&",
657 ResObj_Convert, &region))
658 return NULL;
659 _err = InvalWindowRgn(_self->ob_itself,
660 region);
661 if (_err != noErr) return PyMac_Error(_err);
662 Py_INCREF(Py_None);
663 _res = Py_None;
664 return _res;
667 static PyObject *WinObj_InvalWindowRect(WindowObject *_self, PyObject *_args)
669 PyObject *_res = NULL;
670 OSStatus _err;
671 Rect bounds;
672 if (!PyArg_ParseTuple(_args, "O&",
673 PyMac_GetRect, &bounds))
674 return NULL;
675 _err = InvalWindowRect(_self->ob_itself,
676 &bounds);
677 if (_err != noErr) return PyMac_Error(_err);
678 Py_INCREF(Py_None);
679 _res = Py_None;
680 return _res;
683 static PyObject *WinObj_ValidWindowRgn(WindowObject *_self, PyObject *_args)
685 PyObject *_res = NULL;
686 OSStatus _err;
687 RgnHandle region;
688 if (!PyArg_ParseTuple(_args, "O&",
689 ResObj_Convert, &region))
690 return NULL;
691 _err = ValidWindowRgn(_self->ob_itself,
692 region);
693 if (_err != noErr) return PyMac_Error(_err);
694 Py_INCREF(Py_None);
695 _res = Py_None;
696 return _res;
699 static PyObject *WinObj_ValidWindowRect(WindowObject *_self, PyObject *_args)
701 PyObject *_res = NULL;
702 OSStatus _err;
703 Rect bounds;
704 if (!PyArg_ParseTuple(_args, "O&",
705 PyMac_GetRect, &bounds))
706 return NULL;
707 _err = ValidWindowRect(_self->ob_itself,
708 &bounds);
709 if (_err != noErr) return PyMac_Error(_err);
710 Py_INCREF(Py_None);
711 _res = Py_None;
712 return _res;
715 static PyObject *WinObj_DrawGrowIcon(WindowObject *_self, PyObject *_args)
717 PyObject *_res = NULL;
718 if (!PyArg_ParseTuple(_args, ""))
719 return NULL;
720 DrawGrowIcon(_self->ob_itself);
721 Py_INCREF(Py_None);
722 _res = Py_None;
723 return _res;
726 static PyObject *WinObj_SetWTitle(WindowObject *_self, PyObject *_args)
728 PyObject *_res = NULL;
729 Str255 title;
730 if (!PyArg_ParseTuple(_args, "O&",
731 PyMac_GetStr255, title))
732 return NULL;
733 SetWTitle(_self->ob_itself,
734 title);
735 Py_INCREF(Py_None);
736 _res = Py_None;
737 return _res;
740 static PyObject *WinObj_GetWTitle(WindowObject *_self, PyObject *_args)
742 PyObject *_res = NULL;
743 Str255 title;
744 if (!PyArg_ParseTuple(_args, ""))
745 return NULL;
746 GetWTitle(_self->ob_itself,
747 title);
748 _res = Py_BuildValue("O&",
749 PyMac_BuildStr255, title);
750 return _res;
753 static PyObject *WinObj_SetWindowProxyFSSpec(WindowObject *_self, PyObject *_args)
755 PyObject *_res = NULL;
756 OSStatus _err;
757 FSSpec inFile;
758 if (!PyArg_ParseTuple(_args, "O&",
759 PyMac_GetFSSpec, &inFile))
760 return NULL;
761 _err = SetWindowProxyFSSpec(_self->ob_itself,
762 &inFile);
763 if (_err != noErr) return PyMac_Error(_err);
764 Py_INCREF(Py_None);
765 _res = Py_None;
766 return _res;
769 static PyObject *WinObj_GetWindowProxyFSSpec(WindowObject *_self, PyObject *_args)
771 PyObject *_res = NULL;
772 OSStatus _err;
773 FSSpec outFile;
774 if (!PyArg_ParseTuple(_args, ""))
775 return NULL;
776 _err = GetWindowProxyFSSpec(_self->ob_itself,
777 &outFile);
778 if (_err != noErr) return PyMac_Error(_err);
779 _res = Py_BuildValue("O&",
780 PyMac_BuildFSSpec, outFile);
781 return _res;
784 static PyObject *WinObj_SetWindowProxyAlias(WindowObject *_self, PyObject *_args)
786 PyObject *_res = NULL;
787 OSStatus _err;
788 AliasHandle alias;
789 if (!PyArg_ParseTuple(_args, "O&",
790 ResObj_Convert, &alias))
791 return NULL;
792 _err = SetWindowProxyAlias(_self->ob_itself,
793 alias);
794 if (_err != noErr) return PyMac_Error(_err);
795 Py_INCREF(Py_None);
796 _res = Py_None;
797 return _res;
800 static PyObject *WinObj_GetWindowProxyAlias(WindowObject *_self, PyObject *_args)
802 PyObject *_res = NULL;
803 OSStatus _err;
804 AliasHandle alias;
805 if (!PyArg_ParseTuple(_args, ""))
806 return NULL;
807 _err = GetWindowProxyAlias(_self->ob_itself,
808 &alias);
809 if (_err != noErr) return PyMac_Error(_err);
810 _res = Py_BuildValue("O&",
811 ResObj_New, alias);
812 return _res;
815 static PyObject *WinObj_SetWindowProxyCreatorAndType(WindowObject *_self, PyObject *_args)
817 PyObject *_res = NULL;
818 OSStatus _err;
819 OSType fileCreator;
820 OSType fileType;
821 SInt16 vRefNum;
822 if (!PyArg_ParseTuple(_args, "O&O&h",
823 PyMac_GetOSType, &fileCreator,
824 PyMac_GetOSType, &fileType,
825 &vRefNum))
826 return NULL;
827 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
828 fileCreator,
829 fileType,
830 vRefNum);
831 if (_err != noErr) return PyMac_Error(_err);
832 Py_INCREF(Py_None);
833 _res = Py_None;
834 return _res;
837 static PyObject *WinObj_GetWindowProxyIcon(WindowObject *_self, PyObject *_args)
839 PyObject *_res = NULL;
840 OSStatus _err;
841 IconRef outIcon;
842 if (!PyArg_ParseTuple(_args, ""))
843 return NULL;
844 _err = GetWindowProxyIcon(_self->ob_itself,
845 &outIcon);
846 if (_err != noErr) return PyMac_Error(_err);
847 _res = Py_BuildValue("O&",
848 ResObj_New, outIcon);
849 return _res;
852 static PyObject *WinObj_SetWindowProxyIcon(WindowObject *_self, PyObject *_args)
854 PyObject *_res = NULL;
855 OSStatus _err;
856 IconRef icon;
857 if (!PyArg_ParseTuple(_args, "O&",
858 ResObj_Convert, &icon))
859 return NULL;
860 _err = SetWindowProxyIcon(_self->ob_itself,
861 icon);
862 if (_err != noErr) return PyMac_Error(_err);
863 Py_INCREF(Py_None);
864 _res = Py_None;
865 return _res;
868 static PyObject *WinObj_RemoveWindowProxy(WindowObject *_self, PyObject *_args)
870 PyObject *_res = NULL;
871 OSStatus _err;
872 if (!PyArg_ParseTuple(_args, ""))
873 return NULL;
874 _err = RemoveWindowProxy(_self->ob_itself);
875 if (_err != noErr) return PyMac_Error(_err);
876 Py_INCREF(Py_None);
877 _res = Py_None;
878 return _res;
881 static PyObject *WinObj_BeginWindowProxyDrag(WindowObject *_self, PyObject *_args)
883 PyObject *_res = NULL;
884 OSStatus _err;
885 DragReference outNewDrag;
886 RgnHandle outDragOutlineRgn;
887 if (!PyArg_ParseTuple(_args, "O&",
888 ResObj_Convert, &outDragOutlineRgn))
889 return NULL;
890 _err = BeginWindowProxyDrag(_self->ob_itself,
891 &outNewDrag,
892 outDragOutlineRgn);
893 if (_err != noErr) return PyMac_Error(_err);
894 _res = Py_BuildValue("O&",
895 DragObj_New, outNewDrag);
896 return _res;
899 static PyObject *WinObj_EndWindowProxyDrag(WindowObject *_self, PyObject *_args)
901 PyObject *_res = NULL;
902 OSStatus _err;
903 DragReference theDrag;
904 if (!PyArg_ParseTuple(_args, "O&",
905 DragObj_Convert, &theDrag))
906 return NULL;
907 _err = EndWindowProxyDrag(_self->ob_itself,
908 theDrag);
909 if (_err != noErr) return PyMac_Error(_err);
910 Py_INCREF(Py_None);
911 _res = Py_None;
912 return _res;
915 static PyObject *WinObj_TrackWindowProxyFromExistingDrag(WindowObject *_self, PyObject *_args)
917 PyObject *_res = NULL;
918 OSStatus _err;
919 Point startPt;
920 DragReference drag;
921 RgnHandle inDragOutlineRgn;
922 if (!PyArg_ParseTuple(_args, "O&O&O&",
923 PyMac_GetPoint, &startPt,
924 DragObj_Convert, &drag,
925 ResObj_Convert, &inDragOutlineRgn))
926 return NULL;
927 _err = TrackWindowProxyFromExistingDrag(_self->ob_itself,
928 startPt,
929 drag,
930 inDragOutlineRgn);
931 if (_err != noErr) return PyMac_Error(_err);
932 Py_INCREF(Py_None);
933 _res = Py_None;
934 return _res;
937 static PyObject *WinObj_TrackWindowProxyDrag(WindowObject *_self, PyObject *_args)
939 PyObject *_res = NULL;
940 OSStatus _err;
941 Point startPt;
942 if (!PyArg_ParseTuple(_args, "O&",
943 PyMac_GetPoint, &startPt))
944 return NULL;
945 _err = TrackWindowProxyDrag(_self->ob_itself,
946 startPt);
947 if (_err != noErr) return PyMac_Error(_err);
948 Py_INCREF(Py_None);
949 _res = Py_None;
950 return _res;
953 static PyObject *WinObj_IsWindowModified(WindowObject *_self, PyObject *_args)
955 PyObject *_res = NULL;
956 Boolean _rv;
957 if (!PyArg_ParseTuple(_args, ""))
958 return NULL;
959 _rv = IsWindowModified(_self->ob_itself);
960 _res = Py_BuildValue("b",
961 _rv);
962 return _res;
965 static PyObject *WinObj_SetWindowModified(WindowObject *_self, PyObject *_args)
967 PyObject *_res = NULL;
968 OSStatus _err;
969 Boolean modified;
970 if (!PyArg_ParseTuple(_args, "b",
971 &modified))
972 return NULL;
973 _err = SetWindowModified(_self->ob_itself,
974 modified);
975 if (_err != noErr) return PyMac_Error(_err);
976 Py_INCREF(Py_None);
977 _res = Py_None;
978 return _res;
981 static PyObject *WinObj_IsWindowPathSelectClick(WindowObject *_self, PyObject *_args)
983 PyObject *_res = NULL;
984 Boolean _rv;
985 EventRecord event;
986 if (!PyArg_ParseTuple(_args, "O&",
987 PyMac_GetEventRecord, &event))
988 return NULL;
989 _rv = IsWindowPathSelectClick(_self->ob_itself,
990 &event);
991 _res = Py_BuildValue("b",
992 _rv);
993 return _res;
996 static PyObject *WinObj_WindowPathSelect(WindowObject *_self, PyObject *_args)
998 PyObject *_res = NULL;
999 OSStatus _err;
1000 MenuHandle menu;
1001 SInt32 outMenuResult;
1002 if (!PyArg_ParseTuple(_args, "O&",
1003 MenuObj_Convert, &menu))
1004 return NULL;
1005 _err = WindowPathSelect(_self->ob_itself,
1006 menu,
1007 &outMenuResult);
1008 if (_err != noErr) return PyMac_Error(_err);
1009 _res = Py_BuildValue("l",
1010 outMenuResult);
1011 return _res;
1014 static PyObject *WinObj_HiliteWindowFrameForDrag(WindowObject *_self, PyObject *_args)
1016 PyObject *_res = NULL;
1017 OSStatus _err;
1018 Boolean hilited;
1019 if (!PyArg_ParseTuple(_args, "b",
1020 &hilited))
1021 return NULL;
1022 _err = HiliteWindowFrameForDrag(_self->ob_itself,
1023 hilited);
1024 if (_err != noErr) return PyMac_Error(_err);
1025 Py_INCREF(Py_None);
1026 _res = Py_None;
1027 return _res;
1030 static PyObject *WinObj_TransitionWindow(WindowObject *_self, PyObject *_args)
1032 PyObject *_res = NULL;
1033 OSStatus _err;
1034 WindowTransitionEffect effect;
1035 WindowTransitionAction action;
1036 Rect rect;
1037 if (!PyArg_ParseTuple(_args, "llO&",
1038 &effect,
1039 &action,
1040 PyMac_GetRect, &rect))
1041 return NULL;
1042 _err = TransitionWindow(_self->ob_itself,
1043 effect,
1044 action,
1045 &rect);
1046 if (_err != noErr) return PyMac_Error(_err);
1047 Py_INCREF(Py_None);
1048 _res = Py_None;
1049 return _res;
1052 static PyObject *WinObj_MacMoveWindow(WindowObject *_self, PyObject *_args)
1054 PyObject *_res = NULL;
1055 short hGlobal;
1056 short vGlobal;
1057 Boolean front;
1058 if (!PyArg_ParseTuple(_args, "hhb",
1059 &hGlobal,
1060 &vGlobal,
1061 &front))
1062 return NULL;
1063 MacMoveWindow(_self->ob_itself,
1064 hGlobal,
1065 vGlobal,
1066 front);
1067 Py_INCREF(Py_None);
1068 _res = Py_None;
1069 return _res;
1072 static PyObject *WinObj_SizeWindow(WindowObject *_self, PyObject *_args)
1074 PyObject *_res = NULL;
1075 short w;
1076 short h;
1077 Boolean fUpdate;
1078 if (!PyArg_ParseTuple(_args, "hhb",
1081 &fUpdate))
1082 return NULL;
1083 SizeWindow(_self->ob_itself,
1086 fUpdate);
1087 Py_INCREF(Py_None);
1088 _res = Py_None;
1089 return _res;
1092 static PyObject *WinObj_GrowWindow(WindowObject *_self, PyObject *_args)
1094 PyObject *_res = NULL;
1095 long _rv;
1096 Point startPt;
1097 Rect bBox;
1098 if (!PyArg_ParseTuple(_args, "O&O&",
1099 PyMac_GetPoint, &startPt,
1100 PyMac_GetRect, &bBox))
1101 return NULL;
1102 _rv = GrowWindow(_self->ob_itself,
1103 startPt,
1104 &bBox);
1105 _res = Py_BuildValue("l",
1106 _rv);
1107 return _res;
1110 static PyObject *WinObj_DragWindow(WindowObject *_self, PyObject *_args)
1112 PyObject *_res = NULL;
1113 Point startPt;
1114 Rect boundsRect;
1115 if (!PyArg_ParseTuple(_args, "O&O&",
1116 PyMac_GetPoint, &startPt,
1117 PyMac_GetRect, &boundsRect))
1118 return NULL;
1119 DragWindow(_self->ob_itself,
1120 startPt,
1121 &boundsRect);
1122 Py_INCREF(Py_None);
1123 _res = Py_None;
1124 return _res;
1127 static PyObject *WinObj_ZoomWindow(WindowObject *_self, PyObject *_args)
1129 PyObject *_res = NULL;
1130 WindowPartCode partCode;
1131 Boolean front;
1132 if (!PyArg_ParseTuple(_args, "hb",
1133 &partCode,
1134 &front))
1135 return NULL;
1136 ZoomWindow(_self->ob_itself,
1137 partCode,
1138 front);
1139 Py_INCREF(Py_None);
1140 _res = Py_None;
1141 return _res;
1144 static PyObject *WinObj_IsWindowCollapsable(WindowObject *_self, PyObject *_args)
1146 PyObject *_res = NULL;
1147 Boolean _rv;
1148 if (!PyArg_ParseTuple(_args, ""))
1149 return NULL;
1150 _rv = IsWindowCollapsable(_self->ob_itself);
1151 _res = Py_BuildValue("b",
1152 _rv);
1153 return _res;
1156 static PyObject *WinObj_IsWindowCollapsed(WindowObject *_self, PyObject *_args)
1158 PyObject *_res = NULL;
1159 Boolean _rv;
1160 if (!PyArg_ParseTuple(_args, ""))
1161 return NULL;
1162 _rv = IsWindowCollapsed(_self->ob_itself);
1163 _res = Py_BuildValue("b",
1164 _rv);
1165 return _res;
1168 static PyObject *WinObj_CollapseWindow(WindowObject *_self, PyObject *_args)
1170 PyObject *_res = NULL;
1171 OSStatus _err;
1172 Boolean collapse;
1173 if (!PyArg_ParseTuple(_args, "b",
1174 &collapse))
1175 return NULL;
1176 _err = CollapseWindow(_self->ob_itself,
1177 collapse);
1178 if (_err != noErr) return PyMac_Error(_err);
1179 Py_INCREF(Py_None);
1180 _res = Py_None;
1181 return _res;
1184 static PyObject *WinObj_GetWindowBounds(WindowObject *_self, PyObject *_args)
1186 PyObject *_res = NULL;
1187 OSStatus _err;
1188 WindowRegionCode regionCode;
1189 Rect globalBounds;
1190 if (!PyArg_ParseTuple(_args, "H",
1191 &regionCode))
1192 return NULL;
1193 _err = GetWindowBounds(_self->ob_itself,
1194 regionCode,
1195 &globalBounds);
1196 if (_err != noErr) return PyMac_Error(_err);
1197 _res = Py_BuildValue("O&",
1198 PyMac_BuildRect, &globalBounds);
1199 return _res;
1202 static PyObject *WinObj_ResizeWindow(WindowObject *_self, PyObject *_args)
1204 PyObject *_res = NULL;
1205 Boolean _rv;
1206 Point startPoint;
1207 Rect sizeConstraints;
1208 Rect newContentRect;
1209 if (!PyArg_ParseTuple(_args, "O&O&",
1210 PyMac_GetPoint, &startPoint,
1211 PyMac_GetRect, &sizeConstraints))
1212 return NULL;
1213 _rv = ResizeWindow(_self->ob_itself,
1214 startPoint,
1215 &sizeConstraints,
1216 &newContentRect);
1217 _res = Py_BuildValue("bO&",
1218 _rv,
1219 PyMac_BuildRect, &newContentRect);
1220 return _res;
1223 static PyObject *WinObj_SetWindowBounds(WindowObject *_self, PyObject *_args)
1225 PyObject *_res = NULL;
1226 OSStatus _err;
1227 WindowRegionCode regionCode;
1228 Rect globalBounds;
1229 if (!PyArg_ParseTuple(_args, "HO&",
1230 &regionCode,
1231 PyMac_GetRect, &globalBounds))
1232 return NULL;
1233 _err = SetWindowBounds(_self->ob_itself,
1234 regionCode,
1235 &globalBounds);
1236 if (_err != noErr) return PyMac_Error(_err);
1237 Py_INCREF(Py_None);
1238 _res = Py_None;
1239 return _res;
1242 static PyObject *WinObj_RepositionWindow(WindowObject *_self, PyObject *_args)
1244 PyObject *_res = NULL;
1245 OSStatus _err;
1246 WindowPtr parentWindow;
1247 WindowPositionMethod method;
1248 if (!PyArg_ParseTuple(_args, "O&l",
1249 WinObj_Convert, &parentWindow,
1250 &method))
1251 return NULL;
1252 _err = RepositionWindow(_self->ob_itself,
1253 parentWindow,
1254 method);
1255 if (_err != noErr) return PyMac_Error(_err);
1256 Py_INCREF(Py_None);
1257 _res = Py_None;
1258 return _res;
1261 static PyObject *WinObj_MoveWindowStructure(WindowObject *_self, PyObject *_args)
1263 PyObject *_res = NULL;
1264 OSStatus _err;
1265 short hGlobal;
1266 short vGlobal;
1267 if (!PyArg_ParseTuple(_args, "hh",
1268 &hGlobal,
1269 &vGlobal))
1270 return NULL;
1271 _err = MoveWindowStructure(_self->ob_itself,
1272 hGlobal,
1273 vGlobal);
1274 if (_err != noErr) return PyMac_Error(_err);
1275 Py_INCREF(Py_None);
1276 _res = Py_None;
1277 return _res;
1280 static PyObject *WinObj_IsWindowInStandardState(WindowObject *_self, PyObject *_args)
1282 PyObject *_res = NULL;
1283 Boolean _rv;
1284 Point idealSize;
1285 Rect idealStandardState;
1286 if (!PyArg_ParseTuple(_args, ""))
1287 return NULL;
1288 _rv = IsWindowInStandardState(_self->ob_itself,
1289 &idealSize,
1290 &idealStandardState);
1291 _res = Py_BuildValue("bO&O&",
1292 _rv,
1293 PyMac_BuildPoint, idealSize,
1294 PyMac_BuildRect, &idealStandardState);
1295 return _res;
1298 static PyObject *WinObj_ZoomWindowIdeal(WindowObject *_self, PyObject *_args)
1300 PyObject *_res = NULL;
1301 OSStatus _err;
1302 WindowPartCode partCode;
1303 Point ioIdealSize;
1304 if (!PyArg_ParseTuple(_args, "h",
1305 &partCode))
1306 return NULL;
1307 _err = ZoomWindowIdeal(_self->ob_itself,
1308 partCode,
1309 &ioIdealSize);
1310 if (_err != noErr) return PyMac_Error(_err);
1311 _res = Py_BuildValue("O&",
1312 PyMac_BuildPoint, ioIdealSize);
1313 return _res;
1316 static PyObject *WinObj_GetWindowIdealUserState(WindowObject *_self, PyObject *_args)
1318 PyObject *_res = NULL;
1319 OSStatus _err;
1320 Rect userState;
1321 if (!PyArg_ParseTuple(_args, ""))
1322 return NULL;
1323 _err = GetWindowIdealUserState(_self->ob_itself,
1324 &userState);
1325 if (_err != noErr) return PyMac_Error(_err);
1326 _res = Py_BuildValue("O&",
1327 PyMac_BuildRect, &userState);
1328 return _res;
1331 static PyObject *WinObj_SetWindowIdealUserState(WindowObject *_self, PyObject *_args)
1333 PyObject *_res = NULL;
1334 OSStatus _err;
1335 Rect userState;
1336 if (!PyArg_ParseTuple(_args, ""))
1337 return NULL;
1338 _err = SetWindowIdealUserState(_self->ob_itself,
1339 &userState);
1340 if (_err != noErr) return PyMac_Error(_err);
1341 _res = Py_BuildValue("O&",
1342 PyMac_BuildRect, &userState);
1343 return _res;
1346 static PyObject *WinObj_HideWindow(WindowObject *_self, PyObject *_args)
1348 PyObject *_res = NULL;
1349 if (!PyArg_ParseTuple(_args, ""))
1350 return NULL;
1351 HideWindow(_self->ob_itself);
1352 Py_INCREF(Py_None);
1353 _res = Py_None;
1354 return _res;
1357 static PyObject *WinObj_MacShowWindow(WindowObject *_self, PyObject *_args)
1359 PyObject *_res = NULL;
1360 if (!PyArg_ParseTuple(_args, ""))
1361 return NULL;
1362 MacShowWindow(_self->ob_itself);
1363 Py_INCREF(Py_None);
1364 _res = Py_None;
1365 return _res;
1368 static PyObject *WinObj_ShowHide(WindowObject *_self, PyObject *_args)
1370 PyObject *_res = NULL;
1371 Boolean showFlag;
1372 if (!PyArg_ParseTuple(_args, "b",
1373 &showFlag))
1374 return NULL;
1375 ShowHide(_self->ob_itself,
1376 showFlag);
1377 Py_INCREF(Py_None);
1378 _res = Py_None;
1379 return _res;
1382 #if TARGET_API_MAC_CARBON
1384 static PyObject *WinObj_GetWindowPropertyAttributes(WindowObject *_self, PyObject *_args)
1386 PyObject *_res = NULL;
1387 OSStatus _err;
1388 OSType propertyCreator;
1389 OSType propertyTag;
1390 UInt32 attributes;
1391 if (!PyArg_ParseTuple(_args, "O&O&",
1392 PyMac_GetOSType, &propertyCreator,
1393 PyMac_GetOSType, &propertyTag))
1394 return NULL;
1395 _err = GetWindowPropertyAttributes(_self->ob_itself,
1396 propertyCreator,
1397 propertyTag,
1398 &attributes);
1399 if (_err != noErr) return PyMac_Error(_err);
1400 _res = Py_BuildValue("l",
1401 attributes);
1402 return _res;
1404 #endif
1406 #if TARGET_API_MAC_CARBON
1408 static PyObject *WinObj_ChangeWindowPropertyAttributes(WindowObject *_self, PyObject *_args)
1410 PyObject *_res = NULL;
1411 OSStatus _err;
1412 OSType propertyCreator;
1413 OSType propertyTag;
1414 UInt32 attributesToSet;
1415 UInt32 attributesToClear;
1416 if (!PyArg_ParseTuple(_args, "O&O&ll",
1417 PyMac_GetOSType, &propertyCreator,
1418 PyMac_GetOSType, &propertyTag,
1419 &attributesToSet,
1420 &attributesToClear))
1421 return NULL;
1422 _err = ChangeWindowPropertyAttributes(_self->ob_itself,
1423 propertyCreator,
1424 propertyTag,
1425 attributesToSet,
1426 attributesToClear);
1427 if (_err != noErr) return PyMac_Error(_err);
1428 Py_INCREF(Py_None);
1429 _res = Py_None;
1430 return _res;
1432 #endif
1434 static PyObject *WinObj_TrackBox(WindowObject *_self, PyObject *_args)
1436 PyObject *_res = NULL;
1437 Boolean _rv;
1438 Point thePt;
1439 WindowPartCode partCode;
1440 if (!PyArg_ParseTuple(_args, "O&h",
1441 PyMac_GetPoint, &thePt,
1442 &partCode))
1443 return NULL;
1444 _rv = TrackBox(_self->ob_itself,
1445 thePt,
1446 partCode);
1447 _res = Py_BuildValue("b",
1448 _rv);
1449 return _res;
1452 static PyObject *WinObj_TrackGoAway(WindowObject *_self, PyObject *_args)
1454 PyObject *_res = NULL;
1455 Boolean _rv;
1456 Point thePt;
1457 if (!PyArg_ParseTuple(_args, "O&",
1458 PyMac_GetPoint, &thePt))
1459 return NULL;
1460 _rv = TrackGoAway(_self->ob_itself,
1461 thePt);
1462 _res = Py_BuildValue("b",
1463 _rv);
1464 return _res;
1467 #if !TARGET_API_MAC_CARBON
1469 static PyObject *WinObj_GetAuxWin(WindowObject *_self, PyObject *_args)
1471 PyObject *_res = NULL;
1472 Boolean _rv;
1473 AuxWinHandle awHndl;
1474 if (!PyArg_ParseTuple(_args, ""))
1475 return NULL;
1476 _rv = GetAuxWin(_self->ob_itself,
1477 &awHndl);
1478 _res = Py_BuildValue("bO&",
1479 _rv,
1480 ResObj_New, awHndl);
1481 return _res;
1483 #endif
1485 #if !TARGET_API_MAC_CARBON
1487 static PyObject *WinObj_GetWindowGoAwayFlag(WindowObject *_self, PyObject *_args)
1489 PyObject *_res = NULL;
1490 Boolean _rv;
1491 if (!PyArg_ParseTuple(_args, ""))
1492 return NULL;
1493 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1494 _res = Py_BuildValue("b",
1495 _rv);
1496 return _res;
1498 #endif
1500 #if !TARGET_API_MAC_CARBON
1502 static PyObject *WinObj_GetWindowSpareFlag(WindowObject *_self, PyObject *_args)
1504 PyObject *_res = NULL;
1505 Boolean _rv;
1506 if (!PyArg_ParseTuple(_args, ""))
1507 return NULL;
1508 _rv = GetWindowSpareFlag(_self->ob_itself);
1509 _res = Py_BuildValue("b",
1510 _rv);
1511 return _res;
1513 #endif
1515 static PyObject *WinObj_GetWindowPort(WindowObject *_self, PyObject *_args)
1517 PyObject *_res = NULL;
1518 CGrafPtr _rv;
1519 if (!PyArg_ParseTuple(_args, ""))
1520 return NULL;
1521 _rv = GetWindowPort(_self->ob_itself);
1522 _res = Py_BuildValue("O&",
1523 GrafObj_New, _rv);
1524 return _res;
1527 static PyObject *WinObj_GetWindowKind(WindowObject *_self, PyObject *_args)
1529 PyObject *_res = NULL;
1530 short _rv;
1531 if (!PyArg_ParseTuple(_args, ""))
1532 return NULL;
1533 _rv = GetWindowKind(_self->ob_itself);
1534 _res = Py_BuildValue("h",
1535 _rv);
1536 return _res;
1539 static PyObject *WinObj_MacIsWindowVisible(WindowObject *_self, PyObject *_args)
1541 PyObject *_res = NULL;
1542 Boolean _rv;
1543 if (!PyArg_ParseTuple(_args, ""))
1544 return NULL;
1545 _rv = MacIsWindowVisible(_self->ob_itself);
1546 _res = Py_BuildValue("b",
1547 _rv);
1548 return _res;
1551 static PyObject *WinObj_IsWindowHilited(WindowObject *_self, PyObject *_args)
1553 PyObject *_res = NULL;
1554 Boolean _rv;
1555 if (!PyArg_ParseTuple(_args, ""))
1556 return NULL;
1557 _rv = IsWindowHilited(_self->ob_itself);
1558 _res = Py_BuildValue("b",
1559 _rv);
1560 return _res;
1563 #if TARGET_API_MAC_CARBON
1565 static PyObject *WinObj_IsWindowUpdatePending(WindowObject *_self, PyObject *_args)
1567 PyObject *_res = NULL;
1568 Boolean _rv;
1569 if (!PyArg_ParseTuple(_args, ""))
1570 return NULL;
1571 _rv = IsWindowUpdatePending(_self->ob_itself);
1572 _res = Py_BuildValue("b",
1573 _rv);
1574 return _res;
1576 #endif
1578 static PyObject *WinObj_MacGetNextWindow(WindowObject *_self, PyObject *_args)
1580 PyObject *_res = NULL;
1581 WindowPtr _rv;
1582 if (!PyArg_ParseTuple(_args, ""))
1583 return NULL;
1584 _rv = MacGetNextWindow(_self->ob_itself);
1585 _res = Py_BuildValue("O&",
1586 WinObj_New, _rv);
1587 return _res;
1590 static PyObject *WinObj_GetWindowStandardState(WindowObject *_self, PyObject *_args)
1592 PyObject *_res = NULL;
1593 Rect rect;
1594 if (!PyArg_ParseTuple(_args, ""))
1595 return NULL;
1596 GetWindowStandardState(_self->ob_itself,
1597 &rect);
1598 _res = Py_BuildValue("O&",
1599 PyMac_BuildRect, &rect);
1600 return _res;
1603 static PyObject *WinObj_GetWindowUserState(WindowObject *_self, PyObject *_args)
1605 PyObject *_res = NULL;
1606 Rect rect;
1607 if (!PyArg_ParseTuple(_args, ""))
1608 return NULL;
1609 GetWindowUserState(_self->ob_itself,
1610 &rect);
1611 _res = Py_BuildValue("O&",
1612 PyMac_BuildRect, &rect);
1613 return _res;
1616 static PyObject *WinObj_SetWindowKind(WindowObject *_self, PyObject *_args)
1618 PyObject *_res = NULL;
1619 short kind;
1620 if (!PyArg_ParseTuple(_args, "h",
1621 &kind))
1622 return NULL;
1623 SetWindowKind(_self->ob_itself,
1624 kind);
1625 Py_INCREF(Py_None);
1626 _res = Py_None;
1627 return _res;
1630 static PyObject *WinObj_SetWindowStandardState(WindowObject *_self, PyObject *_args)
1632 PyObject *_res = NULL;
1633 Rect rect;
1634 if (!PyArg_ParseTuple(_args, "O&",
1635 PyMac_GetRect, &rect))
1636 return NULL;
1637 SetWindowStandardState(_self->ob_itself,
1638 &rect);
1639 Py_INCREF(Py_None);
1640 _res = Py_None;
1641 return _res;
1644 static PyObject *WinObj_SetWindowUserState(WindowObject *_self, PyObject *_args)
1646 PyObject *_res = NULL;
1647 Rect rect;
1648 if (!PyArg_ParseTuple(_args, "O&",
1649 PyMac_GetRect, &rect))
1650 return NULL;
1651 SetWindowUserState(_self->ob_itself,
1652 &rect);
1653 Py_INCREF(Py_None);
1654 _res = Py_None;
1655 return _res;
1658 static PyObject *WinObj_SetPortWindowPort(WindowObject *_self, PyObject *_args)
1660 PyObject *_res = NULL;
1661 if (!PyArg_ParseTuple(_args, ""))
1662 return NULL;
1663 SetPortWindowPort(_self->ob_itself);
1664 Py_INCREF(Py_None);
1665 _res = Py_None;
1666 return _res;
1669 static PyObject *WinObj_GetWindowPortBounds(WindowObject *_self, PyObject *_args)
1671 PyObject *_res = NULL;
1672 Rect bounds;
1673 if (!PyArg_ParseTuple(_args, ""))
1674 return NULL;
1675 GetWindowPortBounds(_self->ob_itself,
1676 &bounds);
1677 _res = Py_BuildValue("O&",
1678 PyMac_BuildRect, &bounds);
1679 return _res;
1682 static PyObject *WinObj_IsWindowVisible(WindowObject *_self, PyObject *_args)
1684 PyObject *_res = NULL;
1685 Boolean _rv;
1686 if (!PyArg_ParseTuple(_args, ""))
1687 return NULL;
1688 _rv = IsWindowVisible(_self->ob_itself);
1689 _res = Py_BuildValue("b",
1690 _rv);
1691 return _res;
1694 #if !TARGET_API_MAC_CARBON
1696 static PyObject *WinObj_GetWindowZoomFlag(WindowObject *_self, PyObject *_args)
1698 PyObject *_res = NULL;
1699 Boolean _rv;
1700 if (!PyArg_ParseTuple(_args, ""))
1701 return NULL;
1702 _rv = GetWindowZoomFlag(_self->ob_itself);
1703 _res = Py_BuildValue("b",
1704 _rv);
1705 return _res;
1707 #endif
1709 static PyObject *WinObj_GetWindowStructureRgn(WindowObject *_self, PyObject *_args)
1711 PyObject *_res = NULL;
1712 RgnHandle r;
1713 if (!PyArg_ParseTuple(_args, "O&",
1714 ResObj_Convert, &r))
1715 return NULL;
1716 GetWindowStructureRgn(_self->ob_itself,
1718 Py_INCREF(Py_None);
1719 _res = Py_None;
1720 return _res;
1723 static PyObject *WinObj_GetWindowContentRgn(WindowObject *_self, PyObject *_args)
1725 PyObject *_res = NULL;
1726 RgnHandle r;
1727 if (!PyArg_ParseTuple(_args, "O&",
1728 ResObj_Convert, &r))
1729 return NULL;
1730 GetWindowContentRgn(_self->ob_itself,
1732 Py_INCREF(Py_None);
1733 _res = Py_None;
1734 return _res;
1737 static PyObject *WinObj_GetWindowUpdateRgn(WindowObject *_self, PyObject *_args)
1739 PyObject *_res = NULL;
1740 RgnHandle r;
1741 if (!PyArg_ParseTuple(_args, "O&",
1742 ResObj_Convert, &r))
1743 return NULL;
1744 GetWindowUpdateRgn(_self->ob_itself,
1746 Py_INCREF(Py_None);
1747 _res = Py_None;
1748 return _res;
1751 #if !TARGET_API_MAC_CARBON
1753 static PyObject *WinObj_GetWindowTitleWidth(WindowObject *_self, PyObject *_args)
1755 PyObject *_res = NULL;
1756 short _rv;
1757 if (!PyArg_ParseTuple(_args, ""))
1758 return NULL;
1759 _rv = GetWindowTitleWidth(_self->ob_itself);
1760 _res = Py_BuildValue("h",
1761 _rv);
1762 return _res;
1764 #endif
1766 static PyObject *WinObj_GetNextWindow(WindowObject *_self, PyObject *_args)
1768 PyObject *_res = NULL;
1769 WindowPtr _rv;
1770 if (!PyArg_ParseTuple(_args, ""))
1771 return NULL;
1772 _rv = GetNextWindow(_self->ob_itself);
1773 _res = Py_BuildValue("O&",
1774 WinObj_WhichWindow, _rv);
1775 return _res;
1778 #if !TARGET_API_MAC_CARBON
1780 static PyObject *WinObj_CloseWindow(WindowObject *_self, PyObject *_args)
1782 PyObject *_res = NULL;
1783 if (!PyArg_ParseTuple(_args, ""))
1784 return NULL;
1785 CloseWindow(_self->ob_itself);
1786 Py_INCREF(Py_None);
1787 _res = Py_None;
1788 return _res;
1790 #endif
1792 static PyObject *WinObj_MoveWindow(WindowObject *_self, PyObject *_args)
1794 PyObject *_res = NULL;
1795 short hGlobal;
1796 short vGlobal;
1797 Boolean front;
1798 if (!PyArg_ParseTuple(_args, "hhb",
1799 &hGlobal,
1800 &vGlobal,
1801 &front))
1802 return NULL;
1803 MoveWindow(_self->ob_itself,
1804 hGlobal,
1805 vGlobal,
1806 front);
1807 Py_INCREF(Py_None);
1808 _res = Py_None;
1809 return _res;
1812 static PyObject *WinObj_ShowWindow(WindowObject *_self, PyObject *_args)
1814 PyObject *_res = NULL;
1815 if (!PyArg_ParseTuple(_args, ""))
1816 return NULL;
1817 ShowWindow(_self->ob_itself);
1818 Py_INCREF(Py_None);
1819 _res = Py_None;
1820 return _res;
1823 static PyMethodDef WinObj_methods[] = {
1824 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
1825 "() -> (UInt32 outCount)"},
1826 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
1827 "() -> None"},
1829 #if TARGET_API_MAC_CARBON
1830 {"ReshapeCustomWindow", (PyCFunction)WinObj_ReshapeCustomWindow, 1,
1831 "() -> None"},
1832 #endif
1833 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
1834 "() -> (WindowClass outClass)"},
1835 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
1836 "() -> (WindowAttributes outAttributes)"},
1838 #if TARGET_API_MAC_CARBON
1839 {"ChangeWindowAttributes", (PyCFunction)WinObj_ChangeWindowAttributes, 1,
1840 "(WindowAttributes setTheseAttributes, WindowAttributes clearTheseAttributes) -> None"},
1841 #endif
1843 #if !TARGET_API_MAC_CARBON
1844 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1845 "(WCTabHandle newColorTable) -> None"},
1846 #endif
1847 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
1848 "(RGBColor color) -> None"},
1849 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
1850 "() -> (RGBColor color)"},
1851 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
1852 "(PixPatHandle outPixPat) -> None"},
1853 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
1854 "(PixPatHandle pixPat) -> None"},
1856 #if TARGET_API_MAC_CARBON
1857 {"ScrollWindowRect", (PyCFunction)WinObj_ScrollWindowRect, 1,
1858 "(Rect inScrollRect, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
1859 #endif
1861 #if TARGET_API_MAC_CARBON
1862 {"ScrollWindowRegion", (PyCFunction)WinObj_ScrollWindowRegion, 1,
1863 "(RgnHandle inScrollRgn, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
1864 #endif
1865 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1866 "() -> None"},
1868 #if !TARGET_API_MAC_CARBON
1869 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1870 "() -> None"},
1871 #endif
1873 #if !TARGET_API_MAC_CARBON
1874 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1875 "(Boolean update) -> None"},
1876 #endif
1877 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1878 "(RgnHandle clobberedRgn) -> None"},
1879 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1880 "(RgnHandle clobberedRgn) -> None"},
1881 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1882 "() -> None"},
1883 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1884 "(RgnHandle clobberedRgn) -> None"},
1885 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1886 "() -> None"},
1887 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1888 "(WindowPtr behindWindow) -> None"},
1889 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1890 "() -> None"},
1892 #if TARGET_API_MAC_CARBON
1893 {"GetNextWindowOfClass", (PyCFunction)WinObj_GetNextWindowOfClass, 1,
1894 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
1895 #endif
1897 #if !TARGET_API_MAC_CARBON
1898 {"IsValidWindowPtr", (PyCFunction)WinObj_IsValidWindowPtr, 1,
1899 "() -> (Boolean _rv)"},
1900 #endif
1901 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1902 "(Boolean fHilite) -> None"},
1903 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1904 "(long data) -> None"},
1905 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1906 "() -> (long _rv)"},
1907 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1908 "(PicHandle pic) -> None"},
1909 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1910 "() -> (PicHandle _rv)"},
1911 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1912 "() -> (short _rv)"},
1913 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1914 "() -> (UInt32 outFeatures)"},
1915 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1916 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
1917 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1918 "() -> None"},
1919 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1920 "() -> None"},
1921 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
1922 "(RgnHandle region) -> None"},
1923 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
1924 "(Rect bounds) -> None"},
1925 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
1926 "(RgnHandle region) -> None"},
1927 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
1928 "(Rect bounds) -> None"},
1929 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1930 "() -> None"},
1931 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1932 "(Str255 title) -> None"},
1933 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1934 "() -> (Str255 title)"},
1935 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
1936 "(FSSpec inFile) -> None"},
1937 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
1938 "() -> (FSSpec outFile)"},
1939 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
1940 "(AliasHandle alias) -> None"},
1941 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
1942 "() -> (AliasHandle alias)"},
1943 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
1944 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
1945 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
1946 "() -> (IconRef outIcon)"},
1947 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
1948 "(IconRef icon) -> None"},
1949 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
1950 "() -> None"},
1951 {"BeginWindowProxyDrag", (PyCFunction)WinObj_BeginWindowProxyDrag, 1,
1952 "(RgnHandle outDragOutlineRgn) -> (DragReference outNewDrag)"},
1953 {"EndWindowProxyDrag", (PyCFunction)WinObj_EndWindowProxyDrag, 1,
1954 "(DragReference theDrag) -> None"},
1955 {"TrackWindowProxyFromExistingDrag", (PyCFunction)WinObj_TrackWindowProxyFromExistingDrag, 1,
1956 "(Point startPt, DragReference drag, RgnHandle inDragOutlineRgn) -> None"},
1957 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
1958 "(Point startPt) -> None"},
1959 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
1960 "() -> (Boolean _rv)"},
1961 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
1962 "(Boolean modified) -> None"},
1963 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
1964 "(EventRecord event) -> (Boolean _rv)"},
1965 {"WindowPathSelect", (PyCFunction)WinObj_WindowPathSelect, 1,
1966 "(MenuHandle menu) -> (SInt32 outMenuResult)"},
1967 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
1968 "(Boolean hilited) -> None"},
1969 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
1970 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
1971 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
1972 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1973 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1974 "(short w, short h, Boolean fUpdate) -> None"},
1975 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1976 "(Point startPt, Rect bBox) -> (long _rv)"},
1977 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1978 "(Point startPt, Rect boundsRect) -> None"},
1979 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1980 "(WindowPartCode partCode, Boolean front) -> None"},
1981 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1982 "() -> (Boolean _rv)"},
1983 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1984 "() -> (Boolean _rv)"},
1985 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
1986 "(Boolean collapse) -> None"},
1987 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
1988 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
1989 {"ResizeWindow", (PyCFunction)WinObj_ResizeWindow, 1,
1990 "(Point startPoint, Rect sizeConstraints) -> (Boolean _rv, Rect newContentRect)"},
1991 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
1992 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
1993 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
1994 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
1995 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
1996 "(short hGlobal, short vGlobal) -> None"},
1997 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
1998 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
1999 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
2000 "(WindowPartCode partCode) -> (Point ioIdealSize)"},
2001 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
2002 "() -> (Rect userState)"},
2003 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
2004 "() -> (Rect userState)"},
2005 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
2006 "() -> None"},
2007 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
2008 "() -> None"},
2009 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
2010 "(Boolean showFlag) -> None"},
2012 #if TARGET_API_MAC_CARBON
2013 {"GetWindowPropertyAttributes", (PyCFunction)WinObj_GetWindowPropertyAttributes, 1,
2014 "(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
2015 #endif
2017 #if TARGET_API_MAC_CARBON
2018 {"ChangeWindowPropertyAttributes", (PyCFunction)WinObj_ChangeWindowPropertyAttributes, 1,
2019 "(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
2020 #endif
2021 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
2022 "(Point thePt, WindowPartCode partCode) -> (Boolean _rv)"},
2023 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
2024 "(Point thePt) -> (Boolean _rv)"},
2026 #if !TARGET_API_MAC_CARBON
2027 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
2028 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
2029 #endif
2031 #if !TARGET_API_MAC_CARBON
2032 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
2033 "() -> (Boolean _rv)"},
2034 #endif
2036 #if !TARGET_API_MAC_CARBON
2037 {"GetWindowSpareFlag", (PyCFunction)WinObj_GetWindowSpareFlag, 1,
2038 "() -> (Boolean _rv)"},
2039 #endif
2040 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
2041 "() -> (CGrafPtr _rv)"},
2042 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
2043 "() -> (short _rv)"},
2044 {"MacIsWindowVisible", (PyCFunction)WinObj_MacIsWindowVisible, 1,
2045 "() -> (Boolean _rv)"},
2046 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
2047 "() -> (Boolean _rv)"},
2049 #if TARGET_API_MAC_CARBON
2050 {"IsWindowUpdatePending", (PyCFunction)WinObj_IsWindowUpdatePending, 1,
2051 "() -> (Boolean _rv)"},
2052 #endif
2053 {"MacGetNextWindow", (PyCFunction)WinObj_MacGetNextWindow, 1,
2054 "() -> (WindowPtr _rv)"},
2055 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
2056 "() -> (Rect rect)"},
2057 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
2058 "() -> (Rect rect)"},
2059 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
2060 "(short kind) -> None"},
2061 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
2062 "(Rect rect) -> None"},
2063 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
2064 "(Rect rect) -> None"},
2065 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
2066 "() -> None"},
2067 {"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1,
2068 "() -> (Rect bounds)"},
2069 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
2070 "() -> (Boolean _rv)"},
2072 #if !TARGET_API_MAC_CARBON
2073 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
2074 "() -> (Boolean _rv)"},
2075 #endif
2076 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
2077 "(RgnHandle r) -> None"},
2078 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
2079 "(RgnHandle r) -> None"},
2080 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
2081 "(RgnHandle r) -> None"},
2083 #if !TARGET_API_MAC_CARBON
2084 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
2085 "() -> (short _rv)"},
2086 #endif
2087 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
2088 "() -> (WindowPtr _rv)"},
2090 #if !TARGET_API_MAC_CARBON
2091 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
2092 "() -> None"},
2093 #endif
2094 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
2095 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2096 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
2097 "() -> None"},
2098 {NULL, NULL, 0}
2101 PyMethodChain WinObj_chain = { WinObj_methods, NULL };
2103 static PyObject *WinObj_getattr(WindowObject *self, char *name)
2105 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
2108 #define WinObj_setattr NULL
2110 static int WinObj_compare(WindowObject *self, WindowObject *other)
2112 if ( self->ob_itself > other->ob_itself ) return 1;
2113 if ( self->ob_itself < other->ob_itself ) return -1;
2114 return 0;
2117 static PyObject * WinObj_repr(WindowObject *self)
2119 char buf[100];
2120 sprintf(buf, "<Window object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
2121 return PyString_FromString(buf);
2124 static int WinObj_hash(WindowObject *self)
2126 return (int)self->ob_itself;
2129 PyTypeObject Window_Type = {
2130 PyObject_HEAD_INIT(&PyType_Type)
2131 0, /*ob_size*/
2132 "Window", /*tp_name*/
2133 sizeof(WindowObject), /*tp_basicsize*/
2134 0, /*tp_itemsize*/
2135 /* methods */
2136 (destructor) WinObj_dealloc, /*tp_dealloc*/
2137 0, /*tp_print*/
2138 (getattrfunc) WinObj_getattr, /*tp_getattr*/
2139 (setattrfunc) WinObj_setattr, /*tp_setattr*/
2140 (cmpfunc) WinObj_compare, /*tp_compare*/
2141 (reprfunc) WinObj_repr, /*tp_repr*/
2142 (PyNumberMethods *)0, /* tp_as_number */
2143 (PySequenceMethods *)0, /* tp_as_sequence */
2144 (PyMappingMethods *)0, /* tp_as_mapping */
2145 (hashfunc) WinObj_hash, /*tp_hash*/
2148 /* --------------------- End object type Window --------------------- */
2151 static PyObject *Win_GetNewCWindow(PyObject *_self, PyObject *_args)
2153 PyObject *_res = NULL;
2154 WindowPtr _rv;
2155 short windowID;
2156 WindowPtr behind;
2157 if (!PyArg_ParseTuple(_args, "hO&",
2158 &windowID,
2159 WinObj_Convert, &behind))
2160 return NULL;
2161 _rv = GetNewCWindow(windowID,
2162 (void *)0,
2163 behind);
2164 _res = Py_BuildValue("O&",
2165 WinObj_New, _rv);
2166 return _res;
2169 static PyObject *Win_NewWindow(PyObject *_self, PyObject *_args)
2171 PyObject *_res = NULL;
2172 WindowPtr _rv;
2173 Rect boundsRect;
2174 Str255 title;
2175 Boolean visible;
2176 short theProc;
2177 WindowPtr behind;
2178 Boolean goAwayFlag;
2179 long refCon;
2180 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2181 PyMac_GetRect, &boundsRect,
2182 PyMac_GetStr255, title,
2183 &visible,
2184 &theProc,
2185 WinObj_Convert, &behind,
2186 &goAwayFlag,
2187 &refCon))
2188 return NULL;
2189 _rv = NewWindow((void *)0,
2190 &boundsRect,
2191 title,
2192 visible,
2193 theProc,
2194 behind,
2195 goAwayFlag,
2196 refCon);
2197 _res = Py_BuildValue("O&",
2198 WinObj_New, _rv);
2199 return _res;
2202 static PyObject *Win_GetNewWindow(PyObject *_self, PyObject *_args)
2204 PyObject *_res = NULL;
2205 WindowPtr _rv;
2206 short windowID;
2207 WindowPtr behind;
2208 if (!PyArg_ParseTuple(_args, "hO&",
2209 &windowID,
2210 WinObj_Convert, &behind))
2211 return NULL;
2212 _rv = GetNewWindow(windowID,
2213 (void *)0,
2214 behind);
2215 _res = Py_BuildValue("O&",
2216 WinObj_New, _rv);
2217 return _res;
2220 static PyObject *Win_NewCWindow(PyObject *_self, PyObject *_args)
2222 PyObject *_res = NULL;
2223 WindowPtr _rv;
2224 Rect boundsRect;
2225 Str255 title;
2226 Boolean visible;
2227 short procID;
2228 WindowPtr behind;
2229 Boolean goAwayFlag;
2230 long refCon;
2231 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2232 PyMac_GetRect, &boundsRect,
2233 PyMac_GetStr255, title,
2234 &visible,
2235 &procID,
2236 WinObj_Convert, &behind,
2237 &goAwayFlag,
2238 &refCon))
2239 return NULL;
2240 _rv = NewCWindow((void *)0,
2241 &boundsRect,
2242 title,
2243 visible,
2244 procID,
2245 behind,
2246 goAwayFlag,
2247 refCon);
2248 _res = Py_BuildValue("O&",
2249 WinObj_New, _rv);
2250 return _res;
2253 static PyObject *Win_CreateNewWindow(PyObject *_self, PyObject *_args)
2255 PyObject *_res = NULL;
2256 OSStatus _err;
2257 WindowClass windowClass;
2258 WindowAttributes attributes;
2259 Rect contentBounds;
2260 WindowPtr outWindow;
2261 if (!PyArg_ParseTuple(_args, "llO&",
2262 &windowClass,
2263 &attributes,
2264 PyMac_GetRect, &contentBounds))
2265 return NULL;
2266 _err = CreateNewWindow(windowClass,
2267 attributes,
2268 &contentBounds,
2269 &outWindow);
2270 if (_err != noErr) return PyMac_Error(_err);
2271 _res = Py_BuildValue("O&",
2272 WinObj_WhichWindow, outWindow);
2273 return _res;
2276 static PyObject *Win_CreateWindowFromResource(PyObject *_self, PyObject *_args)
2278 PyObject *_res = NULL;
2279 OSStatus _err;
2280 SInt16 resID;
2281 WindowPtr outWindow;
2282 if (!PyArg_ParseTuple(_args, "h",
2283 &resID))
2284 return NULL;
2285 _err = CreateWindowFromResource(resID,
2286 &outWindow);
2287 if (_err != noErr) return PyMac_Error(_err);
2288 _res = Py_BuildValue("O&",
2289 WinObj_WhichWindow, outWindow);
2290 return _res;
2293 static PyObject *Win_ShowFloatingWindows(PyObject *_self, PyObject *_args)
2295 PyObject *_res = NULL;
2296 OSStatus _err;
2297 if (!PyArg_ParseTuple(_args, ""))
2298 return NULL;
2299 _err = ShowFloatingWindows();
2300 if (_err != noErr) return PyMac_Error(_err);
2301 Py_INCREF(Py_None);
2302 _res = Py_None;
2303 return _res;
2306 static PyObject *Win_HideFloatingWindows(PyObject *_self, PyObject *_args)
2308 PyObject *_res = NULL;
2309 OSStatus _err;
2310 if (!PyArg_ParseTuple(_args, ""))
2311 return NULL;
2312 _err = HideFloatingWindows();
2313 if (_err != noErr) return PyMac_Error(_err);
2314 Py_INCREF(Py_None);
2315 _res = Py_None;
2316 return _res;
2319 static PyObject *Win_AreFloatingWindowsVisible(PyObject *_self, PyObject *_args)
2321 PyObject *_res = NULL;
2322 Boolean _rv;
2323 if (!PyArg_ParseTuple(_args, ""))
2324 return NULL;
2325 _rv = AreFloatingWindowsVisible();
2326 _res = Py_BuildValue("b",
2327 _rv);
2328 return _res;
2331 #if !TARGET_API_MAC_CARBON
2333 static PyObject *Win_SetDeskCPat(PyObject *_self, PyObject *_args)
2335 PyObject *_res = NULL;
2336 PixPatHandle deskPixPat;
2337 if (!PyArg_ParseTuple(_args, "O&",
2338 ResObj_Convert, &deskPixPat))
2339 return NULL;
2340 SetDeskCPat(deskPixPat);
2341 Py_INCREF(Py_None);
2342 _res = Py_None;
2343 return _res;
2345 #endif
2347 static PyObject *Win_CheckUpdate(PyObject *_self, PyObject *_args)
2349 PyObject *_res = NULL;
2350 Boolean _rv;
2351 EventRecord theEvent;
2352 if (!PyArg_ParseTuple(_args, ""))
2353 return NULL;
2354 _rv = CheckUpdate(&theEvent);
2355 _res = Py_BuildValue("bO&",
2356 _rv,
2357 PyMac_BuildEventRecord, &theEvent);
2358 return _res;
2361 static PyObject *Win_MacFindWindow(PyObject *_self, PyObject *_args)
2363 PyObject *_res = NULL;
2364 WindowPartCode _rv;
2365 Point thePoint;
2366 WindowPtr window;
2367 if (!PyArg_ParseTuple(_args, "O&",
2368 PyMac_GetPoint, &thePoint))
2369 return NULL;
2370 _rv = MacFindWindow(thePoint,
2371 &window);
2372 _res = Py_BuildValue("hO&",
2373 _rv,
2374 WinObj_WhichWindow, window);
2375 return _res;
2378 static PyObject *Win_FrontWindow(PyObject *_self, PyObject *_args)
2380 PyObject *_res = NULL;
2381 WindowPtr _rv;
2382 if (!PyArg_ParseTuple(_args, ""))
2383 return NULL;
2384 _rv = FrontWindow();
2385 _res = Py_BuildValue("O&",
2386 WinObj_WhichWindow, _rv);
2387 return _res;
2390 static PyObject *Win_FrontNonFloatingWindow(PyObject *_self, PyObject *_args)
2392 PyObject *_res = NULL;
2393 WindowPtr _rv;
2394 if (!PyArg_ParseTuple(_args, ""))
2395 return NULL;
2396 _rv = FrontNonFloatingWindow();
2397 _res = Py_BuildValue("O&",
2398 WinObj_WhichWindow, _rv);
2399 return _res;
2402 #if TARGET_API_MAC_CARBON
2404 static PyObject *Win_GetFrontWindowOfClass(PyObject *_self, PyObject *_args)
2406 PyObject *_res = NULL;
2407 WindowPtr _rv;
2408 WindowClass inWindowClass;
2409 Boolean mustBeVisible;
2410 if (!PyArg_ParseTuple(_args, "lb",
2411 &inWindowClass,
2412 &mustBeVisible))
2413 return NULL;
2414 _rv = GetFrontWindowOfClass(inWindowClass,
2415 mustBeVisible);
2416 _res = Py_BuildValue("O&",
2417 WinObj_New, _rv);
2418 return _res;
2420 #endif
2422 #if TARGET_API_MAC_CARBON
2424 static PyObject *Win_FindWindowOfClass(PyObject *_self, PyObject *_args)
2426 PyObject *_res = NULL;
2427 OSStatus _err;
2428 Point where;
2429 WindowClass inWindowClass;
2430 WindowPtr outWindow;
2431 WindowPartCode outWindowPart;
2432 if (!PyArg_ParseTuple(_args, "O&l",
2433 PyMac_GetPoint, &where,
2434 &inWindowClass))
2435 return NULL;
2436 _err = FindWindowOfClass(&where,
2437 inWindowClass,
2438 &outWindow,
2439 &outWindowPart);
2440 if (_err != noErr) return PyMac_Error(_err);
2441 _res = Py_BuildValue("O&h",
2442 WinObj_WhichWindow, outWindow,
2443 outWindowPart);
2444 return _res;
2446 #endif
2448 #if !TARGET_API_MAC_CARBON
2450 static PyObject *Win_InitWindows(PyObject *_self, PyObject *_args)
2452 PyObject *_res = NULL;
2453 if (!PyArg_ParseTuple(_args, ""))
2454 return NULL;
2455 InitWindows();
2456 Py_INCREF(Py_None);
2457 _res = Py_None;
2458 return _res;
2460 #endif
2462 #if !TARGET_API_MAC_CARBON
2464 static PyObject *Win_GetWMgrPort(PyObject *_self, PyObject *_args)
2466 PyObject *_res = NULL;
2467 GrafPtr wPort;
2468 if (!PyArg_ParseTuple(_args, ""))
2469 return NULL;
2470 GetWMgrPort(&wPort);
2471 _res = Py_BuildValue("O&",
2472 GrafObj_New, wPort);
2473 return _res;
2475 #endif
2477 #if !TARGET_API_MAC_CARBON
2479 static PyObject *Win_GetCWMgrPort(PyObject *_self, PyObject *_args)
2481 PyObject *_res = NULL;
2482 CGrafPtr wMgrCPort;
2483 if (!PyArg_ParseTuple(_args, ""))
2484 return NULL;
2485 GetCWMgrPort(&wMgrCPort);
2486 _res = Py_BuildValue("O&",
2487 GrafObj_New, wMgrCPort);
2488 return _res;
2490 #endif
2492 #if !TARGET_API_MAC_CARBON
2494 static PyObject *Win_InitFloatingWindows(PyObject *_self, PyObject *_args)
2496 PyObject *_res = NULL;
2497 OSStatus _err;
2498 if (!PyArg_ParseTuple(_args, ""))
2499 return NULL;
2500 _err = InitFloatingWindows();
2501 if (_err != noErr) return PyMac_Error(_err);
2502 Py_INCREF(Py_None);
2503 _res = Py_None;
2504 return _res;
2506 #endif
2508 #if !TARGET_API_MAC_CARBON
2510 static PyObject *Win_InvalRect(PyObject *_self, PyObject *_args)
2512 PyObject *_res = NULL;
2513 Rect badRect;
2514 if (!PyArg_ParseTuple(_args, "O&",
2515 PyMac_GetRect, &badRect))
2516 return NULL;
2517 InvalRect(&badRect);
2518 Py_INCREF(Py_None);
2519 _res = Py_None;
2520 return _res;
2522 #endif
2524 #if !TARGET_API_MAC_CARBON
2526 static PyObject *Win_InvalRgn(PyObject *_self, PyObject *_args)
2528 PyObject *_res = NULL;
2529 RgnHandle badRgn;
2530 if (!PyArg_ParseTuple(_args, "O&",
2531 ResObj_Convert, &badRgn))
2532 return NULL;
2533 InvalRgn(badRgn);
2534 Py_INCREF(Py_None);
2535 _res = Py_None;
2536 return _res;
2538 #endif
2540 #if !TARGET_API_MAC_CARBON
2542 static PyObject *Win_ValidRect(PyObject *_self, PyObject *_args)
2544 PyObject *_res = NULL;
2545 Rect goodRect;
2546 if (!PyArg_ParseTuple(_args, "O&",
2547 PyMac_GetRect, &goodRect))
2548 return NULL;
2549 ValidRect(&goodRect);
2550 Py_INCREF(Py_None);
2551 _res = Py_None;
2552 return _res;
2554 #endif
2556 #if !TARGET_API_MAC_CARBON
2558 static PyObject *Win_ValidRgn(PyObject *_self, PyObject *_args)
2560 PyObject *_res = NULL;
2561 RgnHandle goodRgn;
2562 if (!PyArg_ParseTuple(_args, "O&",
2563 ResObj_Convert, &goodRgn))
2564 return NULL;
2565 ValidRgn(goodRgn);
2566 Py_INCREF(Py_None);
2567 _res = Py_None;
2568 return _res;
2570 #endif
2572 static PyObject *Win_CollapseAllWindows(PyObject *_self, PyObject *_args)
2574 PyObject *_res = NULL;
2575 OSStatus _err;
2576 Boolean collapse;
2577 if (!PyArg_ParseTuple(_args, "b",
2578 &collapse))
2579 return NULL;
2580 _err = CollapseAllWindows(collapse);
2581 if (_err != noErr) return PyMac_Error(_err);
2582 Py_INCREF(Py_None);
2583 _res = Py_None;
2584 return _res;
2587 static PyObject *Win_PinRect(PyObject *_self, PyObject *_args)
2589 PyObject *_res = NULL;
2590 long _rv;
2591 Rect theRect;
2592 Point thePt;
2593 if (!PyArg_ParseTuple(_args, "O&O&",
2594 PyMac_GetRect, &theRect,
2595 PyMac_GetPoint, &thePt))
2596 return NULL;
2597 _rv = PinRect(&theRect,
2598 thePt);
2599 _res = Py_BuildValue("l",
2600 _rv);
2601 return _res;
2604 static PyObject *Win_GetGrayRgn(PyObject *_self, PyObject *_args)
2606 PyObject *_res = NULL;
2607 RgnHandle _rv;
2608 if (!PyArg_ParseTuple(_args, ""))
2609 return NULL;
2610 _rv = GetGrayRgn();
2611 _res = Py_BuildValue("O&",
2612 ResObj_New, _rv);
2613 return _res;
2616 static PyObject *Win_GetWindowFromPort(PyObject *_self, PyObject *_args)
2618 PyObject *_res = NULL;
2619 WindowPtr _rv;
2620 CGrafPtr port;
2621 if (!PyArg_ParseTuple(_args, "O&",
2622 GrafObj_Convert, &port))
2623 return NULL;
2624 _rv = GetWindowFromPort(port);
2625 _res = Py_BuildValue("O&",
2626 WinObj_New, _rv);
2627 return _res;
2630 static PyObject *Win_WhichWindow(PyObject *_self, PyObject *_args)
2632 PyObject *_res = NULL;
2634 long ptr;
2636 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2637 return NULL;
2638 return WinObj_WhichWindow((WindowPtr)ptr);
2642 static PyObject *Win_FindWindow(PyObject *_self, PyObject *_args)
2644 PyObject *_res = NULL;
2645 short _rv;
2646 Point thePoint;
2647 WindowPtr theWindow;
2648 if (!PyArg_ParseTuple(_args, "O&",
2649 PyMac_GetPoint, &thePoint))
2650 return NULL;
2651 _rv = FindWindow(thePoint,
2652 &theWindow);
2653 _res = Py_BuildValue("hO&",
2654 _rv,
2655 WinObj_WhichWindow, theWindow);
2656 return _res;
2659 static PyMethodDef Win_methods[] = {
2660 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2661 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2662 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2663 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2664 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2665 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2666 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2667 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2668 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
2669 "(WindowClass windowClass, WindowAttributes attributes, Rect contentBounds) -> (WindowPtr outWindow)"},
2670 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2671 "(SInt16 resID) -> (WindowPtr outWindow)"},
2672 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2673 "() -> None"},
2674 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2675 "() -> None"},
2676 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2677 "() -> (Boolean _rv)"},
2679 #if !TARGET_API_MAC_CARBON
2680 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2681 "(PixPatHandle deskPixPat) -> None"},
2682 #endif
2683 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2684 "() -> (Boolean _rv, EventRecord theEvent)"},
2685 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
2686 "(Point thePoint) -> (WindowPartCode _rv, WindowPtr window)"},
2687 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2688 "() -> (WindowPtr _rv)"},
2689 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2690 "() -> (WindowPtr _rv)"},
2692 #if TARGET_API_MAC_CARBON
2693 {"GetFrontWindowOfClass", (PyCFunction)Win_GetFrontWindowOfClass, 1,
2694 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2695 #endif
2697 #if TARGET_API_MAC_CARBON
2698 {"FindWindowOfClass", (PyCFunction)Win_FindWindowOfClass, 1,
2699 "(Point where, WindowClass inWindowClass) -> (WindowPtr outWindow, WindowPartCode outWindowPart)"},
2700 #endif
2702 #if !TARGET_API_MAC_CARBON
2703 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2704 "() -> None"},
2705 #endif
2707 #if !TARGET_API_MAC_CARBON
2708 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2709 "() -> (GrafPtr wPort)"},
2710 #endif
2712 #if !TARGET_API_MAC_CARBON
2713 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2714 "() -> (CGrafPtr wMgrCPort)"},
2715 #endif
2717 #if !TARGET_API_MAC_CARBON
2718 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2719 "() -> None"},
2720 #endif
2722 #if !TARGET_API_MAC_CARBON
2723 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2724 "(Rect badRect) -> None"},
2725 #endif
2727 #if !TARGET_API_MAC_CARBON
2728 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2729 "(RgnHandle badRgn) -> None"},
2730 #endif
2732 #if !TARGET_API_MAC_CARBON
2733 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2734 "(Rect goodRect) -> None"},
2735 #endif
2737 #if !TARGET_API_MAC_CARBON
2738 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2739 "(RgnHandle goodRgn) -> None"},
2740 #endif
2741 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
2742 "(Boolean collapse) -> None"},
2743 {"PinRect", (PyCFunction)Win_PinRect, 1,
2744 "(Rect theRect, Point thePt) -> (long _rv)"},
2745 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2746 "() -> (RgnHandle _rv)"},
2747 {"GetWindowFromPort", (PyCFunction)Win_GetWindowFromPort, 1,
2748 "(CGrafPtr port) -> (WindowPtr _rv)"},
2749 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2750 "Resolve an integer WindowPtr address to a Window object"},
2751 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2752 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
2753 {NULL, NULL, 0}
2758 /* Return the object corresponding to the window, or NULL */
2760 PyObject *
2761 WinObj_WhichWindow(WindowPtr w)
2763 PyObject *it;
2765 if (w == NULL) {
2766 it = Py_None;
2767 Py_INCREF(it);
2768 } else {
2769 it = (PyObject *) GetWRefCon(w);
2770 if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
2771 it = WinObj_New(w);
2772 ((WindowObject *)it)->ob_freeit = NULL;
2773 } else {
2774 Py_INCREF(it);
2777 return it;
2781 void initWin(void)
2783 PyObject *m;
2784 PyObject *d;
2788 PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_New);
2789 PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_WhichWindow);
2790 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert);
2793 m = Py_InitModule("Win", Win_methods);
2794 d = PyModule_GetDict(m);
2795 Win_Error = PyMac_GetOSErrException();
2796 if (Win_Error == NULL ||
2797 PyDict_SetItemString(d, "Error", Win_Error) != 0)
2798 return;
2799 Window_Type.ob_type = &PyType_Type;
2800 Py_INCREF(&Window_Type);
2801 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2802 Py_FatalError("can't initialize WindowType");
2805 /* ========================= End module Win ========================= */