blob: f57928ef94d2268720c15e921ddc1cf4c722aaaf [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
Guido van Rossum17448e21995-01-30 11:53:55 +0000970static PyMethodDef WinObj_methods[] = {
Jack Jansen1c4e6141998-04-21 15:23:55 +0000971 {"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
972 "() -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +0000973 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
974 "(WCTabHandle newColorTable) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000975 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
976 "() -> None"},
977 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
978 "() -> None"},
979 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
980 "(Boolean update) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +0000981 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
982 "(RgnHandle clobberedRgn) -> None"},
983 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
984 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000985 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
986 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +0000987 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
988 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +0000989 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
990 "() -> None"},
991 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
992 "(WindowPtr behindWindow) -> None"},
993 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
994 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +0000995 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
996 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +0000997 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
998 "() -> (OSStatus _rv, UInt32 outFeatures)"},
999 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
1000 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> (OSStatus _rv)"},
1001 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1002 "(long data) -> None"},
1003 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1004 "() -> (long _rv)"},
1005 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1006 "(PicHandle pic) -> None"},
1007 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1008 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001009 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1010 "() -> (short _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001011 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1012 "() -> None"},
1013 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1014 "() -> None"},
1015 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1016 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001017 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1018 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001019 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1020 "() -> (Str255 title)"},
1021 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1022 "() -> (Boolean _rv)"},
1023 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1024 "() -> (Boolean _rv)"},
1025 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
1026 "(Boolean inCollapseIt) -> (OSStatus _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001027 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001028 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1029 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1030 "(short w, short h, Boolean fUpdate) -> None"},
1031 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1032 "(short partCode, Boolean front) -> None"},
1033 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1034 "(Point startPt, Rect bBox) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001035 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1036 "(Point startPt, Rect boundsRect) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001037 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1038 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001039 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001040 "() -> None"},
1041 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1042 "(Boolean showFlag) -> None"},
1043 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1044 "(Point thePt, short partCode) -> (Boolean _rv)"},
1045 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1046 "(Point thePt) -> (Boolean _rv)"},
Jack Jansen8f0fab71997-08-15 14:38:05 +00001047 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1048 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001049 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1050 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00001051 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1052 "() -> None"},
1053 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1054 "() -> (short _rv)"},
1055 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1056 "(short wKind) -> None"},
1057 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1058 "() -> (Boolean _rv)"},
1059 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1060 "() -> (Boolean _rv)"},
1061 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1062 "() -> (Boolean _rv)"},
1063 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1064 "() -> (Boolean _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001065 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1066 "(RgnHandle r) -> None"},
1067 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1068 "(RgnHandle r) -> None"},
1069 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1070 "(RgnHandle r) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00001071 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1072 "() -> (short _rv)"},
1073 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1074 "() -> (WindowPtr _rv)"},
1075 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1076 "() -> (Rect r)"},
1077 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1078 "() -> (Rect r)"},
1079 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1080 "(Rect r) -> None"},
1081 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1082 "(Rect r) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001083 {NULL, NULL, 0}
1084};
1085
1086PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1087
1088static PyObject *WinObj_getattr(self, name)
1089 WindowObject *self;
1090 char *name;
1091{
1092 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1093}
1094
1095#define WinObj_setattr NULL
1096
1097PyTypeObject Window_Type = {
1098 PyObject_HEAD_INIT(&PyType_Type)
1099 0, /*ob_size*/
1100 "Window", /*tp_name*/
1101 sizeof(WindowObject), /*tp_basicsize*/
1102 0, /*tp_itemsize*/
1103 /* methods */
1104 (destructor) WinObj_dealloc, /*tp_dealloc*/
1105 0, /*tp_print*/
1106 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1107 (setattrfunc) WinObj_setattr, /*tp_setattr*/
1108};
1109
1110/* --------------------- End object type Window --------------------- */
1111
1112
Jack Jansen21f96871998-02-20 16:02:09 +00001113static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001114 PyObject *_self;
1115 PyObject *_args;
1116{
1117 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001118 WindowPtr _rv;
1119 short windowID;
1120 WindowPtr behind;
1121 if (!PyArg_ParseTuple(_args, "hO&",
1122 &windowID,
1123 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00001124 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001125 _rv = GetNewCWindow(windowID,
1126 (void *)0,
1127 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00001128 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001129 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00001130 return _res;
1131}
1132
Guido van Rossum17448e21995-01-30 11:53:55 +00001133static PyObject *Win_NewWindow(_self, _args)
1134 PyObject *_self;
1135 PyObject *_args;
1136{
1137 PyObject *_res = NULL;
1138 WindowPtr _rv;
1139 Rect boundsRect;
1140 Str255 title;
1141 Boolean visible;
1142 short theProc;
1143 WindowPtr behind;
1144 Boolean goAwayFlag;
1145 long refCon;
1146 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1147 PyMac_GetRect, &boundsRect,
1148 PyMac_GetStr255, title,
1149 &visible,
1150 &theProc,
1151 WinObj_Convert, &behind,
1152 &goAwayFlag,
1153 &refCon))
1154 return NULL;
1155 _rv = NewWindow((void *)0,
1156 &boundsRect,
1157 title,
1158 visible,
1159 theProc,
1160 behind,
1161 goAwayFlag,
1162 refCon);
1163 _res = Py_BuildValue("O&",
1164 WinObj_New, _rv);
1165 return _res;
1166}
1167
1168static PyObject *Win_GetNewWindow(_self, _args)
1169 PyObject *_self;
1170 PyObject *_args;
1171{
1172 PyObject *_res = NULL;
1173 WindowPtr _rv;
1174 short windowID;
1175 WindowPtr behind;
1176 if (!PyArg_ParseTuple(_args, "hO&",
1177 &windowID,
1178 WinObj_Convert, &behind))
1179 return NULL;
1180 _rv = GetNewWindow(windowID,
1181 (void *)0,
1182 behind);
1183 _res = Py_BuildValue("O&",
1184 WinObj_New, _rv);
1185 return _res;
1186}
1187
Jack Jansen21f96871998-02-20 16:02:09 +00001188static PyObject *Win_NewCWindow(_self, _args)
1189 PyObject *_self;
1190 PyObject *_args;
1191{
1192 PyObject *_res = NULL;
1193 WindowPtr _rv;
1194 Rect boundsRect;
1195 Str255 title;
1196 Boolean visible;
1197 short procID;
1198 WindowPtr behind;
1199 Boolean goAwayFlag;
1200 long refCon;
1201 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1202 PyMac_GetRect, &boundsRect,
1203 PyMac_GetStr255, title,
1204 &visible,
1205 &procID,
1206 WinObj_Convert, &behind,
1207 &goAwayFlag,
1208 &refCon))
1209 return NULL;
1210 _rv = NewCWindow((void *)0,
1211 &boundsRect,
1212 title,
1213 visible,
1214 procID,
1215 behind,
1216 goAwayFlag,
1217 refCon);
1218 _res = Py_BuildValue("O&",
1219 WinObj_New, _rv);
1220 return _res;
1221}
1222
1223static PyObject *Win_SetDeskCPat(_self, _args)
1224 PyObject *_self;
1225 PyObject *_args;
1226{
1227 PyObject *_res = NULL;
1228 PixPatHandle deskPixPat;
1229 if (!PyArg_ParseTuple(_args, "O&",
1230 ResObj_Convert, &deskPixPat))
1231 return NULL;
1232 SetDeskCPat(deskPixPat);
1233 Py_INCREF(Py_None);
1234 _res = Py_None;
1235 return _res;
1236}
1237
1238static PyObject *Win_CheckUpdate(_self, _args)
1239 PyObject *_self;
1240 PyObject *_args;
1241{
1242 PyObject *_res = NULL;
1243 Boolean _rv;
1244 EventRecord theEvent;
1245 if (!PyArg_ParseTuple(_args, ""))
1246 return NULL;
1247 _rv = CheckUpdate(&theEvent);
1248 _res = Py_BuildValue("bO&",
1249 _rv,
1250 PyMac_BuildEventRecord, &theEvent);
1251 return _res;
1252}
1253
Jack Jansen1c4e6141998-04-21 15:23:55 +00001254static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001255 PyObject *_self;
1256 PyObject *_args;
1257{
1258 PyObject *_res = NULL;
1259 short _rv;
1260 Point thePoint;
1261 WindowPtr theWindow;
1262 if (!PyArg_ParseTuple(_args, "O&",
1263 PyMac_GetPoint, &thePoint))
1264 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001265 _rv = MacFindWindow(thePoint,
1266 &theWindow);
Jack Jansen21f96871998-02-20 16:02:09 +00001267 _res = Py_BuildValue("hO&",
1268 _rv,
1269 WinObj_WhichWindow, theWindow);
1270 return _res;
1271}
1272
Guido van Rossum17448e21995-01-30 11:53:55 +00001273static PyObject *Win_FrontWindow(_self, _args)
1274 PyObject *_self;
1275 PyObject *_args;
1276{
1277 PyObject *_res = NULL;
1278 WindowPtr _rv;
1279 if (!PyArg_ParseTuple(_args, ""))
1280 return NULL;
1281 _rv = FrontWindow();
1282 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00001283 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001284 return _res;
1285}
1286
Jack Jansen21f96871998-02-20 16:02:09 +00001287static PyObject *Win_InitWindows(_self, _args)
1288 PyObject *_self;
1289 PyObject *_args;
1290{
1291 PyObject *_res = NULL;
1292 if (!PyArg_ParseTuple(_args, ""))
1293 return NULL;
1294 InitWindows();
1295 Py_INCREF(Py_None);
1296 _res = Py_None;
1297 return _res;
1298}
1299
1300static PyObject *Win_GetWMgrPort(_self, _args)
1301 PyObject *_self;
1302 PyObject *_args;
1303{
1304 PyObject *_res = NULL;
1305 GrafPtr wPort;
1306 if (!PyArg_ParseTuple(_args, ""))
1307 return NULL;
1308 GetWMgrPort(&wPort);
1309 _res = Py_BuildValue("O&",
1310 GrafObj_New, wPort);
1311 return _res;
1312}
1313
1314static PyObject *Win_GetCWMgrPort(_self, _args)
1315 PyObject *_self;
1316 PyObject *_args;
1317{
1318 PyObject *_res = NULL;
1319 CGrafPtr wMgrCPort;
1320 if (!PyArg_ParseTuple(_args, ""))
1321 return NULL;
1322 GetCWMgrPort(&wMgrCPort);
1323 _res = Py_BuildValue("O&",
1324 GrafObj_New, wMgrCPort);
1325 return _res;
1326}
1327
Guido van Rossum17448e21995-01-30 11:53:55 +00001328static PyObject *Win_InvalRect(_self, _args)
1329 PyObject *_self;
1330 PyObject *_args;
1331{
1332 PyObject *_res = NULL;
1333 Rect badRect;
1334 if (!PyArg_ParseTuple(_args, "O&",
1335 PyMac_GetRect, &badRect))
1336 return NULL;
1337 InvalRect(&badRect);
1338 Py_INCREF(Py_None);
1339 _res = Py_None;
1340 return _res;
1341}
1342
Jack Jansenb7abb181995-11-15 15:18:47 +00001343static PyObject *Win_InvalRgn(_self, _args)
1344 PyObject *_self;
1345 PyObject *_args;
1346{
1347 PyObject *_res = NULL;
1348 RgnHandle badRgn;
1349 if (!PyArg_ParseTuple(_args, "O&",
1350 ResObj_Convert, &badRgn))
1351 return NULL;
1352 InvalRgn(badRgn);
1353 Py_INCREF(Py_None);
1354 _res = Py_None;
1355 return _res;
1356}
1357
Guido van Rossum17448e21995-01-30 11:53:55 +00001358static PyObject *Win_ValidRect(_self, _args)
1359 PyObject *_self;
1360 PyObject *_args;
1361{
1362 PyObject *_res = NULL;
1363 Rect goodRect;
1364 if (!PyArg_ParseTuple(_args, "O&",
1365 PyMac_GetRect, &goodRect))
1366 return NULL;
1367 ValidRect(&goodRect);
1368 Py_INCREF(Py_None);
1369 _res = Py_None;
1370 return _res;
1371}
1372
Jack Jansenb7abb181995-11-15 15:18:47 +00001373static PyObject *Win_ValidRgn(_self, _args)
1374 PyObject *_self;
1375 PyObject *_args;
1376{
1377 PyObject *_res = NULL;
1378 RgnHandle goodRgn;
1379 if (!PyArg_ParseTuple(_args, "O&",
1380 ResObj_Convert, &goodRgn))
1381 return NULL;
1382 ValidRgn(goodRgn);
1383 Py_INCREF(Py_None);
1384 _res = Py_None;
1385 return _res;
1386}
1387
Jack Jansen21f96871998-02-20 16:02:09 +00001388static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001389 PyObject *_self;
1390 PyObject *_args;
1391{
1392 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001393 OSStatus _rv;
1394 Boolean inCollapseEm;
1395 if (!PyArg_ParseTuple(_args, "b",
1396 &inCollapseEm))
Guido van Rossum17448e21995-01-30 11:53:55 +00001397 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001398 _rv = CollapseAllWindows(inCollapseEm);
1399 _res = Py_BuildValue("l",
1400 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001401 return _res;
1402}
1403
1404static PyObject *Win_PinRect(_self, _args)
1405 PyObject *_self;
1406 PyObject *_args;
1407{
1408 PyObject *_res = NULL;
1409 long _rv;
1410 Rect theRect;
1411 Point thePt;
1412 if (!PyArg_ParseTuple(_args, "O&O&",
1413 PyMac_GetRect, &theRect,
1414 PyMac_GetPoint, &thePt))
1415 return NULL;
1416 _rv = PinRect(&theRect,
1417 thePt);
1418 _res = Py_BuildValue("l",
1419 _rv);
1420 return _res;
1421}
1422
Jack Jansen21f96871998-02-20 16:02:09 +00001423static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001424 PyObject *_self;
1425 PyObject *_args;
1426{
1427 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001428 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00001429 if (!PyArg_ParseTuple(_args, ""))
1430 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001431 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00001432 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001433 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001434 return _res;
1435}
1436
Jack Jansend4c26461995-08-17 14:35:56 +00001437static PyObject *Win_WhichWindow(_self, _args)
1438 PyObject *_self;
1439 PyObject *_args;
1440{
1441 PyObject *_res = NULL;
1442
1443 long ptr;
1444
1445 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
1446 return NULL;
1447 return WinObj_WhichWindow((WindowPtr)ptr);
1448
1449}
1450
Guido van Rossum17448e21995-01-30 11:53:55 +00001451static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00001452 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
1453 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001454 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
1455 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1456 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
1457 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001458 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
1459 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1460 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
1461 "(PixPatHandle deskPixPat) -> None"},
1462 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
1463 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001464 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001465 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001466 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
1467 "() -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001468 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
1469 "() -> None"},
1470 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
1471 "() -> (GrafPtr wPort)"},
1472 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
1473 "() -> (CGrafPtr wMgrCPort)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001474 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
1475 "(Rect badRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001476 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
1477 "(RgnHandle badRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001478 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
1479 "(Rect goodRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001480 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
1481 "(RgnHandle goodRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001482 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
1483 "(Boolean inCollapseEm) -> (OSStatus _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001484 {"PinRect", (PyCFunction)Win_PinRect, 1,
1485 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001486 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
1487 "() -> (RgnHandle _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00001488 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
1489 "Resolve an integer WindowPtr address to a Window object"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001490 {NULL, NULL, 0}
1491};
1492
1493
1494
1495/* Return the object corresponding to the window, or NULL */
1496
1497PyObject *
1498WinObj_WhichWindow(w)
1499 WindowPtr w;
1500{
1501 PyObject *it;
1502
1503 /* XXX What if we find a stdwin window or a window belonging
1504 to some other package? */
Guido van Rossum97842951995-02-19 15:59:49 +00001505 if (w == NULL)
1506 it = NULL;
1507 else
1508 it = (PyObject *) GetWRefCon(w);
Guido van Rossum17448e21995-01-30 11:53:55 +00001509 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
1510 it = Py_None;
1511 Py_INCREF(it);
1512 return it;
1513}
1514
1515
1516void initWin()
1517{
1518 PyObject *m;
1519 PyObject *d;
1520
1521
1522
1523
1524 m = Py_InitModule("Win", Win_methods);
1525 d = PyModule_GetDict(m);
1526 Win_Error = PyMac_GetOSErrException();
1527 if (Win_Error == NULL ||
1528 PyDict_SetItemString(d, "Error", Win_Error) != 0)
1529 Py_FatalError("can't initialize Win.Error");
Jack Jansena755e681997-09-20 17:40:22 +00001530 Window_Type.ob_type = &PyType_Type;
1531 Py_INCREF(&Window_Type);
1532 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
1533 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00001534}
1535
1536/* ========================= End module Win ========================= */
1537