blob: 4dce0e8f2e47bff44b78637fbcc14031f3ed6b34 [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 Jansen723ad8a2000-12-12 22:10:21 +000012
13#if !ACCESSOR_CALLS_ARE_FUNCTIONS
14#define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
15#define GetWindowFromPort(port) ((WindowRef)(port))
16#define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
17#endif
18
Jack Jansen0aee0e62000-08-25 22:17:51 +000019/* Function to dispose a window, with a "normal" calling sequence */
20static void
21PyMac_AutoDisposeWindow(WindowPtr w)
22{
23 DisposeWindow(w);
24}
Guido van Rossum17448e21995-01-30 11:53:55 +000025
Guido van Rossum17448e21995-01-30 11:53:55 +000026static PyObject *Win_Error;
27
28/* ----------------------- Object type Window ----------------------- */
29
30PyTypeObject Window_Type;
31
32#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
33
34typedef struct WindowObject {
35 PyObject_HEAD
36 WindowPtr ob_itself;
Jack Jansen0aee0e62000-08-25 22:17:51 +000037 void (*ob_freeit)(WindowPtr ptr);
Guido van Rossum17448e21995-01-30 11:53:55 +000038} WindowObject;
39
40PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000041 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000042{
43 WindowObject *it;
44 if (itself == NULL) return PyMac_Error(resNotFound);
45 it = PyObject_NEW(WindowObject, &Window_Type);
46 if (it == NULL) return NULL;
47 it->ob_itself = itself;
Jack Jansen80716f02000-12-14 22:29:00 +000048 it->ob_freeit = NULL;
49 if (GetWRefCon(itself) == 0)
50 {
51 SetWRefCon(itself, (long)it);
52 it->ob_freeit = PyMac_AutoDisposeWindow;
53 }
Guido van Rossum17448e21995-01-30 11:53:55 +000054 return (PyObject *)it;
55}
56WinObj_Convert(v, p_itself)
57 PyObject *v;
58 WindowPtr *p_itself;
59{
60 if (DlgObj_Check(v)) {
Jack Jansen723ad8a2000-12-12 22:10:21 +000061 *p_itself = DlgObj_ConvertToWindow(v);
Guido van Rossum17448e21995-01-30 11:53:55 +000062 return 1;
63 }
64
65 if (v == Py_None) { *p_itself = NULL; return 1; }
66 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
67
68 if (!WinObj_Check(v))
69 {
70 PyErr_SetString(PyExc_TypeError, "Window required");
71 return 0;
72 }
73 *p_itself = ((WindowObject *)v)->ob_itself;
74 return 1;
75}
76
77static void WinObj_dealloc(self)
78 WindowObject *self;
79{
Jack Jansen0aee0e62000-08-25 22:17:51 +000080 if (self->ob_freeit && self->ob_itself)
81 {
Jack Jansen80716f02000-12-14 22:29:00 +000082 SetWRefCon(self->ob_itself, 0);
Jack Jansen0aee0e62000-08-25 22:17:51 +000083 self->ob_freeit(self->ob_itself);
84 }
85 self->ob_itself = NULL;
Jack Jansen80716f02000-12-14 22:29:00 +000086 self->ob_freeit = NULL;
Guido van Rossum17448e21995-01-30 11:53:55 +000087 PyMem_DEL(self);
88}
89
Jack Jansena05ac601999-12-12 21:41:51 +000090static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
91 WindowObject *_self;
92 PyObject *_args;
93{
94 PyObject *_res = NULL;
95 OSStatus _err;
96 UInt32 outCount;
97 if (!PyArg_ParseTuple(_args, ""))
98 return NULL;
99 _err = GetWindowOwnerCount(_self->ob_itself,
100 &outCount);
101 if (_err != noErr) return PyMac_Error(_err);
102 _res = Py_BuildValue("l",
103 outCount);
104 return _res;
105}
106
107static PyObject *WinObj_CloneWindow(_self, _args)
108 WindowObject *_self;
109 PyObject *_args;
110{
111 PyObject *_res = NULL;
112 OSStatus _err;
113 if (!PyArg_ParseTuple(_args, ""))
114 return NULL;
115 _err = CloneWindow(_self->ob_itself);
116 if (_err != noErr) return PyMac_Error(_err);
117 Py_INCREF(Py_None);
118 _res = Py_None;
119 return _res;
120}
121
Jack Jansen723ad8a2000-12-12 22:10:21 +0000122#if TARGET_API_MAC_CARBON
123
124static PyObject *WinObj_ReshapeCustomWindow(_self, _args)
125 WindowObject *_self;
126 PyObject *_args;
127{
128 PyObject *_res = NULL;
129 OSStatus _err;
130 if (!PyArg_ParseTuple(_args, ""))
131 return NULL;
132 _err = ReshapeCustomWindow(_self->ob_itself);
133 if (_err != noErr) return PyMac_Error(_err);
134 Py_INCREF(Py_None);
135 _res = Py_None;
136 return _res;
137}
138#endif
139
Jack Jansena05ac601999-12-12 21:41:51 +0000140static PyObject *WinObj_GetWindowClass(_self, _args)
141 WindowObject *_self;
142 PyObject *_args;
143{
144 PyObject *_res = NULL;
145 OSStatus _err;
146 WindowClass outClass;
147 if (!PyArg_ParseTuple(_args, ""))
148 return NULL;
149 _err = GetWindowClass(_self->ob_itself,
150 &outClass);
151 if (_err != noErr) return PyMac_Error(_err);
152 _res = Py_BuildValue("l",
153 outClass);
154 return _res;
155}
156
157static PyObject *WinObj_GetWindowAttributes(_self, _args)
158 WindowObject *_self;
159 PyObject *_args;
160{
161 PyObject *_res = NULL;
162 OSStatus _err;
163 WindowAttributes outAttributes;
164 if (!PyArg_ParseTuple(_args, ""))
165 return NULL;
166 _err = GetWindowAttributes(_self->ob_itself,
167 &outAttributes);
168 if (_err != noErr) return PyMac_Error(_err);
169 _res = Py_BuildValue("l",
170 outAttributes);
171 return _res;
172}
173
Jack Jansen723ad8a2000-12-12 22:10:21 +0000174#if TARGET_API_MAC_CARBON
175
176static PyObject *WinObj_ChangeWindowAttributes(_self, _args)
177 WindowObject *_self;
178 PyObject *_args;
179{
180 PyObject *_res = NULL;
181 OSStatus _err;
182 WindowAttributes setTheseAttributes;
183 WindowAttributes clearTheseAttributes;
184 if (!PyArg_ParseTuple(_args, "ll",
185 &setTheseAttributes,
186 &clearTheseAttributes))
187 return NULL;
188 _err = ChangeWindowAttributes(_self->ob_itself,
189 setTheseAttributes,
190 clearTheseAttributes);
191 if (_err != noErr) return PyMac_Error(_err);
192 Py_INCREF(Py_None);
193 _res = Py_None;
194 return _res;
195}
196#endif
197
Jack Jansen74a1e632000-07-14 22:37:27 +0000198#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000199
Jack Jansen21f96871998-02-20 16:02:09 +0000200static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000201 WindowObject *_self;
202 PyObject *_args;
203{
204 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000205 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000206 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000207 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000208 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000209 SetWinColor(_self->ob_itself,
210 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000211 Py_INCREF(Py_None);
212 _res = Py_None;
213 return _res;
214}
Jack Jansene79dc762000-06-02 21:35:07 +0000215#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000216
Jack Jansena05ac601999-12-12 21:41:51 +0000217static PyObject *WinObj_SetWindowContentColor(_self, _args)
218 WindowObject *_self;
219 PyObject *_args;
220{
221 PyObject *_res = NULL;
222 OSStatus _err;
223 RGBColor color;
Jack Jansen723ad8a2000-12-12 22:10:21 +0000224 if (!PyArg_ParseTuple(_args, "O&",
225 QdRGB_Convert, &color))
Jack Jansena05ac601999-12-12 21:41:51 +0000226 return NULL;
227 _err = SetWindowContentColor(_self->ob_itself,
228 &color);
229 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen723ad8a2000-12-12 22:10:21 +0000230 Py_INCREF(Py_None);
231 _res = Py_None;
Jack Jansena05ac601999-12-12 21:41:51 +0000232 return _res;
233}
234
235static PyObject *WinObj_GetWindowContentColor(_self, _args)
236 WindowObject *_self;
237 PyObject *_args;
238{
239 PyObject *_res = NULL;
240 OSStatus _err;
241 RGBColor color;
242 if (!PyArg_ParseTuple(_args, ""))
243 return NULL;
244 _err = GetWindowContentColor(_self->ob_itself,
245 &color);
246 if (_err != noErr) return PyMac_Error(_err);
247 _res = Py_BuildValue("O&",
248 QdRGB_New, &color);
249 return _res;
250}
251
252static PyObject *WinObj_GetWindowContentPattern(_self, _args)
253 WindowObject *_self;
254 PyObject *_args;
255{
256 PyObject *_res = NULL;
257 OSStatus _err;
258 PixPatHandle outPixPat;
259 if (!PyArg_ParseTuple(_args, "O&",
260 ResObj_Convert, &outPixPat))
261 return NULL;
262 _err = GetWindowContentPattern(_self->ob_itself,
263 outPixPat);
264 if (_err != noErr) return PyMac_Error(_err);
265 Py_INCREF(Py_None);
266 _res = Py_None;
267 return _res;
268}
269
270static PyObject *WinObj_SetWindowContentPattern(_self, _args)
271 WindowObject *_self;
272 PyObject *_args;
273{
274 PyObject *_res = NULL;
275 OSStatus _err;
276 PixPatHandle pixPat;
277 if (!PyArg_ParseTuple(_args, "O&",
278 ResObj_Convert, &pixPat))
279 return NULL;
280 _err = SetWindowContentPattern(_self->ob_itself,
281 pixPat);
282 if (_err != noErr) return PyMac_Error(_err);
283 Py_INCREF(Py_None);
284 _res = Py_None;
285 return _res;
286}
287
Jack Jansen723ad8a2000-12-12 22:10:21 +0000288#if TARGET_API_MAC_CARBON
289
290static PyObject *WinObj_ScrollWindowRect(_self, _args)
291 WindowObject *_self;
292 PyObject *_args;
293{
294 PyObject *_res = NULL;
295 OSStatus _err;
296 Rect inScrollRect;
297 SInt16 inHPixels;
298 SInt16 inVPixels;
299 ScrollWindowOptions inOptions;
300 RgnHandle outExposedRgn;
301 if (!PyArg_ParseTuple(_args, "O&hhlO&",
302 PyMac_GetRect, &inScrollRect,
303 &inHPixels,
304 &inVPixels,
305 &inOptions,
306 ResObj_Convert, &outExposedRgn))
307 return NULL;
308 _err = ScrollWindowRect(_self->ob_itself,
309 &inScrollRect,
310 inHPixels,
311 inVPixels,
312 inOptions,
313 outExposedRgn);
314 if (_err != noErr) return PyMac_Error(_err);
315 Py_INCREF(Py_None);
316 _res = Py_None;
317 return _res;
318}
319#endif
320
321#if TARGET_API_MAC_CARBON
322
323static PyObject *WinObj_ScrollWindowRegion(_self, _args)
324 WindowObject *_self;
325 PyObject *_args;
326{
327 PyObject *_res = NULL;
328 OSStatus _err;
329 RgnHandle inScrollRgn;
330 SInt16 inHPixels;
331 SInt16 inVPixels;
332 ScrollWindowOptions inOptions;
333 RgnHandle outExposedRgn;
334 if (!PyArg_ParseTuple(_args, "O&hhlO&",
335 ResObj_Convert, &inScrollRgn,
336 &inHPixels,
337 &inVPixels,
338 &inOptions,
339 ResObj_Convert, &outExposedRgn))
340 return NULL;
341 _err = ScrollWindowRegion(_self->ob_itself,
342 inScrollRgn,
343 inHPixels,
344 inVPixels,
345 inOptions,
346 outExposedRgn);
347 if (_err != noErr) return PyMac_Error(_err);
348 Py_INCREF(Py_None);
349 _res = Py_None;
350 return _res;
351}
352#endif
353
Guido van Rossum17448e21995-01-30 11:53:55 +0000354static PyObject *WinObj_ClipAbove(_self, _args)
355 WindowObject *_self;
356 PyObject *_args;
357{
358 PyObject *_res = NULL;
359 if (!PyArg_ParseTuple(_args, ""))
360 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000361 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000362 Py_INCREF(Py_None);
363 _res = Py_None;
364 return _res;
365}
366
Jack Jansen74a1e632000-07-14 22:37:27 +0000367#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000368
Guido van Rossum17448e21995-01-30 11:53:55 +0000369static PyObject *WinObj_SaveOld(_self, _args)
370 WindowObject *_self;
371 PyObject *_args;
372{
373 PyObject *_res = NULL;
374 if (!PyArg_ParseTuple(_args, ""))
375 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000376 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000377 Py_INCREF(Py_None);
378 _res = Py_None;
379 return _res;
380}
Jack Jansene79dc762000-06-02 21:35:07 +0000381#endif
382
Jack Jansen74a1e632000-07-14 22:37:27 +0000383#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000384
385static PyObject *WinObj_DrawNew(_self, _args)
386 WindowObject *_self;
387 PyObject *_args;
388{
389 PyObject *_res = NULL;
390 Boolean update;
391 if (!PyArg_ParseTuple(_args, "b",
392 &update))
393 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000394 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000395 update);
396 Py_INCREF(Py_None);
397 _res = Py_None;
398 return _res;
399}
Jack Jansene79dc762000-06-02 21:35:07 +0000400#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000401
Jack Jansen80716f02000-12-14 22:29:00 +0000402static PyObject *WinObj_PaintOne(_self, _args)
403 WindowObject *_self;
404 PyObject *_args;
405{
406 PyObject *_res = NULL;
407 RgnHandle clobberedRgn;
408 if (!PyArg_ParseTuple(_args, "O&",
409 ResObj_Convert, &clobberedRgn))
410 return NULL;
411 PaintOne(_self->ob_itself,
412 clobberedRgn);
413 Py_INCREF(Py_None);
414 _res = Py_None;
415 return _res;
416}
417
418static PyObject *WinObj_PaintBehind(_self, _args)
419 WindowObject *_self;
420 PyObject *_args;
421{
422 PyObject *_res = NULL;
423 RgnHandle clobberedRgn;
424 if (!PyArg_ParseTuple(_args, "O&",
425 ResObj_Convert, &clobberedRgn))
426 return NULL;
427 PaintBehind(_self->ob_itself,
428 clobberedRgn);
429 Py_INCREF(Py_None);
430 _res = Py_None;
431 return _res;
432}
433
Guido van Rossum17448e21995-01-30 11:53:55 +0000434static PyObject *WinObj_CalcVis(_self, _args)
435 WindowObject *_self;
436 PyObject *_args;
437{
438 PyObject *_res = NULL;
439 if (!PyArg_ParseTuple(_args, ""))
440 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000441 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000442 Py_INCREF(Py_None);
443 _res = Py_None;
444 return _res;
445}
446
Jack Jansen80716f02000-12-14 22:29:00 +0000447static PyObject *WinObj_CalcVisBehind(_self, _args)
448 WindowObject *_self;
449 PyObject *_args;
450{
451 PyObject *_res = NULL;
452 RgnHandle clobberedRgn;
453 if (!PyArg_ParseTuple(_args, "O&",
454 ResObj_Convert, &clobberedRgn))
455 return NULL;
456 CalcVisBehind(_self->ob_itself,
457 clobberedRgn);
458 Py_INCREF(Py_None);
459 _res = Py_None;
460 return _res;
461}
462
Jack Jansen21f96871998-02-20 16:02:09 +0000463static PyObject *WinObj_BringToFront(_self, _args)
464 WindowObject *_self;
465 PyObject *_args;
466{
467 PyObject *_res = NULL;
468 if (!PyArg_ParseTuple(_args, ""))
469 return NULL;
470 BringToFront(_self->ob_itself);
471 Py_INCREF(Py_None);
472 _res = Py_None;
473 return _res;
474}
475
476static PyObject *WinObj_SendBehind(_self, _args)
477 WindowObject *_self;
478 PyObject *_args;
479{
480 PyObject *_res = NULL;
481 WindowPtr behindWindow;
482 if (!PyArg_ParseTuple(_args, "O&",
483 WinObj_Convert, &behindWindow))
484 return NULL;
485 SendBehind(_self->ob_itself,
486 behindWindow);
487 Py_INCREF(Py_None);
488 _res = Py_None;
489 return _res;
490}
491
492static PyObject *WinObj_SelectWindow(_self, _args)
493 WindowObject *_self;
494 PyObject *_args;
495{
496 PyObject *_res = NULL;
497 if (!PyArg_ParseTuple(_args, ""))
498 return NULL;
499 SelectWindow(_self->ob_itself);
500 Py_INCREF(Py_None);
501 _res = Py_None;
502 return _res;
503}
504
Jack Jansen723ad8a2000-12-12 22:10:21 +0000505#if TARGET_API_MAC_CARBON
506
507static PyObject *WinObj_GetNextWindowOfClass(_self, _args)
508 WindowObject *_self;
509 PyObject *_args;
510{
511 PyObject *_res = NULL;
512 WindowPtr _rv;
513 WindowClass inWindowClass;
514 Boolean mustBeVisible;
515 if (!PyArg_ParseTuple(_args, "lb",
516 &inWindowClass,
517 &mustBeVisible))
518 return NULL;
519 _rv = GetNextWindowOfClass(_self->ob_itself,
520 inWindowClass,
521 mustBeVisible);
522 _res = Py_BuildValue("O&",
523 WinObj_New, _rv);
524 return _res;
525}
526#endif
527
528#if !TARGET_API_MAC_CARBON
529
530static PyObject *WinObj_IsValidWindowPtr(_self, _args)
531 WindowObject *_self;
532 PyObject *_args;
533{
534 PyObject *_res = NULL;
535 Boolean _rv;
536 if (!PyArg_ParseTuple(_args, ""))
537 return NULL;
538 _rv = IsValidWindowPtr(_self->ob_itself);
539 _res = Py_BuildValue("b",
540 _rv);
541 return _res;
542}
543#endif
544
Jack Jansen1c4e6141998-04-21 15:23:55 +0000545static PyObject *WinObj_HiliteWindow(_self, _args)
546 WindowObject *_self;
547 PyObject *_args;
548{
549 PyObject *_res = NULL;
550 Boolean fHilite;
551 if (!PyArg_ParseTuple(_args, "b",
552 &fHilite))
553 return NULL;
554 HiliteWindow(_self->ob_itself,
555 fHilite);
556 Py_INCREF(Py_None);
557 _res = Py_None;
558 return _res;
559}
560
Jack Jansen21f96871998-02-20 16:02:09 +0000561static PyObject *WinObj_SetWRefCon(_self, _args)
562 WindowObject *_self;
563 PyObject *_args;
564{
565 PyObject *_res = NULL;
566 long data;
567 if (!PyArg_ParseTuple(_args, "l",
568 &data))
569 return NULL;
570 SetWRefCon(_self->ob_itself,
571 data);
572 Py_INCREF(Py_None);
573 _res = Py_None;
574 return _res;
575}
576
577static PyObject *WinObj_GetWRefCon(_self, _args)
578 WindowObject *_self;
579 PyObject *_args;
580{
581 PyObject *_res = NULL;
582 long _rv;
583 if (!PyArg_ParseTuple(_args, ""))
584 return NULL;
585 _rv = GetWRefCon(_self->ob_itself);
586 _res = Py_BuildValue("l",
587 _rv);
588 return _res;
589}
590
591static PyObject *WinObj_SetWindowPic(_self, _args)
592 WindowObject *_self;
593 PyObject *_args;
594{
595 PyObject *_res = NULL;
596 PicHandle pic;
597 if (!PyArg_ParseTuple(_args, "O&",
598 ResObj_Convert, &pic))
599 return NULL;
600 SetWindowPic(_self->ob_itself,
601 pic);
602 Py_INCREF(Py_None);
603 _res = Py_None;
604 return _res;
605}
606
607static PyObject *WinObj_GetWindowPic(_self, _args)
608 WindowObject *_self;
609 PyObject *_args;
610{
611 PyObject *_res = NULL;
612 PicHandle _rv;
613 if (!PyArg_ParseTuple(_args, ""))
614 return NULL;
615 _rv = GetWindowPic(_self->ob_itself);
616 _res = Py_BuildValue("O&",
617 ResObj_New, _rv);
618 return _res;
619}
620
621static PyObject *WinObj_GetWVariant(_self, _args)
622 WindowObject *_self;
623 PyObject *_args;
624{
625 PyObject *_res = NULL;
626 short _rv;
627 if (!PyArg_ParseTuple(_args, ""))
628 return NULL;
629 _rv = GetWVariant(_self->ob_itself);
630 _res = Py_BuildValue("h",
631 _rv);
632 return _res;
633}
634
Jack Jansena05ac601999-12-12 21:41:51 +0000635static PyObject *WinObj_GetWindowFeatures(_self, _args)
636 WindowObject *_self;
637 PyObject *_args;
638{
639 PyObject *_res = NULL;
640 OSStatus _err;
641 UInt32 outFeatures;
642 if (!PyArg_ParseTuple(_args, ""))
643 return NULL;
644 _err = GetWindowFeatures(_self->ob_itself,
645 &outFeatures);
646 if (_err != noErr) return PyMac_Error(_err);
647 _res = Py_BuildValue("l",
648 outFeatures);
649 return _res;
650}
651
652static PyObject *WinObj_GetWindowRegion(_self, _args)
653 WindowObject *_self;
654 PyObject *_args;
655{
656 PyObject *_res = NULL;
657 OSStatus _err;
658 WindowRegionCode inRegionCode;
659 RgnHandle ioWinRgn;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000660 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +0000661 &inRegionCode,
662 ResObj_Convert, &ioWinRgn))
663 return NULL;
664 _err = GetWindowRegion(_self->ob_itself,
665 inRegionCode,
666 ioWinRgn);
667 if (_err != noErr) return PyMac_Error(_err);
668 Py_INCREF(Py_None);
669 _res = Py_None;
670 return _res;
671}
672
Jack Jansen21f96871998-02-20 16:02:09 +0000673static PyObject *WinObj_BeginUpdate(_self, _args)
674 WindowObject *_self;
675 PyObject *_args;
676{
677 PyObject *_res = NULL;
678 if (!PyArg_ParseTuple(_args, ""))
679 return NULL;
680 BeginUpdate(_self->ob_itself);
681 Py_INCREF(Py_None);
682 _res = Py_None;
683 return _res;
684}
685
686static PyObject *WinObj_EndUpdate(_self, _args)
687 WindowObject *_self;
688 PyObject *_args;
689{
690 PyObject *_res = NULL;
691 if (!PyArg_ParseTuple(_args, ""))
692 return NULL;
693 EndUpdate(_self->ob_itself);
694 Py_INCREF(Py_None);
695 _res = Py_None;
696 return _res;
697}
698
Jack Jansena05ac601999-12-12 21:41:51 +0000699static PyObject *WinObj_InvalWindowRgn(_self, _args)
700 WindowObject *_self;
701 PyObject *_args;
702{
703 PyObject *_res = NULL;
704 OSStatus _err;
705 RgnHandle region;
706 if (!PyArg_ParseTuple(_args, "O&",
707 ResObj_Convert, &region))
708 return NULL;
709 _err = InvalWindowRgn(_self->ob_itself,
710 region);
711 if (_err != noErr) return PyMac_Error(_err);
712 Py_INCREF(Py_None);
713 _res = Py_None;
714 return _res;
715}
716
717static PyObject *WinObj_InvalWindowRect(_self, _args)
718 WindowObject *_self;
719 PyObject *_args;
720{
721 PyObject *_res = NULL;
722 OSStatus _err;
723 Rect bounds;
724 if (!PyArg_ParseTuple(_args, "O&",
725 PyMac_GetRect, &bounds))
726 return NULL;
727 _err = InvalWindowRect(_self->ob_itself,
728 &bounds);
729 if (_err != noErr) return PyMac_Error(_err);
730 Py_INCREF(Py_None);
731 _res = Py_None;
732 return _res;
733}
734
735static PyObject *WinObj_ValidWindowRgn(_self, _args)
736 WindowObject *_self;
737 PyObject *_args;
738{
739 PyObject *_res = NULL;
740 OSStatus _err;
741 RgnHandle region;
742 if (!PyArg_ParseTuple(_args, "O&",
743 ResObj_Convert, &region))
744 return NULL;
745 _err = ValidWindowRgn(_self->ob_itself,
746 region);
747 if (_err != noErr) return PyMac_Error(_err);
748 Py_INCREF(Py_None);
749 _res = Py_None;
750 return _res;
751}
752
753static PyObject *WinObj_ValidWindowRect(_self, _args)
754 WindowObject *_self;
755 PyObject *_args;
756{
757 PyObject *_res = NULL;
758 OSStatus _err;
759 Rect bounds;
760 if (!PyArg_ParseTuple(_args, "O&",
761 PyMac_GetRect, &bounds))
762 return NULL;
763 _err = ValidWindowRect(_self->ob_itself,
764 &bounds);
765 if (_err != noErr) return PyMac_Error(_err);
766 Py_INCREF(Py_None);
767 _res = Py_None;
768 return _res;
769}
770
Jack Jansen21f96871998-02-20 16:02:09 +0000771static PyObject *WinObj_DrawGrowIcon(_self, _args)
772 WindowObject *_self;
773 PyObject *_args;
774{
775 PyObject *_res = NULL;
776 if (!PyArg_ParseTuple(_args, ""))
777 return NULL;
778 DrawGrowIcon(_self->ob_itself);
779 Py_INCREF(Py_None);
780 _res = Py_None;
781 return _res;
782}
783
Jack Jansen21f96871998-02-20 16:02:09 +0000784static PyObject *WinObj_SetWTitle(_self, _args)
785 WindowObject *_self;
786 PyObject *_args;
787{
788 PyObject *_res = NULL;
789 Str255 title;
790 if (!PyArg_ParseTuple(_args, "O&",
791 PyMac_GetStr255, title))
792 return NULL;
793 SetWTitle(_self->ob_itself,
794 title);
795 Py_INCREF(Py_None);
796 _res = Py_None;
797 return _res;
798}
799
800static PyObject *WinObj_GetWTitle(_self, _args)
801 WindowObject *_self;
802 PyObject *_args;
803{
804 PyObject *_res = NULL;
805 Str255 title;
806 if (!PyArg_ParseTuple(_args, ""))
807 return NULL;
808 GetWTitle(_self->ob_itself,
809 title);
810 _res = Py_BuildValue("O&",
811 PyMac_BuildStr255, title);
812 return _res;
813}
814
Jack Jansena05ac601999-12-12 21:41:51 +0000815static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000816 WindowObject *_self;
817 PyObject *_args;
818{
819 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000820 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +0000821 FSSpec inFile;
822 if (!PyArg_ParseTuple(_args, "O&",
823 PyMac_GetFSSpec, &inFile))
Jack Jansen21f96871998-02-20 16:02:09 +0000824 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +0000825 _err = SetWindowProxyFSSpec(_self->ob_itself,
826 &inFile);
827 if (_err != noErr) return PyMac_Error(_err);
828 Py_INCREF(Py_None);
829 _res = Py_None;
830 return _res;
831}
832
833static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
834 WindowObject *_self;
835 PyObject *_args;
836{
837 PyObject *_res = NULL;
838 OSStatus _err;
839 FSSpec outFile;
840 if (!PyArg_ParseTuple(_args, ""))
841 return NULL;
842 _err = GetWindowProxyFSSpec(_self->ob_itself,
843 &outFile);
844 if (_err != noErr) return PyMac_Error(_err);
845 _res = Py_BuildValue("O&",
Jack Jansene79dc762000-06-02 21:35:07 +0000846 PyMac_BuildFSSpec, outFile);
Jack Jansena05ac601999-12-12 21:41:51 +0000847 return _res;
848}
849
850static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
851 WindowObject *_self;
852 PyObject *_args;
853{
854 PyObject *_res = NULL;
855 OSStatus _err;
856 AliasHandle alias;
857 if (!PyArg_ParseTuple(_args, "O&",
858 ResObj_Convert, &alias))
859 return NULL;
860 _err = SetWindowProxyAlias(_self->ob_itself,
861 alias);
862 if (_err != noErr) return PyMac_Error(_err);
863 Py_INCREF(Py_None);
864 _res = Py_None;
865 return _res;
866}
867
868static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
869 WindowObject *_self;
870 PyObject *_args;
871{
872 PyObject *_res = NULL;
873 OSStatus _err;
874 AliasHandle alias;
875 if (!PyArg_ParseTuple(_args, ""))
876 return NULL;
877 _err = GetWindowProxyAlias(_self->ob_itself,
878 &alias);
879 if (_err != noErr) return PyMac_Error(_err);
880 _res = Py_BuildValue("O&",
881 ResObj_New, alias);
882 return _res;
883}
884
885static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
886 WindowObject *_self;
887 PyObject *_args;
888{
889 PyObject *_res = NULL;
890 OSStatus _err;
891 OSType fileCreator;
892 OSType fileType;
893 SInt16 vRefNum;
894 if (!PyArg_ParseTuple(_args, "O&O&h",
895 PyMac_GetOSType, &fileCreator,
896 PyMac_GetOSType, &fileType,
897 &vRefNum))
898 return NULL;
899 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
900 fileCreator,
901 fileType,
902 vRefNum);
903 if (_err != noErr) return PyMac_Error(_err);
904 Py_INCREF(Py_None);
905 _res = Py_None;
906 return _res;
907}
908
909static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
910 WindowObject *_self;
911 PyObject *_args;
912{
913 PyObject *_res = NULL;
914 OSStatus _err;
915 IconRef outIcon;
916 if (!PyArg_ParseTuple(_args, ""))
917 return NULL;
918 _err = GetWindowProxyIcon(_self->ob_itself,
919 &outIcon);
920 if (_err != noErr) return PyMac_Error(_err);
921 _res = Py_BuildValue("O&",
922 ResObj_New, outIcon);
923 return _res;
924}
925
926static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
927 WindowObject *_self;
928 PyObject *_args;
929{
930 PyObject *_res = NULL;
931 OSStatus _err;
932 IconRef icon;
933 if (!PyArg_ParseTuple(_args, "O&",
934 ResObj_Convert, &icon))
935 return NULL;
936 _err = SetWindowProxyIcon(_self->ob_itself,
937 icon);
938 if (_err != noErr) return PyMac_Error(_err);
939 Py_INCREF(Py_None);
940 _res = Py_None;
941 return _res;
942}
943
944static PyObject *WinObj_RemoveWindowProxy(_self, _args)
945 WindowObject *_self;
946 PyObject *_args;
947{
948 PyObject *_res = NULL;
949 OSStatus _err;
950 if (!PyArg_ParseTuple(_args, ""))
951 return NULL;
952 _err = RemoveWindowProxy(_self->ob_itself);
953 if (_err != noErr) return PyMac_Error(_err);
954 Py_INCREF(Py_None);
955 _res = Py_None;
956 return _res;
957}
958
Jack Jansen723ad8a2000-12-12 22:10:21 +0000959static PyObject *WinObj_BeginWindowProxyDrag(_self, _args)
960 WindowObject *_self;
961 PyObject *_args;
962{
963 PyObject *_res = NULL;
964 OSStatus _err;
965 DragReference outNewDrag;
966 RgnHandle outDragOutlineRgn;
967 if (!PyArg_ParseTuple(_args, "O&",
968 ResObj_Convert, &outDragOutlineRgn))
969 return NULL;
970 _err = BeginWindowProxyDrag(_self->ob_itself,
971 &outNewDrag,
972 outDragOutlineRgn);
973 if (_err != noErr) return PyMac_Error(_err);
974 _res = Py_BuildValue("O&",
975 DragObj_New, outNewDrag);
976 return _res;
977}
978
979static PyObject *WinObj_EndWindowProxyDrag(_self, _args)
980 WindowObject *_self;
981 PyObject *_args;
982{
983 PyObject *_res = NULL;
984 OSStatus _err;
985 DragReference theDrag;
986 if (!PyArg_ParseTuple(_args, "O&",
987 DragObj_Convert, &theDrag))
988 return NULL;
989 _err = EndWindowProxyDrag(_self->ob_itself,
990 theDrag);
991 if (_err != noErr) return PyMac_Error(_err);
992 Py_INCREF(Py_None);
993 _res = Py_None;
994 return _res;
995}
996
997static PyObject *WinObj_TrackWindowProxyFromExistingDrag(_self, _args)
998 WindowObject *_self;
999 PyObject *_args;
1000{
1001 PyObject *_res = NULL;
1002 OSStatus _err;
1003 Point startPt;
1004 DragReference drag;
1005 RgnHandle inDragOutlineRgn;
1006 if (!PyArg_ParseTuple(_args, "O&O&O&",
1007 PyMac_GetPoint, &startPt,
1008 DragObj_Convert, &drag,
1009 ResObj_Convert, &inDragOutlineRgn))
1010 return NULL;
1011 _err = TrackWindowProxyFromExistingDrag(_self->ob_itself,
1012 startPt,
1013 drag,
1014 inDragOutlineRgn);
1015 if (_err != noErr) return PyMac_Error(_err);
1016 Py_INCREF(Py_None);
1017 _res = Py_None;
1018 return _res;
1019}
1020
Jack Jansena05ac601999-12-12 21:41:51 +00001021static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
1022 WindowObject *_self;
1023 PyObject *_args;
1024{
1025 PyObject *_res = NULL;
1026 OSStatus _err;
1027 Point startPt;
1028 if (!PyArg_ParseTuple(_args, "O&",
1029 PyMac_GetPoint, &startPt))
1030 return NULL;
1031 _err = TrackWindowProxyDrag(_self->ob_itself,
1032 startPt);
1033 if (_err != noErr) return PyMac_Error(_err);
1034 Py_INCREF(Py_None);
1035 _res = Py_None;
1036 return _res;
1037}
1038
1039static PyObject *WinObj_IsWindowModified(_self, _args)
1040 WindowObject *_self;
1041 PyObject *_args;
1042{
1043 PyObject *_res = NULL;
1044 Boolean _rv;
1045 if (!PyArg_ParseTuple(_args, ""))
1046 return NULL;
1047 _rv = IsWindowModified(_self->ob_itself);
1048 _res = Py_BuildValue("b",
1049 _rv);
1050 return _res;
1051}
1052
1053static PyObject *WinObj_SetWindowModified(_self, _args)
1054 WindowObject *_self;
1055 PyObject *_args;
1056{
1057 PyObject *_res = NULL;
1058 OSStatus _err;
1059 Boolean modified;
1060 if (!PyArg_ParseTuple(_args, "b",
1061 &modified))
1062 return NULL;
1063 _err = SetWindowModified(_self->ob_itself,
1064 modified);
1065 if (_err != noErr) return PyMac_Error(_err);
1066 Py_INCREF(Py_None);
1067 _res = Py_None;
1068 return _res;
1069}
1070
1071static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
1072 WindowObject *_self;
1073 PyObject *_args;
1074{
1075 PyObject *_res = NULL;
1076 Boolean _rv;
1077 EventRecord event;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001078 if (!PyArg_ParseTuple(_args, "O&",
1079 PyMac_GetEventRecord, &event))
Jack Jansena05ac601999-12-12 21:41:51 +00001080 return NULL;
1081 _rv = IsWindowPathSelectClick(_self->ob_itself,
1082 &event);
Jack Jansen723ad8a2000-12-12 22:10:21 +00001083 _res = Py_BuildValue("b",
1084 _rv);
Jack Jansena05ac601999-12-12 21:41:51 +00001085 return _res;
1086}
1087
Jack Jansen80716f02000-12-14 22:29:00 +00001088static PyObject *WinObj_WindowPathSelect(_self, _args)
1089 WindowObject *_self;
1090 PyObject *_args;
1091{
1092 PyObject *_res = NULL;
1093 OSStatus _err;
1094 MenuHandle menu;
1095 SInt32 outMenuResult;
1096 if (!PyArg_ParseTuple(_args, "O&",
1097 MenuObj_Convert, &menu))
1098 return NULL;
1099 _err = WindowPathSelect(_self->ob_itself,
1100 menu,
1101 &outMenuResult);
1102 if (_err != noErr) return PyMac_Error(_err);
1103 _res = Py_BuildValue("l",
1104 outMenuResult);
1105 return _res;
1106}
1107
Jack Jansena05ac601999-12-12 21:41:51 +00001108static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
1109 WindowObject *_self;
1110 PyObject *_args;
1111{
1112 PyObject *_res = NULL;
1113 OSStatus _err;
1114 Boolean hilited;
1115 if (!PyArg_ParseTuple(_args, "b",
1116 &hilited))
1117 return NULL;
1118 _err = HiliteWindowFrameForDrag(_self->ob_itself,
1119 hilited);
1120 if (_err != noErr) return PyMac_Error(_err);
1121 Py_INCREF(Py_None);
1122 _res = Py_None;
1123 return _res;
1124}
1125
1126static PyObject *WinObj_TransitionWindow(_self, _args)
1127 WindowObject *_self;
1128 PyObject *_args;
1129{
1130 PyObject *_res = NULL;
1131 OSStatus _err;
1132 WindowTransitionEffect effect;
1133 WindowTransitionAction action;
1134 Rect rect;
1135 if (!PyArg_ParseTuple(_args, "llO&",
1136 &effect,
1137 &action,
1138 PyMac_GetRect, &rect))
1139 return NULL;
1140 _err = TransitionWindow(_self->ob_itself,
1141 effect,
1142 action,
1143 &rect);
Jack Jansene4349e81999-03-04 22:53:24 +00001144 if (_err != noErr) return PyMac_Error(_err);
1145 Py_INCREF(Py_None);
1146 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00001147 return _res;
1148}
1149
Jack Jansen1c4e6141998-04-21 15:23:55 +00001150static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001151 WindowObject *_self;
1152 PyObject *_args;
1153{
1154 PyObject *_res = NULL;
1155 short hGlobal;
1156 short vGlobal;
1157 Boolean front;
1158 if (!PyArg_ParseTuple(_args, "hhb",
1159 &hGlobal,
1160 &vGlobal,
1161 &front))
1162 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001163 MacMoveWindow(_self->ob_itself,
1164 hGlobal,
1165 vGlobal,
1166 front);
Jack Jansen21f96871998-02-20 16:02:09 +00001167 Py_INCREF(Py_None);
1168 _res = Py_None;
1169 return _res;
1170}
1171
1172static PyObject *WinObj_SizeWindow(_self, _args)
1173 WindowObject *_self;
1174 PyObject *_args;
1175{
1176 PyObject *_res = NULL;
1177 short w;
1178 short h;
1179 Boolean fUpdate;
1180 if (!PyArg_ParseTuple(_args, "hhb",
1181 &w,
1182 &h,
1183 &fUpdate))
1184 return NULL;
1185 SizeWindow(_self->ob_itself,
1186 w,
1187 h,
1188 fUpdate);
1189 Py_INCREF(Py_None);
1190 _res = Py_None;
1191 return _res;
1192}
1193
Guido van Rossum17448e21995-01-30 11:53:55 +00001194static PyObject *WinObj_GrowWindow(_self, _args)
1195 WindowObject *_self;
1196 PyObject *_args;
1197{
1198 PyObject *_res = NULL;
1199 long _rv;
1200 Point startPt;
1201 Rect bBox;
1202 if (!PyArg_ParseTuple(_args, "O&O&",
1203 PyMac_GetPoint, &startPt,
1204 PyMac_GetRect, &bBox))
1205 return NULL;
1206 _rv = GrowWindow(_self->ob_itself,
1207 startPt,
1208 &bBox);
1209 _res = Py_BuildValue("l",
1210 _rv);
1211 return _res;
1212}
1213
Jack Jansen21f96871998-02-20 16:02:09 +00001214static PyObject *WinObj_DragWindow(_self, _args)
1215 WindowObject *_self;
1216 PyObject *_args;
1217{
1218 PyObject *_res = NULL;
1219 Point startPt;
1220 Rect boundsRect;
1221 if (!PyArg_ParseTuple(_args, "O&O&",
1222 PyMac_GetPoint, &startPt,
1223 PyMac_GetRect, &boundsRect))
1224 return NULL;
1225 DragWindow(_self->ob_itself,
1226 startPt,
1227 &boundsRect);
1228 Py_INCREF(Py_None);
1229 _res = Py_None;
1230 return _res;
1231}
1232
Jack Jansena05ac601999-12-12 21:41:51 +00001233static PyObject *WinObj_ZoomWindow(_self, _args)
1234 WindowObject *_self;
1235 PyObject *_args;
1236{
1237 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001238 WindowPartCode partCode;
Jack Jansena05ac601999-12-12 21:41:51 +00001239 Boolean front;
1240 if (!PyArg_ParseTuple(_args, "hb",
1241 &partCode,
1242 &front))
1243 return NULL;
1244 ZoomWindow(_self->ob_itself,
1245 partCode,
1246 front);
1247 Py_INCREF(Py_None);
1248 _res = Py_None;
1249 return _res;
1250}
1251
1252static PyObject *WinObj_IsWindowCollapsable(_self, _args)
1253 WindowObject *_self;
1254 PyObject *_args;
1255{
1256 PyObject *_res = NULL;
1257 Boolean _rv;
1258 if (!PyArg_ParseTuple(_args, ""))
1259 return NULL;
1260 _rv = IsWindowCollapsable(_self->ob_itself);
1261 _res = Py_BuildValue("b",
1262 _rv);
1263 return _res;
1264}
1265
1266static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1267 WindowObject *_self;
1268 PyObject *_args;
1269{
1270 PyObject *_res = NULL;
1271 Boolean _rv;
1272 if (!PyArg_ParseTuple(_args, ""))
1273 return NULL;
1274 _rv = IsWindowCollapsed(_self->ob_itself);
1275 _res = Py_BuildValue("b",
1276 _rv);
1277 return _res;
1278}
1279
1280static PyObject *WinObj_CollapseWindow(_self, _args)
1281 WindowObject *_self;
1282 PyObject *_args;
1283{
1284 PyObject *_res = NULL;
1285 OSStatus _err;
1286 Boolean collapse;
1287 if (!PyArg_ParseTuple(_args, "b",
1288 &collapse))
1289 return NULL;
1290 _err = CollapseWindow(_self->ob_itself,
1291 collapse);
1292 if (_err != noErr) return PyMac_Error(_err);
1293 Py_INCREF(Py_None);
1294 _res = Py_None;
1295 return _res;
1296}
1297
Jack Jansen723ad8a2000-12-12 22:10:21 +00001298static PyObject *WinObj_GetWindowBounds(_self, _args)
Jack Jansena05ac601999-12-12 21:41:51 +00001299 WindowObject *_self;
1300 PyObject *_args;
1301{
1302 PyObject *_res = NULL;
1303 OSStatus _err;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001304 WindowRegionCode regionCode;
1305 Rect globalBounds;
1306 if (!PyArg_ParseTuple(_args, "H",
1307 &regionCode))
Jack Jansena05ac601999-12-12 21:41:51 +00001308 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001309 _err = GetWindowBounds(_self->ob_itself,
1310 regionCode,
1311 &globalBounds);
Jack Jansena05ac601999-12-12 21:41:51 +00001312 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen723ad8a2000-12-12 22:10:21 +00001313 _res = Py_BuildValue("O&",
1314 PyMac_BuildRect, &globalBounds);
Jack Jansena05ac601999-12-12 21:41:51 +00001315 return _res;
1316}
1317
Jack Jansen80716f02000-12-14 22:29:00 +00001318static PyObject *WinObj_ResizeWindow(_self, _args)
1319 WindowObject *_self;
1320 PyObject *_args;
1321{
1322 PyObject *_res = NULL;
1323 Boolean _rv;
1324 Point startPoint;
1325 Rect sizeConstraints;
1326 Rect newContentRect;
1327 if (!PyArg_ParseTuple(_args, "O&O&",
1328 PyMac_GetPoint, &startPoint,
1329 PyMac_GetRect, &sizeConstraints))
1330 return NULL;
1331 _rv = ResizeWindow(_self->ob_itself,
1332 startPoint,
1333 &sizeConstraints,
1334 &newContentRect);
1335 _res = Py_BuildValue("bO&",
1336 _rv,
1337 PyMac_BuildRect, &newContentRect);
1338 return _res;
1339}
1340
Jack Jansena05ac601999-12-12 21:41:51 +00001341static PyObject *WinObj_SetWindowBounds(_self, _args)
1342 WindowObject *_self;
1343 PyObject *_args;
1344{
1345 PyObject *_res = NULL;
1346 OSStatus _err;
1347 WindowRegionCode regionCode;
1348 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001349 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +00001350 &regionCode,
1351 PyMac_GetRect, &globalBounds))
1352 return NULL;
1353 _err = SetWindowBounds(_self->ob_itself,
1354 regionCode,
1355 &globalBounds);
1356 if (_err != noErr) return PyMac_Error(_err);
1357 Py_INCREF(Py_None);
1358 _res = Py_None;
1359 return _res;
1360}
1361
Jack Jansen723ad8a2000-12-12 22:10:21 +00001362static PyObject *WinObj_RepositionWindow(_self, _args)
Jack Jansena05ac601999-12-12 21:41:51 +00001363 WindowObject *_self;
1364 PyObject *_args;
1365{
1366 PyObject *_res = NULL;
1367 OSStatus _err;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001368 WindowPtr parentWindow;
1369 WindowPositionMethod method;
1370 if (!PyArg_ParseTuple(_args, "O&l",
1371 WinObj_Convert, &parentWindow,
1372 &method))
Jack Jansena05ac601999-12-12 21:41:51 +00001373 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001374 _err = RepositionWindow(_self->ob_itself,
1375 parentWindow,
1376 method);
Jack Jansena05ac601999-12-12 21:41:51 +00001377 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen723ad8a2000-12-12 22:10:21 +00001378 Py_INCREF(Py_None);
1379 _res = Py_None;
Jack Jansena05ac601999-12-12 21:41:51 +00001380 return _res;
1381}
1382
1383static PyObject *WinObj_MoveWindowStructure(_self, _args)
1384 WindowObject *_self;
1385 PyObject *_args;
1386{
1387 PyObject *_res = NULL;
1388 OSStatus _err;
1389 short hGlobal;
1390 short vGlobal;
1391 if (!PyArg_ParseTuple(_args, "hh",
1392 &hGlobal,
1393 &vGlobal))
1394 return NULL;
1395 _err = MoveWindowStructure(_self->ob_itself,
1396 hGlobal,
1397 vGlobal);
1398 if (_err != noErr) return PyMac_Error(_err);
1399 Py_INCREF(Py_None);
1400 _res = Py_None;
1401 return _res;
1402}
1403
1404static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1405 WindowObject *_self;
1406 PyObject *_args;
1407{
1408 PyObject *_res = NULL;
1409 Boolean _rv;
1410 Point idealSize;
1411 Rect idealStandardState;
1412 if (!PyArg_ParseTuple(_args, ""))
1413 return NULL;
1414 _rv = IsWindowInStandardState(_self->ob_itself,
1415 &idealSize,
1416 &idealStandardState);
1417 _res = Py_BuildValue("bO&O&",
1418 _rv,
1419 PyMac_BuildPoint, idealSize,
1420 PyMac_BuildRect, &idealStandardState);
1421 return _res;
1422}
1423
1424static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1425 WindowObject *_self;
1426 PyObject *_args;
1427{
1428 PyObject *_res = NULL;
1429 OSStatus _err;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001430 WindowPartCode partCode;
Jack Jansena05ac601999-12-12 21:41:51 +00001431 Point ioIdealSize;
1432 if (!PyArg_ParseTuple(_args, "h",
1433 &partCode))
1434 return NULL;
1435 _err = ZoomWindowIdeal(_self->ob_itself,
1436 partCode,
1437 &ioIdealSize);
1438 if (_err != noErr) return PyMac_Error(_err);
1439 _res = Py_BuildValue("O&",
1440 PyMac_BuildPoint, ioIdealSize);
1441 return _res;
1442}
1443
1444static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1445 WindowObject *_self;
1446 PyObject *_args;
1447{
1448 PyObject *_res = NULL;
1449 OSStatus _err;
1450 Rect userState;
1451 if (!PyArg_ParseTuple(_args, ""))
1452 return NULL;
1453 _err = GetWindowIdealUserState(_self->ob_itself,
1454 &userState);
1455 if (_err != noErr) return PyMac_Error(_err);
1456 _res = Py_BuildValue("O&",
1457 PyMac_BuildRect, &userState);
1458 return _res;
1459}
1460
1461static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1462 WindowObject *_self;
1463 PyObject *_args;
1464{
1465 PyObject *_res = NULL;
1466 OSStatus _err;
1467 Rect userState;
1468 if (!PyArg_ParseTuple(_args, ""))
1469 return NULL;
1470 _err = SetWindowIdealUserState(_self->ob_itself,
1471 &userState);
1472 if (_err != noErr) return PyMac_Error(_err);
1473 _res = Py_BuildValue("O&",
1474 PyMac_BuildRect, &userState);
1475 return _res;
1476}
1477
Jack Jansen21f96871998-02-20 16:02:09 +00001478static PyObject *WinObj_HideWindow(_self, _args)
1479 WindowObject *_self;
1480 PyObject *_args;
1481{
1482 PyObject *_res = NULL;
1483 if (!PyArg_ParseTuple(_args, ""))
1484 return NULL;
1485 HideWindow(_self->ob_itself);
1486 Py_INCREF(Py_None);
1487 _res = Py_None;
1488 return _res;
1489}
1490
Jack Jansen1c4e6141998-04-21 15:23:55 +00001491static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001492 WindowObject *_self;
1493 PyObject *_args;
1494{
1495 PyObject *_res = NULL;
1496 if (!PyArg_ParseTuple(_args, ""))
1497 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001498 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +00001499 Py_INCREF(Py_None);
1500 _res = Py_None;
1501 return _res;
1502}
1503
1504static PyObject *WinObj_ShowHide(_self, _args)
1505 WindowObject *_self;
1506 PyObject *_args;
1507{
1508 PyObject *_res = NULL;
1509 Boolean showFlag;
1510 if (!PyArg_ParseTuple(_args, "b",
1511 &showFlag))
1512 return NULL;
1513 ShowHide(_self->ob_itself,
1514 showFlag);
1515 Py_INCREF(Py_None);
1516 _res = Py_None;
1517 return _res;
1518}
1519
Jack Jansen723ad8a2000-12-12 22:10:21 +00001520#if TARGET_API_MAC_CARBON
1521
1522static PyObject *WinObj_GetWindowPropertyAttributes(_self, _args)
1523 WindowObject *_self;
1524 PyObject *_args;
1525{
1526 PyObject *_res = NULL;
1527 OSStatus _err;
1528 OSType propertyCreator;
1529 OSType propertyTag;
1530 UInt32 attributes;
1531 if (!PyArg_ParseTuple(_args, "O&O&",
1532 PyMac_GetOSType, &propertyCreator,
1533 PyMac_GetOSType, &propertyTag))
1534 return NULL;
1535 _err = GetWindowPropertyAttributes(_self->ob_itself,
1536 propertyCreator,
1537 propertyTag,
1538 &attributes);
1539 if (_err != noErr) return PyMac_Error(_err);
1540 _res = Py_BuildValue("l",
1541 attributes);
1542 return _res;
1543}
1544#endif
1545
1546#if TARGET_API_MAC_CARBON
1547
1548static PyObject *WinObj_ChangeWindowPropertyAttributes(_self, _args)
1549 WindowObject *_self;
1550 PyObject *_args;
1551{
1552 PyObject *_res = NULL;
1553 OSStatus _err;
1554 OSType propertyCreator;
1555 OSType propertyTag;
1556 UInt32 attributesToSet;
1557 UInt32 attributesToClear;
1558 if (!PyArg_ParseTuple(_args, "O&O&ll",
1559 PyMac_GetOSType, &propertyCreator,
1560 PyMac_GetOSType, &propertyTag,
1561 &attributesToSet,
1562 &attributesToClear))
1563 return NULL;
1564 _err = ChangeWindowPropertyAttributes(_self->ob_itself,
1565 propertyCreator,
1566 propertyTag,
1567 attributesToSet,
1568 attributesToClear);
1569 if (_err != noErr) return PyMac_Error(_err);
1570 Py_INCREF(Py_None);
1571 _res = Py_None;
1572 return _res;
1573}
1574#endif
1575
Guido van Rossum17448e21995-01-30 11:53:55 +00001576static PyObject *WinObj_TrackBox(_self, _args)
1577 WindowObject *_self;
1578 PyObject *_args;
1579{
1580 PyObject *_res = NULL;
1581 Boolean _rv;
1582 Point thePt;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001583 WindowPartCode partCode;
Guido van Rossum17448e21995-01-30 11:53:55 +00001584 if (!PyArg_ParseTuple(_args, "O&h",
1585 PyMac_GetPoint, &thePt,
1586 &partCode))
1587 return NULL;
1588 _rv = TrackBox(_self->ob_itself,
1589 thePt,
1590 partCode);
1591 _res = Py_BuildValue("b",
1592 _rv);
1593 return _res;
1594}
1595
Guido van Rossum17448e21995-01-30 11:53:55 +00001596static PyObject *WinObj_TrackGoAway(_self, _args)
1597 WindowObject *_self;
1598 PyObject *_args;
1599{
1600 PyObject *_res = NULL;
1601 Boolean _rv;
1602 Point thePt;
1603 if (!PyArg_ParseTuple(_args, "O&",
1604 PyMac_GetPoint, &thePt))
1605 return NULL;
1606 _rv = TrackGoAway(_self->ob_itself,
1607 thePt);
1608 _res = Py_BuildValue("b",
1609 _rv);
1610 return _res;
1611}
1612
Jack Jansen74a1e632000-07-14 22:37:27 +00001613#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00001614
Jack Jansen8f0fab71997-08-15 14:38:05 +00001615static PyObject *WinObj_GetAuxWin(_self, _args)
1616 WindowObject *_self;
1617 PyObject *_args;
1618{
1619 PyObject *_res = NULL;
1620 Boolean _rv;
1621 AuxWinHandle awHndl;
1622 if (!PyArg_ParseTuple(_args, ""))
1623 return NULL;
1624 _rv = GetAuxWin(_self->ob_itself,
1625 &awHndl);
1626 _res = Py_BuildValue("bO&",
1627 _rv,
1628 ResObj_New, awHndl);
1629 return _res;
1630}
Jack Jansene79dc762000-06-02 21:35:07 +00001631#endif
Jack Jansen8f0fab71997-08-15 14:38:05 +00001632
Jack Jansen723ad8a2000-12-12 22:10:21 +00001633static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1634 WindowObject *_self;
1635 PyObject *_args;
1636{
1637 PyObject *_res = NULL;
1638 Boolean _rv;
1639 if (!PyArg_ParseTuple(_args, ""))
1640 return NULL;
1641 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1642 _res = Py_BuildValue("b",
1643 _rv);
1644 return _res;
1645}
1646
1647static PyObject *WinObj_GetWindowSpareFlag(_self, _args)
1648 WindowObject *_self;
1649 PyObject *_args;
1650{
1651 PyObject *_res = NULL;
1652 Boolean _rv;
1653 if (!PyArg_ParseTuple(_args, ""))
1654 return NULL;
1655 _rv = GetWindowSpareFlag(_self->ob_itself);
1656 _res = Py_BuildValue("b",
1657 _rv);
1658 return _res;
1659}
1660
Jack Jansenb7abb181995-11-15 15:18:47 +00001661static PyObject *WinObj_GetWindowPort(_self, _args)
1662 WindowObject *_self;
1663 PyObject *_args;
1664{
1665 PyObject *_res = NULL;
1666 CGrafPtr _rv;
1667 if (!PyArg_ParseTuple(_args, ""))
1668 return NULL;
1669 _rv = GetWindowPort(_self->ob_itself);
1670 _res = Py_BuildValue("O&",
1671 GrafObj_New, _rv);
1672 return _res;
1673}
1674
Jack Jansen330f5761995-11-14 10:48:54 +00001675static PyObject *WinObj_GetWindowKind(_self, _args)
1676 WindowObject *_self;
1677 PyObject *_args;
1678{
1679 PyObject *_res = NULL;
1680 short _rv;
1681 if (!PyArg_ParseTuple(_args, ""))
1682 return NULL;
1683 _rv = GetWindowKind(_self->ob_itself);
1684 _res = Py_BuildValue("h",
1685 _rv);
1686 return _res;
1687}
1688
Jack Jansen723ad8a2000-12-12 22:10:21 +00001689static PyObject *WinObj_MacIsWindowVisible(_self, _args)
Jack Jansen330f5761995-11-14 10:48:54 +00001690 WindowObject *_self;
1691 PyObject *_args;
1692{
1693 PyObject *_res = NULL;
1694 Boolean _rv;
1695 if (!PyArg_ParseTuple(_args, ""))
1696 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001697 _rv = MacIsWindowVisible(_self->ob_itself);
Jack Jansen330f5761995-11-14 10:48:54 +00001698 _res = Py_BuildValue("b",
1699 _rv);
1700 return _res;
1701}
1702
1703static PyObject *WinObj_IsWindowHilited(_self, _args)
1704 WindowObject *_self;
1705 PyObject *_args;
1706{
1707 PyObject *_res = NULL;
1708 Boolean _rv;
1709 if (!PyArg_ParseTuple(_args, ""))
1710 return NULL;
1711 _rv = IsWindowHilited(_self->ob_itself);
1712 _res = Py_BuildValue("b",
1713 _rv);
1714 return _res;
1715}
1716
Jack Jansen723ad8a2000-12-12 22:10:21 +00001717#if TARGET_API_MAC_CARBON
1718
1719static PyObject *WinObj_IsWindowUpdatePending(_self, _args)
Jack Jansen330f5761995-11-14 10:48:54 +00001720 WindowObject *_self;
1721 PyObject *_args;
1722{
1723 PyObject *_res = NULL;
1724 Boolean _rv;
1725 if (!PyArg_ParseTuple(_args, ""))
1726 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001727 _rv = IsWindowUpdatePending(_self->ob_itself);
Jack Jansen330f5761995-11-14 10:48:54 +00001728 _res = Py_BuildValue("b",
1729 _rv);
1730 return _res;
1731}
Jack Jansene79dc762000-06-02 21:35:07 +00001732#endif
1733
Jack Jansen723ad8a2000-12-12 22:10:21 +00001734static PyObject *WinObj_MacGetNextWindow(_self, _args)
Jack Jansen330f5761995-11-14 10:48:54 +00001735 WindowObject *_self;
1736 PyObject *_args;
1737{
1738 PyObject *_res = NULL;
1739 WindowPtr _rv;
1740 if (!PyArg_ParseTuple(_args, ""))
1741 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001742 _rv = MacGetNextWindow(_self->ob_itself);
Jack Jansen330f5761995-11-14 10:48:54 +00001743 _res = Py_BuildValue("O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001744 WinObj_New, _rv);
Jack Jansen330f5761995-11-14 10:48:54 +00001745 return _res;
1746}
1747
1748static PyObject *WinObj_GetWindowStandardState(_self, _args)
1749 WindowObject *_self;
1750 PyObject *_args;
1751{
1752 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001753 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001754 if (!PyArg_ParseTuple(_args, ""))
1755 return NULL;
1756 GetWindowStandardState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001757 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001758 _res = Py_BuildValue("O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001759 PyMac_BuildRect, &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001760 return _res;
1761}
1762
1763static PyObject *WinObj_GetWindowUserState(_self, _args)
1764 WindowObject *_self;
1765 PyObject *_args;
1766{
1767 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001768 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001769 if (!PyArg_ParseTuple(_args, ""))
1770 return NULL;
1771 GetWindowUserState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001772 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001773 _res = Py_BuildValue("O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001774 PyMac_BuildRect, &rect);
1775 return _res;
1776}
1777
1778static PyObject *WinObj_SetWindowKind(_self, _args)
1779 WindowObject *_self;
1780 PyObject *_args;
1781{
1782 PyObject *_res = NULL;
1783 short kind;
1784 if (!PyArg_ParseTuple(_args, "h",
1785 &kind))
1786 return NULL;
1787 SetWindowKind(_self->ob_itself,
1788 kind);
1789 Py_INCREF(Py_None);
1790 _res = Py_None;
Jack Jansen330f5761995-11-14 10:48:54 +00001791 return _res;
1792}
1793
1794static PyObject *WinObj_SetWindowStandardState(_self, _args)
1795 WindowObject *_self;
1796 PyObject *_args;
1797{
1798 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001799 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001800 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001801 PyMac_GetRect, &rect))
Jack Jansen330f5761995-11-14 10:48:54 +00001802 return NULL;
1803 SetWindowStandardState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001804 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001805 Py_INCREF(Py_None);
1806 _res = Py_None;
1807 return _res;
1808}
1809
1810static PyObject *WinObj_SetWindowUserState(_self, _args)
1811 WindowObject *_self;
1812 PyObject *_args;
1813{
1814 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001815 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001816 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001817 PyMac_GetRect, &rect))
Jack Jansen330f5761995-11-14 10:48:54 +00001818 return NULL;
1819 SetWindowUserState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001820 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001821 Py_INCREF(Py_None);
1822 _res = Py_None;
1823 return _res;
1824}
1825
Jack Jansen723ad8a2000-12-12 22:10:21 +00001826static PyObject *WinObj_SetPortWindowPort(_self, _args)
1827 WindowObject *_self;
1828 PyObject *_args;
1829{
1830 PyObject *_res = NULL;
1831 if (!PyArg_ParseTuple(_args, ""))
1832 return NULL;
1833 SetPortWindowPort(_self->ob_itself);
1834 Py_INCREF(Py_None);
1835 _res = Py_None;
1836 return _res;
1837}
1838
1839static PyObject *WinObj_GetWindowPortBounds(_self, _args)
1840 WindowObject *_self;
1841 PyObject *_args;
1842{
1843 PyObject *_res = NULL;
1844 Rect bounds;
1845 if (!PyArg_ParseTuple(_args, ""))
1846 return NULL;
1847 GetWindowPortBounds(_self->ob_itself,
1848 &bounds);
1849 _res = Py_BuildValue("O&",
1850 PyMac_BuildRect, &bounds);
1851 return _res;
1852}
1853
Jack Jansen74a1e632000-07-14 22:37:27 +00001854#if !TARGET_API_MAC_CARBON
Jack Jansencdcbd1f1998-10-22 15:08:00 +00001855
Jack Jansene180d991998-04-24 10:28:20 +00001856static PyObject *WinObj_CloseWindow(_self, _args)
1857 WindowObject *_self;
1858 PyObject *_args;
1859{
1860 PyObject *_res = NULL;
1861 if (!PyArg_ParseTuple(_args, ""))
1862 return NULL;
1863 CloseWindow(_self->ob_itself);
1864 Py_INCREF(Py_None);
1865 _res = Py_None;
1866 return _res;
1867}
Jack Jansene79dc762000-06-02 21:35:07 +00001868#endif
Jack Jansene180d991998-04-24 10:28:20 +00001869
1870static PyObject *WinObj_MoveWindow(_self, _args)
1871 WindowObject *_self;
1872 PyObject *_args;
1873{
1874 PyObject *_res = NULL;
1875 short hGlobal;
1876 short vGlobal;
1877 Boolean front;
1878 if (!PyArg_ParseTuple(_args, "hhb",
1879 &hGlobal,
1880 &vGlobal,
1881 &front))
1882 return NULL;
1883 MoveWindow(_self->ob_itself,
1884 hGlobal,
1885 vGlobal,
1886 front);
1887 Py_INCREF(Py_None);
1888 _res = Py_None;
1889 return _res;
1890}
1891
1892static PyObject *WinObj_ShowWindow(_self, _args)
1893 WindowObject *_self;
1894 PyObject *_args;
1895{
1896 PyObject *_res = NULL;
1897 if (!PyArg_ParseTuple(_args, ""))
1898 return NULL;
1899 ShowWindow(_self->ob_itself);
1900 Py_INCREF(Py_None);
1901 _res = Py_None;
1902 return _res;
1903}
1904
Guido van Rossum17448e21995-01-30 11:53:55 +00001905static PyMethodDef WinObj_methods[] = {
Jack Jansena05ac601999-12-12 21:41:51 +00001906 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
1907 "() -> (UInt32 outCount)"},
1908 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
1909 "() -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00001910
1911#if TARGET_API_MAC_CARBON
1912 {"ReshapeCustomWindow", (PyCFunction)WinObj_ReshapeCustomWindow, 1,
1913 "() -> None"},
1914#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001915 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
1916 "() -> (WindowClass outClass)"},
1917 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
1918 "() -> (WindowAttributes outAttributes)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001919
Jack Jansen723ad8a2000-12-12 22:10:21 +00001920#if TARGET_API_MAC_CARBON
1921 {"ChangeWindowAttributes", (PyCFunction)WinObj_ChangeWindowAttributes, 1,
1922 "(WindowAttributes setTheseAttributes, WindowAttributes clearTheseAttributes) -> None"},
1923#endif
1924
Jack Jansen74a1e632000-07-14 22:37:27 +00001925#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001926 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1927 "(WCTabHandle newColorTable) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001928#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001929 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001930 "(RGBColor color) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001931 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
1932 "() -> (RGBColor color)"},
1933 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
1934 "(PixPatHandle outPixPat) -> None"},
1935 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
1936 "(PixPatHandle pixPat) -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00001937
1938#if TARGET_API_MAC_CARBON
1939 {"ScrollWindowRect", (PyCFunction)WinObj_ScrollWindowRect, 1,
1940 "(Rect inScrollRect, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
1941#endif
1942
1943#if TARGET_API_MAC_CARBON
1944 {"ScrollWindowRegion", (PyCFunction)WinObj_ScrollWindowRegion, 1,
1945 "(RgnHandle inScrollRgn, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
1946#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00001947 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1948 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001949
Jack Jansen74a1e632000-07-14 22:37:27 +00001950#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001951 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1952 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001953#endif
1954
Jack Jansen74a1e632000-07-14 22:37:27 +00001955#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001956 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1957 "(Boolean update) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001958#endif
Jack Jansen80716f02000-12-14 22:29:00 +00001959 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1960 "(RgnHandle clobberedRgn) -> None"},
1961 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1962 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001963 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1964 "() -> None"},
Jack Jansen80716f02000-12-14 22:29:00 +00001965 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1966 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001967 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1968 "() -> None"},
1969 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1970 "(WindowPtr behindWindow) -> None"},
1971 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1972 "() -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00001973
1974#if TARGET_API_MAC_CARBON
1975 {"GetNextWindowOfClass", (PyCFunction)WinObj_GetNextWindowOfClass, 1,
1976 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
1977#endif
1978
1979#if !TARGET_API_MAC_CARBON
1980 {"IsValidWindowPtr", (PyCFunction)WinObj_IsValidWindowPtr, 1,
1981 "() -> (Boolean _rv)"},
1982#endif
Jack Jansen1c4e6141998-04-21 15:23:55 +00001983 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1984 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001985 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1986 "(long data) -> None"},
1987 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1988 "() -> (long _rv)"},
1989 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1990 "(PicHandle pic) -> None"},
1991 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1992 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001993 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1994 "() -> (short _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001995 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1996 "() -> (UInt32 outFeatures)"},
1997 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1998 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001999 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
2000 "() -> None"},
2001 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
2002 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002003 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
2004 "(RgnHandle region) -> None"},
2005 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
2006 "(Rect bounds) -> None"},
2007 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
2008 "(RgnHandle region) -> None"},
2009 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
2010 "(Rect bounds) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002011 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
2012 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002013 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
2014 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002015 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
2016 "() -> (Str255 title)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002017 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
2018 "(FSSpec inFile) -> None"},
2019 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
2020 "() -> (FSSpec outFile)"},
2021 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
2022 "(AliasHandle alias) -> None"},
2023 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
2024 "() -> (AliasHandle alias)"},
2025 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
2026 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
2027 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
2028 "() -> (IconRef outIcon)"},
2029 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
2030 "(IconRef icon) -> None"},
2031 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
2032 "() -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002033 {"BeginWindowProxyDrag", (PyCFunction)WinObj_BeginWindowProxyDrag, 1,
2034 "(RgnHandle outDragOutlineRgn) -> (DragReference outNewDrag)"},
2035 {"EndWindowProxyDrag", (PyCFunction)WinObj_EndWindowProxyDrag, 1,
2036 "(DragReference theDrag) -> None"},
2037 {"TrackWindowProxyFromExistingDrag", (PyCFunction)WinObj_TrackWindowProxyFromExistingDrag, 1,
2038 "(Point startPt, DragReference drag, RgnHandle inDragOutlineRgn) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002039 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
2040 "(Point startPt) -> None"},
2041 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
2042 "() -> (Boolean _rv)"},
2043 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
2044 "(Boolean modified) -> None"},
2045 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002046 "(EventRecord event) -> (Boolean _rv)"},
Jack Jansen80716f02000-12-14 22:29:00 +00002047 {"WindowPathSelect", (PyCFunction)WinObj_WindowPathSelect, 1,
2048 "(MenuHandle menu) -> (SInt32 outMenuResult)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002049 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
2050 "(Boolean hilited) -> None"},
2051 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
2052 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
2053 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
2054 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2055 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
2056 "(short w, short h, Boolean fUpdate) -> None"},
2057 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
2058 "(Point startPt, Rect bBox) -> (long _rv)"},
2059 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
2060 "(Point startPt, Rect boundsRect) -> None"},
2061 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002062 "(WindowPartCode partCode, Boolean front) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002063 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
2064 "() -> (Boolean _rv)"},
2065 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
2066 "() -> (Boolean _rv)"},
2067 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002068 "(Boolean collapse) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002069 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
2070 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
Jack Jansen80716f02000-12-14 22:29:00 +00002071 {"ResizeWindow", (PyCFunction)WinObj_ResizeWindow, 1,
2072 "(Point startPoint, Rect sizeConstraints) -> (Boolean _rv, Rect newContentRect)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002073 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
2074 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
2075 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
2076 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002077 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
2078 "(short hGlobal, short vGlobal) -> None"},
2079 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
2080 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
2081 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002082 "(WindowPartCode partCode) -> (Point ioIdealSize)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002083 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
2084 "() -> (Rect userState)"},
2085 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
2086 "() -> (Rect userState)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002087 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
2088 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002089 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002090 "() -> None"},
2091 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
2092 "(Boolean showFlag) -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002093
2094#if TARGET_API_MAC_CARBON
2095 {"GetWindowPropertyAttributes", (PyCFunction)WinObj_GetWindowPropertyAttributes, 1,
2096 "(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
2097#endif
2098
2099#if TARGET_API_MAC_CARBON
2100 {"ChangeWindowPropertyAttributes", (PyCFunction)WinObj_ChangeWindowPropertyAttributes, 1,
2101 "(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
2102#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002103 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002104 "(Point thePt, WindowPartCode partCode) -> (Boolean _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002105 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
2106 "(Point thePt) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002107
Jack Jansen74a1e632000-07-14 22:37:27 +00002108#if !TARGET_API_MAC_CARBON
Jack Jansen8f0fab71997-08-15 14:38:05 +00002109 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
2110 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002111#endif
Jack Jansen723ad8a2000-12-12 22:10:21 +00002112 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
2113 "() -> (Boolean _rv)"},
2114 {"GetWindowSpareFlag", (PyCFunction)WinObj_GetWindowSpareFlag, 1,
2115 "() -> (Boolean _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00002116 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
2117 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00002118 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
2119 "() -> (short _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002120 {"MacIsWindowVisible", (PyCFunction)WinObj_MacIsWindowVisible, 1,
Jack Jansen330f5761995-11-14 10:48:54 +00002121 "() -> (Boolean _rv)"},
2122 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
2123 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002124
Jack Jansen723ad8a2000-12-12 22:10:21 +00002125#if TARGET_API_MAC_CARBON
2126 {"IsWindowUpdatePending", (PyCFunction)WinObj_IsWindowUpdatePending, 1,
Jack Jansen330f5761995-11-14 10:48:54 +00002127 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002128#endif
Jack Jansen723ad8a2000-12-12 22:10:21 +00002129 {"MacGetNextWindow", (PyCFunction)WinObj_MacGetNextWindow, 1,
Jack Jansen330f5761995-11-14 10:48:54 +00002130 "() -> (WindowPtr _rv)"},
2131 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002132 "() -> (Rect rect)"},
Jack Jansen330f5761995-11-14 10:48:54 +00002133 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002134 "() -> (Rect rect)"},
2135 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
2136 "(short kind) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00002137 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002138 "(Rect rect) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00002139 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002140 "(Rect rect) -> None"},
2141 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
2142 "() -> None"},
2143 {"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1,
2144 "() -> (Rect bounds)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002145
Jack Jansen74a1e632000-07-14 22:37:27 +00002146#if !TARGET_API_MAC_CARBON
Jack Jansene180d991998-04-24 10:28:20 +00002147 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
2148 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002149#endif
Jack Jansene180d991998-04-24 10:28:20 +00002150 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
2151 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2152 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
2153 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002154 {NULL, NULL, 0}
2155};
2156
2157PyMethodChain WinObj_chain = { WinObj_methods, NULL };
2158
2159static PyObject *WinObj_getattr(self, name)
2160 WindowObject *self;
2161 char *name;
2162{
2163 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
2164}
2165
2166#define WinObj_setattr NULL
2167
Jack Jansen87a30922000-12-19 21:34:55 +00002168static int WinObj_compare(self, other)
2169 WindowObject *self, *other;
2170{
2171 if ( self->ob_itself > other->ob_itself ) return 1;
2172 if ( self->ob_itself < other->ob_itself ) return -1;
2173 return 0;
2174}
Jack Jansena05ac601999-12-12 21:41:51 +00002175
2176#define WinObj_repr NULL
2177
Jack Jansen87a30922000-12-19 21:34:55 +00002178static int WinObj_hash(self)
2179 WindowObject *self;
2180{
2181 return (int)self->ob_itself;
2182}
Jack Jansena05ac601999-12-12 21:41:51 +00002183
Guido van Rossum17448e21995-01-30 11:53:55 +00002184PyTypeObject Window_Type = {
2185 PyObject_HEAD_INIT(&PyType_Type)
2186 0, /*ob_size*/
2187 "Window", /*tp_name*/
2188 sizeof(WindowObject), /*tp_basicsize*/
2189 0, /*tp_itemsize*/
2190 /* methods */
2191 (destructor) WinObj_dealloc, /*tp_dealloc*/
2192 0, /*tp_print*/
2193 (getattrfunc) WinObj_getattr, /*tp_getattr*/
2194 (setattrfunc) WinObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00002195 (cmpfunc) WinObj_compare, /*tp_compare*/
2196 (reprfunc) WinObj_repr, /*tp_repr*/
2197 (PyNumberMethods *)0, /* tp_as_number */
2198 (PySequenceMethods *)0, /* tp_as_sequence */
2199 (PyMappingMethods *)0, /* tp_as_mapping */
2200 (hashfunc) WinObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00002201};
2202
2203/* --------------------- End object type Window --------------------- */
2204
2205
Jack Jansen21f96871998-02-20 16:02:09 +00002206static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002207 PyObject *_self;
2208 PyObject *_args;
2209{
2210 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002211 WindowPtr _rv;
2212 short windowID;
2213 WindowPtr behind;
2214 if (!PyArg_ParseTuple(_args, "hO&",
2215 &windowID,
2216 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00002217 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002218 _rv = GetNewCWindow(windowID,
2219 (void *)0,
2220 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00002221 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002222 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00002223 return _res;
2224}
2225
Guido van Rossum17448e21995-01-30 11:53:55 +00002226static PyObject *Win_NewWindow(_self, _args)
2227 PyObject *_self;
2228 PyObject *_args;
2229{
2230 PyObject *_res = NULL;
2231 WindowPtr _rv;
2232 Rect boundsRect;
2233 Str255 title;
2234 Boolean visible;
2235 short theProc;
2236 WindowPtr behind;
2237 Boolean goAwayFlag;
2238 long refCon;
2239 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2240 PyMac_GetRect, &boundsRect,
2241 PyMac_GetStr255, title,
2242 &visible,
2243 &theProc,
2244 WinObj_Convert, &behind,
2245 &goAwayFlag,
2246 &refCon))
2247 return NULL;
2248 _rv = NewWindow((void *)0,
2249 &boundsRect,
2250 title,
2251 visible,
2252 theProc,
2253 behind,
2254 goAwayFlag,
2255 refCon);
2256 _res = Py_BuildValue("O&",
2257 WinObj_New, _rv);
2258 return _res;
2259}
2260
2261static PyObject *Win_GetNewWindow(_self, _args)
2262 PyObject *_self;
2263 PyObject *_args;
2264{
2265 PyObject *_res = NULL;
2266 WindowPtr _rv;
2267 short windowID;
2268 WindowPtr behind;
2269 if (!PyArg_ParseTuple(_args, "hO&",
2270 &windowID,
2271 WinObj_Convert, &behind))
2272 return NULL;
2273 _rv = GetNewWindow(windowID,
2274 (void *)0,
2275 behind);
2276 _res = Py_BuildValue("O&",
2277 WinObj_New, _rv);
2278 return _res;
2279}
2280
Jack Jansen21f96871998-02-20 16:02:09 +00002281static PyObject *Win_NewCWindow(_self, _args)
2282 PyObject *_self;
2283 PyObject *_args;
2284{
2285 PyObject *_res = NULL;
2286 WindowPtr _rv;
2287 Rect boundsRect;
2288 Str255 title;
2289 Boolean visible;
2290 short procID;
2291 WindowPtr behind;
2292 Boolean goAwayFlag;
2293 long refCon;
2294 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2295 PyMac_GetRect, &boundsRect,
2296 PyMac_GetStr255, title,
2297 &visible,
2298 &procID,
2299 WinObj_Convert, &behind,
2300 &goAwayFlag,
2301 &refCon))
2302 return NULL;
2303 _rv = NewCWindow((void *)0,
2304 &boundsRect,
2305 title,
2306 visible,
2307 procID,
2308 behind,
2309 goAwayFlag,
2310 refCon);
2311 _res = Py_BuildValue("O&",
2312 WinObj_New, _rv);
2313 return _res;
2314}
2315
Jack Jansena05ac601999-12-12 21:41:51 +00002316static PyObject *Win_CreateNewWindow(_self, _args)
2317 PyObject *_self;
2318 PyObject *_args;
2319{
2320 PyObject *_res = NULL;
2321 OSStatus _err;
2322 WindowClass windowClass;
2323 WindowAttributes attributes;
Jack Jansen723ad8a2000-12-12 22:10:21 +00002324 Rect contentBounds;
Jack Jansena05ac601999-12-12 21:41:51 +00002325 WindowPtr outWindow;
2326 if (!PyArg_ParseTuple(_args, "llO&",
2327 &windowClass,
2328 &attributes,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002329 PyMac_GetRect, &contentBounds))
Jack Jansena05ac601999-12-12 21:41:51 +00002330 return NULL;
2331 _err = CreateNewWindow(windowClass,
2332 attributes,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002333 &contentBounds,
Jack Jansena05ac601999-12-12 21:41:51 +00002334 &outWindow);
2335 if (_err != noErr) return PyMac_Error(_err);
2336 _res = Py_BuildValue("O&",
2337 WinObj_WhichWindow, outWindow);
2338 return _res;
2339}
2340
2341static PyObject *Win_CreateWindowFromResource(_self, _args)
2342 PyObject *_self;
2343 PyObject *_args;
2344{
2345 PyObject *_res = NULL;
2346 OSStatus _err;
2347 SInt16 resID;
2348 WindowPtr outWindow;
2349 if (!PyArg_ParseTuple(_args, "h",
2350 &resID))
2351 return NULL;
2352 _err = CreateWindowFromResource(resID,
2353 &outWindow);
2354 if (_err != noErr) return PyMac_Error(_err);
2355 _res = Py_BuildValue("O&",
2356 WinObj_WhichWindow, outWindow);
2357 return _res;
2358}
2359
2360static PyObject *Win_ShowFloatingWindows(_self, _args)
2361 PyObject *_self;
2362 PyObject *_args;
2363{
2364 PyObject *_res = NULL;
2365 OSStatus _err;
2366 if (!PyArg_ParseTuple(_args, ""))
2367 return NULL;
2368 _err = ShowFloatingWindows();
2369 if (_err != noErr) return PyMac_Error(_err);
2370 Py_INCREF(Py_None);
2371 _res = Py_None;
2372 return _res;
2373}
2374
2375static PyObject *Win_HideFloatingWindows(_self, _args)
2376 PyObject *_self;
2377 PyObject *_args;
2378{
2379 PyObject *_res = NULL;
2380 OSStatus _err;
2381 if (!PyArg_ParseTuple(_args, ""))
2382 return NULL;
2383 _err = HideFloatingWindows();
2384 if (_err != noErr) return PyMac_Error(_err);
2385 Py_INCREF(Py_None);
2386 _res = Py_None;
2387 return _res;
2388}
2389
2390static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2391 PyObject *_self;
2392 PyObject *_args;
2393{
2394 PyObject *_res = NULL;
2395 Boolean _rv;
2396 if (!PyArg_ParseTuple(_args, ""))
2397 return NULL;
2398 _rv = AreFloatingWindowsVisible();
2399 _res = Py_BuildValue("b",
2400 _rv);
2401 return _res;
2402}
2403
Jack Jansen74a1e632000-07-14 22:37:27 +00002404#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002405
Jack Jansen21f96871998-02-20 16:02:09 +00002406static PyObject *Win_SetDeskCPat(_self, _args)
2407 PyObject *_self;
2408 PyObject *_args;
2409{
2410 PyObject *_res = NULL;
2411 PixPatHandle deskPixPat;
2412 if (!PyArg_ParseTuple(_args, "O&",
2413 ResObj_Convert, &deskPixPat))
2414 return NULL;
2415 SetDeskCPat(deskPixPat);
2416 Py_INCREF(Py_None);
2417 _res = Py_None;
2418 return _res;
2419}
Jack Jansene79dc762000-06-02 21:35:07 +00002420#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002421
2422static PyObject *Win_CheckUpdate(_self, _args)
2423 PyObject *_self;
2424 PyObject *_args;
2425{
2426 PyObject *_res = NULL;
2427 Boolean _rv;
2428 EventRecord theEvent;
2429 if (!PyArg_ParseTuple(_args, ""))
2430 return NULL;
2431 _rv = CheckUpdate(&theEvent);
2432 _res = Py_BuildValue("bO&",
2433 _rv,
2434 PyMac_BuildEventRecord, &theEvent);
2435 return _res;
2436}
2437
Jack Jansen1c4e6141998-04-21 15:23:55 +00002438static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002439 PyObject *_self;
2440 PyObject *_args;
2441{
2442 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00002443 WindowPartCode _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002444 Point thePoint;
Jack Jansena05ac601999-12-12 21:41:51 +00002445 WindowPtr window;
Jack Jansen21f96871998-02-20 16:02:09 +00002446 if (!PyArg_ParseTuple(_args, "O&",
2447 PyMac_GetPoint, &thePoint))
2448 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002449 _rv = MacFindWindow(thePoint,
Jack Jansena05ac601999-12-12 21:41:51 +00002450 &window);
Jack Jansen21f96871998-02-20 16:02:09 +00002451 _res = Py_BuildValue("hO&",
2452 _rv,
Jack Jansena05ac601999-12-12 21:41:51 +00002453 WinObj_WhichWindow, window);
Jack Jansen21f96871998-02-20 16:02:09 +00002454 return _res;
2455}
2456
Guido van Rossum17448e21995-01-30 11:53:55 +00002457static PyObject *Win_FrontWindow(_self, _args)
2458 PyObject *_self;
2459 PyObject *_args;
2460{
2461 PyObject *_res = NULL;
2462 WindowPtr _rv;
2463 if (!PyArg_ParseTuple(_args, ""))
2464 return NULL;
2465 _rv = FrontWindow();
2466 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00002467 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002468 return _res;
2469}
2470
Jack Jansen723ad8a2000-12-12 22:10:21 +00002471static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2472 PyObject *_self;
2473 PyObject *_args;
2474{
2475 PyObject *_res = NULL;
2476 WindowPtr _rv;
2477 if (!PyArg_ParseTuple(_args, ""))
2478 return NULL;
2479 _rv = FrontNonFloatingWindow();
2480 _res = Py_BuildValue("O&",
2481 WinObj_WhichWindow, _rv);
2482 return _res;
2483}
2484
2485#if TARGET_API_MAC_CARBON
2486
2487static PyObject *Win_GetFrontWindowOfClass(_self, _args)
2488 PyObject *_self;
2489 PyObject *_args;
2490{
2491 PyObject *_res = NULL;
2492 WindowPtr _rv;
2493 WindowClass inWindowClass;
2494 Boolean mustBeVisible;
2495 if (!PyArg_ParseTuple(_args, "lb",
2496 &inWindowClass,
2497 &mustBeVisible))
2498 return NULL;
2499 _rv = GetFrontWindowOfClass(inWindowClass,
2500 mustBeVisible);
2501 _res = Py_BuildValue("O&",
2502 WinObj_New, _rv);
2503 return _res;
2504}
2505#endif
2506
2507#if TARGET_API_MAC_CARBON
2508
2509static PyObject *Win_FindWindowOfClass(_self, _args)
2510 PyObject *_self;
2511 PyObject *_args;
2512{
2513 PyObject *_res = NULL;
2514 OSStatus _err;
2515 Point where;
2516 WindowClass inWindowClass;
2517 WindowPtr outWindow;
2518 WindowPartCode outWindowPart;
2519 if (!PyArg_ParseTuple(_args, "O&l",
2520 PyMac_GetPoint, &where,
2521 &inWindowClass))
2522 return NULL;
2523 _err = FindWindowOfClass(&where,
2524 inWindowClass,
2525 &outWindow,
2526 &outWindowPart);
2527 if (_err != noErr) return PyMac_Error(_err);
2528 _res = Py_BuildValue("O&h",
2529 WinObj_WhichWindow, outWindow,
2530 outWindowPart);
2531 return _res;
2532}
2533#endif
2534
Jack Jansen74a1e632000-07-14 22:37:27 +00002535#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002536
Jack Jansen21f96871998-02-20 16:02:09 +00002537static PyObject *Win_InitWindows(_self, _args)
2538 PyObject *_self;
2539 PyObject *_args;
2540{
2541 PyObject *_res = NULL;
2542 if (!PyArg_ParseTuple(_args, ""))
2543 return NULL;
2544 InitWindows();
2545 Py_INCREF(Py_None);
2546 _res = Py_None;
2547 return _res;
2548}
Jack Jansene79dc762000-06-02 21:35:07 +00002549#endif
2550
Jack Jansen74a1e632000-07-14 22:37:27 +00002551#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002552
2553static PyObject *Win_GetWMgrPort(_self, _args)
2554 PyObject *_self;
2555 PyObject *_args;
2556{
2557 PyObject *_res = NULL;
2558 GrafPtr wPort;
2559 if (!PyArg_ParseTuple(_args, ""))
2560 return NULL;
2561 GetWMgrPort(&wPort);
2562 _res = Py_BuildValue("O&",
2563 GrafObj_New, wPort);
2564 return _res;
2565}
Jack Jansene79dc762000-06-02 21:35:07 +00002566#endif
2567
Jack Jansen74a1e632000-07-14 22:37:27 +00002568#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002569
2570static PyObject *Win_GetCWMgrPort(_self, _args)
2571 PyObject *_self;
2572 PyObject *_args;
2573{
2574 PyObject *_res = NULL;
2575 CGrafPtr wMgrCPort;
2576 if (!PyArg_ParseTuple(_args, ""))
2577 return NULL;
2578 GetCWMgrPort(&wMgrCPort);
2579 _res = Py_BuildValue("O&",
2580 GrafObj_New, wMgrCPort);
2581 return _res;
2582}
Jack Jansene79dc762000-06-02 21:35:07 +00002583#endif
2584
Jack Jansen74a1e632000-07-14 22:37:27 +00002585#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002586
Jack Jansena05ac601999-12-12 21:41:51 +00002587static PyObject *Win_InitFloatingWindows(_self, _args)
2588 PyObject *_self;
2589 PyObject *_args;
2590{
2591 PyObject *_res = NULL;
2592 OSStatus _err;
2593 if (!PyArg_ParseTuple(_args, ""))
2594 return NULL;
2595 _err = InitFloatingWindows();
2596 if (_err != noErr) return PyMac_Error(_err);
2597 Py_INCREF(Py_None);
2598 _res = Py_None;
2599 return _res;
2600}
Jack Jansene79dc762000-06-02 21:35:07 +00002601#endif
2602
Jack Jansen74a1e632000-07-14 22:37:27 +00002603#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002604
Guido van Rossum17448e21995-01-30 11:53:55 +00002605static PyObject *Win_InvalRect(_self, _args)
2606 PyObject *_self;
2607 PyObject *_args;
2608{
2609 PyObject *_res = NULL;
2610 Rect badRect;
2611 if (!PyArg_ParseTuple(_args, "O&",
2612 PyMac_GetRect, &badRect))
2613 return NULL;
2614 InvalRect(&badRect);
2615 Py_INCREF(Py_None);
2616 _res = Py_None;
2617 return _res;
2618}
Jack Jansene79dc762000-06-02 21:35:07 +00002619#endif
2620
Jack Jansen74a1e632000-07-14 22:37:27 +00002621#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002622
Jack Jansenb7abb181995-11-15 15:18:47 +00002623static PyObject *Win_InvalRgn(_self, _args)
2624 PyObject *_self;
2625 PyObject *_args;
2626{
2627 PyObject *_res = NULL;
2628 RgnHandle badRgn;
2629 if (!PyArg_ParseTuple(_args, "O&",
2630 ResObj_Convert, &badRgn))
2631 return NULL;
2632 InvalRgn(badRgn);
2633 Py_INCREF(Py_None);
2634 _res = Py_None;
2635 return _res;
2636}
Jack Jansene79dc762000-06-02 21:35:07 +00002637#endif
2638
Jack Jansen74a1e632000-07-14 22:37:27 +00002639#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002640
Guido van Rossum17448e21995-01-30 11:53:55 +00002641static PyObject *Win_ValidRect(_self, _args)
2642 PyObject *_self;
2643 PyObject *_args;
2644{
2645 PyObject *_res = NULL;
2646 Rect goodRect;
2647 if (!PyArg_ParseTuple(_args, "O&",
2648 PyMac_GetRect, &goodRect))
2649 return NULL;
2650 ValidRect(&goodRect);
2651 Py_INCREF(Py_None);
2652 _res = Py_None;
2653 return _res;
2654}
Jack Jansene79dc762000-06-02 21:35:07 +00002655#endif
2656
Jack Jansen74a1e632000-07-14 22:37:27 +00002657#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002658
Jack Jansenb7abb181995-11-15 15:18:47 +00002659static PyObject *Win_ValidRgn(_self, _args)
2660 PyObject *_self;
2661 PyObject *_args;
2662{
2663 PyObject *_res = NULL;
2664 RgnHandle goodRgn;
2665 if (!PyArg_ParseTuple(_args, "O&",
2666 ResObj_Convert, &goodRgn))
2667 return NULL;
2668 ValidRgn(goodRgn);
2669 Py_INCREF(Py_None);
2670 _res = Py_None;
2671 return _res;
2672}
Jack Jansene79dc762000-06-02 21:35:07 +00002673#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00002674
Jack Jansen21f96871998-02-20 16:02:09 +00002675static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002676 PyObject *_self;
2677 PyObject *_args;
2678{
2679 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00002680 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +00002681 Boolean collapse;
Jack Jansen21f96871998-02-20 16:02:09 +00002682 if (!PyArg_ParseTuple(_args, "b",
Jack Jansena05ac601999-12-12 21:41:51 +00002683 &collapse))
Guido van Rossum17448e21995-01-30 11:53:55 +00002684 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002685 _err = CollapseAllWindows(collapse);
Jack Jansene4349e81999-03-04 22:53:24 +00002686 if (_err != noErr) return PyMac_Error(_err);
2687 Py_INCREF(Py_None);
2688 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00002689 return _res;
2690}
2691
2692static PyObject *Win_PinRect(_self, _args)
2693 PyObject *_self;
2694 PyObject *_args;
2695{
2696 PyObject *_res = NULL;
2697 long _rv;
2698 Rect theRect;
2699 Point thePt;
2700 if (!PyArg_ParseTuple(_args, "O&O&",
2701 PyMac_GetRect, &theRect,
2702 PyMac_GetPoint, &thePt))
2703 return NULL;
2704 _rv = PinRect(&theRect,
2705 thePt);
2706 _res = Py_BuildValue("l",
2707 _rv);
2708 return _res;
2709}
2710
Jack Jansen21f96871998-02-20 16:02:09 +00002711static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002712 PyObject *_self;
2713 PyObject *_args;
2714{
2715 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002716 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00002717 if (!PyArg_ParseTuple(_args, ""))
2718 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002719 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00002720 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002721 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002722 return _res;
2723}
2724
Jack Jansen723ad8a2000-12-12 22:10:21 +00002725static PyObject *Win_GetWindowFromPort(_self, _args)
2726 PyObject *_self;
2727 PyObject *_args;
2728{
2729 PyObject *_res = NULL;
2730 WindowPtr _rv;
2731 CGrafPtr port;
2732 if (!PyArg_ParseTuple(_args, "O&",
2733 GrafObj_Convert, &port))
2734 return NULL;
2735 _rv = GetWindowFromPort(port);
2736 _res = Py_BuildValue("O&",
2737 WinObj_New, _rv);
2738 return _res;
2739}
2740
Jack Jansend4c26461995-08-17 14:35:56 +00002741static PyObject *Win_WhichWindow(_self, _args)
2742 PyObject *_self;
2743 PyObject *_args;
2744{
2745 PyObject *_res = NULL;
2746
2747 long ptr;
2748
2749 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2750 return NULL;
2751 return WinObj_WhichWindow((WindowPtr)ptr);
2752
2753}
2754
Jack Jansene180d991998-04-24 10:28:20 +00002755static PyObject *Win_FindWindow(_self, _args)
2756 PyObject *_self;
2757 PyObject *_args;
2758{
2759 PyObject *_res = NULL;
2760 short _rv;
2761 Point thePoint;
2762 WindowPtr theWindow;
2763 if (!PyArg_ParseTuple(_args, "O&",
2764 PyMac_GetPoint, &thePoint))
2765 return NULL;
2766 _rv = FindWindow(thePoint,
2767 &theWindow);
2768 _res = Py_BuildValue("hO&",
2769 _rv,
2770 WinObj_WhichWindow, theWindow);
2771 return _res;
2772}
2773
Guido van Rossum17448e21995-01-30 11:53:55 +00002774static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00002775 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2776 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002777 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2778 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2779 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2780 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002781 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2782 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002783 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002784 "(WindowClass windowClass, WindowAttributes attributes, Rect contentBounds) -> (WindowPtr outWindow)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002785 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2786 "(SInt16 resID) -> (WindowPtr outWindow)"},
2787 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2788 "() -> None"},
2789 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2790 "() -> None"},
2791 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2792 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002793
Jack Jansen74a1e632000-07-14 22:37:27 +00002794#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002795 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2796 "(PixPatHandle deskPixPat) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002797#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002798 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2799 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002800 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002801 "(Point thePoint) -> (WindowPartCode _rv, WindowPtr window)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002802 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2803 "() -> (WindowPtr _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002804 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2805 "() -> (WindowPtr _rv)"},
2806
2807#if TARGET_API_MAC_CARBON
2808 {"GetFrontWindowOfClass", (PyCFunction)Win_GetFrontWindowOfClass, 1,
2809 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2810#endif
2811
2812#if TARGET_API_MAC_CARBON
2813 {"FindWindowOfClass", (PyCFunction)Win_FindWindowOfClass, 1,
2814 "(Point where, WindowClass inWindowClass) -> (WindowPtr outWindow, WindowPartCode outWindowPart)"},
2815#endif
Jack Jansene79dc762000-06-02 21:35:07 +00002816
Jack Jansen74a1e632000-07-14 22:37:27 +00002817#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002818 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2819 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002820#endif
2821
Jack Jansen74a1e632000-07-14 22:37:27 +00002822#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002823 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2824 "() -> (GrafPtr wPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002825#endif
2826
Jack Jansen74a1e632000-07-14 22:37:27 +00002827#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002828 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2829 "() -> (CGrafPtr wMgrCPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002830#endif
2831
Jack Jansen74a1e632000-07-14 22:37:27 +00002832#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002833 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2834 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002835#endif
2836
Jack Jansen74a1e632000-07-14 22:37:27 +00002837#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002838 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2839 "(Rect badRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002840#endif
2841
Jack Jansen74a1e632000-07-14 22:37:27 +00002842#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002843 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2844 "(RgnHandle badRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002845#endif
2846
Jack Jansen74a1e632000-07-14 22:37:27 +00002847#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002848 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2849 "(Rect goodRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002850#endif
2851
Jack Jansen74a1e632000-07-14 22:37:27 +00002852#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002853 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2854 "(RgnHandle goodRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002855#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002856 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002857 "(Boolean collapse) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002858 {"PinRect", (PyCFunction)Win_PinRect, 1,
2859 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002860 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2861 "() -> (RgnHandle _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002862 {"GetWindowFromPort", (PyCFunction)Win_GetWindowFromPort, 1,
2863 "(CGrafPtr port) -> (WindowPtr _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00002864 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2865 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00002866 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2867 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002868 {NULL, NULL, 0}
2869};
2870
2871
2872
2873/* Return the object corresponding to the window, or NULL */
2874
2875PyObject *
2876WinObj_WhichWindow(w)
2877 WindowPtr w;
2878{
2879 PyObject *it;
2880
Jack Jansen0aee0e62000-08-25 22:17:51 +00002881 if (w == NULL) {
Guido van Rossum17448e21995-01-30 11:53:55 +00002882 it = Py_None;
Jack Jansen0aee0e62000-08-25 22:17:51 +00002883 Py_INCREF(it);
2884 } else {
2885 it = (PyObject *) GetWRefCon(w);
Jack Jansen80716f02000-12-14 22:29:00 +00002886 if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
Jack Jansen0aee0e62000-08-25 22:17:51 +00002887 it = WinObj_New(w);
2888 ((WindowObject *)it)->ob_freeit = NULL;
2889 } else {
2890 Py_INCREF(it);
2891 }
2892 }
Guido van Rossum17448e21995-01-30 11:53:55 +00002893 return it;
2894}
2895
2896
2897void initWin()
2898{
2899 PyObject *m;
2900 PyObject *d;
2901
2902
2903
2904
2905 m = Py_InitModule("Win", Win_methods);
2906 d = PyModule_GetDict(m);
2907 Win_Error = PyMac_GetOSErrException();
2908 if (Win_Error == NULL ||
2909 PyDict_SetItemString(d, "Error", Win_Error) != 0)
Jack Jansen723ad8a2000-12-12 22:10:21 +00002910 return;
Jack Jansena755e681997-09-20 17:40:22 +00002911 Window_Type.ob_type = &PyType_Type;
2912 Py_INCREF(&Window_Type);
2913 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2914 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002915}
2916
2917/* ========================= End module Win ========================= */
2918