blob: cfa23c7d8eef9f5b1ab8cf93043b4f7b75cae7cc [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
Jack Jansen46d9e791996-04-12 16:29:23 +000043extern PyObject *PMObj_New(PixMapHandle);
44extern int PMObj_Convert(PyObject *, PixMapHandle *);
45
Guido van Rossum17448e21995-01-30 11:53:55 +000046extern PyObject *WinObj_WhichWindow(WindowPtr);
47
48#include <Windows.h>
49
50#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
51
Guido van Rossum97842951995-02-19 15:59:49 +000052#ifdef HAVE_UNIVERSAL_HEADERS
Guido van Rossum17448e21995-01-30 11:53:55 +000053#define WindowPeek WindowPtr
54#endif
55
Guido van Rossum17448e21995-01-30 11:53:55 +000056static PyObject *Win_Error;
57
58/* ----------------------- Object type Window ----------------------- */
59
60PyTypeObject Window_Type;
61
62#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
63
64typedef struct WindowObject {
65 PyObject_HEAD
66 WindowPtr ob_itself;
67} WindowObject;
68
69PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000070 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000071{
72 WindowObject *it;
73 if (itself == NULL) return PyMac_Error(resNotFound);
74 it = PyObject_NEW(WindowObject, &Window_Type);
75 if (it == NULL) return NULL;
76 it->ob_itself = itself;
77 SetWRefCon(itself, (long)it);
78 return (PyObject *)it;
79}
80WinObj_Convert(v, p_itself)
81 PyObject *v;
82 WindowPtr *p_itself;
83{
84 if (DlgObj_Check(v)) {
85 *p_itself = ((WindowObject *)v)->ob_itself;
86 return 1;
87 }
88
89 if (v == Py_None) { *p_itself = NULL; return 1; }
90 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
91
92 if (!WinObj_Check(v))
93 {
94 PyErr_SetString(PyExc_TypeError, "Window required");
95 return 0;
96 }
97 *p_itself = ((WindowObject *)v)->ob_itself;
98 return 1;
99}
100
101static void WinObj_dealloc(self)
102 WindowObject *self;
103{
104 DisposeWindow(self->ob_itself);
105 PyMem_DEL(self);
106}
107
108static PyObject *WinObj_GetWTitle(_self, _args)
109 WindowObject *_self;
110 PyObject *_args;
111{
112 PyObject *_res = NULL;
113 Str255 title;
114 if (!PyArg_ParseTuple(_args, ""))
115 return NULL;
116 GetWTitle(_self->ob_itself,
117 title);
118 _res = Py_BuildValue("O&",
119 PyMac_BuildStr255, title);
120 return _res;
121}
122
123static PyObject *WinObj_SelectWindow(_self, _args)
124 WindowObject *_self;
125 PyObject *_args;
126{
127 PyObject *_res = NULL;
128 if (!PyArg_ParseTuple(_args, ""))
129 return NULL;
130 SelectWindow(_self->ob_itself);
131 Py_INCREF(Py_None);
132 _res = Py_None;
133 return _res;
134}
135
136static PyObject *WinObj_HideWindow(_self, _args)
137 WindowObject *_self;
138 PyObject *_args;
139{
140 PyObject *_res = NULL;
141 if (!PyArg_ParseTuple(_args, ""))
142 return NULL;
143 HideWindow(_self->ob_itself);
144 Py_INCREF(Py_None);
145 _res = Py_None;
146 return _res;
147}
148
149static PyObject *WinObj_ShowWindow(_self, _args)
150 WindowObject *_self;
151 PyObject *_args;
152{
153 PyObject *_res = NULL;
154 if (!PyArg_ParseTuple(_args, ""))
155 return NULL;
156 ShowWindow(_self->ob_itself);
157 Py_INCREF(Py_None);
158 _res = Py_None;
159 return _res;
160}
161
162static PyObject *WinObj_ShowHide(_self, _args)
163 WindowObject *_self;
164 PyObject *_args;
165{
166 PyObject *_res = NULL;
167 Boolean showFlag;
168 if (!PyArg_ParseTuple(_args, "b",
169 &showFlag))
170 return NULL;
171 ShowHide(_self->ob_itself,
172 showFlag);
173 Py_INCREF(Py_None);
174 _res = Py_None;
175 return _res;
176}
177
178static PyObject *WinObj_HiliteWindow(_self, _args)
179 WindowObject *_self;
180 PyObject *_args;
181{
182 PyObject *_res = NULL;
183 Boolean fHilite;
184 if (!PyArg_ParseTuple(_args, "b",
185 &fHilite))
186 return NULL;
187 HiliteWindow(_self->ob_itself,
188 fHilite);
189 Py_INCREF(Py_None);
190 _res = Py_None;
191 return _res;
192}
193
194static PyObject *WinObj_BringToFront(_self, _args)
195 WindowObject *_self;
196 PyObject *_args;
197{
198 PyObject *_res = NULL;
199 if (!PyArg_ParseTuple(_args, ""))
200 return NULL;
201 BringToFront(_self->ob_itself);
202 Py_INCREF(Py_None);
203 _res = Py_None;
204 return _res;
205}
206
207static PyObject *WinObj_SendBehind(_self, _args)
208 WindowObject *_self;
209 PyObject *_args;
210{
211 PyObject *_res = NULL;
212 WindowPtr behindWindow;
213 if (!PyArg_ParseTuple(_args, "O&",
214 WinObj_Convert, &behindWindow))
215 return NULL;
216 SendBehind(_self->ob_itself,
217 behindWindow);
218 Py_INCREF(Py_None);
219 _res = Py_None;
220 return _res;
221}
222
223static PyObject *WinObj_DrawGrowIcon(_self, _args)
224 WindowObject *_self;
225 PyObject *_args;
226{
227 PyObject *_res = NULL;
228 if (!PyArg_ParseTuple(_args, ""))
229 return NULL;
230 DrawGrowIcon(_self->ob_itself);
231 Py_INCREF(Py_None);
232 _res = Py_None;
233 return _res;
234}
235
236static PyObject *WinObj_MoveWindow(_self, _args)
237 WindowObject *_self;
238 PyObject *_args;
239{
240 PyObject *_res = NULL;
241 short hGlobal;
242 short vGlobal;
243 Boolean front;
244 if (!PyArg_ParseTuple(_args, "hhb",
245 &hGlobal,
246 &vGlobal,
247 &front))
248 return NULL;
249 MoveWindow(_self->ob_itself,
250 hGlobal,
251 vGlobal,
252 front);
253 Py_INCREF(Py_None);
254 _res = Py_None;
255 return _res;
256}
257
258static PyObject *WinObj_SizeWindow(_self, _args)
259 WindowObject *_self;
260 PyObject *_args;
261{
262 PyObject *_res = NULL;
263 short w;
264 short h;
265 Boolean fUpdate;
266 if (!PyArg_ParseTuple(_args, "hhb",
267 &w,
268 &h,
269 &fUpdate))
270 return NULL;
271 SizeWindow(_self->ob_itself,
272 w,
273 h,
274 fUpdate);
275 Py_INCREF(Py_None);
276 _res = Py_None;
277 return _res;
278}
279
280static PyObject *WinObj_ZoomWindow(_self, _args)
281 WindowObject *_self;
282 PyObject *_args;
283{
284 PyObject *_res = NULL;
285 short partCode;
286 Boolean front;
287 if (!PyArg_ParseTuple(_args, "hb",
288 &partCode,
289 &front))
290 return NULL;
291 ZoomWindow(_self->ob_itself,
292 partCode,
293 front);
294 Py_INCREF(Py_None);
295 _res = Py_None;
296 return _res;
297}
298
299static PyObject *WinObj_BeginUpdate(_self, _args)
300 WindowObject *_self;
301 PyObject *_args;
302{
303 PyObject *_res = NULL;
304 if (!PyArg_ParseTuple(_args, ""))
305 return NULL;
306 BeginUpdate(_self->ob_itself);
307 Py_INCREF(Py_None);
308 _res = Py_None;
309 return _res;
310}
311
312static PyObject *WinObj_EndUpdate(_self, _args)
313 WindowObject *_self;
314 PyObject *_args;
315{
316 PyObject *_res = NULL;
317 if (!PyArg_ParseTuple(_args, ""))
318 return NULL;
319 EndUpdate(_self->ob_itself);
320 Py_INCREF(Py_None);
321 _res = Py_None;
322 return _res;
323}
324
325static PyObject *WinObj_SetWRefCon(_self, _args)
326 WindowObject *_self;
327 PyObject *_args;
328{
329 PyObject *_res = NULL;
330 long data;
331 if (!PyArg_ParseTuple(_args, "l",
332 &data))
333 return NULL;
334 SetWRefCon(_self->ob_itself,
335 data);
336 Py_INCREF(Py_None);
337 _res = Py_None;
338 return _res;
339}
340
341static PyObject *WinObj_GetWRefCon(_self, _args)
342 WindowObject *_self;
343 PyObject *_args;
344{
345 PyObject *_res = NULL;
346 long _rv;
347 if (!PyArg_ParseTuple(_args, ""))
348 return NULL;
349 _rv = GetWRefCon(_self->ob_itself);
350 _res = Py_BuildValue("l",
351 _rv);
352 return _res;
353}
354
Jack Jansen330f5761995-11-14 10:48:54 +0000355static PyObject *WinObj_SetWindowPic(_self, _args)
356 WindowObject *_self;
357 PyObject *_args;
358{
359 PyObject *_res = NULL;
360 PicHandle pic;
361 if (!PyArg_ParseTuple(_args, "O&",
362 ResObj_Convert, &pic))
363 return NULL;
364 SetWindowPic(_self->ob_itself,
365 pic);
366 Py_INCREF(Py_None);
367 _res = Py_None;
368 return _res;
369}
370
371static PyObject *WinObj_GetWindowPic(_self, _args)
372 WindowObject *_self;
373 PyObject *_args;
374{
375 PyObject *_res = NULL;
376 PicHandle _rv;
377 if (!PyArg_ParseTuple(_args, ""))
378 return NULL;
379 _rv = GetWindowPic(_self->ob_itself);
380 _res = Py_BuildValue("O&",
381 ResObj_New, _rv);
382 return _res;
383}
384
Guido van Rossum17448e21995-01-30 11:53:55 +0000385static PyObject *WinObj_ClipAbove(_self, _args)
386 WindowObject *_self;
387 PyObject *_args;
388{
389 PyObject *_res = NULL;
390 if (!PyArg_ParseTuple(_args, ""))
391 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000392 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000393 Py_INCREF(Py_None);
394 _res = Py_None;
395 return _res;
396}
397
398static PyObject *WinObj_SaveOld(_self, _args)
399 WindowObject *_self;
400 PyObject *_args;
401{
402 PyObject *_res = NULL;
403 if (!PyArg_ParseTuple(_args, ""))
404 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000405 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000406 Py_INCREF(Py_None);
407 _res = Py_None;
408 return _res;
409}
410
411static PyObject *WinObj_DrawNew(_self, _args)
412 WindowObject *_self;
413 PyObject *_args;
414{
415 PyObject *_res = NULL;
416 Boolean update;
417 if (!PyArg_ParseTuple(_args, "b",
418 &update))
419 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000420 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000421 update);
422 Py_INCREF(Py_None);
423 _res = Py_None;
424 return _res;
425}
426
Jack Jansenb7abb181995-11-15 15:18:47 +0000427static PyObject *WinObj_PaintOne(_self, _args)
428 WindowObject *_self;
429 PyObject *_args;
430{
431 PyObject *_res = NULL;
432 RgnHandle clobberedRgn;
433 if (!PyArg_ParseTuple(_args, "O&",
434 ResObj_Convert, &clobberedRgn))
435 return NULL;
436 PaintOne(_self->ob_itself,
437 clobberedRgn);
438 Py_INCREF(Py_None);
439 _res = Py_None;
440 return _res;
441}
442
443static PyObject *WinObj_PaintBehind(_self, _args)
444 WindowObject *_self;
445 PyObject *_args;
446{
447 PyObject *_res = NULL;
448 RgnHandle clobberedRgn;
449 if (!PyArg_ParseTuple(_args, "O&",
450 ResObj_Convert, &clobberedRgn))
451 return NULL;
452 PaintBehind(_self->ob_itself,
453 clobberedRgn);
454 Py_INCREF(Py_None);
455 _res = Py_None;
456 return _res;
457}
458
Guido van Rossum17448e21995-01-30 11:53:55 +0000459static PyObject *WinObj_CalcVis(_self, _args)
460 WindowObject *_self;
461 PyObject *_args;
462{
463 PyObject *_res = NULL;
464 if (!PyArg_ParseTuple(_args, ""))
465 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000466 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000467 Py_INCREF(Py_None);
468 _res = Py_None;
469 return _res;
470}
471
Jack Jansenb7abb181995-11-15 15:18:47 +0000472static PyObject *WinObj_CalcVisBehind(_self, _args)
473 WindowObject *_self;
474 PyObject *_args;
475{
476 PyObject *_res = NULL;
477 RgnHandle clobberedRgn;
478 if (!PyArg_ParseTuple(_args, "O&",
479 ResObj_Convert, &clobberedRgn))
480 return NULL;
481 CalcVisBehind(_self->ob_itself,
482 clobberedRgn);
483 Py_INCREF(Py_None);
484 _res = Py_None;
485 return _res;
486}
487
Guido van Rossum17448e21995-01-30 11:53:55 +0000488static PyObject *WinObj_GrowWindow(_self, _args)
489 WindowObject *_self;
490 PyObject *_args;
491{
492 PyObject *_res = NULL;
493 long _rv;
494 Point startPt;
495 Rect bBox;
496 if (!PyArg_ParseTuple(_args, "O&O&",
497 PyMac_GetPoint, &startPt,
498 PyMac_GetRect, &bBox))
499 return NULL;
500 _rv = GrowWindow(_self->ob_itself,
501 startPt,
502 &bBox);
503 _res = Py_BuildValue("l",
504 _rv);
505 return _res;
506}
507
508static PyObject *WinObj_TrackBox(_self, _args)
509 WindowObject *_self;
510 PyObject *_args;
511{
512 PyObject *_res = NULL;
513 Boolean _rv;
514 Point thePt;
515 short partCode;
516 if (!PyArg_ParseTuple(_args, "O&h",
517 PyMac_GetPoint, &thePt,
518 &partCode))
519 return NULL;
520 _rv = TrackBox(_self->ob_itself,
521 thePt,
522 partCode);
523 _res = Py_BuildValue("b",
524 _rv);
525 return _res;
526}
527
528static PyObject *WinObj_GetWVariant(_self, _args)
529 WindowObject *_self;
530 PyObject *_args;
531{
532 PyObject *_res = NULL;
533 short _rv;
534 if (!PyArg_ParseTuple(_args, ""))
535 return NULL;
536 _rv = GetWVariant(_self->ob_itself);
537 _res = Py_BuildValue("h",
538 _rv);
539 return _res;
540}
541
542static PyObject *WinObj_SetWTitle(_self, _args)
543 WindowObject *_self;
544 PyObject *_args;
545{
546 PyObject *_res = NULL;
547 Str255 title;
548 if (!PyArg_ParseTuple(_args, "O&",
549 PyMac_GetStr255, title))
550 return NULL;
551 SetWTitle(_self->ob_itself,
552 title);
553 Py_INCREF(Py_None);
554 _res = Py_None;
555 return _res;
556}
557
558static PyObject *WinObj_TrackGoAway(_self, _args)
559 WindowObject *_self;
560 PyObject *_args;
561{
562 PyObject *_res = NULL;
563 Boolean _rv;
564 Point thePt;
565 if (!PyArg_ParseTuple(_args, "O&",
566 PyMac_GetPoint, &thePt))
567 return NULL;
568 _rv = TrackGoAway(_self->ob_itself,
569 thePt);
570 _res = Py_BuildValue("b",
571 _rv);
572 return _res;
573}
574
575static PyObject *WinObj_DragWindow(_self, _args)
576 WindowObject *_self;
577 PyObject *_args;
578{
579 PyObject *_res = NULL;
580 Point startPt;
581 Rect boundsRect;
582 if (!PyArg_ParseTuple(_args, "O&O&",
583 PyMac_GetPoint, &startPt,
584 PyMac_GetRect, &boundsRect))
585 return NULL;
586 DragWindow(_self->ob_itself,
587 startPt,
588 &boundsRect);
589 Py_INCREF(Py_None);
590 _res = Py_None;
591 return _res;
592}
593
Jack Jansenb7abb181995-11-15 15:18:47 +0000594static PyObject *WinObj_GetWindowPort(_self, _args)
595 WindowObject *_self;
596 PyObject *_args;
597{
598 PyObject *_res = NULL;
599 CGrafPtr _rv;
600 if (!PyArg_ParseTuple(_args, ""))
601 return NULL;
602 _rv = GetWindowPort(_self->ob_itself);
603 _res = Py_BuildValue("O&",
604 GrafObj_New, _rv);
605 return _res;
606}
607
Jack Jansen330f5761995-11-14 10:48:54 +0000608static PyObject *WinObj_SetPortWindowPort(_self, _args)
609 WindowObject *_self;
610 PyObject *_args;
611{
612 PyObject *_res = NULL;
613 if (!PyArg_ParseTuple(_args, ""))
614 return NULL;
615 SetPortWindowPort(_self->ob_itself);
616 Py_INCREF(Py_None);
617 _res = Py_None;
618 return _res;
619}
620
621static PyObject *WinObj_GetWindowKind(_self, _args)
622 WindowObject *_self;
623 PyObject *_args;
624{
625 PyObject *_res = NULL;
626 short _rv;
627 if (!PyArg_ParseTuple(_args, ""))
628 return NULL;
629 _rv = GetWindowKind(_self->ob_itself);
630 _res = Py_BuildValue("h",
631 _rv);
632 return _res;
633}
634
635static PyObject *WinObj_SetWindowKind(_self, _args)
636 WindowObject *_self;
637 PyObject *_args;
638{
639 PyObject *_res = NULL;
640 short wKind;
641 if (!PyArg_ParseTuple(_args, "h",
642 &wKind))
643 return NULL;
644 SetWindowKind(_self->ob_itself,
645 wKind);
646 Py_INCREF(Py_None);
647 _res = Py_None;
648 return _res;
649}
650
651static PyObject *WinObj_IsWindowVisible(_self, _args)
652 WindowObject *_self;
653 PyObject *_args;
654{
655 PyObject *_res = NULL;
656 Boolean _rv;
657 if (!PyArg_ParseTuple(_args, ""))
658 return NULL;
659 _rv = IsWindowVisible(_self->ob_itself);
660 _res = Py_BuildValue("b",
661 _rv);
662 return _res;
663}
664
665static PyObject *WinObj_IsWindowHilited(_self, _args)
666 WindowObject *_self;
667 PyObject *_args;
668{
669 PyObject *_res = NULL;
670 Boolean _rv;
671 if (!PyArg_ParseTuple(_args, ""))
672 return NULL;
673 _rv = IsWindowHilited(_self->ob_itself);
674 _res = Py_BuildValue("b",
675 _rv);
676 return _res;
677}
678
679static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
680 WindowObject *_self;
681 PyObject *_args;
682{
683 PyObject *_res = NULL;
684 Boolean _rv;
685 if (!PyArg_ParseTuple(_args, ""))
686 return NULL;
687 _rv = GetWindowGoAwayFlag(_self->ob_itself);
688 _res = Py_BuildValue("b",
689 _rv);
690 return _res;
691}
692
693static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
694 WindowObject *_self;
695 PyObject *_args;
696{
697 PyObject *_res = NULL;
698 Boolean _rv;
699 if (!PyArg_ParseTuple(_args, ""))
700 return NULL;
701 _rv = GetWindowZoomFlag(_self->ob_itself);
702 _res = Py_BuildValue("b",
703 _rv);
704 return _res;
705}
706
Jack Jansenb7abb181995-11-15 15:18:47 +0000707static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
708 WindowObject *_self;
709 PyObject *_args;
710{
711 PyObject *_res = NULL;
712 RgnHandle r;
713 if (!PyArg_ParseTuple(_args, "O&",
714 ResObj_Convert, &r))
715 return NULL;
716 GetWindowStructureRgn(_self->ob_itself,
717 r);
718 Py_INCREF(Py_None);
719 _res = Py_None;
720 return _res;
721}
722
723static PyObject *WinObj_GetWindowContentRgn(_self, _args)
724 WindowObject *_self;
725 PyObject *_args;
726{
727 PyObject *_res = NULL;
728 RgnHandle r;
729 if (!PyArg_ParseTuple(_args, "O&",
730 ResObj_Convert, &r))
731 return NULL;
732 GetWindowContentRgn(_self->ob_itself,
733 r);
734 Py_INCREF(Py_None);
735 _res = Py_None;
736 return _res;
737}
738
739static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
740 WindowObject *_self;
741 PyObject *_args;
742{
743 PyObject *_res = NULL;
744 RgnHandle r;
745 if (!PyArg_ParseTuple(_args, "O&",
746 ResObj_Convert, &r))
747 return NULL;
748 GetWindowUpdateRgn(_self->ob_itself,
749 r);
750 Py_INCREF(Py_None);
751 _res = Py_None;
752 return _res;
753}
754
Jack Jansen330f5761995-11-14 10:48:54 +0000755static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
756 WindowObject *_self;
757 PyObject *_args;
758{
759 PyObject *_res = NULL;
760 short _rv;
761 if (!PyArg_ParseTuple(_args, ""))
762 return NULL;
763 _rv = GetWindowTitleWidth(_self->ob_itself);
764 _res = Py_BuildValue("h",
765 _rv);
766 return _res;
767}
768
769static PyObject *WinObj_GetNextWindow(_self, _args)
770 WindowObject *_self;
771 PyObject *_args;
772{
773 PyObject *_res = NULL;
774 WindowPtr _rv;
775 if (!PyArg_ParseTuple(_args, ""))
776 return NULL;
777 _rv = GetNextWindow(_self->ob_itself);
778 _res = Py_BuildValue("O&",
779 WinObj_WhichWindow, _rv);
780 return _res;
781}
782
783static PyObject *WinObj_GetWindowStandardState(_self, _args)
784 WindowObject *_self;
785 PyObject *_args;
786{
787 PyObject *_res = NULL;
788 Rect r;
789 if (!PyArg_ParseTuple(_args, ""))
790 return NULL;
791 GetWindowStandardState(_self->ob_itself,
792 &r);
793 _res = Py_BuildValue("O&",
794 PyMac_BuildRect, &r);
795 return _res;
796}
797
798static PyObject *WinObj_GetWindowUserState(_self, _args)
799 WindowObject *_self;
800 PyObject *_args;
801{
802 PyObject *_res = NULL;
803 Rect r;
804 if (!PyArg_ParseTuple(_args, ""))
805 return NULL;
806 GetWindowUserState(_self->ob_itself,
807 &r);
808 _res = Py_BuildValue("O&",
809 PyMac_BuildRect, &r);
810 return _res;
811}
812
813static PyObject *WinObj_SetWindowStandardState(_self, _args)
814 WindowObject *_self;
815 PyObject *_args;
816{
817 PyObject *_res = NULL;
818 Rect r;
819 if (!PyArg_ParseTuple(_args, "O&",
820 PyMac_GetRect, &r))
821 return NULL;
822 SetWindowStandardState(_self->ob_itself,
823 &r);
824 Py_INCREF(Py_None);
825 _res = Py_None;
826 return _res;
827}
828
829static PyObject *WinObj_SetWindowUserState(_self, _args)
830 WindowObject *_self;
831 PyObject *_args;
832{
833 PyObject *_res = NULL;
834 Rect r;
835 if (!PyArg_ParseTuple(_args, "O&",
836 PyMac_GetRect, &r))
837 return NULL;
838 SetWindowUserState(_self->ob_itself,
839 &r);
840 Py_INCREF(Py_None);
841 _res = Py_None;
842 return _res;
843}
844
Guido van Rossum17448e21995-01-30 11:53:55 +0000845static PyMethodDef WinObj_methods[] = {
846 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
847 "() -> (Str255 title)"},
848 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
849 "() -> None"},
850 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
851 "() -> None"},
852 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
853 "() -> None"},
854 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
855 "(Boolean showFlag) -> None"},
856 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
857 "(Boolean fHilite) -> None"},
858 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
859 "() -> None"},
860 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
861 "(WindowPtr behindWindow) -> None"},
862 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
863 "() -> None"},
864 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
865 "(short hGlobal, short vGlobal, Boolean front) -> None"},
866 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
867 "(short w, short h, Boolean fUpdate) -> None"},
868 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
869 "(short partCode, Boolean front) -> None"},
870 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
871 "() -> None"},
872 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
873 "() -> None"},
874 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
875 "(long data) -> None"},
876 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
877 "() -> (long _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +0000878 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
879 "(PicHandle pic) -> None"},
880 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
881 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000882 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
883 "() -> None"},
884 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
885 "() -> None"},
886 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
887 "(Boolean update) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +0000888 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
889 "(RgnHandle clobberedRgn) -> None"},
890 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
891 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000892 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
893 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +0000894 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
895 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000896 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
897 "(Point startPt, Rect bBox) -> (long _rv)"},
898 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
899 "(Point thePt, short partCode) -> (Boolean _rv)"},
900 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
901 "() -> (short _rv)"},
902 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
903 "(Str255 title) -> None"},
904 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
905 "(Point thePt) -> (Boolean _rv)"},
906 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
907 "(Point startPt, Rect boundsRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +0000908 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
909 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +0000910 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
911 "() -> None"},
912 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
913 "() -> (short _rv)"},
914 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
915 "(short wKind) -> None"},
916 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
917 "() -> (Boolean _rv)"},
918 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
919 "() -> (Boolean _rv)"},
920 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
921 "() -> (Boolean _rv)"},
922 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
923 "() -> (Boolean _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +0000924 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
925 "(RgnHandle r) -> None"},
926 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
927 "(RgnHandle r) -> None"},
928 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
929 "(RgnHandle r) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +0000930 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
931 "() -> (short _rv)"},
932 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
933 "() -> (WindowPtr _rv)"},
934 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
935 "() -> (Rect r)"},
936 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
937 "() -> (Rect r)"},
938 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
939 "(Rect r) -> None"},
940 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
941 "(Rect r) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000942 {NULL, NULL, 0}
943};
944
945PyMethodChain WinObj_chain = { WinObj_methods, NULL };
946
947static PyObject *WinObj_getattr(self, name)
948 WindowObject *self;
949 char *name;
950{
951 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
952}
953
954#define WinObj_setattr NULL
955
956PyTypeObject Window_Type = {
957 PyObject_HEAD_INIT(&PyType_Type)
958 0, /*ob_size*/
959 "Window", /*tp_name*/
960 sizeof(WindowObject), /*tp_basicsize*/
961 0, /*tp_itemsize*/
962 /* methods */
963 (destructor) WinObj_dealloc, /*tp_dealloc*/
964 0, /*tp_print*/
965 (getattrfunc) WinObj_getattr, /*tp_getattr*/
966 (setattrfunc) WinObj_setattr, /*tp_setattr*/
967};
968
969/* --------------------- End object type Window --------------------- */
970
971
Jack Jansenb7abb181995-11-15 15:18:47 +0000972static PyObject *Win_GetGrayRgn(_self, _args)
973 PyObject *_self;
974 PyObject *_args;
975{
976 PyObject *_res = NULL;
977 RgnHandle _rv;
978 if (!PyArg_ParseTuple(_args, ""))
979 return NULL;
980 _rv = GetGrayRgn();
981 _res = Py_BuildValue("O&",
982 ResObj_New, _rv);
983 return _res;
984}
985
Guido van Rossum17448e21995-01-30 11:53:55 +0000986static PyObject *Win_InitWindows(_self, _args)
987 PyObject *_self;
988 PyObject *_args;
989{
990 PyObject *_res = NULL;
991 if (!PyArg_ParseTuple(_args, ""))
992 return NULL;
993 InitWindows();
994 Py_INCREF(Py_None);
995 _res = Py_None;
996 return _res;
997}
998
Jack Jansenb7abb181995-11-15 15:18:47 +0000999static PyObject *Win_GetWMgrPort(_self, _args)
1000 PyObject *_self;
1001 PyObject *_args;
1002{
1003 PyObject *_res = NULL;
1004 GrafPtr wPort;
1005 if (!PyArg_ParseTuple(_args, ""))
1006 return NULL;
1007 GetWMgrPort(&wPort);
1008 _res = Py_BuildValue("O&",
1009 GrafObj_New, wPort);
1010 return _res;
1011}
1012
Guido van Rossum17448e21995-01-30 11:53:55 +00001013static PyObject *Win_NewWindow(_self, _args)
1014 PyObject *_self;
1015 PyObject *_args;
1016{
1017 PyObject *_res = NULL;
1018 WindowPtr _rv;
1019 Rect boundsRect;
1020 Str255 title;
1021 Boolean visible;
1022 short theProc;
1023 WindowPtr behind;
1024 Boolean goAwayFlag;
1025 long refCon;
1026 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1027 PyMac_GetRect, &boundsRect,
1028 PyMac_GetStr255, title,
1029 &visible,
1030 &theProc,
1031 WinObj_Convert, &behind,
1032 &goAwayFlag,
1033 &refCon))
1034 return NULL;
1035 _rv = NewWindow((void *)0,
1036 &boundsRect,
1037 title,
1038 visible,
1039 theProc,
1040 behind,
1041 goAwayFlag,
1042 refCon);
1043 _res = Py_BuildValue("O&",
1044 WinObj_New, _rv);
1045 return _res;
1046}
1047
1048static PyObject *Win_GetNewWindow(_self, _args)
1049 PyObject *_self;
1050 PyObject *_args;
1051{
1052 PyObject *_res = NULL;
1053 WindowPtr _rv;
1054 short windowID;
1055 WindowPtr behind;
1056 if (!PyArg_ParseTuple(_args, "hO&",
1057 &windowID,
1058 WinObj_Convert, &behind))
1059 return NULL;
1060 _rv = GetNewWindow(windowID,
1061 (void *)0,
1062 behind);
1063 _res = Py_BuildValue("O&",
1064 WinObj_New, _rv);
1065 return _res;
1066}
1067
1068static PyObject *Win_FrontWindow(_self, _args)
1069 PyObject *_self;
1070 PyObject *_args;
1071{
1072 PyObject *_res = NULL;
1073 WindowPtr _rv;
1074 if (!PyArg_ParseTuple(_args, ""))
1075 return NULL;
1076 _rv = FrontWindow();
1077 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00001078 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001079 return _res;
1080}
1081
1082static PyObject *Win_InvalRect(_self, _args)
1083 PyObject *_self;
1084 PyObject *_args;
1085{
1086 PyObject *_res = NULL;
1087 Rect badRect;
1088 if (!PyArg_ParseTuple(_args, "O&",
1089 PyMac_GetRect, &badRect))
1090 return NULL;
1091 InvalRect(&badRect);
1092 Py_INCREF(Py_None);
1093 _res = Py_None;
1094 return _res;
1095}
1096
Jack Jansenb7abb181995-11-15 15:18:47 +00001097static PyObject *Win_InvalRgn(_self, _args)
1098 PyObject *_self;
1099 PyObject *_args;
1100{
1101 PyObject *_res = NULL;
1102 RgnHandle badRgn;
1103 if (!PyArg_ParseTuple(_args, "O&",
1104 ResObj_Convert, &badRgn))
1105 return NULL;
1106 InvalRgn(badRgn);
1107 Py_INCREF(Py_None);
1108 _res = Py_None;
1109 return _res;
1110}
1111
Guido van Rossum17448e21995-01-30 11:53:55 +00001112static PyObject *Win_ValidRect(_self, _args)
1113 PyObject *_self;
1114 PyObject *_args;
1115{
1116 PyObject *_res = NULL;
1117 Rect goodRect;
1118 if (!PyArg_ParseTuple(_args, "O&",
1119 PyMac_GetRect, &goodRect))
1120 return NULL;
1121 ValidRect(&goodRect);
1122 Py_INCREF(Py_None);
1123 _res = Py_None;
1124 return _res;
1125}
1126
Jack Jansenb7abb181995-11-15 15:18:47 +00001127static PyObject *Win_ValidRgn(_self, _args)
1128 PyObject *_self;
1129 PyObject *_args;
1130{
1131 PyObject *_res = NULL;
1132 RgnHandle goodRgn;
1133 if (!PyArg_ParseTuple(_args, "O&",
1134 ResObj_Convert, &goodRgn))
1135 return NULL;
1136 ValidRgn(goodRgn);
1137 Py_INCREF(Py_None);
1138 _res = Py_None;
1139 return _res;
1140}
1141
Guido van Rossum17448e21995-01-30 11:53:55 +00001142static PyObject *Win_CheckUpdate(_self, _args)
1143 PyObject *_self;
1144 PyObject *_args;
1145{
1146 PyObject *_res = NULL;
1147 Boolean _rv;
1148 EventRecord theEvent;
1149 if (!PyArg_ParseTuple(_args, ""))
1150 return NULL;
1151 _rv = CheckUpdate(&theEvent);
1152 _res = Py_BuildValue("bO&",
1153 _rv,
1154 PyMac_BuildEventRecord, &theEvent);
1155 return _res;
1156}
1157
1158static PyObject *Win_FindWindow(_self, _args)
1159 PyObject *_self;
1160 PyObject *_args;
1161{
1162 PyObject *_res = NULL;
1163 short _rv;
1164 Point thePoint;
1165 WindowPtr theWindow;
1166 if (!PyArg_ParseTuple(_args, "O&",
1167 PyMac_GetPoint, &thePoint))
1168 return NULL;
1169 _rv = FindWindow(thePoint,
1170 &theWindow);
1171 _res = Py_BuildValue("hO&",
1172 _rv,
1173 WinObj_WhichWindow, theWindow);
1174 return _res;
1175}
1176
1177static PyObject *Win_PinRect(_self, _args)
1178 PyObject *_self;
1179 PyObject *_args;
1180{
1181 PyObject *_res = NULL;
1182 long _rv;
1183 Rect theRect;
1184 Point thePt;
1185 if (!PyArg_ParseTuple(_args, "O&O&",
1186 PyMac_GetRect, &theRect,
1187 PyMac_GetPoint, &thePt))
1188 return NULL;
1189 _rv = PinRect(&theRect,
1190 thePt);
1191 _res = Py_BuildValue("l",
1192 _rv);
1193 return _res;
1194}
1195
Jack Jansenb7abb181995-11-15 15:18:47 +00001196static PyObject *Win_GetCWMgrPort(_self, _args)
1197 PyObject *_self;
1198 PyObject *_args;
1199{
1200 PyObject *_res = NULL;
1201 CGrafPtr wMgrCPort;
1202 if (!PyArg_ParseTuple(_args, ""))
1203 return NULL;
1204 GetCWMgrPort(&wMgrCPort);
1205 _res = Py_BuildValue("O&",
1206 GrafObj_New, wMgrCPort);
1207 return _res;
1208}
1209
Guido van Rossum17448e21995-01-30 11:53:55 +00001210static PyObject *Win_NewCWindow(_self, _args)
1211 PyObject *_self;
1212 PyObject *_args;
1213{
1214 PyObject *_res = NULL;
1215 WindowPtr _rv;
1216 Rect boundsRect;
1217 Str255 title;
1218 Boolean visible;
1219 short procID;
1220 WindowPtr behind;
1221 Boolean goAwayFlag;
1222 long refCon;
1223 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1224 PyMac_GetRect, &boundsRect,
1225 PyMac_GetStr255, title,
1226 &visible,
1227 &procID,
1228 WinObj_Convert, &behind,
1229 &goAwayFlag,
1230 &refCon))
1231 return NULL;
1232 _rv = NewCWindow((void *)0,
1233 &boundsRect,
1234 title,
1235 visible,
1236 procID,
1237 behind,
1238 goAwayFlag,
1239 refCon);
1240 _res = Py_BuildValue("O&",
1241 WinObj_New, _rv);
1242 return _res;
1243}
1244
1245static PyObject *Win_GetNewCWindow(_self, _args)
1246 PyObject *_self;
1247 PyObject *_args;
1248{
1249 PyObject *_res = NULL;
1250 WindowPtr _rv;
1251 short windowID;
1252 WindowPtr behind;
1253 if (!PyArg_ParseTuple(_args, "hO&",
1254 &windowID,
1255 WinObj_Convert, &behind))
1256 return NULL;
1257 _rv = GetNewCWindow(windowID,
1258 (void *)0,
1259 behind);
1260 _res = Py_BuildValue("O&",
1261 WinObj_New, _rv);
1262 return _res;
1263}
1264
Jack Jansend4c26461995-08-17 14:35:56 +00001265static PyObject *Win_WhichWindow(_self, _args)
1266 PyObject *_self;
1267 PyObject *_args;
1268{
1269 PyObject *_res = NULL;
1270
1271 long ptr;
1272
1273 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
1274 return NULL;
1275 return WinObj_WhichWindow((WindowPtr)ptr);
1276
1277}
1278
Guido van Rossum17448e21995-01-30 11:53:55 +00001279static PyMethodDef Win_methods[] = {
Jack Jansenb7abb181995-11-15 15:18:47 +00001280 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
1281 "() -> (RgnHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001282 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
1283 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001284 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
1285 "() -> (GrafPtr wPort)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001286 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
1287 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1288 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
1289 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
1290 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
1291 "() -> (WindowPtr _rv)"},
1292 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
1293 "(Rect badRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001294 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
1295 "(RgnHandle badRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001296 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
1297 "(Rect goodRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001298 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
1299 "(RgnHandle goodRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001300 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
1301 "() -> (Boolean _rv, EventRecord theEvent)"},
1302 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
1303 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
1304 {"PinRect", (PyCFunction)Win_PinRect, 1,
1305 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001306 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
1307 "() -> (CGrafPtr wMgrCPort)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001308 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
1309 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1310 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
1311 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00001312 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
1313 "Resolve an integer WindowPtr address to a Window object"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001314 {NULL, NULL, 0}
1315};
1316
1317
1318
1319/* Return the object corresponding to the window, or NULL */
1320
1321PyObject *
1322WinObj_WhichWindow(w)
1323 WindowPtr w;
1324{
1325 PyObject *it;
1326
1327 /* XXX What if we find a stdwin window or a window belonging
1328 to some other package? */
Guido van Rossum97842951995-02-19 15:59:49 +00001329 if (w == NULL)
1330 it = NULL;
1331 else
1332 it = (PyObject *) GetWRefCon(w);
Guido van Rossum17448e21995-01-30 11:53:55 +00001333 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
1334 it = Py_None;
1335 Py_INCREF(it);
1336 return it;
1337}
1338
1339
1340void initWin()
1341{
1342 PyObject *m;
1343 PyObject *d;
1344
1345
1346
1347
1348 m = Py_InitModule("Win", Win_methods);
1349 d = PyModule_GetDict(m);
1350 Win_Error = PyMac_GetOSErrException();
1351 if (Win_Error == NULL ||
1352 PyDict_SetItemString(d, "Error", Win_Error) != 0)
1353 Py_FatalError("can't initialize Win.Error");
1354}
1355
1356/* ========================= End module Win ========================= */
1357