blob: 7984293c9305cf6742dacf49636e62fca98a17e9 [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
Jack Jansen32248652000-12-19 22:23:06 +000014/* Carbon calls that we emulate in classic mode */
Jack Jansen723ad8a2000-12-12 22:10:21 +000015#define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
16#define GetWindowFromPort(port) ((WindowRef)(port))
17#define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
18#endif
Jack Jansen32248652000-12-19 22:23:06 +000019#if ACCESSOR_CALLS_ARE_FUNCTIONS
20/* Classic calls that we emulate in carbon mode */
21#define GetWindowUpdateRgn(win, rgn) GetWindowRegion((win), kWindowUpdateRgn, (rgn))
22#define GetWindowStructureRgn(win, rgn) GetWindowRegion((win), kWindowStructureRgn, (rgn))
23#define GetWindowContentRgn(win, rgn) GetWindowRegion((win), kWindowContentRgn, (rgn))
24#endif
Jack Jansen723ad8a2000-12-12 22:10:21 +000025
Jack Jansen0aee0e62000-08-25 22:17:51 +000026/* Function to dispose a window, with a "normal" calling sequence */
27static void
28PyMac_AutoDisposeWindow(WindowPtr w)
29{
30 DisposeWindow(w);
31}
Guido van Rossum17448e21995-01-30 11:53:55 +000032
Guido van Rossum17448e21995-01-30 11:53:55 +000033static PyObject *Win_Error;
34
35/* ----------------------- Object type Window ----------------------- */
36
37PyTypeObject Window_Type;
38
39#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
40
41typedef struct WindowObject {
42 PyObject_HEAD
43 WindowPtr ob_itself;
Jack Jansen0aee0e62000-08-25 22:17:51 +000044 void (*ob_freeit)(WindowPtr ptr);
Guido van Rossum17448e21995-01-30 11:53:55 +000045} WindowObject;
46
47PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000048 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000049{
50 WindowObject *it;
51 if (itself == NULL) return PyMac_Error(resNotFound);
52 it = PyObject_NEW(WindowObject, &Window_Type);
53 if (it == NULL) return NULL;
54 it->ob_itself = itself;
Jack Jansen80716f02000-12-14 22:29:00 +000055 it->ob_freeit = NULL;
56 if (GetWRefCon(itself) == 0)
57 {
58 SetWRefCon(itself, (long)it);
59 it->ob_freeit = PyMac_AutoDisposeWindow;
60 }
Guido van Rossum17448e21995-01-30 11:53:55 +000061 return (PyObject *)it;
62}
63WinObj_Convert(v, p_itself)
64 PyObject *v;
65 WindowPtr *p_itself;
66{
67 if (DlgObj_Check(v)) {
Jack Jansen723ad8a2000-12-12 22:10:21 +000068 *p_itself = DlgObj_ConvertToWindow(v);
Guido van Rossum17448e21995-01-30 11:53:55 +000069 return 1;
70 }
71
72 if (v == Py_None) { *p_itself = NULL; return 1; }
73 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
74
75 if (!WinObj_Check(v))
76 {
77 PyErr_SetString(PyExc_TypeError, "Window required");
78 return 0;
79 }
80 *p_itself = ((WindowObject *)v)->ob_itself;
81 return 1;
82}
83
84static void WinObj_dealloc(self)
85 WindowObject *self;
86{
Jack Jansen0aee0e62000-08-25 22:17:51 +000087 if (self->ob_freeit && self->ob_itself)
88 {
Jack Jansen80716f02000-12-14 22:29:00 +000089 SetWRefCon(self->ob_itself, 0);
Jack Jansen0aee0e62000-08-25 22:17:51 +000090 self->ob_freeit(self->ob_itself);
91 }
92 self->ob_itself = NULL;
Jack Jansen80716f02000-12-14 22:29:00 +000093 self->ob_freeit = NULL;
Guido van Rossum17448e21995-01-30 11:53:55 +000094 PyMem_DEL(self);
95}
96
Jack Jansena05ac601999-12-12 21:41:51 +000097static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
98 WindowObject *_self;
99 PyObject *_args;
100{
101 PyObject *_res = NULL;
102 OSStatus _err;
103 UInt32 outCount;
104 if (!PyArg_ParseTuple(_args, ""))
105 return NULL;
106 _err = GetWindowOwnerCount(_self->ob_itself,
107 &outCount);
108 if (_err != noErr) return PyMac_Error(_err);
109 _res = Py_BuildValue("l",
110 outCount);
111 return _res;
112}
113
114static PyObject *WinObj_CloneWindow(_self, _args)
115 WindowObject *_self;
116 PyObject *_args;
117{
118 PyObject *_res = NULL;
119 OSStatus _err;
120 if (!PyArg_ParseTuple(_args, ""))
121 return NULL;
122 _err = CloneWindow(_self->ob_itself);
123 if (_err != noErr) return PyMac_Error(_err);
124 Py_INCREF(Py_None);
125 _res = Py_None;
126 return _res;
127}
128
Jack Jansen723ad8a2000-12-12 22:10:21 +0000129#if TARGET_API_MAC_CARBON
130
131static PyObject *WinObj_ReshapeCustomWindow(_self, _args)
132 WindowObject *_self;
133 PyObject *_args;
134{
135 PyObject *_res = NULL;
136 OSStatus _err;
137 if (!PyArg_ParseTuple(_args, ""))
138 return NULL;
139 _err = ReshapeCustomWindow(_self->ob_itself);
140 if (_err != noErr) return PyMac_Error(_err);
141 Py_INCREF(Py_None);
142 _res = Py_None;
143 return _res;
144}
145#endif
146
Jack Jansena05ac601999-12-12 21:41:51 +0000147static PyObject *WinObj_GetWindowClass(_self, _args)
148 WindowObject *_self;
149 PyObject *_args;
150{
151 PyObject *_res = NULL;
152 OSStatus _err;
153 WindowClass outClass;
154 if (!PyArg_ParseTuple(_args, ""))
155 return NULL;
156 _err = GetWindowClass(_self->ob_itself,
157 &outClass);
158 if (_err != noErr) return PyMac_Error(_err);
159 _res = Py_BuildValue("l",
160 outClass);
161 return _res;
162}
163
164static PyObject *WinObj_GetWindowAttributes(_self, _args)
165 WindowObject *_self;
166 PyObject *_args;
167{
168 PyObject *_res = NULL;
169 OSStatus _err;
170 WindowAttributes outAttributes;
171 if (!PyArg_ParseTuple(_args, ""))
172 return NULL;
173 _err = GetWindowAttributes(_self->ob_itself,
174 &outAttributes);
175 if (_err != noErr) return PyMac_Error(_err);
176 _res = Py_BuildValue("l",
177 outAttributes);
178 return _res;
179}
180
Jack Jansen723ad8a2000-12-12 22:10:21 +0000181#if TARGET_API_MAC_CARBON
182
183static PyObject *WinObj_ChangeWindowAttributes(_self, _args)
184 WindowObject *_self;
185 PyObject *_args;
186{
187 PyObject *_res = NULL;
188 OSStatus _err;
189 WindowAttributes setTheseAttributes;
190 WindowAttributes clearTheseAttributes;
191 if (!PyArg_ParseTuple(_args, "ll",
192 &setTheseAttributes,
193 &clearTheseAttributes))
194 return NULL;
195 _err = ChangeWindowAttributes(_self->ob_itself,
196 setTheseAttributes,
197 clearTheseAttributes);
198 if (_err != noErr) return PyMac_Error(_err);
199 Py_INCREF(Py_None);
200 _res = Py_None;
201 return _res;
202}
203#endif
204
Jack Jansen74a1e632000-07-14 22:37:27 +0000205#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000206
Jack Jansen21f96871998-02-20 16:02:09 +0000207static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000208 WindowObject *_self;
209 PyObject *_args;
210{
211 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000212 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000213 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000214 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000215 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000216 SetWinColor(_self->ob_itself,
217 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000218 Py_INCREF(Py_None);
219 _res = Py_None;
220 return _res;
221}
Jack Jansene79dc762000-06-02 21:35:07 +0000222#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000223
Jack Jansena05ac601999-12-12 21:41:51 +0000224static PyObject *WinObj_SetWindowContentColor(_self, _args)
225 WindowObject *_self;
226 PyObject *_args;
227{
228 PyObject *_res = NULL;
229 OSStatus _err;
230 RGBColor color;
Jack Jansen723ad8a2000-12-12 22:10:21 +0000231 if (!PyArg_ParseTuple(_args, "O&",
232 QdRGB_Convert, &color))
Jack Jansena05ac601999-12-12 21:41:51 +0000233 return NULL;
234 _err = SetWindowContentColor(_self->ob_itself,
235 &color);
236 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen723ad8a2000-12-12 22:10:21 +0000237 Py_INCREF(Py_None);
238 _res = Py_None;
Jack Jansena05ac601999-12-12 21:41:51 +0000239 return _res;
240}
241
242static PyObject *WinObj_GetWindowContentColor(_self, _args)
243 WindowObject *_self;
244 PyObject *_args;
245{
246 PyObject *_res = NULL;
247 OSStatus _err;
248 RGBColor color;
249 if (!PyArg_ParseTuple(_args, ""))
250 return NULL;
251 _err = GetWindowContentColor(_self->ob_itself,
252 &color);
253 if (_err != noErr) return PyMac_Error(_err);
254 _res = Py_BuildValue("O&",
255 QdRGB_New, &color);
256 return _res;
257}
258
259static PyObject *WinObj_GetWindowContentPattern(_self, _args)
260 WindowObject *_self;
261 PyObject *_args;
262{
263 PyObject *_res = NULL;
264 OSStatus _err;
265 PixPatHandle outPixPat;
266 if (!PyArg_ParseTuple(_args, "O&",
267 ResObj_Convert, &outPixPat))
268 return NULL;
269 _err = GetWindowContentPattern(_self->ob_itself,
270 outPixPat);
271 if (_err != noErr) return PyMac_Error(_err);
272 Py_INCREF(Py_None);
273 _res = Py_None;
274 return _res;
275}
276
277static PyObject *WinObj_SetWindowContentPattern(_self, _args)
278 WindowObject *_self;
279 PyObject *_args;
280{
281 PyObject *_res = NULL;
282 OSStatus _err;
283 PixPatHandle pixPat;
284 if (!PyArg_ParseTuple(_args, "O&",
285 ResObj_Convert, &pixPat))
286 return NULL;
287 _err = SetWindowContentPattern(_self->ob_itself,
288 pixPat);
289 if (_err != noErr) return PyMac_Error(_err);
290 Py_INCREF(Py_None);
291 _res = Py_None;
292 return _res;
293}
294
Jack Jansen723ad8a2000-12-12 22:10:21 +0000295#if TARGET_API_MAC_CARBON
296
297static PyObject *WinObj_ScrollWindowRect(_self, _args)
298 WindowObject *_self;
299 PyObject *_args;
300{
301 PyObject *_res = NULL;
302 OSStatus _err;
303 Rect inScrollRect;
304 SInt16 inHPixels;
305 SInt16 inVPixels;
306 ScrollWindowOptions inOptions;
307 RgnHandle outExposedRgn;
308 if (!PyArg_ParseTuple(_args, "O&hhlO&",
309 PyMac_GetRect, &inScrollRect,
310 &inHPixels,
311 &inVPixels,
312 &inOptions,
313 ResObj_Convert, &outExposedRgn))
314 return NULL;
315 _err = ScrollWindowRect(_self->ob_itself,
316 &inScrollRect,
317 inHPixels,
318 inVPixels,
319 inOptions,
320 outExposedRgn);
321 if (_err != noErr) return PyMac_Error(_err);
322 Py_INCREF(Py_None);
323 _res = Py_None;
324 return _res;
325}
326#endif
327
328#if TARGET_API_MAC_CARBON
329
330static PyObject *WinObj_ScrollWindowRegion(_self, _args)
331 WindowObject *_self;
332 PyObject *_args;
333{
334 PyObject *_res = NULL;
335 OSStatus _err;
336 RgnHandle inScrollRgn;
337 SInt16 inHPixels;
338 SInt16 inVPixels;
339 ScrollWindowOptions inOptions;
340 RgnHandle outExposedRgn;
341 if (!PyArg_ParseTuple(_args, "O&hhlO&",
342 ResObj_Convert, &inScrollRgn,
343 &inHPixels,
344 &inVPixels,
345 &inOptions,
346 ResObj_Convert, &outExposedRgn))
347 return NULL;
348 _err = ScrollWindowRegion(_self->ob_itself,
349 inScrollRgn,
350 inHPixels,
351 inVPixels,
352 inOptions,
353 outExposedRgn);
354 if (_err != noErr) return PyMac_Error(_err);
355 Py_INCREF(Py_None);
356 _res = Py_None;
357 return _res;
358}
359#endif
360
Guido van Rossum17448e21995-01-30 11:53:55 +0000361static PyObject *WinObj_ClipAbove(_self, _args)
362 WindowObject *_self;
363 PyObject *_args;
364{
365 PyObject *_res = NULL;
366 if (!PyArg_ParseTuple(_args, ""))
367 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000368 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000369 Py_INCREF(Py_None);
370 _res = Py_None;
371 return _res;
372}
373
Jack Jansen74a1e632000-07-14 22:37:27 +0000374#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000375
Guido van Rossum17448e21995-01-30 11:53:55 +0000376static PyObject *WinObj_SaveOld(_self, _args)
377 WindowObject *_self;
378 PyObject *_args;
379{
380 PyObject *_res = NULL;
381 if (!PyArg_ParseTuple(_args, ""))
382 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000383 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000384 Py_INCREF(Py_None);
385 _res = Py_None;
386 return _res;
387}
Jack Jansene79dc762000-06-02 21:35:07 +0000388#endif
389
Jack Jansen74a1e632000-07-14 22:37:27 +0000390#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000391
392static PyObject *WinObj_DrawNew(_self, _args)
393 WindowObject *_self;
394 PyObject *_args;
395{
396 PyObject *_res = NULL;
397 Boolean update;
398 if (!PyArg_ParseTuple(_args, "b",
399 &update))
400 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000401 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000402 update);
403 Py_INCREF(Py_None);
404 _res = Py_None;
405 return _res;
406}
Jack Jansene79dc762000-06-02 21:35:07 +0000407#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000408
Jack Jansen80716f02000-12-14 22:29:00 +0000409static PyObject *WinObj_PaintOne(_self, _args)
410 WindowObject *_self;
411 PyObject *_args;
412{
413 PyObject *_res = NULL;
414 RgnHandle clobberedRgn;
415 if (!PyArg_ParseTuple(_args, "O&",
416 ResObj_Convert, &clobberedRgn))
417 return NULL;
418 PaintOne(_self->ob_itself,
419 clobberedRgn);
420 Py_INCREF(Py_None);
421 _res = Py_None;
422 return _res;
423}
424
425static PyObject *WinObj_PaintBehind(_self, _args)
426 WindowObject *_self;
427 PyObject *_args;
428{
429 PyObject *_res = NULL;
430 RgnHandle clobberedRgn;
431 if (!PyArg_ParseTuple(_args, "O&",
432 ResObj_Convert, &clobberedRgn))
433 return NULL;
434 PaintBehind(_self->ob_itself,
435 clobberedRgn);
436 Py_INCREF(Py_None);
437 _res = Py_None;
438 return _res;
439}
440
Guido van Rossum17448e21995-01-30 11:53:55 +0000441static PyObject *WinObj_CalcVis(_self, _args)
442 WindowObject *_self;
443 PyObject *_args;
444{
445 PyObject *_res = NULL;
446 if (!PyArg_ParseTuple(_args, ""))
447 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000448 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000449 Py_INCREF(Py_None);
450 _res = Py_None;
451 return _res;
452}
453
Jack Jansen80716f02000-12-14 22:29:00 +0000454static PyObject *WinObj_CalcVisBehind(_self, _args)
455 WindowObject *_self;
456 PyObject *_args;
457{
458 PyObject *_res = NULL;
459 RgnHandle clobberedRgn;
460 if (!PyArg_ParseTuple(_args, "O&",
461 ResObj_Convert, &clobberedRgn))
462 return NULL;
463 CalcVisBehind(_self->ob_itself,
464 clobberedRgn);
465 Py_INCREF(Py_None);
466 _res = Py_None;
467 return _res;
468}
469
Jack Jansen21f96871998-02-20 16:02:09 +0000470static PyObject *WinObj_BringToFront(_self, _args)
471 WindowObject *_self;
472 PyObject *_args;
473{
474 PyObject *_res = NULL;
475 if (!PyArg_ParseTuple(_args, ""))
476 return NULL;
477 BringToFront(_self->ob_itself);
478 Py_INCREF(Py_None);
479 _res = Py_None;
480 return _res;
481}
482
483static PyObject *WinObj_SendBehind(_self, _args)
484 WindowObject *_self;
485 PyObject *_args;
486{
487 PyObject *_res = NULL;
488 WindowPtr behindWindow;
489 if (!PyArg_ParseTuple(_args, "O&",
490 WinObj_Convert, &behindWindow))
491 return NULL;
492 SendBehind(_self->ob_itself,
493 behindWindow);
494 Py_INCREF(Py_None);
495 _res = Py_None;
496 return _res;
497}
498
499static PyObject *WinObj_SelectWindow(_self, _args)
500 WindowObject *_self;
501 PyObject *_args;
502{
503 PyObject *_res = NULL;
504 if (!PyArg_ParseTuple(_args, ""))
505 return NULL;
506 SelectWindow(_self->ob_itself);
507 Py_INCREF(Py_None);
508 _res = Py_None;
509 return _res;
510}
511
Jack Jansen723ad8a2000-12-12 22:10:21 +0000512#if TARGET_API_MAC_CARBON
513
514static PyObject *WinObj_GetNextWindowOfClass(_self, _args)
515 WindowObject *_self;
516 PyObject *_args;
517{
518 PyObject *_res = NULL;
519 WindowPtr _rv;
520 WindowClass inWindowClass;
521 Boolean mustBeVisible;
522 if (!PyArg_ParseTuple(_args, "lb",
523 &inWindowClass,
524 &mustBeVisible))
525 return NULL;
526 _rv = GetNextWindowOfClass(_self->ob_itself,
527 inWindowClass,
528 mustBeVisible);
529 _res = Py_BuildValue("O&",
530 WinObj_New, _rv);
531 return _res;
532}
533#endif
534
535#if !TARGET_API_MAC_CARBON
536
537static PyObject *WinObj_IsValidWindowPtr(_self, _args)
538 WindowObject *_self;
539 PyObject *_args;
540{
541 PyObject *_res = NULL;
542 Boolean _rv;
543 if (!PyArg_ParseTuple(_args, ""))
544 return NULL;
545 _rv = IsValidWindowPtr(_self->ob_itself);
546 _res = Py_BuildValue("b",
547 _rv);
548 return _res;
549}
550#endif
551
Jack Jansen1c4e6141998-04-21 15:23:55 +0000552static PyObject *WinObj_HiliteWindow(_self, _args)
553 WindowObject *_self;
554 PyObject *_args;
555{
556 PyObject *_res = NULL;
557 Boolean fHilite;
558 if (!PyArg_ParseTuple(_args, "b",
559 &fHilite))
560 return NULL;
561 HiliteWindow(_self->ob_itself,
562 fHilite);
563 Py_INCREF(Py_None);
564 _res = Py_None;
565 return _res;
566}
567
Jack Jansen21f96871998-02-20 16:02:09 +0000568static PyObject *WinObj_SetWRefCon(_self, _args)
569 WindowObject *_self;
570 PyObject *_args;
571{
572 PyObject *_res = NULL;
573 long data;
574 if (!PyArg_ParseTuple(_args, "l",
575 &data))
576 return NULL;
577 SetWRefCon(_self->ob_itself,
578 data);
579 Py_INCREF(Py_None);
580 _res = Py_None;
581 return _res;
582}
583
584static PyObject *WinObj_GetWRefCon(_self, _args)
585 WindowObject *_self;
586 PyObject *_args;
587{
588 PyObject *_res = NULL;
589 long _rv;
590 if (!PyArg_ParseTuple(_args, ""))
591 return NULL;
592 _rv = GetWRefCon(_self->ob_itself);
593 _res = Py_BuildValue("l",
594 _rv);
595 return _res;
596}
597
598static PyObject *WinObj_SetWindowPic(_self, _args)
599 WindowObject *_self;
600 PyObject *_args;
601{
602 PyObject *_res = NULL;
603 PicHandle pic;
604 if (!PyArg_ParseTuple(_args, "O&",
605 ResObj_Convert, &pic))
606 return NULL;
607 SetWindowPic(_self->ob_itself,
608 pic);
609 Py_INCREF(Py_None);
610 _res = Py_None;
611 return _res;
612}
613
614static PyObject *WinObj_GetWindowPic(_self, _args)
615 WindowObject *_self;
616 PyObject *_args;
617{
618 PyObject *_res = NULL;
619 PicHandle _rv;
620 if (!PyArg_ParseTuple(_args, ""))
621 return NULL;
622 _rv = GetWindowPic(_self->ob_itself);
623 _res = Py_BuildValue("O&",
624 ResObj_New, _rv);
625 return _res;
626}
627
628static PyObject *WinObj_GetWVariant(_self, _args)
629 WindowObject *_self;
630 PyObject *_args;
631{
632 PyObject *_res = NULL;
633 short _rv;
634 if (!PyArg_ParseTuple(_args, ""))
635 return NULL;
636 _rv = GetWVariant(_self->ob_itself);
637 _res = Py_BuildValue("h",
638 _rv);
639 return _res;
640}
641
Jack Jansena05ac601999-12-12 21:41:51 +0000642static PyObject *WinObj_GetWindowFeatures(_self, _args)
643 WindowObject *_self;
644 PyObject *_args;
645{
646 PyObject *_res = NULL;
647 OSStatus _err;
648 UInt32 outFeatures;
649 if (!PyArg_ParseTuple(_args, ""))
650 return NULL;
651 _err = GetWindowFeatures(_self->ob_itself,
652 &outFeatures);
653 if (_err != noErr) return PyMac_Error(_err);
654 _res = Py_BuildValue("l",
655 outFeatures);
656 return _res;
657}
658
659static PyObject *WinObj_GetWindowRegion(_self, _args)
660 WindowObject *_self;
661 PyObject *_args;
662{
663 PyObject *_res = NULL;
664 OSStatus _err;
665 WindowRegionCode inRegionCode;
666 RgnHandle ioWinRgn;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000667 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +0000668 &inRegionCode,
669 ResObj_Convert, &ioWinRgn))
670 return NULL;
671 _err = GetWindowRegion(_self->ob_itself,
672 inRegionCode,
673 ioWinRgn);
674 if (_err != noErr) return PyMac_Error(_err);
675 Py_INCREF(Py_None);
676 _res = Py_None;
677 return _res;
678}
679
Jack Jansen21f96871998-02-20 16:02:09 +0000680static PyObject *WinObj_BeginUpdate(_self, _args)
681 WindowObject *_self;
682 PyObject *_args;
683{
684 PyObject *_res = NULL;
685 if (!PyArg_ParseTuple(_args, ""))
686 return NULL;
687 BeginUpdate(_self->ob_itself);
688 Py_INCREF(Py_None);
689 _res = Py_None;
690 return _res;
691}
692
693static PyObject *WinObj_EndUpdate(_self, _args)
694 WindowObject *_self;
695 PyObject *_args;
696{
697 PyObject *_res = NULL;
698 if (!PyArg_ParseTuple(_args, ""))
699 return NULL;
700 EndUpdate(_self->ob_itself);
701 Py_INCREF(Py_None);
702 _res = Py_None;
703 return _res;
704}
705
Jack Jansena05ac601999-12-12 21:41:51 +0000706static PyObject *WinObj_InvalWindowRgn(_self, _args)
707 WindowObject *_self;
708 PyObject *_args;
709{
710 PyObject *_res = NULL;
711 OSStatus _err;
712 RgnHandle region;
713 if (!PyArg_ParseTuple(_args, "O&",
714 ResObj_Convert, &region))
715 return NULL;
716 _err = InvalWindowRgn(_self->ob_itself,
717 region);
718 if (_err != noErr) return PyMac_Error(_err);
719 Py_INCREF(Py_None);
720 _res = Py_None;
721 return _res;
722}
723
724static PyObject *WinObj_InvalWindowRect(_self, _args)
725 WindowObject *_self;
726 PyObject *_args;
727{
728 PyObject *_res = NULL;
729 OSStatus _err;
730 Rect bounds;
731 if (!PyArg_ParseTuple(_args, "O&",
732 PyMac_GetRect, &bounds))
733 return NULL;
734 _err = InvalWindowRect(_self->ob_itself,
735 &bounds);
736 if (_err != noErr) return PyMac_Error(_err);
737 Py_INCREF(Py_None);
738 _res = Py_None;
739 return _res;
740}
741
742static PyObject *WinObj_ValidWindowRgn(_self, _args)
743 WindowObject *_self;
744 PyObject *_args;
745{
746 PyObject *_res = NULL;
747 OSStatus _err;
748 RgnHandle region;
749 if (!PyArg_ParseTuple(_args, "O&",
750 ResObj_Convert, &region))
751 return NULL;
752 _err = ValidWindowRgn(_self->ob_itself,
753 region);
754 if (_err != noErr) return PyMac_Error(_err);
755 Py_INCREF(Py_None);
756 _res = Py_None;
757 return _res;
758}
759
760static PyObject *WinObj_ValidWindowRect(_self, _args)
761 WindowObject *_self;
762 PyObject *_args;
763{
764 PyObject *_res = NULL;
765 OSStatus _err;
766 Rect bounds;
767 if (!PyArg_ParseTuple(_args, "O&",
768 PyMac_GetRect, &bounds))
769 return NULL;
770 _err = ValidWindowRect(_self->ob_itself,
771 &bounds);
772 if (_err != noErr) return PyMac_Error(_err);
773 Py_INCREF(Py_None);
774 _res = Py_None;
775 return _res;
776}
777
Jack Jansen21f96871998-02-20 16:02:09 +0000778static PyObject *WinObj_DrawGrowIcon(_self, _args)
779 WindowObject *_self;
780 PyObject *_args;
781{
782 PyObject *_res = NULL;
783 if (!PyArg_ParseTuple(_args, ""))
784 return NULL;
785 DrawGrowIcon(_self->ob_itself);
786 Py_INCREF(Py_None);
787 _res = Py_None;
788 return _res;
789}
790
Jack Jansen21f96871998-02-20 16:02:09 +0000791static PyObject *WinObj_SetWTitle(_self, _args)
792 WindowObject *_self;
793 PyObject *_args;
794{
795 PyObject *_res = NULL;
796 Str255 title;
797 if (!PyArg_ParseTuple(_args, "O&",
798 PyMac_GetStr255, title))
799 return NULL;
800 SetWTitle(_self->ob_itself,
801 title);
802 Py_INCREF(Py_None);
803 _res = Py_None;
804 return _res;
805}
806
807static PyObject *WinObj_GetWTitle(_self, _args)
808 WindowObject *_self;
809 PyObject *_args;
810{
811 PyObject *_res = NULL;
812 Str255 title;
813 if (!PyArg_ParseTuple(_args, ""))
814 return NULL;
815 GetWTitle(_self->ob_itself,
816 title);
817 _res = Py_BuildValue("O&",
818 PyMac_BuildStr255, title);
819 return _res;
820}
821
Jack Jansena05ac601999-12-12 21:41:51 +0000822static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000823 WindowObject *_self;
824 PyObject *_args;
825{
826 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000827 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +0000828 FSSpec inFile;
829 if (!PyArg_ParseTuple(_args, "O&",
830 PyMac_GetFSSpec, &inFile))
Jack Jansen21f96871998-02-20 16:02:09 +0000831 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +0000832 _err = SetWindowProxyFSSpec(_self->ob_itself,
833 &inFile);
834 if (_err != noErr) return PyMac_Error(_err);
835 Py_INCREF(Py_None);
836 _res = Py_None;
837 return _res;
838}
839
840static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
841 WindowObject *_self;
842 PyObject *_args;
843{
844 PyObject *_res = NULL;
845 OSStatus _err;
846 FSSpec outFile;
847 if (!PyArg_ParseTuple(_args, ""))
848 return NULL;
849 _err = GetWindowProxyFSSpec(_self->ob_itself,
850 &outFile);
851 if (_err != noErr) return PyMac_Error(_err);
852 _res = Py_BuildValue("O&",
Jack Jansene79dc762000-06-02 21:35:07 +0000853 PyMac_BuildFSSpec, outFile);
Jack Jansena05ac601999-12-12 21:41:51 +0000854 return _res;
855}
856
857static PyObject *WinObj_SetWindowProxyAlias(_self, _args)
858 WindowObject *_self;
859 PyObject *_args;
860{
861 PyObject *_res = NULL;
862 OSStatus _err;
863 AliasHandle alias;
864 if (!PyArg_ParseTuple(_args, "O&",
865 ResObj_Convert, &alias))
866 return NULL;
867 _err = SetWindowProxyAlias(_self->ob_itself,
868 alias);
869 if (_err != noErr) return PyMac_Error(_err);
870 Py_INCREF(Py_None);
871 _res = Py_None;
872 return _res;
873}
874
875static PyObject *WinObj_GetWindowProxyAlias(_self, _args)
876 WindowObject *_self;
877 PyObject *_args;
878{
879 PyObject *_res = NULL;
880 OSStatus _err;
881 AliasHandle alias;
882 if (!PyArg_ParseTuple(_args, ""))
883 return NULL;
884 _err = GetWindowProxyAlias(_self->ob_itself,
885 &alias);
886 if (_err != noErr) return PyMac_Error(_err);
887 _res = Py_BuildValue("O&",
888 ResObj_New, alias);
889 return _res;
890}
891
892static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args)
893 WindowObject *_self;
894 PyObject *_args;
895{
896 PyObject *_res = NULL;
897 OSStatus _err;
898 OSType fileCreator;
899 OSType fileType;
900 SInt16 vRefNum;
901 if (!PyArg_ParseTuple(_args, "O&O&h",
902 PyMac_GetOSType, &fileCreator,
903 PyMac_GetOSType, &fileType,
904 &vRefNum))
905 return NULL;
906 _err = SetWindowProxyCreatorAndType(_self->ob_itself,
907 fileCreator,
908 fileType,
909 vRefNum);
910 if (_err != noErr) return PyMac_Error(_err);
911 Py_INCREF(Py_None);
912 _res = Py_None;
913 return _res;
914}
915
916static PyObject *WinObj_GetWindowProxyIcon(_self, _args)
917 WindowObject *_self;
918 PyObject *_args;
919{
920 PyObject *_res = NULL;
921 OSStatus _err;
922 IconRef outIcon;
923 if (!PyArg_ParseTuple(_args, ""))
924 return NULL;
925 _err = GetWindowProxyIcon(_self->ob_itself,
926 &outIcon);
927 if (_err != noErr) return PyMac_Error(_err);
928 _res = Py_BuildValue("O&",
929 ResObj_New, outIcon);
930 return _res;
931}
932
933static PyObject *WinObj_SetWindowProxyIcon(_self, _args)
934 WindowObject *_self;
935 PyObject *_args;
936{
937 PyObject *_res = NULL;
938 OSStatus _err;
939 IconRef icon;
940 if (!PyArg_ParseTuple(_args, "O&",
941 ResObj_Convert, &icon))
942 return NULL;
943 _err = SetWindowProxyIcon(_self->ob_itself,
944 icon);
945 if (_err != noErr) return PyMac_Error(_err);
946 Py_INCREF(Py_None);
947 _res = Py_None;
948 return _res;
949}
950
951static PyObject *WinObj_RemoveWindowProxy(_self, _args)
952 WindowObject *_self;
953 PyObject *_args;
954{
955 PyObject *_res = NULL;
956 OSStatus _err;
957 if (!PyArg_ParseTuple(_args, ""))
958 return NULL;
959 _err = RemoveWindowProxy(_self->ob_itself);
960 if (_err != noErr) return PyMac_Error(_err);
961 Py_INCREF(Py_None);
962 _res = Py_None;
963 return _res;
964}
965
Jack Jansen723ad8a2000-12-12 22:10:21 +0000966static PyObject *WinObj_BeginWindowProxyDrag(_self, _args)
967 WindowObject *_self;
968 PyObject *_args;
969{
970 PyObject *_res = NULL;
971 OSStatus _err;
972 DragReference outNewDrag;
973 RgnHandle outDragOutlineRgn;
974 if (!PyArg_ParseTuple(_args, "O&",
975 ResObj_Convert, &outDragOutlineRgn))
976 return NULL;
977 _err = BeginWindowProxyDrag(_self->ob_itself,
978 &outNewDrag,
979 outDragOutlineRgn);
980 if (_err != noErr) return PyMac_Error(_err);
981 _res = Py_BuildValue("O&",
982 DragObj_New, outNewDrag);
983 return _res;
984}
985
986static PyObject *WinObj_EndWindowProxyDrag(_self, _args)
987 WindowObject *_self;
988 PyObject *_args;
989{
990 PyObject *_res = NULL;
991 OSStatus _err;
992 DragReference theDrag;
993 if (!PyArg_ParseTuple(_args, "O&",
994 DragObj_Convert, &theDrag))
995 return NULL;
996 _err = EndWindowProxyDrag(_self->ob_itself,
997 theDrag);
998 if (_err != noErr) return PyMac_Error(_err);
999 Py_INCREF(Py_None);
1000 _res = Py_None;
1001 return _res;
1002}
1003
1004static PyObject *WinObj_TrackWindowProxyFromExistingDrag(_self, _args)
1005 WindowObject *_self;
1006 PyObject *_args;
1007{
1008 PyObject *_res = NULL;
1009 OSStatus _err;
1010 Point startPt;
1011 DragReference drag;
1012 RgnHandle inDragOutlineRgn;
1013 if (!PyArg_ParseTuple(_args, "O&O&O&",
1014 PyMac_GetPoint, &startPt,
1015 DragObj_Convert, &drag,
1016 ResObj_Convert, &inDragOutlineRgn))
1017 return NULL;
1018 _err = TrackWindowProxyFromExistingDrag(_self->ob_itself,
1019 startPt,
1020 drag,
1021 inDragOutlineRgn);
1022 if (_err != noErr) return PyMac_Error(_err);
1023 Py_INCREF(Py_None);
1024 _res = Py_None;
1025 return _res;
1026}
1027
Jack Jansena05ac601999-12-12 21:41:51 +00001028static PyObject *WinObj_TrackWindowProxyDrag(_self, _args)
1029 WindowObject *_self;
1030 PyObject *_args;
1031{
1032 PyObject *_res = NULL;
1033 OSStatus _err;
1034 Point startPt;
1035 if (!PyArg_ParseTuple(_args, "O&",
1036 PyMac_GetPoint, &startPt))
1037 return NULL;
1038 _err = TrackWindowProxyDrag(_self->ob_itself,
1039 startPt);
1040 if (_err != noErr) return PyMac_Error(_err);
1041 Py_INCREF(Py_None);
1042 _res = Py_None;
1043 return _res;
1044}
1045
1046static PyObject *WinObj_IsWindowModified(_self, _args)
1047 WindowObject *_self;
1048 PyObject *_args;
1049{
1050 PyObject *_res = NULL;
1051 Boolean _rv;
1052 if (!PyArg_ParseTuple(_args, ""))
1053 return NULL;
1054 _rv = IsWindowModified(_self->ob_itself);
1055 _res = Py_BuildValue("b",
1056 _rv);
1057 return _res;
1058}
1059
1060static PyObject *WinObj_SetWindowModified(_self, _args)
1061 WindowObject *_self;
1062 PyObject *_args;
1063{
1064 PyObject *_res = NULL;
1065 OSStatus _err;
1066 Boolean modified;
1067 if (!PyArg_ParseTuple(_args, "b",
1068 &modified))
1069 return NULL;
1070 _err = SetWindowModified(_self->ob_itself,
1071 modified);
1072 if (_err != noErr) return PyMac_Error(_err);
1073 Py_INCREF(Py_None);
1074 _res = Py_None;
1075 return _res;
1076}
1077
1078static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
1079 WindowObject *_self;
1080 PyObject *_args;
1081{
1082 PyObject *_res = NULL;
1083 Boolean _rv;
1084 EventRecord event;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001085 if (!PyArg_ParseTuple(_args, "O&",
1086 PyMac_GetEventRecord, &event))
Jack Jansena05ac601999-12-12 21:41:51 +00001087 return NULL;
1088 _rv = IsWindowPathSelectClick(_self->ob_itself,
1089 &event);
Jack Jansen723ad8a2000-12-12 22:10:21 +00001090 _res = Py_BuildValue("b",
1091 _rv);
Jack Jansena05ac601999-12-12 21:41:51 +00001092 return _res;
1093}
1094
Jack Jansen80716f02000-12-14 22:29:00 +00001095static PyObject *WinObj_WindowPathSelect(_self, _args)
1096 WindowObject *_self;
1097 PyObject *_args;
1098{
1099 PyObject *_res = NULL;
1100 OSStatus _err;
1101 MenuHandle menu;
1102 SInt32 outMenuResult;
1103 if (!PyArg_ParseTuple(_args, "O&",
1104 MenuObj_Convert, &menu))
1105 return NULL;
1106 _err = WindowPathSelect(_self->ob_itself,
1107 menu,
1108 &outMenuResult);
1109 if (_err != noErr) return PyMac_Error(_err);
1110 _res = Py_BuildValue("l",
1111 outMenuResult);
1112 return _res;
1113}
1114
Jack Jansena05ac601999-12-12 21:41:51 +00001115static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
1116 WindowObject *_self;
1117 PyObject *_args;
1118{
1119 PyObject *_res = NULL;
1120 OSStatus _err;
1121 Boolean hilited;
1122 if (!PyArg_ParseTuple(_args, "b",
1123 &hilited))
1124 return NULL;
1125 _err = HiliteWindowFrameForDrag(_self->ob_itself,
1126 hilited);
1127 if (_err != noErr) return PyMac_Error(_err);
1128 Py_INCREF(Py_None);
1129 _res = Py_None;
1130 return _res;
1131}
1132
1133static PyObject *WinObj_TransitionWindow(_self, _args)
1134 WindowObject *_self;
1135 PyObject *_args;
1136{
1137 PyObject *_res = NULL;
1138 OSStatus _err;
1139 WindowTransitionEffect effect;
1140 WindowTransitionAction action;
1141 Rect rect;
1142 if (!PyArg_ParseTuple(_args, "llO&",
1143 &effect,
1144 &action,
1145 PyMac_GetRect, &rect))
1146 return NULL;
1147 _err = TransitionWindow(_self->ob_itself,
1148 effect,
1149 action,
1150 &rect);
Jack Jansene4349e81999-03-04 22:53:24 +00001151 if (_err != noErr) return PyMac_Error(_err);
1152 Py_INCREF(Py_None);
1153 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00001154 return _res;
1155}
1156
Jack Jansen1c4e6141998-04-21 15:23:55 +00001157static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001158 WindowObject *_self;
1159 PyObject *_args;
1160{
1161 PyObject *_res = NULL;
1162 short hGlobal;
1163 short vGlobal;
1164 Boolean front;
1165 if (!PyArg_ParseTuple(_args, "hhb",
1166 &hGlobal,
1167 &vGlobal,
1168 &front))
1169 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001170 MacMoveWindow(_self->ob_itself,
1171 hGlobal,
1172 vGlobal,
1173 front);
Jack Jansen21f96871998-02-20 16:02:09 +00001174 Py_INCREF(Py_None);
1175 _res = Py_None;
1176 return _res;
1177}
1178
1179static PyObject *WinObj_SizeWindow(_self, _args)
1180 WindowObject *_self;
1181 PyObject *_args;
1182{
1183 PyObject *_res = NULL;
1184 short w;
1185 short h;
1186 Boolean fUpdate;
1187 if (!PyArg_ParseTuple(_args, "hhb",
1188 &w,
1189 &h,
1190 &fUpdate))
1191 return NULL;
1192 SizeWindow(_self->ob_itself,
1193 w,
1194 h,
1195 fUpdate);
1196 Py_INCREF(Py_None);
1197 _res = Py_None;
1198 return _res;
1199}
1200
Guido van Rossum17448e21995-01-30 11:53:55 +00001201static PyObject *WinObj_GrowWindow(_self, _args)
1202 WindowObject *_self;
1203 PyObject *_args;
1204{
1205 PyObject *_res = NULL;
1206 long _rv;
1207 Point startPt;
1208 Rect bBox;
1209 if (!PyArg_ParseTuple(_args, "O&O&",
1210 PyMac_GetPoint, &startPt,
1211 PyMac_GetRect, &bBox))
1212 return NULL;
1213 _rv = GrowWindow(_self->ob_itself,
1214 startPt,
1215 &bBox);
1216 _res = Py_BuildValue("l",
1217 _rv);
1218 return _res;
1219}
1220
Jack Jansen21f96871998-02-20 16:02:09 +00001221static PyObject *WinObj_DragWindow(_self, _args)
1222 WindowObject *_self;
1223 PyObject *_args;
1224{
1225 PyObject *_res = NULL;
1226 Point startPt;
1227 Rect boundsRect;
1228 if (!PyArg_ParseTuple(_args, "O&O&",
1229 PyMac_GetPoint, &startPt,
1230 PyMac_GetRect, &boundsRect))
1231 return NULL;
1232 DragWindow(_self->ob_itself,
1233 startPt,
1234 &boundsRect);
1235 Py_INCREF(Py_None);
1236 _res = Py_None;
1237 return _res;
1238}
1239
Jack Jansena05ac601999-12-12 21:41:51 +00001240static PyObject *WinObj_ZoomWindow(_self, _args)
1241 WindowObject *_self;
1242 PyObject *_args;
1243{
1244 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001245 WindowPartCode partCode;
Jack Jansena05ac601999-12-12 21:41:51 +00001246 Boolean front;
1247 if (!PyArg_ParseTuple(_args, "hb",
1248 &partCode,
1249 &front))
1250 return NULL;
1251 ZoomWindow(_self->ob_itself,
1252 partCode,
1253 front);
1254 Py_INCREF(Py_None);
1255 _res = Py_None;
1256 return _res;
1257}
1258
1259static PyObject *WinObj_IsWindowCollapsable(_self, _args)
1260 WindowObject *_self;
1261 PyObject *_args;
1262{
1263 PyObject *_res = NULL;
1264 Boolean _rv;
1265 if (!PyArg_ParseTuple(_args, ""))
1266 return NULL;
1267 _rv = IsWindowCollapsable(_self->ob_itself);
1268 _res = Py_BuildValue("b",
1269 _rv);
1270 return _res;
1271}
1272
1273static PyObject *WinObj_IsWindowCollapsed(_self, _args)
1274 WindowObject *_self;
1275 PyObject *_args;
1276{
1277 PyObject *_res = NULL;
1278 Boolean _rv;
1279 if (!PyArg_ParseTuple(_args, ""))
1280 return NULL;
1281 _rv = IsWindowCollapsed(_self->ob_itself);
1282 _res = Py_BuildValue("b",
1283 _rv);
1284 return _res;
1285}
1286
1287static PyObject *WinObj_CollapseWindow(_self, _args)
1288 WindowObject *_self;
1289 PyObject *_args;
1290{
1291 PyObject *_res = NULL;
1292 OSStatus _err;
1293 Boolean collapse;
1294 if (!PyArg_ParseTuple(_args, "b",
1295 &collapse))
1296 return NULL;
1297 _err = CollapseWindow(_self->ob_itself,
1298 collapse);
1299 if (_err != noErr) return PyMac_Error(_err);
1300 Py_INCREF(Py_None);
1301 _res = Py_None;
1302 return _res;
1303}
1304
Jack Jansen723ad8a2000-12-12 22:10:21 +00001305static PyObject *WinObj_GetWindowBounds(_self, _args)
Jack Jansena05ac601999-12-12 21:41:51 +00001306 WindowObject *_self;
1307 PyObject *_args;
1308{
1309 PyObject *_res = NULL;
1310 OSStatus _err;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001311 WindowRegionCode regionCode;
1312 Rect globalBounds;
1313 if (!PyArg_ParseTuple(_args, "H",
1314 &regionCode))
Jack Jansena05ac601999-12-12 21:41:51 +00001315 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001316 _err = GetWindowBounds(_self->ob_itself,
1317 regionCode,
1318 &globalBounds);
Jack Jansena05ac601999-12-12 21:41:51 +00001319 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen723ad8a2000-12-12 22:10:21 +00001320 _res = Py_BuildValue("O&",
1321 PyMac_BuildRect, &globalBounds);
Jack Jansena05ac601999-12-12 21:41:51 +00001322 return _res;
1323}
1324
Jack Jansen80716f02000-12-14 22:29:00 +00001325static PyObject *WinObj_ResizeWindow(_self, _args)
1326 WindowObject *_self;
1327 PyObject *_args;
1328{
1329 PyObject *_res = NULL;
1330 Boolean _rv;
1331 Point startPoint;
1332 Rect sizeConstraints;
1333 Rect newContentRect;
1334 if (!PyArg_ParseTuple(_args, "O&O&",
1335 PyMac_GetPoint, &startPoint,
1336 PyMac_GetRect, &sizeConstraints))
1337 return NULL;
1338 _rv = ResizeWindow(_self->ob_itself,
1339 startPoint,
1340 &sizeConstraints,
1341 &newContentRect);
1342 _res = Py_BuildValue("bO&",
1343 _rv,
1344 PyMac_BuildRect, &newContentRect);
1345 return _res;
1346}
1347
Jack Jansena05ac601999-12-12 21:41:51 +00001348static PyObject *WinObj_SetWindowBounds(_self, _args)
1349 WindowObject *_self;
1350 PyObject *_args;
1351{
1352 PyObject *_res = NULL;
1353 OSStatus _err;
1354 WindowRegionCode regionCode;
1355 Rect globalBounds;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001356 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansena05ac601999-12-12 21:41:51 +00001357 &regionCode,
1358 PyMac_GetRect, &globalBounds))
1359 return NULL;
1360 _err = SetWindowBounds(_self->ob_itself,
1361 regionCode,
1362 &globalBounds);
1363 if (_err != noErr) return PyMac_Error(_err);
1364 Py_INCREF(Py_None);
1365 _res = Py_None;
1366 return _res;
1367}
1368
Jack Jansen723ad8a2000-12-12 22:10:21 +00001369static PyObject *WinObj_RepositionWindow(_self, _args)
Jack Jansena05ac601999-12-12 21:41:51 +00001370 WindowObject *_self;
1371 PyObject *_args;
1372{
1373 PyObject *_res = NULL;
1374 OSStatus _err;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001375 WindowPtr parentWindow;
1376 WindowPositionMethod method;
1377 if (!PyArg_ParseTuple(_args, "O&l",
1378 WinObj_Convert, &parentWindow,
1379 &method))
Jack Jansena05ac601999-12-12 21:41:51 +00001380 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001381 _err = RepositionWindow(_self->ob_itself,
1382 parentWindow,
1383 method);
Jack Jansena05ac601999-12-12 21:41:51 +00001384 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen723ad8a2000-12-12 22:10:21 +00001385 Py_INCREF(Py_None);
1386 _res = Py_None;
Jack Jansena05ac601999-12-12 21:41:51 +00001387 return _res;
1388}
1389
1390static PyObject *WinObj_MoveWindowStructure(_self, _args)
1391 WindowObject *_self;
1392 PyObject *_args;
1393{
1394 PyObject *_res = NULL;
1395 OSStatus _err;
1396 short hGlobal;
1397 short vGlobal;
1398 if (!PyArg_ParseTuple(_args, "hh",
1399 &hGlobal,
1400 &vGlobal))
1401 return NULL;
1402 _err = MoveWindowStructure(_self->ob_itself,
1403 hGlobal,
1404 vGlobal);
1405 if (_err != noErr) return PyMac_Error(_err);
1406 Py_INCREF(Py_None);
1407 _res = Py_None;
1408 return _res;
1409}
1410
1411static PyObject *WinObj_IsWindowInStandardState(_self, _args)
1412 WindowObject *_self;
1413 PyObject *_args;
1414{
1415 PyObject *_res = NULL;
1416 Boolean _rv;
1417 Point idealSize;
1418 Rect idealStandardState;
1419 if (!PyArg_ParseTuple(_args, ""))
1420 return NULL;
1421 _rv = IsWindowInStandardState(_self->ob_itself,
1422 &idealSize,
1423 &idealStandardState);
1424 _res = Py_BuildValue("bO&O&",
1425 _rv,
1426 PyMac_BuildPoint, idealSize,
1427 PyMac_BuildRect, &idealStandardState);
1428 return _res;
1429}
1430
1431static PyObject *WinObj_ZoomWindowIdeal(_self, _args)
1432 WindowObject *_self;
1433 PyObject *_args;
1434{
1435 PyObject *_res = NULL;
1436 OSStatus _err;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001437 WindowPartCode partCode;
Jack Jansena05ac601999-12-12 21:41:51 +00001438 Point ioIdealSize;
1439 if (!PyArg_ParseTuple(_args, "h",
1440 &partCode))
1441 return NULL;
1442 _err = ZoomWindowIdeal(_self->ob_itself,
1443 partCode,
1444 &ioIdealSize);
1445 if (_err != noErr) return PyMac_Error(_err);
1446 _res = Py_BuildValue("O&",
1447 PyMac_BuildPoint, ioIdealSize);
1448 return _res;
1449}
1450
1451static PyObject *WinObj_GetWindowIdealUserState(_self, _args)
1452 WindowObject *_self;
1453 PyObject *_args;
1454{
1455 PyObject *_res = NULL;
1456 OSStatus _err;
1457 Rect userState;
1458 if (!PyArg_ParseTuple(_args, ""))
1459 return NULL;
1460 _err = GetWindowIdealUserState(_self->ob_itself,
1461 &userState);
1462 if (_err != noErr) return PyMac_Error(_err);
1463 _res = Py_BuildValue("O&",
1464 PyMac_BuildRect, &userState);
1465 return _res;
1466}
1467
1468static PyObject *WinObj_SetWindowIdealUserState(_self, _args)
1469 WindowObject *_self;
1470 PyObject *_args;
1471{
1472 PyObject *_res = NULL;
1473 OSStatus _err;
1474 Rect userState;
1475 if (!PyArg_ParseTuple(_args, ""))
1476 return NULL;
1477 _err = SetWindowIdealUserState(_self->ob_itself,
1478 &userState);
1479 if (_err != noErr) return PyMac_Error(_err);
1480 _res = Py_BuildValue("O&",
1481 PyMac_BuildRect, &userState);
1482 return _res;
1483}
1484
Jack Jansen21f96871998-02-20 16:02:09 +00001485static PyObject *WinObj_HideWindow(_self, _args)
1486 WindowObject *_self;
1487 PyObject *_args;
1488{
1489 PyObject *_res = NULL;
1490 if (!PyArg_ParseTuple(_args, ""))
1491 return NULL;
1492 HideWindow(_self->ob_itself);
1493 Py_INCREF(Py_None);
1494 _res = Py_None;
1495 return _res;
1496}
1497
Jack Jansen1c4e6141998-04-21 15:23:55 +00001498static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001499 WindowObject *_self;
1500 PyObject *_args;
1501{
1502 PyObject *_res = NULL;
1503 if (!PyArg_ParseTuple(_args, ""))
1504 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001505 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +00001506 Py_INCREF(Py_None);
1507 _res = Py_None;
1508 return _res;
1509}
1510
1511static PyObject *WinObj_ShowHide(_self, _args)
1512 WindowObject *_self;
1513 PyObject *_args;
1514{
1515 PyObject *_res = NULL;
1516 Boolean showFlag;
1517 if (!PyArg_ParseTuple(_args, "b",
1518 &showFlag))
1519 return NULL;
1520 ShowHide(_self->ob_itself,
1521 showFlag);
1522 Py_INCREF(Py_None);
1523 _res = Py_None;
1524 return _res;
1525}
1526
Jack Jansen723ad8a2000-12-12 22:10:21 +00001527#if TARGET_API_MAC_CARBON
1528
1529static PyObject *WinObj_GetWindowPropertyAttributes(_self, _args)
1530 WindowObject *_self;
1531 PyObject *_args;
1532{
1533 PyObject *_res = NULL;
1534 OSStatus _err;
1535 OSType propertyCreator;
1536 OSType propertyTag;
1537 UInt32 attributes;
1538 if (!PyArg_ParseTuple(_args, "O&O&",
1539 PyMac_GetOSType, &propertyCreator,
1540 PyMac_GetOSType, &propertyTag))
1541 return NULL;
1542 _err = GetWindowPropertyAttributes(_self->ob_itself,
1543 propertyCreator,
1544 propertyTag,
1545 &attributes);
1546 if (_err != noErr) return PyMac_Error(_err);
1547 _res = Py_BuildValue("l",
1548 attributes);
1549 return _res;
1550}
1551#endif
1552
1553#if TARGET_API_MAC_CARBON
1554
1555static PyObject *WinObj_ChangeWindowPropertyAttributes(_self, _args)
1556 WindowObject *_self;
1557 PyObject *_args;
1558{
1559 PyObject *_res = NULL;
1560 OSStatus _err;
1561 OSType propertyCreator;
1562 OSType propertyTag;
1563 UInt32 attributesToSet;
1564 UInt32 attributesToClear;
1565 if (!PyArg_ParseTuple(_args, "O&O&ll",
1566 PyMac_GetOSType, &propertyCreator,
1567 PyMac_GetOSType, &propertyTag,
1568 &attributesToSet,
1569 &attributesToClear))
1570 return NULL;
1571 _err = ChangeWindowPropertyAttributes(_self->ob_itself,
1572 propertyCreator,
1573 propertyTag,
1574 attributesToSet,
1575 attributesToClear);
1576 if (_err != noErr) return PyMac_Error(_err);
1577 Py_INCREF(Py_None);
1578 _res = Py_None;
1579 return _res;
1580}
1581#endif
1582
Guido van Rossum17448e21995-01-30 11:53:55 +00001583static PyObject *WinObj_TrackBox(_self, _args)
1584 WindowObject *_self;
1585 PyObject *_args;
1586{
1587 PyObject *_res = NULL;
1588 Boolean _rv;
1589 Point thePt;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001590 WindowPartCode partCode;
Guido van Rossum17448e21995-01-30 11:53:55 +00001591 if (!PyArg_ParseTuple(_args, "O&h",
1592 PyMac_GetPoint, &thePt,
1593 &partCode))
1594 return NULL;
1595 _rv = TrackBox(_self->ob_itself,
1596 thePt,
1597 partCode);
1598 _res = Py_BuildValue("b",
1599 _rv);
1600 return _res;
1601}
1602
Guido van Rossum17448e21995-01-30 11:53:55 +00001603static PyObject *WinObj_TrackGoAway(_self, _args)
1604 WindowObject *_self;
1605 PyObject *_args;
1606{
1607 PyObject *_res = NULL;
1608 Boolean _rv;
1609 Point thePt;
1610 if (!PyArg_ParseTuple(_args, "O&",
1611 PyMac_GetPoint, &thePt))
1612 return NULL;
1613 _rv = TrackGoAway(_self->ob_itself,
1614 thePt);
1615 _res = Py_BuildValue("b",
1616 _rv);
1617 return _res;
1618}
1619
Jack Jansen74a1e632000-07-14 22:37:27 +00001620#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00001621
Jack Jansen8f0fab71997-08-15 14:38:05 +00001622static PyObject *WinObj_GetAuxWin(_self, _args)
1623 WindowObject *_self;
1624 PyObject *_args;
1625{
1626 PyObject *_res = NULL;
1627 Boolean _rv;
1628 AuxWinHandle awHndl;
1629 if (!PyArg_ParseTuple(_args, ""))
1630 return NULL;
1631 _rv = GetAuxWin(_self->ob_itself,
1632 &awHndl);
1633 _res = Py_BuildValue("bO&",
1634 _rv,
1635 ResObj_New, awHndl);
1636 return _res;
1637}
Jack Jansene79dc762000-06-02 21:35:07 +00001638#endif
Jack Jansen8f0fab71997-08-15 14:38:05 +00001639
Jack Jansen723ad8a2000-12-12 22:10:21 +00001640static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
1641 WindowObject *_self;
1642 PyObject *_args;
1643{
1644 PyObject *_res = NULL;
1645 Boolean _rv;
1646 if (!PyArg_ParseTuple(_args, ""))
1647 return NULL;
1648 _rv = GetWindowGoAwayFlag(_self->ob_itself);
1649 _res = Py_BuildValue("b",
1650 _rv);
1651 return _res;
1652}
1653
1654static PyObject *WinObj_GetWindowSpareFlag(_self, _args)
1655 WindowObject *_self;
1656 PyObject *_args;
1657{
1658 PyObject *_res = NULL;
1659 Boolean _rv;
1660 if (!PyArg_ParseTuple(_args, ""))
1661 return NULL;
1662 _rv = GetWindowSpareFlag(_self->ob_itself);
1663 _res = Py_BuildValue("b",
1664 _rv);
1665 return _res;
1666}
1667
Jack Jansenb7abb181995-11-15 15:18:47 +00001668static PyObject *WinObj_GetWindowPort(_self, _args)
1669 WindowObject *_self;
1670 PyObject *_args;
1671{
1672 PyObject *_res = NULL;
1673 CGrafPtr _rv;
1674 if (!PyArg_ParseTuple(_args, ""))
1675 return NULL;
1676 _rv = GetWindowPort(_self->ob_itself);
1677 _res = Py_BuildValue("O&",
1678 GrafObj_New, _rv);
1679 return _res;
1680}
1681
Jack Jansen330f5761995-11-14 10:48:54 +00001682static PyObject *WinObj_GetWindowKind(_self, _args)
1683 WindowObject *_self;
1684 PyObject *_args;
1685{
1686 PyObject *_res = NULL;
1687 short _rv;
1688 if (!PyArg_ParseTuple(_args, ""))
1689 return NULL;
1690 _rv = GetWindowKind(_self->ob_itself);
1691 _res = Py_BuildValue("h",
1692 _rv);
1693 return _res;
1694}
1695
Jack Jansen723ad8a2000-12-12 22:10:21 +00001696static PyObject *WinObj_MacIsWindowVisible(_self, _args)
Jack Jansen330f5761995-11-14 10:48:54 +00001697 WindowObject *_self;
1698 PyObject *_args;
1699{
1700 PyObject *_res = NULL;
1701 Boolean _rv;
1702 if (!PyArg_ParseTuple(_args, ""))
1703 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001704 _rv = MacIsWindowVisible(_self->ob_itself);
Jack Jansen330f5761995-11-14 10:48:54 +00001705 _res = Py_BuildValue("b",
1706 _rv);
1707 return _res;
1708}
1709
1710static PyObject *WinObj_IsWindowHilited(_self, _args)
1711 WindowObject *_self;
1712 PyObject *_args;
1713{
1714 PyObject *_res = NULL;
1715 Boolean _rv;
1716 if (!PyArg_ParseTuple(_args, ""))
1717 return NULL;
1718 _rv = IsWindowHilited(_self->ob_itself);
1719 _res = Py_BuildValue("b",
1720 _rv);
1721 return _res;
1722}
1723
Jack Jansen723ad8a2000-12-12 22:10:21 +00001724#if TARGET_API_MAC_CARBON
1725
1726static PyObject *WinObj_IsWindowUpdatePending(_self, _args)
Jack Jansen330f5761995-11-14 10:48:54 +00001727 WindowObject *_self;
1728 PyObject *_args;
1729{
1730 PyObject *_res = NULL;
1731 Boolean _rv;
1732 if (!PyArg_ParseTuple(_args, ""))
1733 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001734 _rv = IsWindowUpdatePending(_self->ob_itself);
Jack Jansen330f5761995-11-14 10:48:54 +00001735 _res = Py_BuildValue("b",
1736 _rv);
1737 return _res;
1738}
Jack Jansene79dc762000-06-02 21:35:07 +00001739#endif
1740
Jack Jansen723ad8a2000-12-12 22:10:21 +00001741static PyObject *WinObj_MacGetNextWindow(_self, _args)
Jack Jansen330f5761995-11-14 10:48:54 +00001742 WindowObject *_self;
1743 PyObject *_args;
1744{
1745 PyObject *_res = NULL;
1746 WindowPtr _rv;
1747 if (!PyArg_ParseTuple(_args, ""))
1748 return NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001749 _rv = MacGetNextWindow(_self->ob_itself);
Jack Jansen330f5761995-11-14 10:48:54 +00001750 _res = Py_BuildValue("O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001751 WinObj_New, _rv);
Jack Jansen330f5761995-11-14 10:48:54 +00001752 return _res;
1753}
1754
1755static PyObject *WinObj_GetWindowStandardState(_self, _args)
1756 WindowObject *_self;
1757 PyObject *_args;
1758{
1759 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001760 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001761 if (!PyArg_ParseTuple(_args, ""))
1762 return NULL;
1763 GetWindowStandardState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001764 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001765 _res = Py_BuildValue("O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001766 PyMac_BuildRect, &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001767 return _res;
1768}
1769
1770static PyObject *WinObj_GetWindowUserState(_self, _args)
1771 WindowObject *_self;
1772 PyObject *_args;
1773{
1774 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001775 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001776 if (!PyArg_ParseTuple(_args, ""))
1777 return NULL;
1778 GetWindowUserState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001779 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001780 _res = Py_BuildValue("O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001781 PyMac_BuildRect, &rect);
1782 return _res;
1783}
1784
1785static PyObject *WinObj_SetWindowKind(_self, _args)
1786 WindowObject *_self;
1787 PyObject *_args;
1788{
1789 PyObject *_res = NULL;
1790 short kind;
1791 if (!PyArg_ParseTuple(_args, "h",
1792 &kind))
1793 return NULL;
1794 SetWindowKind(_self->ob_itself,
1795 kind);
1796 Py_INCREF(Py_None);
1797 _res = Py_None;
Jack Jansen330f5761995-11-14 10:48:54 +00001798 return _res;
1799}
1800
1801static PyObject *WinObj_SetWindowStandardState(_self, _args)
1802 WindowObject *_self;
1803 PyObject *_args;
1804{
1805 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001806 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001807 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001808 PyMac_GetRect, &rect))
Jack Jansen330f5761995-11-14 10:48:54 +00001809 return NULL;
1810 SetWindowStandardState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001811 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001812 Py_INCREF(Py_None);
1813 _res = Py_None;
1814 return _res;
1815}
1816
1817static PyObject *WinObj_SetWindowUserState(_self, _args)
1818 WindowObject *_self;
1819 PyObject *_args;
1820{
1821 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00001822 Rect rect;
Jack Jansen330f5761995-11-14 10:48:54 +00001823 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen723ad8a2000-12-12 22:10:21 +00001824 PyMac_GetRect, &rect))
Jack Jansen330f5761995-11-14 10:48:54 +00001825 return NULL;
1826 SetWindowUserState(_self->ob_itself,
Jack Jansen723ad8a2000-12-12 22:10:21 +00001827 &rect);
Jack Jansen330f5761995-11-14 10:48:54 +00001828 Py_INCREF(Py_None);
1829 _res = Py_None;
1830 return _res;
1831}
1832
Jack Jansen723ad8a2000-12-12 22:10:21 +00001833static PyObject *WinObj_SetPortWindowPort(_self, _args)
1834 WindowObject *_self;
1835 PyObject *_args;
1836{
1837 PyObject *_res = NULL;
1838 if (!PyArg_ParseTuple(_args, ""))
1839 return NULL;
1840 SetPortWindowPort(_self->ob_itself);
1841 Py_INCREF(Py_None);
1842 _res = Py_None;
1843 return _res;
1844}
1845
1846static PyObject *WinObj_GetWindowPortBounds(_self, _args)
1847 WindowObject *_self;
1848 PyObject *_args;
1849{
1850 PyObject *_res = NULL;
1851 Rect bounds;
1852 if (!PyArg_ParseTuple(_args, ""))
1853 return NULL;
1854 GetWindowPortBounds(_self->ob_itself,
1855 &bounds);
1856 _res = Py_BuildValue("O&",
1857 PyMac_BuildRect, &bounds);
1858 return _res;
1859}
1860
Jack Jansen32248652000-12-19 22:23:06 +00001861static PyObject *WinObj_IsWindowVisible(_self, _args)
1862 WindowObject *_self;
1863 PyObject *_args;
1864{
1865 PyObject *_res = NULL;
1866 Boolean _rv;
1867 if (!PyArg_ParseTuple(_args, ""))
1868 return NULL;
1869 _rv = IsWindowVisible(_self->ob_itself);
1870 _res = Py_BuildValue("b",
1871 _rv);
1872 return _res;
1873}
1874
1875static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
1876 WindowObject *_self;
1877 PyObject *_args;
1878{
1879 PyObject *_res = NULL;
1880 Boolean _rv;
1881 if (!PyArg_ParseTuple(_args, ""))
1882 return NULL;
1883 _rv = GetWindowZoomFlag(_self->ob_itself);
1884 _res = Py_BuildValue("b",
1885 _rv);
1886 return _res;
1887}
1888
1889static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
1890 WindowObject *_self;
1891 PyObject *_args;
1892{
1893 PyObject *_res = NULL;
1894 RgnHandle r;
1895 if (!PyArg_ParseTuple(_args, "O&",
1896 ResObj_Convert, &r))
1897 return NULL;
1898 GetWindowStructureRgn(_self->ob_itself,
1899 r);
1900 Py_INCREF(Py_None);
1901 _res = Py_None;
1902 return _res;
1903}
1904
1905static PyObject *WinObj_GetWindowContentRgn(_self, _args)
1906 WindowObject *_self;
1907 PyObject *_args;
1908{
1909 PyObject *_res = NULL;
1910 RgnHandle r;
1911 if (!PyArg_ParseTuple(_args, "O&",
1912 ResObj_Convert, &r))
1913 return NULL;
1914 GetWindowContentRgn(_self->ob_itself,
1915 r);
1916 Py_INCREF(Py_None);
1917 _res = Py_None;
1918 return _res;
1919}
1920
1921static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
1922 WindowObject *_self;
1923 PyObject *_args;
1924{
1925 PyObject *_res = NULL;
1926 RgnHandle r;
1927 if (!PyArg_ParseTuple(_args, "O&",
1928 ResObj_Convert, &r))
1929 return NULL;
1930 GetWindowUpdateRgn(_self->ob_itself,
1931 r);
1932 Py_INCREF(Py_None);
1933 _res = Py_None;
1934 return _res;
1935}
1936
1937static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
1938 WindowObject *_self;
1939 PyObject *_args;
1940{
1941 PyObject *_res = NULL;
1942 short _rv;
1943 if (!PyArg_ParseTuple(_args, ""))
1944 return NULL;
1945 _rv = GetWindowTitleWidth(_self->ob_itself);
1946 _res = Py_BuildValue("h",
1947 _rv);
1948 return _res;
1949}
1950
1951static PyObject *WinObj_GetNextWindow(_self, _args)
1952 WindowObject *_self;
1953 PyObject *_args;
1954{
1955 PyObject *_res = NULL;
1956 WindowPtr _rv;
1957 if (!PyArg_ParseTuple(_args, ""))
1958 return NULL;
1959 _rv = GetNextWindow(_self->ob_itself);
1960 _res = Py_BuildValue("O&",
1961 WinObj_WhichWindow, _rv);
1962 return _res;
1963}
1964
Jack Jansen74a1e632000-07-14 22:37:27 +00001965#if !TARGET_API_MAC_CARBON
Jack Jansencdcbd1f1998-10-22 15:08:00 +00001966
Jack Jansene180d991998-04-24 10:28:20 +00001967static PyObject *WinObj_CloseWindow(_self, _args)
1968 WindowObject *_self;
1969 PyObject *_args;
1970{
1971 PyObject *_res = NULL;
1972 if (!PyArg_ParseTuple(_args, ""))
1973 return NULL;
1974 CloseWindow(_self->ob_itself);
1975 Py_INCREF(Py_None);
1976 _res = Py_None;
1977 return _res;
1978}
Jack Jansene79dc762000-06-02 21:35:07 +00001979#endif
Jack Jansene180d991998-04-24 10:28:20 +00001980
1981static PyObject *WinObj_MoveWindow(_self, _args)
1982 WindowObject *_self;
1983 PyObject *_args;
1984{
1985 PyObject *_res = NULL;
1986 short hGlobal;
1987 short vGlobal;
1988 Boolean front;
1989 if (!PyArg_ParseTuple(_args, "hhb",
1990 &hGlobal,
1991 &vGlobal,
1992 &front))
1993 return NULL;
1994 MoveWindow(_self->ob_itself,
1995 hGlobal,
1996 vGlobal,
1997 front);
1998 Py_INCREF(Py_None);
1999 _res = Py_None;
2000 return _res;
2001}
2002
2003static PyObject *WinObj_ShowWindow(_self, _args)
2004 WindowObject *_self;
2005 PyObject *_args;
2006{
2007 PyObject *_res = NULL;
2008 if (!PyArg_ParseTuple(_args, ""))
2009 return NULL;
2010 ShowWindow(_self->ob_itself);
2011 Py_INCREF(Py_None);
2012 _res = Py_None;
2013 return _res;
2014}
2015
Guido van Rossum17448e21995-01-30 11:53:55 +00002016static PyMethodDef WinObj_methods[] = {
Jack Jansena05ac601999-12-12 21:41:51 +00002017 {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
2018 "() -> (UInt32 outCount)"},
2019 {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
2020 "() -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002021
2022#if TARGET_API_MAC_CARBON
2023 {"ReshapeCustomWindow", (PyCFunction)WinObj_ReshapeCustomWindow, 1,
2024 "() -> None"},
2025#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002026 {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1,
2027 "() -> (WindowClass outClass)"},
2028 {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
2029 "() -> (WindowAttributes outAttributes)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002030
Jack Jansen723ad8a2000-12-12 22:10:21 +00002031#if TARGET_API_MAC_CARBON
2032 {"ChangeWindowAttributes", (PyCFunction)WinObj_ChangeWindowAttributes, 1,
2033 "(WindowAttributes setTheseAttributes, WindowAttributes clearTheseAttributes) -> None"},
2034#endif
2035
Jack Jansen74a1e632000-07-14 22:37:27 +00002036#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002037 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
2038 "(WCTabHandle newColorTable) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002039#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002040 {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002041 "(RGBColor color) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002042 {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
2043 "() -> (RGBColor color)"},
2044 {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1,
2045 "(PixPatHandle outPixPat) -> None"},
2046 {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1,
2047 "(PixPatHandle pixPat) -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002048
2049#if TARGET_API_MAC_CARBON
2050 {"ScrollWindowRect", (PyCFunction)WinObj_ScrollWindowRect, 1,
2051 "(Rect inScrollRect, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
2052#endif
2053
2054#if TARGET_API_MAC_CARBON
2055 {"ScrollWindowRegion", (PyCFunction)WinObj_ScrollWindowRegion, 1,
2056 "(RgnHandle inScrollRgn, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"},
2057#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002058 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
2059 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002060
Jack Jansen74a1e632000-07-14 22:37:27 +00002061#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002062 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
2063 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002064#endif
2065
Jack Jansen74a1e632000-07-14 22:37:27 +00002066#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002067 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
2068 "(Boolean update) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002069#endif
Jack Jansen80716f02000-12-14 22:29:00 +00002070 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
2071 "(RgnHandle clobberedRgn) -> None"},
2072 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
2073 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002074 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
2075 "() -> None"},
Jack Jansen80716f02000-12-14 22:29:00 +00002076 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
2077 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002078 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
2079 "() -> None"},
2080 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
2081 "(WindowPtr behindWindow) -> None"},
2082 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
2083 "() -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002084
2085#if TARGET_API_MAC_CARBON
2086 {"GetNextWindowOfClass", (PyCFunction)WinObj_GetNextWindowOfClass, 1,
2087 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2088#endif
2089
2090#if !TARGET_API_MAC_CARBON
2091 {"IsValidWindowPtr", (PyCFunction)WinObj_IsValidWindowPtr, 1,
2092 "() -> (Boolean _rv)"},
2093#endif
Jack Jansen1c4e6141998-04-21 15:23:55 +00002094 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
2095 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002096 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
2097 "(long data) -> None"},
2098 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
2099 "() -> (long _rv)"},
2100 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
2101 "(PicHandle pic) -> None"},
2102 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
2103 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002104 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
2105 "() -> (short _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002106 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
2107 "() -> (UInt32 outFeatures)"},
2108 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
2109 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002110 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
2111 "() -> None"},
2112 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
2113 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002114 {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1,
2115 "(RgnHandle region) -> None"},
2116 {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1,
2117 "(Rect bounds) -> None"},
2118 {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1,
2119 "(RgnHandle region) -> None"},
2120 {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1,
2121 "(Rect bounds) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002122 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
2123 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002124 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
2125 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002126 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
2127 "() -> (Str255 title)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002128 {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1,
2129 "(FSSpec inFile) -> None"},
2130 {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1,
2131 "() -> (FSSpec outFile)"},
2132 {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1,
2133 "(AliasHandle alias) -> None"},
2134 {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1,
2135 "() -> (AliasHandle alias)"},
2136 {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1,
2137 "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"},
2138 {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1,
2139 "() -> (IconRef outIcon)"},
2140 {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1,
2141 "(IconRef icon) -> None"},
2142 {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1,
2143 "() -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002144 {"BeginWindowProxyDrag", (PyCFunction)WinObj_BeginWindowProxyDrag, 1,
2145 "(RgnHandle outDragOutlineRgn) -> (DragReference outNewDrag)"},
2146 {"EndWindowProxyDrag", (PyCFunction)WinObj_EndWindowProxyDrag, 1,
2147 "(DragReference theDrag) -> None"},
2148 {"TrackWindowProxyFromExistingDrag", (PyCFunction)WinObj_TrackWindowProxyFromExistingDrag, 1,
2149 "(Point startPt, DragReference drag, RgnHandle inDragOutlineRgn) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002150 {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1,
2151 "(Point startPt) -> None"},
2152 {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1,
2153 "() -> (Boolean _rv)"},
2154 {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1,
2155 "(Boolean modified) -> None"},
2156 {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002157 "(EventRecord event) -> (Boolean _rv)"},
Jack Jansen80716f02000-12-14 22:29:00 +00002158 {"WindowPathSelect", (PyCFunction)WinObj_WindowPathSelect, 1,
2159 "(MenuHandle menu) -> (SInt32 outMenuResult)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002160 {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
2161 "(Boolean hilited) -> None"},
2162 {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
2163 "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"},
2164 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
2165 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2166 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
2167 "(short w, short h, Boolean fUpdate) -> None"},
2168 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
2169 "(Point startPt, Rect bBox) -> (long _rv)"},
2170 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
2171 "(Point startPt, Rect boundsRect) -> None"},
2172 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002173 "(WindowPartCode partCode, Boolean front) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002174 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
2175 "() -> (Boolean _rv)"},
2176 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
2177 "() -> (Boolean _rv)"},
2178 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002179 "(Boolean collapse) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002180 {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
2181 "(WindowRegionCode regionCode) -> (Rect globalBounds)"},
Jack Jansen80716f02000-12-14 22:29:00 +00002182 {"ResizeWindow", (PyCFunction)WinObj_ResizeWindow, 1,
2183 "(Point startPoint, Rect sizeConstraints) -> (Boolean _rv, Rect newContentRect)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002184 {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
2185 "(WindowRegionCode regionCode, Rect globalBounds) -> None"},
2186 {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
2187 "(WindowPtr parentWindow, WindowPositionMethod method) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002188 {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1,
2189 "(short hGlobal, short vGlobal) -> None"},
2190 {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1,
2191 "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"},
2192 {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002193 "(WindowPartCode partCode) -> (Point ioIdealSize)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002194 {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1,
2195 "() -> (Rect userState)"},
2196 {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1,
2197 "() -> (Rect userState)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002198 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
2199 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002200 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002201 "() -> None"},
2202 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
2203 "(Boolean showFlag) -> None"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002204
2205#if TARGET_API_MAC_CARBON
2206 {"GetWindowPropertyAttributes", (PyCFunction)WinObj_GetWindowPropertyAttributes, 1,
2207 "(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
2208#endif
2209
2210#if TARGET_API_MAC_CARBON
2211 {"ChangeWindowPropertyAttributes", (PyCFunction)WinObj_ChangeWindowPropertyAttributes, 1,
2212 "(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
2213#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002214 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002215 "(Point thePt, WindowPartCode partCode) -> (Boolean _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002216 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
2217 "(Point thePt) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002218
Jack Jansen74a1e632000-07-14 22:37:27 +00002219#if !TARGET_API_MAC_CARBON
Jack Jansen8f0fab71997-08-15 14:38:05 +00002220 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
2221 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002222#endif
Jack Jansen723ad8a2000-12-12 22:10:21 +00002223 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
2224 "() -> (Boolean _rv)"},
2225 {"GetWindowSpareFlag", (PyCFunction)WinObj_GetWindowSpareFlag, 1,
2226 "() -> (Boolean _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00002227 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
2228 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00002229 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
2230 "() -> (short _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002231 {"MacIsWindowVisible", (PyCFunction)WinObj_MacIsWindowVisible, 1,
Jack Jansen330f5761995-11-14 10:48:54 +00002232 "() -> (Boolean _rv)"},
2233 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
2234 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002235
Jack Jansen723ad8a2000-12-12 22:10:21 +00002236#if TARGET_API_MAC_CARBON
2237 {"IsWindowUpdatePending", (PyCFunction)WinObj_IsWindowUpdatePending, 1,
Jack Jansen330f5761995-11-14 10:48:54 +00002238 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002239#endif
Jack Jansen723ad8a2000-12-12 22:10:21 +00002240 {"MacGetNextWindow", (PyCFunction)WinObj_MacGetNextWindow, 1,
Jack Jansen330f5761995-11-14 10:48:54 +00002241 "() -> (WindowPtr _rv)"},
2242 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002243 "() -> (Rect rect)"},
Jack Jansen330f5761995-11-14 10:48:54 +00002244 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002245 "() -> (Rect rect)"},
2246 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
2247 "(short kind) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00002248 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002249 "(Rect rect) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00002250 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002251 "(Rect rect) -> None"},
2252 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
2253 "() -> None"},
2254 {"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1,
2255 "() -> (Rect bounds)"},
Jack Jansen32248652000-12-19 22:23:06 +00002256 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
2257 "() -> (Boolean _rv)"},
2258 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
2259 "() -> (Boolean _rv)"},
2260 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
2261 "(RgnHandle r) -> None"},
2262 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
2263 "(RgnHandle r) -> None"},
2264 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
2265 "(RgnHandle r) -> None"},
2266 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
2267 "() -> (short _rv)"},
2268 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
2269 "() -> (WindowPtr _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002270
Jack Jansen74a1e632000-07-14 22:37:27 +00002271#if !TARGET_API_MAC_CARBON
Jack Jansene180d991998-04-24 10:28:20 +00002272 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
2273 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002274#endif
Jack Jansene180d991998-04-24 10:28:20 +00002275 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
2276 "(short hGlobal, short vGlobal, Boolean front) -> None"},
2277 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
2278 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002279 {NULL, NULL, 0}
2280};
2281
2282PyMethodChain WinObj_chain = { WinObj_methods, NULL };
2283
2284static PyObject *WinObj_getattr(self, name)
2285 WindowObject *self;
2286 char *name;
2287{
2288 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
2289}
2290
2291#define WinObj_setattr NULL
2292
Jack Jansen87a30922000-12-19 21:34:55 +00002293static int WinObj_compare(self, other)
2294 WindowObject *self, *other;
2295{
2296 if ( self->ob_itself > other->ob_itself ) return 1;
2297 if ( self->ob_itself < other->ob_itself ) return -1;
2298 return 0;
2299}
Jack Jansena05ac601999-12-12 21:41:51 +00002300
2301#define WinObj_repr NULL
2302
Jack Jansen87a30922000-12-19 21:34:55 +00002303static int WinObj_hash(self)
2304 WindowObject *self;
2305{
2306 return (int)self->ob_itself;
2307}
Jack Jansena05ac601999-12-12 21:41:51 +00002308
Guido van Rossum17448e21995-01-30 11:53:55 +00002309PyTypeObject Window_Type = {
2310 PyObject_HEAD_INIT(&PyType_Type)
2311 0, /*ob_size*/
2312 "Window", /*tp_name*/
2313 sizeof(WindowObject), /*tp_basicsize*/
2314 0, /*tp_itemsize*/
2315 /* methods */
2316 (destructor) WinObj_dealloc, /*tp_dealloc*/
2317 0, /*tp_print*/
2318 (getattrfunc) WinObj_getattr, /*tp_getattr*/
2319 (setattrfunc) WinObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00002320 (cmpfunc) WinObj_compare, /*tp_compare*/
2321 (reprfunc) WinObj_repr, /*tp_repr*/
2322 (PyNumberMethods *)0, /* tp_as_number */
2323 (PySequenceMethods *)0, /* tp_as_sequence */
2324 (PyMappingMethods *)0, /* tp_as_mapping */
2325 (hashfunc) WinObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00002326};
2327
2328/* --------------------- End object type Window --------------------- */
2329
2330
Jack Jansen21f96871998-02-20 16:02:09 +00002331static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002332 PyObject *_self;
2333 PyObject *_args;
2334{
2335 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002336 WindowPtr _rv;
2337 short windowID;
2338 WindowPtr behind;
2339 if (!PyArg_ParseTuple(_args, "hO&",
2340 &windowID,
2341 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00002342 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002343 _rv = GetNewCWindow(windowID,
2344 (void *)0,
2345 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00002346 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002347 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00002348 return _res;
2349}
2350
Guido van Rossum17448e21995-01-30 11:53:55 +00002351static PyObject *Win_NewWindow(_self, _args)
2352 PyObject *_self;
2353 PyObject *_args;
2354{
2355 PyObject *_res = NULL;
2356 WindowPtr _rv;
2357 Rect boundsRect;
2358 Str255 title;
2359 Boolean visible;
2360 short theProc;
2361 WindowPtr behind;
2362 Boolean goAwayFlag;
2363 long refCon;
2364 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2365 PyMac_GetRect, &boundsRect,
2366 PyMac_GetStr255, title,
2367 &visible,
2368 &theProc,
2369 WinObj_Convert, &behind,
2370 &goAwayFlag,
2371 &refCon))
2372 return NULL;
2373 _rv = NewWindow((void *)0,
2374 &boundsRect,
2375 title,
2376 visible,
2377 theProc,
2378 behind,
2379 goAwayFlag,
2380 refCon);
2381 _res = Py_BuildValue("O&",
2382 WinObj_New, _rv);
2383 return _res;
2384}
2385
2386static PyObject *Win_GetNewWindow(_self, _args)
2387 PyObject *_self;
2388 PyObject *_args;
2389{
2390 PyObject *_res = NULL;
2391 WindowPtr _rv;
2392 short windowID;
2393 WindowPtr behind;
2394 if (!PyArg_ParseTuple(_args, "hO&",
2395 &windowID,
2396 WinObj_Convert, &behind))
2397 return NULL;
2398 _rv = GetNewWindow(windowID,
2399 (void *)0,
2400 behind);
2401 _res = Py_BuildValue("O&",
2402 WinObj_New, _rv);
2403 return _res;
2404}
2405
Jack Jansen21f96871998-02-20 16:02:09 +00002406static PyObject *Win_NewCWindow(_self, _args)
2407 PyObject *_self;
2408 PyObject *_args;
2409{
2410 PyObject *_res = NULL;
2411 WindowPtr _rv;
2412 Rect boundsRect;
2413 Str255 title;
2414 Boolean visible;
2415 short procID;
2416 WindowPtr behind;
2417 Boolean goAwayFlag;
2418 long refCon;
2419 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
2420 PyMac_GetRect, &boundsRect,
2421 PyMac_GetStr255, title,
2422 &visible,
2423 &procID,
2424 WinObj_Convert, &behind,
2425 &goAwayFlag,
2426 &refCon))
2427 return NULL;
2428 _rv = NewCWindow((void *)0,
2429 &boundsRect,
2430 title,
2431 visible,
2432 procID,
2433 behind,
2434 goAwayFlag,
2435 refCon);
2436 _res = Py_BuildValue("O&",
2437 WinObj_New, _rv);
2438 return _res;
2439}
2440
Jack Jansena05ac601999-12-12 21:41:51 +00002441static PyObject *Win_CreateNewWindow(_self, _args)
2442 PyObject *_self;
2443 PyObject *_args;
2444{
2445 PyObject *_res = NULL;
2446 OSStatus _err;
2447 WindowClass windowClass;
2448 WindowAttributes attributes;
Jack Jansen723ad8a2000-12-12 22:10:21 +00002449 Rect contentBounds;
Jack Jansena05ac601999-12-12 21:41:51 +00002450 WindowPtr outWindow;
2451 if (!PyArg_ParseTuple(_args, "llO&",
2452 &windowClass,
2453 &attributes,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002454 PyMac_GetRect, &contentBounds))
Jack Jansena05ac601999-12-12 21:41:51 +00002455 return NULL;
2456 _err = CreateNewWindow(windowClass,
2457 attributes,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002458 &contentBounds,
Jack Jansena05ac601999-12-12 21:41:51 +00002459 &outWindow);
2460 if (_err != noErr) return PyMac_Error(_err);
2461 _res = Py_BuildValue("O&",
2462 WinObj_WhichWindow, outWindow);
2463 return _res;
2464}
2465
2466static PyObject *Win_CreateWindowFromResource(_self, _args)
2467 PyObject *_self;
2468 PyObject *_args;
2469{
2470 PyObject *_res = NULL;
2471 OSStatus _err;
2472 SInt16 resID;
2473 WindowPtr outWindow;
2474 if (!PyArg_ParseTuple(_args, "h",
2475 &resID))
2476 return NULL;
2477 _err = CreateWindowFromResource(resID,
2478 &outWindow);
2479 if (_err != noErr) return PyMac_Error(_err);
2480 _res = Py_BuildValue("O&",
2481 WinObj_WhichWindow, outWindow);
2482 return _res;
2483}
2484
2485static PyObject *Win_ShowFloatingWindows(_self, _args)
2486 PyObject *_self;
2487 PyObject *_args;
2488{
2489 PyObject *_res = NULL;
2490 OSStatus _err;
2491 if (!PyArg_ParseTuple(_args, ""))
2492 return NULL;
2493 _err = ShowFloatingWindows();
2494 if (_err != noErr) return PyMac_Error(_err);
2495 Py_INCREF(Py_None);
2496 _res = Py_None;
2497 return _res;
2498}
2499
2500static PyObject *Win_HideFloatingWindows(_self, _args)
2501 PyObject *_self;
2502 PyObject *_args;
2503{
2504 PyObject *_res = NULL;
2505 OSStatus _err;
2506 if (!PyArg_ParseTuple(_args, ""))
2507 return NULL;
2508 _err = HideFloatingWindows();
2509 if (_err != noErr) return PyMac_Error(_err);
2510 Py_INCREF(Py_None);
2511 _res = Py_None;
2512 return _res;
2513}
2514
2515static PyObject *Win_AreFloatingWindowsVisible(_self, _args)
2516 PyObject *_self;
2517 PyObject *_args;
2518{
2519 PyObject *_res = NULL;
2520 Boolean _rv;
2521 if (!PyArg_ParseTuple(_args, ""))
2522 return NULL;
2523 _rv = AreFloatingWindowsVisible();
2524 _res = Py_BuildValue("b",
2525 _rv);
2526 return _res;
2527}
2528
Jack Jansen74a1e632000-07-14 22:37:27 +00002529#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002530
Jack Jansen21f96871998-02-20 16:02:09 +00002531static PyObject *Win_SetDeskCPat(_self, _args)
2532 PyObject *_self;
2533 PyObject *_args;
2534{
2535 PyObject *_res = NULL;
2536 PixPatHandle deskPixPat;
2537 if (!PyArg_ParseTuple(_args, "O&",
2538 ResObj_Convert, &deskPixPat))
2539 return NULL;
2540 SetDeskCPat(deskPixPat);
2541 Py_INCREF(Py_None);
2542 _res = Py_None;
2543 return _res;
2544}
Jack Jansene79dc762000-06-02 21:35:07 +00002545#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002546
2547static PyObject *Win_CheckUpdate(_self, _args)
2548 PyObject *_self;
2549 PyObject *_args;
2550{
2551 PyObject *_res = NULL;
2552 Boolean _rv;
2553 EventRecord theEvent;
2554 if (!PyArg_ParseTuple(_args, ""))
2555 return NULL;
2556 _rv = CheckUpdate(&theEvent);
2557 _res = Py_BuildValue("bO&",
2558 _rv,
2559 PyMac_BuildEventRecord, &theEvent);
2560 return _res;
2561}
2562
Jack Jansen1c4e6141998-04-21 15:23:55 +00002563static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002564 PyObject *_self;
2565 PyObject *_args;
2566{
2567 PyObject *_res = NULL;
Jack Jansen723ad8a2000-12-12 22:10:21 +00002568 WindowPartCode _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002569 Point thePoint;
Jack Jansena05ac601999-12-12 21:41:51 +00002570 WindowPtr window;
Jack Jansen21f96871998-02-20 16:02:09 +00002571 if (!PyArg_ParseTuple(_args, "O&",
2572 PyMac_GetPoint, &thePoint))
2573 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002574 _rv = MacFindWindow(thePoint,
Jack Jansena05ac601999-12-12 21:41:51 +00002575 &window);
Jack Jansen21f96871998-02-20 16:02:09 +00002576 _res = Py_BuildValue("hO&",
2577 _rv,
Jack Jansena05ac601999-12-12 21:41:51 +00002578 WinObj_WhichWindow, window);
Jack Jansen21f96871998-02-20 16:02:09 +00002579 return _res;
2580}
2581
Guido van Rossum17448e21995-01-30 11:53:55 +00002582static PyObject *Win_FrontWindow(_self, _args)
2583 PyObject *_self;
2584 PyObject *_args;
2585{
2586 PyObject *_res = NULL;
2587 WindowPtr _rv;
2588 if (!PyArg_ParseTuple(_args, ""))
2589 return NULL;
2590 _rv = FrontWindow();
2591 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00002592 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002593 return _res;
2594}
2595
Jack Jansen723ad8a2000-12-12 22:10:21 +00002596static PyObject *Win_FrontNonFloatingWindow(_self, _args)
2597 PyObject *_self;
2598 PyObject *_args;
2599{
2600 PyObject *_res = NULL;
2601 WindowPtr _rv;
2602 if (!PyArg_ParseTuple(_args, ""))
2603 return NULL;
2604 _rv = FrontNonFloatingWindow();
2605 _res = Py_BuildValue("O&",
2606 WinObj_WhichWindow, _rv);
2607 return _res;
2608}
2609
2610#if TARGET_API_MAC_CARBON
2611
2612static PyObject *Win_GetFrontWindowOfClass(_self, _args)
2613 PyObject *_self;
2614 PyObject *_args;
2615{
2616 PyObject *_res = NULL;
2617 WindowPtr _rv;
2618 WindowClass inWindowClass;
2619 Boolean mustBeVisible;
2620 if (!PyArg_ParseTuple(_args, "lb",
2621 &inWindowClass,
2622 &mustBeVisible))
2623 return NULL;
2624 _rv = GetFrontWindowOfClass(inWindowClass,
2625 mustBeVisible);
2626 _res = Py_BuildValue("O&",
2627 WinObj_New, _rv);
2628 return _res;
2629}
2630#endif
2631
2632#if TARGET_API_MAC_CARBON
2633
2634static PyObject *Win_FindWindowOfClass(_self, _args)
2635 PyObject *_self;
2636 PyObject *_args;
2637{
2638 PyObject *_res = NULL;
2639 OSStatus _err;
2640 Point where;
2641 WindowClass inWindowClass;
2642 WindowPtr outWindow;
2643 WindowPartCode outWindowPart;
2644 if (!PyArg_ParseTuple(_args, "O&l",
2645 PyMac_GetPoint, &where,
2646 &inWindowClass))
2647 return NULL;
2648 _err = FindWindowOfClass(&where,
2649 inWindowClass,
2650 &outWindow,
2651 &outWindowPart);
2652 if (_err != noErr) return PyMac_Error(_err);
2653 _res = Py_BuildValue("O&h",
2654 WinObj_WhichWindow, outWindow,
2655 outWindowPart);
2656 return _res;
2657}
2658#endif
2659
Jack Jansen74a1e632000-07-14 22:37:27 +00002660#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002661
Jack Jansen21f96871998-02-20 16:02:09 +00002662static PyObject *Win_InitWindows(_self, _args)
2663 PyObject *_self;
2664 PyObject *_args;
2665{
2666 PyObject *_res = NULL;
2667 if (!PyArg_ParseTuple(_args, ""))
2668 return NULL;
2669 InitWindows();
2670 Py_INCREF(Py_None);
2671 _res = Py_None;
2672 return _res;
2673}
Jack Jansene79dc762000-06-02 21:35:07 +00002674#endif
2675
Jack Jansen74a1e632000-07-14 22:37:27 +00002676#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002677
2678static PyObject *Win_GetWMgrPort(_self, _args)
2679 PyObject *_self;
2680 PyObject *_args;
2681{
2682 PyObject *_res = NULL;
2683 GrafPtr wPort;
2684 if (!PyArg_ParseTuple(_args, ""))
2685 return NULL;
2686 GetWMgrPort(&wPort);
2687 _res = Py_BuildValue("O&",
2688 GrafObj_New, wPort);
2689 return _res;
2690}
Jack Jansene79dc762000-06-02 21:35:07 +00002691#endif
2692
Jack Jansen74a1e632000-07-14 22:37:27 +00002693#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002694
2695static PyObject *Win_GetCWMgrPort(_self, _args)
2696 PyObject *_self;
2697 PyObject *_args;
2698{
2699 PyObject *_res = NULL;
2700 CGrafPtr wMgrCPort;
2701 if (!PyArg_ParseTuple(_args, ""))
2702 return NULL;
2703 GetCWMgrPort(&wMgrCPort);
2704 _res = Py_BuildValue("O&",
2705 GrafObj_New, wMgrCPort);
2706 return _res;
2707}
Jack Jansene79dc762000-06-02 21:35:07 +00002708#endif
2709
Jack Jansen74a1e632000-07-14 22:37:27 +00002710#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002711
Jack Jansena05ac601999-12-12 21:41:51 +00002712static PyObject *Win_InitFloatingWindows(_self, _args)
2713 PyObject *_self;
2714 PyObject *_args;
2715{
2716 PyObject *_res = NULL;
2717 OSStatus _err;
2718 if (!PyArg_ParseTuple(_args, ""))
2719 return NULL;
2720 _err = InitFloatingWindows();
2721 if (_err != noErr) return PyMac_Error(_err);
2722 Py_INCREF(Py_None);
2723 _res = Py_None;
2724 return _res;
2725}
Jack Jansene79dc762000-06-02 21:35:07 +00002726#endif
2727
Jack Jansen74a1e632000-07-14 22:37:27 +00002728#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002729
Guido van Rossum17448e21995-01-30 11:53:55 +00002730static PyObject *Win_InvalRect(_self, _args)
2731 PyObject *_self;
2732 PyObject *_args;
2733{
2734 PyObject *_res = NULL;
2735 Rect badRect;
2736 if (!PyArg_ParseTuple(_args, "O&",
2737 PyMac_GetRect, &badRect))
2738 return NULL;
2739 InvalRect(&badRect);
2740 Py_INCREF(Py_None);
2741 _res = Py_None;
2742 return _res;
2743}
Jack Jansene79dc762000-06-02 21:35:07 +00002744#endif
2745
Jack Jansen74a1e632000-07-14 22:37:27 +00002746#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002747
Jack Jansenb7abb181995-11-15 15:18:47 +00002748static PyObject *Win_InvalRgn(_self, _args)
2749 PyObject *_self;
2750 PyObject *_args;
2751{
2752 PyObject *_res = NULL;
2753 RgnHandle badRgn;
2754 if (!PyArg_ParseTuple(_args, "O&",
2755 ResObj_Convert, &badRgn))
2756 return NULL;
2757 InvalRgn(badRgn);
2758 Py_INCREF(Py_None);
2759 _res = Py_None;
2760 return _res;
2761}
Jack Jansene79dc762000-06-02 21:35:07 +00002762#endif
2763
Jack Jansen74a1e632000-07-14 22:37:27 +00002764#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002765
Guido van Rossum17448e21995-01-30 11:53:55 +00002766static PyObject *Win_ValidRect(_self, _args)
2767 PyObject *_self;
2768 PyObject *_args;
2769{
2770 PyObject *_res = NULL;
2771 Rect goodRect;
2772 if (!PyArg_ParseTuple(_args, "O&",
2773 PyMac_GetRect, &goodRect))
2774 return NULL;
2775 ValidRect(&goodRect);
2776 Py_INCREF(Py_None);
2777 _res = Py_None;
2778 return _res;
2779}
Jack Jansene79dc762000-06-02 21:35:07 +00002780#endif
2781
Jack Jansen74a1e632000-07-14 22:37:27 +00002782#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002783
Jack Jansenb7abb181995-11-15 15:18:47 +00002784static PyObject *Win_ValidRgn(_self, _args)
2785 PyObject *_self;
2786 PyObject *_args;
2787{
2788 PyObject *_res = NULL;
2789 RgnHandle goodRgn;
2790 if (!PyArg_ParseTuple(_args, "O&",
2791 ResObj_Convert, &goodRgn))
2792 return NULL;
2793 ValidRgn(goodRgn);
2794 Py_INCREF(Py_None);
2795 _res = Py_None;
2796 return _res;
2797}
Jack Jansene79dc762000-06-02 21:35:07 +00002798#endif
Jack Jansenb7abb181995-11-15 15:18:47 +00002799
Jack Jansen21f96871998-02-20 16:02:09 +00002800static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002801 PyObject *_self;
2802 PyObject *_args;
2803{
2804 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00002805 OSStatus _err;
Jack Jansena05ac601999-12-12 21:41:51 +00002806 Boolean collapse;
Jack Jansen21f96871998-02-20 16:02:09 +00002807 if (!PyArg_ParseTuple(_args, "b",
Jack Jansena05ac601999-12-12 21:41:51 +00002808 &collapse))
Guido van Rossum17448e21995-01-30 11:53:55 +00002809 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002810 _err = CollapseAllWindows(collapse);
Jack Jansene4349e81999-03-04 22:53:24 +00002811 if (_err != noErr) return PyMac_Error(_err);
2812 Py_INCREF(Py_None);
2813 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00002814 return _res;
2815}
2816
2817static PyObject *Win_PinRect(_self, _args)
2818 PyObject *_self;
2819 PyObject *_args;
2820{
2821 PyObject *_res = NULL;
2822 long _rv;
2823 Rect theRect;
2824 Point thePt;
2825 if (!PyArg_ParseTuple(_args, "O&O&",
2826 PyMac_GetRect, &theRect,
2827 PyMac_GetPoint, &thePt))
2828 return NULL;
2829 _rv = PinRect(&theRect,
2830 thePt);
2831 _res = Py_BuildValue("l",
2832 _rv);
2833 return _res;
2834}
2835
Jack Jansen21f96871998-02-20 16:02:09 +00002836static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00002837 PyObject *_self;
2838 PyObject *_args;
2839{
2840 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002841 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00002842 if (!PyArg_ParseTuple(_args, ""))
2843 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00002844 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00002845 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00002846 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002847 return _res;
2848}
2849
Jack Jansen723ad8a2000-12-12 22:10:21 +00002850static PyObject *Win_GetWindowFromPort(_self, _args)
2851 PyObject *_self;
2852 PyObject *_args;
2853{
2854 PyObject *_res = NULL;
2855 WindowPtr _rv;
2856 CGrafPtr port;
2857 if (!PyArg_ParseTuple(_args, "O&",
2858 GrafObj_Convert, &port))
2859 return NULL;
2860 _rv = GetWindowFromPort(port);
2861 _res = Py_BuildValue("O&",
2862 WinObj_New, _rv);
2863 return _res;
2864}
2865
Jack Jansend4c26461995-08-17 14:35:56 +00002866static PyObject *Win_WhichWindow(_self, _args)
2867 PyObject *_self;
2868 PyObject *_args;
2869{
2870 PyObject *_res = NULL;
2871
2872 long ptr;
2873
2874 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
2875 return NULL;
2876 return WinObj_WhichWindow((WindowPtr)ptr);
2877
2878}
2879
Jack Jansene180d991998-04-24 10:28:20 +00002880static PyObject *Win_FindWindow(_self, _args)
2881 PyObject *_self;
2882 PyObject *_args;
2883{
2884 PyObject *_res = NULL;
2885 short _rv;
2886 Point thePoint;
2887 WindowPtr theWindow;
2888 if (!PyArg_ParseTuple(_args, "O&",
2889 PyMac_GetPoint, &thePoint))
2890 return NULL;
2891 _rv = FindWindow(thePoint,
2892 &theWindow);
2893 _res = Py_BuildValue("hO&",
2894 _rv,
2895 WinObj_WhichWindow, theWindow);
2896 return _res;
2897}
2898
Guido van Rossum17448e21995-01-30 11:53:55 +00002899static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00002900 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
2901 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002902 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
2903 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
2904 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
2905 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002906 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
2907 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002908 {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002909 "(WindowClass windowClass, WindowAttributes attributes, Rect contentBounds) -> (WindowPtr outWindow)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002910 {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1,
2911 "(SInt16 resID) -> (WindowPtr outWindow)"},
2912 {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1,
2913 "() -> None"},
2914 {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1,
2915 "() -> None"},
2916 {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1,
2917 "() -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002918
Jack Jansen74a1e632000-07-14 22:37:27 +00002919#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002920 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
2921 "(PixPatHandle deskPixPat) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002922#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002923 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
2924 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002925 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansen723ad8a2000-12-12 22:10:21 +00002926 "(Point thePoint) -> (WindowPartCode _rv, WindowPtr window)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002927 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
2928 "() -> (WindowPtr _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002929 {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
2930 "() -> (WindowPtr _rv)"},
2931
2932#if TARGET_API_MAC_CARBON
2933 {"GetFrontWindowOfClass", (PyCFunction)Win_GetFrontWindowOfClass, 1,
2934 "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"},
2935#endif
2936
2937#if TARGET_API_MAC_CARBON
2938 {"FindWindowOfClass", (PyCFunction)Win_FindWindowOfClass, 1,
2939 "(Point where, WindowClass inWindowClass) -> (WindowPtr outWindow, WindowPartCode outWindowPart)"},
2940#endif
Jack Jansene79dc762000-06-02 21:35:07 +00002941
Jack Jansen74a1e632000-07-14 22:37:27 +00002942#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002943 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
2944 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002945#endif
2946
Jack Jansen74a1e632000-07-14 22:37:27 +00002947#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002948 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
2949 "() -> (GrafPtr wPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002950#endif
2951
Jack Jansen74a1e632000-07-14 22:37:27 +00002952#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002953 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
2954 "() -> (CGrafPtr wMgrCPort)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002955#endif
2956
Jack Jansen74a1e632000-07-14 22:37:27 +00002957#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002958 {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
2959 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002960#endif
2961
Jack Jansen74a1e632000-07-14 22:37:27 +00002962#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002963 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
2964 "(Rect badRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002965#endif
2966
Jack Jansen74a1e632000-07-14 22:37:27 +00002967#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002968 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
2969 "(RgnHandle badRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002970#endif
2971
Jack Jansen74a1e632000-07-14 22:37:27 +00002972#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002973 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
2974 "(Rect goodRect) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002975#endif
2976
Jack Jansen74a1e632000-07-14 22:37:27 +00002977#if !TARGET_API_MAC_CARBON
Jack Jansenb7abb181995-11-15 15:18:47 +00002978 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
2979 "(RgnHandle goodRgn) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002980#endif
Jack Jansen21f96871998-02-20 16:02:09 +00002981 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansena05ac601999-12-12 21:41:51 +00002982 "(Boolean collapse) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002983 {"PinRect", (PyCFunction)Win_PinRect, 1,
2984 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002985 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
2986 "() -> (RgnHandle _rv)"},
Jack Jansen723ad8a2000-12-12 22:10:21 +00002987 {"GetWindowFromPort", (PyCFunction)Win_GetWindowFromPort, 1,
2988 "(CGrafPtr port) -> (WindowPtr _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00002989 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
2990 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00002991 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
2992 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002993 {NULL, NULL, 0}
2994};
2995
2996
2997
2998/* Return the object corresponding to the window, or NULL */
2999
3000PyObject *
3001WinObj_WhichWindow(w)
3002 WindowPtr w;
3003{
3004 PyObject *it;
3005
Jack Jansen0aee0e62000-08-25 22:17:51 +00003006 if (w == NULL) {
Guido van Rossum17448e21995-01-30 11:53:55 +00003007 it = Py_None;
Jack Jansen0aee0e62000-08-25 22:17:51 +00003008 Py_INCREF(it);
3009 } else {
3010 it = (PyObject *) GetWRefCon(w);
Jack Jansen80716f02000-12-14 22:29:00 +00003011 if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
Jack Jansen0aee0e62000-08-25 22:17:51 +00003012 it = WinObj_New(w);
3013 ((WindowObject *)it)->ob_freeit = NULL;
3014 } else {
3015 Py_INCREF(it);
3016 }
3017 }
Guido van Rossum17448e21995-01-30 11:53:55 +00003018 return it;
3019}
3020
3021
3022void initWin()
3023{
3024 PyObject *m;
3025 PyObject *d;
3026
3027
3028
3029
3030 m = Py_InitModule("Win", Win_methods);
3031 d = PyModule_GetDict(m);
3032 Win_Error = PyMac_GetOSErrException();
3033 if (Win_Error == NULL ||
3034 PyDict_SetItemString(d, "Error", Win_Error) != 0)
Jack Jansen723ad8a2000-12-12 22:10:21 +00003035 return;
Jack Jansena755e681997-09-20 17:40:22 +00003036 Window_Type.ob_type = &PyType_Type;
3037 Py_INCREF(&Window_Type);
3038 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
3039 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00003040}
3041
3042/* ========================= End module Win ========================= */
3043