blob: 033dd4b331e62f291ef10a30d380e6b25ab4e9f0 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Win =========================== */
3
4#include "Python.h"
5
6
7
Guido van Rossum17448e21995-01-30 11:53:55 +00008#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +00009#include "pymactoolbox.h"
Guido van Rossum17448e21995-01-30 11:53:55 +000010
11#include <Windows.h>
12
Guido van Rossum17448e21995-01-30 11:53:55 +000013static PyObject *Win_Error;
14
15/* ----------------------- Object type Window ----------------------- */
16
17PyTypeObject Window_Type;
18
19#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
20
21typedef struct WindowObject {
22 PyObject_HEAD
23 WindowPtr ob_itself;
24} WindowObject;
25
26PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000027 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000028{
29 WindowObject *it;
30 if (itself == NULL) return PyMac_Error(resNotFound);
31 it = PyObject_NEW(WindowObject, &Window_Type);
32 if (it == NULL) return NULL;
33 it->ob_itself = itself;
34 SetWRefCon(itself, (long)it);
35 return (PyObject *)it;
36}
37WinObj_Convert(v, p_itself)
38 PyObject *v;
39 WindowPtr *p_itself;
40{
Jack Jansene79dc762000-06-02 21:35:07 +000041#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +000042 if (DlgObj_Check(v)) {
43 *p_itself = ((WindowObject *)v)->ob_itself;
44 return 1;
45 }
Jack Jansene79dc762000-06-02 21:35:07 +000046#endif
Guido van Rossum17448e21995-01-30 11:53:55 +000047
48 if (v == Py_None) { *p_itself = NULL; return 1; }
49 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
50
51 if (!WinObj_Check(v))
52 {
53 PyErr_SetString(PyExc_TypeError, "Window required");
54 return 0;
55 }
56 *p_itself = ((WindowObject *)v)->ob_itself;
57 return 1;
58}
59
60static void WinObj_dealloc(self)
61 WindowObject *self;
62{
63 DisposeWindow(self->ob_itself);
64 PyMem_DEL(self);
65}
66
Jack Jansena05ac601999-12-12 21:41:51 +000067static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
68 WindowObject *_self;
69 PyObject *_args;
70{
71 PyObject *_res = NULL;
72 OSStatus _err;
73 UInt32 outCount;
74 if (!PyArg_ParseTuple(_args, ""))
75 return NULL;
76 _err = GetWindowOwnerCount(_self->ob_itself,
77 &outCount);
78 if (_err != noErr) return PyMac_Error(_err);
79 _res = Py_BuildValue("l",
80 outCount);
81 return _res;
82}
83
84static PyObject *WinObj_CloneWindow(_self, _args)
85 WindowObject *_self;
86 PyObject *_args;
87{
88 PyObject *_res = NULL;
89 OSStatus _err;
90 if (!PyArg_ParseTuple(_args, ""))
91 return NULL;
92 _err = CloneWindow(_self->ob_itself);
93 if (_err != noErr) return PyMac_Error(_err);
94 Py_INCREF(Py_None);
95 _res = Py_None;
96 return _res;
97}
98
99static PyObject *WinObj_GetWindowClass(_self, _args)
100 WindowObject *_self;
101 PyObject *_args;
102{
103 PyObject *_res = NULL;
104 OSStatus _err;
105 WindowClass outClass;
106 if (!PyArg_ParseTuple(_args, ""))
107 return NULL;
108 _err = GetWindowClass(_self->ob_itself,
109 &outClass);
110 if (_err != noErr) return PyMac_Error(_err);
111 _res = Py_BuildValue("l",
112 outClass);
113 return _res;
114}
115
116static PyObject *WinObj_GetWindowAttributes(_self, _args)
117 WindowObject *_self;
118 PyObject *_args;
119{
120 PyObject *_res = NULL;
121 OSStatus _err;
122 WindowAttributes outAttributes;
123 if (!PyArg_ParseTuple(_args, ""))
124 return NULL;
125 _err = GetWindowAttributes(_self->ob_itself,
126 &outAttributes);
127 if (_err != noErr) return PyMac_Error(_err);
128 _res = Py_BuildValue("l",
129 outAttributes);
130 return _res;
131}
132
Jack Jansene79dc762000-06-02 21:35:07 +0000133#ifndef TARGET_API_MAC_CARBON
134
Jack Jansen21f96871998-02-20 16:02:09 +0000135static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000136 WindowObject *_self;
137 PyObject *_args;
138{
139 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000140 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000141 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000142 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000143 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000144 SetWinColor(_self->ob_itself,
145 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000146 Py_INCREF(Py_None);
147 _res = Py_None;
148 return _res;
149}
Jack Jansene79dc762000-06-02 21:35:07 +0000150#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000151
Jack Jansena05ac601999-12-12 21:41:51 +0000152static PyObject *WinObj_SetWindowContentColor(_self, _args)
153 WindowObject *_self;
154 PyObject *_args;
155{
156 PyObject *_res = NULL;
157 OSStatus _err;
158 RGBColor color;
159 if (!PyArg_ParseTuple(_args, ""))
160 return NULL;
161 _err = SetWindowContentColor(_self->ob_itself,
162 &color);
163 if (_err != noErr) return PyMac_Error(_err);
164 _res = Py_BuildValue("O&",
165 QdRGB_New, &color);
166 return _res;
167}
168
169static PyObject *WinObj_GetWindowContentColor(_self, _args)
170 WindowObject *_self;
171 PyObject *_args;
172{
173 PyObject *_res = NULL;
174 OSStatus _err;
175 RGBColor color;
176 if (!PyArg_ParseTuple(_args, ""))
177 return NULL;
178 _err = GetWindowContentColor(_self->ob_itself,
179 &color);
180 if (_err != noErr) return PyMac_Error(_err);
181 _res = Py_BuildValue("O&",
182 QdRGB_New, &color);
183 return _res;
184}
185
186static PyObject *WinObj_GetWindowContentPattern(_self, _args)
187 WindowObject *_self;
188 PyObject *_args;
189{
190 PyObject *_res = NULL;
191 OSStatus _err;
192 PixPatHandle outPixPat;
193 if (!PyArg_ParseTuple(_args, "O&",
194 ResObj_Convert, &outPixPat))
195 return NULL;
196 _err = GetWindowContentPattern(_self->ob_itself,
197 outPixPat);
198 if (_err != noErr) return PyMac_Error(_err);
199 Py_INCREF(Py_None);
200 _res = Py_None;
201 return _res;
202}
203
204static PyObject *WinObj_SetWindowContentPattern(_self, _args)
205 WindowObject *_self;
206 PyObject *_args;
207{
208 PyObject *_res = NULL;
209 OSStatus _err;
210 PixPatHandle pixPat;
211 if (!PyArg_ParseTuple(_args, "O&",
212 ResObj_Convert, &pixPat))
213 return NULL;
214 _err = SetWindowContentPattern(_self->ob_itself,
215 pixPat);
216 if (_err != noErr) return PyMac_Error(_err);
217 Py_INCREF(Py_None);
218 _res = Py_None;
219 return _res;
220}
221
Guido van Rossum17448e21995-01-30 11:53:55 +0000222static PyObject *WinObj_ClipAbove(_self, _args)
223 WindowObject *_self;
224 PyObject *_args;
225{
226 PyObject *_res = NULL;
227 if (!PyArg_ParseTuple(_args, ""))
228 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000229 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000230 Py_INCREF(Py_None);
231 _res = Py_None;
232 return _res;
233}
234
Jack Jansene79dc762000-06-02 21:35:07 +0000235#ifndef TARGET_API_MAC_CARBON
236
Guido van Rossum17448e21995-01-30 11:53:55 +0000237static PyObject *WinObj_SaveOld(_self, _args)
238 WindowObject *_self;
239 PyObject *_args;
240{
241 PyObject *_res = NULL;
242 if (!PyArg_ParseTuple(_args, ""))
243 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000244 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000245 Py_INCREF(Py_None);
246 _res = Py_None;
247 return _res;
248}
Jack Jansene79dc762000-06-02 21:35:07 +0000249#endif
250
251#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000252
253static PyObject *WinObj_DrawNew(_self, _args)
254 WindowObject *_self;
255 PyObject *_args;
256{
257 PyObject *_res = NULL;
258 Boolean update;
259 if (!PyArg_ParseTuple(_args, "b",
260 &update))
261 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000262 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000263 update);
264 Py_INCREF(Py_None);
265 _res = Py_None;
266 return _res;
267}
Jack Jansene79dc762000-06-02 21:35:07 +0000268#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000269
Jack Jansenb7abb181995-11-15 15:18:47 +0000270static PyObject *WinObj_PaintOne(_self, _args)
271 WindowObject *_self;
272 PyObject *_args;
273{
274 PyObject *_res = NULL;
275 RgnHandle clobberedRgn;
276 if (!PyArg_ParseTuple(_args, "O&",
277 ResObj_Convert, &clobberedRgn))
278 return NULL;
279 PaintOne(_self->ob_itself,
280 clobberedRgn);
281 Py_INCREF(Py_None);
282 _res = Py_None;
283 return _res;
284}
285
286static PyObject *WinObj_PaintBehind(_self, _args)
287 WindowObject *_self;
288 PyObject *_args;
289{
290 PyObject *_res = NULL;
291 RgnHandle clobberedRgn;
292 if (!PyArg_ParseTuple(_args, "O&",
293 ResObj_Convert, &clobberedRgn))
294 return NULL;
295 PaintBehind(_self->ob_itself,
296 clobberedRgn);
297 Py_INCREF(Py_None);
298 _res = Py_None;
299 return _res;
300}
301
Guido van Rossum17448e21995-01-30 11:53:55 +0000302static PyObject *WinObj_CalcVis(_self, _args)
303 WindowObject *_self;
304 PyObject *_args;
305{
306 PyObject *_res = NULL;
307 if (!PyArg_ParseTuple(_args, ""))
308 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000309 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000310 Py_INCREF(Py_None);
311 _res = Py_None;
312 return _res;
313}
314
Jack Jansenb7abb181995-11-15 15:18:47 +0000315static PyObject *WinObj_CalcVisBehind(_self, _args)
316 WindowObject *_self;
317 PyObject *_args;
318{
319 PyObject *_res = NULL;
320 RgnHandle clobberedRgn;
321 if (!PyArg_ParseTuple(_args, "O&",
322 ResObj_Convert, &clobberedRgn))
323 return NULL;
324 CalcVisBehind(_self->ob_itself,
325 clobberedRgn);
326 Py_INCREF(Py_None);
327 _res = Py_None;
328 return _res;
329}
330
Jack Jansen21f96871998-02-20 16:02:09 +0000331static PyObject *WinObj_BringToFront(_self, _args)
332 WindowObject *_self;
333 PyObject *_args;
334{
335 PyObject *_res = NULL;
336 if (!PyArg_ParseTuple(_args, ""))
337 return NULL;
338 BringToFront(_self->ob_itself);
339 Py_INCREF(Py_None);
340 _res = Py_None;
341 return _res;
342}
343
344static PyObject *WinObj_SendBehind(_self, _args)
345 WindowObject *_self;
346 PyObject *_args;
347{
348 PyObject *_res = NULL;
349 WindowPtr behindWindow;
350 if (!PyArg_ParseTuple(_args, "O&",
351 WinObj_Convert, &behindWindow))
352 return NULL;
353 SendBehind(_self->ob_itself,
354 behindWindow);
355 Py_INCREF(Py_None);
356 _res = Py_None;
357 return _res;
358}
359
360static PyObject *WinObj_SelectWindow(_self, _args)
361 WindowObject *_self;
362 PyObject *_args;
363{
364 PyObject *_res = NULL;
365 if (!PyArg_ParseTuple(_args, ""))
366 return NULL;
367 SelectWindow(_self->ob_itself);
368 Py_INCREF(Py_None);
369 _res = Py_None;
370 return _res;
371}
372
Jack Jansen1c4e6141998-04-21 15:23:55 +0000373static PyObject *WinObj_HiliteWindow(_self, _args)
374 WindowObject *_self;
375 PyObject *_args;
376{
377 PyObject *_res = NULL;
378 Boolean fHilite;
379 if (!PyArg_ParseTuple(_args, "b",
380 &fHilite))
381 return NULL;
382 HiliteWindow(_self->ob_itself,
383 fHilite);
384 Py_INCREF(Py_None);
385 _res = Py_None;
386 return _res;
387}
388
Jack Jansen21f96871998-02-20 16:02:09 +0000389static PyObject *WinObj_SetWRefCon(_self, _args)
390 WindowObject *_self;
391 PyObject *_args;
392{
393 PyObject *_res = NULL;
394 long data;
395 if (!PyArg_ParseTuple(_args, "l",
396 &data))
397 return NULL;
398 SetWRefCon(_self->ob_itself,
399 data);
400 Py_INCREF(Py_None);
401 _res = Py_None;
402 return _res;
403}
404
405static PyObject *WinObj_GetWRefCon(_self, _args)
406 WindowObject *_self;
407 PyObject *_args;
408{
409 PyObject *_res = NULL;
410 long _rv;
411 if (!PyArg_ParseTuple(_args, ""))
412 return NULL;
413 _rv = GetWRefCon(_self->ob_itself);
414 _res = Py_BuildValue("l",
415 _rv);
416 return _res;
417}
418
419static PyObject *WinObj_SetWindowPic(_self, _args)
420 WindowObject *_self;
421 PyObject *_args;
422{
423 PyObject *_res = NULL;
424 PicHandle pic;
425 if (!PyArg_ParseTuple(_args, "O&",
426 ResObj_Convert, &pic))
427 return NULL;
428 SetWindowPic(_self->ob_itself,
429 pic);
430 Py_INCREF(Py_None);
431 _res = Py_None;
432 return _res;
433}
434
435static PyObject *WinObj_GetWindowPic(_self, _args)
436 WindowObject *_self;
437 PyObject *_args;
438{
439 PyObject *_res = NULL;
440 PicHandle _rv;
441 if (!PyArg_ParseTuple(_args, ""))
442 return NULL;
443 _rv = GetWindowPic(_self->ob_itself);
444 _res = Py_BuildValue("O&",
445 ResObj_New, _rv);
446 return _res;
447}
448
449static PyObject *WinObj_GetWVariant(_self, _args)
450 WindowObject *_self;
451 PyObject *_args;
452{
453 PyObject *_res = NULL;
454 short _rv;
455 if (!PyArg_ParseTuple(_args, ""))
456 return NULL;
457 _rv = GetWVariant(_self->ob_itself);
458 _res = Py_BuildValue("h",
459 _rv);
460 return _res;
461}
462
Jack Jansena05ac601999-12-12 21:41:51 +0000463static PyObject *WinObj_GetWindowFeatures(_self, _args)
464 WindowObject *_self;
465 PyObject *_args;
466{
467 PyObject *_res = NULL;
468 OSStatus _err;
469 UInt32 outFeatures;
470 if (!PyArg_ParseTuple(_args, ""))
471 return NULL;
472 _err = GetWindowFeatures(_self->ob_itself,
473 &outFeatures);
474 if (_err != noErr) return PyMac_Error(_err);
475 _res = Py_BuildValue("l",
476 outFeatures);
477 return _res;
478}
479
480static PyObject *WinObj_GetWindowRegion(_self, _args)
481 WindowObject *_self;
482 PyObject *_args;
483{
484 PyObject *_res = NULL;
485 OSStatus _err;
486 WindowRegionCode inRegionCode;
487 RgnHandle ioWinRgn;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000488 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +0000489 &inRegionCode,
490 ResObj_Convert, &ioWinRgn))
491 return NULL;
492 _err = GetWindowRegion(_self->ob_itself,
493 inRegionCode,
494 ioWinRgn);
495 if (_err != noErr) return PyMac_Error(_err);
496 Py_INCREF(Py_None);
497 _res = Py_None;
498 return _res;
499}
500
Jack Jansen21f96871998-02-20 16:02:09 +0000501static PyObject *WinObj_BeginUpdate(_self, _args)
502 WindowObject *_self;
503 PyObject *_args;
504{
505 PyObject *_res = NULL;
506 if (!PyArg_ParseTuple(_args, ""))
507 return NULL;
508 BeginUpdate(_self->ob_itself);
509 Py_INCREF(Py_None);
510 _res = Py_None;
511 return _res;
512}
513
514static PyObject *WinObj_EndUpdate(_self, _args)
515 WindowObject *_self;
516 PyObject *_args;
517{
518 PyObject *_res = NULL;
519 if (!PyArg_ParseTuple(_args, ""))
520 return NULL;
521 EndUpdate(_self->ob_itself);
522 Py_INCREF(Py_None);
523 _res = Py_None;
524 return _res;
525}
526
Jack Jansena05ac601999-12-12 21:41:51 +0000527static PyObject *WinObj_InvalWindowRgn(_self, _args)
528 WindowObject *_self;
529 PyObject *_args;
530{
531 PyObject *_res = NULL;
532 OSStatus _err;
533 RgnHandle region;
534 if (!PyArg_ParseTuple(_args, "O&",
535 ResObj_Convert, &region))
536 return NULL;
537 _err = InvalWindowRgn(_self->ob_itself,
538 region);
539 if (_err != noErr) return PyMac_Error(_err);
540 Py_INCREF(Py_None);
541 _res = Py_None;
542 return _res;
543}
544
545static PyObject *WinObj_InvalWindowRect(_self, _args)
546 WindowObject *_self;
547 PyObject *_args;
548{
549 PyObject *_res = NULL;
550 OSStatus _err;
551 Rect bounds;
552 if (!PyArg_ParseTuple(_args, "O&",
553 PyMac_GetRect, &bounds))
554 return NULL;
555 _err = InvalWindowRect(_self->ob_itself,
556 &bounds);
557 if (_err != noErr) return PyMac_Error(_err);
558 Py_INCREF(Py_None);
559 _res = Py_None;
560 return _res;
561}
562
563static PyObject *WinObj_ValidWindowRgn(_self, _args)
564 WindowObject *_self;
565 PyObject *_args;
566{
567 PyObject *_res = NULL;
568 OSStatus _err;
569 RgnHandle region;
570 if (!PyArg_ParseTuple(_args, "O&",
571 ResObj_Convert, &region))
572 return NULL;
573 _err = ValidWindowRgn(_self->ob_itself,
574 region);
575 if (_err != noErr) return PyMac_Error(_err);
576 Py_INCREF(Py_None);
577 _res = Py_None;
578 return _res;
579}
580
581static PyObject *WinObj_ValidWindowRect(_self, _args)
582 WindowObject *_self;
583 PyObject *_args;
584{
585 PyObject *_res = NULL;
586 OSStatus _err;
587 Rect bounds;
588 if (!PyArg_ParseTuple(_args, "O&",
589 PyMac_GetRect, &bounds))
590 return NULL;
591 _err = ValidWindowRect(_self->ob_itself,
592 &bounds);
593 if (_err != noErr) return PyMac_Error(_err);
594 Py_INCREF(Py_None);
595 _res = Py_None;
596 return _res;
597}
598
Jack Jansen21f96871998-02-20 16:02:09 +0000599static PyObject *WinObj_DrawGrowIcon(_self, _args)
600 WindowObject *_self;
601 PyObject *_args;
602{
603 PyObject *_res = NULL;
604 if (!PyArg_ParseTuple(_args, ""))
605 return NULL;
606 DrawGrowIcon(_self->ob_itself);
607 Py_INCREF(Py_None);
608 _res = Py_None;
609 return _res;
610}
611
Jack Jansen21f96871998-02-20 16:02:09 +0000612static PyObject *WinObj_SetWTitle(_self, _args)
613 WindowObject *_self;
614 PyObject *_args;
615{
616 PyObject *_res = NULL;
617 Str255 title;
618 if (!PyArg_ParseTuple(_args, "O&",
619 PyMac_GetStr255, title))
620 return NULL;
621 SetWTitle(_self->ob_itself,
622 title);
623 Py_INCREF(Py_None);
624 _res = Py_None;
625 return _res;
626}
627
628static PyObject *WinObj_GetWTitle(_self, _args)
629 WindowObject *_self;
630 PyObject *_args;
631{
632 PyObject *_res = NULL;
633 Str255 title;
634 if (!PyArg_ParseTuple(_args, ""))
635 return NULL;
636 GetWTitle(_self->ob_itself,
637 title);
638 _res = Py_BuildValue("O&",
639 PyMac_BuildStr255, title);
640 return _res;
641}
642
Jack Jansena05ac601999-12-12 21:41:51 +0000643static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000644 WindowObject *_self;
645 PyObject *_args;
646{
647 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000648 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +0000649 FSSpec inFile;
650 if (!PyArg_ParseTuple(_args, "O&",
651 PyMac_GetFSSpec, &inFile))
Jack Jansen21f96871998-02-20 16:02:09 +0000652 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +0000653 _err = SetWindowProxyFSSpec(_self->ob_itself,
654 &inFile);
655 if (_err != noErr) return PyMac_Error(_err);
656 Py_INCREF(Py_None);
657 _res = Py_None;
658 return _res;
659}
660
661static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
662 WindowObject *_self;
663 PyObject *_args;
664{
665 PyObject *_res = NULL;
666 OSStatus _err;
667 FSSpec outFile;
668 if (!PyArg_ParseTuple(_args, ""))
669 return NULL;
670 _err = GetWindowProxyFSSpec(_self->ob_itself,
671 &outFile);
672 if (_err != noErr) return PyMac_Error(_err);
673 _res = Py_BuildValue("O&",
Jack Jansene79dc762000-06-02 21:35:07 +0000674 PyMac_BuildFSSpec, outFile);
Jack Jansena05ac601999-12-12 21:41:51 +0000675 return _res;
676}
677
678static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
679 WindowObject *_self;
680 PyObject *_args;
681{
682 PyObject *_res = NULL;
683 OSStatus _err;
684 AliasHandle alias;
685 if (!PyArg_ParseTuple(_args, "O&",
686 ResObj_Convert, &alias))
687 return NULL;
688 _err = SetWindowProxyAlias(_self->ob_itself,
689 alias);
690 if (_err != noErr) return PyMac_Error(_err);
691 Py_INCREF(Py_None);
692 _res = Py_None;
693 return _res;
694}
695
696static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
697 WindowObject *_self;
698 PyObject *_args;
699{
700 PyObject *_res = NULL;
701 OSStatus _err;
702 AliasHandle alias;
703 if (!PyArg_ParseTuple(_args, ""))
704 return NULL;
705 _err = GetWindowProxyAlias(_self->ob_itself,
706 &alias);
707 if (_err != noErr) return PyMac_Error(_err);
708 _res = Py_BuildValue("O&",
709 ResObj_New, alias);
710 return _res;
711}
712
713static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
714 WindowObject *_self;
715 PyObject *_args;
716{
717 PyObject *_res = NULL;
718 OSStatus _err;
719 OSType fileCreator;
720 OSType fileType;
721 SInt16 vRefNum;
722 if (!PyArg_ParseTuple(_args, "O&O&h",
723 PyMac_GetOSType, &fileCreator,
724 PyMac_GetOSType, &fileType,
725 &vRefNum))
726 return NULL;
727 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
728 fileCreator,
729 fileType,
730 vRefNum);
731 if (_err != noErr) return PyMac_Error(_err);
732 Py_INCREF(Py_None);
733 _res = Py_None;
734 return _res;
735}
736
737static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
738 WindowObject *_self;
739 PyObject *_args;
740{
741 PyObject *_res = NULL;
742 OSStatus _err;
743 IconRef outIcon;
744 if (!PyArg_ParseTuple(_args, ""))
745 return NULL;
746 _err = GetWindowProxyIcon(_self->ob_itself,
747 &outIcon);
748 if (_err != noErr) return PyMac_Error(_err);
749 _res = Py_BuildValue("O&",
750 ResObj_New, outIcon);
751 return _res;
752}
753
754static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
755 WindowObject *_self;
756 PyObject *_args;
757{
758 PyObject *_res = NULL;
759 OSStatus _err;
760 IconRef icon;
761 if (!PyArg_ParseTuple(_args, "O&",
762 ResObj_Convert, &icon))
763 return NULL;
764 _err = SetWindowProxyIcon(_self->ob_itself,
765 icon);
766 if (_err != noErr) return PyMac_Error(_err);
767 Py_INCREF(Py_None);
768 _res = Py_None;
769 return _res;
770}
771
772static PyObject *WinObj_RemoveWindowProxy(_self, _args)
773 WindowObject *_self;
774 PyObject *_args;
775{
776 PyObject *_res = NULL;
777 OSStatus _err;
778 if (!PyArg_ParseTuple(_args, ""))
779 return NULL;
780 _err = RemoveWindowProxy(_self->ob_itself);
781 if (_err != noErr) return PyMac_Error(_err);
782 Py_INCREF(Py_None);
783 _res = Py_None;
784 return _res;
785}
786
787static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
788 WindowObject *_self;
789 PyObject *_args;
790{
791 PyObject *_res = NULL;
792 OSStatus _err;
793 Point startPt;
794 if (!PyArg_ParseTuple(_args, "O&",
795 PyMac_GetPoint, &startPt))
796 return NULL;
797 _err = TrackWindowProxyDrag(_self->ob_itself,
798 startPt);
799 if (_err != noErr) return PyMac_Error(_err);
800 Py_INCREF(Py_None);
801 _res = Py_None;
802 return _res;
803}
804
805static PyObject *WinObj_IsWindowModified(_self, _args)
806 WindowObject *_self;
807 PyObject *_args;
808{
809 PyObject *_res = NULL;
810 Boolean _rv;
811 if (!PyArg_ParseTuple(_args, ""))
812 return NULL;
813 _rv = IsWindowModified(_self->ob_itself);
814 _res = Py_BuildValue("b",
815 _rv);
816 return _res;
817}
818
819static PyObject *WinObj_SetWindowModified(_self, _args)
820 WindowObject *_self;
821 PyObject *_args;
822{
823 PyObject *_res = NULL;
824 OSStatus _err;
825 Boolean modified;
826 if (!PyArg_ParseTuple(_args, "b",
827 &modified))
828 return NULL;
829 _err = SetWindowModified(_self->ob_itself,
830 modified);
831 if (_err != noErr) return PyMac_Error(_err);
832 Py_INCREF(Py_None);
833 _res = Py_None;
834 return _res;
835}
836
837static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
838 WindowObject *_self;
839 PyObject *_args;
840{
841 PyObject *_res = NULL;
842 Boolean _rv;
843 EventRecord event;
844 if (!PyArg_ParseTuple(_args, ""))
845 return NULL;
846 _rv = IsWindowPathSelectClick(_self->ob_itself,
847 &event);
848 _res = Py_BuildValue("bO&",
849 _rv,
850 PyMac_BuildEventRecord, &event);
851 return _res;
852}
853
854static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
855 WindowObject *_self;
856 PyObject *_args;
857{
858 PyObject *_res = NULL;
859 OSStatus _err;
860 Boolean hilited;
861 if (!PyArg_ParseTuple(_args, "b",
862 &hilited))
863 return NULL;
864 _err = HiliteWindowFrameForDrag(_self->ob_itself,
865 hilited);
866 if (_err != noErr) return PyMac_Error(_err);
867 Py_INCREF(Py_None);
868 _res = Py_None;
869 return _res;
870}
871
872static PyObject *WinObj_TransitionWindow(_self, _args)
873 WindowObject *_self;
874 PyObject *_args;
875{
876 PyObject *_res = NULL;
877 OSStatus _err;
878 WindowTransitionEffect effect;
879 WindowTransitionAction action;
880 Rect rect;
881 if (!PyArg_ParseTuple(_args, "llO&",
882 &effect,
883 &action,
884 PyMac_GetRect, &rect))
885 return NULL;
886 _err = TransitionWindow(_self->ob_itself,
887 effect,
888 action,
889 &rect);
Jack Jansene4349e81999-03-04 22:53:24 +0000890 if (_err != noErr) return PyMac_Error(_err);
891 Py_INCREF(Py_None);
892 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +0000893 return _res;
894}
895
Jack Jansen1c4e6141998-04-21 15:23:55 +0000896static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000897 WindowObject *_self;
898 PyObject *_args;
899{
900 PyObject *_res = NULL;
901 short hGlobal;
902 short vGlobal;
903 Boolean front;
904 if (!PyArg_ParseTuple(_args, "hhb",
905 &hGlobal,
906 &vGlobal,
907 &front))
908 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000909 MacMoveWindow(_self->ob_itself,
910 hGlobal,
911 vGlobal,
912 front);
Jack Jansen21f96871998-02-20 16:02:09 +0000913 Py_INCREF(Py_None);
914 _res = Py_None;
915 return _res;
916}
917
918static PyObject *WinObj_SizeWindow(_self, _args)
919 WindowObject *_self;
920 PyObject *_args;
921{
922 PyObject *_res = NULL;
923 short w;
924 short h;
925 Boolean fUpdate;
926 if (!PyArg_ParseTuple(_args, "hhb",
927 &w,
928 &h,
929 &fUpdate))
930 return NULL;
931 SizeWindow(_self->ob_itself,
932 w,
933 h,
934 fUpdate);
935 Py_INCREF(Py_None);
936 _res = Py_None;
937 return _res;
938}
939
Guido van Rossum17448e21995-01-30 11:53:55 +0000940static PyObject *WinObj_GrowWindow(_self, _args)
941 WindowObject *_self;
942 PyObject *_args;
943{
944 PyObject *_res = NULL;
945 long _rv;
946 Point startPt;
947 Rect bBox;
948 if (!PyArg_ParseTuple(_args, "O&O&",
949 PyMac_GetPoint, &startPt,
950 PyMac_GetRect, &bBox))
951 return NULL;
952 _rv = GrowWindow(_self->ob_itself,
953 startPt,
954 &bBox);
955 _res = Py_BuildValue("l",
956 _rv);
957 return _res;
958}
959
Jack Jansen21f96871998-02-20 16:02:09 +0000960static PyObject *WinObj_DragWindow(_self, _args)
961 WindowObject *_self;
962 PyObject *_args;
963{
964 PyObject *_res = NULL;
965 Point startPt;
966 Rect boundsRect;
967 if (!PyArg_ParseTuple(_args, "O&O&",
968 PyMac_GetPoint, &startPt,
969 PyMac_GetRect, &boundsRect))
970 return NULL;
971 DragWindow(_self->ob_itself,
972 startPt,
973 &boundsRect);
974 Py_INCREF(Py_None);
975 _res = Py_None;
976 return _res;
977}
978
Jack Jansena05ac601999-12-12 21:41:51 +0000979static PyObject *WinObj_ZoomWindow(_self, _args)
980 WindowObject *_self;
981 PyObject *_args;
982{
983 PyObject *_res = NULL;
984 short partCode;
985 Boolean front;
986 if (!PyArg_ParseTuple(_args, "hb",
987 &partCode,
988 &front))
989 return NULL;
990 ZoomWindow(_self->ob_itself,
991 partCode,
992 front);
993 Py_INCREF(Py_None);
994 _res = Py_None;
995 return _res;
996}
997
998static PyObject *WinObj_IsWindowCollapsable(_self, _args)
999 WindowObject *_self;
1000 PyObject *_args;
1001{
1002 PyObject *_res = NULL;
1003 Boolean _rv;
1004 if (!PyArg_ParseTuple(_args, ""))
1005 return NULL;
1006 _rv = IsWindowCollapsable(_self->ob_itself);
1007 _res = Py_BuildValue("b",
1008 _rv);
1009 return _res;
1010}
1011
1012static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1013 WindowObject *_self;
1014 PyObject *_args;
1015{
1016 PyObject *_res = NULL;
1017 Boolean _rv;
1018 if (!PyArg_ParseTuple(_args, ""))
1019 return NULL;
1020 _rv = IsWindowCollapsed(_self->ob_itself);
1021 _res = Py_BuildValue("b",
1022 _rv);
1023 return _res;
1024}
1025
1026static PyObject *WinObj_CollapseWindow(_self, _args)
1027 WindowObject *_self;
1028 PyObject *_args;
1029{
1030 PyObject *_res = NULL;
1031 OSStatus _err;
1032 Boolean collapse;
1033 if (!PyArg_ParseTuple(_args, "b",
1034 &collapse))
1035 return NULL;
1036 _err = CollapseWindow(_self->ob_itself,
1037 collapse);
1038 if (_err != noErr) return PyMac_Error(_err);
1039 Py_INCREF(Py_None);
1040 _res = Py_None;
1041 return _res;
1042}
1043
1044static PyObject *WinObj_RepositionWindow(_self, _args)
1045 WindowObject *_self;
1046 PyObject *_args;
1047{
1048 PyObject *_res = NULL;
1049 OSStatus _err;
1050 WindowPtr parentWindow;
1051 WindowPositionMethod method;
1052 if (!PyArg_ParseTuple(_args, "O&l",
1053 WinObj_Convert, &parentWindow,
1054 &method))
1055 return NULL;
1056 _err = RepositionWindow(_self->ob_itself,
1057 parentWindow,
1058 method);
1059 if (_err != noErr) return PyMac_Error(_err);
1060 Py_INCREF(Py_None);
1061 _res = Py_None;
1062 return _res;
1063}
1064
1065static PyObject *WinObj_SetWindowBounds(_self, _args)
1066 WindowObject *_self;
1067 PyObject *_args;
1068{
1069 PyObject *_res = NULL;
1070 OSStatus _err;
1071 WindowRegionCode regionCode;
1072 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001073 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +00001074 &regionCode,
1075 PyMac_GetRect, &globalBounds))
1076 return NULL;
1077 _err = SetWindowBounds(_self->ob_itself,
1078 regionCode,
1079 &globalBounds);
1080 if (_err != noErr) return PyMac_Error(_err);
1081 Py_INCREF(Py_None);
1082 _res = Py_None;
1083 return _res;
1084}
1085
1086static PyObject *WinObj_GetWindowBounds(_self, _args)
1087 WindowObject *_self;
1088 PyObject *_args;
1089{
1090 PyObject *_res = NULL;
1091 OSStatus _err;
1092 WindowRegionCode regionCode;
1093 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001094 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001095 &regionCode))
1096 return NULL;
1097 _err = GetWindowBounds(_self->ob_itself,
1098 regionCode,
1099 &globalBounds);
1100 if (_err != noErr) return PyMac_Error(_err);
1101 _res = Py_BuildValue("O&",
1102 PyMac_BuildRect, &globalBounds);
1103 return _res;
1104}
1105
1106static PyObject *WinObj_MoveWindowStructure(_self, _args)
1107 WindowObject *_self;
1108 PyObject *_args;
1109{
1110 PyObject *_res = NULL;
1111 OSStatus _err;
1112 short hGlobal;
1113 short vGlobal;
1114 if (!PyArg_ParseTuple(_args, "hh",
1115 &hGlobal,
1116 &vGlobal))
1117 return NULL;
1118 _err = MoveWindowStructure(_self->ob_itself,
1119 hGlobal,
1120 vGlobal);
1121 if (_err != noErr) return PyMac_Error(_err);
1122 Py_INCREF(Py_None);
1123 _res = Py_None;
1124 return _res;
1125}
1126
1127static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1128 WindowObject *_self;
1129 PyObject *_args;
1130{
1131 PyObject *_res = NULL;
1132 Boolean _rv;
1133 Point idealSize;
1134 Rect idealStandardState;
1135 if (!PyArg_ParseTuple(_args, ""))
1136 return NULL;
1137 _rv = IsWindowInStandardState(_self->ob_itself,
1138 &idealSize,
1139 &idealStandardState);
1140 _res = Py_BuildValue("bO&O&",
1141 _rv,
1142 PyMac_BuildPoint, idealSize,
1143 PyMac_BuildRect, &idealStandardState);
1144 return _res;
1145}
1146
1147static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1148 WindowObject *_self;
1149 PyObject *_args;
1150{
1151 PyObject *_res = NULL;
1152 OSStatus _err;
1153 SInt16 partCode;
1154 Point ioIdealSize;
1155 if (!PyArg_ParseTuple(_args, "h",
1156 &partCode))
1157 return NULL;
1158 _err = ZoomWindowIdeal(_self->ob_itself,
1159 partCode,
1160 &ioIdealSize);
1161 if (_err != noErr) return PyMac_Error(_err);
1162 _res = Py_BuildValue("O&",
1163 PyMac_BuildPoint, ioIdealSize);
1164 return _res;
1165}
1166
1167static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1168 WindowObject *_self;
1169 PyObject *_args;
1170{
1171 PyObject *_res = NULL;
1172 OSStatus _err;
1173 Rect userState;
1174 if (!PyArg_ParseTuple(_args, ""))
1175 return NULL;
1176 _err = GetWindowIdealUserState(_self->ob_itself,
1177 &userState);
1178 if (_err != noErr) return PyMac_Error(_err);
1179 _res = Py_BuildValue("O&",
1180 PyMac_BuildRect, &userState);
1181 return _res;
1182}
1183
1184static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1185 WindowObject *_self;
1186 PyObject *_args;
1187{
1188 PyObject *_res = NULL;
1189 OSStatus _err;
1190 Rect userState;
1191 if (!PyArg_ParseTuple(_args, ""))
1192 return NULL;
1193 _err = SetWindowIdealUserState(_self->ob_itself,
1194 &userState);
1195 if (_err != noErr) return PyMac_Error(_err);
1196 _res = Py_BuildValue("O&",
1197 PyMac_BuildRect, &userState);
1198 return _res;
1199}
1200
Jack Jansen21f96871998-02-20 16:02:09 +00001201static PyObject *WinObj_HideWindow(_self, _args)
1202 WindowObject *_self;
1203 PyObject *_args;
1204{
1205 PyObject *_res = NULL;
1206 if (!PyArg_ParseTuple(_args, ""))
1207 return NULL;
1208 HideWindow(_self->ob_itself);
1209 Py_INCREF(Py_None);
1210 _res = Py_None;
1211 return _res;
1212}
1213
Jack Jansen1c4e6141998-04-21 15:23:55 +00001214static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001215 WindowObject *_self;
1216 PyObject *_args;
1217{
1218 PyObject *_res = NULL;
1219 if (!PyArg_ParseTuple(_args, ""))
1220 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001221 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +00001222 Py_INCREF(Py_None);
1223 _res = Py_None;
1224 return _res;
1225}
1226
1227static PyObject *WinObj_ShowHide(_self, _args)
1228 WindowObject *_self;
1229 PyObject *_args;
1230{
1231 PyObject *_res = NULL;
1232 Boolean showFlag;
1233 if (!PyArg_ParseTuple(_args, "b",
1234 &showFlag))
1235 return NULL;
1236 ShowHide(_self->ob_itself,
1237 showFlag);
1238 Py_INCREF(Py_None);
1239 _res = Py_None;
1240 return _res;
1241}
1242
Guido van Rossum17448e21995-01-30 11:53:55 +00001243static PyObject *WinObj_TrackBox(_self, _args)
1244 WindowObject *_self;
1245 PyObject *_args;
1246{
1247 PyObject *_res = NULL;
1248 Boolean _rv;
1249 Point thePt;
1250 short partCode;
1251 if (!PyArg_ParseTuple(_args, "O&h",
1252 PyMac_GetPoint, &thePt,
1253 &partCode))
1254 return NULL;
1255 _rv = TrackBox(_self->ob_itself,
1256 thePt,
1257 partCode);
1258 _res = Py_BuildValue("b",
1259 _rv);
1260 return _res;
1261}
1262
Guido van Rossum17448e21995-01-30 11:53:55 +00001263static PyObject *WinObj_TrackGoAway(_self, _args)
1264 WindowObject *_self;
1265 PyObject *_args;
1266{
1267 PyObject *_res = NULL;
1268 Boolean _rv;
1269 Point thePt;
1270 if (!PyArg_ParseTuple(_args, "O&",
1271 PyMac_GetPoint, &thePt))
1272 return NULL;
1273 _rv = TrackGoAway(_self->ob_itself,
1274 thePt);
1275 _res = Py_BuildValue("b",
1276 _rv);
1277 return _res;
1278}
1279
Jack Jansene79dc762000-06-02 21:35:07 +00001280#ifndef TARGET_API_MAC_CARBON
1281
Jack Jansen8f0fab71997-08-15 14:38:05 +00001282static PyObject *WinObj_GetAuxWin(_self, _args)
1283 WindowObject *_self;
1284 PyObject *_args;
1285{
1286 PyObject *_res = NULL;
1287 Boolean _rv;
1288 AuxWinHandle awHndl;
1289 if (!PyArg_ParseTuple(_args, ""))
1290 return NULL;
1291 _rv = GetAuxWin(_self->ob_itself,
1292 &awHndl);
1293 _res = Py_BuildValue("bO&",
1294 _rv,
1295 ResObj_New, awHndl);
1296 return _res;
1297}
Jack Jansene79dc762000-06-02 21:35:07 +00001298#endif
Jack Jansen8f0fab71997-08-15 14:38:05 +00001299
Jack Jansenb7abb181995-11-15 15:18:47 +00001300static PyObject *WinObj_GetWindowPort(_self, _args)
1301 WindowObject *_self;
1302 PyObject *_args;
1303{
1304 PyObject *_res = NULL;
1305 CGrafPtr _rv;
1306 if (!PyArg_ParseTuple(_args, ""))
1307 return NULL;
1308 _rv = GetWindowPort(_self->ob_itself);
1309 _res = Py_BuildValue("O&",
1310 GrafObj_New, _rv);
1311 return _res;
1312}
1313
Jack Jansen330f5761995-11-14 10:48:54 +00001314static PyObject *WinObj_SetPortWindowPort(_self, _args)
1315 WindowObject *_self;
1316 PyObject *_args;
1317{
1318 PyObject *_res = NULL;
1319 if (!PyArg_ParseTuple(_args, ""))
1320 return NULL;
1321 SetPortWindowPort(_self->ob_itself);
1322 Py_INCREF(Py_None);
1323 _res = Py_None;
1324 return _res;
1325}
1326
1327static PyObject *WinObj_GetWindowKind(_self, _args)
1328 WindowObject *_self;
1329 PyObject *_args;
1330{
1331 PyObject *_res = NULL;
1332 short _rv;
1333 if (!PyArg_ParseTuple(_args, ""))
1334 return NULL;
1335 _rv = GetWindowKind(_self->ob_itself);
1336 _res = Py_BuildValue("h",
1337 _rv);
1338 return _res;
1339}
1340
1341static PyObject *WinObj_SetWindowKind(_self, _args)
1342 WindowObject *_self;
1343 PyObject *_args;
1344{
1345 PyObject *_res = NULL;
1346 short wKind;
1347 if (!PyArg_ParseTuple(_args, "h",
1348 &wKind))
1349 return NULL;
1350 SetWindowKind(_self->ob_itself,
1351 wKind);
1352 Py_INCREF(Py_None);
1353 _res = Py_None;
1354 return _res;
1355}
1356
1357static PyObject *WinObj_IsWindowVisible(_self, _args)
1358 WindowObject *_self;
1359 PyObject *_args;
1360{
1361 PyObject *_res = NULL;
1362 Boolean _rv;
1363 if (!PyArg_ParseTuple(_args, ""))
1364 return NULL;
1365 _rv = IsWindowVisible(_self->ob_itself);
1366 _res = Py_BuildValue("b",
1367 _rv);
1368 return _res;
1369}
1370
1371static PyObject *WinObj_IsWindowHilited(_self, _args)
1372 WindowObject *_self;
1373 PyObject *_args;
1374{
1375 PyObject *_res = NULL;
1376 Boolean _rv;
1377 if (!PyArg_ParseTuple(_args, ""))
1378 return NULL;
1379 _rv = IsWindowHilited(_self->ob_itself);
1380 _res = Py_BuildValue("b",
1381 _rv);
1382 return _res;
1383}
1384
1385static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1386 WindowObject *_self;
1387 PyObject *_args;
1388{
1389 PyObject *_res = NULL;
1390 Boolean _rv;
1391 if (!PyArg_ParseTuple(_args, ""))
1392 return NULL;
1393 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1394 _res = Py_BuildValue("b",
1395 _rv);
1396 return _res;
1397}
1398
Jack Jansene79dc762000-06-02 21:35:07 +00001399#ifndef TARGET_API_MAC_CARBON
1400
Jack Jansen330f5761995-11-14 10:48:54 +00001401static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1402 WindowObject *_self;
1403 PyObject *_args;
1404{
1405 PyObject *_res = NULL;
1406 Boolean _rv;
1407 if (!PyArg_ParseTuple(_args, ""))
1408 return NULL;
1409 _rv = GetWindowZoomFlag(_self->ob_itself);
1410 _res = Py_BuildValue("b",
1411 _rv);
1412 return _res;
1413}
Jack Jansene79dc762000-06-02 21:35:07 +00001414#endif
1415
1416#ifndef TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001417
Jack Jansenb7abb181995-11-15 15:18:47 +00001418static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1419 WindowObject *_self;
1420 PyObject *_args;
1421{
1422 PyObject *_res = NULL;
1423 RgnHandle r;
1424 if (!PyArg_ParseTuple(_args, "O&",
1425 ResObj_Convert, &r))
1426 return NULL;
1427 GetWindowStructureRgn(_self->ob_itself,
1428 r);
1429 Py_INCREF(Py_None);
1430 _res = Py_None;
1431 return _res;
1432}
Jack Jansene79dc762000-06-02 21:35:07 +00001433#endif
1434
1435#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001436
1437static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1438 WindowObject *_self;
1439 PyObject *_args;
1440{
1441 PyObject *_res = NULL;
1442 RgnHandle r;
1443 if (!PyArg_ParseTuple(_args, "O&",
1444 ResObj_Convert, &r))
1445 return NULL;
1446 GetWindowContentRgn(_self->ob_itself,
1447 r);
1448 Py_INCREF(Py_None);
1449 _res = Py_None;
1450 return _res;
1451}
Jack Jansene79dc762000-06-02 21:35:07 +00001452#endif
1453
1454#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001455
1456static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1457 WindowObject *_self;
1458 PyObject *_args;
1459{
1460 PyObject *_res = NULL;
1461 RgnHandle r;
1462 if (!PyArg_ParseTuple(_args, "O&",
1463 ResObj_Convert, &r))
1464 return NULL;
1465 GetWindowUpdateRgn(_self->ob_itself,
1466 r);
1467 Py_INCREF(Py_None);
1468 _res = Py_None;
1469 return _res;
1470}
Jack Jansene79dc762000-06-02 21:35:07 +00001471#endif
1472
1473#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001474
Jack Jansen330f5761995-11-14 10:48:54 +00001475static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1476 WindowObject *_self;
1477 PyObject *_args;
1478{
1479 PyObject *_res = NULL;
1480 short _rv;
1481 if (!PyArg_ParseTuple(_args, ""))
1482 return NULL;
1483 _rv = GetWindowTitleWidth(_self->ob_itself);
1484 _res = Py_BuildValue("h",
1485 _rv);
1486 return _res;
1487}
Jack Jansene79dc762000-06-02 21:35:07 +00001488#endif
Jack Jansen330f5761995-11-14 10:48:54 +00001489
1490static PyObject *WinObj_GetNextWindow(_self, _args)
1491 WindowObject *_self;
1492 PyObject *_args;
1493{
1494 PyObject *_res = NULL;
1495 WindowPtr _rv;
1496 if (!PyArg_ParseTuple(_args, ""))
1497 return NULL;
1498 _rv = GetNextWindow(_self->ob_itself);
1499 _res = Py_BuildValue("O&",
1500 WinObj_WhichWindow, _rv);
1501 return _res;
1502}
1503
1504static PyObject *WinObj_GetWindowStandardState(_self, _args)
1505 WindowObject *_self;
1506 PyObject *_args;
1507{
1508 PyObject *_res = NULL;
1509 Rect r;
1510 if (!PyArg_ParseTuple(_args, ""))
1511 return NULL;
1512 GetWindowStandardState(_self->ob_itself,
1513 &r);
1514 _res = Py_BuildValue("O&",
1515 PyMac_BuildRect, &r);
1516 return _res;
1517}
1518
1519static PyObject *WinObj_GetWindowUserState(_self, _args)
1520 WindowObject *_self;
1521 PyObject *_args;
1522{
1523 PyObject *_res = NULL;
1524 Rect r;
1525 if (!PyArg_ParseTuple(_args, ""))
1526 return NULL;
1527 GetWindowUserState(_self->ob_itself,
1528 &r);
1529 _res = Py_BuildValue("O&",
1530 PyMac_BuildRect, &r);
1531 return _res;
1532}
1533
1534static PyObject *WinObj_SetWindowStandardState(_self, _args)
1535 WindowObject *_self;
1536 PyObject *_args;
1537{
1538 PyObject *_res = NULL;
1539 Rect r;
1540 if (!PyArg_ParseTuple(_args, "O&",
1541 PyMac_GetRect, &r))
1542 return NULL;
1543 SetWindowStandardState(_self->ob_itself,
1544 &r);
1545 Py_INCREF(Py_None);
1546 _res = Py_None;
1547 return _res;
1548}
1549
1550static PyObject *WinObj_SetWindowUserState(_self, _args)
1551 WindowObject *_self;
1552 PyObject *_args;
1553{
1554 PyObject *_res = NULL;
1555 Rect r;
1556 if (!PyArg_ParseTuple(_args, "O&",
1557 PyMac_GetRect, &r))
1558 return NULL;
1559 SetWindowUserState(_self->ob_itself,
1560 &r);
1561 Py_INCREF(Py_None);
1562 _res = Py_None;
1563 return _res;
1564}
1565
Jack Jansene79dc762000-06-02 21:35:07 +00001566#ifndef TARGET_API_MAC_CARBON
Jack Jansencdcbd1f1998-10-22 15:08:00 +00001567
Jack Jansene180d991998-04-24 10:28:20 +00001568static PyObject *WinObj_CloseWindow(_self, _args)
1569 WindowObject *_self;
1570 PyObject *_args;
1571{
1572 PyObject *_res = NULL;
1573 if (!PyArg_ParseTuple(_args, ""))
1574 return NULL;
1575 CloseWindow(_self->ob_itself);
1576 Py_INCREF(Py_None);
1577 _res = Py_None;
1578 return _res;
1579}
Jack Jansene79dc762000-06-02 21:35:07 +00001580#endif
Jack Jansene180d991998-04-24 10:28:20 +00001581
1582static PyObject *WinObj_MoveWindow(_self, _args)
1583 WindowObject *_self;
1584 PyObject *_args;
1585{
1586 PyObject *_res = NULL;
1587 short hGlobal;
1588 short vGlobal;
1589 Boolean front;
1590 if (!PyArg_ParseTuple(_args, "hhb",
1591 &hGlobal,
1592 &vGlobal,
1593 &front))
1594 return NULL;
1595 MoveWindow(_self->ob_itself,
1596 hGlobal,
1597 vGlobal,
1598 front);
1599 Py_INCREF(Py_None);
1600 _res = Py_None;
1601 return _res;
1602}
1603
1604static PyObject *WinObj_ShowWindow(_self, _args)
1605 WindowObject *_self;
1606 PyObject *_args;
1607{
1608 PyObject *_res = NULL;
1609 if (!PyArg_ParseTuple(_args, ""))
1610 return NULL;
1611 ShowWindow(_self->ob_itself);
1612 Py_INCREF(Py_None);
1613 _res = Py_None;
1614 return _res;
1615}
1616
Guido van Rossum17448e21995-01-30 11:53:55 +00001617static PyMethodDef WinObj_methods[] = {
Jack Jansena05ac601999-12-12 21:41:51 +00001618 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
1619 "() -> (UInt32 outCount)"},
1620 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
1621 "() -> None"},
1622 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
1623 "() -> (WindowClass outClass)"},
1624 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
1625 "() -> (WindowAttributes outAttributes)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001626
1627#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001628 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1629 "(WCTabHandle newColorTable) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001630#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001631 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
1632 "() -> (RGBColor color)"},
1633 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
1634 "() -> (RGBColor color)"},
1635 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
1636 "(PixPatHandle outPixPat) -> None"},
1637 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
1638 "(PixPatHandle pixPat) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001639 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1640 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001641
1642#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001643 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1644 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001645#endif
1646
1647#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001648 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1649 "(Boolean update) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001650#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00001651 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1652 "(RgnHandle clobberedRgn) -> None"},
1653 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1654 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001655 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1656 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001657 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1658 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001659 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1660 "() -> None"},
1661 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1662 "(WindowPtr behindWindow) -> None"},
1663 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1664 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001665 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1666 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001667 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1668 "(long data) -> None"},
1669 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1670 "() -> (long _rv)"},
1671 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1672 "(PicHandle pic) -> None"},
1673 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1674 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001675 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1676 "() -> (short _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001677 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1678 "() -> (UInt32 outFeatures)"},
1679 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1680 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001681 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1682 "() -> None"},
1683 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1684 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001685 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
1686 "(RgnHandle region) -> None"},
1687 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
1688 "(Rect bounds) -> None"},
1689 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
1690 "(RgnHandle region) -> None"},
1691 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
1692 "(Rect bounds) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001693 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1694 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001695 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1696 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001697 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1698 "() -> (Str255 title)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001699 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
1700 "(FSSpec inFile) -> None"},
1701 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
1702 "() -> (FSSpec outFile)"},
1703 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
1704 "(AliasHandle alias) -> None"},
1705 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
1706 "() -> (AliasHandle alias)"},
1707 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
1708 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
1709 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
1710 "() -> (IconRef outIcon)"},
1711 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
1712 "(IconRef icon) -> None"},
1713 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
1714 "() -> None"},
1715 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
1716 "(Point startPt) -> None"},
1717 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
1718 "() -> (Boolean _rv)"},
1719 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
1720 "(Boolean modified) -> None"},
1721 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
1722 "() -> (Boolean _rv, EventRecord event)"},
1723 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
1724 "(Boolean hilited) -> None"},
1725 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
1726 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
1727 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
1728 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1729 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1730 "(short w, short h, Boolean fUpdate) -> None"},
1731 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1732 "(Point startPt, Rect bBox) -> (long _rv)"},
1733 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1734 "(Point startPt, Rect boundsRect) -> None"},
1735 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1736 "(short partCode, Boolean front) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001737 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1738 "() -> (Boolean _rv)"},
1739 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1740 "() -> (Boolean _rv)"},
1741 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00001742 "(Boolean collapse) -> None"},
1743 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
1744 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
1745 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
1746 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
1747 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
1748 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
1749 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
1750 "(short hGlobal, short vGlobal) -> None"},
1751 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
1752 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
1753 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
1754 "(SInt16 partCode) -> (Point ioIdealSize)"},
1755 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
1756 "() -> (Rect userState)"},
1757 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
1758 "() -> (Rect userState)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001759 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1760 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001761 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001762 "() -> None"},
1763 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1764 "(Boolean showFlag) -> None"},
1765 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1766 "(Point thePt, short partCode) -> (Boolean _rv)"},
1767 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1768 "(Point thePt) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001769
1770#ifndef TARGET_API_MAC_CARBON
Jack Jansen8f0fab71997-08-15 14:38:05 +00001771 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1772 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001773#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00001774 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1775 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00001776 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1777 "() -> None"},
1778 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1779 "() -> (short _rv)"},
1780 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1781 "(short wKind) -> None"},
1782 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1783 "() -> (Boolean _rv)"},
1784 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1785 "() -> (Boolean _rv)"},
1786 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1787 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001788
1789#ifndef TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001790 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1791 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001792#endif
1793
1794#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001795 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1796 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001797#endif
1798
1799#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001800 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1801 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001802#endif
1803
1804#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001805 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1806 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001807#endif
1808
1809#ifndef TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001810 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1811 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001812#endif
Jack Jansen330f5761995-11-14 10:48:54 +00001813 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1814 "() -> (WindowPtr _rv)"},
1815 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1816 "() -> (Rect r)"},
1817 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1818 "() -> (Rect r)"},
1819 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1820 "(Rect r) -> None"},
1821 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1822 "(Rect r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001823
1824#ifndef TARGET_API_MAC_CARBON
Jack Jansene180d991998-04-24 10:28:20 +00001825 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
1826 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001827#endif
Jack Jansene180d991998-04-24 10:28:20 +00001828 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
1829 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1830 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
1831 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001832 {NULL, NULL, 0}
1833};
1834
1835PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1836
1837static PyObject *WinObj_getattr(self, name)
1838 WindowObject *self;
1839 char *name;
1840{
1841 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1842}
1843
1844#define WinObj_setattr NULL
1845
Jack Jansena05ac601999-12-12 21:41:51 +00001846#define WinObj_compare NULL
1847
1848#define WinObj_repr NULL
1849
1850#define WinObj_hash NULL
1851
Guido van Rossum17448e21995-01-30 11:53:55 +00001852PyTypeObject Window_Type = {
1853 PyObject_HEAD_INIT(&PyType_Type)
1854 0, /*ob_size*/
1855 "Window", /*tp_name*/
1856 sizeof(WindowObject), /*tp_basicsize*/
1857 0, /*tp_itemsize*/
1858 /* methods */
1859 (destructor) WinObj_dealloc, /*tp_dealloc*/
1860 0, /*tp_print*/
1861 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1862 (setattrfunc) WinObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00001863 (cmpfunc) WinObj_compare, /*tp_compare*/
1864 (reprfunc) WinObj_repr, /*tp_repr*/
1865 (PyNumberMethods *)0, /* tp_as_number */
1866 (PySequenceMethods *)0, /* tp_as_sequence */
1867 (PyMappingMethods *)0, /* tp_as_mapping */
1868 (hashfunc) WinObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00001869};
1870
1871/* --------------------- End object type Window --------------------- */
1872
1873
Jack Jansen21f96871998-02-20 16:02:09 +00001874static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001875 PyObject *_self;
1876 PyObject *_args;
1877{
1878 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001879 WindowPtr _rv;
1880 short windowID;
1881 WindowPtr behind;
1882 if (!PyArg_ParseTuple(_args, "hO&",
1883 &windowID,
1884 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00001885 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001886 _rv = GetNewCWindow(windowID,
1887 (void *)0,
1888 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00001889 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001890 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00001891 return _res;
1892}
1893
Guido van Rossum17448e21995-01-30 11:53:55 +00001894static PyObject *Win_NewWindow(_self, _args)
1895 PyObject *_self;
1896 PyObject *_args;
1897{
1898 PyObject *_res = NULL;
1899 WindowPtr _rv;
1900 Rect boundsRect;
1901 Str255 title;
1902 Boolean visible;
1903 short theProc;
1904 WindowPtr behind;
1905 Boolean goAwayFlag;
1906 long refCon;
1907 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1908 PyMac_GetRect, &boundsRect,
1909 PyMac_GetStr255, title,
1910 &visible,
1911 &theProc,
1912 WinObj_Convert, &behind,
1913 &goAwayFlag,
1914 &refCon))
1915 return NULL;
1916 _rv = NewWindow((void *)0,
1917 &boundsRect,
1918 title,
1919 visible,
1920 theProc,
1921 behind,
1922 goAwayFlag,
1923 refCon);
1924 _res = Py_BuildValue("O&",
1925 WinObj_New, _rv);
1926 return _res;
1927}
1928
1929static PyObject *Win_GetNewWindow(_self, _args)
1930 PyObject *_self;
1931 PyObject *_args;
1932{
1933 PyObject *_res = NULL;
1934 WindowPtr _rv;
1935 short windowID;
1936 WindowPtr behind;
1937 if (!PyArg_ParseTuple(_args, "hO&",
1938 &windowID,
1939 WinObj_Convert, &behind))
1940 return NULL;
1941 _rv = GetNewWindow(windowID,
1942 (void *)0,
1943 behind);
1944 _res = Py_BuildValue("O&",
1945 WinObj_New, _rv);
1946 return _res;
1947}
1948
Jack Jansen21f96871998-02-20 16:02:09 +00001949static PyObject *Win_NewCWindow(_self, _args)
1950 PyObject *_self;
1951 PyObject *_args;
1952{
1953 PyObject *_res = NULL;
1954 WindowPtr _rv;
1955 Rect boundsRect;
1956 Str255 title;
1957 Boolean visible;
1958 short procID;
1959 WindowPtr behind;
1960 Boolean goAwayFlag;
1961 long refCon;
1962 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1963 PyMac_GetRect, &boundsRect,
1964 PyMac_GetStr255, title,
1965 &visible,
1966 &procID,
1967 WinObj_Convert, &behind,
1968 &goAwayFlag,
1969 &refCon))
1970 return NULL;
1971 _rv = NewCWindow((void *)0,
1972 &boundsRect,
1973 title,
1974 visible,
1975 procID,
1976 behind,
1977 goAwayFlag,
1978 refCon);
1979 _res = Py_BuildValue("O&",
1980 WinObj_New, _rv);
1981 return _res;
1982}
1983
Jack Jansena05ac601999-12-12 21:41:51 +00001984static PyObject *Win_CreateNewWindow(_self, _args)
1985 PyObject *_self;
1986 PyObject *_args;
1987{
1988 PyObject *_res = NULL;
1989 OSStatus _err;
1990 WindowClass windowClass;
1991 WindowAttributes attributes;
1992 Rect bounds;
1993 WindowPtr outWindow;
1994 if (!PyArg_ParseTuple(_args, "llO&",
1995 &windowClass,
1996 &attributes,
1997 PyMac_GetRect, &bounds))
1998 return NULL;
1999 _err = CreateNewWindow(windowClass,
2000 attributes,
2001 &bounds,
2002 &outWindow);
2003 if (_err != noErr) return PyMac_Error(_err);
2004 _res = Py_BuildValue("O&",
2005 WinObj_WhichWindow, outWindow);
2006 return _res;
2007}
2008
2009static PyObject *Win_CreateWindowFromResource(_self, _args)
2010 PyObject *_self;
2011 PyObject *_args;
2012{
2013 PyObject *_res = NULL;
2014 OSStatus _err;
2015 SInt16 resID;
2016 WindowPtr outWindow;
2017 if (!PyArg_ParseTuple(_args, "h",
2018 &resID))
2019 return NULL;
2020 _err = CreateWindowFromResource(resID,
2021 &outWindow);
2022 if (_err != noErr) return PyMac_Error(_err);
2023 _res = Py_BuildValue("O&",
2024 WinObj_WhichWindow, outWindow);
2025 return _res;
2026}
2027
2028static PyObject *Win_ShowFloatingWindows(_self, _args)
2029 PyObject *_self;
2030 PyObject *_args;
2031{
2032 PyObject *_res = NULL;
2033 OSStatus _err;
2034 if (!PyArg_ParseTuple(_args, ""))
2035 return NULL;
2036 _err = ShowFloatingWindows();
2037 if (_err != noErr) return PyMac_Error(_err);
2038 Py_INCREF(Py_None);
2039 _res = Py_None;
2040 return _res;
2041}
2042
2043static PyObject *Win_HideFloatingWindows(_self, _args)
2044 PyObject *_self;
2045 PyObject *_args;
2046{
2047 PyObject *_res = NULL;
2048 OSStatus _err;
2049 if (!PyArg_ParseTuple(_args, ""))
2050 return NULL;
2051 _err = HideFloatingWindows();
2052 if (_err != noErr) return PyMac_Error(_err);
2053 Py_INCREF(Py_None);
2054 _res = Py_None;
2055 return _res;
2056}
2057
2058static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2059 PyObject *_self;
2060 PyObject *_args;
2061{
2062 PyObject *_res = NULL;
2063 Boolean _rv;
2064 if (!PyArg_ParseTuple(_args, ""))
2065 return NULL;
2066 _rv = AreFloatingWindowsVisible();
2067 _res = Py_BuildValue("b",
2068 _rv);
2069 return _res;
2070}
2071
2072static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2073 PyObject *_self;
2074 PyObject *_args;
2075{
2076 PyObject *_res = NULL;
2077 WindowPtr _rv;
2078 if (!PyArg_ParseTuple(_args, ""))
2079 return NULL;
2080 _rv = FrontNonFloatingWindow();
2081 _res = Py_BuildValue("O&",
2082 WinObj_New, _rv);
2083 return _res;
2084}
2085
Jack Jansene79dc762000-06-02 21:35:07 +00002086#ifndef TARGET_API_MAC_CARBON
2087
Jack Jansen21f96871998-02-20 16:02:09 +00002088static PyObject *Win_SetDeskCPat(_self, _args)
2089 PyObject *_self;
2090 PyObject *_args;
2091{
2092 PyObject *_res = NULL;
2093 PixPatHandle deskPixPat;
2094 if (!PyArg_ParseTuple(_args, "O&",
2095 ResObj_Convert, &deskPixPat))
2096 return NULL;
2097 SetDeskCPat(deskPixPat);
2098 Py_INCREF(Py_None);
2099 _res = Py_None;
2100 return _res;
2101}
Jack Jansene79dc762000-06-02 21:35:07 +00002102#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002103
2104static PyObject *Win_CheckUpdate(_self, _args)
2105 PyObject *_self;
2106 PyObject *_args;
2107{
2108 PyObject *_res = NULL;
2109 Boolean _rv;
2110 EventRecord theEvent;
2111 if (!PyArg_ParseTuple(_args, ""))
2112 return NULL;
2113 _rv = CheckUpdate(&theEvent);
2114 _res = Py_BuildValue("bO&",
2115 _rv,
2116 PyMac_BuildEventRecord, &theEvent);
2117 return _res;
2118}
2119
Jack Jansen1c4e6141998-04-21 15:23:55 +00002120static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002121 PyObject *_self;
2122 PyObject *_args;
2123{
2124 PyObject *_res = NULL;
2125 short _rv;
2126 Point thePoint;
Jack Jansena05ac601999-12-12 21:41:51 +00002127 WindowPtr window;
Jack Jansen21f96871998-02-20 16:02:09 +00002128 if (!PyArg_ParseTuple(_args, "O&",
2129 PyMac_GetPoint, &thePoint))
2130 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002131 _rv = MacFindWindow(thePoint,
Jack Jansena05ac601999-12-12 21:41:51 +00002132 &window);
Jack Jansen21f96871998-02-20 16:02:09 +00002133 _res = Py_BuildValue("hO&",
2134 _rv,
Jack Jansena05ac601999-12-12 21:41:51 +00002135 WinObj_WhichWindow, window);
Jack Jansen21f96871998-02-20 16:02:09 +00002136 return _res;
2137}
2138
Guido van Rossum17448e21995-01-30 11:53:55 +00002139static PyObject *Win_FrontWindow(_self, _args)
2140 PyObject *_self;
2141 PyObject *_args;
2142{
2143 PyObject *_res = NULL;
2144 WindowPtr _rv;
2145 if (!PyArg_ParseTuple(_args, ""))
2146 return NULL;
2147 _rv = FrontWindow();
2148 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00002149 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002150 return _res;
2151}
2152
Jack Jansene79dc762000-06-02 21:35:07 +00002153#ifndef TARGET_API_MAC_CARBON
2154
Jack Jansen21f96871998-02-20 16:02:09 +00002155static PyObject *Win_InitWindows(_self, _args)
2156 PyObject *_self;
2157 PyObject *_args;
2158{
2159 PyObject *_res = NULL;
2160 if (!PyArg_ParseTuple(_args, ""))
2161 return NULL;
2162 InitWindows();
2163 Py_INCREF(Py_None);
2164 _res = Py_None;
2165 return _res;
2166}
Jack Jansene79dc762000-06-02 21:35:07 +00002167#endif
2168
2169#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002170
2171static PyObject *Win_GetWMgrPort(_self, _args)
2172 PyObject *_self;
2173 PyObject *_args;
2174{
2175 PyObject *_res = NULL;
2176 GrafPtr wPort;
2177 if (!PyArg_ParseTuple(_args, ""))
2178 return NULL;
2179 GetWMgrPort(&wPort);
2180 _res = Py_BuildValue("O&",
2181 GrafObj_New, wPort);
2182 return _res;
2183}
Jack Jansene79dc762000-06-02 21:35:07 +00002184#endif
2185
2186#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002187
2188static PyObject *Win_GetCWMgrPort(_self, _args)
2189 PyObject *_self;
2190 PyObject *_args;
2191{
2192 PyObject *_res = NULL;
2193 CGrafPtr wMgrCPort;
2194 if (!PyArg_ParseTuple(_args, ""))
2195 return NULL;
2196 GetCWMgrPort(&wMgrCPort);
2197 _res = Py_BuildValue("O&",
2198 GrafObj_New, wMgrCPort);
2199 return _res;
2200}
Jack Jansene79dc762000-06-02 21:35:07 +00002201#endif
2202
Jack Jansen8d929ae2000-06-21 22:07:06 +00002203#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002204
Jack Jansena05ac601999-12-12 21:41:51 +00002205static PyObject *Win_IsValidWindowPtr(_self, _args)
2206 PyObject *_self;
2207 PyObject *_args;
2208{
2209 PyObject *_res = NULL;
2210 Boolean _rv;
2211 GrafPtr grafPort;
2212 if (!PyArg_ParseTuple(_args, "O&",
2213 GrafObj_Convert, &grafPort))
2214 return NULL;
2215 _rv = IsValidWindowPtr(grafPort);
2216 _res = Py_BuildValue("b",
2217 _rv);
2218 return _res;
2219}
Jack Jansene79dc762000-06-02 21:35:07 +00002220#endif
2221
2222#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002223
2224static PyObject *Win_InitFloatingWindows(_self, _args)
2225 PyObject *_self;
2226 PyObject *_args;
2227{
2228 PyObject *_res = NULL;
2229 OSStatus _err;
2230 if (!PyArg_ParseTuple(_args, ""))
2231 return NULL;
2232 _err = InitFloatingWindows();
2233 if (_err != noErr) return PyMac_Error(_err);
2234 Py_INCREF(Py_None);
2235 _res = Py_None;
2236 return _res;
2237}
Jack Jansene79dc762000-06-02 21:35:07 +00002238#endif
2239
2240#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002241
Guido van Rossum17448e21995-01-30 11:53:55 +00002242static PyObject *Win_InvalRect(_self, _args)
2243 PyObject *_self;
2244 PyObject *_args;
2245{
2246 PyObject *_res = NULL;
2247 Rect badRect;
2248 if (!PyArg_ParseTuple(_args, "O&",
2249 PyMac_GetRect, &badRect))
2250 return NULL;
2251 InvalRect(&badRect);
2252 Py_INCREF(Py_None);
2253 _res = Py_None;
2254 return _res;
2255}
Jack Jansene79dc762000-06-02 21:35:07 +00002256#endif
2257
2258#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002259
Jack Jansenb7abb181995-11-15 15:18:47 +00002260static PyObject *Win_InvalRgn(_self, _args)
2261 PyObject *_self;
2262 PyObject *_args;
2263{
2264 PyObject *_res = NULL;
2265 RgnHandle badRgn;
2266 if (!PyArg_ParseTuple(_args, "O&",
2267 ResObj_Convert, &badRgn))
2268 return NULL;
2269 InvalRgn(badRgn);
2270 Py_INCREF(Py_None);
2271 _res = Py_None;
2272 return _res;
2273}
Jack Jansene79dc762000-06-02 21:35:07 +00002274#endif
2275
2276#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002277
Guido van Rossum17448e21995-01-30 11:53:55 +00002278static PyObject *Win_ValidRect(_self, _args)
2279 PyObject *_self;
2280 PyObject *_args;
2281{
2282 PyObject *_res = NULL;
2283 Rect goodRect;
2284 if (!PyArg_ParseTuple(_args, "O&",
2285 PyMac_GetRect, &goodRect))
2286 return NULL;
2287 ValidRect(&goodRect);
2288 Py_INCREF(Py_None);
2289 _res = Py_None;
2290 return _res;
2291}
Jack Jansene79dc762000-06-02 21:35:07 +00002292#endif
2293
2294#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002295
Jack Jansenb7abb181995-11-15 15:18:47 +00002296static PyObject *Win_ValidRgn(_self, _args)
2297 PyObject *_self;
2298 PyObject *_args;
2299{
2300 PyObject *_res = NULL;
2301 RgnHandle goodRgn;
2302 if (!PyArg_ParseTuple(_args, "O&",
2303 ResObj_Convert, &goodRgn))
2304 return NULL;
2305 ValidRgn(goodRgn);
2306 Py_INCREF(Py_None);
2307 _res = Py_None;
2308 return _res;
2309}
Jack Jansene79dc762000-06-02 21:35:07 +00002310#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00002311
Jack Jansen21f96871998-02-20 16:02:09 +00002312static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002313 PyObject *_self;
2314 PyObject *_args;
2315{
2316 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00002317 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +00002318 Boolean collapse;
Jack Jansen21f96871998-02-20 16:02:09 +00002319 if (!PyArg_ParseTuple(_args, "b",
Jack Jansena05ac601999-12-12 21:41:51 +00002320 &collapse))
Guido van Rossum17448e21995-01-30 11:53:55 +00002321 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002322 _err = CollapseAllWindows(collapse);
Jack Jansene4349e81999-03-04 22:53:24 +00002323 if (_err != noErr) return PyMac_Error(_err);
2324 Py_INCREF(Py_None);
2325 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00002326 return _res;
2327}
2328
2329static PyObject *Win_PinRect(_self, _args)
2330 PyObject *_self;
2331 PyObject *_args;
2332{
2333 PyObject *_res = NULL;
2334 long _rv;
2335 Rect theRect;
2336 Point thePt;
2337 if (!PyArg_ParseTuple(_args, "O&O&",
2338 PyMac_GetRect, &theRect,
2339 PyMac_GetPoint, &thePt))
2340 return NULL;
2341 _rv = PinRect(&theRect,
2342 thePt);
2343 _res = Py_BuildValue("l",
2344 _rv);
2345 return _res;
2346}
2347
Jack Jansen21f96871998-02-20 16:02:09 +00002348static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002349 PyObject *_self;
2350 PyObject *_args;
2351{
2352 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002353 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00002354 if (!PyArg_ParseTuple(_args, ""))
2355 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002356 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00002357 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002358 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002359 return _res;
2360}
2361
Jack Jansend4c26461995-08-17 14:35:56 +00002362static PyObject *Win_WhichWindow(_self, _args)
2363 PyObject *_self;
2364 PyObject *_args;
2365{
2366 PyObject *_res = NULL;
2367
2368 long ptr;
2369
2370 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2371 return NULL;
2372 return WinObj_WhichWindow((WindowPtr)ptr);
2373
2374}
2375
Jack Jansene180d991998-04-24 10:28:20 +00002376static PyObject *Win_FindWindow(_self, _args)
2377 PyObject *_self;
2378 PyObject *_args;
2379{
2380 PyObject *_res = NULL;
2381 short _rv;
2382 Point thePoint;
2383 WindowPtr theWindow;
2384 if (!PyArg_ParseTuple(_args, "O&",
2385 PyMac_GetPoint, &thePoint))
2386 return NULL;
2387 _rv = FindWindow(thePoint,
2388 &theWindow);
2389 _res = Py_BuildValue("hO&",
2390 _rv,
2391 WinObj_WhichWindow, theWindow);
2392 return _res;
2393}
2394
Guido van Rossum17448e21995-01-30 11:53:55 +00002395static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00002396 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2397 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002398 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2399 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2400 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2401 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002402 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2403 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002404 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
2405 "(WindowClass windowClass, WindowAttributes attributes, Rect bounds) -> (WindowPtr outWindow)"},
2406 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2407 "(SInt16 resID) -> (WindowPtr outWindow)"},
2408 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2409 "() -> None"},
2410 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2411 "() -> None"},
2412 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2413 "() -> (Boolean _rv)"},
2414 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2415 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002416
2417#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002418 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2419 "(PixPatHandle deskPixPat) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002420#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002421 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2422 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002423 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002424 "(Point thePoint) -> (short _rv, WindowPtr window)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002425 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2426 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002427
2428#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002429 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2430 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002431#endif
2432
2433#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002434 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2435 "() -> (GrafPtr wPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002436#endif
2437
2438#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002439 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2440 "() -> (CGrafPtr wMgrCPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002441#endif
2442
Jack Jansen8d929ae2000-06-21 22:07:06 +00002443#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002444 {"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1,
2445 "(GrafPtr grafPort) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002446#endif
2447
2448#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002449 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2450 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002451#endif
2452
2453#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002454 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2455 "(Rect badRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002456#endif
2457
2458#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002459 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2460 "(RgnHandle badRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002461#endif
2462
2463#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002464 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2465 "(Rect goodRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002466#endif
2467
2468#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002469 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2470 "(RgnHandle goodRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002471#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002472 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002473 "(Boolean collapse) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002474 {"PinRect", (PyCFunction)Win_PinRect, 1,
2475 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002476 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2477 "() -> (RgnHandle _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00002478 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2479 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00002480 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2481 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002482 {NULL, NULL, 0}
2483};
2484
2485
2486
2487/* Return the object corresponding to the window, or NULL */
2488
2489PyObject *
2490WinObj_WhichWindow(w)
2491 WindowPtr w;
2492{
2493 PyObject *it;
2494
2495 /* XXX What if we find a stdwin window or a window belonging
2496 to some other package? */
Guido van Rossum97842951995-02-19 15:59:49 +00002497 if (w == NULL)
2498 it = NULL;
2499 else
2500 it = (PyObject *) GetWRefCon(w);
Guido van Rossum17448e21995-01-30 11:53:55 +00002501 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
2502 it = Py_None;
2503 Py_INCREF(it);
2504 return it;
2505}
2506
2507
2508void initWin()
2509{
2510 PyObject *m;
2511 PyObject *d;
2512
2513
2514
2515
2516 m = Py_InitModule("Win", Win_methods);
2517 d = PyModule_GetDict(m);
2518 Win_Error = PyMac_GetOSErrException();
2519 if (Win_Error == NULL ||
2520 PyDict_SetItemString(d, "Error", Win_Error) != 0)
2521 Py_FatalError("can't initialize Win.Error");
Jack Jansena755e681997-09-20 17:40:22 +00002522 Window_Type.ob_type = &PyType_Type;
2523 Py_INCREF(&Window_Type);
2524 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2525 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002526}
2527
2528/* ========================= End module Win ========================= */
2529