blob: 58da8fdbc78e1f9d32080b026efa8ac19bbfdf30 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Win =========================== */
3
4#include "Python.h"
5
6
7
8#define SystemSevenOrLater 1
9
10#include "macglue.h"
11#include <Memory.h>
12#include <Dialogs.h>
13#include <Menus.h>
14#include <Controls.h>
15
16extern PyObject *ResObj_New(Handle);
17extern int ResObj_Convert(PyObject *, Handle *);
Jack Jansen425e9eb1995-12-12 15:02:03 +000018extern PyObject *OptResObj_New(Handle);
19extern int OptResObj_Convert(PyObject *, Handle *);
Guido van Rossum17448e21995-01-30 11:53:55 +000020
21extern PyObject *WinObj_New(WindowPtr);
22extern int WinObj_Convert(PyObject *, WindowPtr *);
Jack Jansenb7abb181995-11-15 15:18:47 +000023extern PyTypeObject Window_Type;
24#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
Guido van Rossum17448e21995-01-30 11:53:55 +000025
26extern PyObject *DlgObj_New(DialogPtr);
27extern int DlgObj_Convert(PyObject *, DialogPtr *);
28extern PyTypeObject Dialog_Type;
29#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
30
31extern PyObject *MenuObj_New(MenuHandle);
32extern int MenuObj_Convert(PyObject *, MenuHandle *);
33
34extern PyObject *CtlObj_New(ControlHandle);
35extern int CtlObj_Convert(PyObject *, ControlHandle *);
36
Jack Jansenb7abb181995-11-15 15:18:47 +000037extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
Jack Jansen425e9eb1995-12-12 15:02:03 +000040extern PyObject *BMObj_New(BitMapPtr);
41extern int BMObj_Convert(PyObject *, BitMapPtr *);
42
Guido van Rossum17448e21995-01-30 11:53:55 +000043extern PyObject *WinObj_WhichWindow(WindowPtr);
44
45#include <Windows.h>
46
47#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
48
Guido van Rossum97842951995-02-19 15:59:49 +000049#ifdef HAVE_UNIVERSAL_HEADERS
Guido van Rossum17448e21995-01-30 11:53:55 +000050#define WindowPeek WindowPtr
51#endif
52
Guido van Rossum17448e21995-01-30 11:53:55 +000053static PyObject *Win_Error;
54
55/* ----------------------- Object type Window ----------------------- */
56
57PyTypeObject Window_Type;
58
59#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
60
61typedef struct WindowObject {
62 PyObject_HEAD
63 WindowPtr ob_itself;
64} WindowObject;
65
66PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000067 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000068{
69 WindowObject *it;
70 if (itself == NULL) return PyMac_Error(resNotFound);
71 it = PyObject_NEW(WindowObject, &Window_Type);
72 if (it == NULL) return NULL;
73 it->ob_itself = itself;
74 SetWRefCon(itself, (long)it);
75 return (PyObject *)it;
76}
77WinObj_Convert(v, p_itself)
78 PyObject *v;
79 WindowPtr *p_itself;
80{
81 if (DlgObj_Check(v)) {
82 *p_itself = ((WindowObject *)v)->ob_itself;
83 return 1;
84 }
85
86 if (v == Py_None) { *p_itself = NULL; return 1; }
87 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
88
89 if (!WinObj_Check(v))
90 {
91 PyErr_SetString(PyExc_TypeError, "Window required");
92 return 0;
93 }
94 *p_itself = ((WindowObject *)v)->ob_itself;
95 return 1;
96}
97
98static void WinObj_dealloc(self)
99 WindowObject *self;
100{
101 DisposeWindow(self->ob_itself);
102 PyMem_DEL(self);
103}
104
Jack Jansen1c4e6141998-04-21 15:23:55 +0000105static PyObject *WinObj_MacCloseWindow(_self, _args)
106 WindowObject *_self;
107 PyObject *_args;
108{
109 PyObject *_res = NULL;
110 if (!PyArg_ParseTuple(_args, ""))
111 return NULL;
112 MacCloseWindow(_self->ob_itself);
113 Py_INCREF(Py_None);
114 _res = Py_None;
115 return _res;
116}
117
Jack Jansen21f96871998-02-20 16:02:09 +0000118static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000119 WindowObject *_self;
120 PyObject *_args;
121{
122 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000123 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000124 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000125 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000126 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000127 SetWinColor(_self->ob_itself,
128 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000129 Py_INCREF(Py_None);
130 _res = Py_None;
131 return _res;
132}
133
Guido van Rossum17448e21995-01-30 11:53:55 +0000134static PyObject *WinObj_ClipAbove(_self, _args)
135 WindowObject *_self;
136 PyObject *_args;
137{
138 PyObject *_res = NULL;
139 if (!PyArg_ParseTuple(_args, ""))
140 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000141 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000142 Py_INCREF(Py_None);
143 _res = Py_None;
144 return _res;
145}
146
147static PyObject *WinObj_SaveOld(_self, _args)
148 WindowObject *_self;
149 PyObject *_args;
150{
151 PyObject *_res = NULL;
152 if (!PyArg_ParseTuple(_args, ""))
153 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000154 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000155 Py_INCREF(Py_None);
156 _res = Py_None;
157 return _res;
158}
159
160static PyObject *WinObj_DrawNew(_self, _args)
161 WindowObject *_self;
162 PyObject *_args;
163{
164 PyObject *_res = NULL;
165 Boolean update;
166 if (!PyArg_ParseTuple(_args, "b",
167 &update))
168 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000169 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000170 update);
171 Py_INCREF(Py_None);
172 _res = Py_None;
173 return _res;
174}
175
Jack Jansenb7abb181995-11-15 15:18:47 +0000176static PyObject *WinObj_PaintOne(_self, _args)
177 WindowObject *_self;
178 PyObject *_args;
179{
180 PyObject *_res = NULL;
181 RgnHandle clobberedRgn;
182 if (!PyArg_ParseTuple(_args, "O&",
183 ResObj_Convert, &clobberedRgn))
184 return NULL;
185 PaintOne(_self->ob_itself,
186 clobberedRgn);
187 Py_INCREF(Py_None);
188 _res = Py_None;
189 return _res;
190}
191
192static PyObject *WinObj_PaintBehind(_self, _args)
193 WindowObject *_self;
194 PyObject *_args;
195{
196 PyObject *_res = NULL;
197 RgnHandle clobberedRgn;
198 if (!PyArg_ParseTuple(_args, "O&",
199 ResObj_Convert, &clobberedRgn))
200 return NULL;
201 PaintBehind(_self->ob_itself,
202 clobberedRgn);
203 Py_INCREF(Py_None);
204 _res = Py_None;
205 return _res;
206}
207
Guido van Rossum17448e21995-01-30 11:53:55 +0000208static PyObject *WinObj_CalcVis(_self, _args)
209 WindowObject *_self;
210 PyObject *_args;
211{
212 PyObject *_res = NULL;
213 if (!PyArg_ParseTuple(_args, ""))
214 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000215 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000216 Py_INCREF(Py_None);
217 _res = Py_None;
218 return _res;
219}
220
Jack Jansenb7abb181995-11-15 15:18:47 +0000221static PyObject *WinObj_CalcVisBehind(_self, _args)
222 WindowObject *_self;
223 PyObject *_args;
224{
225 PyObject *_res = NULL;
226 RgnHandle clobberedRgn;
227 if (!PyArg_ParseTuple(_args, "O&",
228 ResObj_Convert, &clobberedRgn))
229 return NULL;
230 CalcVisBehind(_self->ob_itself,
231 clobberedRgn);
232 Py_INCREF(Py_None);
233 _res = Py_None;
234 return _res;
235}
236
Jack Jansen21f96871998-02-20 16:02:09 +0000237static PyObject *WinObj_BringToFront(_self, _args)
238 WindowObject *_self;
239 PyObject *_args;
240{
241 PyObject *_res = NULL;
242 if (!PyArg_ParseTuple(_args, ""))
243 return NULL;
244 BringToFront(_self->ob_itself);
245 Py_INCREF(Py_None);
246 _res = Py_None;
247 return _res;
248}
249
250static PyObject *WinObj_SendBehind(_self, _args)
251 WindowObject *_self;
252 PyObject *_args;
253{
254 PyObject *_res = NULL;
255 WindowPtr behindWindow;
256 if (!PyArg_ParseTuple(_args, "O&",
257 WinObj_Convert, &behindWindow))
258 return NULL;
259 SendBehind(_self->ob_itself,
260 behindWindow);
261 Py_INCREF(Py_None);
262 _res = Py_None;
263 return _res;
264}
265
266static PyObject *WinObj_SelectWindow(_self, _args)
267 WindowObject *_self;
268 PyObject *_args;
269{
270 PyObject *_res = NULL;
271 if (!PyArg_ParseTuple(_args, ""))
272 return NULL;
273 SelectWindow(_self->ob_itself);
274 Py_INCREF(Py_None);
275 _res = Py_None;
276 return _res;
277}
278
Jack Jansen1c4e6141998-04-21 15:23:55 +0000279static PyObject *WinObj_HiliteWindow(_self, _args)
280 WindowObject *_self;
281 PyObject *_args;
282{
283 PyObject *_res = NULL;
284 Boolean fHilite;
285 if (!PyArg_ParseTuple(_args, "b",
286 &fHilite))
287 return NULL;
288 HiliteWindow(_self->ob_itself,
289 fHilite);
290 Py_INCREF(Py_None);
291 _res = Py_None;
292 return _res;
293}
294
Jack Jansen21f96871998-02-20 16:02:09 +0000295static PyObject *WinObj_GetWindowFeatures(_self, _args)
296 WindowObject *_self;
297 PyObject *_args;
298{
299 PyObject *_res = NULL;
300 OSStatus _rv;
301 UInt32 outFeatures;
302 if (!PyArg_ParseTuple(_args, ""))
303 return NULL;
304 _rv = GetWindowFeatures(_self->ob_itself,
305 &outFeatures);
306 _res = Py_BuildValue("ll",
307 _rv,
308 outFeatures);
309 return _res;
310}
311
312static PyObject *WinObj_GetWindowRegion(_self, _args)
313 WindowObject *_self;
314 PyObject *_args;
315{
316 PyObject *_res = NULL;
317 OSStatus _rv;
318 WindowRegionCode inRegionCode;
319 RgnHandle ioWinRgn;
320 if (!PyArg_ParseTuple(_args, "hO&",
321 &inRegionCode,
322 ResObj_Convert, &ioWinRgn))
323 return NULL;
324 _rv = GetWindowRegion(_self->ob_itself,
325 inRegionCode,
326 ioWinRgn);
327 _res = Py_BuildValue("l",
328 _rv);
329 return _res;
330}
331
332static PyObject *WinObj_SetWRefCon(_self, _args)
333 WindowObject *_self;
334 PyObject *_args;
335{
336 PyObject *_res = NULL;
337 long data;
338 if (!PyArg_ParseTuple(_args, "l",
339 &data))
340 return NULL;
341 SetWRefCon(_self->ob_itself,
342 data);
343 Py_INCREF(Py_None);
344 _res = Py_None;
345 return _res;
346}
347
348static PyObject *WinObj_GetWRefCon(_self, _args)
349 WindowObject *_self;
350 PyObject *_args;
351{
352 PyObject *_res = NULL;
353 long _rv;
354 if (!PyArg_ParseTuple(_args, ""))
355 return NULL;
356 _rv = GetWRefCon(_self->ob_itself);
357 _res = Py_BuildValue("l",
358 _rv);
359 return _res;
360}
361
362static PyObject *WinObj_SetWindowPic(_self, _args)
363 WindowObject *_self;
364 PyObject *_args;
365{
366 PyObject *_res = NULL;
367 PicHandle pic;
368 if (!PyArg_ParseTuple(_args, "O&",
369 ResObj_Convert, &pic))
370 return NULL;
371 SetWindowPic(_self->ob_itself,
372 pic);
373 Py_INCREF(Py_None);
374 _res = Py_None;
375 return _res;
376}
377
378static PyObject *WinObj_GetWindowPic(_self, _args)
379 WindowObject *_self;
380 PyObject *_args;
381{
382 PyObject *_res = NULL;
383 PicHandle _rv;
384 if (!PyArg_ParseTuple(_args, ""))
385 return NULL;
386 _rv = GetWindowPic(_self->ob_itself);
387 _res = Py_BuildValue("O&",
388 ResObj_New, _rv);
389 return _res;
390}
391
392static PyObject *WinObj_GetWVariant(_self, _args)
393 WindowObject *_self;
394 PyObject *_args;
395{
396 PyObject *_res = NULL;
397 short _rv;
398 if (!PyArg_ParseTuple(_args, ""))
399 return NULL;
400 _rv = GetWVariant(_self->ob_itself);
401 _res = Py_BuildValue("h",
402 _rv);
403 return _res;
404}
405
406static PyObject *WinObj_BeginUpdate(_self, _args)
407 WindowObject *_self;
408 PyObject *_args;
409{
410 PyObject *_res = NULL;
411 if (!PyArg_ParseTuple(_args, ""))
412 return NULL;
413 BeginUpdate(_self->ob_itself);
414 Py_INCREF(Py_None);
415 _res = Py_None;
416 return _res;
417}
418
419static PyObject *WinObj_EndUpdate(_self, _args)
420 WindowObject *_self;
421 PyObject *_args;
422{
423 PyObject *_res = NULL;
424 if (!PyArg_ParseTuple(_args, ""))
425 return NULL;
426 EndUpdate(_self->ob_itself);
427 Py_INCREF(Py_None);
428 _res = Py_None;
429 return _res;
430}
431
432static PyObject *WinObj_DrawGrowIcon(_self, _args)
433 WindowObject *_self;
434 PyObject *_args;
435{
436 PyObject *_res = NULL;
437 if (!PyArg_ParseTuple(_args, ""))
438 return NULL;
439 DrawGrowIcon(_self->ob_itself);
440 Py_INCREF(Py_None);
441 _res = Py_None;
442 return _res;
443}
444
Jack Jansen21f96871998-02-20 16:02:09 +0000445static PyObject *WinObj_SetWTitle(_self, _args)
446 WindowObject *_self;
447 PyObject *_args;
448{
449 PyObject *_res = NULL;
450 Str255 title;
451 if (!PyArg_ParseTuple(_args, "O&",
452 PyMac_GetStr255, title))
453 return NULL;
454 SetWTitle(_self->ob_itself,
455 title);
456 Py_INCREF(Py_None);
457 _res = Py_None;
458 return _res;
459}
460
461static PyObject *WinObj_GetWTitle(_self, _args)
462 WindowObject *_self;
463 PyObject *_args;
464{
465 PyObject *_res = NULL;
466 Str255 title;
467 if (!PyArg_ParseTuple(_args, ""))
468 return NULL;
469 GetWTitle(_self->ob_itself,
470 title);
471 _res = Py_BuildValue("O&",
472 PyMac_BuildStr255, title);
473 return _res;
474}
475
476static PyObject *WinObj_IsWindowCollapsable(_self, _args)
477 WindowObject *_self;
478 PyObject *_args;
479{
480 PyObject *_res = NULL;
481 Boolean _rv;
482 if (!PyArg_ParseTuple(_args, ""))
483 return NULL;
484 _rv = IsWindowCollapsable(_self->ob_itself);
485 _res = Py_BuildValue("b",
486 _rv);
487 return _res;
488}
489
490static PyObject *WinObj_IsWindowCollapsed(_self, _args)
491 WindowObject *_self;
492 PyObject *_args;
493{
494 PyObject *_res = NULL;
495 Boolean _rv;
496 if (!PyArg_ParseTuple(_args, ""))
497 return NULL;
498 _rv = IsWindowCollapsed(_self->ob_itself);
499 _res = Py_BuildValue("b",
500 _rv);
501 return _res;
502}
503
504static PyObject *WinObj_CollapseWindow(_self, _args)
505 WindowObject *_self;
506 PyObject *_args;
507{
508 PyObject *_res = NULL;
509 OSStatus _rv;
510 Boolean inCollapseIt;
511 if (!PyArg_ParseTuple(_args, "b",
512 &inCollapseIt))
513 return NULL;
514 _rv = CollapseWindow(_self->ob_itself,
515 inCollapseIt);
516 _res = Py_BuildValue("l",
517 _rv);
518 return _res;
519}
520
Jack Jansen1c4e6141998-04-21 15:23:55 +0000521static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000522 WindowObject *_self;
523 PyObject *_args;
524{
525 PyObject *_res = NULL;
526 short hGlobal;
527 short vGlobal;
528 Boolean front;
529 if (!PyArg_ParseTuple(_args, "hhb",
530 &hGlobal,
531 &vGlobal,
532 &front))
533 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000534 MacMoveWindow(_self->ob_itself,
535 hGlobal,
536 vGlobal,
537 front);
Jack Jansen21f96871998-02-20 16:02:09 +0000538 Py_INCREF(Py_None);
539 _res = Py_None;
540 return _res;
541}
542
543static PyObject *WinObj_SizeWindow(_self, _args)
544 WindowObject *_self;
545 PyObject *_args;
546{
547 PyObject *_res = NULL;
548 short w;
549 short h;
550 Boolean fUpdate;
551 if (!PyArg_ParseTuple(_args, "hhb",
552 &w,
553 &h,
554 &fUpdate))
555 return NULL;
556 SizeWindow(_self->ob_itself,
557 w,
558 h,
559 fUpdate);
560 Py_INCREF(Py_None);
561 _res = Py_None;
562 return _res;
563}
564
565static PyObject *WinObj_ZoomWindow(_self, _args)
566 WindowObject *_self;
567 PyObject *_args;
568{
569 PyObject *_res = NULL;
570 short partCode;
571 Boolean front;
572 if (!PyArg_ParseTuple(_args, "hb",
573 &partCode,
574 &front))
575 return NULL;
576 ZoomWindow(_self->ob_itself,
577 partCode,
578 front);
579 Py_INCREF(Py_None);
580 _res = Py_None;
581 return _res;
582}
583
Guido van Rossum17448e21995-01-30 11:53:55 +0000584static PyObject *WinObj_GrowWindow(_self, _args)
585 WindowObject *_self;
586 PyObject *_args;
587{
588 PyObject *_res = NULL;
589 long _rv;
590 Point startPt;
591 Rect bBox;
592 if (!PyArg_ParseTuple(_args, "O&O&",
593 PyMac_GetPoint, &startPt,
594 PyMac_GetRect, &bBox))
595 return NULL;
596 _rv = GrowWindow(_self->ob_itself,
597 startPt,
598 &bBox);
599 _res = Py_BuildValue("l",
600 _rv);
601 return _res;
602}
603
Jack Jansen21f96871998-02-20 16:02:09 +0000604static PyObject *WinObj_DragWindow(_self, _args)
605 WindowObject *_self;
606 PyObject *_args;
607{
608 PyObject *_res = NULL;
609 Point startPt;
610 Rect boundsRect;
611 if (!PyArg_ParseTuple(_args, "O&O&",
612 PyMac_GetPoint, &startPt,
613 PyMac_GetRect, &boundsRect))
614 return NULL;
615 DragWindow(_self->ob_itself,
616 startPt,
617 &boundsRect);
618 Py_INCREF(Py_None);
619 _res = Py_None;
620 return _res;
621}
622
623static PyObject *WinObj_HideWindow(_self, _args)
624 WindowObject *_self;
625 PyObject *_args;
626{
627 PyObject *_res = NULL;
628 if (!PyArg_ParseTuple(_args, ""))
629 return NULL;
630 HideWindow(_self->ob_itself);
631 Py_INCREF(Py_None);
632 _res = Py_None;
633 return _res;
634}
635
Jack Jansen1c4e6141998-04-21 15:23:55 +0000636static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000637 WindowObject *_self;
638 PyObject *_args;
639{
640 PyObject *_res = NULL;
641 if (!PyArg_ParseTuple(_args, ""))
642 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000643 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +0000644 Py_INCREF(Py_None);
645 _res = Py_None;
646 return _res;
647}
648
649static PyObject *WinObj_ShowHide(_self, _args)
650 WindowObject *_self;
651 PyObject *_args;
652{
653 PyObject *_res = NULL;
654 Boolean showFlag;
655 if (!PyArg_ParseTuple(_args, "b",
656 &showFlag))
657 return NULL;
658 ShowHide(_self->ob_itself,
659 showFlag);
660 Py_INCREF(Py_None);
661 _res = Py_None;
662 return _res;
663}
664
Guido van Rossum17448e21995-01-30 11:53:55 +0000665static PyObject *WinObj_TrackBox(_self, _args)
666 WindowObject *_self;
667 PyObject *_args;
668{
669 PyObject *_res = NULL;
670 Boolean _rv;
671 Point thePt;
672 short partCode;
673 if (!PyArg_ParseTuple(_args, "O&h",
674 PyMac_GetPoint, &thePt,
675 &partCode))
676 return NULL;
677 _rv = TrackBox(_self->ob_itself,
678 thePt,
679 partCode);
680 _res = Py_BuildValue("b",
681 _rv);
682 return _res;
683}
684
Guido van Rossum17448e21995-01-30 11:53:55 +0000685static PyObject *WinObj_TrackGoAway(_self, _args)
686 WindowObject *_self;
687 PyObject *_args;
688{
689 PyObject *_res = NULL;
690 Boolean _rv;
691 Point thePt;
692 if (!PyArg_ParseTuple(_args, "O&",
693 PyMac_GetPoint, &thePt))
694 return NULL;
695 _rv = TrackGoAway(_self->ob_itself,
696 thePt);
697 _res = Py_BuildValue("b",
698 _rv);
699 return _res;
700}
701
Jack Jansen8f0fab71997-08-15 14:38:05 +0000702static PyObject *WinObj_GetAuxWin(_self, _args)
703 WindowObject *_self;
704 PyObject *_args;
705{
706 PyObject *_res = NULL;
707 Boolean _rv;
708 AuxWinHandle awHndl;
709 if (!PyArg_ParseTuple(_args, ""))
710 return NULL;
711 _rv = GetAuxWin(_self->ob_itself,
712 &awHndl);
713 _res = Py_BuildValue("bO&",
714 _rv,
715 ResObj_New, awHndl);
716 return _res;
717}
718
Jack Jansenb7abb181995-11-15 15:18:47 +0000719static PyObject *WinObj_GetWindowPort(_self, _args)
720 WindowObject *_self;
721 PyObject *_args;
722{
723 PyObject *_res = NULL;
724 CGrafPtr _rv;
725 if (!PyArg_ParseTuple(_args, ""))
726 return NULL;
727 _rv = GetWindowPort(_self->ob_itself);
728 _res = Py_BuildValue("O&",
729 GrafObj_New, _rv);
730 return _res;
731}
732
Jack Jansen330f5761995-11-14 10:48:54 +0000733static PyObject *WinObj_SetPortWindowPort(_self, _args)
734 WindowObject *_self;
735 PyObject *_args;
736{
737 PyObject *_res = NULL;
738 if (!PyArg_ParseTuple(_args, ""))
739 return NULL;
740 SetPortWindowPort(_self->ob_itself);
741 Py_INCREF(Py_None);
742 _res = Py_None;
743 return _res;
744}
745
746static PyObject *WinObj_GetWindowKind(_self, _args)
747 WindowObject *_self;
748 PyObject *_args;
749{
750 PyObject *_res = NULL;
751 short _rv;
752 if (!PyArg_ParseTuple(_args, ""))
753 return NULL;
754 _rv = GetWindowKind(_self->ob_itself);
755 _res = Py_BuildValue("h",
756 _rv);
757 return _res;
758}
759
760static PyObject *WinObj_SetWindowKind(_self, _args)
761 WindowObject *_self;
762 PyObject *_args;
763{
764 PyObject *_res = NULL;
765 short wKind;
766 if (!PyArg_ParseTuple(_args, "h",
767 &wKind))
768 return NULL;
769 SetWindowKind(_self->ob_itself,
770 wKind);
771 Py_INCREF(Py_None);
772 _res = Py_None;
773 return _res;
774}
775
776static PyObject *WinObj_IsWindowVisible(_self, _args)
777 WindowObject *_self;
778 PyObject *_args;
779{
780 PyObject *_res = NULL;
781 Boolean _rv;
782 if (!PyArg_ParseTuple(_args, ""))
783 return NULL;
784 _rv = IsWindowVisible(_self->ob_itself);
785 _res = Py_BuildValue("b",
786 _rv);
787 return _res;
788}
789
790static PyObject *WinObj_IsWindowHilited(_self, _args)
791 WindowObject *_self;
792 PyObject *_args;
793{
794 PyObject *_res = NULL;
795 Boolean _rv;
796 if (!PyArg_ParseTuple(_args, ""))
797 return NULL;
798 _rv = IsWindowHilited(_self->ob_itself);
799 _res = Py_BuildValue("b",
800 _rv);
801 return _res;
802}
803
804static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
805 WindowObject *_self;
806 PyObject *_args;
807{
808 PyObject *_res = NULL;
809 Boolean _rv;
810 if (!PyArg_ParseTuple(_args, ""))
811 return NULL;
812 _rv = GetWindowGoAwayFlag(_self->ob_itself);
813 _res = Py_BuildValue("b",
814 _rv);
815 return _res;
816}
817
818static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
819 WindowObject *_self;
820 PyObject *_args;
821{
822 PyObject *_res = NULL;
823 Boolean _rv;
824 if (!PyArg_ParseTuple(_args, ""))
825 return NULL;
826 _rv = GetWindowZoomFlag(_self->ob_itself);
827 _res = Py_BuildValue("b",
828 _rv);
829 return _res;
830}
831
Jack Jansenb7abb181995-11-15 15:18:47 +0000832static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
833 WindowObject *_self;
834 PyObject *_args;
835{
836 PyObject *_res = NULL;
837 RgnHandle r;
838 if (!PyArg_ParseTuple(_args, "O&",
839 ResObj_Convert, &r))
840 return NULL;
841 GetWindowStructureRgn(_self->ob_itself,
842 r);
843 Py_INCREF(Py_None);
844 _res = Py_None;
845 return _res;
846}
847
848static PyObject *WinObj_GetWindowContentRgn(_self, _args)
849 WindowObject *_self;
850 PyObject *_args;
851{
852 PyObject *_res = NULL;
853 RgnHandle r;
854 if (!PyArg_ParseTuple(_args, "O&",
855 ResObj_Convert, &r))
856 return NULL;
857 GetWindowContentRgn(_self->ob_itself,
858 r);
859 Py_INCREF(Py_None);
860 _res = Py_None;
861 return _res;
862}
863
864static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
865 WindowObject *_self;
866 PyObject *_args;
867{
868 PyObject *_res = NULL;
869 RgnHandle r;
870 if (!PyArg_ParseTuple(_args, "O&",
871 ResObj_Convert, &r))
872 return NULL;
873 GetWindowUpdateRgn(_self->ob_itself,
874 r);
875 Py_INCREF(Py_None);
876 _res = Py_None;
877 return _res;
878}
879
Jack Jansen330f5761995-11-14 10:48:54 +0000880static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
881 WindowObject *_self;
882 PyObject *_args;
883{
884 PyObject *_res = NULL;
885 short _rv;
886 if (!PyArg_ParseTuple(_args, ""))
887 return NULL;
888 _rv = GetWindowTitleWidth(_self->ob_itself);
889 _res = Py_BuildValue("h",
890 _rv);
891 return _res;
892}
893
894static PyObject *WinObj_GetNextWindow(_self, _args)
895 WindowObject *_self;
896 PyObject *_args;
897{
898 PyObject *_res = NULL;
899 WindowPtr _rv;
900 if (!PyArg_ParseTuple(_args, ""))
901 return NULL;
902 _rv = GetNextWindow(_self->ob_itself);
903 _res = Py_BuildValue("O&",
904 WinObj_WhichWindow, _rv);
905 return _res;
906}
907
908static PyObject *WinObj_GetWindowStandardState(_self, _args)
909 WindowObject *_self;
910 PyObject *_args;
911{
912 PyObject *_res = NULL;
913 Rect r;
914 if (!PyArg_ParseTuple(_args, ""))
915 return NULL;
916 GetWindowStandardState(_self->ob_itself,
917 &r);
918 _res = Py_BuildValue("O&",
919 PyMac_BuildRect, &r);
920 return _res;
921}
922
923static PyObject *WinObj_GetWindowUserState(_self, _args)
924 WindowObject *_self;
925 PyObject *_args;
926{
927 PyObject *_res = NULL;
928 Rect r;
929 if (!PyArg_ParseTuple(_args, ""))
930 return NULL;
931 GetWindowUserState(_self->ob_itself,
932 &r);
933 _res = Py_BuildValue("O&",
934 PyMac_BuildRect, &r);
935 return _res;
936}
937
938static PyObject *WinObj_SetWindowStandardState(_self, _args)
939 WindowObject *_self;
940 PyObject *_args;
941{
942 PyObject *_res = NULL;
943 Rect r;
944 if (!PyArg_ParseTuple(_args, "O&",
945 PyMac_GetRect, &r))
946 return NULL;
947 SetWindowStandardState(_self->ob_itself,
948 &r);
949 Py_INCREF(Py_None);
950 _res = Py_None;
951 return _res;
952}
953
954static PyObject *WinObj_SetWindowUserState(_self, _args)
955 WindowObject *_self;
956 PyObject *_args;
957{
958 PyObject *_res = NULL;
959 Rect r;
960 if (!PyArg_ParseTuple(_args, "O&",
961 PyMac_GetRect, &r))
962 return NULL;
963 SetWindowUserState(_self->ob_itself,
964 &r);
965 Py_INCREF(Py_None);
966 _res = Py_None;
967 return _res;
968}
969
Jack Jansene180d991998-04-24 10:28:20 +0000970static PyObject *WinObj_CloseWindow(_self, _args)
971 WindowObject *_self;
972 PyObject *_args;
973{
974 PyObject *_res = NULL;
975 if (!PyArg_ParseTuple(_args, ""))
976 return NULL;
977 CloseWindow(_self->ob_itself);
978 Py_INCREF(Py_None);
979 _res = Py_None;
980 return _res;
981}
982
983static PyObject *WinObj_MoveWindow(_self, _args)
984 WindowObject *_self;
985 PyObject *_args;
986{
987 PyObject *_res = NULL;
988 short hGlobal;
989 short vGlobal;
990 Boolean front;
991 if (!PyArg_ParseTuple(_args, "hhb",
992 &hGlobal,
993 &vGlobal,
994 &front))
995 return NULL;
996 MoveWindow(_self->ob_itself,
997 hGlobal,
998 vGlobal,
999 front);
1000 Py_INCREF(Py_None);
1001 _res = Py_None;
1002 return _res;
1003}
1004
1005static PyObject *WinObj_ShowWindow(_self, _args)
1006 WindowObject *_self;
1007 PyObject *_args;
1008{
1009 PyObject *_res = NULL;
1010 if (!PyArg_ParseTuple(_args, ""))
1011 return NULL;
1012 ShowWindow(_self->ob_itself);
1013 Py_INCREF(Py_None);
1014 _res = Py_None;
1015 return _res;
1016}
1017
Guido van Rossum17448e21995-01-30 11:53:55 +00001018static PyMethodDef WinObj_methods[] = {
Jack Jansen1c4e6141998-04-21 15:23:55 +00001019 {"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
1020 "() -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001021 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1022 "(WCTabHandle newColorTable) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001023 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1024 "() -> None"},
1025 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1026 "() -> None"},
1027 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1028 "(Boolean update) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001029 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1030 "(RgnHandle clobberedRgn) -> None"},
1031 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1032 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001033 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1034 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001035 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1036 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001037 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1038 "() -> None"},
1039 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1040 "(WindowPtr behindWindow) -> None"},
1041 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1042 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001043 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1044 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001045 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
1046 "() -> (OSStatus _rv, UInt32 outFeatures)"},
1047 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1048 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> (OSStatus _rv)"},
1049 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1050 "(long data) -> None"},
1051 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1052 "() -> (long _rv)"},
1053 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1054 "(PicHandle pic) -> None"},
1055 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1056 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001057 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1058 "() -> (short _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001059 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1060 "() -> None"},
1061 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1062 "() -> None"},
1063 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1064 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001065 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1066 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001067 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1068 "() -> (Str255 title)"},
1069 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1070 "() -> (Boolean _rv)"},
1071 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1072 "() -> (Boolean _rv)"},
1073 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
1074 "(Boolean inCollapseIt) -> (OSStatus _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001075 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001076 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1077 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1078 "(short w, short h, Boolean fUpdate) -> None"},
1079 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1080 "(short partCode, Boolean front) -> None"},
1081 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1082 "(Point startPt, Rect bBox) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001083 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1084 "(Point startPt, Rect boundsRect) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001085 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1086 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001087 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001088 "() -> None"},
1089 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1090 "(Boolean showFlag) -> None"},
1091 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1092 "(Point thePt, short partCode) -> (Boolean _rv)"},
1093 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1094 "(Point thePt) -> (Boolean _rv)"},
Jack Jansen8f0fab71997-08-15 14:38:05 +00001095 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1096 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001097 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1098 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00001099 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1100 "() -> None"},
1101 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1102 "() -> (short _rv)"},
1103 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1104 "(short wKind) -> None"},
1105 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1106 "() -> (Boolean _rv)"},
1107 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1108 "() -> (Boolean _rv)"},
1109 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1110 "() -> (Boolean _rv)"},
1111 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1112 "() -> (Boolean _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001113 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1114 "(RgnHandle r) -> None"},
1115 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1116 "(RgnHandle r) -> None"},
1117 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1118 "(RgnHandle r) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00001119 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1120 "() -> (short _rv)"},
1121 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1122 "() -> (WindowPtr _rv)"},
1123 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1124 "() -> (Rect r)"},
1125 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1126 "() -> (Rect r)"},
1127 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1128 "(Rect r) -> None"},
1129 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1130 "(Rect r) -> None"},
Jack Jansene180d991998-04-24 10:28:20 +00001131 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
1132 "() -> None"},
1133 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
1134 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1135 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
1136 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001137 {NULL, NULL, 0}
1138};
1139
1140PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1141
1142static PyObject *WinObj_getattr(self, name)
1143 WindowObject *self;
1144 char *name;
1145{
1146 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1147}
1148
1149#define WinObj_setattr NULL
1150
1151PyTypeObject Window_Type = {
1152 PyObject_HEAD_INIT(&PyType_Type)
1153 0, /*ob_size*/
1154 "Window", /*tp_name*/
1155 sizeof(WindowObject), /*tp_basicsize*/
1156 0, /*tp_itemsize*/
1157 /* methods */
1158 (destructor) WinObj_dealloc, /*tp_dealloc*/
1159 0, /*tp_print*/
1160 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1161 (setattrfunc) WinObj_setattr, /*tp_setattr*/
1162};
1163
1164/* --------------------- End object type Window --------------------- */
1165
1166
Jack Jansen21f96871998-02-20 16:02:09 +00001167static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001168 PyObject *_self;
1169 PyObject *_args;
1170{
1171 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001172 WindowPtr _rv;
1173 short windowID;
1174 WindowPtr behind;
1175 if (!PyArg_ParseTuple(_args, "hO&",
1176 &windowID,
1177 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00001178 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001179 _rv = GetNewCWindow(windowID,
1180 (void *)0,
1181 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00001182 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001183 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00001184 return _res;
1185}
1186
Guido van Rossum17448e21995-01-30 11:53:55 +00001187static PyObject *Win_NewWindow(_self, _args)
1188 PyObject *_self;
1189 PyObject *_args;
1190{
1191 PyObject *_res = NULL;
1192 WindowPtr _rv;
1193 Rect boundsRect;
1194 Str255 title;
1195 Boolean visible;
1196 short theProc;
1197 WindowPtr behind;
1198 Boolean goAwayFlag;
1199 long refCon;
1200 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1201 PyMac_GetRect, &boundsRect,
1202 PyMac_GetStr255, title,
1203 &visible,
1204 &theProc,
1205 WinObj_Convert, &behind,
1206 &goAwayFlag,
1207 &refCon))
1208 return NULL;
1209 _rv = NewWindow((void *)0,
1210 &boundsRect,
1211 title,
1212 visible,
1213 theProc,
1214 behind,
1215 goAwayFlag,
1216 refCon);
1217 _res = Py_BuildValue("O&",
1218 WinObj_New, _rv);
1219 return _res;
1220}
1221
1222static PyObject *Win_GetNewWindow(_self, _args)
1223 PyObject *_self;
1224 PyObject *_args;
1225{
1226 PyObject *_res = NULL;
1227 WindowPtr _rv;
1228 short windowID;
1229 WindowPtr behind;
1230 if (!PyArg_ParseTuple(_args, "hO&",
1231 &windowID,
1232 WinObj_Convert, &behind))
1233 return NULL;
1234 _rv = GetNewWindow(windowID,
1235 (void *)0,
1236 behind);
1237 _res = Py_BuildValue("O&",
1238 WinObj_New, _rv);
1239 return _res;
1240}
1241
Jack Jansen21f96871998-02-20 16:02:09 +00001242static PyObject *Win_NewCWindow(_self, _args)
1243 PyObject *_self;
1244 PyObject *_args;
1245{
1246 PyObject *_res = NULL;
1247 WindowPtr _rv;
1248 Rect boundsRect;
1249 Str255 title;
1250 Boolean visible;
1251 short procID;
1252 WindowPtr behind;
1253 Boolean goAwayFlag;
1254 long refCon;
1255 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1256 PyMac_GetRect, &boundsRect,
1257 PyMac_GetStr255, title,
1258 &visible,
1259 &procID,
1260 WinObj_Convert, &behind,
1261 &goAwayFlag,
1262 &refCon))
1263 return NULL;
1264 _rv = NewCWindow((void *)0,
1265 &boundsRect,
1266 title,
1267 visible,
1268 procID,
1269 behind,
1270 goAwayFlag,
1271 refCon);
1272 _res = Py_BuildValue("O&",
1273 WinObj_New, _rv);
1274 return _res;
1275}
1276
1277static PyObject *Win_SetDeskCPat(_self, _args)
1278 PyObject *_self;
1279 PyObject *_args;
1280{
1281 PyObject *_res = NULL;
1282 PixPatHandle deskPixPat;
1283 if (!PyArg_ParseTuple(_args, "O&",
1284 ResObj_Convert, &deskPixPat))
1285 return NULL;
1286 SetDeskCPat(deskPixPat);
1287 Py_INCREF(Py_None);
1288 _res = Py_None;
1289 return _res;
1290}
1291
1292static PyObject *Win_CheckUpdate(_self, _args)
1293 PyObject *_self;
1294 PyObject *_args;
1295{
1296 PyObject *_res = NULL;
1297 Boolean _rv;
1298 EventRecord theEvent;
1299 if (!PyArg_ParseTuple(_args, ""))
1300 return NULL;
1301 _rv = CheckUpdate(&theEvent);
1302 _res = Py_BuildValue("bO&",
1303 _rv,
1304 PyMac_BuildEventRecord, &theEvent);
1305 return _res;
1306}
1307
Jack Jansen1c4e6141998-04-21 15:23:55 +00001308static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001309 PyObject *_self;
1310 PyObject *_args;
1311{
1312 PyObject *_res = NULL;
1313 short _rv;
1314 Point thePoint;
1315 WindowPtr theWindow;
1316 if (!PyArg_ParseTuple(_args, "O&",
1317 PyMac_GetPoint, &thePoint))
1318 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001319 _rv = MacFindWindow(thePoint,
1320 &theWindow);
Jack Jansen21f96871998-02-20 16:02:09 +00001321 _res = Py_BuildValue("hO&",
1322 _rv,
1323 WinObj_WhichWindow, theWindow);
1324 return _res;
1325}
1326
Guido van Rossum17448e21995-01-30 11:53:55 +00001327static PyObject *Win_FrontWindow(_self, _args)
1328 PyObject *_self;
1329 PyObject *_args;
1330{
1331 PyObject *_res = NULL;
1332 WindowPtr _rv;
1333 if (!PyArg_ParseTuple(_args, ""))
1334 return NULL;
1335 _rv = FrontWindow();
1336 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00001337 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001338 return _res;
1339}
1340
Jack Jansen21f96871998-02-20 16:02:09 +00001341static PyObject *Win_InitWindows(_self, _args)
1342 PyObject *_self;
1343 PyObject *_args;
1344{
1345 PyObject *_res = NULL;
1346 if (!PyArg_ParseTuple(_args, ""))
1347 return NULL;
1348 InitWindows();
1349 Py_INCREF(Py_None);
1350 _res = Py_None;
1351 return _res;
1352}
1353
1354static PyObject *Win_GetWMgrPort(_self, _args)
1355 PyObject *_self;
1356 PyObject *_args;
1357{
1358 PyObject *_res = NULL;
1359 GrafPtr wPort;
1360 if (!PyArg_ParseTuple(_args, ""))
1361 return NULL;
1362 GetWMgrPort(&wPort);
1363 _res = Py_BuildValue("O&",
1364 GrafObj_New, wPort);
1365 return _res;
1366}
1367
1368static PyObject *Win_GetCWMgrPort(_self, _args)
1369 PyObject *_self;
1370 PyObject *_args;
1371{
1372 PyObject *_res = NULL;
1373 CGrafPtr wMgrCPort;
1374 if (!PyArg_ParseTuple(_args, ""))
1375 return NULL;
1376 GetCWMgrPort(&wMgrCPort);
1377 _res = Py_BuildValue("O&",
1378 GrafObj_New, wMgrCPort);
1379 return _res;
1380}
1381
Guido van Rossum17448e21995-01-30 11:53:55 +00001382static PyObject *Win_InvalRect(_self, _args)
1383 PyObject *_self;
1384 PyObject *_args;
1385{
1386 PyObject *_res = NULL;
1387 Rect badRect;
1388 if (!PyArg_ParseTuple(_args, "O&",
1389 PyMac_GetRect, &badRect))
1390 return NULL;
1391 InvalRect(&badRect);
1392 Py_INCREF(Py_None);
1393 _res = Py_None;
1394 return _res;
1395}
1396
Jack Jansenb7abb181995-11-15 15:18:47 +00001397static PyObject *Win_InvalRgn(_self, _args)
1398 PyObject *_self;
1399 PyObject *_args;
1400{
1401 PyObject *_res = NULL;
1402 RgnHandle badRgn;
1403 if (!PyArg_ParseTuple(_args, "O&",
1404 ResObj_Convert, &badRgn))
1405 return NULL;
1406 InvalRgn(badRgn);
1407 Py_INCREF(Py_None);
1408 _res = Py_None;
1409 return _res;
1410}
1411
Guido van Rossum17448e21995-01-30 11:53:55 +00001412static PyObject *Win_ValidRect(_self, _args)
1413 PyObject *_self;
1414 PyObject *_args;
1415{
1416 PyObject *_res = NULL;
1417 Rect goodRect;
1418 if (!PyArg_ParseTuple(_args, "O&",
1419 PyMac_GetRect, &goodRect))
1420 return NULL;
1421 ValidRect(&goodRect);
1422 Py_INCREF(Py_None);
1423 _res = Py_None;
1424 return _res;
1425}
1426
Jack Jansenb7abb181995-11-15 15:18:47 +00001427static PyObject *Win_ValidRgn(_self, _args)
1428 PyObject *_self;
1429 PyObject *_args;
1430{
1431 PyObject *_res = NULL;
1432 RgnHandle goodRgn;
1433 if (!PyArg_ParseTuple(_args, "O&",
1434 ResObj_Convert, &goodRgn))
1435 return NULL;
1436 ValidRgn(goodRgn);
1437 Py_INCREF(Py_None);
1438 _res = Py_None;
1439 return _res;
1440}
1441
Jack Jansen21f96871998-02-20 16:02:09 +00001442static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001443 PyObject *_self;
1444 PyObject *_args;
1445{
1446 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001447 OSStatus _rv;
1448 Boolean inCollapseEm;
1449 if (!PyArg_ParseTuple(_args, "b",
1450 &inCollapseEm))
Guido van Rossum17448e21995-01-30 11:53:55 +00001451 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001452 _rv = CollapseAllWindows(inCollapseEm);
1453 _res = Py_BuildValue("l",
1454 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001455 return _res;
1456}
1457
1458static PyObject *Win_PinRect(_self, _args)
1459 PyObject *_self;
1460 PyObject *_args;
1461{
1462 PyObject *_res = NULL;
1463 long _rv;
1464 Rect theRect;
1465 Point thePt;
1466 if (!PyArg_ParseTuple(_args, "O&O&",
1467 PyMac_GetRect, &theRect,
1468 PyMac_GetPoint, &thePt))
1469 return NULL;
1470 _rv = PinRect(&theRect,
1471 thePt);
1472 _res = Py_BuildValue("l",
1473 _rv);
1474 return _res;
1475}
1476
Jack Jansen21f96871998-02-20 16:02:09 +00001477static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001478 PyObject *_self;
1479 PyObject *_args;
1480{
1481 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001482 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00001483 if (!PyArg_ParseTuple(_args, ""))
1484 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001485 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00001486 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001487 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001488 return _res;
1489}
1490
Jack Jansend4c26461995-08-17 14:35:56 +00001491static PyObject *Win_WhichWindow(_self, _args)
1492 PyObject *_self;
1493 PyObject *_args;
1494{
1495 PyObject *_res = NULL;
1496
1497 long ptr;
1498
1499 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
1500 return NULL;
1501 return WinObj_WhichWindow((WindowPtr)ptr);
1502
1503}
1504
Jack Jansene180d991998-04-24 10:28:20 +00001505static PyObject *Win_FindWindow(_self, _args)
1506 PyObject *_self;
1507 PyObject *_args;
1508{
1509 PyObject *_res = NULL;
1510 short _rv;
1511 Point thePoint;
1512 WindowPtr theWindow;
1513 if (!PyArg_ParseTuple(_args, "O&",
1514 PyMac_GetPoint, &thePoint))
1515 return NULL;
1516 _rv = FindWindow(thePoint,
1517 &theWindow);
1518 _res = Py_BuildValue("hO&",
1519 _rv,
1520 WinObj_WhichWindow, theWindow);
1521 return _res;
1522}
1523
Guido van Rossum17448e21995-01-30 11:53:55 +00001524static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00001525 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
1526 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001527 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
1528 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1529 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
1530 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001531 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
1532 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1533 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
1534 "(PixPatHandle deskPixPat) -> None"},
1535 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
1536 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001537 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001538 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001539 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
1540 "() -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001541 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
1542 "() -> None"},
1543 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
1544 "() -> (GrafPtr wPort)"},
1545 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
1546 "() -> (CGrafPtr wMgrCPort)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001547 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
1548 "(Rect badRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001549 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
1550 "(RgnHandle badRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001551 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
1552 "(Rect goodRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001553 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
1554 "(RgnHandle goodRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001555 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
1556 "(Boolean inCollapseEm) -> (OSStatus _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001557 {"PinRect", (PyCFunction)Win_PinRect, 1,
1558 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001559 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
1560 "() -> (RgnHandle _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00001561 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
1562 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00001563 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
1564 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001565 {NULL, NULL, 0}
1566};
1567
1568
1569
1570/* Return the object corresponding to the window, or NULL */
1571
1572PyObject *
1573WinObj_WhichWindow(w)
1574 WindowPtr w;
1575{
1576 PyObject *it;
1577
1578 /* XXX What if we find a stdwin window or a window belonging
1579 to some other package? */
Guido van Rossum97842951995-02-19 15:59:49 +00001580 if (w == NULL)
1581 it = NULL;
1582 else
1583 it = (PyObject *) GetWRefCon(w);
Guido van Rossum17448e21995-01-30 11:53:55 +00001584 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
1585 it = Py_None;
1586 Py_INCREF(it);
1587 return it;
1588}
1589
1590
1591void initWin()
1592{
1593 PyObject *m;
1594 PyObject *d;
1595
1596
1597
1598
1599 m = Py_InitModule("Win", Win_methods);
1600 d = PyModule_GetDict(m);
1601 Win_Error = PyMac_GetOSErrException();
1602 if (Win_Error == NULL ||
1603 PyDict_SetItemString(d, "Error", Win_Error) != 0)
1604 Py_FatalError("can't initialize Win.Error");
Jack Jansena755e681997-09-20 17:40:22 +00001605 Window_Type.ob_type = &PyType_Type;
1606 Py_INCREF(&Window_Type);
1607 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
1608 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00001609}
1610
1611/* ========================= End module Win ========================= */
1612