Added 'description' class attribute to every command class (to help the
[python/dscho.git] / Mac / Modules / win / Winmodule.c
blob954244702983a5b998e14c249f60f88939cba9be
2 /* =========================== Module Win =========================== */
4 #include "Python.h"
8 #define SystemSevenOrLater 1
10 #include "macglue.h"
11 #include <Memory.h>
12 #include <Dialogs.h>
13 #include <Menus.h>
14 #include <Controls.h>
16 extern PyObject *ResObj_New(Handle);
17 extern int ResObj_Convert(PyObject *, Handle *);
18 extern PyObject *OptResObj_New(Handle);
19 extern int OptResObj_Convert(PyObject *, Handle *);
21 extern PyObject *WinObj_New(WindowPtr);
22 extern int WinObj_Convert(PyObject *, WindowPtr *);
23 extern PyTypeObject Window_Type;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject *DlgObj_New(DialogPtr);
27 extern int DlgObj_Convert(PyObject *, DialogPtr *);
28 extern PyTypeObject Dialog_Type;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject *MenuObj_New(MenuHandle);
32 extern int MenuObj_Convert(PyObject *, MenuHandle *);
34 extern PyObject *CtlObj_New(ControlHandle);
35 extern int CtlObj_Convert(PyObject *, ControlHandle *);
37 extern PyObject *GrafObj_New(GrafPtr);
38 extern int GrafObj_Convert(PyObject *, GrafPtr *);
40 extern PyObject *BMObj_New(BitMapPtr);
41 extern int BMObj_Convert(PyObject *, BitMapPtr *);
43 extern PyObject *WinObj_WhichWindow(WindowPtr);
45 #include <Windows.h>
47 extern PyObject *QdRGB_New(RGBColor *);
48 extern int QdRGB_Convert(PyObject *, RGBColor *);
50 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
53 static PyObject *Win_Error;
55 /* ----------------------- Object type Window ----------------------- */
57 PyTypeObject Window_Type;
59 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
61 typedef struct WindowObject {
62 PyObject_HEAD
63 WindowPtr ob_itself;
64 } WindowObject;
66 PyObject *WinObj_New(itself)
67 WindowPtr itself;
69 WindowObject *it;
70 if (itself == NULL) return PyMac_Error(resNotFound);
71 it = PyObject_NEW(WindowObject, &Window_Type);
72 if (it == NULL) return NULL;
73 it->ob_itself = itself;
74 SetWRefCon(itself, (long)it);
75 return (PyObject *)it;
77 WinObj_Convert(v, p_itself)
78 PyObject *v;
79 WindowPtr *p_itself;
81 if (DlgObj_Check(v)) {
82 *p_itself = ((WindowObject *)v)->ob_itself;
83 return 1;
86 if (v == Py_None) { *p_itself = NULL; return 1; }
87 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
89 if (!WinObj_Check(v))
91 PyErr_SetString(PyExc_TypeError, "Window required");
92 return 0;
94 *p_itself = ((WindowObject *)v)->ob_itself;
95 return 1;
98 static void WinObj_dealloc(self)
99 WindowObject *self;
101 DisposeWindow(self->ob_itself);
102 PyMem_DEL(self);
105 static PyObject *WinObj_MacCloseWindow(_self, _args)
106 WindowObject *_self;
107 PyObject *_args;
109 PyObject *_res = NULL;
110 if (!PyArg_ParseTuple(_args, ""))
111 return NULL;
112 MacCloseWindow(_self->ob_itself);
113 Py_INCREF(Py_None);
114 _res = Py_None;
115 return _res;
118 static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
119 WindowObject *_self;
120 PyObject *_args;
122 PyObject *_res = NULL;
123 OSStatus _err;
124 UInt32 outCount;
125 if (!PyArg_ParseTuple(_args, ""))
126 return NULL;
127 _err = GetWindowOwnerCount(_self->ob_itself,
128 &outCount);
129 if (_err != noErr) return PyMac_Error(_err);
130 _res = Py_BuildValue("l",
131 outCount);
132 return _res;
135 static PyObject *WinObj_CloneWindow(_self, _args)
136 WindowObject *_self;
137 PyObject *_args;
139 PyObject *_res = NULL;
140 OSStatus _err;
141 if (!PyArg_ParseTuple(_args, ""))
142 return NULL;
143 _err = CloneWindow(_self->ob_itself);
144 if (_err != noErr) return PyMac_Error(_err);
145 Py_INCREF(Py_None);
146 _res = Py_None;
147 return _res;
150 static PyObject *WinObj_GetWindowClass(_self, _args)
151 WindowObject *_self;
152 PyObject *_args;
154 PyObject *_res = NULL;
155 OSStatus _err;
156 WindowClass outClass;
157 if (!PyArg_ParseTuple(_args, ""))
158 return NULL;
159 _err = GetWindowClass(_self->ob_itself,
160 &outClass);
161 if (_err != noErr) return PyMac_Error(_err);
162 _res = Py_BuildValue("l",
163 outClass);
164 return _res;
167 static PyObject *WinObj_GetWindowAttributes(_self, _args)
168 WindowObject *_self;
169 PyObject *_args;
171 PyObject *_res = NULL;
172 OSStatus _err;
173 WindowAttributes outAttributes;
174 if (!PyArg_ParseTuple(_args, ""))
175 return NULL;
176 _err = GetWindowAttributes(_self->ob_itself,
177 &outAttributes);
178 if (_err != noErr) return PyMac_Error(_err);
179 _res = Py_BuildValue("l",
180 outAttributes);
181 return _res;
184 static PyObject *WinObj_SetWinColor(_self, _args)
185 WindowObject *_self;
186 PyObject *_args;
188 PyObject *_res = NULL;
189 WCTabHandle newColorTable;
190 if (!PyArg_ParseTuple(_args, "O&",
191 ResObj_Convert, &newColorTable))
192 return NULL;
193 SetWinColor(_self->ob_itself,
194 newColorTable);
195 Py_INCREF(Py_None);
196 _res = Py_None;
197 return _res;
200 static PyObject *WinObj_SetWindowContentColor(_self, _args)
201 WindowObject *_self;
202 PyObject *_args;
204 PyObject *_res = NULL;
205 OSStatus _err;
206 RGBColor color;
207 if (!PyArg_ParseTuple(_args, ""))
208 return NULL;
209 _err = SetWindowContentColor(_self->ob_itself,
210 &color);
211 if (_err != noErr) return PyMac_Error(_err);
212 _res = Py_BuildValue("O&",
213 QdRGB_New, &color);
214 return _res;
217 static PyObject *WinObj_GetWindowContentColor(_self, _args)
218 WindowObject *_self;
219 PyObject *_args;
221 PyObject *_res = NULL;
222 OSStatus _err;
223 RGBColor color;
224 if (!PyArg_ParseTuple(_args, ""))
225 return NULL;
226 _err = GetWindowContentColor(_self->ob_itself,
227 &color);
228 if (_err != noErr) return PyMac_Error(_err);
229 _res = Py_BuildValue("O&",
230 QdRGB_New, &color);
231 return _res;
234 static PyObject *WinObj_GetWindowContentPattern(_self, _args)
235 WindowObject *_self;
236 PyObject *_args;
238 PyObject *_res = NULL;
239 OSStatus _err;
240 PixPatHandle outPixPat;
241 if (!PyArg_ParseTuple(_args, "O&",
242 ResObj_Convert, &outPixPat))
243 return NULL;
244 _err = GetWindowContentPattern(_self->ob_itself,
245 outPixPat);
246 if (_err != noErr) return PyMac_Error(_err);
247 Py_INCREF(Py_None);
248 _res = Py_None;
249 return _res;
252 static PyObject *WinObj_SetWindowContentPattern(_self, _args)
253 WindowObject *_self;
254 PyObject *_args;
256 PyObject *_res = NULL;
257 OSStatus _err;
258 PixPatHandle pixPat;
259 if (!PyArg_ParseTuple(_args, "O&",
260 ResObj_Convert, &pixPat))
261 return NULL;
262 _err = SetWindowContentPattern(_self->ob_itself,
263 pixPat);
264 if (_err != noErr) return PyMac_Error(_err);
265 Py_INCREF(Py_None);
266 _res = Py_None;
267 return _res;
270 static PyObject *WinObj_ClipAbove(_self, _args)
271 WindowObject *_self;
272 PyObject *_args;
274 PyObject *_res = NULL;
275 if (!PyArg_ParseTuple(_args, ""))
276 return NULL;
277 ClipAbove(_self->ob_itself);
278 Py_INCREF(Py_None);
279 _res = Py_None;
280 return _res;
283 static PyObject *WinObj_SaveOld(_self, _args)
284 WindowObject *_self;
285 PyObject *_args;
287 PyObject *_res = NULL;
288 if (!PyArg_ParseTuple(_args, ""))
289 return NULL;
290 SaveOld(_self->ob_itself);
291 Py_INCREF(Py_None);
292 _res = Py_None;
293 return _res;
296 static PyObject *WinObj_DrawNew(_self, _args)
297 WindowObject *_self;
298 PyObject *_args;
300 PyObject *_res = NULL;
301 Boolean update;
302 if (!PyArg_ParseTuple(_args, "b",
303 &update))
304 return NULL;
305 DrawNew(_self->ob_itself,
306 update);
307 Py_INCREF(Py_None);
308 _res = Py_None;
309 return _res;
312 static PyObject *WinObj_PaintOne(_self, _args)
313 WindowObject *_self;
314 PyObject *_args;
316 PyObject *_res = NULL;
317 RgnHandle clobberedRgn;
318 if (!PyArg_ParseTuple(_args, "O&",
319 ResObj_Convert, &clobberedRgn))
320 return NULL;
321 PaintOne(_self->ob_itself,
322 clobberedRgn);
323 Py_INCREF(Py_None);
324 _res = Py_None;
325 return _res;
328 static PyObject *WinObj_PaintBehind(_self, _args)
329 WindowObject *_self;
330 PyObject *_args;
332 PyObject *_res = NULL;
333 RgnHandle clobberedRgn;
334 if (!PyArg_ParseTuple(_args, "O&",
335 ResObj_Convert, &clobberedRgn))
336 return NULL;
337 PaintBehind(_self->ob_itself,
338 clobberedRgn);
339 Py_INCREF(Py_None);
340 _res = Py_None;
341 return _res;
344 static PyObject *WinObj_CalcVis(_self, _args)
345 WindowObject *_self;
346 PyObject *_args;
348 PyObject *_res = NULL;
349 if (!PyArg_ParseTuple(_args, ""))
350 return NULL;
351 CalcVis(_self->ob_itself);
352 Py_INCREF(Py_None);
353 _res = Py_None;
354 return _res;
357 static PyObject *WinObj_CalcVisBehind(_self, _args)
358 WindowObject *_self;
359 PyObject *_args;
361 PyObject *_res = NULL;
362 RgnHandle clobberedRgn;
363 if (!PyArg_ParseTuple(_args, "O&",
364 ResObj_Convert, &clobberedRgn))
365 return NULL;
366 CalcVisBehind(_self->ob_itself,
367 clobberedRgn);
368 Py_INCREF(Py_None);
369 _res = Py_None;
370 return _res;
373 static PyObject *WinObj_BringToFront(_self, _args)
374 WindowObject *_self;
375 PyObject *_args;
377 PyObject *_res = NULL;
378 if (!PyArg_ParseTuple(_args, ""))
379 return NULL;
380 BringToFront(_self->ob_itself);
381 Py_INCREF(Py_None);
382 _res = Py_None;
383 return _res;
386 static PyObject *WinObj_SendBehind(_self, _args)
387 WindowObject *_self;
388 PyObject *_args;
390 PyObject *_res = NULL;
391 WindowPtr behindWindow;
392 if (!PyArg_ParseTuple(_args, "O&",
393 WinObj_Convert, &behindWindow))
394 return NULL;
395 SendBehind(_self->ob_itself,
396 behindWindow);
397 Py_INCREF(Py_None);
398 _res = Py_None;
399 return _res;
402 static PyObject *WinObj_SelectWindow(_self, _args)
403 WindowObject *_self;
404 PyObject *_args;
406 PyObject *_res = NULL;
407 if (!PyArg_ParseTuple(_args, ""))
408 return NULL;
409 SelectWindow(_self->ob_itself);
410 Py_INCREF(Py_None);
411 _res = Py_None;
412 return _res;
415 static PyObject *WinObj_HiliteWindow(_self, _args)
416 WindowObject *_self;
417 PyObject *_args;
419 PyObject *_res = NULL;
420 Boolean fHilite;
421 if (!PyArg_ParseTuple(_args, "b",
422 &fHilite))
423 return NULL;
424 HiliteWindow(_self->ob_itself,
425 fHilite);
426 Py_INCREF(Py_None);
427 _res = Py_None;
428 return _res;
431 static PyObject *WinObj_SetWRefCon(_self, _args)
432 WindowObject *_self;
433 PyObject *_args;
435 PyObject *_res = NULL;
436 long data;
437 if (!PyArg_ParseTuple(_args, "l",
438 &data))
439 return NULL;
440 SetWRefCon(_self->ob_itself,
441 data);
442 Py_INCREF(Py_None);
443 _res = Py_None;
444 return _res;
447 static PyObject *WinObj_GetWRefCon(_self, _args)
448 WindowObject *_self;
449 PyObject *_args;
451 PyObject *_res = NULL;
452 long _rv;
453 if (!PyArg_ParseTuple(_args, ""))
454 return NULL;
455 _rv = GetWRefCon(_self->ob_itself);
456 _res = Py_BuildValue("l",
457 _rv);
458 return _res;
461 static PyObject *WinObj_SetWindowPic(_self, _args)
462 WindowObject *_self;
463 PyObject *_args;
465 PyObject *_res = NULL;
466 PicHandle pic;
467 if (!PyArg_ParseTuple(_args, "O&",
468 ResObj_Convert, &pic))
469 return NULL;
470 SetWindowPic(_self->ob_itself,
471 pic);
472 Py_INCREF(Py_None);
473 _res = Py_None;
474 return _res;
477 static PyObject *WinObj_GetWindowPic(_self, _args)
478 WindowObject *_self;
479 PyObject *_args;
481 PyObject *_res = NULL;
482 PicHandle _rv;
483 if (!PyArg_ParseTuple(_args, ""))
484 return NULL;
485 _rv = GetWindowPic(_self->ob_itself);
486 _res = Py_BuildValue("O&",
487 ResObj_New, _rv);
488 return _res;
491 static PyObject *WinObj_GetWVariant(_self, _args)
492 WindowObject *_self;
493 PyObject *_args;
495 PyObject *_res = NULL;
496 short _rv;
497 if (!PyArg_ParseTuple(_args, ""))
498 return NULL;
499 _rv = GetWVariant(_self->ob_itself);
500 _res = Py_BuildValue("h",
501 _rv);
502 return _res;
505 static PyObject *WinObj_GetWindowFeatures(_self, _args)
506 WindowObject *_self;
507 PyObject *_args;
509 PyObject *_res = NULL;
510 OSStatus _err;
511 UInt32 outFeatures;
512 if (!PyArg_ParseTuple(_args, ""))
513 return NULL;
514 _err = GetWindowFeatures(_self->ob_itself,
515 &outFeatures);
516 if (_err != noErr) return PyMac_Error(_err);
517 _res = Py_BuildValue("l",
518 outFeatures);
519 return _res;
522 static PyObject *WinObj_GetWindowRegion(_self, _args)
523 WindowObject *_self;
524 PyObject *_args;
526 PyObject *_res = NULL;
527 OSStatus _err;
528 WindowRegionCode inRegionCode;
529 RgnHandle ioWinRgn;
530 if (!PyArg_ParseTuple(_args, "hO&",
531 &inRegionCode,
532 ResObj_Convert, &ioWinRgn))
533 return NULL;
534 _err = GetWindowRegion(_self->ob_itself,
535 inRegionCode,
536 ioWinRgn);
537 if (_err != noErr) return PyMac_Error(_err);
538 Py_INCREF(Py_None);
539 _res = Py_None;
540 return _res;
543 static PyObject *WinObj_BeginUpdate(_self, _args)
544 WindowObject *_self;
545 PyObject *_args;
547 PyObject *_res = NULL;
548 if (!PyArg_ParseTuple(_args, ""))
549 return NULL;
550 BeginUpdate(_self->ob_itself);
551 Py_INCREF(Py_None);
552 _res = Py_None;
553 return _res;
556 static PyObject *WinObj_EndUpdate(_self, _args)
557 WindowObject *_self;
558 PyObject *_args;
560 PyObject *_res = NULL;
561 if (!PyArg_ParseTuple(_args, ""))
562 return NULL;
563 EndUpdate(_self->ob_itself);
564 Py_INCREF(Py_None);
565 _res = Py_None;
566 return _res;
569 static PyObject *WinObj_InvalWindowRgn(_self, _args)
570 WindowObject *_self;
571 PyObject *_args;
573 PyObject *_res = NULL;
574 OSStatus _err;
575 RgnHandle region;
576 if (!PyArg_ParseTuple(_args, "O&",
577 ResObj_Convert, &region))
578 return NULL;
579 _err = InvalWindowRgn(_self->ob_itself,
580 region);
581 if (_err != noErr) return PyMac_Error(_err);
582 Py_INCREF(Py_None);
583 _res = Py_None;
584 return _res;
587 static PyObject *WinObj_InvalWindowRect(_self, _args)
588 WindowObject *_self;
589 PyObject *_args;
591 PyObject *_res = NULL;
592 OSStatus _err;
593 Rect bounds;
594 if (!PyArg_ParseTuple(_args, "O&",
595 PyMac_GetRect, &bounds))
596 return NULL;
597 _err = InvalWindowRect(_self->ob_itself,
598 &bounds);
599 if (_err != noErr) return PyMac_Error(_err);
600 Py_INCREF(Py_None);
601 _res = Py_None;
602 return _res;
605 static PyObject *WinObj_ValidWindowRgn(_self, _args)
606 WindowObject *_self;
607 PyObject *_args;
609 PyObject *_res = NULL;
610 OSStatus _err;
611 RgnHandle region;
612 if (!PyArg_ParseTuple(_args, "O&",
613 ResObj_Convert, &region))
614 return NULL;
615 _err = ValidWindowRgn(_self->ob_itself,
616 region);
617 if (_err != noErr) return PyMac_Error(_err);
618 Py_INCREF(Py_None);
619 _res = Py_None;
620 return _res;
623 static PyObject *WinObj_ValidWindowRect(_self, _args)
624 WindowObject *_self;
625 PyObject *_args;
627 PyObject *_res = NULL;
628 OSStatus _err;
629 Rect bounds;
630 if (!PyArg_ParseTuple(_args, "O&",
631 PyMac_GetRect, &bounds))
632 return NULL;
633 _err = ValidWindowRect(_self->ob_itself,
634 &bounds);
635 if (_err != noErr) return PyMac_Error(_err);
636 Py_INCREF(Py_None);
637 _res = Py_None;
638 return _res;
641 static PyObject *WinObj_DrawGrowIcon(_self, _args)
642 WindowObject *_self;
643 PyObject *_args;
645 PyObject *_res = NULL;
646 if (!PyArg_ParseTuple(_args, ""))
647 return NULL;
648 DrawGrowIcon(_self->ob_itself);
649 Py_INCREF(Py_None);
650 _res = Py_None;
651 return _res;
654 static PyObject *WinObj_SetWTitle(_self, _args)
655 WindowObject *_self;
656 PyObject *_args;
658 PyObject *_res = NULL;
659 Str255 title;
660 if (!PyArg_ParseTuple(_args, "O&",
661 PyMac_GetStr255, title))
662 return NULL;
663 SetWTitle(_self->ob_itself,
664 title);
665 Py_INCREF(Py_None);
666 _res = Py_None;
667 return _res;
670 static PyObject *WinObj_GetWTitle(_self, _args)
671 WindowObject *_self;
672 PyObject *_args;
674 PyObject *_res = NULL;
675 Str255 title;
676 if (!PyArg_ParseTuple(_args, ""))
677 return NULL;
678 GetWTitle(_self->ob_itself,
679 title);
680 _res = Py_BuildValue("O&",
681 PyMac_BuildStr255, title);
682 return _res;
685 static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
686 WindowObject *_self;
687 PyObject *_args;
689 PyObject *_res = NULL;
690 OSStatus _err;
691 FSSpec inFile;
692 if (!PyArg_ParseTuple(_args, "O&",
693 PyMac_GetFSSpec, &inFile))
694 return NULL;
695 _err = SetWindowProxyFSSpec(_self->ob_itself,
696 &inFile);
697 if (_err != noErr) return PyMac_Error(_err);
698 Py_INCREF(Py_None);
699 _res = Py_None;
700 return _res;
703 static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
704 WindowObject *_self;
705 PyObject *_args;
707 PyObject *_res = NULL;
708 OSStatus _err;
709 FSSpec outFile;
710 if (!PyArg_ParseTuple(_args, ""))
711 return NULL;
712 _err = GetWindowProxyFSSpec(_self->ob_itself,
713 &outFile);
714 if (_err != noErr) return PyMac_Error(_err);
715 _res = Py_BuildValue("O&",
716 PyMac_BuildFSSpec, &outFile);
717 return _res;
720 static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
721 WindowObject *_self;
722 PyObject *_args;
724 PyObject *_res = NULL;
725 OSStatus _err;
726 AliasHandle alias;
727 if (!PyArg_ParseTuple(_args, "O&",
728 ResObj_Convert, &alias))
729 return NULL;
730 _err = SetWindowProxyAlias(_self->ob_itself,
731 alias);
732 if (_err != noErr) return PyMac_Error(_err);
733 Py_INCREF(Py_None);
734 _res = Py_None;
735 return _res;
738 static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
739 WindowObject *_self;
740 PyObject *_args;
742 PyObject *_res = NULL;
743 OSStatus _err;
744 AliasHandle alias;
745 if (!PyArg_ParseTuple(_args, ""))
746 return NULL;
747 _err = GetWindowProxyAlias(_self->ob_itself,
748 &alias);
749 if (_err != noErr) return PyMac_Error(_err);
750 _res = Py_BuildValue("O&",
751 ResObj_New, alias);
752 return _res;
755 static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
756 WindowObject *_self;
757 PyObject *_args;
759 PyObject *_res = NULL;
760 OSStatus _err;
761 OSType fileCreator;
762 OSType fileType;
763 SInt16 vRefNum;
764 if (!PyArg_ParseTuple(_args, "O&O&h",
765 PyMac_GetOSType, &fileCreator,
766 PyMac_GetOSType, &fileType,
767 &vRefNum))
768 return NULL;
769 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
770 fileCreator,
771 fileType,
772 vRefNum);
773 if (_err != noErr) return PyMac_Error(_err);
774 Py_INCREF(Py_None);
775 _res = Py_None;
776 return _res;
779 static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
780 WindowObject *_self;
781 PyObject *_args;
783 PyObject *_res = NULL;
784 OSStatus _err;
785 IconRef outIcon;
786 if (!PyArg_ParseTuple(_args, ""))
787 return NULL;
788 _err = GetWindowProxyIcon(_self->ob_itself,
789 &outIcon);
790 if (_err != noErr) return PyMac_Error(_err);
791 _res = Py_BuildValue("O&",
792 ResObj_New, outIcon);
793 return _res;
796 static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
797 WindowObject *_self;
798 PyObject *_args;
800 PyObject *_res = NULL;
801 OSStatus _err;
802 IconRef icon;
803 if (!PyArg_ParseTuple(_args, "O&",
804 ResObj_Convert, &icon))
805 return NULL;
806 _err = SetWindowProxyIcon(_self->ob_itself,
807 icon);
808 if (_err != noErr) return PyMac_Error(_err);
809 Py_INCREF(Py_None);
810 _res = Py_None;
811 return _res;
814 static PyObject *WinObj_RemoveWindowProxy(_self, _args)
815 WindowObject *_self;
816 PyObject *_args;
818 PyObject *_res = NULL;
819 OSStatus _err;
820 if (!PyArg_ParseTuple(_args, ""))
821 return NULL;
822 _err = RemoveWindowProxy(_self->ob_itself);
823 if (_err != noErr) return PyMac_Error(_err);
824 Py_INCREF(Py_None);
825 _res = Py_None;
826 return _res;
829 static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
830 WindowObject *_self;
831 PyObject *_args;
833 PyObject *_res = NULL;
834 OSStatus _err;
835 Point startPt;
836 if (!PyArg_ParseTuple(_args, "O&",
837 PyMac_GetPoint, &startPt))
838 return NULL;
839 _err = TrackWindowProxyDrag(_self->ob_itself,
840 startPt);
841 if (_err != noErr) return PyMac_Error(_err);
842 Py_INCREF(Py_None);
843 _res = Py_None;
844 return _res;
847 static PyObject *WinObj_IsWindowModified(_self, _args)
848 WindowObject *_self;
849 PyObject *_args;
851 PyObject *_res = NULL;
852 Boolean _rv;
853 if (!PyArg_ParseTuple(_args, ""))
854 return NULL;
855 _rv = IsWindowModified(_self->ob_itself);
856 _res = Py_BuildValue("b",
857 _rv);
858 return _res;
861 static PyObject *WinObj_SetWindowModified(_self, _args)
862 WindowObject *_self;
863 PyObject *_args;
865 PyObject *_res = NULL;
866 OSStatus _err;
867 Boolean modified;
868 if (!PyArg_ParseTuple(_args, "b",
869 &modified))
870 return NULL;
871 _err = SetWindowModified(_self->ob_itself,
872 modified);
873 if (_err != noErr) return PyMac_Error(_err);
874 Py_INCREF(Py_None);
875 _res = Py_None;
876 return _res;
879 static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
880 WindowObject *_self;
881 PyObject *_args;
883 PyObject *_res = NULL;
884 Boolean _rv;
885 EventRecord event;
886 if (!PyArg_ParseTuple(_args, ""))
887 return NULL;
888 _rv = IsWindowPathSelectClick(_self->ob_itself,
889 &event);
890 _res = Py_BuildValue("bO&",
891 _rv,
892 PyMac_BuildEventRecord, &event);
893 return _res;
896 static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
897 WindowObject *_self;
898 PyObject *_args;
900 PyObject *_res = NULL;
901 OSStatus _err;
902 Boolean hilited;
903 if (!PyArg_ParseTuple(_args, "b",
904 &hilited))
905 return NULL;
906 _err = HiliteWindowFrameForDrag(_self->ob_itself,
907 hilited);
908 if (_err != noErr) return PyMac_Error(_err);
909 Py_INCREF(Py_None);
910 _res = Py_None;
911 return _res;
914 static PyObject *WinObj_TransitionWindow(_self, _args)
915 WindowObject *_self;
916 PyObject *_args;
918 PyObject *_res = NULL;
919 OSStatus _err;
920 WindowTransitionEffect effect;
921 WindowTransitionAction action;
922 Rect rect;
923 if (!PyArg_ParseTuple(_args, "llO&",
924 &effect,
925 &action,
926 PyMac_GetRect, &rect))
927 return NULL;
928 _err = TransitionWindow(_self->ob_itself,
929 effect,
930 action,
931 &rect);
932 if (_err != noErr) return PyMac_Error(_err);
933 Py_INCREF(Py_None);
934 _res = Py_None;
935 return _res;
938 static PyObject *WinObj_MacMoveWindow(_self, _args)
939 WindowObject *_self;
940 PyObject *_args;
942 PyObject *_res = NULL;
943 short hGlobal;
944 short vGlobal;
945 Boolean front;
946 if (!PyArg_ParseTuple(_args, "hhb",
947 &hGlobal,
948 &vGlobal,
949 &front))
950 return NULL;
951 MacMoveWindow(_self->ob_itself,
952 hGlobal,
953 vGlobal,
954 front);
955 Py_INCREF(Py_None);
956 _res = Py_None;
957 return _res;
960 static PyObject *WinObj_SizeWindow(_self, _args)
961 WindowObject *_self;
962 PyObject *_args;
964 PyObject *_res = NULL;
965 short w;
966 short h;
967 Boolean fUpdate;
968 if (!PyArg_ParseTuple(_args, "hhb",
971 &fUpdate))
972 return NULL;
973 SizeWindow(_self->ob_itself,
976 fUpdate);
977 Py_INCREF(Py_None);
978 _res = Py_None;
979 return _res;
982 static PyObject *WinObj_GrowWindow(_self, _args)
983 WindowObject *_self;
984 PyObject *_args;
986 PyObject *_res = NULL;
987 long _rv;
988 Point startPt;
989 Rect bBox;
990 if (!PyArg_ParseTuple(_args, "O&O&",
991 PyMac_GetPoint, &startPt,
992 PyMac_GetRect, &bBox))
993 return NULL;
994 _rv = GrowWindow(_self->ob_itself,
995 startPt,
996 &bBox);
997 _res = Py_BuildValue("l",
998 _rv);
999 return _res;
1002 static PyObject *WinObj_DragWindow(_self, _args)
1003 WindowObject *_self;
1004 PyObject *_args;
1006 PyObject *_res = NULL;
1007 Point startPt;
1008 Rect boundsRect;
1009 if (!PyArg_ParseTuple(_args, "O&O&",
1010 PyMac_GetPoint, &startPt,
1011 PyMac_GetRect, &boundsRect))
1012 return NULL;
1013 DragWindow(_self->ob_itself,
1014 startPt,
1015 &boundsRect);
1016 Py_INCREF(Py_None);
1017 _res = Py_None;
1018 return _res;
1021 static PyObject *WinObj_ZoomWindow(_self, _args)
1022 WindowObject *_self;
1023 PyObject *_args;
1025 PyObject *_res = NULL;
1026 short partCode;
1027 Boolean front;
1028 if (!PyArg_ParseTuple(_args, "hb",
1029 &partCode,
1030 &front))
1031 return NULL;
1032 ZoomWindow(_self->ob_itself,
1033 partCode,
1034 front);
1035 Py_INCREF(Py_None);
1036 _res = Py_None;
1037 return _res;
1040 static PyObject *WinObj_IsWindowCollapsable(_self, _args)
1041 WindowObject *_self;
1042 PyObject *_args;
1044 PyObject *_res = NULL;
1045 Boolean _rv;
1046 if (!PyArg_ParseTuple(_args, ""))
1047 return NULL;
1048 _rv = IsWindowCollapsable(_self->ob_itself);
1049 _res = Py_BuildValue("b",
1050 _rv);
1051 return _res;
1054 static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1055 WindowObject *_self;
1056 PyObject *_args;
1058 PyObject *_res = NULL;
1059 Boolean _rv;
1060 if (!PyArg_ParseTuple(_args, ""))
1061 return NULL;
1062 _rv = IsWindowCollapsed(_self->ob_itself);
1063 _res = Py_BuildValue("b",
1064 _rv);
1065 return _res;
1068 static PyObject *WinObj_CollapseWindow(_self, _args)
1069 WindowObject *_self;
1070 PyObject *_args;
1072 PyObject *_res = NULL;
1073 OSStatus _err;
1074 Boolean collapse;
1075 if (!PyArg_ParseTuple(_args, "b",
1076 &collapse))
1077 return NULL;
1078 _err = CollapseWindow(_self->ob_itself,
1079 collapse);
1080 if (_err != noErr) return PyMac_Error(_err);
1081 Py_INCREF(Py_None);
1082 _res = Py_None;
1083 return _res;
1086 static PyObject *WinObj_RepositionWindow(_self, _args)
1087 WindowObject *_self;
1088 PyObject *_args;
1090 PyObject *_res = NULL;
1091 OSStatus _err;
1092 WindowPtr parentWindow;
1093 WindowPositionMethod method;
1094 if (!PyArg_ParseTuple(_args, "O&l",
1095 WinObj_Convert, &parentWindow,
1096 &method))
1097 return NULL;
1098 _err = RepositionWindow(_self->ob_itself,
1099 parentWindow,
1100 method);
1101 if (_err != noErr) return PyMac_Error(_err);
1102 Py_INCREF(Py_None);
1103 _res = Py_None;
1104 return _res;
1107 static PyObject *WinObj_SetWindowBounds(_self, _args)
1108 WindowObject *_self;
1109 PyObject *_args;
1111 PyObject *_res = NULL;
1112 OSStatus _err;
1113 WindowRegionCode regionCode;
1114 Rect globalBounds;
1115 if (!PyArg_ParseTuple(_args, "hO&",
1116 &regionCode,
1117 PyMac_GetRect, &globalBounds))
1118 return NULL;
1119 _err = SetWindowBounds(_self->ob_itself,
1120 regionCode,
1121 &globalBounds);
1122 if (_err != noErr) return PyMac_Error(_err);
1123 Py_INCREF(Py_None);
1124 _res = Py_None;
1125 return _res;
1128 static PyObject *WinObj_GetWindowBounds(_self, _args)
1129 WindowObject *_self;
1130 PyObject *_args;
1132 PyObject *_res = NULL;
1133 OSStatus _err;
1134 WindowRegionCode regionCode;
1135 Rect globalBounds;
1136 if (!PyArg_ParseTuple(_args, "h",
1137 &regionCode))
1138 return NULL;
1139 _err = GetWindowBounds(_self->ob_itself,
1140 regionCode,
1141 &globalBounds);
1142 if (_err != noErr) return PyMac_Error(_err);
1143 _res = Py_BuildValue("O&",
1144 PyMac_BuildRect, &globalBounds);
1145 return _res;
1148 static PyObject *WinObj_MoveWindowStructure(_self, _args)
1149 WindowObject *_self;
1150 PyObject *_args;
1152 PyObject *_res = NULL;
1153 OSStatus _err;
1154 short hGlobal;
1155 short vGlobal;
1156 if (!PyArg_ParseTuple(_args, "hh",
1157 &hGlobal,
1158 &vGlobal))
1159 return NULL;
1160 _err = MoveWindowStructure(_self->ob_itself,
1161 hGlobal,
1162 vGlobal);
1163 if (_err != noErr) return PyMac_Error(_err);
1164 Py_INCREF(Py_None);
1165 _res = Py_None;
1166 return _res;
1169 static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1170 WindowObject *_self;
1171 PyObject *_args;
1173 PyObject *_res = NULL;
1174 Boolean _rv;
1175 Point idealSize;
1176 Rect idealStandardState;
1177 if (!PyArg_ParseTuple(_args, ""))
1178 return NULL;
1179 _rv = IsWindowInStandardState(_self->ob_itself,
1180 &idealSize,
1181 &idealStandardState);
1182 _res = Py_BuildValue("bO&O&",
1183 _rv,
1184 PyMac_BuildPoint, idealSize,
1185 PyMac_BuildRect, &idealStandardState);
1186 return _res;
1189 static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1190 WindowObject *_self;
1191 PyObject *_args;
1193 PyObject *_res = NULL;
1194 OSStatus _err;
1195 SInt16 partCode;
1196 Point ioIdealSize;
1197 if (!PyArg_ParseTuple(_args, "h",
1198 &partCode))
1199 return NULL;
1200 _err = ZoomWindowIdeal(_self->ob_itself,
1201 partCode,
1202 &ioIdealSize);
1203 if (_err != noErr) return PyMac_Error(_err);
1204 _res = Py_BuildValue("O&",
1205 PyMac_BuildPoint, ioIdealSize);
1206 return _res;
1209 static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1210 WindowObject *_self;
1211 PyObject *_args;
1213 PyObject *_res = NULL;
1214 OSStatus _err;
1215 Rect userState;
1216 if (!PyArg_ParseTuple(_args, ""))
1217 return NULL;
1218 _err = GetWindowIdealUserState(_self->ob_itself,
1219 &userState);
1220 if (_err != noErr) return PyMac_Error(_err);
1221 _res = Py_BuildValue("O&",
1222 PyMac_BuildRect, &userState);
1223 return _res;
1226 static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1227 WindowObject *_self;
1228 PyObject *_args;
1230 PyObject *_res = NULL;
1231 OSStatus _err;
1232 Rect userState;
1233 if (!PyArg_ParseTuple(_args, ""))
1234 return NULL;
1235 _err = SetWindowIdealUserState(_self->ob_itself,
1236 &userState);
1237 if (_err != noErr) return PyMac_Error(_err);
1238 _res = Py_BuildValue("O&",
1239 PyMac_BuildRect, &userState);
1240 return _res;
1243 static PyObject *WinObj_HideWindow(_self, _args)
1244 WindowObject *_self;
1245 PyObject *_args;
1247 PyObject *_res = NULL;
1248 if (!PyArg_ParseTuple(_args, ""))
1249 return NULL;
1250 HideWindow(_self->ob_itself);
1251 Py_INCREF(Py_None);
1252 _res = Py_None;
1253 return _res;
1256 static PyObject *WinObj_MacShowWindow(_self, _args)
1257 WindowObject *_self;
1258 PyObject *_args;
1260 PyObject *_res = NULL;
1261 if (!PyArg_ParseTuple(_args, ""))
1262 return NULL;
1263 MacShowWindow(_self->ob_itself);
1264 Py_INCREF(Py_None);
1265 _res = Py_None;
1266 return _res;
1269 static PyObject *WinObj_ShowHide(_self, _args)
1270 WindowObject *_self;
1271 PyObject *_args;
1273 PyObject *_res = NULL;
1274 Boolean showFlag;
1275 if (!PyArg_ParseTuple(_args, "b",
1276 &showFlag))
1277 return NULL;
1278 ShowHide(_self->ob_itself,
1279 showFlag);
1280 Py_INCREF(Py_None);
1281 _res = Py_None;
1282 return _res;
1285 static PyObject *WinObj_TrackBox(_self, _args)
1286 WindowObject *_self;
1287 PyObject *_args;
1289 PyObject *_res = NULL;
1290 Boolean _rv;
1291 Point thePt;
1292 short partCode;
1293 if (!PyArg_ParseTuple(_args, "O&h",
1294 PyMac_GetPoint, &thePt,
1295 &partCode))
1296 return NULL;
1297 _rv = TrackBox(_self->ob_itself,
1298 thePt,
1299 partCode);
1300 _res = Py_BuildValue("b",
1301 _rv);
1302 return _res;
1305 static PyObject *WinObj_TrackGoAway(_self, _args)
1306 WindowObject *_self;
1307 PyObject *_args;
1309 PyObject *_res = NULL;
1310 Boolean _rv;
1311 Point thePt;
1312 if (!PyArg_ParseTuple(_args, "O&",
1313 PyMac_GetPoint, &thePt))
1314 return NULL;
1315 _rv = TrackGoAway(_self->ob_itself,
1316 thePt);
1317 _res = Py_BuildValue("b",
1318 _rv);
1319 return _res;
1322 static PyObject *WinObj_GetAuxWin(_self, _args)
1323 WindowObject *_self;
1324 PyObject *_args;
1326 PyObject *_res = NULL;
1327 Boolean _rv;
1328 AuxWinHandle awHndl;
1329 if (!PyArg_ParseTuple(_args, ""))
1330 return NULL;
1331 _rv = GetAuxWin(_self->ob_itself,
1332 &awHndl);
1333 _res = Py_BuildValue("bO&",
1334 _rv,
1335 ResObj_New, awHndl);
1336 return _res;
1339 static PyObject *WinObj_GetWindowPort(_self, _args)
1340 WindowObject *_self;
1341 PyObject *_args;
1343 PyObject *_res = NULL;
1344 CGrafPtr _rv;
1345 if (!PyArg_ParseTuple(_args, ""))
1346 return NULL;
1347 _rv = GetWindowPort(_self->ob_itself);
1348 _res = Py_BuildValue("O&",
1349 GrafObj_New, _rv);
1350 return _res;
1353 static PyObject *WinObj_SetPortWindowPort(_self, _args)
1354 WindowObject *_self;
1355 PyObject *_args;
1357 PyObject *_res = NULL;
1358 if (!PyArg_ParseTuple(_args, ""))
1359 return NULL;
1360 SetPortWindowPort(_self->ob_itself);
1361 Py_INCREF(Py_None);
1362 _res = Py_None;
1363 return _res;
1366 static PyObject *WinObj_GetWindowKind(_self, _args)
1367 WindowObject *_self;
1368 PyObject *_args;
1370 PyObject *_res = NULL;
1371 short _rv;
1372 if (!PyArg_ParseTuple(_args, ""))
1373 return NULL;
1374 _rv = GetWindowKind(_self->ob_itself);
1375 _res = Py_BuildValue("h",
1376 _rv);
1377 return _res;
1380 static PyObject *WinObj_SetWindowKind(_self, _args)
1381 WindowObject *_self;
1382 PyObject *_args;
1384 PyObject *_res = NULL;
1385 short wKind;
1386 if (!PyArg_ParseTuple(_args, "h",
1387 &wKind))
1388 return NULL;
1389 SetWindowKind(_self->ob_itself,
1390 wKind);
1391 Py_INCREF(Py_None);
1392 _res = Py_None;
1393 return _res;
1396 static PyObject *WinObj_IsWindowVisible(_self, _args)
1397 WindowObject *_self;
1398 PyObject *_args;
1400 PyObject *_res = NULL;
1401 Boolean _rv;
1402 if (!PyArg_ParseTuple(_args, ""))
1403 return NULL;
1404 _rv = IsWindowVisible(_self->ob_itself);
1405 _res = Py_BuildValue("b",
1406 _rv);
1407 return _res;
1410 static PyObject *WinObj_IsWindowHilited(_self, _args)
1411 WindowObject *_self;
1412 PyObject *_args;
1414 PyObject *_res = NULL;
1415 Boolean _rv;
1416 if (!PyArg_ParseTuple(_args, ""))
1417 return NULL;
1418 _rv = IsWindowHilited(_self->ob_itself);
1419 _res = Py_BuildValue("b",
1420 _rv);
1421 return _res;
1424 static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1425 WindowObject *_self;
1426 PyObject *_args;
1428 PyObject *_res = NULL;
1429 Boolean _rv;
1430 if (!PyArg_ParseTuple(_args, ""))
1431 return NULL;
1432 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1433 _res = Py_BuildValue("b",
1434 _rv);
1435 return _res;
1438 static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1439 WindowObject *_self;
1440 PyObject *_args;
1442 PyObject *_res = NULL;
1443 Boolean _rv;
1444 if (!PyArg_ParseTuple(_args, ""))
1445 return NULL;
1446 _rv = GetWindowZoomFlag(_self->ob_itself);
1447 _res = Py_BuildValue("b",
1448 _rv);
1449 return _res;
1452 static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1453 WindowObject *_self;
1454 PyObject *_args;
1456 PyObject *_res = NULL;
1457 RgnHandle r;
1458 if (!PyArg_ParseTuple(_args, "O&",
1459 ResObj_Convert, &r))
1460 return NULL;
1461 GetWindowStructureRgn(_self->ob_itself,
1463 Py_INCREF(Py_None);
1464 _res = Py_None;
1465 return _res;
1468 static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1469 WindowObject *_self;
1470 PyObject *_args;
1472 PyObject *_res = NULL;
1473 RgnHandle r;
1474 if (!PyArg_ParseTuple(_args, "O&",
1475 ResObj_Convert, &r))
1476 return NULL;
1477 GetWindowContentRgn(_self->ob_itself,
1479 Py_INCREF(Py_None);
1480 _res = Py_None;
1481 return _res;
1484 static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1485 WindowObject *_self;
1486 PyObject *_args;
1488 PyObject *_res = NULL;
1489 RgnHandle r;
1490 if (!PyArg_ParseTuple(_args, "O&",
1491 ResObj_Convert, &r))
1492 return NULL;
1493 GetWindowUpdateRgn(_self->ob_itself,
1495 Py_INCREF(Py_None);
1496 _res = Py_None;
1497 return _res;
1500 static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1501 WindowObject *_self;
1502 PyObject *_args;
1504 PyObject *_res = NULL;
1505 short _rv;
1506 if (!PyArg_ParseTuple(_args, ""))
1507 return NULL;
1508 _rv = GetWindowTitleWidth(_self->ob_itself);
1509 _res = Py_BuildValue("h",
1510 _rv);
1511 return _res;
1514 static PyObject *WinObj_GetNextWindow(_self, _args)
1515 WindowObject *_self;
1516 PyObject *_args;
1518 PyObject *_res = NULL;
1519 WindowPtr _rv;
1520 if (!PyArg_ParseTuple(_args, ""))
1521 return NULL;
1522 _rv = GetNextWindow(_self->ob_itself);
1523 _res = Py_BuildValue("O&",
1524 WinObj_WhichWindow, _rv);
1525 return _res;
1528 static PyObject *WinObj_GetWindowStandardState(_self, _args)
1529 WindowObject *_self;
1530 PyObject *_args;
1532 PyObject *_res = NULL;
1533 Rect r;
1534 if (!PyArg_ParseTuple(_args, ""))
1535 return NULL;
1536 GetWindowStandardState(_self->ob_itself,
1537 &r);
1538 _res = Py_BuildValue("O&",
1539 PyMac_BuildRect, &r);
1540 return _res;
1543 static PyObject *WinObj_GetWindowUserState(_self, _args)
1544 WindowObject *_self;
1545 PyObject *_args;
1547 PyObject *_res = NULL;
1548 Rect r;
1549 if (!PyArg_ParseTuple(_args, ""))
1550 return NULL;
1551 GetWindowUserState(_self->ob_itself,
1552 &r);
1553 _res = Py_BuildValue("O&",
1554 PyMac_BuildRect, &r);
1555 return _res;
1558 static PyObject *WinObj_SetWindowStandardState(_self, _args)
1559 WindowObject *_self;
1560 PyObject *_args;
1562 PyObject *_res = NULL;
1563 Rect r;
1564 if (!PyArg_ParseTuple(_args, "O&",
1565 PyMac_GetRect, &r))
1566 return NULL;
1567 SetWindowStandardState(_self->ob_itself,
1568 &r);
1569 Py_INCREF(Py_None);
1570 _res = Py_None;
1571 return _res;
1574 static PyObject *WinObj_SetWindowUserState(_self, _args)
1575 WindowObject *_self;
1576 PyObject *_args;
1578 PyObject *_res = NULL;
1579 Rect r;
1580 if (!PyArg_ParseTuple(_args, "O&",
1581 PyMac_GetRect, &r))
1582 return NULL;
1583 SetWindowUserState(_self->ob_itself,
1584 &r);
1585 Py_INCREF(Py_None);
1586 _res = Py_None;
1587 return _res;
1590 static PyObject *WinObj_GetWindowDataHandle(_self, _args)
1591 WindowObject *_self;
1592 PyObject *_args;
1594 PyObject *_res = NULL;
1595 Handle _rv;
1596 if (!PyArg_ParseTuple(_args, ""))
1597 return NULL;
1598 _rv = GetWindowDataHandle(_self->ob_itself);
1599 _res = Py_BuildValue("O&",
1600 ResObj_New, _rv);
1601 return _res;
1604 static PyObject *WinObj_SetWindowDataHandle(_self, _args)
1605 WindowObject *_self;
1606 PyObject *_args;
1608 PyObject *_res = NULL;
1609 Handle data;
1610 if (!PyArg_ParseTuple(_args, "O&",
1611 ResObj_Convert, &data))
1612 return NULL;
1613 SetWindowDataHandle(_self->ob_itself,
1614 data);
1615 Py_INCREF(Py_None);
1616 _res = Py_None;
1617 return _res;
1620 static PyObject *WinObj_CloseWindow(_self, _args)
1621 WindowObject *_self;
1622 PyObject *_args;
1624 PyObject *_res = NULL;
1625 if (!PyArg_ParseTuple(_args, ""))
1626 return NULL;
1627 CloseWindow(_self->ob_itself);
1628 Py_INCREF(Py_None);
1629 _res = Py_None;
1630 return _res;
1633 static PyObject *WinObj_MoveWindow(_self, _args)
1634 WindowObject *_self;
1635 PyObject *_args;
1637 PyObject *_res = NULL;
1638 short hGlobal;
1639 short vGlobal;
1640 Boolean front;
1641 if (!PyArg_ParseTuple(_args, "hhb",
1642 &hGlobal,
1643 &vGlobal,
1644 &front))
1645 return NULL;
1646 MoveWindow(_self->ob_itself,
1647 hGlobal,
1648 vGlobal,
1649 front);
1650 Py_INCREF(Py_None);
1651 _res = Py_None;
1652 return _res;
1655 static PyObject *WinObj_ShowWindow(_self, _args)
1656 WindowObject *_self;
1657 PyObject *_args;
1659 PyObject *_res = NULL;
1660 if (!PyArg_ParseTuple(_args, ""))
1661 return NULL;
1662 ShowWindow(_self->ob_itself);
1663 Py_INCREF(Py_None);
1664 _res = Py_None;
1665 return _res;
1668 static PyMethodDef WinObj_methods[] = {
1669 {"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
1670 "() -> None"},
1671 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
1672 "() -> (UInt32 outCount)"},
1673 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
1674 "() -> None"},
1675 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
1676 "() -> (WindowClass outClass)"},
1677 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
1678 "() -> (WindowAttributes outAttributes)"},
1679 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1680 "(WCTabHandle newColorTable) -> None"},
1681 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
1682 "() -> (RGBColor color)"},
1683 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
1684 "() -> (RGBColor color)"},
1685 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
1686 "(PixPatHandle outPixPat) -> None"},
1687 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
1688 "(PixPatHandle pixPat) -> None"},
1689 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1690 "() -> None"},
1691 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1692 "() -> None"},
1693 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1694 "(Boolean update) -> None"},
1695 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1696 "(RgnHandle clobberedRgn) -> None"},
1697 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1698 "(RgnHandle clobberedRgn) -> None"},
1699 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1700 "() -> None"},
1701 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1702 "(RgnHandle clobberedRgn) -> None"},
1703 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1704 "() -> None"},
1705 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1706 "(WindowPtr behindWindow) -> None"},
1707 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1708 "() -> None"},
1709 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1710 "(Boolean fHilite) -> None"},
1711 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1712 "(long data) -> None"},
1713 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1714 "() -> (long _rv)"},
1715 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1716 "(PicHandle pic) -> None"},
1717 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1718 "() -> (PicHandle _rv)"},
1719 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1720 "() -> (short _rv)"},
1721 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1722 "() -> (UInt32 outFeatures)"},
1723 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1724 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
1725 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1726 "() -> None"},
1727 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1728 "() -> None"},
1729 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
1730 "(RgnHandle region) -> None"},
1731 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
1732 "(Rect bounds) -> None"},
1733 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
1734 "(RgnHandle region) -> None"},
1735 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
1736 "(Rect bounds) -> None"},
1737 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1738 "() -> None"},
1739 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1740 "(Str255 title) -> None"},
1741 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1742 "() -> (Str255 title)"},
1743 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
1744 "(FSSpec inFile) -> None"},
1745 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
1746 "() -> (FSSpec outFile)"},
1747 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
1748 "(AliasHandle alias) -> None"},
1749 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
1750 "() -> (AliasHandle alias)"},
1751 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
1752 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
1753 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
1754 "() -> (IconRef outIcon)"},
1755 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
1756 "(IconRef icon) -> None"},
1757 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
1758 "() -> None"},
1759 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
1760 "(Point startPt) -> None"},
1761 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
1762 "() -> (Boolean _rv)"},
1763 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
1764 "(Boolean modified) -> None"},
1765 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
1766 "() -> (Boolean _rv, EventRecord event)"},
1767 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
1768 "(Boolean hilited) -> None"},
1769 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
1770 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
1771 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
1772 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1773 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1774 "(short w, short h, Boolean fUpdate) -> None"},
1775 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1776 "(Point startPt, Rect bBox) -> (long _rv)"},
1777 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1778 "(Point startPt, Rect boundsRect) -> None"},
1779 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1780 "(short partCode, Boolean front) -> None"},
1781 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1782 "() -> (Boolean _rv)"},
1783 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1784 "() -> (Boolean _rv)"},
1785 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
1786 "(Boolean collapse) -> None"},
1787 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
1788 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
1789 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
1790 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
1791 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
1792 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
1793 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
1794 "(short hGlobal, short vGlobal) -> None"},
1795 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
1796 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
1797 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
1798 "(SInt16 partCode) -> (Point ioIdealSize)"},
1799 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
1800 "() -> (Rect userState)"},
1801 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
1802 "() -> (Rect userState)"},
1803 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1804 "() -> None"},
1805 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
1806 "() -> None"},
1807 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1808 "(Boolean showFlag) -> None"},
1809 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1810 "(Point thePt, short partCode) -> (Boolean _rv)"},
1811 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1812 "(Point thePt) -> (Boolean _rv)"},
1813 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1814 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
1815 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1816 "() -> (CGrafPtr _rv)"},
1817 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1818 "() -> None"},
1819 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1820 "() -> (short _rv)"},
1821 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1822 "(short wKind) -> None"},
1823 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1824 "() -> (Boolean _rv)"},
1825 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1826 "() -> (Boolean _rv)"},
1827 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1828 "() -> (Boolean _rv)"},
1829 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1830 "() -> (Boolean _rv)"},
1831 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1832 "(RgnHandle r) -> None"},
1833 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1834 "(RgnHandle r) -> None"},
1835 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1836 "(RgnHandle r) -> None"},
1837 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1838 "() -> (short _rv)"},
1839 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1840 "() -> (WindowPtr _rv)"},
1841 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1842 "() -> (Rect r)"},
1843 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1844 "() -> (Rect r)"},
1845 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1846 "(Rect r) -> None"},
1847 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1848 "(Rect r) -> None"},
1849 {"GetWindowDataHandle", (PyCFunction)WinObj_GetWindowDataHandle, 1,
1850 "() -> (Handle _rv)"},
1851 {"SetWindowDataHandle", (PyCFunction)WinObj_SetWindowDataHandle, 1,
1852 "(Handle data) -> None"},
1853 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
1854 "() -> None"},
1855 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
1856 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1857 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
1858 "() -> None"},
1859 {NULL, NULL, 0}
1862 PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1864 static PyObject *WinObj_getattr(self, name)
1865 WindowObject *self;
1866 char *name;
1868 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1871 #define WinObj_setattr NULL
1873 #define WinObj_compare NULL
1875 #define WinObj_repr NULL
1877 #define WinObj_hash NULL
1879 PyTypeObject Window_Type = {
1880 PyObject_HEAD_INIT(&PyType_Type)
1881 0, /*ob_size*/
1882 "Window", /*tp_name*/
1883 sizeof(WindowObject), /*tp_basicsize*/
1884 0, /*tp_itemsize*/
1885 /* methods */
1886 (destructor) WinObj_dealloc, /*tp_dealloc*/
1887 0, /*tp_print*/
1888 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1889 (setattrfunc) WinObj_setattr, /*tp_setattr*/
1890 (cmpfunc) WinObj_compare, /*tp_compare*/
1891 (reprfunc) WinObj_repr, /*tp_repr*/
1892 (PyNumberMethods *)0, /* tp_as_number */
1893 (PySequenceMethods *)0, /* tp_as_sequence */
1894 (PyMappingMethods *)0, /* tp_as_mapping */
1895 (hashfunc) WinObj_hash, /*tp_hash*/
1898 /* --------------------- End object type Window --------------------- */
1901 static PyObject *Win_GetNewCWindow(_self, _args)
1902 PyObject *_self;
1903 PyObject *_args;
1905 PyObject *_res = NULL;
1906 WindowPtr _rv;
1907 short windowID;
1908 WindowPtr behind;
1909 if (!PyArg_ParseTuple(_args, "hO&",
1910 &windowID,
1911 WinObj_Convert, &behind))
1912 return NULL;
1913 _rv = GetNewCWindow(windowID,
1914 (void *)0,
1915 behind);
1916 _res = Py_BuildValue("O&",
1917 WinObj_New, _rv);
1918 return _res;
1921 static PyObject *Win_NewWindow(_self, _args)
1922 PyObject *_self;
1923 PyObject *_args;
1925 PyObject *_res = NULL;
1926 WindowPtr _rv;
1927 Rect boundsRect;
1928 Str255 title;
1929 Boolean visible;
1930 short theProc;
1931 WindowPtr behind;
1932 Boolean goAwayFlag;
1933 long refCon;
1934 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1935 PyMac_GetRect, &boundsRect,
1936 PyMac_GetStr255, title,
1937 &visible,
1938 &theProc,
1939 WinObj_Convert, &behind,
1940 &goAwayFlag,
1941 &refCon))
1942 return NULL;
1943 _rv = NewWindow((void *)0,
1944 &boundsRect,
1945 title,
1946 visible,
1947 theProc,
1948 behind,
1949 goAwayFlag,
1950 refCon);
1951 _res = Py_BuildValue("O&",
1952 WinObj_New, _rv);
1953 return _res;
1956 static PyObject *Win_GetNewWindow(_self, _args)
1957 PyObject *_self;
1958 PyObject *_args;
1960 PyObject *_res = NULL;
1961 WindowPtr _rv;
1962 short windowID;
1963 WindowPtr behind;
1964 if (!PyArg_ParseTuple(_args, "hO&",
1965 &windowID,
1966 WinObj_Convert, &behind))
1967 return NULL;
1968 _rv = GetNewWindow(windowID,
1969 (void *)0,
1970 behind);
1971 _res = Py_BuildValue("O&",
1972 WinObj_New, _rv);
1973 return _res;
1976 static PyObject *Win_NewCWindow(_self, _args)
1977 PyObject *_self;
1978 PyObject *_args;
1980 PyObject *_res = NULL;
1981 WindowPtr _rv;
1982 Rect boundsRect;
1983 Str255 title;
1984 Boolean visible;
1985 short procID;
1986 WindowPtr behind;
1987 Boolean goAwayFlag;
1988 long refCon;
1989 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1990 PyMac_GetRect, &boundsRect,
1991 PyMac_GetStr255, title,
1992 &visible,
1993 &procID,
1994 WinObj_Convert, &behind,
1995 &goAwayFlag,
1996 &refCon))
1997 return NULL;
1998 _rv = NewCWindow((void *)0,
1999 &boundsRect,
2000 title,
2001 visible,
2002 procID,
2003 behind,
2004 goAwayFlag,
2005 refCon);
2006 _res = Py_BuildValue("O&",
2007 WinObj_New, _rv);
2008 return _res;
2011 static PyObject *Win_CreateNewWindow(_self, _args)
2012 PyObject *_self;
2013 PyObject *_args;
2015 PyObject *_res = NULL;
2016 OSStatus _err;
2017 WindowClass windowClass;
2018 WindowAttributes attributes;
2019 Rect bounds;
2020 WindowPtr outWindow;
2021 if (!PyArg_ParseTuple(_args, "llO&",
2022 &windowClass,
2023 &attributes,
2024 PyMac_GetRect, &bounds))
2025 return NULL;
2026 _err = CreateNewWindow(windowClass,
2027 attributes,
2028 &bounds,
2029 &outWindow);
2030 if (_err != noErr) return PyMac_Error(_err);
2031 _res = Py_BuildValue("O&",
2032 WinObj_WhichWindow, outWindow);
2033 return _res;
2036 static PyObject *Win_CreateWindowFromResource(_self, _args)
2037 PyObject *_self;
2038 PyObject *_args;
2040 PyObject *_res = NULL;
2041 OSStatus _err;
2042 SInt16 resID;
2043 WindowPtr outWindow;
2044 if (!PyArg_ParseTuple(_args, "h",
2045 &resID))
2046 return NULL;
2047 _err = CreateWindowFromResource(resID,
2048 &outWindow);
2049 if (_err != noErr) return PyMac_Error(_err);
2050 _res = Py_BuildValue("O&",
2051 WinObj_WhichWindow, outWindow);
2052 return _res;
2055 static PyObject *Win_ShowFloatingWindows(_self, _args)
2056 PyObject *_self;
2057 PyObject *_args;
2059 PyObject *_res = NULL;
2060 OSStatus _err;
2061 if (!PyArg_ParseTuple(_args, ""))
2062 return NULL;
2063 _err = ShowFloatingWindows();
2064 if (_err != noErr) return PyMac_Error(_err);
2065 Py_INCREF(Py_None);
2066 _res = Py_None;
2067 return _res;
2070 static PyObject *Win_HideFloatingWindows(_self, _args)
2071 PyObject *_self;
2072 PyObject *_args;
2074 PyObject *_res = NULL;
2075 OSStatus _err;
2076 if (!PyArg_ParseTuple(_args, ""))
2077 return NULL;
2078 _err = HideFloatingWindows();
2079 if (_err != noErr) return PyMac_Error(_err);
2080 Py_INCREF(Py_None);
2081 _res = Py_None;
2082 return _res;
2085 static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2086 PyObject *_self;
2087 PyObject *_args;
2089 PyObject *_res = NULL;
2090 Boolean _rv;
2091 if (!PyArg_ParseTuple(_args, ""))
2092 return NULL;
2093 _rv = AreFloatingWindowsVisible();
2094 _res = Py_BuildValue("b",
2095 _rv);
2096 return _res;
2099 static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2100 PyObject *_self;
2101 PyObject *_args;
2103 PyObject *_res = NULL;
2104 WindowPtr _rv;
2105 if (!PyArg_ParseTuple(_args, ""))
2106 return NULL;
2107 _rv = FrontNonFloatingWindow();
2108 _res = Py_BuildValue("O&",
2109 WinObj_New, _rv);
2110 return _res;
2113 static PyObject *Win_SetDeskCPat(_self, _args)
2114 PyObject *_self;
2115 PyObject *_args;
2117 PyObject *_res = NULL;
2118 PixPatHandle deskPixPat;
2119 if (!PyArg_ParseTuple(_args, "O&",
2120 ResObj_Convert, &deskPixPat))
2121 return NULL;
2122 SetDeskCPat(deskPixPat);
2123 Py_INCREF(Py_None);
2124 _res = Py_None;
2125 return _res;
2128 static PyObject *Win_CheckUpdate(_self, _args)
2129 PyObject *_self;
2130 PyObject *_args;
2132 PyObject *_res = NULL;
2133 Boolean _rv;
2134 EventRecord theEvent;
2135 if (!PyArg_ParseTuple(_args, ""))
2136 return NULL;
2137 _rv = CheckUpdate(&theEvent);
2138 _res = Py_BuildValue("bO&",
2139 _rv,
2140 PyMac_BuildEventRecord, &theEvent);
2141 return _res;
2144 static PyObject *Win_MacFindWindow(_self, _args)
2145 PyObject *_self;
2146 PyObject *_args;
2148 PyObject *_res = NULL;
2149 short _rv;
2150 Point thePoint;
2151 WindowPtr window;
2152 if (!PyArg_ParseTuple(_args, "O&",
2153 PyMac_GetPoint, &thePoint))
2154 return NULL;
2155 _rv = MacFindWindow(thePoint,
2156 &window);
2157 _res = Py_BuildValue("hO&",
2158 _rv,
2159 WinObj_WhichWindow, window);
2160 return _res;
2163 static PyObject *Win_FrontWindow(_self, _args)
2164 PyObject *_self;
2165 PyObject *_args;
2167 PyObject *_res = NULL;
2168 WindowPtr _rv;
2169 if (!PyArg_ParseTuple(_args, ""))
2170 return NULL;
2171 _rv = FrontWindow();
2172 _res = Py_BuildValue("O&",
2173 WinObj_WhichWindow, _rv);
2174 return _res;
2177 static PyObject *Win_InitWindows(_self, _args)
2178 PyObject *_self;
2179 PyObject *_args;
2181 PyObject *_res = NULL;
2182 if (!PyArg_ParseTuple(_args, ""))
2183 return NULL;
2184 InitWindows();
2185 Py_INCREF(Py_None);
2186 _res = Py_None;
2187 return _res;
2190 static PyObject *Win_GetWMgrPort(_self, _args)
2191 PyObject *_self;
2192 PyObject *_args;
2194 PyObject *_res = NULL;
2195 GrafPtr wPort;
2196 if (!PyArg_ParseTuple(_args, ""))
2197 return NULL;
2198 GetWMgrPort(&wPort);
2199 _res = Py_BuildValue("O&",
2200 GrafObj_New, wPort);
2201 return _res;
2204 static PyObject *Win_GetCWMgrPort(_self, _args)
2205 PyObject *_self;
2206 PyObject *_args;
2208 PyObject *_res = NULL;
2209 CGrafPtr wMgrCPort;
2210 if (!PyArg_ParseTuple(_args, ""))
2211 return NULL;
2212 GetCWMgrPort(&wMgrCPort);
2213 _res = Py_BuildValue("O&",
2214 GrafObj_New, wMgrCPort);
2215 return _res;
2218 static PyObject *Win_IsValidWindowPtr(_self, _args)
2219 PyObject *_self;
2220 PyObject *_args;
2222 PyObject *_res = NULL;
2223 Boolean _rv;
2224 GrafPtr grafPort;
2225 if (!PyArg_ParseTuple(_args, "O&",
2226 GrafObj_Convert, &grafPort))
2227 return NULL;
2228 _rv = IsValidWindowPtr(grafPort);
2229 _res = Py_BuildValue("b",
2230 _rv);
2231 return _res;
2234 static PyObject *Win_InitFloatingWindows(_self, _args)
2235 PyObject *_self;
2236 PyObject *_args;
2238 PyObject *_res = NULL;
2239 OSStatus _err;
2240 if (!PyArg_ParseTuple(_args, ""))
2241 return NULL;
2242 _err = InitFloatingWindows();
2243 if (_err != noErr) return PyMac_Error(_err);
2244 Py_INCREF(Py_None);
2245 _res = Py_None;
2246 return _res;
2249 static PyObject *Win_InvalRect(_self, _args)
2250 PyObject *_self;
2251 PyObject *_args;
2253 PyObject *_res = NULL;
2254 Rect badRect;
2255 if (!PyArg_ParseTuple(_args, "O&",
2256 PyMac_GetRect, &badRect))
2257 return NULL;
2258 InvalRect(&badRect);
2259 Py_INCREF(Py_None);
2260 _res = Py_None;
2261 return _res;
2264 static PyObject *Win_InvalRgn(_self, _args)
2265 PyObject *_self;
2266 PyObject *_args;
2268 PyObject *_res = NULL;
2269 RgnHandle badRgn;
2270 if (!PyArg_ParseTuple(_args, "O&",
2271 ResObj_Convert, &badRgn))
2272 return NULL;
2273 InvalRgn(badRgn);
2274 Py_INCREF(Py_None);
2275 _res = Py_None;
2276 return _res;
2279 static PyObject *Win_ValidRect(_self, _args)
2280 PyObject *_self;
2281 PyObject *_args;
2283 PyObject *_res = NULL;
2284 Rect goodRect;
2285 if (!PyArg_ParseTuple(_args, "O&",
2286 PyMac_GetRect, &goodRect))
2287 return NULL;
2288 ValidRect(&goodRect);
2289 Py_INCREF(Py_None);
2290 _res = Py_None;
2291 return _res;
2294 static PyObject *Win_ValidRgn(_self, _args)
2295 PyObject *_self;
2296 PyObject *_args;
2298 PyObject *_res = NULL;
2299 RgnHandle goodRgn;
2300 if (!PyArg_ParseTuple(_args, "O&",
2301 ResObj_Convert, &goodRgn))
2302 return NULL;
2303 ValidRgn(goodRgn);
2304 Py_INCREF(Py_None);
2305 _res = Py_None;
2306 return _res;
2309 static PyObject *Win_CollapseAllWindows(_self, _args)
2310 PyObject *_self;
2311 PyObject *_args;
2313 PyObject *_res = NULL;
2314 OSStatus _err;
2315 Boolean collapse;
2316 if (!PyArg_ParseTuple(_args, "b",
2317 &collapse))
2318 return NULL;
2319 _err = CollapseAllWindows(collapse);
2320 if (_err != noErr) return PyMac_Error(_err);
2321 Py_INCREF(Py_None);
2322 _res = Py_None;
2323 return _res;
2326 static PyObject *Win_PinRect(_self, _args)
2327 PyObject *_self;
2328 PyObject *_args;
2330 PyObject *_res = NULL;
2331 long _rv;
2332 Rect theRect;
2333 Point thePt;
2334 if (!PyArg_ParseTuple(_args, "O&O&",
2335 PyMac_GetRect, &theRect,
2336 PyMac_GetPoint, &thePt))
2337 return NULL;
2338 _rv = PinRect(&theRect,
2339 thePt);
2340 _res = Py_BuildValue("l",
2341 _rv);
2342 return _res;
2345 static PyObject *Win_GetGrayRgn(_self, _args)
2346 PyObject *_self;
2347 PyObject *_args;
2349 PyObject *_res = NULL;
2350 RgnHandle _rv;
2351 if (!PyArg_ParseTuple(_args, ""))
2352 return NULL;
2353 _rv = GetGrayRgn();
2354 _res = Py_BuildValue("O&",
2355 ResObj_New, _rv);
2356 return _res;
2359 static PyObject *Win_WhichWindow(_self, _args)
2360 PyObject *_self;
2361 PyObject *_args;
2363 PyObject *_res = NULL;
2365 long ptr;
2367 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2368 return NULL;
2369 return WinObj_WhichWindow((WindowPtr)ptr);
2373 static PyObject *Win_FindWindow(_self, _args)
2374 PyObject *_self;
2375 PyObject *_args;
2377 PyObject *_res = NULL;
2378 short _rv;
2379 Point thePoint;
2380 WindowPtr theWindow;
2381 if (!PyArg_ParseTuple(_args, "O&",
2382 PyMac_GetPoint, &thePoint))
2383 return NULL;
2384 _rv = FindWindow(thePoint,
2385 &theWindow);
2386 _res = Py_BuildValue("hO&",
2387 _rv,
2388 WinObj_WhichWindow, theWindow);
2389 return _res;
2392 static PyMethodDef Win_methods[] = {
2393 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2394 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2395 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2396 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2397 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2398 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
2399 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2400 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2401 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
2402 "(WindowClass windowClass, WindowAttributes attributes, Rect bounds) -> (WindowPtr outWindow)"},
2403 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2404 "(SInt16 resID) -> (WindowPtr outWindow)"},
2405 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2406 "() -> None"},
2407 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2408 "() -> None"},
2409 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2410 "() -> (Boolean _rv)"},
2411 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2412 "() -> (WindowPtr _rv)"},
2413 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2414 "(PixPatHandle deskPixPat) -> None"},
2415 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2416 "() -> (Boolean _rv, EventRecord theEvent)"},
2417 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
2418 "(Point thePoint) -> (short _rv, WindowPtr window)"},
2419 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2420 "() -> (WindowPtr _rv)"},
2421 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2422 "() -> None"},
2423 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2424 "() -> (GrafPtr wPort)"},
2425 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2426 "() -> (CGrafPtr wMgrCPort)"},
2427 {"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1,
2428 "(GrafPtr grafPort) -> (Boolean _rv)"},
2429 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2430 "() -> None"},
2431 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2432 "(Rect badRect) -> None"},
2433 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2434 "(RgnHandle badRgn) -> None"},
2435 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2436 "(Rect goodRect) -> None"},
2437 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2438 "(RgnHandle goodRgn) -> None"},
2439 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
2440 "(Boolean collapse) -> None"},
2441 {"PinRect", (PyCFunction)Win_PinRect, 1,
2442 "(Rect theRect, Point thePt) -> (long _rv)"},
2443 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2444 "() -> (RgnHandle _rv)"},
2445 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2446 "Resolve an integer WindowPtr address to a Window object"},
2447 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2448 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
2449 {NULL, NULL, 0}
2454 /* Return the object corresponding to the window, or NULL */
2456 PyObject *
2457 WinObj_WhichWindow(w)
2458 WindowPtr w;
2460 PyObject *it;
2462 /* XXX What if we find a stdwin window or a window belonging
2463 to some other package? */
2464 if (w == NULL)
2465 it = NULL;
2466 else
2467 it = (PyObject *) GetWRefCon(w);
2468 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
2469 it = Py_None;
2470 Py_INCREF(it);
2471 return it;
2475 void initWin()
2477 PyObject *m;
2478 PyObject *d;
2483 m = Py_InitModule("Win", Win_methods);
2484 d = PyModule_GetDict(m);
2485 Win_Error = PyMac_GetOSErrException();
2486 if (Win_Error == NULL ||
2487 PyDict_SetItemString(d, "Error", Win_Error) != 0)
2488 Py_FatalError("can't initialize Win.Error");
2489 Window_Type.ob_type = &PyType_Type;
2490 Py_INCREF(&Window_Type);
2491 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2492 Py_FatalError("can't initialize WindowType");
2495 /* ========================= End module Win ========================= */