blob: 78c801d8d71a1ee05e3e60fceca54d7b29ddc18a [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 Rossum17448e21995-01-30 11:53:55 +000049
Guido van Rossum17448e21995-01-30 11:53:55 +000050static PyObject *Win_Error;
51
52/* ----------------------- Object type Window ----------------------- */
53
54PyTypeObject Window_Type;
55
56#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
57
58typedef struct WindowObject {
59 PyObject_HEAD
60 WindowPtr ob_itself;
61} WindowObject;
62
63PyObject *WinObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +000064 WindowPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000065{
66 WindowObject *it;
67 if (itself == NULL) return PyMac_Error(resNotFound);
68 it = PyObject_NEW(WindowObject, &Window_Type);
69 if (it == NULL) return NULL;
70 it->ob_itself = itself;
71 SetWRefCon(itself, (long)it);
72 return (PyObject *)it;
73}
74WinObj_Convert(v, p_itself)
75 PyObject *v;
76 WindowPtr *p_itself;
77{
78 if (DlgObj_Check(v)) {
79 *p_itself = ((WindowObject *)v)->ob_itself;
80 return 1;
81 }
82
83 if (v == Py_None) { *p_itself = NULL; return 1; }
84 if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
85
86 if (!WinObj_Check(v))
87 {
88 PyErr_SetString(PyExc_TypeError, "Window required");
89 return 0;
90 }
91 *p_itself = ((WindowObject *)v)->ob_itself;
92 return 1;
93}
94
95static void WinObj_dealloc(self)
96 WindowObject *self;
97{
98 DisposeWindow(self->ob_itself);
99 PyMem_DEL(self);
100}
101
Jack Jansen1c4e6141998-04-21 15:23:55 +0000102static PyObject *WinObj_MacCloseWindow(_self, _args)
103 WindowObject *_self;
104 PyObject *_args;
105{
106 PyObject *_res = NULL;
107 if (!PyArg_ParseTuple(_args, ""))
108 return NULL;
109 MacCloseWindow(_self->ob_itself);
110 Py_INCREF(Py_None);
111 _res = Py_None;
112 return _res;
113}
114
Jack Jansen21f96871998-02-20 16:02:09 +0000115static PyObject *WinObj_SetWinColor(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000116 WindowObject *_self;
117 PyObject *_args;
118{
119 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000120 WCTabHandle newColorTable;
Guido van Rossum17448e21995-01-30 11:53:55 +0000121 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen21f96871998-02-20 16:02:09 +0000122 ResObj_Convert, &newColorTable))
Guido van Rossum17448e21995-01-30 11:53:55 +0000123 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000124 SetWinColor(_self->ob_itself,
125 newColorTable);
Guido van Rossum17448e21995-01-30 11:53:55 +0000126 Py_INCREF(Py_None);
127 _res = Py_None;
128 return _res;
129}
130
Guido van Rossum17448e21995-01-30 11:53:55 +0000131static PyObject *WinObj_ClipAbove(_self, _args)
132 WindowObject *_self;
133 PyObject *_args;
134{
135 PyObject *_res = NULL;
136 if (!PyArg_ParseTuple(_args, ""))
137 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000138 ClipAbove(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000139 Py_INCREF(Py_None);
140 _res = Py_None;
141 return _res;
142}
143
144static PyObject *WinObj_SaveOld(_self, _args)
145 WindowObject *_self;
146 PyObject *_args;
147{
148 PyObject *_res = NULL;
149 if (!PyArg_ParseTuple(_args, ""))
150 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000151 SaveOld(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000152 Py_INCREF(Py_None);
153 _res = Py_None;
154 return _res;
155}
156
157static PyObject *WinObj_DrawNew(_self, _args)
158 WindowObject *_self;
159 PyObject *_args;
160{
161 PyObject *_res = NULL;
162 Boolean update;
163 if (!PyArg_ParseTuple(_args, "b",
164 &update))
165 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000166 DrawNew(_self->ob_itself,
Guido van Rossum17448e21995-01-30 11:53:55 +0000167 update);
168 Py_INCREF(Py_None);
169 _res = Py_None;
170 return _res;
171}
172
Jack Jansenb7abb181995-11-15 15:18:47 +0000173static PyObject *WinObj_PaintOne(_self, _args)
174 WindowObject *_self;
175 PyObject *_args;
176{
177 PyObject *_res = NULL;
178 RgnHandle clobberedRgn;
179 if (!PyArg_ParseTuple(_args, "O&",
180 ResObj_Convert, &clobberedRgn))
181 return NULL;
182 PaintOne(_self->ob_itself,
183 clobberedRgn);
184 Py_INCREF(Py_None);
185 _res = Py_None;
186 return _res;
187}
188
189static PyObject *WinObj_PaintBehind(_self, _args)
190 WindowObject *_self;
191 PyObject *_args;
192{
193 PyObject *_res = NULL;
194 RgnHandle clobberedRgn;
195 if (!PyArg_ParseTuple(_args, "O&",
196 ResObj_Convert, &clobberedRgn))
197 return NULL;
198 PaintBehind(_self->ob_itself,
199 clobberedRgn);
200 Py_INCREF(Py_None);
201 _res = Py_None;
202 return _res;
203}
204
Guido van Rossum17448e21995-01-30 11:53:55 +0000205static PyObject *WinObj_CalcVis(_self, _args)
206 WindowObject *_self;
207 PyObject *_args;
208{
209 PyObject *_res = NULL;
210 if (!PyArg_ParseTuple(_args, ""))
211 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000212 CalcVis(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000213 Py_INCREF(Py_None);
214 _res = Py_None;
215 return _res;
216}
217
Jack Jansenb7abb181995-11-15 15:18:47 +0000218static PyObject *WinObj_CalcVisBehind(_self, _args)
219 WindowObject *_self;
220 PyObject *_args;
221{
222 PyObject *_res = NULL;
223 RgnHandle clobberedRgn;
224 if (!PyArg_ParseTuple(_args, "O&",
225 ResObj_Convert, &clobberedRgn))
226 return NULL;
227 CalcVisBehind(_self->ob_itself,
228 clobberedRgn);
229 Py_INCREF(Py_None);
230 _res = Py_None;
231 return _res;
232}
233
Jack Jansen21f96871998-02-20 16:02:09 +0000234static PyObject *WinObj_BringToFront(_self, _args)
235 WindowObject *_self;
236 PyObject *_args;
237{
238 PyObject *_res = NULL;
239 if (!PyArg_ParseTuple(_args, ""))
240 return NULL;
241 BringToFront(_self->ob_itself);
242 Py_INCREF(Py_None);
243 _res = Py_None;
244 return _res;
245}
246
247static PyObject *WinObj_SendBehind(_self, _args)
248 WindowObject *_self;
249 PyObject *_args;
250{
251 PyObject *_res = NULL;
252 WindowPtr behindWindow;
253 if (!PyArg_ParseTuple(_args, "O&",
254 WinObj_Convert, &behindWindow))
255 return NULL;
256 SendBehind(_self->ob_itself,
257 behindWindow);
258 Py_INCREF(Py_None);
259 _res = Py_None;
260 return _res;
261}
262
263static PyObject *WinObj_SelectWindow(_self, _args)
264 WindowObject *_self;
265 PyObject *_args;
266{
267 PyObject *_res = NULL;
268 if (!PyArg_ParseTuple(_args, ""))
269 return NULL;
270 SelectWindow(_self->ob_itself);
271 Py_INCREF(Py_None);
272 _res = Py_None;
273 return _res;
274}
275
Jack Jansen1c4e6141998-04-21 15:23:55 +0000276static PyObject *WinObj_HiliteWindow(_self, _args)
277 WindowObject *_self;
278 PyObject *_args;
279{
280 PyObject *_res = NULL;
281 Boolean fHilite;
282 if (!PyArg_ParseTuple(_args, "b",
283 &fHilite))
284 return NULL;
285 HiliteWindow(_self->ob_itself,
286 fHilite);
287 Py_INCREF(Py_None);
288 _res = Py_None;
289 return _res;
290}
291
Jack Jansen21f96871998-02-20 16:02:09 +0000292static PyObject *WinObj_GetWindowFeatures(_self, _args)
293 WindowObject *_self;
294 PyObject *_args;
295{
296 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000297 OSStatus _err;
Jack Jansen21f96871998-02-20 16:02:09 +0000298 UInt32 outFeatures;
299 if (!PyArg_ParseTuple(_args, ""))
300 return NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000301 _err = GetWindowFeatures(_self->ob_itself,
302 &outFeatures);
303 if (_err != noErr) return PyMac_Error(_err);
304 _res = Py_BuildValue("l",
Jack Jansen21f96871998-02-20 16:02:09 +0000305 outFeatures);
306 return _res;
307}
308
309static PyObject *WinObj_GetWindowRegion(_self, _args)
310 WindowObject *_self;
311 PyObject *_args;
312{
313 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000314 OSStatus _err;
Jack Jansen21f96871998-02-20 16:02:09 +0000315 WindowRegionCode inRegionCode;
316 RgnHandle ioWinRgn;
317 if (!PyArg_ParseTuple(_args, "hO&",
318 &inRegionCode,
319 ResObj_Convert, &ioWinRgn))
320 return NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000321 _err = GetWindowRegion(_self->ob_itself,
322 inRegionCode,
323 ioWinRgn);
324 if (_err != noErr) return PyMac_Error(_err);
325 Py_INCREF(Py_None);
326 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +0000327 return _res;
328}
329
330static PyObject *WinObj_SetWRefCon(_self, _args)
331 WindowObject *_self;
332 PyObject *_args;
333{
334 PyObject *_res = NULL;
335 long data;
336 if (!PyArg_ParseTuple(_args, "l",
337 &data))
338 return NULL;
339 SetWRefCon(_self->ob_itself,
340 data);
341 Py_INCREF(Py_None);
342 _res = Py_None;
343 return _res;
344}
345
346static PyObject *WinObj_GetWRefCon(_self, _args)
347 WindowObject *_self;
348 PyObject *_args;
349{
350 PyObject *_res = NULL;
351 long _rv;
352 if (!PyArg_ParseTuple(_args, ""))
353 return NULL;
354 _rv = GetWRefCon(_self->ob_itself);
355 _res = Py_BuildValue("l",
356 _rv);
357 return _res;
358}
359
360static PyObject *WinObj_SetWindowPic(_self, _args)
361 WindowObject *_self;
362 PyObject *_args;
363{
364 PyObject *_res = NULL;
365 PicHandle pic;
366 if (!PyArg_ParseTuple(_args, "O&",
367 ResObj_Convert, &pic))
368 return NULL;
369 SetWindowPic(_self->ob_itself,
370 pic);
371 Py_INCREF(Py_None);
372 _res = Py_None;
373 return _res;
374}
375
376static PyObject *WinObj_GetWindowPic(_self, _args)
377 WindowObject *_self;
378 PyObject *_args;
379{
380 PyObject *_res = NULL;
381 PicHandle _rv;
382 if (!PyArg_ParseTuple(_args, ""))
383 return NULL;
384 _rv = GetWindowPic(_self->ob_itself);
385 _res = Py_BuildValue("O&",
386 ResObj_New, _rv);
387 return _res;
388}
389
390static PyObject *WinObj_GetWVariant(_self, _args)
391 WindowObject *_self;
392 PyObject *_args;
393{
394 PyObject *_res = NULL;
395 short _rv;
396 if (!PyArg_ParseTuple(_args, ""))
397 return NULL;
398 _rv = GetWVariant(_self->ob_itself);
399 _res = Py_BuildValue("h",
400 _rv);
401 return _res;
402}
403
404static PyObject *WinObj_BeginUpdate(_self, _args)
405 WindowObject *_self;
406 PyObject *_args;
407{
408 PyObject *_res = NULL;
409 if (!PyArg_ParseTuple(_args, ""))
410 return NULL;
411 BeginUpdate(_self->ob_itself);
412 Py_INCREF(Py_None);
413 _res = Py_None;
414 return _res;
415}
416
417static PyObject *WinObj_EndUpdate(_self, _args)
418 WindowObject *_self;
419 PyObject *_args;
420{
421 PyObject *_res = NULL;
422 if (!PyArg_ParseTuple(_args, ""))
423 return NULL;
424 EndUpdate(_self->ob_itself);
425 Py_INCREF(Py_None);
426 _res = Py_None;
427 return _res;
428}
429
430static PyObject *WinObj_DrawGrowIcon(_self, _args)
431 WindowObject *_self;
432 PyObject *_args;
433{
434 PyObject *_res = NULL;
435 if (!PyArg_ParseTuple(_args, ""))
436 return NULL;
437 DrawGrowIcon(_self->ob_itself);
438 Py_INCREF(Py_None);
439 _res = Py_None;
440 return _res;
441}
442
Jack Jansen21f96871998-02-20 16:02:09 +0000443static PyObject *WinObj_SetWTitle(_self, _args)
444 WindowObject *_self;
445 PyObject *_args;
446{
447 PyObject *_res = NULL;
448 Str255 title;
449 if (!PyArg_ParseTuple(_args, "O&",
450 PyMac_GetStr255, title))
451 return NULL;
452 SetWTitle(_self->ob_itself,
453 title);
454 Py_INCREF(Py_None);
455 _res = Py_None;
456 return _res;
457}
458
459static PyObject *WinObj_GetWTitle(_self, _args)
460 WindowObject *_self;
461 PyObject *_args;
462{
463 PyObject *_res = NULL;
464 Str255 title;
465 if (!PyArg_ParseTuple(_args, ""))
466 return NULL;
467 GetWTitle(_self->ob_itself,
468 title);
469 _res = Py_BuildValue("O&",
470 PyMac_BuildStr255, title);
471 return _res;
472}
473
474static PyObject *WinObj_IsWindowCollapsable(_self, _args)
475 WindowObject *_self;
476 PyObject *_args;
477{
478 PyObject *_res = NULL;
479 Boolean _rv;
480 if (!PyArg_ParseTuple(_args, ""))
481 return NULL;
482 _rv = IsWindowCollapsable(_self->ob_itself);
483 _res = Py_BuildValue("b",
484 _rv);
485 return _res;
486}
487
488static PyObject *WinObj_IsWindowCollapsed(_self, _args)
489 WindowObject *_self;
490 PyObject *_args;
491{
492 PyObject *_res = NULL;
493 Boolean _rv;
494 if (!PyArg_ParseTuple(_args, ""))
495 return NULL;
496 _rv = IsWindowCollapsed(_self->ob_itself);
497 _res = Py_BuildValue("b",
498 _rv);
499 return _res;
500}
501
502static PyObject *WinObj_CollapseWindow(_self, _args)
503 WindowObject *_self;
504 PyObject *_args;
505{
506 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000507 OSStatus _err;
Jack Jansen21f96871998-02-20 16:02:09 +0000508 Boolean inCollapseIt;
509 if (!PyArg_ParseTuple(_args, "b",
510 &inCollapseIt))
511 return NULL;
Jack Jansene4349e81999-03-04 22:53:24 +0000512 _err = CollapseWindow(_self->ob_itself,
513 inCollapseIt);
514 if (_err != noErr) return PyMac_Error(_err);
515 Py_INCREF(Py_None);
516 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +0000517 return _res;
518}
519
Jack Jansen1c4e6141998-04-21 15:23:55 +0000520static PyObject *WinObj_MacMoveWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000521 WindowObject *_self;
522 PyObject *_args;
523{
524 PyObject *_res = NULL;
525 short hGlobal;
526 short vGlobal;
527 Boolean front;
528 if (!PyArg_ParseTuple(_args, "hhb",
529 &hGlobal,
530 &vGlobal,
531 &front))
532 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000533 MacMoveWindow(_self->ob_itself,
534 hGlobal,
535 vGlobal,
536 front);
Jack Jansen21f96871998-02-20 16:02:09 +0000537 Py_INCREF(Py_None);
538 _res = Py_None;
539 return _res;
540}
541
542static PyObject *WinObj_SizeWindow(_self, _args)
543 WindowObject *_self;
544 PyObject *_args;
545{
546 PyObject *_res = NULL;
547 short w;
548 short h;
549 Boolean fUpdate;
550 if (!PyArg_ParseTuple(_args, "hhb",
551 &w,
552 &h,
553 &fUpdate))
554 return NULL;
555 SizeWindow(_self->ob_itself,
556 w,
557 h,
558 fUpdate);
559 Py_INCREF(Py_None);
560 _res = Py_None;
561 return _res;
562}
563
564static PyObject *WinObj_ZoomWindow(_self, _args)
565 WindowObject *_self;
566 PyObject *_args;
567{
568 PyObject *_res = NULL;
569 short partCode;
570 Boolean front;
571 if (!PyArg_ParseTuple(_args, "hb",
572 &partCode,
573 &front))
574 return NULL;
575 ZoomWindow(_self->ob_itself,
576 partCode,
577 front);
578 Py_INCREF(Py_None);
579 _res = Py_None;
580 return _res;
581}
582
Guido van Rossum17448e21995-01-30 11:53:55 +0000583static PyObject *WinObj_GrowWindow(_self, _args)
584 WindowObject *_self;
585 PyObject *_args;
586{
587 PyObject *_res = NULL;
588 long _rv;
589 Point startPt;
590 Rect bBox;
591 if (!PyArg_ParseTuple(_args, "O&O&",
592 PyMac_GetPoint, &startPt,
593 PyMac_GetRect, &bBox))
594 return NULL;
595 _rv = GrowWindow(_self->ob_itself,
596 startPt,
597 &bBox);
598 _res = Py_BuildValue("l",
599 _rv);
600 return _res;
601}
602
Jack Jansen21f96871998-02-20 16:02:09 +0000603static PyObject *WinObj_DragWindow(_self, _args)
604 WindowObject *_self;
605 PyObject *_args;
606{
607 PyObject *_res = NULL;
608 Point startPt;
609 Rect boundsRect;
610 if (!PyArg_ParseTuple(_args, "O&O&",
611 PyMac_GetPoint, &startPt,
612 PyMac_GetRect, &boundsRect))
613 return NULL;
614 DragWindow(_self->ob_itself,
615 startPt,
616 &boundsRect);
617 Py_INCREF(Py_None);
618 _res = Py_None;
619 return _res;
620}
621
622static PyObject *WinObj_HideWindow(_self, _args)
623 WindowObject *_self;
624 PyObject *_args;
625{
626 PyObject *_res = NULL;
627 if (!PyArg_ParseTuple(_args, ""))
628 return NULL;
629 HideWindow(_self->ob_itself);
630 Py_INCREF(Py_None);
631 _res = Py_None;
632 return _res;
633}
634
Jack Jansen1c4e6141998-04-21 15:23:55 +0000635static PyObject *WinObj_MacShowWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +0000636 WindowObject *_self;
637 PyObject *_args;
638{
639 PyObject *_res = NULL;
640 if (!PyArg_ParseTuple(_args, ""))
641 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000642 MacShowWindow(_self->ob_itself);
Jack Jansen21f96871998-02-20 16:02:09 +0000643 Py_INCREF(Py_None);
644 _res = Py_None;
645 return _res;
646}
647
648static PyObject *WinObj_ShowHide(_self, _args)
649 WindowObject *_self;
650 PyObject *_args;
651{
652 PyObject *_res = NULL;
653 Boolean showFlag;
654 if (!PyArg_ParseTuple(_args, "b",
655 &showFlag))
656 return NULL;
657 ShowHide(_self->ob_itself,
658 showFlag);
659 Py_INCREF(Py_None);
660 _res = Py_None;
661 return _res;
662}
663
Guido van Rossum17448e21995-01-30 11:53:55 +0000664static PyObject *WinObj_TrackBox(_self, _args)
665 WindowObject *_self;
666 PyObject *_args;
667{
668 PyObject *_res = NULL;
669 Boolean _rv;
670 Point thePt;
671 short partCode;
672 if (!PyArg_ParseTuple(_args, "O&h",
673 PyMac_GetPoint, &thePt,
674 &partCode))
675 return NULL;
676 _rv = TrackBox(_self->ob_itself,
677 thePt,
678 partCode);
679 _res = Py_BuildValue("b",
680 _rv);
681 return _res;
682}
683
Guido van Rossum17448e21995-01-30 11:53:55 +0000684static PyObject *WinObj_TrackGoAway(_self, _args)
685 WindowObject *_self;
686 PyObject *_args;
687{
688 PyObject *_res = NULL;
689 Boolean _rv;
690 Point thePt;
691 if (!PyArg_ParseTuple(_args, "O&",
692 PyMac_GetPoint, &thePt))
693 return NULL;
694 _rv = TrackGoAway(_self->ob_itself,
695 thePt);
696 _res = Py_BuildValue("b",
697 _rv);
698 return _res;
699}
700
Jack Jansen8f0fab71997-08-15 14:38:05 +0000701static PyObject *WinObj_GetAuxWin(_self, _args)
702 WindowObject *_self;
703 PyObject *_args;
704{
705 PyObject *_res = NULL;
706 Boolean _rv;
707 AuxWinHandle awHndl;
708 if (!PyArg_ParseTuple(_args, ""))
709 return NULL;
710 _rv = GetAuxWin(_self->ob_itself,
711 &awHndl);
712 _res = Py_BuildValue("bO&",
713 _rv,
714 ResObj_New, awHndl);
715 return _res;
716}
717
Jack Jansenb7abb181995-11-15 15:18:47 +0000718static PyObject *WinObj_GetWindowPort(_self, _args)
719 WindowObject *_self;
720 PyObject *_args;
721{
722 PyObject *_res = NULL;
723 CGrafPtr _rv;
724 if (!PyArg_ParseTuple(_args, ""))
725 return NULL;
726 _rv = GetWindowPort(_self->ob_itself);
727 _res = Py_BuildValue("O&",
728 GrafObj_New, _rv);
729 return _res;
730}
731
Jack Jansen330f5761995-11-14 10:48:54 +0000732static PyObject *WinObj_SetPortWindowPort(_self, _args)
733 WindowObject *_self;
734 PyObject *_args;
735{
736 PyObject *_res = NULL;
737 if (!PyArg_ParseTuple(_args, ""))
738 return NULL;
739 SetPortWindowPort(_self->ob_itself);
740 Py_INCREF(Py_None);
741 _res = Py_None;
742 return _res;
743}
744
745static PyObject *WinObj_GetWindowKind(_self, _args)
746 WindowObject *_self;
747 PyObject *_args;
748{
749 PyObject *_res = NULL;
750 short _rv;
751 if (!PyArg_ParseTuple(_args, ""))
752 return NULL;
753 _rv = GetWindowKind(_self->ob_itself);
754 _res = Py_BuildValue("h",
755 _rv);
756 return _res;
757}
758
759static PyObject *WinObj_SetWindowKind(_self, _args)
760 WindowObject *_self;
761 PyObject *_args;
762{
763 PyObject *_res = NULL;
764 short wKind;
765 if (!PyArg_ParseTuple(_args, "h",
766 &wKind))
767 return NULL;
768 SetWindowKind(_self->ob_itself,
769 wKind);
770 Py_INCREF(Py_None);
771 _res = Py_None;
772 return _res;
773}
774
775static PyObject *WinObj_IsWindowVisible(_self, _args)
776 WindowObject *_self;
777 PyObject *_args;
778{
779 PyObject *_res = NULL;
780 Boolean _rv;
781 if (!PyArg_ParseTuple(_args, ""))
782 return NULL;
783 _rv = IsWindowVisible(_self->ob_itself);
784 _res = Py_BuildValue("b",
785 _rv);
786 return _res;
787}
788
789static PyObject *WinObj_IsWindowHilited(_self, _args)
790 WindowObject *_self;
791 PyObject *_args;
792{
793 PyObject *_res = NULL;
794 Boolean _rv;
795 if (!PyArg_ParseTuple(_args, ""))
796 return NULL;
797 _rv = IsWindowHilited(_self->ob_itself);
798 _res = Py_BuildValue("b",
799 _rv);
800 return _res;
801}
802
803static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
804 WindowObject *_self;
805 PyObject *_args;
806{
807 PyObject *_res = NULL;
808 Boolean _rv;
809 if (!PyArg_ParseTuple(_args, ""))
810 return NULL;
811 _rv = GetWindowGoAwayFlag(_self->ob_itself);
812 _res = Py_BuildValue("b",
813 _rv);
814 return _res;
815}
816
817static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
818 WindowObject *_self;
819 PyObject *_args;
820{
821 PyObject *_res = NULL;
822 Boolean _rv;
823 if (!PyArg_ParseTuple(_args, ""))
824 return NULL;
825 _rv = GetWindowZoomFlag(_self->ob_itself);
826 _res = Py_BuildValue("b",
827 _rv);
828 return _res;
829}
830
Jack Jansenb7abb181995-11-15 15:18:47 +0000831static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
832 WindowObject *_self;
833 PyObject *_args;
834{
835 PyObject *_res = NULL;
836 RgnHandle r;
837 if (!PyArg_ParseTuple(_args, "O&",
838 ResObj_Convert, &r))
839 return NULL;
840 GetWindowStructureRgn(_self->ob_itself,
841 r);
842 Py_INCREF(Py_None);
843 _res = Py_None;
844 return _res;
845}
846
847static PyObject *WinObj_GetWindowContentRgn(_self, _args)
848 WindowObject *_self;
849 PyObject *_args;
850{
851 PyObject *_res = NULL;
852 RgnHandle r;
853 if (!PyArg_ParseTuple(_args, "O&",
854 ResObj_Convert, &r))
855 return NULL;
856 GetWindowContentRgn(_self->ob_itself,
857 r);
858 Py_INCREF(Py_None);
859 _res = Py_None;
860 return _res;
861}
862
863static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
864 WindowObject *_self;
865 PyObject *_args;
866{
867 PyObject *_res = NULL;
868 RgnHandle r;
869 if (!PyArg_ParseTuple(_args, "O&",
870 ResObj_Convert, &r))
871 return NULL;
872 GetWindowUpdateRgn(_self->ob_itself,
873 r);
874 Py_INCREF(Py_None);
875 _res = Py_None;
876 return _res;
877}
878
Jack Jansen330f5761995-11-14 10:48:54 +0000879static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
880 WindowObject *_self;
881 PyObject *_args;
882{
883 PyObject *_res = NULL;
884 short _rv;
885 if (!PyArg_ParseTuple(_args, ""))
886 return NULL;
887 _rv = GetWindowTitleWidth(_self->ob_itself);
888 _res = Py_BuildValue("h",
889 _rv);
890 return _res;
891}
892
893static PyObject *WinObj_GetNextWindow(_self, _args)
894 WindowObject *_self;
895 PyObject *_args;
896{
897 PyObject *_res = NULL;
898 WindowPtr _rv;
899 if (!PyArg_ParseTuple(_args, ""))
900 return NULL;
901 _rv = GetNextWindow(_self->ob_itself);
902 _res = Py_BuildValue("O&",
903 WinObj_WhichWindow, _rv);
904 return _res;
905}
906
907static PyObject *WinObj_GetWindowStandardState(_self, _args)
908 WindowObject *_self;
909 PyObject *_args;
910{
911 PyObject *_res = NULL;
912 Rect r;
913 if (!PyArg_ParseTuple(_args, ""))
914 return NULL;
915 GetWindowStandardState(_self->ob_itself,
916 &r);
917 _res = Py_BuildValue("O&",
918 PyMac_BuildRect, &r);
919 return _res;
920}
921
922static PyObject *WinObj_GetWindowUserState(_self, _args)
923 WindowObject *_self;
924 PyObject *_args;
925{
926 PyObject *_res = NULL;
927 Rect r;
928 if (!PyArg_ParseTuple(_args, ""))
929 return NULL;
930 GetWindowUserState(_self->ob_itself,
931 &r);
932 _res = Py_BuildValue("O&",
933 PyMac_BuildRect, &r);
934 return _res;
935}
936
937static PyObject *WinObj_SetWindowStandardState(_self, _args)
938 WindowObject *_self;
939 PyObject *_args;
940{
941 PyObject *_res = NULL;
942 Rect r;
943 if (!PyArg_ParseTuple(_args, "O&",
944 PyMac_GetRect, &r))
945 return NULL;
946 SetWindowStandardState(_self->ob_itself,
947 &r);
948 Py_INCREF(Py_None);
949 _res = Py_None;
950 return _res;
951}
952
953static PyObject *WinObj_SetWindowUserState(_self, _args)
954 WindowObject *_self;
955 PyObject *_args;
956{
957 PyObject *_res = NULL;
958 Rect r;
959 if (!PyArg_ParseTuple(_args, "O&",
960 PyMac_GetRect, &r))
961 return NULL;
962 SetWindowUserState(_self->ob_itself,
963 &r);
964 Py_INCREF(Py_None);
965 _res = Py_None;
966 return _res;
967}
968
Jack Jansencdcbd1f1998-10-22 15:08:00 +0000969static PyObject *WinObj_GetWindowDataHandle(_self, _args)
970 WindowObject *_self;
971 PyObject *_args;
972{
973 PyObject *_res = NULL;
974 Handle _rv;
975 if (!PyArg_ParseTuple(_args, ""))
976 return NULL;
977 _rv = GetWindowDataHandle(_self->ob_itself);
978 _res = Py_BuildValue("O&",
979 ResObj_New, _rv);
980 return _res;
981}
982
983static PyObject *WinObj_SetWindowDataHandle(_self, _args)
984 WindowObject *_self;
985 PyObject *_args;
986{
987 PyObject *_res = NULL;
988 Handle data;
989 if (!PyArg_ParseTuple(_args, "O&",
990 ResObj_Convert, &data))
991 return NULL;
992 SetWindowDataHandle(_self->ob_itself,
993 data);
994 Py_INCREF(Py_None);
995 _res = Py_None;
996 return _res;
997}
998
Jack Jansene180d991998-04-24 10:28:20 +0000999static PyObject *WinObj_CloseWindow(_self, _args)
1000 WindowObject *_self;
1001 PyObject *_args;
1002{
1003 PyObject *_res = NULL;
1004 if (!PyArg_ParseTuple(_args, ""))
1005 return NULL;
1006 CloseWindow(_self->ob_itself);
1007 Py_INCREF(Py_None);
1008 _res = Py_None;
1009 return _res;
1010}
1011
1012static PyObject *WinObj_MoveWindow(_self, _args)
1013 WindowObject *_self;
1014 PyObject *_args;
1015{
1016 PyObject *_res = NULL;
1017 short hGlobal;
1018 short vGlobal;
1019 Boolean front;
1020 if (!PyArg_ParseTuple(_args, "hhb",
1021 &hGlobal,
1022 &vGlobal,
1023 &front))
1024 return NULL;
1025 MoveWindow(_self->ob_itself,
1026 hGlobal,
1027 vGlobal,
1028 front);
1029 Py_INCREF(Py_None);
1030 _res = Py_None;
1031 return _res;
1032}
1033
1034static PyObject *WinObj_ShowWindow(_self, _args)
1035 WindowObject *_self;
1036 PyObject *_args;
1037{
1038 PyObject *_res = NULL;
1039 if (!PyArg_ParseTuple(_args, ""))
1040 return NULL;
1041 ShowWindow(_self->ob_itself);
1042 Py_INCREF(Py_None);
1043 _res = Py_None;
1044 return _res;
1045}
1046
Guido van Rossum17448e21995-01-30 11:53:55 +00001047static PyMethodDef WinObj_methods[] = {
Jack Jansen1c4e6141998-04-21 15:23:55 +00001048 {"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
1049 "() -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001050 {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
1051 "(WCTabHandle newColorTable) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001052 {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
1053 "() -> None"},
1054 {"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
1055 "() -> None"},
1056 {"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
1057 "(Boolean update) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001058 {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
1059 "(RgnHandle clobberedRgn) -> None"},
1060 {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
1061 "(RgnHandle clobberedRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001062 {"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
1063 "() -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001064 {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
1065 "(RgnHandle clobberedRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001066 {"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
1067 "() -> None"},
1068 {"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
1069 "(WindowPtr behindWindow) -> None"},
1070 {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1,
1071 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001072 {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1,
1073 "(Boolean fHilite) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001074 {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1,
Jack Jansene4349e81999-03-04 22:53:24 +00001075 "() -> (UInt32 outFeatures)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001076 {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1,
Jack Jansene4349e81999-03-04 22:53:24 +00001077 "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001078 {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1,
1079 "(long data) -> None"},
1080 {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1,
1081 "() -> (long _rv)"},
1082 {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1,
1083 "(PicHandle pic) -> None"},
1084 {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1,
1085 "() -> (PicHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001086 {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1,
1087 "() -> (short _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001088 {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1,
1089 "() -> None"},
1090 {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1,
1091 "() -> None"},
1092 {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1,
1093 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001094 {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1,
1095 "(Str255 title) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001096 {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1,
1097 "() -> (Str255 title)"},
1098 {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1,
1099 "() -> (Boolean _rv)"},
1100 {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1,
1101 "() -> (Boolean _rv)"},
1102 {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1,
Jack Jansene4349e81999-03-04 22:53:24 +00001103 "(Boolean inCollapseIt) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001104 {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001105 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1106 {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1,
1107 "(short w, short h, Boolean fUpdate) -> None"},
1108 {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1,
1109 "(short partCode, Boolean front) -> None"},
1110 {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1,
1111 "(Point startPt, Rect bBox) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001112 {"DragWindow", (PyCFunction)WinObj_DragWindow, 1,
1113 "(Point startPt, Rect boundsRect) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001114 {"HideWindow", (PyCFunction)WinObj_HideWindow, 1,
1115 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001116 {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001117 "() -> None"},
1118 {"ShowHide", (PyCFunction)WinObj_ShowHide, 1,
1119 "(Boolean showFlag) -> None"},
1120 {"TrackBox", (PyCFunction)WinObj_TrackBox, 1,
1121 "(Point thePt, short partCode) -> (Boolean _rv)"},
1122 {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
1123 "(Point thePt) -> (Boolean _rv)"},
Jack Jansen8f0fab71997-08-15 14:38:05 +00001124 {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
1125 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001126 {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
1127 "() -> (CGrafPtr _rv)"},
Jack Jansen330f5761995-11-14 10:48:54 +00001128 {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
1129 "() -> None"},
1130 {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1,
1131 "() -> (short _rv)"},
1132 {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1,
1133 "(short wKind) -> None"},
1134 {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1,
1135 "() -> (Boolean _rv)"},
1136 {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1,
1137 "() -> (Boolean _rv)"},
1138 {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
1139 "() -> (Boolean _rv)"},
1140 {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
1141 "() -> (Boolean _rv)"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001142 {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
1143 "(RgnHandle r) -> None"},
1144 {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
1145 "(RgnHandle r) -> None"},
1146 {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
1147 "(RgnHandle r) -> None"},
Jack Jansen330f5761995-11-14 10:48:54 +00001148 {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
1149 "() -> (short _rv)"},
1150 {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
1151 "() -> (WindowPtr _rv)"},
1152 {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
1153 "() -> (Rect r)"},
1154 {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1,
1155 "() -> (Rect r)"},
1156 {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1,
1157 "(Rect r) -> None"},
1158 {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
1159 "(Rect r) -> None"},
Jack Jansencdcbd1f1998-10-22 15:08:00 +00001160 {"GetWindowDataHandle", (PyCFunction)WinObj_GetWindowDataHandle, 1,
1161 "() -> (Handle _rv)"},
1162 {"SetWindowDataHandle", (PyCFunction)WinObj_SetWindowDataHandle, 1,
1163 "(Handle data) -> None"},
Jack Jansene180d991998-04-24 10:28:20 +00001164 {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
1165 "() -> None"},
1166 {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
1167 "(short hGlobal, short vGlobal, Boolean front) -> None"},
1168 {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
1169 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001170 {NULL, NULL, 0}
1171};
1172
1173PyMethodChain WinObj_chain = { WinObj_methods, NULL };
1174
1175static PyObject *WinObj_getattr(self, name)
1176 WindowObject *self;
1177 char *name;
1178{
1179 return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
1180}
1181
1182#define WinObj_setattr NULL
1183
1184PyTypeObject Window_Type = {
1185 PyObject_HEAD_INIT(&PyType_Type)
1186 0, /*ob_size*/
1187 "Window", /*tp_name*/
1188 sizeof(WindowObject), /*tp_basicsize*/
1189 0, /*tp_itemsize*/
1190 /* methods */
1191 (destructor) WinObj_dealloc, /*tp_dealloc*/
1192 0, /*tp_print*/
1193 (getattrfunc) WinObj_getattr, /*tp_getattr*/
1194 (setattrfunc) WinObj_setattr, /*tp_setattr*/
1195};
1196
1197/* --------------------- End object type Window --------------------- */
1198
1199
Jack Jansen21f96871998-02-20 16:02:09 +00001200static PyObject *Win_GetNewCWindow(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001201 PyObject *_self;
1202 PyObject *_args;
1203{
1204 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001205 WindowPtr _rv;
1206 short windowID;
1207 WindowPtr behind;
1208 if (!PyArg_ParseTuple(_args, "hO&",
1209 &windowID,
1210 WinObj_Convert, &behind))
Jack Jansenb7abb181995-11-15 15:18:47 +00001211 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001212 _rv = GetNewCWindow(windowID,
1213 (void *)0,
1214 behind);
Jack Jansenb7abb181995-11-15 15:18:47 +00001215 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001216 WinObj_New, _rv);
Jack Jansenb7abb181995-11-15 15:18:47 +00001217 return _res;
1218}
1219
Guido van Rossum17448e21995-01-30 11:53:55 +00001220static PyObject *Win_NewWindow(_self, _args)
1221 PyObject *_self;
1222 PyObject *_args;
1223{
1224 PyObject *_res = NULL;
1225 WindowPtr _rv;
1226 Rect boundsRect;
1227 Str255 title;
1228 Boolean visible;
1229 short theProc;
1230 WindowPtr behind;
1231 Boolean goAwayFlag;
1232 long refCon;
1233 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1234 PyMac_GetRect, &boundsRect,
1235 PyMac_GetStr255, title,
1236 &visible,
1237 &theProc,
1238 WinObj_Convert, &behind,
1239 &goAwayFlag,
1240 &refCon))
1241 return NULL;
1242 _rv = NewWindow((void *)0,
1243 &boundsRect,
1244 title,
1245 visible,
1246 theProc,
1247 behind,
1248 goAwayFlag,
1249 refCon);
1250 _res = Py_BuildValue("O&",
1251 WinObj_New, _rv);
1252 return _res;
1253}
1254
1255static PyObject *Win_GetNewWindow(_self, _args)
1256 PyObject *_self;
1257 PyObject *_args;
1258{
1259 PyObject *_res = NULL;
1260 WindowPtr _rv;
1261 short windowID;
1262 WindowPtr behind;
1263 if (!PyArg_ParseTuple(_args, "hO&",
1264 &windowID,
1265 WinObj_Convert, &behind))
1266 return NULL;
1267 _rv = GetNewWindow(windowID,
1268 (void *)0,
1269 behind);
1270 _res = Py_BuildValue("O&",
1271 WinObj_New, _rv);
1272 return _res;
1273}
1274
Jack Jansen21f96871998-02-20 16:02:09 +00001275static PyObject *Win_NewCWindow(_self, _args)
1276 PyObject *_self;
1277 PyObject *_args;
1278{
1279 PyObject *_res = NULL;
1280 WindowPtr _rv;
1281 Rect boundsRect;
1282 Str255 title;
1283 Boolean visible;
1284 short procID;
1285 WindowPtr behind;
1286 Boolean goAwayFlag;
1287 long refCon;
1288 if (!PyArg_ParseTuple(_args, "O&O&bhO&bl",
1289 PyMac_GetRect, &boundsRect,
1290 PyMac_GetStr255, title,
1291 &visible,
1292 &procID,
1293 WinObj_Convert, &behind,
1294 &goAwayFlag,
1295 &refCon))
1296 return NULL;
1297 _rv = NewCWindow((void *)0,
1298 &boundsRect,
1299 title,
1300 visible,
1301 procID,
1302 behind,
1303 goAwayFlag,
1304 refCon);
1305 _res = Py_BuildValue("O&",
1306 WinObj_New, _rv);
1307 return _res;
1308}
1309
1310static PyObject *Win_SetDeskCPat(_self, _args)
1311 PyObject *_self;
1312 PyObject *_args;
1313{
1314 PyObject *_res = NULL;
1315 PixPatHandle deskPixPat;
1316 if (!PyArg_ParseTuple(_args, "O&",
1317 ResObj_Convert, &deskPixPat))
1318 return NULL;
1319 SetDeskCPat(deskPixPat);
1320 Py_INCREF(Py_None);
1321 _res = Py_None;
1322 return _res;
1323}
1324
1325static PyObject *Win_CheckUpdate(_self, _args)
1326 PyObject *_self;
1327 PyObject *_args;
1328{
1329 PyObject *_res = NULL;
1330 Boolean _rv;
1331 EventRecord theEvent;
1332 if (!PyArg_ParseTuple(_args, ""))
1333 return NULL;
1334 _rv = CheckUpdate(&theEvent);
1335 _res = Py_BuildValue("bO&",
1336 _rv,
1337 PyMac_BuildEventRecord, &theEvent);
1338 return _res;
1339}
1340
Jack Jansen1c4e6141998-04-21 15:23:55 +00001341static PyObject *Win_MacFindWindow(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001342 PyObject *_self;
1343 PyObject *_args;
1344{
1345 PyObject *_res = NULL;
1346 short _rv;
1347 Point thePoint;
1348 WindowPtr theWindow;
1349 if (!PyArg_ParseTuple(_args, "O&",
1350 PyMac_GetPoint, &thePoint))
1351 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001352 _rv = MacFindWindow(thePoint,
1353 &theWindow);
Jack Jansen21f96871998-02-20 16:02:09 +00001354 _res = Py_BuildValue("hO&",
1355 _rv,
1356 WinObj_WhichWindow, theWindow);
1357 return _res;
1358}
1359
Guido van Rossum17448e21995-01-30 11:53:55 +00001360static PyObject *Win_FrontWindow(_self, _args)
1361 PyObject *_self;
1362 PyObject *_args;
1363{
1364 PyObject *_res = NULL;
1365 WindowPtr _rv;
1366 if (!PyArg_ParseTuple(_args, ""))
1367 return NULL;
1368 _rv = FrontWindow();
1369 _res = Py_BuildValue("O&",
Guido van Rossumea39abd1995-02-28 09:49:02 +00001370 WinObj_WhichWindow, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001371 return _res;
1372}
1373
Jack Jansen21f96871998-02-20 16:02:09 +00001374static PyObject *Win_InitWindows(_self, _args)
1375 PyObject *_self;
1376 PyObject *_args;
1377{
1378 PyObject *_res = NULL;
1379 if (!PyArg_ParseTuple(_args, ""))
1380 return NULL;
1381 InitWindows();
1382 Py_INCREF(Py_None);
1383 _res = Py_None;
1384 return _res;
1385}
1386
1387static PyObject *Win_GetWMgrPort(_self, _args)
1388 PyObject *_self;
1389 PyObject *_args;
1390{
1391 PyObject *_res = NULL;
1392 GrafPtr wPort;
1393 if (!PyArg_ParseTuple(_args, ""))
1394 return NULL;
1395 GetWMgrPort(&wPort);
1396 _res = Py_BuildValue("O&",
1397 GrafObj_New, wPort);
1398 return _res;
1399}
1400
1401static PyObject *Win_GetCWMgrPort(_self, _args)
1402 PyObject *_self;
1403 PyObject *_args;
1404{
1405 PyObject *_res = NULL;
1406 CGrafPtr wMgrCPort;
1407 if (!PyArg_ParseTuple(_args, ""))
1408 return NULL;
1409 GetCWMgrPort(&wMgrCPort);
1410 _res = Py_BuildValue("O&",
1411 GrafObj_New, wMgrCPort);
1412 return _res;
1413}
1414
Guido van Rossum17448e21995-01-30 11:53:55 +00001415static PyObject *Win_InvalRect(_self, _args)
1416 PyObject *_self;
1417 PyObject *_args;
1418{
1419 PyObject *_res = NULL;
1420 Rect badRect;
1421 if (!PyArg_ParseTuple(_args, "O&",
1422 PyMac_GetRect, &badRect))
1423 return NULL;
1424 InvalRect(&badRect);
1425 Py_INCREF(Py_None);
1426 _res = Py_None;
1427 return _res;
1428}
1429
Jack Jansenb7abb181995-11-15 15:18:47 +00001430static PyObject *Win_InvalRgn(_self, _args)
1431 PyObject *_self;
1432 PyObject *_args;
1433{
1434 PyObject *_res = NULL;
1435 RgnHandle badRgn;
1436 if (!PyArg_ParseTuple(_args, "O&",
1437 ResObj_Convert, &badRgn))
1438 return NULL;
1439 InvalRgn(badRgn);
1440 Py_INCREF(Py_None);
1441 _res = Py_None;
1442 return _res;
1443}
1444
Guido van Rossum17448e21995-01-30 11:53:55 +00001445static PyObject *Win_ValidRect(_self, _args)
1446 PyObject *_self;
1447 PyObject *_args;
1448{
1449 PyObject *_res = NULL;
1450 Rect goodRect;
1451 if (!PyArg_ParseTuple(_args, "O&",
1452 PyMac_GetRect, &goodRect))
1453 return NULL;
1454 ValidRect(&goodRect);
1455 Py_INCREF(Py_None);
1456 _res = Py_None;
1457 return _res;
1458}
1459
Jack Jansenb7abb181995-11-15 15:18:47 +00001460static PyObject *Win_ValidRgn(_self, _args)
1461 PyObject *_self;
1462 PyObject *_args;
1463{
1464 PyObject *_res = NULL;
1465 RgnHandle goodRgn;
1466 if (!PyArg_ParseTuple(_args, "O&",
1467 ResObj_Convert, &goodRgn))
1468 return NULL;
1469 ValidRgn(goodRgn);
1470 Py_INCREF(Py_None);
1471 _res = Py_None;
1472 return _res;
1473}
1474
Jack Jansen21f96871998-02-20 16:02:09 +00001475static PyObject *Win_CollapseAllWindows(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001476 PyObject *_self;
1477 PyObject *_args;
1478{
1479 PyObject *_res = NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00001480 OSStatus _err;
Jack Jansen21f96871998-02-20 16:02:09 +00001481 Boolean inCollapseEm;
1482 if (!PyArg_ParseTuple(_args, "b",
1483 &inCollapseEm))
Guido van Rossum17448e21995-01-30 11:53:55 +00001484 return NULL;
Jack Jansene4349e81999-03-04 22:53:24 +00001485 _err = CollapseAllWindows(inCollapseEm);
1486 if (_err != noErr) return PyMac_Error(_err);
1487 Py_INCREF(Py_None);
1488 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +00001489 return _res;
1490}
1491
1492static PyObject *Win_PinRect(_self, _args)
1493 PyObject *_self;
1494 PyObject *_args;
1495{
1496 PyObject *_res = NULL;
1497 long _rv;
1498 Rect theRect;
1499 Point thePt;
1500 if (!PyArg_ParseTuple(_args, "O&O&",
1501 PyMac_GetRect, &theRect,
1502 PyMac_GetPoint, &thePt))
1503 return NULL;
1504 _rv = PinRect(&theRect,
1505 thePt);
1506 _res = Py_BuildValue("l",
1507 _rv);
1508 return _res;
1509}
1510
Jack Jansen21f96871998-02-20 16:02:09 +00001511static PyObject *Win_GetGrayRgn(_self, _args)
Jack Jansenb7abb181995-11-15 15:18:47 +00001512 PyObject *_self;
1513 PyObject *_args;
1514{
1515 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001516 RgnHandle _rv;
Jack Jansenb7abb181995-11-15 15:18:47 +00001517 if (!PyArg_ParseTuple(_args, ""))
1518 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001519 _rv = GetGrayRgn();
Jack Jansenb7abb181995-11-15 15:18:47 +00001520 _res = Py_BuildValue("O&",
Jack Jansen21f96871998-02-20 16:02:09 +00001521 ResObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001522 return _res;
1523}
1524
Jack Jansend4c26461995-08-17 14:35:56 +00001525static PyObject *Win_WhichWindow(_self, _args)
1526 PyObject *_self;
1527 PyObject *_args;
1528{
1529 PyObject *_res = NULL;
1530
1531 long ptr;
1532
1533 if ( !PyArg_ParseTuple(_args, "i", &ptr) )
1534 return NULL;
1535 return WinObj_WhichWindow((WindowPtr)ptr);
1536
1537}
1538
Jack Jansene180d991998-04-24 10:28:20 +00001539static PyObject *Win_FindWindow(_self, _args)
1540 PyObject *_self;
1541 PyObject *_args;
1542{
1543 PyObject *_res = NULL;
1544 short _rv;
1545 Point thePoint;
1546 WindowPtr theWindow;
1547 if (!PyArg_ParseTuple(_args, "O&",
1548 PyMac_GetPoint, &thePoint))
1549 return NULL;
1550 _rv = FindWindow(thePoint,
1551 &theWindow);
1552 _res = Py_BuildValue("hO&",
1553 _rv,
1554 WinObj_WhichWindow, theWindow);
1555 return _res;
1556}
1557
Guido van Rossum17448e21995-01-30 11:53:55 +00001558static PyMethodDef Win_methods[] = {
Jack Jansen21f96871998-02-20 16:02:09 +00001559 {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1,
1560 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001561 {"NewWindow", (PyCFunction)Win_NewWindow, 1,
1562 "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1563 {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1,
1564 "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001565 {"NewCWindow", (PyCFunction)Win_NewCWindow, 1,
1566 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"},
1567 {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
1568 "(PixPatHandle deskPixPat) -> None"},
1569 {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
1570 "() -> (Boolean _rv, EventRecord theEvent)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001571 {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001572 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001573 {"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
1574 "() -> (WindowPtr _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001575 {"InitWindows", (PyCFunction)Win_InitWindows, 1,
1576 "() -> None"},
1577 {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
1578 "() -> (GrafPtr wPort)"},
1579 {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
1580 "() -> (CGrafPtr wMgrCPort)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001581 {"InvalRect", (PyCFunction)Win_InvalRect, 1,
1582 "(Rect badRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001583 {"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
1584 "(RgnHandle badRgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001585 {"ValidRect", (PyCFunction)Win_ValidRect, 1,
1586 "(Rect goodRect) -> None"},
Jack Jansenb7abb181995-11-15 15:18:47 +00001587 {"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
1588 "(RgnHandle goodRgn) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001589 {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
Jack Jansene4349e81999-03-04 22:53:24 +00001590 "(Boolean inCollapseEm) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001591 {"PinRect", (PyCFunction)Win_PinRect, 1,
1592 "(Rect theRect, Point thePt) -> (long _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001593 {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1,
1594 "() -> (RgnHandle _rv)"},
Jack Jansend4c26461995-08-17 14:35:56 +00001595 {"WhichWindow", (PyCFunction)Win_WhichWindow, 1,
1596 "Resolve an integer WindowPtr address to a Window object"},
Jack Jansene180d991998-04-24 10:28:20 +00001597 {"FindWindow", (PyCFunction)Win_FindWindow, 1,
1598 "(Point thePoint) -> (short _rv, WindowPtr theWindow)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001599 {NULL, NULL, 0}
1600};
1601
1602
1603
1604/* Return the object corresponding to the window, or NULL */
1605
1606PyObject *
1607WinObj_WhichWindow(w)
1608 WindowPtr w;
1609{
1610 PyObject *it;
1611
1612 /* XXX What if we find a stdwin window or a window belonging
1613 to some other package? */
Guido van Rossum97842951995-02-19 15:59:49 +00001614 if (w == NULL)
1615 it = NULL;
1616 else
1617 it = (PyObject *) GetWRefCon(w);
Guido van Rossum17448e21995-01-30 11:53:55 +00001618 if (it == NULL || ((WindowObject *)it)->ob_itself != w)
1619 it = Py_None;
1620 Py_INCREF(it);
1621 return it;
1622}
1623
1624
1625void initWin()
1626{
1627 PyObject *m;
1628 PyObject *d;
1629
1630
1631
1632
1633 m = Py_InitModule("Win", Win_methods);
1634 d = PyModule_GetDict(m);
1635 Win_Error = PyMac_GetOSErrException();
1636 if (Win_Error == NULL ||
1637 PyDict_SetItemString(d, "Error", Win_Error) != 0)
1638 Py_FatalError("can't initialize Win.Error");
Jack Jansena755e681997-09-20 17:40:22 +00001639 Window_Type.ob_type = &PyType_Type;
1640 Py_INCREF(&Window_Type);
1641 if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
1642 Py_FatalError("can't initialize WindowType");
Guido van Rossum17448e21995-01-30 11:53:55 +00001643}
1644
1645/* ========================= End module Win ========================= */
1646