blob: c95e06b48f52a58cf6c9381251e4d0abb61b0ec0 [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>
Jack Jansen0aee0e62000-08-25 22:17:51 +000012/* Function to dispose a window, with a "normal" calling sequence */
13static void
14PyMac_AutoDisposeWindow(WindowPtr w)
15{
16 DisposeWindow(w);
17}
Guido van Rossum17448e21995-01-30 11:53:55 +000018
Guido van Rossum17448e21995-01-30 11:53:55 +000019static PyObject *Win_Error;
20
21/* ----------------------- Object type Window ----------------------- */
22
23PyTypeObject Window_Type;
24
25#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26
27typedef struct WindowObject {
28 PyObject_HEAD
29 WindowPtr ob_itself;
Jack Jansen0aee0e62000-08-25 22:17:51 +000030 void (*ob_freeit)(WindowPtr ptr);
Guido van Rossum17448e21995-01-30 11:53:55 +000031} WindowObject;
32
33PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000034 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000035{
36 WindowObject *it;
37 if (itself == NULL) return PyMac_Error(resNotFound);
38 it = PyObject_NEW(WindowObject, &Window_Type);
39 if (it == NULL) return NULL;
40 it->ob_itself = itself;
41 SetWRefCon(itself, (long)it);
Jack Jansen0aee0e62000-08-25 22:17:51 +000042 it->ob_freeit = PyMac_AutoDisposeWindow;
Guido van Rossum17448e21995-01-30 11:53:55 +000043 return (PyObject *)it;
44}
45WinObj_Convert(v, p_itself)
46 PyObject *v;
47 WindowPtr *p_itself;
48{
Jack Jansen74a1e632000-07-14 22:37:27 +000049#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +000050 if (DlgObj_Check(v)) {
51 *p_itself = ((WindowObject *)v)->ob_itself;
52 return 1;
53 }
Jack Jansene79dc762000-06-02 21:35:07 +000054#endif
Guido van Rossum17448e21995-01-30 11:53:55 +000055
56 if (v == Py_None) { *p_itself = NULL; return 1; }
57 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
58
59 if (!WinObj_Check(v))
60 {
61 PyErr_SetString(PyExc_TypeError, "Window required");
62 return 0;
63 }
64 *p_itself = ((WindowObject *)v)->ob_itself;
65 return 1;
66}
67
68static void WinObj_dealloc(self)
69 WindowObject *self;
70{
Jack Jansen0aee0e62000-08-25 22:17:51 +000071 if (self->ob_itself) SetWRefCon(self->ob_itself, 0);
72 if (self->ob_freeit && self->ob_itself)
73 {
74 self->ob_freeit(self->ob_itself);
75 }
76 self->ob_itself = NULL;
Guido van Rossum17448e21995-01-30 11:53:55 +000077 PyMem_DEL(self);
78}
79
Jack Jansena05ac601999-12-12 21:41:51 +000080static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
81 WindowObject *_self;
82 PyObject *_args;
83{
84 PyObject *_res = NULL;
85 OSStatus _err;
86 UInt32 outCount;
87 if (!PyArg_ParseTuple(_args, ""))
88 return NULL;
89 _err = GetWindowOwnerCount(_self->ob_itself,
90 &outCount);
91 if (_err != noErr) return PyMac_Error(_err);
92 _res = Py_BuildValue("l",
93 outCount);
94 return _res;
95}
96
97static PyObject *WinObj_CloneWindow(_self, _args)
98 WindowObject *_self;
99 PyObject *_args;
100{
101 PyObject *_res = NULL;
102 OSStatus _err;
103 if (!PyArg_ParseTuple(_args, ""))
104 return NULL;
105 _err = CloneWindow(_self->ob_itself);
106 if (_err != noErr) return PyMac_Error(_err);
107 Py_INCREF(Py_None);
108 _res = Py_None;
109 return _res;
110}
111
112static PyObject *WinObj_GetWindowClass(_self, _args)
113 WindowObject *_self;
114 PyObject *_args;
115{
116 PyObject *_res = NULL;
117 OSStatus _err;
118 WindowClass outClass;
119 if (!PyArg_ParseTuple(_args, ""))
120 return NULL;
121 _err = GetWindowClass(_self->ob_itself,
122 &outClass);
123 if (_err != noErr) return PyMac_Error(_err);
124 _res = Py_BuildValue("l",
125 outClass);
126 return _res;
127}
128
129static PyObject *WinObj_GetWindowAttributes(_self, _args)
130 WindowObject *_self;
131 PyObject *_args;
132{
133 PyObject *_res = NULL;
134 OSStatus _err;
135 WindowAttributes outAttributes;
136 if (!PyArg_ParseTuple(_args, ""))
137 return NULL;
138 _err = GetWindowAttributes(_self->ob_itself,
139 &outAttributes);
140 if (_err != noErr) return PyMac_Error(_err);
141 _res = Py_BuildValue("l",
142 outAttributes);
143 return _res;
144}
145
Jack Jansen74a1e632000-07-14 22:37:27 +0000146#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000147
Jack Jansen21f96871998-02-20 16:02:09 +0000148static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000149 WindowObject *_self;
150 PyObject *_args;
151{
152 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000153 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000154 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000155 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000156 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000157 SetWinColor(_self->ob_itself,
158 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000159 Py_INCREF(Py_None);
160 _res = Py_None;
161 return _res;
162}
Jack Jansene79dc762000-06-02 21:35:07 +0000163#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000164
Jack Jansena05ac601999-12-12 21:41:51 +0000165static PyObject *WinObj_SetWindowContentColor(_self, _args)
166 WindowObject *_self;
167 PyObject *_args;
168{
169 PyObject *_res = NULL;
170 OSStatus _err;
171 RGBColor color;
172 if (!PyArg_ParseTuple(_args, ""))
173 return NULL;
174 _err = SetWindowContentColor(_self->ob_itself,
175 &color);
176 if (_err != noErr) return PyMac_Error(_err);
177 _res = Py_BuildValue("O&",
178 QdRGB_New, &color);
179 return _res;
180}
181
182static PyObject *WinObj_GetWindowContentColor(_self, _args)
183 WindowObject *_self;
184 PyObject *_args;
185{
186 PyObject *_res = NULL;
187 OSStatus _err;
188 RGBColor color;
189 if (!PyArg_ParseTuple(_args, ""))
190 return NULL;
191 _err = GetWindowContentColor(_self->ob_itself,
192 &color);
193 if (_err != noErr) return PyMac_Error(_err);
194 _res = Py_BuildValue("O&",
195 QdRGB_New, &color);
196 return _res;
197}
198
199static PyObject *WinObj_GetWindowContentPattern(_self, _args)
200 WindowObject *_self;
201 PyObject *_args;
202{
203 PyObject *_res = NULL;
204 OSStatus _err;
205 PixPatHandle outPixPat;
206 if (!PyArg_ParseTuple(_args, "O&",
207 ResObj_Convert, &outPixPat))
208 return NULL;
209 _err = GetWindowContentPattern(_self->ob_itself,
210 outPixPat);
211 if (_err != noErr) return PyMac_Error(_err);
212 Py_INCREF(Py_None);
213 _res = Py_None;
214 return _res;
215}
216
217static PyObject *WinObj_SetWindowContentPattern(_self, _args)
218 WindowObject *_self;
219 PyObject *_args;
220{
221 PyObject *_res = NULL;
222 OSStatus _err;
223 PixPatHandle pixPat;
224 if (!PyArg_ParseTuple(_args, "O&",
225 ResObj_Convert, &pixPat))
226 return NULL;
227 _err = SetWindowContentPattern(_self->ob_itself,
228 pixPat);
229 if (_err != noErr) return PyMac_Error(_err);
230 Py_INCREF(Py_None);
231 _res = Py_None;
232 return _res;
233}
234
Guido van Rossum17448e21995-01-30 11:53:55 +0000235static PyObject *WinObj_ClipAbove(_self, _args)
236 WindowObject *_self;
237 PyObject *_args;
238{
239 PyObject *_res = NULL;
240 if (!PyArg_ParseTuple(_args, ""))
241 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000242 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000243 Py_INCREF(Py_None);
244 _res = Py_None;
245 return _res;
246}
247
Jack Jansen74a1e632000-07-14 22:37:27 +0000248#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000249
Guido van Rossum17448e21995-01-30 11:53:55 +0000250static PyObject *WinObj_SaveOld(_self, _args)
251 WindowObject *_self;
252 PyObject *_args;
253{
254 PyObject *_res = NULL;
255 if (!PyArg_ParseTuple(_args, ""))
256 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000257 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000258 Py_INCREF(Py_None);
259 _res = Py_None;
260 return _res;
261}
Jack Jansene79dc762000-06-02 21:35:07 +0000262#endif
263
Jack Jansen74a1e632000-07-14 22:37:27 +0000264#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000265
266static PyObject *WinObj_DrawNew(_self, _args)
267 WindowObject *_self;
268 PyObject *_args;
269{
270 PyObject *_res = NULL;
271 Boolean update;
272 if (!PyArg_ParseTuple(_args, "b",
273 &update))
274 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000275 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000276 update);
277 Py_INCREF(Py_None);
278 _res = Py_None;
279 return _res;
280}
Jack Jansene79dc762000-06-02 21:35:07 +0000281#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000282
Jack Jansenb7abb181995-11-15 15:18:47 +0000283static PyObject *WinObj_PaintOne(_self, _args)
284 WindowObject *_self;
285 PyObject *_args;
286{
287 PyObject *_res = NULL;
288 RgnHandle clobberedRgn;
289 if (!PyArg_ParseTuple(_args, "O&",
290 ResObj_Convert, &clobberedRgn))
291 return NULL;
292 PaintOne(_self->ob_itself,
293 clobberedRgn);
294 Py_INCREF(Py_None);
295 _res = Py_None;
296 return _res;
297}
298
299static PyObject *WinObj_PaintBehind(_self, _args)
300 WindowObject *_self;
301 PyObject *_args;
302{
303 PyObject *_res = NULL;
304 RgnHandle clobberedRgn;
305 if (!PyArg_ParseTuple(_args, "O&",
306 ResObj_Convert, &clobberedRgn))
307 return NULL;
308 PaintBehind(_self->ob_itself,
309 clobberedRgn);
310 Py_INCREF(Py_None);
311 _res = Py_None;
312 return _res;
313}
314
Guido van Rossum17448e21995-01-30 11:53:55 +0000315static PyObject *WinObj_CalcVis(_self, _args)
316 WindowObject *_self;
317 PyObject *_args;
318{
319 PyObject *_res = NULL;
320 if (!PyArg_ParseTuple(_args, ""))
321 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000322 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000323 Py_INCREF(Py_None);
324 _res = Py_None;
325 return _res;
326}
327
Jack Jansenb7abb181995-11-15 15:18:47 +0000328static PyObject *WinObj_CalcVisBehind(_self, _args)
329 WindowObject *_self;
330 PyObject *_args;
331{
332 PyObject *_res = NULL;
333 RgnHandle clobberedRgn;
334 if (!PyArg_ParseTuple(_args, "O&",
335 ResObj_Convert, &clobberedRgn))
336 return NULL;
337 CalcVisBehind(_self->ob_itself,
338 clobberedRgn);
339 Py_INCREF(Py_None);
340 _res = Py_None;
341 return _res;
342}
343
Jack Jansen21f96871998-02-20 16:02:09 +0000344static PyObject *WinObj_BringToFront(_self, _args)
345 WindowObject *_self;
346 PyObject *_args;
347{
348 PyObject *_res = NULL;
349 if (!PyArg_ParseTuple(_args, ""))
350 return NULL;
351 BringToFront(_self->ob_itself);
352 Py_INCREF(Py_None);
353 _res = Py_None;
354 return _res;
355}
356
357static PyObject *WinObj_SendBehind(_self, _args)
358 WindowObject *_self;
359 PyObject *_args;
360{
361 PyObject *_res = NULL;
362 WindowPtr behindWindow;
363 if (!PyArg_ParseTuple(_args, "O&",
364 WinObj_Convert, &behindWindow))
365 return NULL;
366 SendBehind(_self->ob_itself,
367 behindWindow);
368 Py_INCREF(Py_None);
369 _res = Py_None;
370 return _res;
371}
372
373static PyObject *WinObj_SelectWindow(_self, _args)
374 WindowObject *_self;
375 PyObject *_args;
376{
377 PyObject *_res = NULL;
378 if (!PyArg_ParseTuple(_args, ""))
379 return NULL;
380 SelectWindow(_self->ob_itself);
381 Py_INCREF(Py_None);
382 _res = Py_None;
383 return _res;
384}
385
Jack Jansen1c4e6141998-04-21 15:23:55 +0000386static PyObject *WinObj_HiliteWindow(_self, _args)
387 WindowObject *_self;
388 PyObject *_args;
389{
390 PyObject *_res = NULL;
391 Boolean fHilite;
392 if (!PyArg_ParseTuple(_args, "b",
393 &fHilite))
394 return NULL;
395 HiliteWindow(_self->ob_itself,
396 fHilite);
397 Py_INCREF(Py_None);
398 _res = Py_None;
399 return _res;
400}
401
Jack Jansen21f96871998-02-20 16:02:09 +0000402static PyObject *WinObj_SetWRefCon(_self, _args)
403 WindowObject *_self;
404 PyObject *_args;
405{
406 PyObject *_res = NULL;
407 long data;
408 if (!PyArg_ParseTuple(_args, "l",
409 &data))
410 return NULL;
411 SetWRefCon(_self->ob_itself,
412 data);
413 Py_INCREF(Py_None);
414 _res = Py_None;
415 return _res;
416}
417
418static PyObject *WinObj_GetWRefCon(_self, _args)
419 WindowObject *_self;
420 PyObject *_args;
421{
422 PyObject *_res = NULL;
423 long _rv;
424 if (!PyArg_ParseTuple(_args, ""))
425 return NULL;
426 _rv = GetWRefCon(_self->ob_itself);
427 _res = Py_BuildValue("l",
428 _rv);
429 return _res;
430}
431
432static PyObject *WinObj_SetWindowPic(_self, _args)
433 WindowObject *_self;
434 PyObject *_args;
435{
436 PyObject *_res = NULL;
437 PicHandle pic;
438 if (!PyArg_ParseTuple(_args, "O&",
439 ResObj_Convert, &pic))
440 return NULL;
441 SetWindowPic(_self->ob_itself,
442 pic);
443 Py_INCREF(Py_None);
444 _res = Py_None;
445 return _res;
446}
447
448static PyObject *WinObj_GetWindowPic(_self, _args)
449 WindowObject *_self;
450 PyObject *_args;
451{
452 PyObject *_res = NULL;
453 PicHandle _rv;
454 if (!PyArg_ParseTuple(_args, ""))
455 return NULL;
456 _rv = GetWindowPic(_self->ob_itself);
457 _res = Py_BuildValue("O&",
458 ResObj_New, _rv);
459 return _res;
460}
461
462static PyObject *WinObj_GetWVariant(_self, _args)
463 WindowObject *_self;
464 PyObject *_args;
465{
466 PyObject *_res = NULL;
467 short _rv;
468 if (!PyArg_ParseTuple(_args, ""))
469 return NULL;
470 _rv = GetWVariant(_self->ob_itself);
471 _res = Py_BuildValue("h",
472 _rv);
473 return _res;
474}
475
Jack Jansena05ac601999-12-12 21:41:51 +0000476static PyObject *WinObj_GetWindowFeatures(_self, _args)
477 WindowObject *_self;
478 PyObject *_args;
479{
480 PyObject *_res = NULL;
481 OSStatus _err;
482 UInt32 outFeatures;
483 if (!PyArg_ParseTuple(_args, ""))
484 return NULL;
485 _err = GetWindowFeatures(_self->ob_itself,
486 &outFeatures);
487 if (_err != noErr) return PyMac_Error(_err);
488 _res = Py_BuildValue("l",
489 outFeatures);
490 return _res;
491}
492
493static PyObject *WinObj_GetWindowRegion(_self, _args)
494 WindowObject *_self;
495 PyObject *_args;
496{
497 PyObject *_res = NULL;
498 OSStatus _err;
499 WindowRegionCode inRegionCode;
500 RgnHandle ioWinRgn;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000501 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +0000502 &inRegionCode,
503 ResObj_Convert, &ioWinRgn))
504 return NULL;
505 _err = GetWindowRegion(_self->ob_itself,
506 inRegionCode,
507 ioWinRgn);
508 if (_err != noErr) return PyMac_Error(_err);
509 Py_INCREF(Py_None);
510 _res = Py_None;
511 return _res;
512}
513
Jack Jansen21f96871998-02-20 16:02:09 +0000514static PyObject *WinObj_BeginUpdate(_self, _args)
515 WindowObject *_self;
516 PyObject *_args;
517{
518 PyObject *_res = NULL;
519 if (!PyArg_ParseTuple(_args, ""))
520 return NULL;
521 BeginUpdate(_self->ob_itself);
522 Py_INCREF(Py_None);
523 _res = Py_None;
524 return _res;
525}
526
527static PyObject *WinObj_EndUpdate(_self, _args)
528 WindowObject *_self;
529 PyObject *_args;
530{
531 PyObject *_res = NULL;
532 if (!PyArg_ParseTuple(_args, ""))
533 return NULL;
534 EndUpdate(_self->ob_itself);
535 Py_INCREF(Py_None);
536 _res = Py_None;
537 return _res;
538}
539
Jack Jansena05ac601999-12-12 21:41:51 +0000540static PyObject *WinObj_InvalWindowRgn(_self, _args)
541 WindowObject *_self;
542 PyObject *_args;
543{
544 PyObject *_res = NULL;
545 OSStatus _err;
546 RgnHandle region;
547 if (!PyArg_ParseTuple(_args, "O&",
548 ResObj_Convert, &region))
549 return NULL;
550 _err = InvalWindowRgn(_self->ob_itself,
551 region);
552 if (_err != noErr) return PyMac_Error(_err);
553 Py_INCREF(Py_None);
554 _res = Py_None;
555 return _res;
556}
557
558static PyObject *WinObj_InvalWindowRect(_self, _args)
559 WindowObject *_self;
560 PyObject *_args;
561{
562 PyObject *_res = NULL;
563 OSStatus _err;
564 Rect bounds;
565 if (!PyArg_ParseTuple(_args, "O&",
566 PyMac_GetRect, &bounds))
567 return NULL;
568 _err = InvalWindowRect(_self->ob_itself,
569 &bounds);
570 if (_err != noErr) return PyMac_Error(_err);
571 Py_INCREF(Py_None);
572 _res = Py_None;
573 return _res;
574}
575
576static PyObject *WinObj_ValidWindowRgn(_self, _args)
577 WindowObject *_self;
578 PyObject *_args;
579{
580 PyObject *_res = NULL;
581 OSStatus _err;
582 RgnHandle region;
583 if (!PyArg_ParseTuple(_args, "O&",
584 ResObj_Convert, &region))
585 return NULL;
586 _err = ValidWindowRgn(_self->ob_itself,
587 region);
588 if (_err != noErr) return PyMac_Error(_err);
589 Py_INCREF(Py_None);
590 _res = Py_None;
591 return _res;
592}
593
594static PyObject *WinObj_ValidWindowRect(_self, _args)
595 WindowObject *_self;
596 PyObject *_args;
597{
598 PyObject *_res = NULL;
599 OSStatus _err;
600 Rect bounds;
601 if (!PyArg_ParseTuple(_args, "O&",
602 PyMac_GetRect, &bounds))
603 return NULL;
604 _err = ValidWindowRect(_self->ob_itself,
605 &bounds);
606 if (_err != noErr) return PyMac_Error(_err);
607 Py_INCREF(Py_None);
608 _res = Py_None;
609 return _res;
610}
611
Jack Jansen21f96871998-02-20 16:02:09 +0000612static PyObject *WinObj_DrawGrowIcon(_self, _args)
613 WindowObject *_self;
614 PyObject *_args;
615{
616 PyObject *_res = NULL;
617 if (!PyArg_ParseTuple(_args, ""))
618 return NULL;
619 DrawGrowIcon(_self->ob_itself);
620 Py_INCREF(Py_None);
621 _res = Py_None;
622 return _res;
623}
624
Jack Jansen21f96871998-02-20 16:02:09 +0000625static PyObject *WinObj_SetWTitle(_self, _args)
626 WindowObject *_self;
627 PyObject *_args;
628{
629 PyObject *_res = NULL;
630 Str255 title;
631 if (!PyArg_ParseTuple(_args, "O&",
632 PyMac_GetStr255, title))
633 return NULL;
634 SetWTitle(_self->ob_itself,
635 title);
636 Py_INCREF(Py_None);
637 _res = Py_None;
638 return _res;
639}
640
641static PyObject *WinObj_GetWTitle(_self, _args)
642 WindowObject *_self;
643 PyObject *_args;
644{
645 PyObject *_res = NULL;
646 Str255 title;
647 if (!PyArg_ParseTuple(_args, ""))
648 return NULL;
649 GetWTitle(_self->ob_itself,
650 title);
651 _res = Py_BuildValue("O&",
652 PyMac_BuildStr255, title);
653 return _res;
654}
655
Jack Jansena05ac601999-12-12 21:41:51 +0000656static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000657 WindowObject *_self;
658 PyObject *_args;
659{
660 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000661 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +0000662 FSSpec inFile;
663 if (!PyArg_ParseTuple(_args, "O&",
664 PyMac_GetFSSpec, &inFile))
Jack Jansen21f96871998-02-20 16:02:09 +0000665 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +0000666 _err = SetWindowProxyFSSpec(_self->ob_itself,
667 &inFile);
668 if (_err != noErr) return PyMac_Error(_err);
669 Py_INCREF(Py_None);
670 _res = Py_None;
671 return _res;
672}
673
674static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
675 WindowObject *_self;
676 PyObject *_args;
677{
678 PyObject *_res = NULL;
679 OSStatus _err;
680 FSSpec outFile;
681 if (!PyArg_ParseTuple(_args, ""))
682 return NULL;
683 _err = GetWindowProxyFSSpec(_self->ob_itself,
684 &outFile);
685 if (_err != noErr) return PyMac_Error(_err);
686 _res = Py_BuildValue("O&",
Jack Jansene79dc762000-06-02 21:35:07 +0000687 PyMac_BuildFSSpec, outFile);
Jack Jansena05ac601999-12-12 21:41:51 +0000688 return _res;
689}
690
691static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
692 WindowObject *_self;
693 PyObject *_args;
694{
695 PyObject *_res = NULL;
696 OSStatus _err;
697 AliasHandle alias;
698 if (!PyArg_ParseTuple(_args, "O&",
699 ResObj_Convert, &alias))
700 return NULL;
701 _err = SetWindowProxyAlias(_self->ob_itself,
702 alias);
703 if (_err != noErr) return PyMac_Error(_err);
704 Py_INCREF(Py_None);
705 _res = Py_None;
706 return _res;
707}
708
709static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
710 WindowObject *_self;
711 PyObject *_args;
712{
713 PyObject *_res = NULL;
714 OSStatus _err;
715 AliasHandle alias;
716 if (!PyArg_ParseTuple(_args, ""))
717 return NULL;
718 _err = GetWindowProxyAlias(_self->ob_itself,
719 &alias);
720 if (_err != noErr) return PyMac_Error(_err);
721 _res = Py_BuildValue("O&",
722 ResObj_New, alias);
723 return _res;
724}
725
726static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
727 WindowObject *_self;
728 PyObject *_args;
729{
730 PyObject *_res = NULL;
731 OSStatus _err;
732 OSType fileCreator;
733 OSType fileType;
734 SInt16 vRefNum;
735 if (!PyArg_ParseTuple(_args, "O&O&h",
736 PyMac_GetOSType, &fileCreator,
737 PyMac_GetOSType, &fileType,
738 &vRefNum))
739 return NULL;
740 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
741 fileCreator,
742 fileType,
743 vRefNum);
744 if (_err != noErr) return PyMac_Error(_err);
745 Py_INCREF(Py_None);
746 _res = Py_None;
747 return _res;
748}
749
750static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
751 WindowObject *_self;
752 PyObject *_args;
753{
754 PyObject *_res = NULL;
755 OSStatus _err;
756 IconRef outIcon;
757 if (!PyArg_ParseTuple(_args, ""))
758 return NULL;
759 _err = GetWindowProxyIcon(_self->ob_itself,
760 &outIcon);
761 if (_err != noErr) return PyMac_Error(_err);
762 _res = Py_BuildValue("O&",
763 ResObj_New, outIcon);
764 return _res;
765}
766
767static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
768 WindowObject *_self;
769 PyObject *_args;
770{
771 PyObject *_res = NULL;
772 OSStatus _err;
773 IconRef icon;
774 if (!PyArg_ParseTuple(_args, "O&",
775 ResObj_Convert, &icon))
776 return NULL;
777 _err = SetWindowProxyIcon(_self->ob_itself,
778 icon);
779 if (_err != noErr) return PyMac_Error(_err);
780 Py_INCREF(Py_None);
781 _res = Py_None;
782 return _res;
783}
784
785static PyObject *WinObj_RemoveWindowProxy(_self, _args)
786 WindowObject *_self;
787 PyObject *_args;
788{
789 PyObject *_res = NULL;
790 OSStatus _err;
791 if (!PyArg_ParseTuple(_args, ""))
792 return NULL;
793 _err = RemoveWindowProxy(_self->ob_itself);
794 if (_err != noErr) return PyMac_Error(_err);
795 Py_INCREF(Py_None);
796 _res = Py_None;
797 return _res;
798}
799
800static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
801 WindowObject *_self;
802 PyObject *_args;
803{
804 PyObject *_res = NULL;
805 OSStatus _err;
806 Point startPt;
807 if (!PyArg_ParseTuple(_args, "O&",
808 PyMac_GetPoint, &startPt))
809 return NULL;
810 _err = TrackWindowProxyDrag(_self->ob_itself,
811 startPt);
812 if (_err != noErr) return PyMac_Error(_err);
813 Py_INCREF(Py_None);
814 _res = Py_None;
815 return _res;
816}
817
818static PyObject *WinObj_IsWindowModified(_self, _args)
819 WindowObject *_self;
820 PyObject *_args;
821{
822 PyObject *_res = NULL;
823 Boolean _rv;
824 if (!PyArg_ParseTuple(_args, ""))
825 return NULL;
826 _rv = IsWindowModified(_self->ob_itself);
827 _res = Py_BuildValue("b",
828 _rv);
829 return _res;
830}
831
832static PyObject *WinObj_SetWindowModified(_self, _args)
833 WindowObject *_self;
834 PyObject *_args;
835{
836 PyObject *_res = NULL;
837 OSStatus _err;
838 Boolean modified;
839 if (!PyArg_ParseTuple(_args, "b",
840 &modified))
841 return NULL;
842 _err = SetWindowModified(_self->ob_itself,
843 modified);
844 if (_err != noErr) return PyMac_Error(_err);
845 Py_INCREF(Py_None);
846 _res = Py_None;
847 return _res;
848}
849
850static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
851 WindowObject *_self;
852 PyObject *_args;
853{
854 PyObject *_res = NULL;
855 Boolean _rv;
856 EventRecord event;
857 if (!PyArg_ParseTuple(_args, ""))
858 return NULL;
859 _rv = IsWindowPathSelectClick(_self->ob_itself,
860 &event);
861 _res = Py_BuildValue("bO&",
862 _rv,
863 PyMac_BuildEventRecord, &event);
864 return _res;
865}
866
867static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
868 WindowObject *_self;
869 PyObject *_args;
870{
871 PyObject *_res = NULL;
872 OSStatus _err;
873 Boolean hilited;
874 if (!PyArg_ParseTuple(_args, "b",
875 &hilited))
876 return NULL;
877 _err = HiliteWindowFrameForDrag(_self->ob_itself,
878 hilited);
879 if (_err != noErr) return PyMac_Error(_err);
880 Py_INCREF(Py_None);
881 _res = Py_None;
882 return _res;
883}
884
885static PyObject *WinObj_TransitionWindow(_self, _args)
886 WindowObject *_self;
887 PyObject *_args;
888{
889 PyObject *_res = NULL;
890 OSStatus _err;
891 WindowTransitionEffect effect;
892 WindowTransitionAction action;
893 Rect rect;
894 if (!PyArg_ParseTuple(_args, "llO&",
895 &effect,
896 &action,
897 PyMac_GetRect, &rect))
898 return NULL;
899 _err = TransitionWindow(_self->ob_itself,
900 effect,
901 action,
902 &rect);
Jack Jansene4349e81999-03-04 22:53:24 +0000903 if (_err != noErr) return PyMac_Error(_err);
904 Py_INCREF(Py_None);
905 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +0000906 return _res;
907}
908
Jack Jansen1c4e6141998-04-21 15:23:55 +0000909static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000910 WindowObject *_self;
911 PyObject *_args;
912{
913 PyObject *_res = NULL;
914 short hGlobal;
915 short vGlobal;
916 Boolean front;
917 if (!PyArg_ParseTuple(_args, "hhb",
918 &hGlobal,
919 &vGlobal,
920 &front))
921 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000922 MacMoveWindow(_self->ob_itself,
923 hGlobal,
924 vGlobal,
925 front);
Jack Jansen21f96871998-02-20 16:02:09 +0000926 Py_INCREF(Py_None);
927 _res = Py_None;
928 return _res;
929}
930
931static PyObject *WinObj_SizeWindow(_self, _args)
932 WindowObject *_self;
933 PyObject *_args;
934{
935 PyObject *_res = NULL;
936 short w;
937 short h;
938 Boolean fUpdate;
939 if (!PyArg_ParseTuple(_args, "hhb",
940 &w,
941 &h,
942 &fUpdate))
943 return NULL;
944 SizeWindow(_self->ob_itself,
945 w,
946 h,
947 fUpdate);
948 Py_INCREF(Py_None);
949 _res = Py_None;
950 return _res;
951}
952
Guido van Rossum17448e21995-01-30 11:53:55 +0000953static PyObject *WinObj_GrowWindow(_self, _args)
954 WindowObject *_self;
955 PyObject *_args;
956{
957 PyObject *_res = NULL;
958 long _rv;
959 Point startPt;
960 Rect bBox;
961 if (!PyArg_ParseTuple(_args, "O&O&",
962 PyMac_GetPoint, &startPt,
963 PyMac_GetRect, &bBox))
964 return NULL;
965 _rv = GrowWindow(_self->ob_itself,
966 startPt,
967 &bBox);
968 _res = Py_BuildValue("l",
969 _rv);
970 return _res;
971}
972
Jack Jansen21f96871998-02-20 16:02:09 +0000973static PyObject *WinObj_DragWindow(_self, _args)
974 WindowObject *_self;
975 PyObject *_args;
976{
977 PyObject *_res = NULL;
978 Point startPt;
979 Rect boundsRect;
980 if (!PyArg_ParseTuple(_args, "O&O&",
981 PyMac_GetPoint, &startPt,
982 PyMac_GetRect, &boundsRect))
983 return NULL;
984 DragWindow(_self->ob_itself,
985 startPt,
986 &boundsRect);
987 Py_INCREF(Py_None);
988 _res = Py_None;
989 return _res;
990}
991
Jack Jansena05ac601999-12-12 21:41:51 +0000992static PyObject *WinObj_ZoomWindow(_self, _args)
993 WindowObject *_self;
994 PyObject *_args;
995{
996 PyObject *_res = NULL;
997 short partCode;
998 Boolean front;
999 if (!PyArg_ParseTuple(_args, "hb",
1000 &partCode,
1001 &front))
1002 return NULL;
1003 ZoomWindow(_self->ob_itself,
1004 partCode,
1005 front);
1006 Py_INCREF(Py_None);
1007 _res = Py_None;
1008 return _res;
1009}
1010
1011static PyObject *WinObj_IsWindowCollapsable(_self, _args)
1012 WindowObject *_self;
1013 PyObject *_args;
1014{
1015 PyObject *_res = NULL;
1016 Boolean _rv;
1017 if (!PyArg_ParseTuple(_args, ""))
1018 return NULL;
1019 _rv = IsWindowCollapsable(_self->ob_itself);
1020 _res = Py_BuildValue("b",
1021 _rv);
1022 return _res;
1023}
1024
1025static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1026 WindowObject *_self;
1027 PyObject *_args;
1028{
1029 PyObject *_res = NULL;
1030 Boolean _rv;
1031 if (!PyArg_ParseTuple(_args, ""))
1032 return NULL;
1033 _rv = IsWindowCollapsed(_self->ob_itself);
1034 _res = Py_BuildValue("b",
1035 _rv);
1036 return _res;
1037}
1038
1039static PyObject *WinObj_CollapseWindow(_self, _args)
1040 WindowObject *_self;
1041 PyObject *_args;
1042{
1043 PyObject *_res = NULL;
1044 OSStatus _err;
1045 Boolean collapse;
1046 if (!PyArg_ParseTuple(_args, "b",
1047 &collapse))
1048 return NULL;
1049 _err = CollapseWindow(_self->ob_itself,
1050 collapse);
1051 if (_err != noErr) return PyMac_Error(_err);
1052 Py_INCREF(Py_None);
1053 _res = Py_None;
1054 return _res;
1055}
1056
1057static PyObject *WinObj_RepositionWindow(_self, _args)
1058 WindowObject *_self;
1059 PyObject *_args;
1060{
1061 PyObject *_res = NULL;
1062 OSStatus _err;
1063 WindowPtr parentWindow;
1064 WindowPositionMethod method;
1065 if (!PyArg_ParseTuple(_args, "O&l",
1066 WinObj_Convert, &parentWindow,
1067 &method))
1068 return NULL;
1069 _err = RepositionWindow(_self->ob_itself,
1070 parentWindow,
1071 method);
1072 if (_err != noErr) return PyMac_Error(_err);
1073 Py_INCREF(Py_None);
1074 _res = Py_None;
1075 return _res;
1076}
1077
1078static PyObject *WinObj_SetWindowBounds(_self, _args)
1079 WindowObject *_self;
1080 PyObject *_args;
1081{
1082 PyObject *_res = NULL;
1083 OSStatus _err;
1084 WindowRegionCode regionCode;
1085 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001086 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +00001087 &regionCode,
1088 PyMac_GetRect, &globalBounds))
1089 return NULL;
1090 _err = SetWindowBounds(_self->ob_itself,
1091 regionCode,
1092 &globalBounds);
1093 if (_err != noErr) return PyMac_Error(_err);
1094 Py_INCREF(Py_None);
1095 _res = Py_None;
1096 return _res;
1097}
1098
1099static PyObject *WinObj_GetWindowBounds(_self, _args)
1100 WindowObject *_self;
1101 PyObject *_args;
1102{
1103 PyObject *_res = NULL;
1104 OSStatus _err;
1105 WindowRegionCode regionCode;
1106 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001107 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001108 &regionCode))
1109 return NULL;
1110 _err = GetWindowBounds(_self->ob_itself,
1111 regionCode,
1112 &globalBounds);
1113 if (_err != noErr) return PyMac_Error(_err);
1114 _res = Py_BuildValue("O&",
1115 PyMac_BuildRect, &globalBounds);
1116 return _res;
1117}
1118
1119static PyObject *WinObj_MoveWindowStructure(_self, _args)
1120 WindowObject *_self;
1121 PyObject *_args;
1122{
1123 PyObject *_res = NULL;
1124 OSStatus _err;
1125 short hGlobal;
1126 short vGlobal;
1127 if (!PyArg_ParseTuple(_args, "hh",
1128 &hGlobal,
1129 &vGlobal))
1130 return NULL;
1131 _err = MoveWindowStructure(_self->ob_itself,
1132 hGlobal,
1133 vGlobal);
1134 if (_err != noErr) return PyMac_Error(_err);
1135 Py_INCREF(Py_None);
1136 _res = Py_None;
1137 return _res;
1138}
1139
1140static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1141 WindowObject *_self;
1142 PyObject *_args;
1143{
1144 PyObject *_res = NULL;
1145 Boolean _rv;
1146 Point idealSize;
1147 Rect idealStandardState;
1148 if (!PyArg_ParseTuple(_args, ""))
1149 return NULL;
1150 _rv = IsWindowInStandardState(_self->ob_itself,
1151 &idealSize,
1152 &idealStandardState);
1153 _res = Py_BuildValue("bO&O&",
1154 _rv,
1155 PyMac_BuildPoint, idealSize,
1156 PyMac_BuildRect, &idealStandardState);
1157 return _res;
1158}
1159
1160static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1161 WindowObject *_self;
1162 PyObject *_args;
1163{
1164 PyObject *_res = NULL;
1165 OSStatus _err;
1166 SInt16 partCode;
1167 Point ioIdealSize;
1168 if (!PyArg_ParseTuple(_args, "h",
1169 &partCode))
1170 return NULL;
1171 _err = ZoomWindowIdeal(_self->ob_itself,
1172 partCode,
1173 &ioIdealSize);
1174 if (_err != noErr) return PyMac_Error(_err);
1175 _res = Py_BuildValue("O&",
1176 PyMac_BuildPoint, ioIdealSize);
1177 return _res;
1178}
1179
1180static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1181 WindowObject *_self;
1182 PyObject *_args;
1183{
1184 PyObject *_res = NULL;
1185 OSStatus _err;
1186 Rect userState;
1187 if (!PyArg_ParseTuple(_args, ""))
1188 return NULL;
1189 _err = GetWindowIdealUserState(_self->ob_itself,
1190 &userState);
1191 if (_err != noErr) return PyMac_Error(_err);
1192 _res = Py_BuildValue("O&",
1193 PyMac_BuildRect, &userState);
1194 return _res;
1195}
1196
1197static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1198 WindowObject *_self;
1199 PyObject *_args;
1200{
1201 PyObject *_res = NULL;
1202 OSStatus _err;
1203 Rect userState;
1204 if (!PyArg_ParseTuple(_args, ""))
1205 return NULL;
1206 _err = SetWindowIdealUserState(_self->ob_itself,
1207 &userState);
1208 if (_err != noErr) return PyMac_Error(_err);
1209 _res = Py_BuildValue("O&",
1210 PyMac_BuildRect, &userState);
1211 return _res;
1212}
1213
Jack Jansen21f96871998-02-20 16:02:09 +00001214static PyObject *WinObj_HideWindow(_self, _args)
1215 WindowObject *_self;
1216 PyObject *_args;
1217{
1218 PyObject *_res = NULL;
1219 if (!PyArg_ParseTuple(_args, ""))
1220 return NULL;
1221 HideWindow(_self->ob_itself);
1222 Py_INCREF(Py_None);
1223 _res = Py_None;
1224 return _res;
1225}
1226
Jack Jansen1c4e6141998-04-21 15:23:55 +00001227static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001228 WindowObject *_self;
1229 PyObject *_args;
1230{
1231 PyObject *_res = NULL;
1232 if (!PyArg_ParseTuple(_args, ""))
1233 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001234 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +00001235 Py_INCREF(Py_None);
1236 _res = Py_None;
1237 return _res;
1238}
1239
1240static PyObject *WinObj_ShowHide(_self, _args)
1241 WindowObject *_self;
1242 PyObject *_args;
1243{
1244 PyObject *_res = NULL;
1245 Boolean showFlag;
1246 if (!PyArg_ParseTuple(_args, "b",
1247 &showFlag))
1248 return NULL;
1249 ShowHide(_self->ob_itself,
1250 showFlag);
1251 Py_INCREF(Py_None);
1252 _res = Py_None;
1253 return _res;
1254}
1255
Guido van Rossum17448e21995-01-30 11:53:55 +00001256static PyObject *WinObj_TrackBox(_self, _args)
1257 WindowObject *_self;
1258 PyObject *_args;
1259{
1260 PyObject *_res = NULL;
1261 Boolean _rv;
1262 Point thePt;
1263 short partCode;
1264 if (!PyArg_ParseTuple(_args, "O&h",
1265 PyMac_GetPoint, &thePt,
1266 &partCode))
1267 return NULL;
1268 _rv = TrackBox(_self->ob_itself,
1269 thePt,
1270 partCode);
1271 _res = Py_BuildValue("b",
1272 _rv);
1273 return _res;
1274}
1275
Guido van Rossum17448e21995-01-30 11:53:55 +00001276static PyObject *WinObj_TrackGoAway(_self, _args)
1277 WindowObject *_self;
1278 PyObject *_args;
1279{
1280 PyObject *_res = NULL;
1281 Boolean _rv;
1282 Point thePt;
1283 if (!PyArg_ParseTuple(_args, "O&",
1284 PyMac_GetPoint, &thePt))
1285 return NULL;
1286 _rv = TrackGoAway(_self->ob_itself,
1287 thePt);
1288 _res = Py_BuildValue("b",
1289 _rv);
1290 return _res;
1291}
1292
Jack Jansen74a1e632000-07-14 22:37:27 +00001293#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00001294
Jack Jansen8f0fab71997-08-15 14:38:05 +00001295static PyObject *WinObj_GetAuxWin(_self, _args)
1296 WindowObject *_self;
1297 PyObject *_args;
1298{
1299 PyObject *_res = NULL;
1300 Boolean _rv;
1301 AuxWinHandle awHndl;
1302 if (!PyArg_ParseTuple(_args, ""))
1303 return NULL;
1304 _rv = GetAuxWin(_self->ob_itself,
1305 &awHndl);
1306 _res = Py_BuildValue("bO&",
1307 _rv,
1308 ResObj_New, awHndl);
1309 return _res;
1310}
Jack Jansene79dc762000-06-02 21:35:07 +00001311#endif
Jack Jansen8f0fab71997-08-15 14:38:05 +00001312
Jack Jansenb7abb181995-11-15 15:18:47 +00001313static PyObject *WinObj_GetWindowPort(_self, _args)
1314 WindowObject *_self;
1315 PyObject *_args;
1316{
1317 PyObject *_res = NULL;
1318 CGrafPtr _rv;
1319 if (!PyArg_ParseTuple(_args, ""))
1320 return NULL;
1321 _rv = GetWindowPort(_self->ob_itself);
1322 _res = Py_BuildValue("O&",
1323 GrafObj_New, _rv);
1324 return _res;
1325}
1326
Jack Jansen330f5761995-11-14 10:48:54 +00001327static PyObject *WinObj_SetPortWindowPort(_self, _args)
1328 WindowObject *_self;
1329 PyObject *_args;
1330{
1331 PyObject *_res = NULL;
1332 if (!PyArg_ParseTuple(_args, ""))
1333 return NULL;
1334 SetPortWindowPort(_self->ob_itself);
1335 Py_INCREF(Py_None);
1336 _res = Py_None;
1337 return _res;
1338}
1339
1340static PyObject *WinObj_GetWindowKind(_self, _args)
1341 WindowObject *_self;
1342 PyObject *_args;
1343{
1344 PyObject *_res = NULL;
1345 short _rv;
1346 if (!PyArg_ParseTuple(_args, ""))
1347 return NULL;
1348 _rv = GetWindowKind(_self->ob_itself);
1349 _res = Py_BuildValue("h",
1350 _rv);
1351 return _res;
1352}
1353
1354static PyObject *WinObj_SetWindowKind(_self, _args)
1355 WindowObject *_self;
1356 PyObject *_args;
1357{
1358 PyObject *_res = NULL;
1359 short wKind;
1360 if (!PyArg_ParseTuple(_args, "h",
1361 &wKind))
1362 return NULL;
1363 SetWindowKind(_self->ob_itself,
1364 wKind);
1365 Py_INCREF(Py_None);
1366 _res = Py_None;
1367 return _res;
1368}
1369
1370static PyObject *WinObj_IsWindowVisible(_self, _args)
1371 WindowObject *_self;
1372 PyObject *_args;
1373{
1374 PyObject *_res = NULL;
1375 Boolean _rv;
1376 if (!PyArg_ParseTuple(_args, ""))
1377 return NULL;
1378 _rv = IsWindowVisible(_self->ob_itself);
1379 _res = Py_BuildValue("b",
1380 _rv);
1381 return _res;
1382}
1383
1384static PyObject *WinObj_IsWindowHilited(_self, _args)
1385 WindowObject *_self;
1386 PyObject *_args;
1387{
1388 PyObject *_res = NULL;
1389 Boolean _rv;
1390 if (!PyArg_ParseTuple(_args, ""))
1391 return NULL;
1392 _rv = IsWindowHilited(_self->ob_itself);
1393 _res = Py_BuildValue("b",
1394 _rv);
1395 return _res;
1396}
1397
1398static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1399 WindowObject *_self;
1400 PyObject *_args;
1401{
1402 PyObject *_res = NULL;
1403 Boolean _rv;
1404 if (!PyArg_ParseTuple(_args, ""))
1405 return NULL;
1406 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1407 _res = Py_BuildValue("b",
1408 _rv);
1409 return _res;
1410}
1411
Jack Jansen74a1e632000-07-14 22:37:27 +00001412#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00001413
Jack Jansen330f5761995-11-14 10:48:54 +00001414static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1415 WindowObject *_self;
1416 PyObject *_args;
1417{
1418 PyObject *_res = NULL;
1419 Boolean _rv;
1420 if (!PyArg_ParseTuple(_args, ""))
1421 return NULL;
1422 _rv = GetWindowZoomFlag(_self->ob_itself);
1423 _res = Py_BuildValue("b",
1424 _rv);
1425 return _res;
1426}
Jack Jansene79dc762000-06-02 21:35:07 +00001427#endif
1428
Jack Jansen74a1e632000-07-14 22:37:27 +00001429#if !TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001430
Jack Jansenb7abb181995-11-15 15:18:47 +00001431static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1432 WindowObject *_self;
1433 PyObject *_args;
1434{
1435 PyObject *_res = NULL;
1436 RgnHandle r;
1437 if (!PyArg_ParseTuple(_args, "O&",
1438 ResObj_Convert, &r))
1439 return NULL;
1440 GetWindowStructureRgn(_self->ob_itself,
1441 r);
1442 Py_INCREF(Py_None);
1443 _res = Py_None;
1444 return _res;
1445}
Jack Jansene79dc762000-06-02 21:35:07 +00001446#endif
1447
Jack Jansen74a1e632000-07-14 22:37:27 +00001448#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001449
1450static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1451 WindowObject *_self;
1452 PyObject *_args;
1453{
1454 PyObject *_res = NULL;
1455 RgnHandle r;
1456 if (!PyArg_ParseTuple(_args, "O&",
1457 ResObj_Convert, &r))
1458 return NULL;
1459 GetWindowContentRgn(_self->ob_itself,
1460 r);
1461 Py_INCREF(Py_None);
1462 _res = Py_None;
1463 return _res;
1464}
Jack Jansene79dc762000-06-02 21:35:07 +00001465#endif
1466
Jack Jansen74a1e632000-07-14 22:37:27 +00001467#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001468
1469static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1470 WindowObject *_self;
1471 PyObject *_args;
1472{
1473 PyObject *_res = NULL;
1474 RgnHandle r;
1475 if (!PyArg_ParseTuple(_args, "O&",
1476 ResObj_Convert, &r))
1477 return NULL;
1478 GetWindowUpdateRgn(_self->ob_itself,
1479 r);
1480 Py_INCREF(Py_None);
1481 _res = Py_None;
1482 return _res;
1483}
Jack Jansene79dc762000-06-02 21:35:07 +00001484#endif
1485
Jack Jansen74a1e632000-07-14 22:37:27 +00001486#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001487
Jack Jansen330f5761995-11-14 10:48:54 +00001488static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1489 WindowObject *_self;
1490 PyObject *_args;
1491{
1492 PyObject *_res = NULL;
1493 short _rv;
1494 if (!PyArg_ParseTuple(_args, ""))
1495 return NULL;
1496 _rv = GetWindowTitleWidth(_self->ob_itself);
1497 _res = Py_BuildValue("h",
1498 _rv);
1499 return _res;
1500}
Jack Jansene79dc762000-06-02 21:35:07 +00001501#endif
Jack Jansen330f5761995-11-14 10:48:54 +00001502
1503static PyObject *WinObj_GetNextWindow(_self, _args)
1504 WindowObject *_self;
1505 PyObject *_args;
1506{
1507 PyObject *_res = NULL;
1508 WindowPtr _rv;
1509 if (!PyArg_ParseTuple(_args, ""))
1510 return NULL;
1511 _rv = GetNextWindow(_self->ob_itself);
1512 _res = Py_BuildValue("O&",
1513 WinObj_WhichWindow, _rv);
1514 return _res;
1515}
1516
1517static PyObject *WinObj_GetWindowStandardState(_self, _args)
1518 WindowObject *_self;
1519 PyObject *_args;
1520{
1521 PyObject *_res = NULL;
1522 Rect r;
1523 if (!PyArg_ParseTuple(_args, ""))
1524 return NULL;
1525 GetWindowStandardState(_self->ob_itself,
1526 &r);
1527 _res = Py_BuildValue("O&",
1528 PyMac_BuildRect, &r);
1529 return _res;
1530}
1531
1532static PyObject *WinObj_GetWindowUserState(_self, _args)
1533 WindowObject *_self;
1534 PyObject *_args;
1535{
1536 PyObject *_res = NULL;
1537 Rect r;
1538 if (!PyArg_ParseTuple(_args, ""))
1539 return NULL;
1540 GetWindowUserState(_self->ob_itself,
1541 &r);
1542 _res = Py_BuildValue("O&",
1543 PyMac_BuildRect, &r);
1544 return _res;
1545}
1546
1547static PyObject *WinObj_SetWindowStandardState(_self, _args)
1548 WindowObject *_self;
1549 PyObject *_args;
1550{
1551 PyObject *_res = NULL;
1552 Rect r;
1553 if (!PyArg_ParseTuple(_args, "O&",
1554 PyMac_GetRect, &r))
1555 return NULL;
1556 SetWindowStandardState(_self->ob_itself,
1557 &r);
1558 Py_INCREF(Py_None);
1559 _res = Py_None;
1560 return _res;
1561}
1562
1563static PyObject *WinObj_SetWindowUserState(_self, _args)
1564 WindowObject *_self;
1565 PyObject *_args;
1566{
1567 PyObject *_res = NULL;
1568 Rect r;
1569 if (!PyArg_ParseTuple(_args, "O&",
1570 PyMac_GetRect, &r))
1571 return NULL;
1572 SetWindowUserState(_self->ob_itself,
1573 &r);
1574 Py_INCREF(Py_None);
1575 _res = Py_None;
1576 return _res;
1577}
1578
Jack Jansen74a1e632000-07-14 22:37:27 +00001579#if !TARGET_API_MAC_CARBON
Jack Jansencdcbd1f1998-10-22 15:08:00 +00001580
Jack Jansene180d991998-04-24 10:28:20 +00001581static PyObject *WinObj_CloseWindow(_self, _args)
1582 WindowObject *_self;
1583 PyObject *_args;
1584{
1585 PyObject *_res = NULL;
1586 if (!PyArg_ParseTuple(_args, ""))
1587 return NULL;
1588 CloseWindow(_self->ob_itself);
1589 Py_INCREF(Py_None);
1590 _res = Py_None;
1591 return _res;
1592}
Jack Jansene79dc762000-06-02 21:35:07 +00001593#endif
Jack Jansene180d991998-04-24 10:28:20 +00001594
1595static PyObject *WinObj_MoveWindow(_self, _args)
1596 WindowObject *_self;
1597 PyObject *_args;
1598{
1599 PyObject *_res = NULL;
1600 short hGlobal;
1601 short vGlobal;
1602 Boolean front;
1603 if (!PyArg_ParseTuple(_args, "hhb",
1604 &hGlobal,
1605 &vGlobal,
1606 &front))
1607 return NULL;
1608 MoveWindow(_self->ob_itself,
1609 hGlobal,
1610 vGlobal,
1611 front);
1612 Py_INCREF(Py_None);
1613 _res = Py_None;
1614 return _res;
1615}
1616
1617static PyObject *WinObj_ShowWindow(_self, _args)
1618 WindowObject *_self;
1619 PyObject *_args;
1620{
1621 PyObject *_res = NULL;
1622 if (!PyArg_ParseTuple(_args, ""))
1623 return NULL;
1624 ShowWindow(_self->ob_itself);
1625 Py_INCREF(Py_None);
1626 _res = Py_None;
1627 return _res;
1628}
1629
Guido van Rossum17448e21995-01-30 11:53:55 +00001630static PyMethodDef WinObj_methods[] = {
Jack Jansena05ac601999-12-12 21:41:51 +00001631 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
1632 "() -> (UInt32 outCount)"},
1633 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
1634 "() -> None"},
1635 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
1636 "() -> (WindowClass outClass)"},
1637 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
1638 "() -> (WindowAttributes outAttributes)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001639
Jack Jansen74a1e632000-07-14 22:37:27 +00001640#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001641 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1642 "(WCTabHandle newColorTable) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001643#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001644 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
1645 "() -> (RGBColor color)"},
1646 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
1647 "() -> (RGBColor color)"},
1648 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
1649 "(PixPatHandle outPixPat) -> None"},
1650 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
1651 "(PixPatHandle pixPat) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001652 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1653 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001654
Jack Jansen74a1e632000-07-14 22:37:27 +00001655#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001656 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1657 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001658#endif
1659
Jack Jansen74a1e632000-07-14 22:37:27 +00001660#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001661 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1662 "(Boolean update) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001663#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00001664 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1665 "(RgnHandle clobberedRgn) -> None"},
1666 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1667 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001668 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1669 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001670 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1671 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001672 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1673 "() -> None"},
1674 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1675 "(WindowPtr behindWindow) -> None"},
1676 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1677 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001678 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1679 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001680 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1681 "(long data) -> None"},
1682 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1683 "() -> (long _rv)"},
1684 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1685 "(PicHandle pic) -> None"},
1686 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1687 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001688 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1689 "() -> (short _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001690 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1691 "() -> (UInt32 outFeatures)"},
1692 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1693 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001694 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1695 "() -> None"},
1696 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1697 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001698 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
1699 "(RgnHandle region) -> None"},
1700 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
1701 "(Rect bounds) -> None"},
1702 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
1703 "(RgnHandle region) -> None"},
1704 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
1705 "(Rect bounds) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001706 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1707 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001708 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1709 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001710 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1711 "() -> (Str255 title)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001712 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
1713 "(FSSpec inFile) -> None"},
1714 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
1715 "() -> (FSSpec outFile)"},
1716 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
1717 "(AliasHandle alias) -> None"},
1718 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
1719 "() -> (AliasHandle alias)"},
1720 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
1721 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
1722 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
1723 "() -> (IconRef outIcon)"},
1724 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
1725 "(IconRef icon) -> None"},
1726 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
1727 "() -> None"},
1728 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
1729 "(Point startPt) -> None"},
1730 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
1731 "() -> (Boolean _rv)"},
1732 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
1733 "(Boolean modified) -> None"},
1734 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
1735 "() -> (Boolean _rv, EventRecord event)"},
1736 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
1737 "(Boolean hilited) -> None"},
1738 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
1739 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
1740 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
1741 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1742 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1743 "(short w, short h, Boolean fUpdate) -> None"},
1744 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1745 "(Point startPt, Rect bBox) -> (long _rv)"},
1746 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1747 "(Point startPt, Rect boundsRect) -> None"},
1748 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1749 "(short partCode, Boolean front) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001750 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1751 "() -> (Boolean _rv)"},
1752 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1753 "() -> (Boolean _rv)"},
1754 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00001755 "(Boolean collapse) -> None"},
1756 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
1757 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
1758 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
1759 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
1760 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
1761 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
1762 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
1763 "(short hGlobal, short vGlobal) -> None"},
1764 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
1765 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
1766 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
1767 "(SInt16 partCode) -> (Point ioIdealSize)"},
1768 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
1769 "() -> (Rect userState)"},
1770 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
1771 "() -> (Rect userState)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001772 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1773 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001774 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001775 "() -> None"},
1776 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1777 "(Boolean showFlag) -> None"},
1778 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1779 "(Point thePt, short partCode) -> (Boolean _rv)"},
1780 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1781 "(Point thePt) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001782
Jack Jansen74a1e632000-07-14 22:37:27 +00001783#if !TARGET_API_MAC_CARBON
Jack Jansen8f0fab71997-08-15 14:38:05 +00001784 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1785 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001786#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00001787 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1788 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00001789 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1790 "() -> None"},
1791 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1792 "() -> (short _rv)"},
1793 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1794 "(short wKind) -> None"},
1795 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1796 "() -> (Boolean _rv)"},
1797 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1798 "() -> (Boolean _rv)"},
1799 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1800 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001801
Jack Jansen74a1e632000-07-14 22:37:27 +00001802#if !TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001803 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1804 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001805#endif
1806
Jack Jansen74a1e632000-07-14 22:37:27 +00001807#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001808 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1809 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001810#endif
1811
Jack Jansen74a1e632000-07-14 22:37:27 +00001812#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001813 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1814 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001815#endif
1816
Jack Jansen74a1e632000-07-14 22:37:27 +00001817#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001818 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1819 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001820#endif
1821
Jack Jansen74a1e632000-07-14 22:37:27 +00001822#if !TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001823 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1824 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001825#endif
Jack Jansen330f5761995-11-14 10:48:54 +00001826 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1827 "() -> (WindowPtr _rv)"},
1828 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1829 "() -> (Rect r)"},
1830 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1831 "() -> (Rect r)"},
1832 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1833 "(Rect r) -> None"},
1834 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1835 "(Rect r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001836
Jack Jansen74a1e632000-07-14 22:37:27 +00001837#if !TARGET_API_MAC_CARBON
Jack Jansene180d991998-04-24 10:28:20 +00001838 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
1839 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001840#endif
Jack Jansene180d991998-04-24 10:28:20 +00001841 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
1842 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1843 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
1844 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001845 {NULL, NULL, 0}
1846};
1847
1848PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1849
1850static PyObject *WinObj_getattr(self, name)
1851 WindowObject *self;
1852 char *name;
1853{
1854 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1855}
1856
1857#define WinObj_setattr NULL
1858
Jack Jansena05ac601999-12-12 21:41:51 +00001859#define WinObj_compare NULL
1860
1861#define WinObj_repr NULL
1862
1863#define WinObj_hash NULL
1864
Guido van Rossum17448e21995-01-30 11:53:55 +00001865PyTypeObject Window_Type = {
1866 PyObject_HEAD_INIT(&PyType_Type)
1867 0, /*ob_size*/
1868 "Window", /*tp_name*/
1869 sizeof(WindowObject), /*tp_basicsize*/
1870 0, /*tp_itemsize*/
1871 /* methods */
1872 (destructor) WinObj_dealloc, /*tp_dealloc*/
1873 0, /*tp_print*/
1874 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1875 (setattrfunc) WinObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00001876 (cmpfunc) WinObj_compare, /*tp_compare*/
1877 (reprfunc) WinObj_repr, /*tp_repr*/
1878 (PyNumberMethods *)0, /* tp_as_number */
1879 (PySequenceMethods *)0, /* tp_as_sequence */
1880 (PyMappingMethods *)0, /* tp_as_mapping */
1881 (hashfunc) WinObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00001882};
1883
1884/* --------------------- End object type Window --------------------- */
1885
1886
Jack Jansen21f96871998-02-20 16:02:09 +00001887static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001888 PyObject *_self;
1889 PyObject *_args;
1890{
1891 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001892 WindowPtr _rv;
1893 short windowID;
1894 WindowPtr behind;
1895 if (!PyArg_ParseTuple(_args, "hO&",
1896 &windowID,
1897 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00001898 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001899 _rv = GetNewCWindow(windowID,
1900 (void *)0,
1901 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00001902 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001903 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00001904 return _res;
1905}
1906
Guido van Rossum17448e21995-01-30 11:53:55 +00001907static PyObject *Win_NewWindow(_self, _args)
1908 PyObject *_self;
1909 PyObject *_args;
1910{
1911 PyObject *_res = NULL;
1912 WindowPtr _rv;
1913 Rect boundsRect;
1914 Str255 title;
1915 Boolean visible;
1916 short theProc;
1917 WindowPtr behind;
1918 Boolean goAwayFlag;
1919 long refCon;
1920 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1921 PyMac_GetRect, &boundsRect,
1922 PyMac_GetStr255, title,
1923 &visible,
1924 &theProc,
1925 WinObj_Convert, &behind,
1926 &goAwayFlag,
1927 &refCon))
1928 return NULL;
1929 _rv = NewWindow((void *)0,
1930 &boundsRect,
1931 title,
1932 visible,
1933 theProc,
1934 behind,
1935 goAwayFlag,
1936 refCon);
1937 _res = Py_BuildValue("O&",
1938 WinObj_New, _rv);
1939 return _res;
1940}
1941
1942static PyObject *Win_GetNewWindow(_self, _args)
1943 PyObject *_self;
1944 PyObject *_args;
1945{
1946 PyObject *_res = NULL;
1947 WindowPtr _rv;
1948 short windowID;
1949 WindowPtr behind;
1950 if (!PyArg_ParseTuple(_args, "hO&",
1951 &windowID,
1952 WinObj_Convert, &behind))
1953 return NULL;
1954 _rv = GetNewWindow(windowID,
1955 (void *)0,
1956 behind);
1957 _res = Py_BuildValue("O&",
1958 WinObj_New, _rv);
1959 return _res;
1960}
1961
Jack Jansen21f96871998-02-20 16:02:09 +00001962static PyObject *Win_NewCWindow(_self, _args)
1963 PyObject *_self;
1964 PyObject *_args;
1965{
1966 PyObject *_res = NULL;
1967 WindowPtr _rv;
1968 Rect boundsRect;
1969 Str255 title;
1970 Boolean visible;
1971 short procID;
1972 WindowPtr behind;
1973 Boolean goAwayFlag;
1974 long refCon;
1975 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1976 PyMac_GetRect, &boundsRect,
1977 PyMac_GetStr255, title,
1978 &visible,
1979 &procID,
1980 WinObj_Convert, &behind,
1981 &goAwayFlag,
1982 &refCon))
1983 return NULL;
1984 _rv = NewCWindow((void *)0,
1985 &boundsRect,
1986 title,
1987 visible,
1988 procID,
1989 behind,
1990 goAwayFlag,
1991 refCon);
1992 _res = Py_BuildValue("O&",
1993 WinObj_New, _rv);
1994 return _res;
1995}
1996
Jack Jansena05ac601999-12-12 21:41:51 +00001997static PyObject *Win_CreateNewWindow(_self, _args)
1998 PyObject *_self;
1999 PyObject *_args;
2000{
2001 PyObject *_res = NULL;
2002 OSStatus _err;
2003 WindowClass windowClass;
2004 WindowAttributes attributes;
2005 Rect bounds;
2006 WindowPtr outWindow;
2007 if (!PyArg_ParseTuple(_args, "llO&",
2008 &windowClass,
2009 &attributes,
2010 PyMac_GetRect, &bounds))
2011 return NULL;
2012 _err = CreateNewWindow(windowClass,
2013 attributes,
2014 &bounds,
2015 &outWindow);
2016 if (_err != noErr) return PyMac_Error(_err);
2017 _res = Py_BuildValue("O&",
2018 WinObj_WhichWindow, outWindow);
2019 return _res;
2020}
2021
2022static PyObject *Win_CreateWindowFromResource(_self, _args)
2023 PyObject *_self;
2024 PyObject *_args;
2025{
2026 PyObject *_res = NULL;
2027 OSStatus _err;
2028 SInt16 resID;
2029 WindowPtr outWindow;
2030 if (!PyArg_ParseTuple(_args, "h",
2031 &resID))
2032 return NULL;
2033 _err = CreateWindowFromResource(resID,
2034 &outWindow);
2035 if (_err != noErr) return PyMac_Error(_err);
2036 _res = Py_BuildValue("O&",
2037 WinObj_WhichWindow, outWindow);
2038 return _res;
2039}
2040
2041static PyObject *Win_ShowFloatingWindows(_self, _args)
2042 PyObject *_self;
2043 PyObject *_args;
2044{
2045 PyObject *_res = NULL;
2046 OSStatus _err;
2047 if (!PyArg_ParseTuple(_args, ""))
2048 return NULL;
2049 _err = ShowFloatingWindows();
2050 if (_err != noErr) return PyMac_Error(_err);
2051 Py_INCREF(Py_None);
2052 _res = Py_None;
2053 return _res;
2054}
2055
2056static PyObject *Win_HideFloatingWindows(_self, _args)
2057 PyObject *_self;
2058 PyObject *_args;
2059{
2060 PyObject *_res = NULL;
2061 OSStatus _err;
2062 if (!PyArg_ParseTuple(_args, ""))
2063 return NULL;
2064 _err = HideFloatingWindows();
2065 if (_err != noErr) return PyMac_Error(_err);
2066 Py_INCREF(Py_None);
2067 _res = Py_None;
2068 return _res;
2069}
2070
2071static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2072 PyObject *_self;
2073 PyObject *_args;
2074{
2075 PyObject *_res = NULL;
2076 Boolean _rv;
2077 if (!PyArg_ParseTuple(_args, ""))
2078 return NULL;
2079 _rv = AreFloatingWindowsVisible();
2080 _res = Py_BuildValue("b",
2081 _rv);
2082 return _res;
2083}
2084
2085static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2086 PyObject *_self;
2087 PyObject *_args;
2088{
2089 PyObject *_res = NULL;
2090 WindowPtr _rv;
2091 if (!PyArg_ParseTuple(_args, ""))
2092 return NULL;
2093 _rv = FrontNonFloatingWindow();
2094 _res = Py_BuildValue("O&",
Jack Jansen0aee0e62000-08-25 22:17:51 +00002095 WinObj_WhichWindow, _rv);
Jack Jansena05ac601999-12-12 21:41:51 +00002096 return _res;
2097}
2098
Jack Jansen74a1e632000-07-14 22:37:27 +00002099#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002100
Jack Jansen21f96871998-02-20 16:02:09 +00002101static PyObject *Win_SetDeskCPat(_self, _args)
2102 PyObject *_self;
2103 PyObject *_args;
2104{
2105 PyObject *_res = NULL;
2106 PixPatHandle deskPixPat;
2107 if (!PyArg_ParseTuple(_args, "O&",
2108 ResObj_Convert, &deskPixPat))
2109 return NULL;
2110 SetDeskCPat(deskPixPat);
2111 Py_INCREF(Py_None);
2112 _res = Py_None;
2113 return _res;
2114}
Jack Jansene79dc762000-06-02 21:35:07 +00002115#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002116
2117static PyObject *Win_CheckUpdate(_self, _args)
2118 PyObject *_self;
2119 PyObject *_args;
2120{
2121 PyObject *_res = NULL;
2122 Boolean _rv;
2123 EventRecord theEvent;
2124 if (!PyArg_ParseTuple(_args, ""))
2125 return NULL;
2126 _rv = CheckUpdate(&theEvent);
2127 _res = Py_BuildValue("bO&",
2128 _rv,
2129 PyMac_BuildEventRecord, &theEvent);
2130 return _res;
2131}
2132
Jack Jansen1c4e6141998-04-21 15:23:55 +00002133static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002134 PyObject *_self;
2135 PyObject *_args;
2136{
2137 PyObject *_res = NULL;
2138 short _rv;
2139 Point thePoint;
Jack Jansena05ac601999-12-12 21:41:51 +00002140 WindowPtr window;
Jack Jansen21f96871998-02-20 16:02:09 +00002141 if (!PyArg_ParseTuple(_args, "O&",
2142 PyMac_GetPoint, &thePoint))
2143 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002144 _rv = MacFindWindow(thePoint,
Jack Jansena05ac601999-12-12 21:41:51 +00002145 &window);
Jack Jansen21f96871998-02-20 16:02:09 +00002146 _res = Py_BuildValue("hO&",
2147 _rv,
Jack Jansena05ac601999-12-12 21:41:51 +00002148 WinObj_WhichWindow, window);
Jack Jansen21f96871998-02-20 16:02:09 +00002149 return _res;
2150}
2151
Guido van Rossum17448e21995-01-30 11:53:55 +00002152static PyObject *Win_FrontWindow(_self, _args)
2153 PyObject *_self;
2154 PyObject *_args;
2155{
2156 PyObject *_res = NULL;
2157 WindowPtr _rv;
2158 if (!PyArg_ParseTuple(_args, ""))
2159 return NULL;
2160 _rv = FrontWindow();
2161 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00002162 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002163 return _res;
2164}
2165
Jack Jansen74a1e632000-07-14 22:37:27 +00002166#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002167
Jack Jansen21f96871998-02-20 16:02:09 +00002168static PyObject *Win_InitWindows(_self, _args)
2169 PyObject *_self;
2170 PyObject *_args;
2171{
2172 PyObject *_res = NULL;
2173 if (!PyArg_ParseTuple(_args, ""))
2174 return NULL;
2175 InitWindows();
2176 Py_INCREF(Py_None);
2177 _res = Py_None;
2178 return _res;
2179}
Jack Jansene79dc762000-06-02 21:35:07 +00002180#endif
2181
Jack Jansen74a1e632000-07-14 22:37:27 +00002182#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002183
2184static PyObject *Win_GetWMgrPort(_self, _args)
2185 PyObject *_self;
2186 PyObject *_args;
2187{
2188 PyObject *_res = NULL;
2189 GrafPtr wPort;
2190 if (!PyArg_ParseTuple(_args, ""))
2191 return NULL;
2192 GetWMgrPort(&wPort);
2193 _res = Py_BuildValue("O&",
2194 GrafObj_New, wPort);
2195 return _res;
2196}
Jack Jansene79dc762000-06-02 21:35:07 +00002197#endif
2198
Jack Jansen74a1e632000-07-14 22:37:27 +00002199#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002200
2201static PyObject *Win_GetCWMgrPort(_self, _args)
2202 PyObject *_self;
2203 PyObject *_args;
2204{
2205 PyObject *_res = NULL;
2206 CGrafPtr wMgrCPort;
2207 if (!PyArg_ParseTuple(_args, ""))
2208 return NULL;
2209 GetCWMgrPort(&wMgrCPort);
2210 _res = Py_BuildValue("O&",
2211 GrafObj_New, wMgrCPort);
2212 return _res;
2213}
Jack Jansene79dc762000-06-02 21:35:07 +00002214#endif
2215
Jack Jansen74a1e632000-07-14 22:37:27 +00002216#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002217
Jack Jansena05ac601999-12-12 21:41:51 +00002218static PyObject *Win_IsValidWindowPtr(_self, _args)
2219 PyObject *_self;
2220 PyObject *_args;
2221{
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;
2232}
Jack Jansene79dc762000-06-02 21:35:07 +00002233#endif
2234
Jack Jansen74a1e632000-07-14 22:37:27 +00002235#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002236
2237static PyObject *Win_InitFloatingWindows(_self, _args)
2238 PyObject *_self;
2239 PyObject *_args;
2240{
2241 PyObject *_res = NULL;
2242 OSStatus _err;
2243 if (!PyArg_ParseTuple(_args, ""))
2244 return NULL;
2245 _err = InitFloatingWindows();
2246 if (_err != noErr) return PyMac_Error(_err);
2247 Py_INCREF(Py_None);
2248 _res = Py_None;
2249 return _res;
2250}
Jack Jansene79dc762000-06-02 21:35:07 +00002251#endif
2252
Jack Jansen74a1e632000-07-14 22:37:27 +00002253#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002254
Guido van Rossum17448e21995-01-30 11:53:55 +00002255static PyObject *Win_InvalRect(_self, _args)
2256 PyObject *_self;
2257 PyObject *_args;
2258{
2259 PyObject *_res = NULL;
2260 Rect badRect;
2261 if (!PyArg_ParseTuple(_args, "O&",
2262 PyMac_GetRect, &badRect))
2263 return NULL;
2264 InvalRect(&badRect);
2265 Py_INCREF(Py_None);
2266 _res = Py_None;
2267 return _res;
2268}
Jack Jansene79dc762000-06-02 21:35:07 +00002269#endif
2270
Jack Jansen74a1e632000-07-14 22:37:27 +00002271#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002272
Jack Jansenb7abb181995-11-15 15:18:47 +00002273static PyObject *Win_InvalRgn(_self, _args)
2274 PyObject *_self;
2275 PyObject *_args;
2276{
2277 PyObject *_res = NULL;
2278 RgnHandle badRgn;
2279 if (!PyArg_ParseTuple(_args, "O&",
2280 ResObj_Convert, &badRgn))
2281 return NULL;
2282 InvalRgn(badRgn);
2283 Py_INCREF(Py_None);
2284 _res = Py_None;
2285 return _res;
2286}
Jack Jansene79dc762000-06-02 21:35:07 +00002287#endif
2288
Jack Jansen74a1e632000-07-14 22:37:27 +00002289#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002290
Guido van Rossum17448e21995-01-30 11:53:55 +00002291static PyObject *Win_ValidRect(_self, _args)
2292 PyObject *_self;
2293 PyObject *_args;
2294{
2295 PyObject *_res = NULL;
2296 Rect goodRect;
2297 if (!PyArg_ParseTuple(_args, "O&",
2298 PyMac_GetRect, &goodRect))
2299 return NULL;
2300 ValidRect(&goodRect);
2301 Py_INCREF(Py_None);
2302 _res = Py_None;
2303 return _res;
2304}
Jack Jansene79dc762000-06-02 21:35:07 +00002305#endif
2306
Jack Jansen74a1e632000-07-14 22:37:27 +00002307#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002308
Jack Jansenb7abb181995-11-15 15:18:47 +00002309static PyObject *Win_ValidRgn(_self, _args)
2310 PyObject *_self;
2311 PyObject *_args;
2312{
2313 PyObject *_res = NULL;
2314 RgnHandle goodRgn;
2315 if (!PyArg_ParseTuple(_args, "O&",
2316 ResObj_Convert, &goodRgn))
2317 return NULL;
2318 ValidRgn(goodRgn);
2319 Py_INCREF(Py_None);
2320 _res = Py_None;
2321 return _res;
2322}
Jack Jansene79dc762000-06-02 21:35:07 +00002323#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00002324
Jack Jansen21f96871998-02-20 16:02:09 +00002325static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002326 PyObject *_self;
2327 PyObject *_args;
2328{
2329 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00002330 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +00002331 Boolean collapse;
Jack Jansen21f96871998-02-20 16:02:09 +00002332 if (!PyArg_ParseTuple(_args, "b",
Jack Jansena05ac601999-12-12 21:41:51 +00002333 &collapse))
Guido van Rossum17448e21995-01-30 11:53:55 +00002334 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002335 _err = CollapseAllWindows(collapse);
Jack Jansene4349e81999-03-04 22:53:24 +00002336 if (_err != noErr) return PyMac_Error(_err);
2337 Py_INCREF(Py_None);
2338 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00002339 return _res;
2340}
2341
2342static PyObject *Win_PinRect(_self, _args)
2343 PyObject *_self;
2344 PyObject *_args;
2345{
2346 PyObject *_res = NULL;
2347 long _rv;
2348 Rect theRect;
2349 Point thePt;
2350 if (!PyArg_ParseTuple(_args, "O&O&",
2351 PyMac_GetRect, &theRect,
2352 PyMac_GetPoint, &thePt))
2353 return NULL;
2354 _rv = PinRect(&theRect,
2355 thePt);
2356 _res = Py_BuildValue("l",
2357 _rv);
2358 return _res;
2359}
2360
Jack Jansen21f96871998-02-20 16:02:09 +00002361static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002362 PyObject *_self;
2363 PyObject *_args;
2364{
2365 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002366 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00002367 if (!PyArg_ParseTuple(_args, ""))
2368 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002369 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00002370 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002371 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002372 return _res;
2373}
2374
Jack Jansend4c26461995-08-17 14:35:56 +00002375static PyObject *Win_WhichWindow(_self, _args)
2376 PyObject *_self;
2377 PyObject *_args;
2378{
2379 PyObject *_res = NULL;
2380
2381 long ptr;
2382
2383 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2384 return NULL;
2385 return WinObj_WhichWindow((WindowPtr)ptr);
2386
2387}
2388
Jack Jansene180d991998-04-24 10:28:20 +00002389static PyObject *Win_FindWindow(_self, _args)
2390 PyObject *_self;
2391 PyObject *_args;
2392{
2393 PyObject *_res = NULL;
2394 short _rv;
2395 Point thePoint;
2396 WindowPtr theWindow;
2397 if (!PyArg_ParseTuple(_args, "O&",
2398 PyMac_GetPoint, &thePoint))
2399 return NULL;
2400 _rv = FindWindow(thePoint,
2401 &theWindow);
2402 _res = Py_BuildValue("hO&",
2403 _rv,
2404 WinObj_WhichWindow, theWindow);
2405 return _res;
2406}
2407
Guido van Rossum17448e21995-01-30 11:53:55 +00002408static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00002409 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2410 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002411 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2412 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2413 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2414 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002415 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2416 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002417 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
2418 "(WindowClass windowClass, WindowAttributes attributes, Rect bounds) -> (WindowPtr outWindow)"},
2419 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2420 "(SInt16 resID) -> (WindowPtr outWindow)"},
2421 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2422 "() -> None"},
2423 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2424 "() -> None"},
2425 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2426 "() -> (Boolean _rv)"},
2427 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2428 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002429
Jack Jansen74a1e632000-07-14 22:37:27 +00002430#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002431 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2432 "(PixPatHandle deskPixPat) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002433#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002434 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2435 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002436 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002437 "(Point thePoint) -> (short _rv, WindowPtr window)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002438 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2439 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002440
Jack Jansen74a1e632000-07-14 22:37:27 +00002441#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002442 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2443 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002444#endif
2445
Jack Jansen74a1e632000-07-14 22:37:27 +00002446#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002447 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2448 "() -> (GrafPtr wPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002449#endif
2450
Jack Jansen74a1e632000-07-14 22:37:27 +00002451#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002452 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2453 "() -> (CGrafPtr wMgrCPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002454#endif
2455
Jack Jansen74a1e632000-07-14 22:37:27 +00002456#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002457 {"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1,
2458 "(GrafPtr grafPort) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002459#endif
2460
Jack Jansen74a1e632000-07-14 22:37:27 +00002461#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002462 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2463 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002464#endif
2465
Jack Jansen74a1e632000-07-14 22:37:27 +00002466#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002467 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2468 "(Rect badRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002469#endif
2470
Jack Jansen74a1e632000-07-14 22:37:27 +00002471#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002472 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2473 "(RgnHandle badRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002474#endif
2475
Jack Jansen74a1e632000-07-14 22:37:27 +00002476#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002477 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2478 "(Rect goodRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002479#endif
2480
Jack Jansen74a1e632000-07-14 22:37:27 +00002481#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002482 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2483 "(RgnHandle goodRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002484#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002485 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002486 "(Boolean collapse) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002487 {"PinRect", (PyCFunction)Win_PinRect, 1,
2488 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002489 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2490 "() -> (RgnHandle _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00002491 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2492 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00002493 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2494 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002495 {NULL, NULL, 0}
2496};
2497
2498
2499
2500/* Return the object corresponding to the window, or NULL */
2501
2502PyObject *
2503WinObj_WhichWindow(w)
2504 WindowPtr w;
2505{
2506 PyObject *it;
2507
Jack Jansen0aee0e62000-08-25 22:17:51 +00002508 if (w == NULL) {
Guido van Rossum17448e21995-01-30 11:53:55 +00002509 it = Py_None;
Jack Jansen0aee0e62000-08-25 22:17:51 +00002510 Py_INCREF(it);
2511 } else {
2512 it = (PyObject *) GetWRefCon(w);
2513 if (it == NULL || ((WindowObject *)it)->ob_itself != w) {
2514 it = WinObj_New(w);
2515 ((WindowObject *)it)->ob_freeit = NULL;
2516 } else {
2517 Py_INCREF(it);
2518 }
2519 }
Guido van Rossum17448e21995-01-30 11:53:55 +00002520 return it;
2521}
2522
2523
2524void initWin()
2525{
2526 PyObject *m;
2527 PyObject *d;
2528
2529
2530
2531
2532 m = Py_InitModule("Win", Win_methods);
2533 d = PyModule_GetDict(m);
2534 Win_Error = PyMac_GetOSErrException();
2535 if (Win_Error == NULL ||
2536 PyDict_SetItemString(d, "Error", Win_Error) != 0)
2537 Py_FatalError("can't initialize Win.Error");
Jack Jansena755e681997-09-20 17:40:22 +00002538 Window_Type.ob_type = &PyType_Type;
2539 Py_INCREF(&Window_Type);
2540 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2541 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002542}
2543
2544/* ========================= End module Win ========================= */
2545