blob: 2ad1d601f34f1aa990679c15d9593a0319679207 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Win =========================== */
3
4#include "Python.h"
5
6
7
8#define SystemSevenOrLater 1
9
10#include "macglue.h"
11#include <Memory.h>
12#include <Dialogs.h>
13#include <Menus.h>
14#include <Controls.h>
15
16extern PyObject *ResObj_New(Handle);
17extern int ResObj_Convert(PyObject *, Handle *);
Jack Jansen425e9eb1995-12-12 15:02:03 +000018extern PyObject *OptResObj_New(Handle);
19extern int OptResObj_Convert(PyObject *, Handle *);
Guido van Rossum17448e21995-01-30 11:53:55 +000020
21extern PyObject *WinObj_New(WindowPtr);
22extern int WinObj_Convert(PyObject *, WindowPtr *);
Jack Jansenb7abb181995-11-15 15:18:47 +000023extern PyTypeObject Window_Type;
24#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
Guido van Rossum17448e21995-01-30 11:53:55 +000025
26extern PyObject *DlgObj_New(DialogPtr);
27extern int DlgObj_Convert(PyObject *, DialogPtr *);
28extern PyTypeObject Dialog_Type;
29#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
30
31extern PyObject *MenuObj_New(MenuHandle);
32extern int MenuObj_Convert(PyObject *, MenuHandle *);
33
34extern PyObject *CtlObj_New(ControlHandle);
35extern int CtlObj_Convert(PyObject *, ControlHandle *);
36
Jack Jansenb7abb181995-11-15 15:18:47 +000037extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
Jack Jansen425e9eb1995-12-12 15:02:03 +000040extern PyObject *BMObj_New(BitMapPtr);
41extern int BMObj_Convert(PyObject *, BitMapPtr *);
42
Guido van Rossum17448e21995-01-30 11:53:55 +000043extern PyObject *WinObj_WhichWindow(WindowPtr);
44
45#include <Windows.h>
46
Jack Jansena05ac601999-12-12 21:41:51 +000047extern PyObject *QdRGB_New(RGBColor *);
48extern int QdRGB_Convert(PyObject *, RGBColor *);
49
Guido van Rossum17448e21995-01-30 11:53:55 +000050#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
51
Guido van Rossum17448e21995-01-30 11:53:55 +000052
Guido van Rossum17448e21995-01-30 11:53:55 +000053static PyObject *Win_Error;
54
55/* ----------------------- Object type Window ----------------------- */
56
57PyTypeObject Window_Type;
58
59#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
60
61typedef struct WindowObject {
62 PyObject_HEAD
63 WindowPtr ob_itself;
64} WindowObject;
65
66PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000067 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000068{
69 WindowObject *it;
70 if (itself == NULL) return PyMac_Error(resNotFound);
71 it = PyObject_NEW(WindowObject, &Window_Type);
72 if (it == NULL) return NULL;
73 it->ob_itself = itself;
74 SetWRefCon(itself, (long)it);
75 return (PyObject *)it;
76}
77WinObj_Convert(v, p_itself)
78 PyObject *v;
79 WindowPtr *p_itself;
80{
Jack Jansene79dc762000-06-02 21:35:07 +000081#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +000082 if (DlgObj_Check(v)) {
83 *p_itself = ((WindowObject *)v)->ob_itself;
84 return 1;
85 }
Jack Jansene79dc762000-06-02 21:35:07 +000086#endif
Guido van Rossum17448e21995-01-30 11:53:55 +000087
88 if (v == Py_None) { *p_itself = NULL; return 1; }
89 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
90
91 if (!WinObj_Check(v))
92 {
93 PyErr_SetString(PyExc_TypeError, "Window required");
94 return 0;
95 }
96 *p_itself = ((WindowObject *)v)->ob_itself;
97 return 1;
98}
99
100static void WinObj_dealloc(self)
101 WindowObject *self;
102{
103 DisposeWindow(self->ob_itself);
104 PyMem_DEL(self);
105}
106
Jack Jansena05ac601999-12-12 21:41:51 +0000107static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
108 WindowObject *_self;
109 PyObject *_args;
110{
111 PyObject *_res = NULL;
112 OSStatus _err;
113 UInt32 outCount;
114 if (!PyArg_ParseTuple(_args, ""))
115 return NULL;
116 _err = GetWindowOwnerCount(_self->ob_itself,
117 &outCount);
118 if (_err != noErr) return PyMac_Error(_err);
119 _res = Py_BuildValue("l",
120 outCount);
121 return _res;
122}
123
124static PyObject *WinObj_CloneWindow(_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 = CloneWindow(_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
139static PyObject *WinObj_GetWindowClass(_self, _args)
140 WindowObject *_self;
141 PyObject *_args;
142{
143 PyObject *_res = NULL;
144 OSStatus _err;
145 WindowClass outClass;
146 if (!PyArg_ParseTuple(_args, ""))
147 return NULL;
148 _err = GetWindowClass(_self->ob_itself,
149 &outClass);
150 if (_err != noErr) return PyMac_Error(_err);
151 _res = Py_BuildValue("l",
152 outClass);
153 return _res;
154}
155
156static PyObject *WinObj_GetWindowAttributes(_self, _args)
157 WindowObject *_self;
158 PyObject *_args;
159{
160 PyObject *_res = NULL;
161 OSStatus _err;
162 WindowAttributes outAttributes;
163 if (!PyArg_ParseTuple(_args, ""))
164 return NULL;
165 _err = GetWindowAttributes(_self->ob_itself,
166 &outAttributes);
167 if (_err != noErr) return PyMac_Error(_err);
168 _res = Py_BuildValue("l",
169 outAttributes);
170 return _res;
171}
172
Jack Jansene79dc762000-06-02 21:35:07 +0000173#ifndef TARGET_API_MAC_CARBON
174
Jack Jansen21f96871998-02-20 16:02:09 +0000175static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000176 WindowObject *_self;
177 PyObject *_args;
178{
179 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000180 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000181 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000182 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000183 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000184 SetWinColor(_self->ob_itself,
185 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000186 Py_INCREF(Py_None);
187 _res = Py_None;
188 return _res;
189}
Jack Jansene79dc762000-06-02 21:35:07 +0000190#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000191
Jack Jansena05ac601999-12-12 21:41:51 +0000192static PyObject *WinObj_SetWindowContentColor(_self, _args)
193 WindowObject *_self;
194 PyObject *_args;
195{
196 PyObject *_res = NULL;
197 OSStatus _err;
198 RGBColor color;
199 if (!PyArg_ParseTuple(_args, ""))
200 return NULL;
201 _err = SetWindowContentColor(_self->ob_itself,
202 &color);
203 if (_err != noErr) return PyMac_Error(_err);
204 _res = Py_BuildValue("O&",
205 QdRGB_New, &color);
206 return _res;
207}
208
209static PyObject *WinObj_GetWindowContentColor(_self, _args)
210 WindowObject *_self;
211 PyObject *_args;
212{
213 PyObject *_res = NULL;
214 OSStatus _err;
215 RGBColor color;
216 if (!PyArg_ParseTuple(_args, ""))
217 return NULL;
218 _err = GetWindowContentColor(_self->ob_itself,
219 &color);
220 if (_err != noErr) return PyMac_Error(_err);
221 _res = Py_BuildValue("O&",
222 QdRGB_New, &color);
223 return _res;
224}
225
226static PyObject *WinObj_GetWindowContentPattern(_self, _args)
227 WindowObject *_self;
228 PyObject *_args;
229{
230 PyObject *_res = NULL;
231 OSStatus _err;
232 PixPatHandle outPixPat;
233 if (!PyArg_ParseTuple(_args, "O&",
234 ResObj_Convert, &outPixPat))
235 return NULL;
236 _err = GetWindowContentPattern(_self->ob_itself,
237 outPixPat);
238 if (_err != noErr) return PyMac_Error(_err);
239 Py_INCREF(Py_None);
240 _res = Py_None;
241 return _res;
242}
243
244static PyObject *WinObj_SetWindowContentPattern(_self, _args)
245 WindowObject *_self;
246 PyObject *_args;
247{
248 PyObject *_res = NULL;
249 OSStatus _err;
250 PixPatHandle pixPat;
251 if (!PyArg_ParseTuple(_args, "O&",
252 ResObj_Convert, &pixPat))
253 return NULL;
254 _err = SetWindowContentPattern(_self->ob_itself,
255 pixPat);
256 if (_err != noErr) return PyMac_Error(_err);
257 Py_INCREF(Py_None);
258 _res = Py_None;
259 return _res;
260}
261
Guido van Rossum17448e21995-01-30 11:53:55 +0000262static PyObject *WinObj_ClipAbove(_self, _args)
263 WindowObject *_self;
264 PyObject *_args;
265{
266 PyObject *_res = NULL;
267 if (!PyArg_ParseTuple(_args, ""))
268 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000269 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000270 Py_INCREF(Py_None);
271 _res = Py_None;
272 return _res;
273}
274
Jack Jansene79dc762000-06-02 21:35:07 +0000275#ifndef TARGET_API_MAC_CARBON
276
Guido van Rossum17448e21995-01-30 11:53:55 +0000277static PyObject *WinObj_SaveOld(_self, _args)
278 WindowObject *_self;
279 PyObject *_args;
280{
281 PyObject *_res = NULL;
282 if (!PyArg_ParseTuple(_args, ""))
283 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000284 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000285 Py_INCREF(Py_None);
286 _res = Py_None;
287 return _res;
288}
Jack Jansene79dc762000-06-02 21:35:07 +0000289#endif
290
291#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000292
293static PyObject *WinObj_DrawNew(_self, _args)
294 WindowObject *_self;
295 PyObject *_args;
296{
297 PyObject *_res = NULL;
298 Boolean update;
299 if (!PyArg_ParseTuple(_args, "b",
300 &update))
301 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000302 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000303 update);
304 Py_INCREF(Py_None);
305 _res = Py_None;
306 return _res;
307}
Jack Jansene79dc762000-06-02 21:35:07 +0000308#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000309
Jack Jansenb7abb181995-11-15 15:18:47 +0000310static PyObject *WinObj_PaintOne(_self, _args)
311 WindowObject *_self;
312 PyObject *_args;
313{
314 PyObject *_res = NULL;
315 RgnHandle clobberedRgn;
316 if (!PyArg_ParseTuple(_args, "O&",
317 ResObj_Convert, &clobberedRgn))
318 return NULL;
319 PaintOne(_self->ob_itself,
320 clobberedRgn);
321 Py_INCREF(Py_None);
322 _res = Py_None;
323 return _res;
324}
325
326static PyObject *WinObj_PaintBehind(_self, _args)
327 WindowObject *_self;
328 PyObject *_args;
329{
330 PyObject *_res = NULL;
331 RgnHandle clobberedRgn;
332 if (!PyArg_ParseTuple(_args, "O&",
333 ResObj_Convert, &clobberedRgn))
334 return NULL;
335 PaintBehind(_self->ob_itself,
336 clobberedRgn);
337 Py_INCREF(Py_None);
338 _res = Py_None;
339 return _res;
340}
341
Guido van Rossum17448e21995-01-30 11:53:55 +0000342static PyObject *WinObj_CalcVis(_self, _args)
343 WindowObject *_self;
344 PyObject *_args;
345{
346 PyObject *_res = NULL;
347 if (!PyArg_ParseTuple(_args, ""))
348 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000349 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000350 Py_INCREF(Py_None);
351 _res = Py_None;
352 return _res;
353}
354
Jack Jansenb7abb181995-11-15 15:18:47 +0000355static PyObject *WinObj_CalcVisBehind(_self, _args)
356 WindowObject *_self;
357 PyObject *_args;
358{
359 PyObject *_res = NULL;
360 RgnHandle clobberedRgn;
361 if (!PyArg_ParseTuple(_args, "O&",
362 ResObj_Convert, &clobberedRgn))
363 return NULL;
364 CalcVisBehind(_self->ob_itself,
365 clobberedRgn);
366 Py_INCREF(Py_None);
367 _res = Py_None;
368 return _res;
369}
370
Jack Jansen21f96871998-02-20 16:02:09 +0000371static PyObject *WinObj_BringToFront(_self, _args)
372 WindowObject *_self;
373 PyObject *_args;
374{
375 PyObject *_res = NULL;
376 if (!PyArg_ParseTuple(_args, ""))
377 return NULL;
378 BringToFront(_self->ob_itself);
379 Py_INCREF(Py_None);
380 _res = Py_None;
381 return _res;
382}
383
384static PyObject *WinObj_SendBehind(_self, _args)
385 WindowObject *_self;
386 PyObject *_args;
387{
388 PyObject *_res = NULL;
389 WindowPtr behindWindow;
390 if (!PyArg_ParseTuple(_args, "O&",
391 WinObj_Convert, &behindWindow))
392 return NULL;
393 SendBehind(_self->ob_itself,
394 behindWindow);
395 Py_INCREF(Py_None);
396 _res = Py_None;
397 return _res;
398}
399
400static PyObject *WinObj_SelectWindow(_self, _args)
401 WindowObject *_self;
402 PyObject *_args;
403{
404 PyObject *_res = NULL;
405 if (!PyArg_ParseTuple(_args, ""))
406 return NULL;
407 SelectWindow(_self->ob_itself);
408 Py_INCREF(Py_None);
409 _res = Py_None;
410 return _res;
411}
412
Jack Jansen1c4e6141998-04-21 15:23:55 +0000413static PyObject *WinObj_HiliteWindow(_self, _args)
414 WindowObject *_self;
415 PyObject *_args;
416{
417 PyObject *_res = NULL;
418 Boolean fHilite;
419 if (!PyArg_ParseTuple(_args, "b",
420 &fHilite))
421 return NULL;
422 HiliteWindow(_self->ob_itself,
423 fHilite);
424 Py_INCREF(Py_None);
425 _res = Py_None;
426 return _res;
427}
428
Jack Jansen21f96871998-02-20 16:02:09 +0000429static PyObject *WinObj_SetWRefCon(_self, _args)
430 WindowObject *_self;
431 PyObject *_args;
432{
433 PyObject *_res = NULL;
434 long data;
435 if (!PyArg_ParseTuple(_args, "l",
436 &data))
437 return NULL;
438 SetWRefCon(_self->ob_itself,
439 data);
440 Py_INCREF(Py_None);
441 _res = Py_None;
442 return _res;
443}
444
445static PyObject *WinObj_GetWRefCon(_self, _args)
446 WindowObject *_self;
447 PyObject *_args;
448{
449 PyObject *_res = NULL;
450 long _rv;
451 if (!PyArg_ParseTuple(_args, ""))
452 return NULL;
453 _rv = GetWRefCon(_self->ob_itself);
454 _res = Py_BuildValue("l",
455 _rv);
456 return _res;
457}
458
459static PyObject *WinObj_SetWindowPic(_self, _args)
460 WindowObject *_self;
461 PyObject *_args;
462{
463 PyObject *_res = NULL;
464 PicHandle pic;
465 if (!PyArg_ParseTuple(_args, "O&",
466 ResObj_Convert, &pic))
467 return NULL;
468 SetWindowPic(_self->ob_itself,
469 pic);
470 Py_INCREF(Py_None);
471 _res = Py_None;
472 return _res;
473}
474
475static PyObject *WinObj_GetWindowPic(_self, _args)
476 WindowObject *_self;
477 PyObject *_args;
478{
479 PyObject *_res = NULL;
480 PicHandle _rv;
481 if (!PyArg_ParseTuple(_args, ""))
482 return NULL;
483 _rv = GetWindowPic(_self->ob_itself);
484 _res = Py_BuildValue("O&",
485 ResObj_New, _rv);
486 return _res;
487}
488
489static PyObject *WinObj_GetWVariant(_self, _args)
490 WindowObject *_self;
491 PyObject *_args;
492{
493 PyObject *_res = NULL;
494 short _rv;
495 if (!PyArg_ParseTuple(_args, ""))
496 return NULL;
497 _rv = GetWVariant(_self->ob_itself);
498 _res = Py_BuildValue("h",
499 _rv);
500 return _res;
501}
502
Jack Jansena05ac601999-12-12 21:41:51 +0000503static PyObject *WinObj_GetWindowFeatures(_self, _args)
504 WindowObject *_self;
505 PyObject *_args;
506{
507 PyObject *_res = NULL;
508 OSStatus _err;
509 UInt32 outFeatures;
510 if (!PyArg_ParseTuple(_args, ""))
511 return NULL;
512 _err = GetWindowFeatures(_self->ob_itself,
513 &outFeatures);
514 if (_err != noErr) return PyMac_Error(_err);
515 _res = Py_BuildValue("l",
516 outFeatures);
517 return _res;
518}
519
520static PyObject *WinObj_GetWindowRegion(_self, _args)
521 WindowObject *_self;
522 PyObject *_args;
523{
524 PyObject *_res = NULL;
525 OSStatus _err;
526 WindowRegionCode inRegionCode;
527 RgnHandle ioWinRgn;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000528 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +0000529 &inRegionCode,
530 ResObj_Convert, &ioWinRgn))
531 return NULL;
532 _err = GetWindowRegion(_self->ob_itself,
533 inRegionCode,
534 ioWinRgn);
535 if (_err != noErr) return PyMac_Error(_err);
536 Py_INCREF(Py_None);
537 _res = Py_None;
538 return _res;
539}
540
Jack Jansen21f96871998-02-20 16:02:09 +0000541static PyObject *WinObj_BeginUpdate(_self, _args)
542 WindowObject *_self;
543 PyObject *_args;
544{
545 PyObject *_res = NULL;
546 if (!PyArg_ParseTuple(_args, ""))
547 return NULL;
548 BeginUpdate(_self->ob_itself);
549 Py_INCREF(Py_None);
550 _res = Py_None;
551 return _res;
552}
553
554static PyObject *WinObj_EndUpdate(_self, _args)
555 WindowObject *_self;
556 PyObject *_args;
557{
558 PyObject *_res = NULL;
559 if (!PyArg_ParseTuple(_args, ""))
560 return NULL;
561 EndUpdate(_self->ob_itself);
562 Py_INCREF(Py_None);
563 _res = Py_None;
564 return _res;
565}
566
Jack Jansena05ac601999-12-12 21:41:51 +0000567static PyObject *WinObj_InvalWindowRgn(_self, _args)
568 WindowObject *_self;
569 PyObject *_args;
570{
571 PyObject *_res = NULL;
572 OSStatus _err;
573 RgnHandle region;
574 if (!PyArg_ParseTuple(_args, "O&",
575 ResObj_Convert, &region))
576 return NULL;
577 _err = InvalWindowRgn(_self->ob_itself,
578 region);
579 if (_err != noErr) return PyMac_Error(_err);
580 Py_INCREF(Py_None);
581 _res = Py_None;
582 return _res;
583}
584
585static PyObject *WinObj_InvalWindowRect(_self, _args)
586 WindowObject *_self;
587 PyObject *_args;
588{
589 PyObject *_res = NULL;
590 OSStatus _err;
591 Rect bounds;
592 if (!PyArg_ParseTuple(_args, "O&",
593 PyMac_GetRect, &bounds))
594 return NULL;
595 _err = InvalWindowRect(_self->ob_itself,
596 &bounds);
597 if (_err != noErr) return PyMac_Error(_err);
598 Py_INCREF(Py_None);
599 _res = Py_None;
600 return _res;
601}
602
603static PyObject *WinObj_ValidWindowRgn(_self, _args)
604 WindowObject *_self;
605 PyObject *_args;
606{
607 PyObject *_res = NULL;
608 OSStatus _err;
609 RgnHandle region;
610 if (!PyArg_ParseTuple(_args, "O&",
611 ResObj_Convert, &region))
612 return NULL;
613 _err = ValidWindowRgn(_self->ob_itself,
614 region);
615 if (_err != noErr) return PyMac_Error(_err);
616 Py_INCREF(Py_None);
617 _res = Py_None;
618 return _res;
619}
620
621static PyObject *WinObj_ValidWindowRect(_self, _args)
622 WindowObject *_self;
623 PyObject *_args;
624{
625 PyObject *_res = NULL;
626 OSStatus _err;
627 Rect bounds;
628 if (!PyArg_ParseTuple(_args, "O&",
629 PyMac_GetRect, &bounds))
630 return NULL;
631 _err = ValidWindowRect(_self->ob_itself,
632 &bounds);
633 if (_err != noErr) return PyMac_Error(_err);
634 Py_INCREF(Py_None);
635 _res = Py_None;
636 return _res;
637}
638
Jack Jansen21f96871998-02-20 16:02:09 +0000639static PyObject *WinObj_DrawGrowIcon(_self, _args)
640 WindowObject *_self;
641 PyObject *_args;
642{
643 PyObject *_res = NULL;
644 if (!PyArg_ParseTuple(_args, ""))
645 return NULL;
646 DrawGrowIcon(_self->ob_itself);
647 Py_INCREF(Py_None);
648 _res = Py_None;
649 return _res;
650}
651
Jack Jansen21f96871998-02-20 16:02:09 +0000652static PyObject *WinObj_SetWTitle(_self, _args)
653 WindowObject *_self;
654 PyObject *_args;
655{
656 PyObject *_res = NULL;
657 Str255 title;
658 if (!PyArg_ParseTuple(_args, "O&",
659 PyMac_GetStr255, title))
660 return NULL;
661 SetWTitle(_self->ob_itself,
662 title);
663 Py_INCREF(Py_None);
664 _res = Py_None;
665 return _res;
666}
667
668static PyObject *WinObj_GetWTitle(_self, _args)
669 WindowObject *_self;
670 PyObject *_args;
671{
672 PyObject *_res = NULL;
673 Str255 title;
674 if (!PyArg_ParseTuple(_args, ""))
675 return NULL;
676 GetWTitle(_self->ob_itself,
677 title);
678 _res = Py_BuildValue("O&",
679 PyMac_BuildStr255, title);
680 return _res;
681}
682
Jack Jansena05ac601999-12-12 21:41:51 +0000683static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000684 WindowObject *_self;
685 PyObject *_args;
686{
687 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000688 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +0000689 FSSpec inFile;
690 if (!PyArg_ParseTuple(_args, "O&",
691 PyMac_GetFSSpec, &inFile))
Jack Jansen21f96871998-02-20 16:02:09 +0000692 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +0000693 _err = SetWindowProxyFSSpec(_self->ob_itself,
694 &inFile);
695 if (_err != noErr) return PyMac_Error(_err);
696 Py_INCREF(Py_None);
697 _res = Py_None;
698 return _res;
699}
700
701static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
702 WindowObject *_self;
703 PyObject *_args;
704{
705 PyObject *_res = NULL;
706 OSStatus _err;
707 FSSpec outFile;
708 if (!PyArg_ParseTuple(_args, ""))
709 return NULL;
710 _err = GetWindowProxyFSSpec(_self->ob_itself,
711 &outFile);
712 if (_err != noErr) return PyMac_Error(_err);
713 _res = Py_BuildValue("O&",
Jack Jansene79dc762000-06-02 21:35:07 +0000714 PyMac_BuildFSSpec, outFile);
Jack Jansena05ac601999-12-12 21:41:51 +0000715 return _res;
716}
717
718static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
719 WindowObject *_self;
720 PyObject *_args;
721{
722 PyObject *_res = NULL;
723 OSStatus _err;
724 AliasHandle alias;
725 if (!PyArg_ParseTuple(_args, "O&",
726 ResObj_Convert, &alias))
727 return NULL;
728 _err = SetWindowProxyAlias(_self->ob_itself,
729 alias);
730 if (_err != noErr) return PyMac_Error(_err);
731 Py_INCREF(Py_None);
732 _res = Py_None;
733 return _res;
734}
735
736static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
737 WindowObject *_self;
738 PyObject *_args;
739{
740 PyObject *_res = NULL;
741 OSStatus _err;
742 AliasHandle alias;
743 if (!PyArg_ParseTuple(_args, ""))
744 return NULL;
745 _err = GetWindowProxyAlias(_self->ob_itself,
746 &alias);
747 if (_err != noErr) return PyMac_Error(_err);
748 _res = Py_BuildValue("O&",
749 ResObj_New, alias);
750 return _res;
751}
752
753static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
754 WindowObject *_self;
755 PyObject *_args;
756{
757 PyObject *_res = NULL;
758 OSStatus _err;
759 OSType fileCreator;
760 OSType fileType;
761 SInt16 vRefNum;
762 if (!PyArg_ParseTuple(_args, "O&O&h",
763 PyMac_GetOSType, &fileCreator,
764 PyMac_GetOSType, &fileType,
765 &vRefNum))
766 return NULL;
767 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
768 fileCreator,
769 fileType,
770 vRefNum);
771 if (_err != noErr) return PyMac_Error(_err);
772 Py_INCREF(Py_None);
773 _res = Py_None;
774 return _res;
775}
776
777static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
778 WindowObject *_self;
779 PyObject *_args;
780{
781 PyObject *_res = NULL;
782 OSStatus _err;
783 IconRef outIcon;
784 if (!PyArg_ParseTuple(_args, ""))
785 return NULL;
786 _err = GetWindowProxyIcon(_self->ob_itself,
787 &outIcon);
788 if (_err != noErr) return PyMac_Error(_err);
789 _res = Py_BuildValue("O&",
790 ResObj_New, outIcon);
791 return _res;
792}
793
794static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
795 WindowObject *_self;
796 PyObject *_args;
797{
798 PyObject *_res = NULL;
799 OSStatus _err;
800 IconRef icon;
801 if (!PyArg_ParseTuple(_args, "O&",
802 ResObj_Convert, &icon))
803 return NULL;
804 _err = SetWindowProxyIcon(_self->ob_itself,
805 icon);
806 if (_err != noErr) return PyMac_Error(_err);
807 Py_INCREF(Py_None);
808 _res = Py_None;
809 return _res;
810}
811
812static PyObject *WinObj_RemoveWindowProxy(_self, _args)
813 WindowObject *_self;
814 PyObject *_args;
815{
816 PyObject *_res = NULL;
817 OSStatus _err;
818 if (!PyArg_ParseTuple(_args, ""))
819 return NULL;
820 _err = RemoveWindowProxy(_self->ob_itself);
821 if (_err != noErr) return PyMac_Error(_err);
822 Py_INCREF(Py_None);
823 _res = Py_None;
824 return _res;
825}
826
827static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
828 WindowObject *_self;
829 PyObject *_args;
830{
831 PyObject *_res = NULL;
832 OSStatus _err;
833 Point startPt;
834 if (!PyArg_ParseTuple(_args, "O&",
835 PyMac_GetPoint, &startPt))
836 return NULL;
837 _err = TrackWindowProxyDrag(_self->ob_itself,
838 startPt);
839 if (_err != noErr) return PyMac_Error(_err);
840 Py_INCREF(Py_None);
841 _res = Py_None;
842 return _res;
843}
844
845static PyObject *WinObj_IsWindowModified(_self, _args)
846 WindowObject *_self;
847 PyObject *_args;
848{
849 PyObject *_res = NULL;
850 Boolean _rv;
851 if (!PyArg_ParseTuple(_args, ""))
852 return NULL;
853 _rv = IsWindowModified(_self->ob_itself);
854 _res = Py_BuildValue("b",
855 _rv);
856 return _res;
857}
858
859static PyObject *WinObj_SetWindowModified(_self, _args)
860 WindowObject *_self;
861 PyObject *_args;
862{
863 PyObject *_res = NULL;
864 OSStatus _err;
865 Boolean modified;
866 if (!PyArg_ParseTuple(_args, "b",
867 &modified))
868 return NULL;
869 _err = SetWindowModified(_self->ob_itself,
870 modified);
871 if (_err != noErr) return PyMac_Error(_err);
872 Py_INCREF(Py_None);
873 _res = Py_None;
874 return _res;
875}
876
877static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
878 WindowObject *_self;
879 PyObject *_args;
880{
881 PyObject *_res = NULL;
882 Boolean _rv;
883 EventRecord event;
884 if (!PyArg_ParseTuple(_args, ""))
885 return NULL;
886 _rv = IsWindowPathSelectClick(_self->ob_itself,
887 &event);
888 _res = Py_BuildValue("bO&",
889 _rv,
890 PyMac_BuildEventRecord, &event);
891 return _res;
892}
893
894static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
895 WindowObject *_self;
896 PyObject *_args;
897{
898 PyObject *_res = NULL;
899 OSStatus _err;
900 Boolean hilited;
901 if (!PyArg_ParseTuple(_args, "b",
902 &hilited))
903 return NULL;
904 _err = HiliteWindowFrameForDrag(_self->ob_itself,
905 hilited);
906 if (_err != noErr) return PyMac_Error(_err);
907 Py_INCREF(Py_None);
908 _res = Py_None;
909 return _res;
910}
911
912static PyObject *WinObj_TransitionWindow(_self, _args)
913 WindowObject *_self;
914 PyObject *_args;
915{
916 PyObject *_res = NULL;
917 OSStatus _err;
918 WindowTransitionEffect effect;
919 WindowTransitionAction action;
920 Rect rect;
921 if (!PyArg_ParseTuple(_args, "llO&",
922 &effect,
923 &action,
924 PyMac_GetRect, &rect))
925 return NULL;
926 _err = TransitionWindow(_self->ob_itself,
927 effect,
928 action,
929 &rect);
Jack Jansene4349e81999-03-04 22:53:24 +0000930 if (_err != noErr) return PyMac_Error(_err);
931 Py_INCREF(Py_None);
932 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +0000933 return _res;
934}
935
Jack Jansen1c4e6141998-04-21 15:23:55 +0000936static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000937 WindowObject *_self;
938 PyObject *_args;
939{
940 PyObject *_res = NULL;
941 short hGlobal;
942 short vGlobal;
943 Boolean front;
944 if (!PyArg_ParseTuple(_args, "hhb",
945 &hGlobal,
946 &vGlobal,
947 &front))
948 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000949 MacMoveWindow(_self->ob_itself,
950 hGlobal,
951 vGlobal,
952 front);
Jack Jansen21f96871998-02-20 16:02:09 +0000953 Py_INCREF(Py_None);
954 _res = Py_None;
955 return _res;
956}
957
958static PyObject *WinObj_SizeWindow(_self, _args)
959 WindowObject *_self;
960 PyObject *_args;
961{
962 PyObject *_res = NULL;
963 short w;
964 short h;
965 Boolean fUpdate;
966 if (!PyArg_ParseTuple(_args, "hhb",
967 &w,
968 &h,
969 &fUpdate))
970 return NULL;
971 SizeWindow(_self->ob_itself,
972 w,
973 h,
974 fUpdate);
975 Py_INCREF(Py_None);
976 _res = Py_None;
977 return _res;
978}
979
Guido van Rossum17448e21995-01-30 11:53:55 +0000980static PyObject *WinObj_GrowWindow(_self, _args)
981 WindowObject *_self;
982 PyObject *_args;
983{
984 PyObject *_res = NULL;
985 long _rv;
986 Point startPt;
987 Rect bBox;
988 if (!PyArg_ParseTuple(_args, "O&O&",
989 PyMac_GetPoint, &startPt,
990 PyMac_GetRect, &bBox))
991 return NULL;
992 _rv = GrowWindow(_self->ob_itself,
993 startPt,
994 &bBox);
995 _res = Py_BuildValue("l",
996 _rv);
997 return _res;
998}
999
Jack Jansen21f96871998-02-20 16:02:09 +00001000static PyObject *WinObj_DragWindow(_self, _args)
1001 WindowObject *_self;
1002 PyObject *_args;
1003{
1004 PyObject *_res = NULL;
1005 Point startPt;
1006 Rect boundsRect;
1007 if (!PyArg_ParseTuple(_args, "O&O&",
1008 PyMac_GetPoint, &startPt,
1009 PyMac_GetRect, &boundsRect))
1010 return NULL;
1011 DragWindow(_self->ob_itself,
1012 startPt,
1013 &boundsRect);
1014 Py_INCREF(Py_None);
1015 _res = Py_None;
1016 return _res;
1017}
1018
Jack Jansena05ac601999-12-12 21:41:51 +00001019static PyObject *WinObj_ZoomWindow(_self, _args)
1020 WindowObject *_self;
1021 PyObject *_args;
1022{
1023 PyObject *_res = NULL;
1024 short partCode;
1025 Boolean front;
1026 if (!PyArg_ParseTuple(_args, "hb",
1027 &partCode,
1028 &front))
1029 return NULL;
1030 ZoomWindow(_self->ob_itself,
1031 partCode,
1032 front);
1033 Py_INCREF(Py_None);
1034 _res = Py_None;
1035 return _res;
1036}
1037
1038static PyObject *WinObj_IsWindowCollapsable(_self, _args)
1039 WindowObject *_self;
1040 PyObject *_args;
1041{
1042 PyObject *_res = NULL;
1043 Boolean _rv;
1044 if (!PyArg_ParseTuple(_args, ""))
1045 return NULL;
1046 _rv = IsWindowCollapsable(_self->ob_itself);
1047 _res = Py_BuildValue("b",
1048 _rv);
1049 return _res;
1050}
1051
1052static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1053 WindowObject *_self;
1054 PyObject *_args;
1055{
1056 PyObject *_res = NULL;
1057 Boolean _rv;
1058 if (!PyArg_ParseTuple(_args, ""))
1059 return NULL;
1060 _rv = IsWindowCollapsed(_self->ob_itself);
1061 _res = Py_BuildValue("b",
1062 _rv);
1063 return _res;
1064}
1065
1066static PyObject *WinObj_CollapseWindow(_self, _args)
1067 WindowObject *_self;
1068 PyObject *_args;
1069{
1070 PyObject *_res = NULL;
1071 OSStatus _err;
1072 Boolean collapse;
1073 if (!PyArg_ParseTuple(_args, "b",
1074 &collapse))
1075 return NULL;
1076 _err = CollapseWindow(_self->ob_itself,
1077 collapse);
1078 if (_err != noErr) return PyMac_Error(_err);
1079 Py_INCREF(Py_None);
1080 _res = Py_None;
1081 return _res;
1082}
1083
1084static PyObject *WinObj_RepositionWindow(_self, _args)
1085 WindowObject *_self;
1086 PyObject *_args;
1087{
1088 PyObject *_res = NULL;
1089 OSStatus _err;
1090 WindowPtr parentWindow;
1091 WindowPositionMethod method;
1092 if (!PyArg_ParseTuple(_args, "O&l",
1093 WinObj_Convert, &parentWindow,
1094 &method))
1095 return NULL;
1096 _err = RepositionWindow(_self->ob_itself,
1097 parentWindow,
1098 method);
1099 if (_err != noErr) return PyMac_Error(_err);
1100 Py_INCREF(Py_None);
1101 _res = Py_None;
1102 return _res;
1103}
1104
1105static PyObject *WinObj_SetWindowBounds(_self, _args)
1106 WindowObject *_self;
1107 PyObject *_args;
1108{
1109 PyObject *_res = NULL;
1110 OSStatus _err;
1111 WindowRegionCode regionCode;
1112 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001113 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +00001114 &regionCode,
1115 PyMac_GetRect, &globalBounds))
1116 return NULL;
1117 _err = SetWindowBounds(_self->ob_itself,
1118 regionCode,
1119 &globalBounds);
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_GetWindowBounds(_self, _args)
1127 WindowObject *_self;
1128 PyObject *_args;
1129{
1130 PyObject *_res = NULL;
1131 OSStatus _err;
1132 WindowRegionCode regionCode;
1133 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001134 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001135 &regionCode))
1136 return NULL;
1137 _err = GetWindowBounds(_self->ob_itself,
1138 regionCode,
1139 &globalBounds);
1140 if (_err != noErr) return PyMac_Error(_err);
1141 _res = Py_BuildValue("O&",
1142 PyMac_BuildRect, &globalBounds);
1143 return _res;
1144}
1145
1146static PyObject *WinObj_MoveWindowStructure(_self, _args)
1147 WindowObject *_self;
1148 PyObject *_args;
1149{
1150 PyObject *_res = NULL;
1151 OSStatus _err;
1152 short hGlobal;
1153 short vGlobal;
1154 if (!PyArg_ParseTuple(_args, "hh",
1155 &hGlobal,
1156 &vGlobal))
1157 return NULL;
1158 _err = MoveWindowStructure(_self->ob_itself,
1159 hGlobal,
1160 vGlobal);
1161 if (_err != noErr) return PyMac_Error(_err);
1162 Py_INCREF(Py_None);
1163 _res = Py_None;
1164 return _res;
1165}
1166
1167static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1168 WindowObject *_self;
1169 PyObject *_args;
1170{
1171 PyObject *_res = NULL;
1172 Boolean _rv;
1173 Point idealSize;
1174 Rect idealStandardState;
1175 if (!PyArg_ParseTuple(_args, ""))
1176 return NULL;
1177 _rv = IsWindowInStandardState(_self->ob_itself,
1178 &idealSize,
1179 &idealStandardState);
1180 _res = Py_BuildValue("bO&O&",
1181 _rv,
1182 PyMac_BuildPoint, idealSize,
1183 PyMac_BuildRect, &idealStandardState);
1184 return _res;
1185}
1186
1187static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1188 WindowObject *_self;
1189 PyObject *_args;
1190{
1191 PyObject *_res = NULL;
1192 OSStatus _err;
1193 SInt16 partCode;
1194 Point ioIdealSize;
1195 if (!PyArg_ParseTuple(_args, "h",
1196 &partCode))
1197 return NULL;
1198 _err = ZoomWindowIdeal(_self->ob_itself,
1199 partCode,
1200 &ioIdealSize);
1201 if (_err != noErr) return PyMac_Error(_err);
1202 _res = Py_BuildValue("O&",
1203 PyMac_BuildPoint, ioIdealSize);
1204 return _res;
1205}
1206
1207static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1208 WindowObject *_self;
1209 PyObject *_args;
1210{
1211 PyObject *_res = NULL;
1212 OSStatus _err;
1213 Rect userState;
1214 if (!PyArg_ParseTuple(_args, ""))
1215 return NULL;
1216 _err = GetWindowIdealUserState(_self->ob_itself,
1217 &userState);
1218 if (_err != noErr) return PyMac_Error(_err);
1219 _res = Py_BuildValue("O&",
1220 PyMac_BuildRect, &userState);
1221 return _res;
1222}
1223
1224static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1225 WindowObject *_self;
1226 PyObject *_args;
1227{
1228 PyObject *_res = NULL;
1229 OSStatus _err;
1230 Rect userState;
1231 if (!PyArg_ParseTuple(_args, ""))
1232 return NULL;
1233 _err = SetWindowIdealUserState(_self->ob_itself,
1234 &userState);
1235 if (_err != noErr) return PyMac_Error(_err);
1236 _res = Py_BuildValue("O&",
1237 PyMac_BuildRect, &userState);
1238 return _res;
1239}
1240
Jack Jansen21f96871998-02-20 16:02:09 +00001241static PyObject *WinObj_HideWindow(_self, _args)
1242 WindowObject *_self;
1243 PyObject *_args;
1244{
1245 PyObject *_res = NULL;
1246 if (!PyArg_ParseTuple(_args, ""))
1247 return NULL;
1248 HideWindow(_self->ob_itself);
1249 Py_INCREF(Py_None);
1250 _res = Py_None;
1251 return _res;
1252}
1253
Jack Jansen1c4e6141998-04-21 15:23:55 +00001254static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001255 WindowObject *_self;
1256 PyObject *_args;
1257{
1258 PyObject *_res = NULL;
1259 if (!PyArg_ParseTuple(_args, ""))
1260 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001261 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +00001262 Py_INCREF(Py_None);
1263 _res = Py_None;
1264 return _res;
1265}
1266
1267static PyObject *WinObj_ShowHide(_self, _args)
1268 WindowObject *_self;
1269 PyObject *_args;
1270{
1271 PyObject *_res = NULL;
1272 Boolean showFlag;
1273 if (!PyArg_ParseTuple(_args, "b",
1274 &showFlag))
1275 return NULL;
1276 ShowHide(_self->ob_itself,
1277 showFlag);
1278 Py_INCREF(Py_None);
1279 _res = Py_None;
1280 return _res;
1281}
1282
Guido van Rossum17448e21995-01-30 11:53:55 +00001283static PyObject *WinObj_TrackBox(_self, _args)
1284 WindowObject *_self;
1285 PyObject *_args;
1286{
1287 PyObject *_res = NULL;
1288 Boolean _rv;
1289 Point thePt;
1290 short partCode;
1291 if (!PyArg_ParseTuple(_args, "O&h",
1292 PyMac_GetPoint, &thePt,
1293 &partCode))
1294 return NULL;
1295 _rv = TrackBox(_self->ob_itself,
1296 thePt,
1297 partCode);
1298 _res = Py_BuildValue("b",
1299 _rv);
1300 return _res;
1301}
1302
Guido van Rossum17448e21995-01-30 11:53:55 +00001303static PyObject *WinObj_TrackGoAway(_self, _args)
1304 WindowObject *_self;
1305 PyObject *_args;
1306{
1307 PyObject *_res = NULL;
1308 Boolean _rv;
1309 Point thePt;
1310 if (!PyArg_ParseTuple(_args, "O&",
1311 PyMac_GetPoint, &thePt))
1312 return NULL;
1313 _rv = TrackGoAway(_self->ob_itself,
1314 thePt);
1315 _res = Py_BuildValue("b",
1316 _rv);
1317 return _res;
1318}
1319
Jack Jansene79dc762000-06-02 21:35:07 +00001320#ifndef TARGET_API_MAC_CARBON
1321
Jack Jansen8f0fab71997-08-15 14:38:05 +00001322static PyObject *WinObj_GetAuxWin(_self, _args)
1323 WindowObject *_self;
1324 PyObject *_args;
1325{
1326 PyObject *_res = NULL;
1327 Boolean _rv;
1328 AuxWinHandle awHndl;
1329 if (!PyArg_ParseTuple(_args, ""))
1330 return NULL;
1331 _rv = GetAuxWin(_self->ob_itself,
1332 &awHndl);
1333 _res = Py_BuildValue("bO&",
1334 _rv,
1335 ResObj_New, awHndl);
1336 return _res;
1337}
Jack Jansene79dc762000-06-02 21:35:07 +00001338#endif
Jack Jansen8f0fab71997-08-15 14:38:05 +00001339
Jack Jansenb7abb181995-11-15 15:18:47 +00001340static PyObject *WinObj_GetWindowPort(_self, _args)
1341 WindowObject *_self;
1342 PyObject *_args;
1343{
1344 PyObject *_res = NULL;
1345 CGrafPtr _rv;
1346 if (!PyArg_ParseTuple(_args, ""))
1347 return NULL;
1348 _rv = GetWindowPort(_self->ob_itself);
1349 _res = Py_BuildValue("O&",
1350 GrafObj_New, _rv);
1351 return _res;
1352}
1353
Jack Jansen330f5761995-11-14 10:48:54 +00001354static PyObject *WinObj_SetPortWindowPort(_self, _args)
1355 WindowObject *_self;
1356 PyObject *_args;
1357{
1358 PyObject *_res = NULL;
1359 if (!PyArg_ParseTuple(_args, ""))
1360 return NULL;
1361 SetPortWindowPort(_self->ob_itself);
1362 Py_INCREF(Py_None);
1363 _res = Py_None;
1364 return _res;
1365}
1366
1367static PyObject *WinObj_GetWindowKind(_self, _args)
1368 WindowObject *_self;
1369 PyObject *_args;
1370{
1371 PyObject *_res = NULL;
1372 short _rv;
1373 if (!PyArg_ParseTuple(_args, ""))
1374 return NULL;
1375 _rv = GetWindowKind(_self->ob_itself);
1376 _res = Py_BuildValue("h",
1377 _rv);
1378 return _res;
1379}
1380
1381static PyObject *WinObj_SetWindowKind(_self, _args)
1382 WindowObject *_self;
1383 PyObject *_args;
1384{
1385 PyObject *_res = NULL;
1386 short wKind;
1387 if (!PyArg_ParseTuple(_args, "h",
1388 &wKind))
1389 return NULL;
1390 SetWindowKind(_self->ob_itself,
1391 wKind);
1392 Py_INCREF(Py_None);
1393 _res = Py_None;
1394 return _res;
1395}
1396
1397static PyObject *WinObj_IsWindowVisible(_self, _args)
1398 WindowObject *_self;
1399 PyObject *_args;
1400{
1401 PyObject *_res = NULL;
1402 Boolean _rv;
1403 if (!PyArg_ParseTuple(_args, ""))
1404 return NULL;
1405 _rv = IsWindowVisible(_self->ob_itself);
1406 _res = Py_BuildValue("b",
1407 _rv);
1408 return _res;
1409}
1410
1411static PyObject *WinObj_IsWindowHilited(_self, _args)
1412 WindowObject *_self;
1413 PyObject *_args;
1414{
1415 PyObject *_res = NULL;
1416 Boolean _rv;
1417 if (!PyArg_ParseTuple(_args, ""))
1418 return NULL;
1419 _rv = IsWindowHilited(_self->ob_itself);
1420 _res = Py_BuildValue("b",
1421 _rv);
1422 return _res;
1423}
1424
1425static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1426 WindowObject *_self;
1427 PyObject *_args;
1428{
1429 PyObject *_res = NULL;
1430 Boolean _rv;
1431 if (!PyArg_ParseTuple(_args, ""))
1432 return NULL;
1433 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1434 _res = Py_BuildValue("b",
1435 _rv);
1436 return _res;
1437}
1438
Jack Jansene79dc762000-06-02 21:35:07 +00001439#ifndef TARGET_API_MAC_CARBON
1440
Jack Jansen330f5761995-11-14 10:48:54 +00001441static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1442 WindowObject *_self;
1443 PyObject *_args;
1444{
1445 PyObject *_res = NULL;
1446 Boolean _rv;
1447 if (!PyArg_ParseTuple(_args, ""))
1448 return NULL;
1449 _rv = GetWindowZoomFlag(_self->ob_itself);
1450 _res = Py_BuildValue("b",
1451 _rv);
1452 return _res;
1453}
Jack Jansene79dc762000-06-02 21:35:07 +00001454#endif
1455
1456#ifndef TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001457
Jack Jansenb7abb181995-11-15 15:18:47 +00001458static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1459 WindowObject *_self;
1460 PyObject *_args;
1461{
1462 PyObject *_res = NULL;
1463 RgnHandle r;
1464 if (!PyArg_ParseTuple(_args, "O&",
1465 ResObj_Convert, &r))
1466 return NULL;
1467 GetWindowStructureRgn(_self->ob_itself,
1468 r);
1469 Py_INCREF(Py_None);
1470 _res = Py_None;
1471 return _res;
1472}
Jack Jansene79dc762000-06-02 21:35:07 +00001473#endif
1474
1475#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001476
1477static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1478 WindowObject *_self;
1479 PyObject *_args;
1480{
1481 PyObject *_res = NULL;
1482 RgnHandle r;
1483 if (!PyArg_ParseTuple(_args, "O&",
1484 ResObj_Convert, &r))
1485 return NULL;
1486 GetWindowContentRgn(_self->ob_itself,
1487 r);
1488 Py_INCREF(Py_None);
1489 _res = Py_None;
1490 return _res;
1491}
Jack Jansene79dc762000-06-02 21:35:07 +00001492#endif
1493
1494#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001495
1496static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1497 WindowObject *_self;
1498 PyObject *_args;
1499{
1500 PyObject *_res = NULL;
1501 RgnHandle r;
1502 if (!PyArg_ParseTuple(_args, "O&",
1503 ResObj_Convert, &r))
1504 return NULL;
1505 GetWindowUpdateRgn(_self->ob_itself,
1506 r);
1507 Py_INCREF(Py_None);
1508 _res = Py_None;
1509 return _res;
1510}
Jack Jansene79dc762000-06-02 21:35:07 +00001511#endif
1512
1513#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001514
Jack Jansen330f5761995-11-14 10:48:54 +00001515static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1516 WindowObject *_self;
1517 PyObject *_args;
1518{
1519 PyObject *_res = NULL;
1520 short _rv;
1521 if (!PyArg_ParseTuple(_args, ""))
1522 return NULL;
1523 _rv = GetWindowTitleWidth(_self->ob_itself);
1524 _res = Py_BuildValue("h",
1525 _rv);
1526 return _res;
1527}
Jack Jansene79dc762000-06-02 21:35:07 +00001528#endif
Jack Jansen330f5761995-11-14 10:48:54 +00001529
1530static PyObject *WinObj_GetNextWindow(_self, _args)
1531 WindowObject *_self;
1532 PyObject *_args;
1533{
1534 PyObject *_res = NULL;
1535 WindowPtr _rv;
1536 if (!PyArg_ParseTuple(_args, ""))
1537 return NULL;
1538 _rv = GetNextWindow(_self->ob_itself);
1539 _res = Py_BuildValue("O&",
1540 WinObj_WhichWindow, _rv);
1541 return _res;
1542}
1543
1544static PyObject *WinObj_GetWindowStandardState(_self, _args)
1545 WindowObject *_self;
1546 PyObject *_args;
1547{
1548 PyObject *_res = NULL;
1549 Rect r;
1550 if (!PyArg_ParseTuple(_args, ""))
1551 return NULL;
1552 GetWindowStandardState(_self->ob_itself,
1553 &r);
1554 _res = Py_BuildValue("O&",
1555 PyMac_BuildRect, &r);
1556 return _res;
1557}
1558
1559static PyObject *WinObj_GetWindowUserState(_self, _args)
1560 WindowObject *_self;
1561 PyObject *_args;
1562{
1563 PyObject *_res = NULL;
1564 Rect r;
1565 if (!PyArg_ParseTuple(_args, ""))
1566 return NULL;
1567 GetWindowUserState(_self->ob_itself,
1568 &r);
1569 _res = Py_BuildValue("O&",
1570 PyMac_BuildRect, &r);
1571 return _res;
1572}
1573
1574static PyObject *WinObj_SetWindowStandardState(_self, _args)
1575 WindowObject *_self;
1576 PyObject *_args;
1577{
1578 PyObject *_res = NULL;
1579 Rect r;
1580 if (!PyArg_ParseTuple(_args, "O&",
1581 PyMac_GetRect, &r))
1582 return NULL;
1583 SetWindowStandardState(_self->ob_itself,
1584 &r);
1585 Py_INCREF(Py_None);
1586 _res = Py_None;
1587 return _res;
1588}
1589
1590static PyObject *WinObj_SetWindowUserState(_self, _args)
1591 WindowObject *_self;
1592 PyObject *_args;
1593{
1594 PyObject *_res = NULL;
1595 Rect r;
1596 if (!PyArg_ParseTuple(_args, "O&",
1597 PyMac_GetRect, &r))
1598 return NULL;
1599 SetWindowUserState(_self->ob_itself,
1600 &r);
1601 Py_INCREF(Py_None);
1602 _res = Py_None;
1603 return _res;
1604}
1605
Jack Jansene79dc762000-06-02 21:35:07 +00001606#ifndef TARGET_API_MAC_CARBON
Jack Jansencdcbd1f1998-10-22 15:08:00 +00001607
Jack Jansene180d991998-04-24 10:28:20 +00001608static PyObject *WinObj_CloseWindow(_self, _args)
1609 WindowObject *_self;
1610 PyObject *_args;
1611{
1612 PyObject *_res = NULL;
1613 if (!PyArg_ParseTuple(_args, ""))
1614 return NULL;
1615 CloseWindow(_self->ob_itself);
1616 Py_INCREF(Py_None);
1617 _res = Py_None;
1618 return _res;
1619}
Jack Jansene79dc762000-06-02 21:35:07 +00001620#endif
Jack Jansene180d991998-04-24 10:28:20 +00001621
1622static PyObject *WinObj_MoveWindow(_self, _args)
1623 WindowObject *_self;
1624 PyObject *_args;
1625{
1626 PyObject *_res = NULL;
1627 short hGlobal;
1628 short vGlobal;
1629 Boolean front;
1630 if (!PyArg_ParseTuple(_args, "hhb",
1631 &hGlobal,
1632 &vGlobal,
1633 &front))
1634 return NULL;
1635 MoveWindow(_self->ob_itself,
1636 hGlobal,
1637 vGlobal,
1638 front);
1639 Py_INCREF(Py_None);
1640 _res = Py_None;
1641 return _res;
1642}
1643
1644static PyObject *WinObj_ShowWindow(_self, _args)
1645 WindowObject *_self;
1646 PyObject *_args;
1647{
1648 PyObject *_res = NULL;
1649 if (!PyArg_ParseTuple(_args, ""))
1650 return NULL;
1651 ShowWindow(_self->ob_itself);
1652 Py_INCREF(Py_None);
1653 _res = Py_None;
1654 return _res;
1655}
1656
Guido van Rossum17448e21995-01-30 11:53:55 +00001657static PyMethodDef WinObj_methods[] = {
Jack Jansena05ac601999-12-12 21:41:51 +00001658 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
1659 "() -> (UInt32 outCount)"},
1660 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
1661 "() -> None"},
1662 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
1663 "() -> (WindowClass outClass)"},
1664 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
1665 "() -> (WindowAttributes outAttributes)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001666
1667#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001668 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1669 "(WCTabHandle newColorTable) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001670#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001671 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
1672 "() -> (RGBColor color)"},
1673 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
1674 "() -> (RGBColor color)"},
1675 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
1676 "(PixPatHandle outPixPat) -> None"},
1677 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
1678 "(PixPatHandle pixPat) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001679 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1680 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001681
1682#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001683 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1684 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001685#endif
1686
1687#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001688 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1689 "(Boolean update) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001690#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00001691 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1692 "(RgnHandle clobberedRgn) -> None"},
1693 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1694 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001695 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1696 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001697 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1698 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001699 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1700 "() -> None"},
1701 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1702 "(WindowPtr behindWindow) -> None"},
1703 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1704 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001705 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1706 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001707 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1708 "(long data) -> None"},
1709 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1710 "() -> (long _rv)"},
1711 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1712 "(PicHandle pic) -> None"},
1713 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1714 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001715 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1716 "() -> (short _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001717 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1718 "() -> (UInt32 outFeatures)"},
1719 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1720 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001721 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1722 "() -> None"},
1723 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1724 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001725 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
1726 "(RgnHandle region) -> None"},
1727 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
1728 "(Rect bounds) -> None"},
1729 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
1730 "(RgnHandle region) -> None"},
1731 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
1732 "(Rect bounds) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001733 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1734 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001735 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1736 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001737 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1738 "() -> (Str255 title)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001739 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
1740 "(FSSpec inFile) -> None"},
1741 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
1742 "() -> (FSSpec outFile)"},
1743 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
1744 "(AliasHandle alias) -> None"},
1745 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
1746 "() -> (AliasHandle alias)"},
1747 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
1748 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
1749 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
1750 "() -> (IconRef outIcon)"},
1751 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
1752 "(IconRef icon) -> None"},
1753 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
1754 "() -> None"},
1755 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
1756 "(Point startPt) -> None"},
1757 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
1758 "() -> (Boolean _rv)"},
1759 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
1760 "(Boolean modified) -> None"},
1761 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
1762 "() -> (Boolean _rv, EventRecord event)"},
1763 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
1764 "(Boolean hilited) -> None"},
1765 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
1766 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
1767 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
1768 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1769 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1770 "(short w, short h, Boolean fUpdate) -> None"},
1771 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1772 "(Point startPt, Rect bBox) -> (long _rv)"},
1773 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1774 "(Point startPt, Rect boundsRect) -> None"},
1775 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1776 "(short partCode, Boolean front) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001777 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1778 "() -> (Boolean _rv)"},
1779 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1780 "() -> (Boolean _rv)"},
1781 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00001782 "(Boolean collapse) -> None"},
1783 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
1784 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
1785 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
1786 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
1787 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
1788 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
1789 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
1790 "(short hGlobal, short vGlobal) -> None"},
1791 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
1792 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
1793 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
1794 "(SInt16 partCode) -> (Point ioIdealSize)"},
1795 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
1796 "() -> (Rect userState)"},
1797 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
1798 "() -> (Rect userState)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001799 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1800 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001801 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001802 "() -> None"},
1803 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1804 "(Boolean showFlag) -> None"},
1805 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1806 "(Point thePt, short partCode) -> (Boolean _rv)"},
1807 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1808 "(Point thePt) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001809
1810#ifndef TARGET_API_MAC_CARBON
Jack Jansen8f0fab71997-08-15 14:38:05 +00001811 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1812 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001813#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00001814 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1815 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00001816 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1817 "() -> None"},
1818 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1819 "() -> (short _rv)"},
1820 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1821 "(short wKind) -> None"},
1822 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1823 "() -> (Boolean _rv)"},
1824 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1825 "() -> (Boolean _rv)"},
1826 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1827 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001828
1829#ifndef TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001830 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1831 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001832#endif
1833
1834#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001835 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1836 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001837#endif
1838
1839#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001840 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1841 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001842#endif
1843
1844#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00001845 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1846 "(RgnHandle r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001847#endif
1848
1849#ifndef TARGET_API_MAC_CARBON
Jack Jansen330f5761995-11-14 10:48:54 +00001850 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1851 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001852#endif
Jack Jansen330f5761995-11-14 10:48:54 +00001853 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1854 "() -> (WindowPtr _rv)"},
1855 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1856 "() -> (Rect r)"},
1857 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1858 "() -> (Rect r)"},
1859 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1860 "(Rect r) -> None"},
1861 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1862 "(Rect r) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001863
1864#ifndef TARGET_API_MAC_CARBON
Jack Jansene180d991998-04-24 10:28:20 +00001865 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
1866 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001867#endif
Jack Jansene180d991998-04-24 10:28:20 +00001868 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
1869 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1870 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
1871 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001872 {NULL, NULL, 0}
1873};
1874
1875PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1876
1877static PyObject *WinObj_getattr(self, name)
1878 WindowObject *self;
1879 char *name;
1880{
1881 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1882}
1883
1884#define WinObj_setattr NULL
1885
Jack Jansena05ac601999-12-12 21:41:51 +00001886#define WinObj_compare NULL
1887
1888#define WinObj_repr NULL
1889
1890#define WinObj_hash NULL
1891
Guido van Rossum17448e21995-01-30 11:53:55 +00001892PyTypeObject Window_Type = {
1893 PyObject_HEAD_INIT(&PyType_Type)
1894 0, /*ob_size*/
1895 "Window", /*tp_name*/
1896 sizeof(WindowObject), /*tp_basicsize*/
1897 0, /*tp_itemsize*/
1898 /* methods */
1899 (destructor) WinObj_dealloc, /*tp_dealloc*/
1900 0, /*tp_print*/
1901 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1902 (setattrfunc) WinObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00001903 (cmpfunc) WinObj_compare, /*tp_compare*/
1904 (reprfunc) WinObj_repr, /*tp_repr*/
1905 (PyNumberMethods *)0, /* tp_as_number */
1906 (PySequenceMethods *)0, /* tp_as_sequence */
1907 (PyMappingMethods *)0, /* tp_as_mapping */
1908 (hashfunc) WinObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00001909};
1910
1911/* --------------------- End object type Window --------------------- */
1912
1913
Jack Jansen21f96871998-02-20 16:02:09 +00001914static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001915 PyObject *_self;
1916 PyObject *_args;
1917{
1918 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001919 WindowPtr _rv;
1920 short windowID;
1921 WindowPtr behind;
1922 if (!PyArg_ParseTuple(_args, "hO&",
1923 &windowID,
1924 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00001925 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001926 _rv = GetNewCWindow(windowID,
1927 (void *)0,
1928 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00001929 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001930 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00001931 return _res;
1932}
1933
Guido van Rossum17448e21995-01-30 11:53:55 +00001934static PyObject *Win_NewWindow(_self, _args)
1935 PyObject *_self;
1936 PyObject *_args;
1937{
1938 PyObject *_res = NULL;
1939 WindowPtr _rv;
1940 Rect boundsRect;
1941 Str255 title;
1942 Boolean visible;
1943 short theProc;
1944 WindowPtr behind;
1945 Boolean goAwayFlag;
1946 long refCon;
1947 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1948 PyMac_GetRect, &boundsRect,
1949 PyMac_GetStr255, title,
1950 &visible,
1951 &theProc,
1952 WinObj_Convert, &behind,
1953 &goAwayFlag,
1954 &refCon))
1955 return NULL;
1956 _rv = NewWindow((void *)0,
1957 &boundsRect,
1958 title,
1959 visible,
1960 theProc,
1961 behind,
1962 goAwayFlag,
1963 refCon);
1964 _res = Py_BuildValue("O&",
1965 WinObj_New, _rv);
1966 return _res;
1967}
1968
1969static PyObject *Win_GetNewWindow(_self, _args)
1970 PyObject *_self;
1971 PyObject *_args;
1972{
1973 PyObject *_res = NULL;
1974 WindowPtr _rv;
1975 short windowID;
1976 WindowPtr behind;
1977 if (!PyArg_ParseTuple(_args, "hO&",
1978 &windowID,
1979 WinObj_Convert, &behind))
1980 return NULL;
1981 _rv = GetNewWindow(windowID,
1982 (void *)0,
1983 behind);
1984 _res = Py_BuildValue("O&",
1985 WinObj_New, _rv);
1986 return _res;
1987}
1988
Jack Jansen21f96871998-02-20 16:02:09 +00001989static PyObject *Win_NewCWindow(_self, _args)
1990 PyObject *_self;
1991 PyObject *_args;
1992{
1993 PyObject *_res = NULL;
1994 WindowPtr _rv;
1995 Rect boundsRect;
1996 Str255 title;
1997 Boolean visible;
1998 short procID;
1999 WindowPtr behind;
2000 Boolean goAwayFlag;
2001 long refCon;
2002 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2003 PyMac_GetRect, &boundsRect,
2004 PyMac_GetStr255, title,
2005 &visible,
2006 &procID,
2007 WinObj_Convert, &behind,
2008 &goAwayFlag,
2009 &refCon))
2010 return NULL;
2011 _rv = NewCWindow((void *)0,
2012 &boundsRect,
2013 title,
2014 visible,
2015 procID,
2016 behind,
2017 goAwayFlag,
2018 refCon);
2019 _res = Py_BuildValue("O&",
2020 WinObj_New, _rv);
2021 return _res;
2022}
2023
Jack Jansena05ac601999-12-12 21:41:51 +00002024static PyObject *Win_CreateNewWindow(_self, _args)
2025 PyObject *_self;
2026 PyObject *_args;
2027{
2028 PyObject *_res = NULL;
2029 OSStatus _err;
2030 WindowClass windowClass;
2031 WindowAttributes attributes;
2032 Rect bounds;
2033 WindowPtr outWindow;
2034 if (!PyArg_ParseTuple(_args, "llO&",
2035 &windowClass,
2036 &attributes,
2037 PyMac_GetRect, &bounds))
2038 return NULL;
2039 _err = CreateNewWindow(windowClass,
2040 attributes,
2041 &bounds,
2042 &outWindow);
2043 if (_err != noErr) return PyMac_Error(_err);
2044 _res = Py_BuildValue("O&",
2045 WinObj_WhichWindow, outWindow);
2046 return _res;
2047}
2048
2049static PyObject *Win_CreateWindowFromResource(_self, _args)
2050 PyObject *_self;
2051 PyObject *_args;
2052{
2053 PyObject *_res = NULL;
2054 OSStatus _err;
2055 SInt16 resID;
2056 WindowPtr outWindow;
2057 if (!PyArg_ParseTuple(_args, "h",
2058 &resID))
2059 return NULL;
2060 _err = CreateWindowFromResource(resID,
2061 &outWindow);
2062 if (_err != noErr) return PyMac_Error(_err);
2063 _res = Py_BuildValue("O&",
2064 WinObj_WhichWindow, outWindow);
2065 return _res;
2066}
2067
2068static PyObject *Win_ShowFloatingWindows(_self, _args)
2069 PyObject *_self;
2070 PyObject *_args;
2071{
2072 PyObject *_res = NULL;
2073 OSStatus _err;
2074 if (!PyArg_ParseTuple(_args, ""))
2075 return NULL;
2076 _err = ShowFloatingWindows();
2077 if (_err != noErr) return PyMac_Error(_err);
2078 Py_INCREF(Py_None);
2079 _res = Py_None;
2080 return _res;
2081}
2082
2083static PyObject *Win_HideFloatingWindows(_self, _args)
2084 PyObject *_self;
2085 PyObject *_args;
2086{
2087 PyObject *_res = NULL;
2088 OSStatus _err;
2089 if (!PyArg_ParseTuple(_args, ""))
2090 return NULL;
2091 _err = HideFloatingWindows();
2092 if (_err != noErr) return PyMac_Error(_err);
2093 Py_INCREF(Py_None);
2094 _res = Py_None;
2095 return _res;
2096}
2097
2098static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2099 PyObject *_self;
2100 PyObject *_args;
2101{
2102 PyObject *_res = NULL;
2103 Boolean _rv;
2104 if (!PyArg_ParseTuple(_args, ""))
2105 return NULL;
2106 _rv = AreFloatingWindowsVisible();
2107 _res = Py_BuildValue("b",
2108 _rv);
2109 return _res;
2110}
2111
2112static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2113 PyObject *_self;
2114 PyObject *_args;
2115{
2116 PyObject *_res = NULL;
2117 WindowPtr _rv;
2118 if (!PyArg_ParseTuple(_args, ""))
2119 return NULL;
2120 _rv = FrontNonFloatingWindow();
2121 _res = Py_BuildValue("O&",
2122 WinObj_New, _rv);
2123 return _res;
2124}
2125
Jack Jansene79dc762000-06-02 21:35:07 +00002126#ifndef TARGET_API_MAC_CARBON
2127
Jack Jansen21f96871998-02-20 16:02:09 +00002128static PyObject *Win_SetDeskCPat(_self, _args)
2129 PyObject *_self;
2130 PyObject *_args;
2131{
2132 PyObject *_res = NULL;
2133 PixPatHandle deskPixPat;
2134 if (!PyArg_ParseTuple(_args, "O&",
2135 ResObj_Convert, &deskPixPat))
2136 return NULL;
2137 SetDeskCPat(deskPixPat);
2138 Py_INCREF(Py_None);
2139 _res = Py_None;
2140 return _res;
2141}
Jack Jansene79dc762000-06-02 21:35:07 +00002142#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002143
2144static PyObject *Win_CheckUpdate(_self, _args)
2145 PyObject *_self;
2146 PyObject *_args;
2147{
2148 PyObject *_res = NULL;
2149 Boolean _rv;
2150 EventRecord theEvent;
2151 if (!PyArg_ParseTuple(_args, ""))
2152 return NULL;
2153 _rv = CheckUpdate(&theEvent);
2154 _res = Py_BuildValue("bO&",
2155 _rv,
2156 PyMac_BuildEventRecord, &theEvent);
2157 return _res;
2158}
2159
Jack Jansen1c4e6141998-04-21 15:23:55 +00002160static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002161 PyObject *_self;
2162 PyObject *_args;
2163{
2164 PyObject *_res = NULL;
2165 short _rv;
2166 Point thePoint;
Jack Jansena05ac601999-12-12 21:41:51 +00002167 WindowPtr window;
Jack Jansen21f96871998-02-20 16:02:09 +00002168 if (!PyArg_ParseTuple(_args, "O&",
2169 PyMac_GetPoint, &thePoint))
2170 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002171 _rv = MacFindWindow(thePoint,
Jack Jansena05ac601999-12-12 21:41:51 +00002172 &window);
Jack Jansen21f96871998-02-20 16:02:09 +00002173 _res = Py_BuildValue("hO&",
2174 _rv,
Jack Jansena05ac601999-12-12 21:41:51 +00002175 WinObj_WhichWindow, window);
Jack Jansen21f96871998-02-20 16:02:09 +00002176 return _res;
2177}
2178
Guido van Rossum17448e21995-01-30 11:53:55 +00002179static PyObject *Win_FrontWindow(_self, _args)
2180 PyObject *_self;
2181 PyObject *_args;
2182{
2183 PyObject *_res = NULL;
2184 WindowPtr _rv;
2185 if (!PyArg_ParseTuple(_args, ""))
2186 return NULL;
2187 _rv = FrontWindow();
2188 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00002189 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002190 return _res;
2191}
2192
Jack Jansene79dc762000-06-02 21:35:07 +00002193#ifndef TARGET_API_MAC_CARBON
2194
Jack Jansen21f96871998-02-20 16:02:09 +00002195static PyObject *Win_InitWindows(_self, _args)
2196 PyObject *_self;
2197 PyObject *_args;
2198{
2199 PyObject *_res = NULL;
2200 if (!PyArg_ParseTuple(_args, ""))
2201 return NULL;
2202 InitWindows();
2203 Py_INCREF(Py_None);
2204 _res = Py_None;
2205 return _res;
2206}
Jack Jansene79dc762000-06-02 21:35:07 +00002207#endif
2208
2209#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002210
2211static PyObject *Win_GetWMgrPort(_self, _args)
2212 PyObject *_self;
2213 PyObject *_args;
2214{
2215 PyObject *_res = NULL;
2216 GrafPtr wPort;
2217 if (!PyArg_ParseTuple(_args, ""))
2218 return NULL;
2219 GetWMgrPort(&wPort);
2220 _res = Py_BuildValue("O&",
2221 GrafObj_New, wPort);
2222 return _res;
2223}
Jack Jansene79dc762000-06-02 21:35:07 +00002224#endif
2225
2226#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002227
2228static PyObject *Win_GetCWMgrPort(_self, _args)
2229 PyObject *_self;
2230 PyObject *_args;
2231{
2232 PyObject *_res = NULL;
2233 CGrafPtr wMgrCPort;
2234 if (!PyArg_ParseTuple(_args, ""))
2235 return NULL;
2236 GetCWMgrPort(&wMgrCPort);
2237 _res = Py_BuildValue("O&",
2238 GrafObj_New, wMgrCPort);
2239 return _res;
2240}
Jack Jansene79dc762000-06-02 21:35:07 +00002241#endif
2242
Jack Jansen8d929ae2000-06-21 22:07:06 +00002243#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002244
Jack Jansena05ac601999-12-12 21:41:51 +00002245static PyObject *Win_IsValidWindowPtr(_self, _args)
2246 PyObject *_self;
2247 PyObject *_args;
2248{
2249 PyObject *_res = NULL;
2250 Boolean _rv;
2251 GrafPtr grafPort;
2252 if (!PyArg_ParseTuple(_args, "O&",
2253 GrafObj_Convert, &grafPort))
2254 return NULL;
2255 _rv = IsValidWindowPtr(grafPort);
2256 _res = Py_BuildValue("b",
2257 _rv);
2258 return _res;
2259}
Jack Jansene79dc762000-06-02 21:35:07 +00002260#endif
2261
2262#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002263
2264static PyObject *Win_InitFloatingWindows(_self, _args)
2265 PyObject *_self;
2266 PyObject *_args;
2267{
2268 PyObject *_res = NULL;
2269 OSStatus _err;
2270 if (!PyArg_ParseTuple(_args, ""))
2271 return NULL;
2272 _err = InitFloatingWindows();
2273 if (_err != noErr) return PyMac_Error(_err);
2274 Py_INCREF(Py_None);
2275 _res = Py_None;
2276 return _res;
2277}
Jack Jansene79dc762000-06-02 21:35:07 +00002278#endif
2279
2280#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002281
Guido van Rossum17448e21995-01-30 11:53:55 +00002282static PyObject *Win_InvalRect(_self, _args)
2283 PyObject *_self;
2284 PyObject *_args;
2285{
2286 PyObject *_res = NULL;
2287 Rect badRect;
2288 if (!PyArg_ParseTuple(_args, "O&",
2289 PyMac_GetRect, &badRect))
2290 return NULL;
2291 InvalRect(&badRect);
2292 Py_INCREF(Py_None);
2293 _res = Py_None;
2294 return _res;
2295}
Jack Jansene79dc762000-06-02 21:35:07 +00002296#endif
2297
2298#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002299
Jack Jansenb7abb181995-11-15 15:18:47 +00002300static PyObject *Win_InvalRgn(_self, _args)
2301 PyObject *_self;
2302 PyObject *_args;
2303{
2304 PyObject *_res = NULL;
2305 RgnHandle badRgn;
2306 if (!PyArg_ParseTuple(_args, "O&",
2307 ResObj_Convert, &badRgn))
2308 return NULL;
2309 InvalRgn(badRgn);
2310 Py_INCREF(Py_None);
2311 _res = Py_None;
2312 return _res;
2313}
Jack Jansene79dc762000-06-02 21:35:07 +00002314#endif
2315
2316#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002317
Guido van Rossum17448e21995-01-30 11:53:55 +00002318static PyObject *Win_ValidRect(_self, _args)
2319 PyObject *_self;
2320 PyObject *_args;
2321{
2322 PyObject *_res = NULL;
2323 Rect goodRect;
2324 if (!PyArg_ParseTuple(_args, "O&",
2325 PyMac_GetRect, &goodRect))
2326 return NULL;
2327 ValidRect(&goodRect);
2328 Py_INCREF(Py_None);
2329 _res = Py_None;
2330 return _res;
2331}
Jack Jansene79dc762000-06-02 21:35:07 +00002332#endif
2333
2334#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002335
Jack Jansenb7abb181995-11-15 15:18:47 +00002336static PyObject *Win_ValidRgn(_self, _args)
2337 PyObject *_self;
2338 PyObject *_args;
2339{
2340 PyObject *_res = NULL;
2341 RgnHandle goodRgn;
2342 if (!PyArg_ParseTuple(_args, "O&",
2343 ResObj_Convert, &goodRgn))
2344 return NULL;
2345 ValidRgn(goodRgn);
2346 Py_INCREF(Py_None);
2347 _res = Py_None;
2348 return _res;
2349}
Jack Jansene79dc762000-06-02 21:35:07 +00002350#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00002351
Jack Jansen21f96871998-02-20 16:02:09 +00002352static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002353 PyObject *_self;
2354 PyObject *_args;
2355{
2356 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00002357 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +00002358 Boolean collapse;
Jack Jansen21f96871998-02-20 16:02:09 +00002359 if (!PyArg_ParseTuple(_args, "b",
Jack Jansena05ac601999-12-12 21:41:51 +00002360 &collapse))
Guido van Rossum17448e21995-01-30 11:53:55 +00002361 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002362 _err = CollapseAllWindows(collapse);
Jack Jansene4349e81999-03-04 22:53:24 +00002363 if (_err != noErr) return PyMac_Error(_err);
2364 Py_INCREF(Py_None);
2365 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00002366 return _res;
2367}
2368
2369static PyObject *Win_PinRect(_self, _args)
2370 PyObject *_self;
2371 PyObject *_args;
2372{
2373 PyObject *_res = NULL;
2374 long _rv;
2375 Rect theRect;
2376 Point thePt;
2377 if (!PyArg_ParseTuple(_args, "O&O&",
2378 PyMac_GetRect, &theRect,
2379 PyMac_GetPoint, &thePt))
2380 return NULL;
2381 _rv = PinRect(&theRect,
2382 thePt);
2383 _res = Py_BuildValue("l",
2384 _rv);
2385 return _res;
2386}
2387
Jack Jansen21f96871998-02-20 16:02:09 +00002388static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002389 PyObject *_self;
2390 PyObject *_args;
2391{
2392 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002393 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00002394 if (!PyArg_ParseTuple(_args, ""))
2395 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002396 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00002397 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002398 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002399 return _res;
2400}
2401
Jack Jansend4c26461995-08-17 14:35:56 +00002402static PyObject *Win_WhichWindow(_self, _args)
2403 PyObject *_self;
2404 PyObject *_args;
2405{
2406 PyObject *_res = NULL;
2407
2408 long ptr;
2409
2410 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2411 return NULL;
2412 return WinObj_WhichWindow((WindowPtr)ptr);
2413
2414}
2415
Jack Jansene180d991998-04-24 10:28:20 +00002416static PyObject *Win_FindWindow(_self, _args)
2417 PyObject *_self;
2418 PyObject *_args;
2419{
2420 PyObject *_res = NULL;
2421 short _rv;
2422 Point thePoint;
2423 WindowPtr theWindow;
2424 if (!PyArg_ParseTuple(_args, "O&",
2425 PyMac_GetPoint, &thePoint))
2426 return NULL;
2427 _rv = FindWindow(thePoint,
2428 &theWindow);
2429 _res = Py_BuildValue("hO&",
2430 _rv,
2431 WinObj_WhichWindow, theWindow);
2432 return _res;
2433}
2434
Guido van Rossum17448e21995-01-30 11:53:55 +00002435static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00002436 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2437 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002438 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2439 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2440 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2441 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002442 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2443 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002444 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
2445 "(WindowClass windowClass, WindowAttributes attributes, Rect bounds) -> (WindowPtr outWindow)"},
2446 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2447 "(SInt16 resID) -> (WindowPtr outWindow)"},
2448 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2449 "() -> None"},
2450 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2451 "() -> None"},
2452 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2453 "() -> (Boolean _rv)"},
2454 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2455 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002456
2457#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002458 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2459 "(PixPatHandle deskPixPat) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002460#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002461 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2462 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002463 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002464 "(Point thePoint) -> (short _rv, WindowPtr window)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002465 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2466 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002467
2468#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002469 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2470 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002471#endif
2472
2473#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002474 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2475 "() -> (GrafPtr wPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002476#endif
2477
2478#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002479 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2480 "() -> (CGrafPtr wMgrCPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002481#endif
2482
Jack Jansen8d929ae2000-06-21 22:07:06 +00002483#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002484 {"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1,
2485 "(GrafPtr grafPort) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002486#endif
2487
2488#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002489 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2490 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002491#endif
2492
2493#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002494 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2495 "(Rect badRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002496#endif
2497
2498#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002499 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2500 "(RgnHandle badRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002501#endif
2502
2503#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002504 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2505 "(Rect goodRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002506#endif
2507
2508#ifndef TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002509 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2510 "(RgnHandle goodRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002511#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002512 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002513 "(Boolean collapse) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002514 {"PinRect", (PyCFunction)Win_PinRect, 1,
2515 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002516 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2517 "() -> (RgnHandle _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00002518 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2519 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00002520 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2521 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002522 {NULL, NULL, 0}
2523};
2524
2525
2526
2527/* Return the object corresponding to the window, or NULL */
2528
2529PyObject *
2530WinObj_WhichWindow(w)
2531 WindowPtr w;
2532{
2533 PyObject *it;
2534
2535 /* XXX What if we find a stdwin window or a window belonging
2536 to some other package? */
Guido van Rossum97842951995-02-19 15:59:49 +00002537 if (w == NULL)
2538 it = NULL;
2539 else
2540 it = (PyObject *) GetWRefCon(w);
Guido van Rossum17448e21995-01-30 11:53:55 +00002541 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
2542 it = Py_None;
2543 Py_INCREF(it);
2544 return it;
2545}
2546
2547
2548void initWin()
2549{
2550 PyObject *m;
2551 PyObject *d;
2552
2553
2554
2555
2556 m = Py_InitModule("Win", Win_methods);
2557 d = PyModule_GetDict(m);
2558 Win_Error = PyMac_GetOSErrException();
2559 if (Win_Error == NULL ||
2560 PyDict_SetItemString(d, "Error", Win_Error) != 0)
2561 Py_FatalError("can't initialize Win.Error");
Jack Jansena755e681997-09-20 17:40:22 +00002562 Window_Type.ob_type = &PyType_Type;
2563 Py_INCREF(&Window_Type);
2564 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
2565 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002566}
2567
2568/* ========================= End module Win ========================= */
2569