blob: 2abd785f731ae6aa1a29221f23595cc6a6b2857b [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Dlg =========================== */
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 Jansen425e9eb1995-12-12 15:02:03 +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 Jansen425e9eb1995-12-12 15:02:03 +000037extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
40extern 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 <Dialogs.h>
46
Guido van Rossum97842951995-02-19 15:59:49 +000047#ifndef HAVE_UNIVERSAL_HEADERS
48#define NewModalFilterProc(x) (x)
49#endif
50
Guido van Rossum17448e21995-01-30 11:53:55 +000051#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
52
53/* XXX Shouldn't this be a stack? */
54static PyObject *Dlg_FilterProc_callback = NULL;
55
56static PyObject *DlgObj_New(DialogPtr); /* Forward */
57
58static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
59 EventRecord *event,
60 short *itemHit)
61{
62 Boolean rv;
63 PyObject *args, *res;
64 PyObject *callback = Dlg_FilterProc_callback;
65 if (callback == NULL)
66 return 0; /* Default behavior */
67 Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
Guido van Rossum0437e891995-02-21 20:56:21 +000068 args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
Guido van Rossum17448e21995-01-30 11:53:55 +000069 if (args == NULL)
70 res = NULL;
71 else {
72 res = PyEval_CallObject(callback, args);
73 Py_DECREF(args);
74 }
75 if (res == NULL) {
Jack Jansendeff89c1998-10-12 20:53:15 +000076 PySys_WriteStderr("Exception in Dialog Filter\n");
Guido van Rossum17448e21995-01-30 11:53:55 +000077 PyErr_Print();
78 *itemHit = -1; /* Fake return item */
79 return 1; /* We handled it */
80 }
81 else {
82 Dlg_FilterProc_callback = callback;
83 if (PyInt_Check(res)) {
84 *itemHit = PyInt_AsLong(res);
85 rv = 1;
86 }
87 else
88 rv = PyObject_IsTrue(res);
89 }
90 Py_DECREF(res);
91 return rv;
92}
93
94static ModalFilterProcPtr
95Dlg_PassFilterProc(PyObject *callback)
96{
97 PyObject *tmp = Dlg_FilterProc_callback;
98 Dlg_FilterProc_callback = NULL;
99 if (callback == Py_None) {
100 Py_XDECREF(tmp);
101 return NULL;
102 }
103 Py_INCREF(callback);
104 Dlg_FilterProc_callback = callback;
105 Py_XDECREF(tmp);
106 return &Dlg_UnivFilterProc;
107}
108
Jack Jansendf901df1998-07-10 15:47:48 +0000109static PyObject *Dlg_UserItemProc_callback = NULL;
110
111static pascal void Dlg_UnivUserItemProc(DialogPtr dialog,
112 short item)
113{
114 PyObject *args, *res;
115
116 if (Dlg_UserItemProc_callback == NULL)
117 return; /* Default behavior */
118 Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
119 args = Py_BuildValue("O&h", WinObj_WhichWindow, dialog, item);
120 if (args == NULL)
121 res = NULL;
122 else {
123 res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
124 Py_DECREF(args);
125 }
126 if (res == NULL) {
Jack Jansendeff89c1998-10-12 20:53:15 +0000127 PySys_WriteStderr("Exception in Dialog UserItem proc\n");
Jack Jansendf901df1998-07-10 15:47:48 +0000128 PyErr_Print();
129 }
130 Py_XDECREF(res);
131 return;
132}
133
Guido van Rossum17448e21995-01-30 11:53:55 +0000134extern PyMethodChain WinObj_chain;
135
136static PyObject *Dlg_Error;
137
138/* ----------------------- Object type Dialog ----------------------- */
139
140PyTypeObject Dialog_Type;
141
142#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
143
144typedef struct DialogObject {
145 PyObject_HEAD
146 DialogPtr ob_itself;
147} DialogObject;
148
149PyObject *DlgObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +0000150 DialogPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +0000151{
152 DialogObject *it;
153 if (itself == NULL) return Py_None;
154 it = PyObject_NEW(DialogObject, &Dialog_Type);
155 if (it == NULL) return NULL;
156 it->ob_itself = itself;
157 SetWRefCon(itself, (long)it);
158 return (PyObject *)it;
159}
160DlgObj_Convert(v, p_itself)
161 PyObject *v;
162 DialogPtr *p_itself;
163{
164 if (v == Py_None) { *p_itself = NULL; return 1; }
165 if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);
166 return 1; }
167 if (!DlgObj_Check(v))
168 {
169 PyErr_SetString(PyExc_TypeError, "Dialog required");
170 return 0;
171 }
172 *p_itself = ((DialogObject *)v)->ob_itself;
173 return 1;
174}
175
176static void DlgObj_dealloc(self)
177 DialogObject *self;
178{
179 DisposeDialog(self->ob_itself);
180 PyMem_DEL(self);
181}
182
183static PyObject *DlgObj_DrawDialog(_self, _args)
184 DialogObject *_self;
185 PyObject *_args;
186{
187 PyObject *_res = NULL;
188 if (!PyArg_ParseTuple(_args, ""))
189 return NULL;
190 DrawDialog(_self->ob_itself);
191 Py_INCREF(Py_None);
192 _res = Py_None;
193 return _res;
194}
195
Guido van Rossum17448e21995-01-30 11:53:55 +0000196static PyObject *DlgObj_UpdateDialog(_self, _args)
197 DialogObject *_self;
198 PyObject *_args;
199{
200 PyObject *_res = NULL;
Jack Jansen2b724171996-04-10 14:48:19 +0000201 RgnHandle updateRgn;
202 if (!PyArg_ParseTuple(_args, "O&",
203 ResObj_Convert, &updateRgn))
Guido van Rossum17448e21995-01-30 11:53:55 +0000204 return NULL;
205 UpdateDialog(_self->ob_itself,
Jack Jansen2b724171996-04-10 14:48:19 +0000206 updateRgn);
Guido van Rossum17448e21995-01-30 11:53:55 +0000207 Py_INCREF(Py_None);
208 _res = Py_None;
209 return _res;
210}
211
Jack Jansenae8a68f1995-06-06 12:55:40 +0000212static PyObject *DlgObj_HideDialogItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000213 DialogObject *_self;
214 PyObject *_args;
215{
216 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000217 DialogItemIndex itemNo;
Guido van Rossum17448e21995-01-30 11:53:55 +0000218 if (!PyArg_ParseTuple(_args, "h",
219 &itemNo))
220 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000221 HideDialogItem(_self->ob_itself,
222 itemNo);
Guido van Rossum17448e21995-01-30 11:53:55 +0000223 Py_INCREF(Py_None);
224 _res = Py_None;
225 return _res;
226}
227
Jack Jansenae8a68f1995-06-06 12:55:40 +0000228static PyObject *DlgObj_ShowDialogItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000229 DialogObject *_self;
230 PyObject *_args;
231{
232 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000233 DialogItemIndex itemNo;
Guido van Rossum17448e21995-01-30 11:53:55 +0000234 if (!PyArg_ParseTuple(_args, "h",
235 &itemNo))
236 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000237 ShowDialogItem(_self->ob_itself,
238 itemNo);
Guido van Rossum17448e21995-01-30 11:53:55 +0000239 Py_INCREF(Py_None);
240 _res = Py_None;
241 return _res;
242}
243
Jack Jansenae8a68f1995-06-06 12:55:40 +0000244static PyObject *DlgObj_FindDialogItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000245 DialogObject *_self;
246 PyObject *_args;
247{
248 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000249 DialogItemIndexZeroBased _rv;
Guido van Rossum17448e21995-01-30 11:53:55 +0000250 Point thePt;
251 if (!PyArg_ParseTuple(_args, "O&",
252 PyMac_GetPoint, &thePt))
253 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000254 _rv = FindDialogItem(_self->ob_itself,
255 thePt);
Guido van Rossum17448e21995-01-30 11:53:55 +0000256 _res = Py_BuildValue("h",
257 _rv);
258 return _res;
259}
260
Jack Jansenae8a68f1995-06-06 12:55:40 +0000261static PyObject *DlgObj_DialogCut(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000262 DialogObject *_self;
263 PyObject *_args;
264{
265 PyObject *_res = NULL;
266 if (!PyArg_ParseTuple(_args, ""))
267 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000268 DialogCut(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000269 Py_INCREF(Py_None);
270 _res = Py_None;
271 return _res;
272}
273
Jack Jansenae8a68f1995-06-06 12:55:40 +0000274static PyObject *DlgObj_DialogPaste(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000275 DialogObject *_self;
276 PyObject *_args;
277{
278 PyObject *_res = NULL;
279 if (!PyArg_ParseTuple(_args, ""))
280 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000281 DialogPaste(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000282 Py_INCREF(Py_None);
283 _res = Py_None;
284 return _res;
285}
286
Jack Jansenae8a68f1995-06-06 12:55:40 +0000287static PyObject *DlgObj_DialogCopy(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000288 DialogObject *_self;
289 PyObject *_args;
290{
291 PyObject *_res = NULL;
292 if (!PyArg_ParseTuple(_args, ""))
293 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000294 DialogCopy(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000295 Py_INCREF(Py_None);
296 _res = Py_None;
297 return _res;
298}
299
Jack Jansenae8a68f1995-06-06 12:55:40 +0000300static PyObject *DlgObj_DialogDelete(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000301 DialogObject *_self;
302 PyObject *_args;
303{
304 PyObject *_res = NULL;
305 if (!PyArg_ParseTuple(_args, ""))
306 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000307 DialogDelete(_self->ob_itself);
Guido van Rossum17448e21995-01-30 11:53:55 +0000308 Py_INCREF(Py_None);
309 _res = Py_None;
310 return _res;
311}
312
Jack Jansen21f96871998-02-20 16:02:09 +0000313static PyObject *DlgObj_GetDialogItem(_self, _args)
314 DialogObject *_self;
315 PyObject *_args;
316{
317 PyObject *_res = NULL;
318 DialogItemIndex itemNo;
319 DialogItemType itemType;
320 Handle item;
321 Rect box;
322 if (!PyArg_ParseTuple(_args, "h",
323 &itemNo))
324 return NULL;
325 GetDialogItem(_self->ob_itself,
326 itemNo,
327 &itemType,
328 &item,
329 &box);
330 _res = Py_BuildValue("hO&O&",
331 itemType,
332 OptResObj_New, item,
333 PyMac_BuildRect, &box);
334 return _res;
335}
336
337static PyObject *DlgObj_SetDialogItem(_self, _args)
338 DialogObject *_self;
339 PyObject *_args;
340{
341 PyObject *_res = NULL;
342 DialogItemIndex itemNo;
343 DialogItemType itemType;
344 Handle item;
345 Rect box;
346 if (!PyArg_ParseTuple(_args, "hhO&O&",
347 &itemNo,
348 &itemType,
349 ResObj_Convert, &item,
350 PyMac_GetRect, &box))
351 return NULL;
352 SetDialogItem(_self->ob_itself,
353 itemNo,
354 itemType,
355 item,
356 &box);
357 Py_INCREF(Py_None);
358 _res = Py_None;
359 return _res;
360}
361
362static PyObject *DlgObj_SelectDialogItemText(_self, _args)
363 DialogObject *_self;
364 PyObject *_args;
365{
366 PyObject *_res = NULL;
367 DialogItemIndex itemNo;
368 SInt16 strtSel;
369 SInt16 endSel;
370 if (!PyArg_ParseTuple(_args, "hhh",
371 &itemNo,
372 &strtSel,
373 &endSel))
374 return NULL;
375 SelectDialogItemText(_self->ob_itself,
376 itemNo,
377 strtSel,
378 endSel);
379 Py_INCREF(Py_None);
380 _res = Py_None;
381 return _res;
382}
383
Guido van Rossum17448e21995-01-30 11:53:55 +0000384static PyObject *DlgObj_AppendDITL(_self, _args)
385 DialogObject *_self;
386 PyObject *_args;
387{
388 PyObject *_res = NULL;
389 Handle theHandle;
390 DITLMethod method;
391 if (!PyArg_ParseTuple(_args, "O&h",
392 ResObj_Convert, &theHandle,
393 &method))
394 return NULL;
395 AppendDITL(_self->ob_itself,
396 theHandle,
397 method);
398 Py_INCREF(Py_None);
399 _res = Py_None;
400 return _res;
401}
402
403static PyObject *DlgObj_CountDITL(_self, _args)
404 DialogObject *_self;
405 PyObject *_args;
406{
407 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000408 DialogItemIndex _rv;
Guido van Rossum17448e21995-01-30 11:53:55 +0000409 if (!PyArg_ParseTuple(_args, ""))
410 return NULL;
411 _rv = CountDITL(_self->ob_itself);
412 _res = Py_BuildValue("h",
413 _rv);
414 return _res;
415}
416
417static PyObject *DlgObj_ShortenDITL(_self, _args)
418 DialogObject *_self;
419 PyObject *_args;
420{
421 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000422 DialogItemIndex numberItems;
Guido van Rossum17448e21995-01-30 11:53:55 +0000423 if (!PyArg_ParseTuple(_args, "h",
424 &numberItems))
425 return NULL;
426 ShortenDITL(_self->ob_itself,
427 numberItems);
428 Py_INCREF(Py_None);
429 _res = Py_None;
430 return _res;
431}
432
Jack Jansenae8a68f1995-06-06 12:55:40 +0000433static PyObject *DlgObj_StdFilterProc(_self, _args)
434 DialogObject *_self;
435 PyObject *_args;
436{
437 PyObject *_res = NULL;
438 Boolean _rv;
439 EventRecord event;
Jack Jansen21f96871998-02-20 16:02:09 +0000440 DialogItemIndex itemHit;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000441 if (!PyArg_ParseTuple(_args, ""))
442 return NULL;
443 _rv = StdFilterProc(_self->ob_itself,
444 &event,
445 &itemHit);
446 _res = Py_BuildValue("bO&h",
447 _rv,
448 PyMac_BuildEventRecord, &event,
449 itemHit);
450 return _res;
451}
452
453static PyObject *DlgObj_SetDialogDefaultItem(_self, _args)
454 DialogObject *_self;
455 PyObject *_args;
456{
457 PyObject *_res = NULL;
458 OSErr _err;
Jack Jansen21f96871998-02-20 16:02:09 +0000459 DialogItemIndex newItem;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000460 if (!PyArg_ParseTuple(_args, "h",
461 &newItem))
462 return NULL;
463 _err = SetDialogDefaultItem(_self->ob_itself,
464 newItem);
465 if (_err != noErr) return PyMac_Error(_err);
466 Py_INCREF(Py_None);
467 _res = Py_None;
468 return _res;
469}
470
471static PyObject *DlgObj_SetDialogCancelItem(_self, _args)
472 DialogObject *_self;
473 PyObject *_args;
474{
475 PyObject *_res = NULL;
476 OSErr _err;
Jack Jansen21f96871998-02-20 16:02:09 +0000477 DialogItemIndex newItem;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000478 if (!PyArg_ParseTuple(_args, "h",
479 &newItem))
480 return NULL;
481 _err = SetDialogCancelItem(_self->ob_itself,
482 newItem);
483 if (_err != noErr) return PyMac_Error(_err);
484 Py_INCREF(Py_None);
485 _res = Py_None;
486 return _res;
487}
488
489static PyObject *DlgObj_SetDialogTracksCursor(_self, _args)
490 DialogObject *_self;
491 PyObject *_args;
492{
493 PyObject *_res = NULL;
494 OSErr _err;
495 Boolean tracks;
496 if (!PyArg_ParseTuple(_args, "b",
497 &tracks))
498 return NULL;
499 _err = SetDialogTracksCursor(_self->ob_itself,
500 tracks);
501 if (_err != noErr) return PyMac_Error(_err);
502 Py_INCREF(Py_None);
503 _res = Py_None;
504 return _res;
505}
506
Jack Jansen21f96871998-02-20 16:02:09 +0000507static PyObject *DlgObj_AutoSizeDialog(_self, _args)
508 DialogObject *_self;
509 PyObject *_args;
510{
511 PyObject *_res = NULL;
512 OSErr _err;
513 if (!PyArg_ParseTuple(_args, ""))
514 return NULL;
515 _err = AutoSizeDialog(_self->ob_itself);
516 if (_err != noErr) return PyMac_Error(_err);
517 Py_INCREF(Py_None);
518 _res = Py_None;
519 return _res;
520}
521
522static PyObject *DlgObj_GetDialogItemAsControl(_self, _args)
523 DialogObject *_self;
524 PyObject *_args;
525{
526 PyObject *_res = NULL;
527 OSErr _err;
528 SInt16 inItemNo;
529 ControlHandle outControl;
530 if (!PyArg_ParseTuple(_args, "h",
531 &inItemNo))
532 return NULL;
533 _err = GetDialogItemAsControl(_self->ob_itself,
534 inItemNo,
535 &outControl);
536 if (_err != noErr) return PyMac_Error(_err);
537 _res = Py_BuildValue("O&",
538 CtlObj_New, outControl);
539 return _res;
540}
541
542static PyObject *DlgObj_MoveDialogItem(_self, _args)
543 DialogObject *_self;
544 PyObject *_args;
545{
546 PyObject *_res = NULL;
547 OSErr _err;
548 SInt16 inItemNo;
549 SInt16 inHoriz;
550 SInt16 inVert;
551 if (!PyArg_ParseTuple(_args, "hhh",
552 &inItemNo,
553 &inHoriz,
554 &inVert))
555 return NULL;
556 _err = MoveDialogItem(_self->ob_itself,
557 inItemNo,
558 inHoriz,
559 inVert);
560 if (_err != noErr) return PyMac_Error(_err);
561 Py_INCREF(Py_None);
562 _res = Py_None;
563 return _res;
564}
565
566static PyObject *DlgObj_SizeDialogItem(_self, _args)
567 DialogObject *_self;
568 PyObject *_args;
569{
570 PyObject *_res = NULL;
571 OSErr _err;
572 SInt16 inItemNo;
Jack Jansen21f96871998-02-20 16:02:09 +0000573 SInt16 inWidth;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000574 SInt16 inHeight;
Jack Jansen21f96871998-02-20 16:02:09 +0000575 if (!PyArg_ParseTuple(_args, "hhh",
576 &inItemNo,
Jack Jansen1c4e6141998-04-21 15:23:55 +0000577 &inWidth,
578 &inHeight))
Jack Jansen21f96871998-02-20 16:02:09 +0000579 return NULL;
580 _err = SizeDialogItem(_self->ob_itself,
581 inItemNo,
Jack Jansen1c4e6141998-04-21 15:23:55 +0000582 inWidth,
583 inHeight);
Jack Jansen21f96871998-02-20 16:02:09 +0000584 if (_err != noErr) return PyMac_Error(_err);
585 Py_INCREF(Py_None);
586 _res = Py_None;
587 return _res;
588}
589
Jack Jansend96cb501996-09-23 15:48:46 +0000590static PyObject *DlgObj_GetDialogWindow(_self, _args)
591 DialogObject *_self;
592 PyObject *_args;
593{
594 PyObject *_res = NULL;
595 DialogPtr _rv;
596 if (!PyArg_ParseTuple(_args, ""))
597 return NULL;
598 _rv = GetDialogWindow(_self->ob_itself);
599 _res = Py_BuildValue("O&",
600 WinObj_WhichWindow, _rv);
601 return _res;
602}
603
604static PyObject *DlgObj_GetDialogDefaultItem(_self, _args)
605 DialogObject *_self;
606 PyObject *_args;
607{
608 PyObject *_res = NULL;
609 SInt16 _rv;
610 if (!PyArg_ParseTuple(_args, ""))
611 return NULL;
612 _rv = GetDialogDefaultItem(_self->ob_itself);
613 _res = Py_BuildValue("h",
614 _rv);
615 return _res;
616}
617
618static PyObject *DlgObj_GetDialogCancelItem(_self, _args)
619 DialogObject *_self;
620 PyObject *_args;
621{
622 PyObject *_res = NULL;
623 SInt16 _rv;
624 if (!PyArg_ParseTuple(_args, ""))
625 return NULL;
626 _rv = GetDialogCancelItem(_self->ob_itself);
627 _res = Py_BuildValue("h",
628 _rv);
629 return _res;
630}
631
632static PyObject *DlgObj_GetDialogKeyboardFocusItem(_self, _args)
633 DialogObject *_self;
634 PyObject *_args;
635{
636 PyObject *_res = NULL;
637 SInt16 _rv;
638 if (!PyArg_ParseTuple(_args, ""))
639 return NULL;
640 _rv = GetDialogKeyboardFocusItem(_self->ob_itself);
641 _res = Py_BuildValue("h",
642 _rv);
643 return _res;
644}
645
646static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args)
647 DialogObject *_self;
648 PyObject *_args;
649{
650 PyObject *_res = NULL;
651 if (!PyArg_ParseTuple(_args, ""))
652 return NULL;
653 SetGrafPortOfDialog(_self->ob_itself);
654 Py_INCREF(Py_None);
655 _res = Py_None;
656 return _res;
657}
658
Guido van Rossum17448e21995-01-30 11:53:55 +0000659static PyMethodDef DlgObj_methods[] = {
660 {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1,
661 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000662 {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1,
Jack Jansen2b724171996-04-10 14:48:19 +0000663 "(RgnHandle updateRgn) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000664 {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000665 "(DialogItemIndex itemNo) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000666 {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000667 "(DialogItemIndex itemNo) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000668 {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000669 "(Point thePt) -> (DialogItemIndexZeroBased _rv)"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000670 {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +0000671 "() -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000672 {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +0000673 "() -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000674 {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +0000675 "() -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000676 {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +0000677 "() -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +0000678 {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1,
679 "(DialogItemIndex itemNo) -> (DialogItemType itemType, Handle item, Rect box)"},
680 {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1,
681 "(DialogItemIndex itemNo, DialogItemType itemType, Handle item, Rect box) -> None"},
682 {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1,
683 "(DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000684 {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1,
685 "(Handle theHandle, DITLMethod method) -> None"},
686 {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000687 "() -> (DialogItemIndex _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000688 {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000689 "(DialogItemIndex numberItems) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000690 {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000691 "() -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000692 {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000693 "(DialogItemIndex newItem) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000694 {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000695 "(DialogItemIndex newItem) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +0000696 {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1,
697 "(Boolean tracks) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +0000698 {"AutoSizeDialog", (PyCFunction)DlgObj_AutoSizeDialog, 1,
699 "() -> None"},
700 {"GetDialogItemAsControl", (PyCFunction)DlgObj_GetDialogItemAsControl, 1,
701 "(SInt16 inItemNo) -> (ControlHandle outControl)"},
702 {"MoveDialogItem", (PyCFunction)DlgObj_MoveDialogItem, 1,
703 "(SInt16 inItemNo, SInt16 inHoriz, SInt16 inVert) -> None"},
704 {"SizeDialogItem", (PyCFunction)DlgObj_SizeDialogItem, 1,
Jack Jansen1c4e6141998-04-21 15:23:55 +0000705 "(SInt16 inItemNo, SInt16 inWidth, SInt16 inHeight) -> None"},
Jack Jansend96cb501996-09-23 15:48:46 +0000706 {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1,
707 "() -> (DialogPtr _rv)"},
708 {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1,
709 "() -> (SInt16 _rv)"},
710 {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1,
711 "() -> (SInt16 _rv)"},
712 {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1,
713 "() -> (SInt16 _rv)"},
714 {"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1,
715 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000716 {NULL, NULL, 0}
717};
718
719PyMethodChain DlgObj_chain = { DlgObj_methods, &WinObj_chain };
720
721static PyObject *DlgObj_getattr(self, name)
722 DialogObject *self;
723 char *name;
724{
725 return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name);
726}
727
728#define DlgObj_setattr NULL
729
730PyTypeObject Dialog_Type = {
731 PyObject_HEAD_INIT(&PyType_Type)
732 0, /*ob_size*/
733 "Dialog", /*tp_name*/
734 sizeof(DialogObject), /*tp_basicsize*/
735 0, /*tp_itemsize*/
736 /* methods */
737 (destructor) DlgObj_dealloc, /*tp_dealloc*/
738 0, /*tp_print*/
739 (getattrfunc) DlgObj_getattr, /*tp_getattr*/
740 (setattrfunc) DlgObj_setattr, /*tp_setattr*/
741};
742
743/* --------------------- End object type Dialog --------------------- */
744
745
746static PyObject *Dlg_NewDialog(_self, _args)
747 PyObject *_self;
748 PyObject *_args;
749{
750 PyObject *_res = NULL;
751 DialogPtr _rv;
752 Rect boundsRect;
753 Str255 title;
754 Boolean visible;
Jack Jansen21f96871998-02-20 16:02:09 +0000755 SInt16 procID;
Guido van Rossum17448e21995-01-30 11:53:55 +0000756 WindowPtr behind;
757 Boolean goAwayFlag;
Jack Jansen21f96871998-02-20 16:02:09 +0000758 SInt32 refCon;
759 Handle items;
Guido van Rossum17448e21995-01-30 11:53:55 +0000760 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
761 PyMac_GetRect, &boundsRect,
762 PyMac_GetStr255, title,
763 &visible,
764 &procID,
765 WinObj_Convert, &behind,
766 &goAwayFlag,
767 &refCon,
Jack Jansen21f96871998-02-20 16:02:09 +0000768 ResObj_Convert, &items))
Guido van Rossum17448e21995-01-30 11:53:55 +0000769 return NULL;
770 _rv = NewDialog((void *)0,
771 &boundsRect,
772 title,
773 visible,
774 procID,
775 behind,
776 goAwayFlag,
777 refCon,
Jack Jansen21f96871998-02-20 16:02:09 +0000778 items);
Guido van Rossum17448e21995-01-30 11:53:55 +0000779 _res = Py_BuildValue("O&",
780 DlgObj_New, _rv);
781 return _res;
782}
783
784static PyObject *Dlg_GetNewDialog(_self, _args)
785 PyObject *_self;
786 PyObject *_args;
787{
788 PyObject *_res = NULL;
789 DialogPtr _rv;
Jack Jansen21f96871998-02-20 16:02:09 +0000790 SInt16 dialogID;
Guido van Rossum17448e21995-01-30 11:53:55 +0000791 WindowPtr behind;
792 if (!PyArg_ParseTuple(_args, "hO&",
793 &dialogID,
794 WinObj_Convert, &behind))
795 return NULL;
796 _rv = GetNewDialog(dialogID,
797 (void *)0,
798 behind);
799 _res = Py_BuildValue("O&",
800 DlgObj_New, _rv);
801 return _res;
802}
803
Jack Jansen21f96871998-02-20 16:02:09 +0000804static PyObject *Dlg_NewColorDialog(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000805 PyObject *_self;
806 PyObject *_args;
807{
808 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000809 DialogPtr _rv;
810 Rect boundsRect;
811 Str255 title;
812 Boolean visible;
813 SInt16 procID;
814 WindowPtr behind;
815 Boolean goAwayFlag;
816 SInt32 refCon;
817 Handle items;
818 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
819 PyMac_GetRect, &boundsRect,
820 PyMac_GetStr255, title,
821 &visible,
822 &procID,
823 WinObj_Convert, &behind,
824 &goAwayFlag,
825 &refCon,
826 ResObj_Convert, &items))
Guido van Rossum17448e21995-01-30 11:53:55 +0000827 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000828 _rv = NewColorDialog((void *)0,
829 &boundsRect,
830 title,
831 visible,
832 procID,
833 behind,
834 goAwayFlag,
835 refCon,
836 items);
837 _res = Py_BuildValue("O&",
838 DlgObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +0000839 return _res;
840}
841
842static PyObject *Dlg_ModalDialog(_self, _args)
843 PyObject *_self;
844 PyObject *_args;
845{
846 PyObject *_res = NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000847 PyObject* modalFilter;
Jack Jansen21f96871998-02-20 16:02:09 +0000848 DialogItemIndex itemHit;
Guido van Rossum17448e21995-01-30 11:53:55 +0000849 if (!PyArg_ParseTuple(_args, "O",
Jack Jansenae8a68f1995-06-06 12:55:40 +0000850 &modalFilter))
Guido van Rossum17448e21995-01-30 11:53:55 +0000851 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000852 ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter)),
Guido van Rossum17448e21995-01-30 11:53:55 +0000853 &itemHit);
854 _res = Py_BuildValue("h",
855 itemHit);
856 return _res;
857}
858
859static PyObject *Dlg_IsDialogEvent(_self, _args)
860 PyObject *_self;
861 PyObject *_args;
862{
863 PyObject *_res = NULL;
864 Boolean _rv;
865 EventRecord theEvent;
866 if (!PyArg_ParseTuple(_args, "O&",
867 PyMac_GetEventRecord, &theEvent))
868 return NULL;
869 _rv = IsDialogEvent(&theEvent);
870 _res = Py_BuildValue("b",
871 _rv);
872 return _res;
873}
874
875static PyObject *Dlg_DialogSelect(_self, _args)
876 PyObject *_self;
877 PyObject *_args;
878{
879 PyObject *_res = NULL;
880 Boolean _rv;
881 EventRecord theEvent;
882 DialogPtr theDialog;
Jack Jansen21f96871998-02-20 16:02:09 +0000883 DialogItemIndex itemHit;
Guido van Rossum17448e21995-01-30 11:53:55 +0000884 if (!PyArg_ParseTuple(_args, "O&",
885 PyMac_GetEventRecord, &theEvent))
886 return NULL;
887 _rv = DialogSelect(&theEvent,
888 &theDialog,
889 &itemHit);
890 _res = Py_BuildValue("bO&h",
891 _rv,
892 WinObj_WhichWindow, theDialog,
893 itemHit);
894 return _res;
895}
896
897static PyObject *Dlg_Alert(_self, _args)
898 PyObject *_self;
899 PyObject *_args;
900{
901 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000902 DialogItemIndex _rv;
903 SInt16 alertID;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000904 PyObject* modalFilter;
Guido van Rossum17448e21995-01-30 11:53:55 +0000905 if (!PyArg_ParseTuple(_args, "hO",
906 &alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000907 &modalFilter))
Guido van Rossum17448e21995-01-30 11:53:55 +0000908 return NULL;
909 _rv = Alert(alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000910 NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000911 _res = Py_BuildValue("h",
912 _rv);
913 return _res;
914}
915
916static PyObject *Dlg_StopAlert(_self, _args)
917 PyObject *_self;
918 PyObject *_args;
919{
920 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000921 DialogItemIndex _rv;
922 SInt16 alertID;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000923 PyObject* modalFilter;
Guido van Rossum17448e21995-01-30 11:53:55 +0000924 if (!PyArg_ParseTuple(_args, "hO",
925 &alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000926 &modalFilter))
Guido van Rossum17448e21995-01-30 11:53:55 +0000927 return NULL;
928 _rv = StopAlert(alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000929 NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000930 _res = Py_BuildValue("h",
931 _rv);
932 return _res;
933}
934
935static PyObject *Dlg_NoteAlert(_self, _args)
936 PyObject *_self;
937 PyObject *_args;
938{
939 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000940 DialogItemIndex _rv;
941 SInt16 alertID;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000942 PyObject* modalFilter;
Guido van Rossum17448e21995-01-30 11:53:55 +0000943 if (!PyArg_ParseTuple(_args, "hO",
944 &alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000945 &modalFilter))
Guido van Rossum17448e21995-01-30 11:53:55 +0000946 return NULL;
947 _rv = NoteAlert(alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000948 NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000949 _res = Py_BuildValue("h",
950 _rv);
951 return _res;
952}
953
954static PyObject *Dlg_CautionAlert(_self, _args)
955 PyObject *_self;
956 PyObject *_args;
957{
958 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000959 DialogItemIndex _rv;
960 SInt16 alertID;
Jack Jansenae8a68f1995-06-06 12:55:40 +0000961 PyObject* modalFilter;
Guido van Rossum17448e21995-01-30 11:53:55 +0000962 if (!PyArg_ParseTuple(_args, "hO",
963 &alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000964 &modalFilter))
Guido van Rossum17448e21995-01-30 11:53:55 +0000965 return NULL;
966 _rv = CautionAlert(alertID,
Jack Jansenae8a68f1995-06-06 12:55:40 +0000967 NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000968 _res = Py_BuildValue("h",
969 _rv);
970 return _res;
971}
972
Jack Jansen21f96871998-02-20 16:02:09 +0000973static PyObject *Dlg_ParamText(_self, _args)
974 PyObject *_self;
975 PyObject *_args;
976{
977 PyObject *_res = NULL;
978 Str255 param0;
979 Str255 param1;
980 Str255 param2;
981 Str255 param3;
982 if (!PyArg_ParseTuple(_args, "O&O&O&O&",
983 PyMac_GetStr255, param0,
984 PyMac_GetStr255, param1,
985 PyMac_GetStr255, param2,
986 PyMac_GetStr255, param3))
987 return NULL;
988 ParamText(param0,
989 param1,
990 param2,
991 param3);
992 Py_INCREF(Py_None);
993 _res = Py_None;
994 return _res;
995}
996
Jack Jansenae8a68f1995-06-06 12:55:40 +0000997static PyObject *Dlg_GetDialogItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000998 PyObject *_self;
999 PyObject *_args;
1000{
1001 PyObject *_res = NULL;
1002 Handle item;
1003 Str255 text;
1004 if (!PyArg_ParseTuple(_args, "O&",
1005 ResObj_Convert, &item))
1006 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +00001007 GetDialogItemText(item,
1008 text);
Guido van Rossum17448e21995-01-30 11:53:55 +00001009 _res = Py_BuildValue("O&",
1010 PyMac_BuildStr255, text);
1011 return _res;
1012}
1013
Jack Jansenae8a68f1995-06-06 12:55:40 +00001014static PyObject *Dlg_SetDialogItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001015 PyObject *_self;
1016 PyObject *_args;
1017{
1018 PyObject *_res = NULL;
1019 Handle item;
1020 Str255 text;
1021 if (!PyArg_ParseTuple(_args, "O&O&",
1022 ResObj_Convert, &item,
1023 PyMac_GetStr255, text))
1024 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +00001025 SetDialogItemText(item,
1026 text);
Guido van Rossum17448e21995-01-30 11:53:55 +00001027 Py_INCREF(Py_None);
1028 _res = Py_None;
1029 return _res;
1030}
1031
Jack Jansenae8a68f1995-06-06 12:55:40 +00001032static PyObject *Dlg_GetAlertStage(_self, _args)
1033 PyObject *_self;
1034 PyObject *_args;
1035{
1036 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001037 SInt16 _rv;
Jack Jansenae8a68f1995-06-06 12:55:40 +00001038 if (!PyArg_ParseTuple(_args, ""))
1039 return NULL;
1040 _rv = GetAlertStage();
1041 _res = Py_BuildValue("h",
1042 _rv);
1043 return _res;
1044}
1045
Jack Jansen21f96871998-02-20 16:02:09 +00001046static PyObject *Dlg_SetDialogFont(_self, _args)
1047 PyObject *_self;
1048 PyObject *_args;
1049{
1050 PyObject *_res = NULL;
1051 SInt16 value;
1052 if (!PyArg_ParseTuple(_args, "h",
1053 &value))
1054 return NULL;
1055 SetDialogFont(value);
1056 Py_INCREF(Py_None);
1057 _res = Py_None;
1058 return _res;
1059}
1060
Jack Jansenae8a68f1995-06-06 12:55:40 +00001061static PyObject *Dlg_ResetAlertStage(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001062 PyObject *_self;
1063 PyObject *_args;
1064{
1065 PyObject *_res = NULL;
1066 if (!PyArg_ParseTuple(_args, ""))
1067 return NULL;
Jack Jansenae8a68f1995-06-06 12:55:40 +00001068 ResetAlertStage();
Guido van Rossum17448e21995-01-30 11:53:55 +00001069 Py_INCREF(Py_None);
1070 _res = Py_None;
1071 return _res;
1072}
1073
Jack Jansen21f96871998-02-20 16:02:09 +00001074static PyObject *Dlg_NewFeaturesDialog(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001075 PyObject *_self;
1076 PyObject *_args;
1077{
1078 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001079 DialogPtr _rv;
1080 Rect inBoundsRect;
1081 Str255 inTitle;
1082 Boolean inIsVisible;
1083 SInt16 inProcID;
1084 WindowPtr inBehind;
1085 Boolean inGoAwayFlag;
1086 SInt32 inRefCon;
1087 Handle inItemListHandle;
1088 UInt32 inFlags;
1089 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&l",
1090 PyMac_GetRect, &inBoundsRect,
1091 PyMac_GetStr255, inTitle,
1092 &inIsVisible,
1093 &inProcID,
1094 WinObj_Convert, &inBehind,
1095 &inGoAwayFlag,
1096 &inRefCon,
1097 ResObj_Convert, &inItemListHandle,
1098 &inFlags))
Guido van Rossum17448e21995-01-30 11:53:55 +00001099 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00001100 _rv = NewFeaturesDialog((void *)0,
1101 &inBoundsRect,
1102 inTitle,
1103 inIsVisible,
1104 inProcID,
1105 inBehind,
1106 inGoAwayFlag,
1107 inRefCon,
1108 inItemListHandle,
1109 inFlags);
1110 _res = Py_BuildValue("O&",
1111 DlgObj_New, _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001112 return _res;
1113}
1114
Jack Jansendf901df1998-07-10 15:47:48 +00001115static PyObject *Dlg_SetUserItemHandler(_self, _args)
1116 PyObject *_self;
1117 PyObject *_args;
1118{
1119 PyObject *_res = NULL;
1120
1121 PyObject *new = NULL;
1122
1123
1124 if (!PyArg_ParseTuple(_args, "|O", &new))
1125 return NULL;
1126
1127 if (Dlg_UserItemProc_callback && new && new != Py_None) {
1128 PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
1129 return NULL;
1130 }
1131
1132 if (new == Py_None) {
1133 new = NULL;
1134 _res = Py_None;
1135 Py_INCREF(Py_None);
1136 } else {
1137 Py_INCREF(new);
1138 _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemProc(Dlg_UnivUserItemProc));
1139 }
1140
1141 Dlg_UserItemProc_callback = new;
1142 return _res;
1143
1144}
1145
Guido van Rossum17448e21995-01-30 11:53:55 +00001146static PyMethodDef Dlg_methods[] = {
1147 {"NewDialog", (PyCFunction)Dlg_NewDialog, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001148 "(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001149 {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001150 "(SInt16 dialogID, WindowPtr behind) -> (DialogPtr _rv)"},
1151 {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1,
1152 "(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001153 {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001154 "(PyObject* modalFilter) -> (DialogItemIndex itemHit)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001155 {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1,
1156 "(EventRecord theEvent) -> (Boolean _rv)"},
1157 {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001158 "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, DialogItemIndex itemHit)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001159 {"Alert", (PyCFunction)Dlg_Alert, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001160 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001161 {"StopAlert", (PyCFunction)Dlg_StopAlert, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001162 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001163 {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001164 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001165 {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001166 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
1167 {"ParamText", (PyCFunction)Dlg_ParamText, 1,
1168 "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +00001169 {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001170 "(Handle item) -> (Str255 text)"},
Jack Jansenae8a68f1995-06-06 12:55:40 +00001171 {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001172 "(Handle item, Str255 text) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +00001173 {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001174 "() -> (SInt16 _rv)"},
1175 {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1,
1176 "(SInt16 value) -> None"},
Jack Jansenae8a68f1995-06-06 12:55:40 +00001177 {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001178 "() -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001179 {"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1,
1180 "(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)"},
Jack Jansendf901df1998-07-10 15:47:48 +00001181 {"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1,
1182 NULL},
Guido van Rossum17448e21995-01-30 11:53:55 +00001183 {NULL, NULL, 0}
1184};
1185
1186
1187
1188
1189void initDlg()
1190{
1191 PyObject *m;
1192 PyObject *d;
1193
1194
1195
1196
1197 m = Py_InitModule("Dlg", Dlg_methods);
1198 d = PyModule_GetDict(m);
1199 Dlg_Error = PyMac_GetOSErrException();
1200 if (Dlg_Error == NULL ||
1201 PyDict_SetItemString(d, "Error", Dlg_Error) != 0)
1202 Py_FatalError("can't initialize Dlg.Error");
Jack Jansena755e681997-09-20 17:40:22 +00001203 Dialog_Type.ob_type = &PyType_Type;
1204 Py_INCREF(&Dialog_Type);
1205 if (PyDict_SetItemString(d, "DialogType", (PyObject *)&Dialog_Type) != 0)
1206 Py_FatalError("can't initialize DialogType");
Guido van Rossum17448e21995-01-30 11:53:55 +00001207}
1208
1209/* ========================= End module Dlg ========================= */
1210