blob: 800bad01ad379b6289f4136b042b518305713cd6 [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 Jansena05ac601999-12-12 21:41:51 +00002168#define WinObj_compare NULL
2169
2170#define WinObj_repr NULL
2171
2172#define WinObj_hash NULL
2173
Guido van Rossum17448e21995-01-30 11:53:55 +00002174PyTypeObject Window_Type = {
2175 PyObject_HEAD_INIT(&PyType_Type)
2176 0, /*ob_size*/
2177 "Window", /*tp_name*/
2178 sizeof(WindowObject), /*tp_basicsize*/
2179 0, /*tp_itemsize*/
2180 /* methods */
2181 (destructor) WinObj_dealloc, /*tp_dealloc*/
2182 0, /*tp_print*/
2183 (getattrfunc) WinObj_getattr, /*tp_getattr*/
2184 (setattrfunc) WinObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00002185 (cmpfunc) WinObj_compare, /*tp_compare*/
2186 (reprfunc) WinObj_repr, /*tp_repr*/
2187 (PyNumberMethods *)0, /* tp_as_number */
2188 (PySequenceMethods *)0, /* tp_as_sequence */
2189 (PyMappingMethods *)0, /* tp_as_mapping */
2190 (hashfunc) WinObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00002191};
2192
2193/* --------------------- End object type Window --------------------- */
2194
2195
Jack Jansen21f96871998-02-20 16:02:09 +00002196static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002197 PyObject *_self;
2198 PyObject *_args;
2199{
2200 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002201 WindowPtr _rv;
2202 short windowID;
2203 WindowPtr behind;
2204 if (!PyArg_ParseTuple(_args, "hO&",
2205 &windowID,
2206 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00002207 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002208 _rv = GetNewCWindow(windowID,
2209 (void *)0,
2210 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00002211 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002212 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00002213 return _res;
2214}
2215
Guido van Rossum17448e21995-01-30 11:53:55 +00002216static PyObject *Win_NewWindow(_self, _args)
2217 PyObject *_self;
2218 PyObject *_args;
2219{
2220 PyObject *_res = NULL;
2221 WindowPtr _rv;
2222 Rect boundsRect;
2223 Str255 title;
2224 Boolean visible;
2225 short theProc;
2226 WindowPtr behind;
2227 Boolean goAwayFlag;
2228 long refCon;
2229 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2230 PyMac_GetRect, &boundsRect,
2231 PyMac_GetStr255, title,
2232 &visible,
2233 &theProc,
2234 WinObj_Convert, &behind,
2235 &goAwayFlag,
2236 &refCon))
2237 return NULL;
2238 _rv = NewWindow((void *)0,
2239 &boundsRect,
2240 title,
2241 visible,
2242 theProc,
2243 behind,
2244 goAwayFlag,
2245 refCon);
2246 _res = Py_BuildValue("O&",
2247 WinObj_New, _rv);
2248 return _res;
2249}
2250
2251static PyObject *Win_GetNewWindow(_self, _args)
2252 PyObject *_self;
2253 PyObject *_args;
2254{
2255 PyObject *_res = NULL;
2256 WindowPtr _rv;
2257 short windowID;
2258 WindowPtr behind;
2259 if (!PyArg_ParseTuple(_args, "hO&",
2260 &windowID,
2261 WinObj_Convert, &behind))
2262 return NULL;
2263 _rv = GetNewWindow(windowID,
2264 (void *)0,
2265 behind);
2266 _res = Py_BuildValue("O&",
2267 WinObj_New, _rv);
2268 return _res;
2269}
2270
Jack Jansen21f96871998-02-20 16:02:09 +00002271static PyObject *Win_NewCWindow(_self, _args)
2272 PyObject *_self;
2273 PyObject *_args;
2274{
2275 PyObject *_res = NULL;
2276 WindowPtr _rv;
2277 Rect boundsRect;
2278 Str255 title;
2279 Boolean visible;
2280 short procID;
2281 WindowPtr behind;
2282 Boolean goAwayFlag;
2283 long refCon;
2284 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2285 PyMac_GetRect, &boundsRect,
2286 PyMac_GetStr255, title,
2287 &visible,
2288 &procID,
2289 WinObj_Convert, &behind,
2290 &goAwayFlag,
2291 &refCon))
2292 return NULL;
2293 _rv = NewCWindow((void *)0,
2294 &boundsRect,
2295 title,
2296 visible,
2297 procID,
2298 behind,
2299 goAwayFlag,
2300 refCon);
2301 _res = Py_BuildValue("O&",
2302 WinObj_New, _rv);
2303 return _res;
2304}
2305
Jack Jansena05ac601999-12-12 21:41:51 +00002306static PyObject *Win_CreateNewWindow(_self, _args)
2307 PyObject *_self;
2308 PyObject *_args;
2309{
2310 PyObject *_res = NULL;
2311 OSStatus _err;
2312 WindowClass windowClass;
2313 WindowAttributes attributes;
Jack Jansen723ad8a2000-12-12 22:10:21 +00002314 Rect contentBounds;
Jack Jansena05ac601999-12-12 21:41:51 +00002315 WindowPtr outWindow;
2316 if (!PyArg_ParseTuple(_args, "llO&",
2317 &windowClass,
2318 &attributes,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002319 PyMac_GetRect, &contentBounds))
Jack Jansena05ac601999-12-12 21:41:51 +00002320 return NULL;
2321 _err = CreateNewWindow(windowClass,
2322 attributes,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002323 &contentBounds,
Jack Jansena05ac601999-12-12 21:41:51 +00002324 &outWindow);
2325 if (_err != noErr) return PyMac_Error(_err);
2326 _res = Py_BuildValue("O&",
2327 WinObj_WhichWindow, outWindow);
2328 return _res;
2329}
2330
2331static PyObject *Win_CreateWindowFromResource(_self, _args)
2332 PyObject *_self;
2333 PyObject *_args;
2334{
2335 PyObject *_res = NULL;
2336 OSStatus _err;
2337 SInt16 resID;
2338 WindowPtr outWindow;
2339 if (!PyArg_ParseTuple(_args, "h",
2340 &resID))
2341 return NULL;
2342 _err = CreateWindowFromResource(resID,
2343 &outWindow);
2344 if (_err != noErr) return PyMac_Error(_err);
2345 _res = Py_BuildValue("O&",
2346 WinObj_WhichWindow, outWindow);
2347 return _res;
2348}
2349
2350static PyObject *Win_ShowFloatingWindows(_self, _args)
2351 PyObject *_self;
2352 PyObject *_args;
2353{
2354 PyObject *_res = NULL;
2355 OSStatus _err;
2356 if (!PyArg_ParseTuple(_args, ""))
2357 return NULL;
2358 _err = ShowFloatingWindows();
2359 if (_err != noErr) return PyMac_Error(_err);
2360 Py_INCREF(Py_None);
2361 _res = Py_None;
2362 return _res;
2363}
2364
2365static PyObject *Win_HideFloatingWindows(_self, _args)
2366 PyObject *_self;
2367 PyObject *_args;
2368{
2369 PyObject *_res = NULL;
2370 OSStatus _err;
2371 if (!PyArg_ParseTuple(_args, ""))
2372 return NULL;
2373 _err = HideFloatingWindows();
2374 if (_err != noErr) return PyMac_Error(_err);
2375 Py_INCREF(Py_None);
2376 _res = Py_None;
2377 return _res;
2378}
2379
2380static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2381 PyObject *_self;
2382 PyObject *_args;
2383{
2384 PyObject *_res = NULL;
2385 Boolean _rv;
2386 if (!PyArg_ParseTuple(_args, ""))
2387 return NULL;
2388 _rv = AreFloatingWindowsVisible();
2389 _res = Py_BuildValue("b",
2390 _rv);
2391 return _res;
2392}
2393
Jack Jansen74a1e632000-07-14 22:37:27 +00002394#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002395
Jack Jansen21f96871998-02-20 16:02:09 +00002396static PyObject *Win_SetDeskCPat(_self, _args)
2397 PyObject *_self;
2398 PyObject *_args;
2399{
2400 PyObject *_res = NULL;
2401 PixPatHandle deskPixPat;
2402 if (!PyArg_ParseTuple(_args, "O&",
2403 ResObj_Convert, &deskPixPat))
2404 return NULL;
2405 SetDeskCPat(deskPixPat);
2406 Py_INCREF(Py_None);
2407 _res = Py_None;
2408 return _res;
2409}
Jack Jansene79dc762000-06-02 21:35:07 +00002410#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002411
2412static PyObject *Win_CheckUpdate(_self, _args)
2413 PyObject *_self;
2414 PyObject *_args;
2415{
2416 PyObject *_res = NULL;
2417 Boolean _rv;
2418 EventRecord theEvent;
2419 if (!PyArg_ParseTuple(_args, ""))
2420 return NULL;
2421 _rv = CheckUpdate(&theEvent);
2422 _res = Py_BuildValue("bO&",
2423 _rv,
2424 PyMac_BuildEventRecord, &theEvent);
2425 return _res;
2426}
2427
Jack Jansen1c4e6141998-04-21 15:23:55 +00002428static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002429 PyObject *_self;
2430 PyObject *_args;
2431{
2432 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00002433 WindowPartCode _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002434 Point thePoint;
Jack Jansena05ac601999-12-12 21:41:51 +00002435 WindowPtr window;
Jack Jansen21f96871998-02-20 16:02:09 +00002436 if (!PyArg_ParseTuple(_args, "O&",
2437 PyMac_GetPoint, &thePoint))
2438 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002439 _rv = MacFindWindow(thePoint,
Jack Jansena05ac601999-12-12 21:41:51 +00002440 &window);
Jack Jansen21f96871998-02-20 16:02:09 +00002441 _res = Py_BuildValue("hO&",
2442 _rv,
Jack Jansena05ac601999-12-12 21:41:51 +00002443 WinObj_WhichWindow, window);
Jack Jansen21f96871998-02-20 16:02:09 +00002444 return _res;
2445}
2446
Guido van Rossum17448e21995-01-30 11:53:55 +00002447static PyObject *Win_FrontWindow(_self, _args)
2448 PyObject *_self;
2449 PyObject *_args;
2450{
2451 PyObject *_res = NULL;
2452 WindowPtr _rv;
2453 if (!PyArg_ParseTuple(_args, ""))
2454 return NULL;
2455 _rv = FrontWindow();
2456 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00002457 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002458 return _res;
2459}
2460
Jack Jansen723ad8a2000-12-12 22:10:21 +00002461static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2462 PyObject *_self;
2463 PyObject *_args;
2464{
2465 PyObject *_res = NULL;
2466 WindowPtr _rv;
2467 if (!PyArg_ParseTuple(_args, ""))
2468 return NULL;
2469 _rv = FrontNonFloatingWindow();
2470 _res = Py_BuildValue("O&",
2471 WinObj_WhichWindow, _rv);
2472 return _res;
2473}
2474
2475#if TARGET_API_MAC_CARBON
2476
2477static PyObject *Win_GetFrontWindowOfClass(_self, _args)
2478 PyObject *_self;
2479 PyObject *_args;
2480{
2481 PyObject *_res = NULL;
2482 WindowPtr _rv;
2483 WindowClass inWindowClass;
2484 Boolean mustBeVisible;
2485 if (!PyArg_ParseTuple(_args, "lb",
2486 &inWindowClass,
2487 &mustBeVisible))
2488 return NULL;
2489 _rv = GetFrontWindowOfClass(inWindowClass,
2490 mustBeVisible);
2491 _res = Py_BuildValue("O&",
2492 WinObj_New, _rv);
2493 return _res;
2494}
2495#endif
2496
2497#if TARGET_API_MAC_CARBON
2498
2499static PyObject *Win_FindWindowOfClass(_self, _args)
2500 PyObject *_self;
2501 PyObject *_args;
2502{
2503 PyObject *_res = NULL;
2504 OSStatus _err;
2505 Point where;
2506 WindowClass inWindowClass;
2507 WindowPtr outWindow;
2508 WindowPartCode outWindowPart;
2509 if (!PyArg_ParseTuple(_args, "O&l",
2510 PyMac_GetPoint, &where,
2511 &inWindowClass))
2512 return NULL;
2513 _err = FindWindowOfClass(&where,
2514 inWindowClass,
2515 &outWindow,
2516 &outWindowPart);
2517 if (_err != noErr) return PyMac_Error(_err);
2518 _res = Py_BuildValue("O&h",
2519 WinObj_WhichWindow, outWindow,
2520 outWindowPart);
2521 return _res;
2522}
2523#endif
2524
Jack Jansen74a1e632000-07-14 22:37:27 +00002525#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002526
Jack Jansen21f96871998-02-20 16:02:09 +00002527static PyObject *Win_InitWindows(_self, _args)
2528 PyObject *_self;
2529 PyObject *_args;
2530{
2531 PyObject *_res = NULL;
2532 if (!PyArg_ParseTuple(_args, ""))
2533 return NULL;
2534 InitWindows();
2535 Py_INCREF(Py_None);
2536 _res = Py_None;
2537 return _res;
2538}
Jack Jansene79dc762000-06-02 21:35:07 +00002539#endif
2540
Jack Jansen74a1e632000-07-14 22:37:27 +00002541#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002542
2543static PyObject *Win_GetWMgrPort(_self, _args)
2544 PyObject *_self;
2545 PyObject *_args;
2546{
2547 PyObject *_res = NULL;
2548 GrafPtr wPort;
2549 if (!PyArg_ParseTuple(_args, ""))
2550 return NULL;
2551 GetWMgrPort(&wPort);
2552 _res = Py_BuildValue("O&",
2553 GrafObj_New, wPort);
2554 return _res;
2555}
Jack Jansene79dc762000-06-02 21:35:07 +00002556#endif
2557
Jack Jansen74a1e632000-07-14 22:37:27 +00002558#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002559
2560static PyObject *Win_GetCWMgrPort(_self, _args)
2561 PyObject *_self;
2562 PyObject *_args;
2563{
2564 PyObject *_res = NULL;
2565 CGrafPtr wMgrCPort;
2566 if (!PyArg_ParseTuple(_args, ""))
2567 return NULL;
2568 GetCWMgrPort(&wMgrCPort);
2569 _res = Py_BuildValue("O&",
2570 GrafObj_New, wMgrCPort);
2571 return _res;
2572}
Jack Jansene79dc762000-06-02 21:35:07 +00002573#endif
2574
Jack Jansen74a1e632000-07-14 22:37:27 +00002575#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002576
Jack Jansena05ac601999-12-12 21:41:51 +00002577static PyObject *Win_InitFloatingWindows(_self, _args)
2578 PyObject *_self;
2579 PyObject *_args;
2580{
2581 PyObject *_res = NULL;
2582 OSStatus _err;
2583 if (!PyArg_ParseTuple(_args, ""))
2584 return NULL;
2585 _err = InitFloatingWindows();
2586 if (_err != noErr) return PyMac_Error(_err);
2587 Py_INCREF(Py_None);
2588 _res = Py_None;
2589 return _res;
2590}
Jack Jansene79dc762000-06-02 21:35:07 +00002591#endif
2592
Jack Jansen74a1e632000-07-14 22:37:27 +00002593#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002594
Guido van Rossum17448e21995-01-30 11:53:55 +00002595static PyObject *Win_InvalRect(_self, _args)
2596 PyObject *_self;
2597 PyObject *_args;
2598{
2599 PyObject *_res = NULL;
2600 Rect badRect;
2601 if (!PyArg_ParseTuple(_args, "O&",
2602 PyMac_GetRect, &badRect))
2603 return NULL;
2604 InvalRect(&badRect);
2605 Py_INCREF(Py_None);
2606 _res = Py_None;
2607 return _res;
2608}
Jack Jansene79dc762000-06-02 21:35:07 +00002609#endif
2610
Jack Jansen74a1e632000-07-14 22:37:27 +00002611#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002612
Jack Jansenb7abb181995-11-15 15:18:47 +00002613static PyObject *Win_InvalRgn(_self, _args)
2614 PyObject *_self;
2615 PyObject *_args;
2616{
2617 PyObject *_res = NULL;
2618 RgnHandle badRgn;
2619 if (!PyArg_ParseTuple(_args, "O&",
2620 ResObj_Convert, &badRgn))
2621 return NULL;
2622 InvalRgn(badRgn);
2623 Py_INCREF(Py_None);
2624 _res = Py_None;
2625 return _res;
2626}
Jack Jansene79dc762000-06-02 21:35:07 +00002627#endif
2628
Jack Jansen74a1e632000-07-14 22:37:27 +00002629#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002630
Guido van Rossum17448e21995-01-30 11:53:55 +00002631static PyObject *Win_ValidRect(_self, _args)
2632 PyObject *_self;
2633 PyObject *_args;
2634{
2635 PyObject *_res = NULL;
2636 Rect goodRect;
2637 if (!PyArg_ParseTuple(_args, "O&",
2638 PyMac_GetRect, &goodRect))
2639 return NULL;
2640 ValidRect(&goodRect);
2641 Py_INCREF(Py_None);
2642 _res = Py_None;
2643 return _res;
2644}
Jack Jansene79dc762000-06-02 21:35:07 +00002645#endif
2646
Jack Jansen74a1e632000-07-14 22:37:27 +00002647#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002648
Jack Jansenb7abb181995-11-15 15:18:47 +00002649static PyObject *Win_ValidRgn(_self, _args)
2650 PyObject *_self;
2651 PyObject *_args;
2652{
2653 PyObject *_res = NULL;
2654 RgnHandle goodRgn;
2655 if (!PyArg_ParseTuple(_args, "O&",
2656 ResObj_Convert, &goodRgn))
2657 return NULL;
2658 ValidRgn(goodRgn);
2659 Py_INCREF(Py_None);
2660 _res = Py_None;
2661 return _res;
2662}
Jack Jansene79dc762000-06-02 21:35:07 +00002663#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00002664
Jack Jansen21f96871998-02-20 16:02:09 +00002665static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002666 PyObject *_self;
2667 PyObject *_args;
2668{
2669 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00002670 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +00002671 Boolean collapse;
Jack Jansen21f96871998-02-20 16:02:09 +00002672 if (!PyArg_ParseTuple(_args, "b",
Jack Jansena05ac601999-12-12 21:41:51 +00002673 &collapse))
Guido van Rossum17448e21995-01-30 11:53:55 +00002674 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002675 _err = CollapseAllWindows(collapse);
Jack Jansene4349e81999-03-04 22:53:24 +00002676 if (_err != noErr) return PyMac_Error(_err);
2677 Py_INCREF(Py_None);
2678 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00002679 return _res;
2680}
2681
2682static PyObject *Win_PinRect(_self, _args)
2683 PyObject *_self;
2684 PyObject *_args;
2685{
2686 PyObject *_res = NULL;
2687 long _rv;
2688 Rect theRect;
2689 Point thePt;
2690 if (!PyArg_ParseTuple(_args, "O&O&",
2691 PyMac_GetRect, &theRect,
2692 PyMac_GetPoint, &thePt))
2693 return NULL;
2694 _rv = PinRect(&theRect,
2695 thePt);
2696 _res = Py_BuildValue("l",
2697 _rv);
2698 return _res;
2699}
2700
Jack Jansen21f96871998-02-20 16:02:09 +00002701static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002702 PyObject *_self;
2703 PyObject *_args;
2704{
2705 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002706 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00002707 if (!PyArg_ParseTuple(_args, ""))
2708 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002709 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00002710 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002711 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002712 return _res;
2713}
2714
Jack Jansen723ad8a2000-12-12 22:10:21 +00002715static PyObject *Win_GetWindowFromPort(_self, _args)
2716 PyObject *_self;
2717 PyObject *_args;
2718{
2719 PyObject *_res = NULL;
2720 WindowPtr _rv;
2721 CGrafPtr port;
2722 if (!PyArg_ParseTuple(_args, "O&",
2723 GrafObj_Convert, &port))
2724 return NULL;
2725 _rv = GetWindowFromPort(port);
2726 _res = Py_BuildValue("O&",
2727 WinObj_New, _rv);
2728 return _res;
2729}
2730
Jack Jansend4c26461995-08-17 14:35:56 +00002731static PyObject *Win_WhichWindow(_self, _args)
2732 PyObject *_self;
2733 PyObject *_args;
2734{
2735 PyObject *_res = NULL;
2736
2737 long ptr;
2738
2739 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2740 return NULL;
2741 return WinObj_WhichWindow((WindowPtr)ptr);
2742
2743}
2744
Jack Jansene180d991998-04-24 10:28:20 +00002745static PyObject *Win_FindWindow(_self, _args)
2746 PyObject *_self;
2747 PyObject *_args;
2748{
2749 PyObject *_res = NULL;
2750 short _rv;
2751 Point thePoint;
2752 WindowPtr theWindow;
2753 if (!PyArg_ParseTuple(_args, "O&",
2754 PyMac_GetPoint, &thePoint))
2755 return NULL;
2756 _rv = FindWindow(thePoint,
2757 &theWindow);
2758 _res = Py_BuildValue("hO&",
2759 _rv,
2760 WinObj_WhichWindow, theWindow);
2761 return _res;
2762}
2763
Guido van Rossum17448e21995-01-30 11:53:55 +00002764static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00002765 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2766 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002767 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2768 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2769 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2770 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002771 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2772 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002773 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002774 "(WindowClass windowClass, WindowAttributes attributes, Rect contentBounds) -> (WindowPtr outWindow)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002775 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2776 "(SInt16 resID) -> (WindowPtr outWindow)"},
2777 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2778 "() -> None"},
2779 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2780 "() -> None"},
2781 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2782 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002783
Jack Jansen74a1e632000-07-14 22:37:27 +00002784#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002785 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2786 "(PixPatHandle deskPixPat) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002787#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002788 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2789 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002790 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002791 "(Point thePoint) -> (WindowPartCode _rv, WindowPtr window)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002792 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2793 "() -> (WindowPtr _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002794 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2795 "() -> (WindowPtr _rv)"},
2796
2797#if TARGET_API_MAC_CARBON
2798 {"GetFrontWindowOfClass", (PyCFunction)Win_GetFrontWindowOfClass, 1,
2799 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2800#endif
2801
2802#if TARGET_API_MAC_CARBON
2803 {"FindWindowOfClass", (PyCFunction)Win_FindWindowOfClass, 1,
2804 "(Point where, WindowClass inWindowClass) -> (WindowPtr outWindow, WindowPartCode outWindowPart)"},
2805#endif
Jack Jansene79dc762000-06-02 21:35:07 +00002806
Jack Jansen74a1e632000-07-14 22:37:27 +00002807#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002808 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2809 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002810#endif
2811
Jack Jansen74a1e632000-07-14 22:37:27 +00002812#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002813 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2814 "() -> (GrafPtr wPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002815#endif
2816
Jack Jansen74a1e632000-07-14 22:37:27 +00002817#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002818 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2819 "() -> (CGrafPtr wMgrCPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002820#endif
2821
Jack Jansen74a1e632000-07-14 22:37:27 +00002822#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002823 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2824 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002825#endif
2826
Jack Jansen74a1e632000-07-14 22:37:27 +00002827#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002828 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2829 "(Rect badRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002830#endif
2831
Jack Jansen74a1e632000-07-14 22:37:27 +00002832#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002833 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2834 "(RgnHandle badRgn) -> 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 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2839 "(Rect goodRect) -> 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 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2844 "(RgnHandle goodRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002845#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002846 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002847 "(Boolean collapse) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002848 {"PinRect", (PyCFunction)Win_PinRect, 1,
2849 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002850 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2851 "() -> (RgnHandle _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002852 {"GetWindowFromPort", (PyCFunction)Win_GetWindowFromPort, 1,
2853 "(CGrafPtr port) -> (WindowPtr _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00002854 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2855 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00002856 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2857 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002858 {NULL, NULL, 0}
2859};
2860
2861
2862
2863/* Return the object corresponding to the window, or NULL */
2864
2865PyObject *
2866WinObj_WhichWindow(w)
2867 WindowPtr w;
2868{
2869 PyObject *it;
2870
Jack Jansen0aee0e62000-08-25 22:17:51 +00002871 if (w == NULL) {
Guido van Rossum17448e21995-01-30 11:53:55 +00002872 it = Py_None;
Jack Jansen0aee0e62000-08-25 22:17:51 +00002873 Py_INCREF(it);
2874 } else {
2875 it = (PyObject *) GetWRefCon(w);
Jack Jansen80716f02000-12-14 22:29:00 +00002876 if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
Jack Jansen0aee0e62000-08-25 22:17:51 +00002877 it = WinObj_New(w);
2878 ((WindowObject *)it)->ob_freeit = NULL;
2879 } else {
2880 Py_INCREF(it);
2881 }
2882 }
Guido van Rossum17448e21995-01-30 11:53:55 +00002883 return it;
2884}
2885
2886
2887void initWin()
2888{
2889 PyObject *m;
2890 PyObject *d;
2891
2892
2893
2894
2895 m = Py_InitModule("Win", Win_methods);
2896 d = PyModule_GetDict(m);
2897 Win_Error = PyMac_GetOSErrException();
2898 if (Win_Error == NULL ||
2899 PyDict_SetItemString(d, "Error", Win_Error) != 0)
Jack Jansen723ad8a2000-12-12 22:10:21 +00002900 return;
Jack Jansena755e681997-09-20 17:40:22 +00002901 Window_Type.ob_type = &PyType_Type;
2902 Py_INCREF(&Window_Type);
2903 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2904 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002905}
2906
2907/* ========================= End module Win ========================= */
2908