1 |
|
---|
2 | /* ========================== Module _Dlg =========================== */
|
---|
3 |
|
---|
4 | #include "Python.h"
|
---|
5 |
|
---|
6 | #ifndef __LP64__
|
---|
7 |
|
---|
8 |
|
---|
9 | #include "pymactoolbox.h"
|
---|
10 |
|
---|
11 | /* Macro to test whether a weak-loaded CFM function exists */
|
---|
12 | #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
---|
13 | PyErr_SetString(PyExc_NotImplementedError, \
|
---|
14 | "Not available in this shared library/OS version"); \
|
---|
15 | return NULL; \
|
---|
16 | }} while(0)
|
---|
17 |
|
---|
18 |
|
---|
19 | #include <Carbon/Carbon.h>
|
---|
20 |
|
---|
21 | #ifdef USE_TOOLBOX_OBJECT_GLUE
|
---|
22 | extern PyObject *_DlgObj_New(DialogRef);
|
---|
23 | extern PyObject *_DlgObj_WhichDialog(DialogRef);
|
---|
24 | extern int _DlgObj_Convert(PyObject *, DialogRef *);
|
---|
25 |
|
---|
26 | #define DlgObj_New _DlgObj_New
|
---|
27 | #define DlgObj_WhichDialog _DlgObj_WhichDialog
|
---|
28 | #define DlgObj_Convert _DlgObj_Convert
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /* XXX Shouldn't this be a stack? */
|
---|
32 | static PyObject *Dlg_FilterProc_callback = NULL;
|
---|
33 |
|
---|
34 | static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
|
---|
35 | EventRecord *event,
|
---|
36 | short *itemHit)
|
---|
37 | {
|
---|
38 | Boolean rv;
|
---|
39 | PyObject *args, *res;
|
---|
40 | PyObject *callback = Dlg_FilterProc_callback;
|
---|
41 | if (callback == NULL)
|
---|
42 | return 0; /* Default behavior */
|
---|
43 | Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
|
---|
44 | args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event);
|
---|
45 | if (args == NULL)
|
---|
46 | res = NULL;
|
---|
47 | else {
|
---|
48 | res = PyEval_CallObject(callback, args);
|
---|
49 | Py_DECREF(args);
|
---|
50 | }
|
---|
51 | if (res == NULL) {
|
---|
52 | PySys_WriteStderr("Exception in Dialog Filter\n");
|
---|
53 | PyErr_Print();
|
---|
54 | *itemHit = -1; /* Fake return item */
|
---|
55 | return 1; /* We handled it */
|
---|
56 | }
|
---|
57 | else {
|
---|
58 | Dlg_FilterProc_callback = callback;
|
---|
59 | if (PyInt_Check(res)) {
|
---|
60 | *itemHit = PyInt_AsLong(res);
|
---|
61 | rv = 1;
|
---|
62 | }
|
---|
63 | else
|
---|
64 | rv = PyObject_IsTrue(res);
|
---|
65 | }
|
---|
66 | Py_DECREF(res);
|
---|
67 | return rv;
|
---|
68 | }
|
---|
69 |
|
---|
70 | static ModalFilterUPP
|
---|
71 | Dlg_PassFilterProc(PyObject *callback)
|
---|
72 | {
|
---|
73 | PyObject *tmp = Dlg_FilterProc_callback;
|
---|
74 | static ModalFilterUPP UnivFilterUpp = NULL;
|
---|
75 |
|
---|
76 | Dlg_FilterProc_callback = NULL;
|
---|
77 | if (callback == Py_None) {
|
---|
78 | Py_XDECREF(tmp);
|
---|
79 | return NULL;
|
---|
80 | }
|
---|
81 | Py_INCREF(callback);
|
---|
82 | Dlg_FilterProc_callback = callback;
|
---|
83 | Py_XDECREF(tmp);
|
---|
84 | if ( UnivFilterUpp == NULL )
|
---|
85 | UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
|
---|
86 | return UnivFilterUpp;
|
---|
87 | }
|
---|
88 |
|
---|
89 | static PyObject *Dlg_UserItemProc_callback = NULL;
|
---|
90 |
|
---|
91 | static pascal void Dlg_UnivUserItemProc(DialogPtr dialog,
|
---|
92 | short item)
|
---|
93 | {
|
---|
94 | PyObject *args, *res;
|
---|
95 |
|
---|
96 | if (Dlg_UserItemProc_callback == NULL)
|
---|
97 | return; /* Default behavior */
|
---|
98 | Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
|
---|
99 | args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item);
|
---|
100 | if (args == NULL)
|
---|
101 | res = NULL;
|
---|
102 | else {
|
---|
103 | res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
|
---|
104 | Py_DECREF(args);
|
---|
105 | }
|
---|
106 | if (res == NULL) {
|
---|
107 | PySys_WriteStderr("Exception in Dialog UserItem proc\n");
|
---|
108 | PyErr_Print();
|
---|
109 | }
|
---|
110 | Py_XDECREF(res);
|
---|
111 | return;
|
---|
112 | }
|
---|
113 |
|
---|
114 | #if 0
|
---|
115 | /*
|
---|
116 | ** Treating DialogObjects as WindowObjects is (I think) illegal under Carbon.
|
---|
117 | ** However, as they are still identical under MacOS9 Carbon this is a problem, even
|
---|
118 | ** if we neatly call GetDialogWindow() at the right places: there's one refcon field
|
---|
119 | ** and it points to the DialogObject, so WinObj_WhichWindow will smartly return the
|
---|
120 | ** dialog object, and therefore we still don't have a WindowObject.
|
---|
121 | ** I'll leave the chaining code in place for now, with this comment to warn the
|
---|
122 | ** unsuspecting victims (i.e. me, probably, in a few weeks:-)
|
---|
123 | */
|
---|
124 | extern PyMethodChain WinObj_chain;
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | static PyObject *Dlg_Error;
|
---|
128 |
|
---|
129 | /* ----------------------- Object type Dialog ----------------------- */
|
---|
130 |
|
---|
131 | PyTypeObject Dialog_Type;
|
---|
132 |
|
---|
133 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type || PyObject_TypeCheck((x), &Dialog_Type))
|
---|
134 |
|
---|
135 | typedef struct DialogObject {
|
---|
136 | PyObject_HEAD
|
---|
137 | DialogPtr ob_itself;
|
---|
138 | } DialogObject;
|
---|
139 |
|
---|
140 | PyObject *DlgObj_New(DialogPtr itself)
|
---|
141 | {
|
---|
142 | DialogObject *it;
|
---|
143 | if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }
|
---|
144 | it = PyObject_NEW(DialogObject, &Dialog_Type);
|
---|
145 | if (it == NULL) return NULL;
|
---|
146 | it->ob_itself = itself;
|
---|
147 | SetWRefCon(GetDialogWindow(itself), (long)it);
|
---|
148 | return (PyObject *)it;
|
---|
149 | }
|
---|
150 |
|
---|
151 | int DlgObj_Convert(PyObject *v, DialogPtr *p_itself)
|
---|
152 | {
|
---|
153 | if (v == Py_None) { *p_itself = NULL; return 1; }
|
---|
154 | if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);
|
---|
155 | return 1; }
|
---|
156 | if (!DlgObj_Check(v))
|
---|
157 | {
|
---|
158 | PyErr_SetString(PyExc_TypeError, "Dialog required");
|
---|
159 | return 0;
|
---|
160 | }
|
---|
161 | *p_itself = ((DialogObject *)v)->ob_itself;
|
---|
162 | return 1;
|
---|
163 | }
|
---|
164 |
|
---|
165 | static void DlgObj_dealloc(DialogObject *self)
|
---|
166 | {
|
---|
167 | DisposeDialog(self->ob_itself);
|
---|
168 | self->ob_type->tp_free((PyObject *)self);
|
---|
169 | }
|
---|
170 |
|
---|
171 | static PyObject *DlgObj_DrawDialog(DialogObject *_self, PyObject *_args)
|
---|
172 | {
|
---|
173 | PyObject *_res = NULL;
|
---|
174 | #ifndef DrawDialog
|
---|
175 | PyMac_PRECHECK(DrawDialog);
|
---|
176 | #endif
|
---|
177 | if (!PyArg_ParseTuple(_args, ""))
|
---|
178 | return NULL;
|
---|
179 | DrawDialog(_self->ob_itself);
|
---|
180 | Py_INCREF(Py_None);
|
---|
181 | _res = Py_None;
|
---|
182 | return _res;
|
---|
183 | }
|
---|
184 |
|
---|
185 | static PyObject *DlgObj_UpdateDialog(DialogObject *_self, PyObject *_args)
|
---|
186 | {
|
---|
187 | PyObject *_res = NULL;
|
---|
188 | RgnHandle updateRgn;
|
---|
189 | #ifndef UpdateDialog
|
---|
190 | PyMac_PRECHECK(UpdateDialog);
|
---|
191 | #endif
|
---|
192 | if (!PyArg_ParseTuple(_args, "O&",
|
---|
193 | ResObj_Convert, &updateRgn))
|
---|
194 | return NULL;
|
---|
195 | UpdateDialog(_self->ob_itself,
|
---|
196 | updateRgn);
|
---|
197 | Py_INCREF(Py_None);
|
---|
198 | _res = Py_None;
|
---|
199 | return _res;
|
---|
200 | }
|
---|
201 |
|
---|
202 | static PyObject *DlgObj_HideDialogItem(DialogObject *_self, PyObject *_args)
|
---|
203 | {
|
---|
204 | PyObject *_res = NULL;
|
---|
205 | DialogItemIndex itemNo;
|
---|
206 | #ifndef HideDialogItem
|
---|
207 | PyMac_PRECHECK(HideDialogItem);
|
---|
208 | #endif
|
---|
209 | if (!PyArg_ParseTuple(_args, "h",
|
---|
210 | &itemNo))
|
---|
211 | return NULL;
|
---|
212 | HideDialogItem(_self->ob_itself,
|
---|
213 | itemNo);
|
---|
214 | Py_INCREF(Py_None);
|
---|
215 | _res = Py_None;
|
---|
216 | return _res;
|
---|
217 | }
|
---|
218 |
|
---|
219 | static PyObject *DlgObj_ShowDialogItem(DialogObject *_self, PyObject *_args)
|
---|
220 | {
|
---|
221 | PyObject *_res = NULL;
|
---|
222 | DialogItemIndex itemNo;
|
---|
223 | #ifndef ShowDialogItem
|
---|
224 | PyMac_PRECHECK(ShowDialogItem);
|
---|
225 | #endif
|
---|
226 | if (!PyArg_ParseTuple(_args, "h",
|
---|
227 | &itemNo))
|
---|
228 | return NULL;
|
---|
229 | ShowDialogItem(_self->ob_itself,
|
---|
230 | itemNo);
|
---|
231 | Py_INCREF(Py_None);
|
---|
232 | _res = Py_None;
|
---|
233 | return _res;
|
---|
234 | }
|
---|
235 |
|
---|
236 | static PyObject *DlgObj_FindDialogItem(DialogObject *_self, PyObject *_args)
|
---|
237 | {
|
---|
238 | PyObject *_res = NULL;
|
---|
239 | DialogItemIndexZeroBased _rv;
|
---|
240 | Point thePt;
|
---|
241 | #ifndef FindDialogItem
|
---|
242 | PyMac_PRECHECK(FindDialogItem);
|
---|
243 | #endif
|
---|
244 | if (!PyArg_ParseTuple(_args, "O&",
|
---|
245 | PyMac_GetPoint, &thePt))
|
---|
246 | return NULL;
|
---|
247 | _rv = FindDialogItem(_self->ob_itself,
|
---|
248 | thePt);
|
---|
249 | _res = Py_BuildValue("h",
|
---|
250 | _rv);
|
---|
251 | return _res;
|
---|
252 | }
|
---|
253 |
|
---|
254 | static PyObject *DlgObj_DialogCut(DialogObject *_self, PyObject *_args)
|
---|
255 | {
|
---|
256 | PyObject *_res = NULL;
|
---|
257 | #ifndef DialogCut
|
---|
258 | PyMac_PRECHECK(DialogCut);
|
---|
259 | #endif
|
---|
260 | if (!PyArg_ParseTuple(_args, ""))
|
---|
261 | return NULL;
|
---|
262 | DialogCut(_self->ob_itself);
|
---|
263 | Py_INCREF(Py_None);
|
---|
264 | _res = Py_None;
|
---|
265 | return _res;
|
---|
266 | }
|
---|
267 |
|
---|
268 | static PyObject *DlgObj_DialogPaste(DialogObject *_self, PyObject *_args)
|
---|
269 | {
|
---|
270 | PyObject *_res = NULL;
|
---|
271 | #ifndef DialogPaste
|
---|
272 | PyMac_PRECHECK(DialogPaste);
|
---|
273 | #endif
|
---|
274 | if (!PyArg_ParseTuple(_args, ""))
|
---|
275 | return NULL;
|
---|
276 | DialogPaste(_self->ob_itself);
|
---|
277 | Py_INCREF(Py_None);
|
---|
278 | _res = Py_None;
|
---|
279 | return _res;
|
---|
280 | }
|
---|
281 |
|
---|
282 | static PyObject *DlgObj_DialogCopy(DialogObject *_self, PyObject *_args)
|
---|
283 | {
|
---|
284 | PyObject *_res = NULL;
|
---|
285 | #ifndef DialogCopy
|
---|
286 | PyMac_PRECHECK(DialogCopy);
|
---|
287 | #endif
|
---|
288 | if (!PyArg_ParseTuple(_args, ""))
|
---|
289 | return NULL;
|
---|
290 | DialogCopy(_self->ob_itself);
|
---|
291 | Py_INCREF(Py_None);
|
---|
292 | _res = Py_None;
|
---|
293 | return _res;
|
---|
294 | }
|
---|
295 |
|
---|
296 | static PyObject *DlgObj_DialogDelete(DialogObject *_self, PyObject *_args)
|
---|
297 | {
|
---|
298 | PyObject *_res = NULL;
|
---|
299 | #ifndef DialogDelete
|
---|
300 | PyMac_PRECHECK(DialogDelete);
|
---|
301 | #endif
|
---|
302 | if (!PyArg_ParseTuple(_args, ""))
|
---|
303 | return NULL;
|
---|
304 | DialogDelete(_self->ob_itself);
|
---|
305 | Py_INCREF(Py_None);
|
---|
306 | _res = Py_None;
|
---|
307 | return _res;
|
---|
308 | }
|
---|
309 |
|
---|
310 | static PyObject *DlgObj_GetDialogItem(DialogObject *_self, PyObject *_args)
|
---|
311 | {
|
---|
312 | PyObject *_res = NULL;
|
---|
313 | DialogItemIndex itemNo;
|
---|
314 | DialogItemType itemType;
|
---|
315 | Handle item;
|
---|
316 | Rect box;
|
---|
317 | #ifndef GetDialogItem
|
---|
318 | PyMac_PRECHECK(GetDialogItem);
|
---|
319 | #endif
|
---|
320 | if (!PyArg_ParseTuple(_args, "h",
|
---|
321 | &itemNo))
|
---|
322 | return NULL;
|
---|
323 | GetDialogItem(_self->ob_itself,
|
---|
324 | itemNo,
|
---|
325 | &itemType,
|
---|
326 | &item,
|
---|
327 | &box);
|
---|
328 | _res = Py_BuildValue("hO&O&",
|
---|
329 | itemType,
|
---|
330 | OptResObj_New, item,
|
---|
331 | PyMac_BuildRect, &box);
|
---|
332 | return _res;
|
---|
333 | }
|
---|
334 |
|
---|
335 | static PyObject *DlgObj_SetDialogItem(DialogObject *_self, PyObject *_args)
|
---|
336 | {
|
---|
337 | PyObject *_res = NULL;
|
---|
338 | DialogItemIndex itemNo;
|
---|
339 | DialogItemType itemType;
|
---|
340 | Handle item;
|
---|
341 | Rect box;
|
---|
342 | #ifndef SetDialogItem
|
---|
343 | PyMac_PRECHECK(SetDialogItem);
|
---|
344 | #endif
|
---|
345 | if (!PyArg_ParseTuple(_args, "hhO&O&",
|
---|
346 | &itemNo,
|
---|
347 | &itemType,
|
---|
348 | ResObj_Convert, &item,
|
---|
349 | PyMac_GetRect, &box))
|
---|
350 | return NULL;
|
---|
351 | SetDialogItem(_self->ob_itself,
|
---|
352 | itemNo,
|
---|
353 | itemType,
|
---|
354 | item,
|
---|
355 | &box);
|
---|
356 | Py_INCREF(Py_None);
|
---|
357 | _res = Py_None;
|
---|
358 | return _res;
|
---|
359 | }
|
---|
360 |
|
---|
361 | static PyObject *DlgObj_SelectDialogItemText(DialogObject *_self, PyObject *_args)
|
---|
362 | {
|
---|
363 | PyObject *_res = NULL;
|
---|
364 | DialogItemIndex itemNo;
|
---|
365 | SInt16 strtSel;
|
---|
366 | SInt16 endSel;
|
---|
367 | #ifndef SelectDialogItemText
|
---|
368 | PyMac_PRECHECK(SelectDialogItemText);
|
---|
369 | #endif
|
---|
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 |
|
---|
384 | static PyObject *DlgObj_AppendDITL(DialogObject *_self, PyObject *_args)
|
---|
385 | {
|
---|
386 | PyObject *_res = NULL;
|
---|
387 | Handle theHandle;
|
---|
388 | DITLMethod method;
|
---|
389 | #ifndef AppendDITL
|
---|
390 | PyMac_PRECHECK(AppendDITL);
|
---|
391 | #endif
|
---|
392 | if (!PyArg_ParseTuple(_args, "O&h",
|
---|
393 | ResObj_Convert, &theHandle,
|
---|
394 | &method))
|
---|
395 | return NULL;
|
---|
396 | AppendDITL(_self->ob_itself,
|
---|
397 | theHandle,
|
---|
398 | method);
|
---|
399 | Py_INCREF(Py_None);
|
---|
400 | _res = Py_None;
|
---|
401 | return _res;
|
---|
402 | }
|
---|
403 |
|
---|
404 | static PyObject *DlgObj_CountDITL(DialogObject *_self, PyObject *_args)
|
---|
405 | {
|
---|
406 | PyObject *_res = NULL;
|
---|
407 | DialogItemIndex _rv;
|
---|
408 | #ifndef CountDITL
|
---|
409 | PyMac_PRECHECK(CountDITL);
|
---|
410 | #endif
|
---|
411 | if (!PyArg_ParseTuple(_args, ""))
|
---|
412 | return NULL;
|
---|
413 | _rv = CountDITL(_self->ob_itself);
|
---|
414 | _res = Py_BuildValue("h",
|
---|
415 | _rv);
|
---|
416 | return _res;
|
---|
417 | }
|
---|
418 |
|
---|
419 | static PyObject *DlgObj_ShortenDITL(DialogObject *_self, PyObject *_args)
|
---|
420 | {
|
---|
421 | PyObject *_res = NULL;
|
---|
422 | DialogItemIndex numberItems;
|
---|
423 | #ifndef ShortenDITL
|
---|
424 | PyMac_PRECHECK(ShortenDITL);
|
---|
425 | #endif
|
---|
426 | if (!PyArg_ParseTuple(_args, "h",
|
---|
427 | &numberItems))
|
---|
428 | return NULL;
|
---|
429 | ShortenDITL(_self->ob_itself,
|
---|
430 | numberItems);
|
---|
431 | Py_INCREF(Py_None);
|
---|
432 | _res = Py_None;
|
---|
433 | return _res;
|
---|
434 | }
|
---|
435 |
|
---|
436 | static PyObject *DlgObj_InsertDialogItem(DialogObject *_self, PyObject *_args)
|
---|
437 | {
|
---|
438 | PyObject *_res = NULL;
|
---|
439 | OSStatus _err;
|
---|
440 | DialogItemIndex afterItem;
|
---|
441 | DialogItemType itemType;
|
---|
442 | Handle itemHandle;
|
---|
443 | Rect box;
|
---|
444 | #ifndef InsertDialogItem
|
---|
445 | PyMac_PRECHECK(InsertDialogItem);
|
---|
446 | #endif
|
---|
447 | if (!PyArg_ParseTuple(_args, "hhO&O&",
|
---|
448 | &afterItem,
|
---|
449 | &itemType,
|
---|
450 | ResObj_Convert, &itemHandle,
|
---|
451 | PyMac_GetRect, &box))
|
---|
452 | return NULL;
|
---|
453 | _err = InsertDialogItem(_self->ob_itself,
|
---|
454 | afterItem,
|
---|
455 | itemType,
|
---|
456 | itemHandle,
|
---|
457 | &box);
|
---|
458 | if (_err != noErr) return PyMac_Error(_err);
|
---|
459 | Py_INCREF(Py_None);
|
---|
460 | _res = Py_None;
|
---|
461 | return _res;
|
---|
462 | }
|
---|
463 |
|
---|
464 | static PyObject *DlgObj_RemoveDialogItems(DialogObject *_self, PyObject *_args)
|
---|
465 | {
|
---|
466 | PyObject *_res = NULL;
|
---|
467 | OSStatus _err;
|
---|
468 | DialogItemIndex itemNo;
|
---|
469 | DialogItemIndex amountToRemove;
|
---|
470 | Boolean disposeItemData;
|
---|
471 | #ifndef RemoveDialogItems
|
---|
472 | PyMac_PRECHECK(RemoveDialogItems);
|
---|
473 | #endif
|
---|
474 | if (!PyArg_ParseTuple(_args, "hhb",
|
---|
475 | &itemNo,
|
---|
476 | &amountToRemove,
|
---|
477 | &disposeItemData))
|
---|
478 | return NULL;
|
---|
479 | _err = RemoveDialogItems(_self->ob_itself,
|
---|
480 | itemNo,
|
---|
481 | amountToRemove,
|
---|
482 | disposeItemData);
|
---|
483 | if (_err != noErr) return PyMac_Error(_err);
|
---|
484 | Py_INCREF(Py_None);
|
---|
485 | _res = Py_None;
|
---|
486 | return _res;
|
---|
487 | }
|
---|
488 |
|
---|
489 | static PyObject *DlgObj_StdFilterProc(DialogObject *_self, PyObject *_args)
|
---|
490 | {
|
---|
491 | PyObject *_res = NULL;
|
---|
492 | Boolean _rv;
|
---|
493 | EventRecord event;
|
---|
494 | DialogItemIndex itemHit;
|
---|
495 | #ifndef StdFilterProc
|
---|
496 | PyMac_PRECHECK(StdFilterProc);
|
---|
497 | #endif
|
---|
498 | if (!PyArg_ParseTuple(_args, "O&h",
|
---|
499 | PyMac_GetEventRecord, &event,
|
---|
500 | &itemHit))
|
---|
501 | return NULL;
|
---|
502 | _rv = StdFilterProc(_self->ob_itself,
|
---|
503 | &event,
|
---|
504 | &itemHit);
|
---|
505 | _res = Py_BuildValue("bO&h",
|
---|
506 | _rv,
|
---|
507 | PyMac_BuildEventRecord, &event,
|
---|
508 | itemHit);
|
---|
509 | return _res;
|
---|
510 | }
|
---|
511 |
|
---|
512 | static PyObject *DlgObj_SetDialogDefaultItem(DialogObject *_self, PyObject *_args)
|
---|
513 | {
|
---|
514 | PyObject *_res = NULL;
|
---|
515 | OSErr _err;
|
---|
516 | DialogItemIndex newItem;
|
---|
517 | #ifndef SetDialogDefaultItem
|
---|
518 | PyMac_PRECHECK(SetDialogDefaultItem);
|
---|
519 | #endif
|
---|
520 | if (!PyArg_ParseTuple(_args, "h",
|
---|
521 | &newItem))
|
---|
522 | return NULL;
|
---|
523 | _err = SetDialogDefaultItem(_self->ob_itself,
|
---|
524 | newItem);
|
---|
525 | if (_err != noErr) return PyMac_Error(_err);
|
---|
526 | Py_INCREF(Py_None);
|
---|
527 | _res = Py_None;
|
---|
528 | return _res;
|
---|
529 | }
|
---|
530 |
|
---|
531 | static PyObject *DlgObj_SetDialogCancelItem(DialogObject *_self, PyObject *_args)
|
---|
532 | {
|
---|
533 | PyObject *_res = NULL;
|
---|
534 | OSErr _err;
|
---|
535 | DialogItemIndex newItem;
|
---|
536 | #ifndef SetDialogCancelItem
|
---|
537 | PyMac_PRECHECK(SetDialogCancelItem);
|
---|
538 | #endif
|
---|
539 | if (!PyArg_ParseTuple(_args, "h",
|
---|
540 | &newItem))
|
---|
541 | return NULL;
|
---|
542 | _err = SetDialogCancelItem(_self->ob_itself,
|
---|
543 | newItem);
|
---|
544 | if (_err != noErr) return PyMac_Error(_err);
|
---|
545 | Py_INCREF(Py_None);
|
---|
546 | _res = Py_None;
|
---|
547 | return _res;
|
---|
548 | }
|
---|
549 |
|
---|
550 | static PyObject *DlgObj_SetDialogTracksCursor(DialogObject *_self, PyObject *_args)
|
---|
551 | {
|
---|
552 | PyObject *_res = NULL;
|
---|
553 | OSErr _err;
|
---|
554 | Boolean tracks;
|
---|
555 | #ifndef SetDialogTracksCursor
|
---|
556 | PyMac_PRECHECK(SetDialogTracksCursor);
|
---|
557 | #endif
|
---|
558 | if (!PyArg_ParseTuple(_args, "b",
|
---|
559 | &tracks))
|
---|
560 | return NULL;
|
---|
561 | _err = SetDialogTracksCursor(_self->ob_itself,
|
---|
562 | tracks);
|
---|
563 | if (_err != noErr) return PyMac_Error(_err);
|
---|
564 | Py_INCREF(Py_None);
|
---|
565 | _res = Py_None;
|
---|
566 | return _res;
|
---|
567 | }
|
---|
568 |
|
---|
569 | static PyObject *DlgObj_AutoSizeDialog(DialogObject *_self, PyObject *_args)
|
---|
570 | {
|
---|
571 | PyObject *_res = NULL;
|
---|
572 | OSErr _err;
|
---|
573 | #ifndef AutoSizeDialog
|
---|
574 | PyMac_PRECHECK(AutoSizeDialog);
|
---|
575 | #endif
|
---|
576 | if (!PyArg_ParseTuple(_args, ""))
|
---|
577 | return NULL;
|
---|
578 | _err = AutoSizeDialog(_self->ob_itself);
|
---|
579 | if (_err != noErr) return PyMac_Error(_err);
|
---|
580 | Py_INCREF(Py_None);
|
---|
581 | _res = Py_None;
|
---|
582 | return _res;
|
---|
583 | }
|
---|
584 |
|
---|
585 | static PyObject *DlgObj_GetDialogItemAsControl(DialogObject *_self, PyObject *_args)
|
---|
586 | {
|
---|
587 | PyObject *_res = NULL;
|
---|
588 | OSErr _err;
|
---|
589 | SInt16 inItemNo;
|
---|
590 | ControlHandle outControl;
|
---|
591 | #ifndef GetDialogItemAsControl
|
---|
592 | PyMac_PRECHECK(GetDialogItemAsControl);
|
---|
593 | #endif
|
---|
594 | if (!PyArg_ParseTuple(_args, "h",
|
---|
595 | &inItemNo))
|
---|
596 | return NULL;
|
---|
597 | _err = GetDialogItemAsControl(_self->ob_itself,
|
---|
598 | inItemNo,
|
---|
599 | &outControl);
|
---|
600 | if (_err != noErr) return PyMac_Error(_err);
|
---|
601 | _res = Py_BuildValue("O&",
|
---|
602 | CtlObj_New, outControl);
|
---|
603 | return _res;
|
---|
604 | }
|
---|
605 |
|
---|
606 | static PyObject *DlgObj_MoveDialogItem(DialogObject *_self, PyObject *_args)
|
---|
607 | {
|
---|
608 | PyObject *_res = NULL;
|
---|
609 | OSErr _err;
|
---|
610 | SInt16 inItemNo;
|
---|
611 | SInt16 inHoriz;
|
---|
612 | SInt16 inVert;
|
---|
613 | #ifndef MoveDialogItem
|
---|
614 | PyMac_PRECHECK(MoveDialogItem);
|
---|
615 | #endif
|
---|
616 | if (!PyArg_ParseTuple(_args, "hhh",
|
---|
617 | &inItemNo,
|
---|
618 | &inHoriz,
|
---|
619 | &inVert))
|
---|
620 | return NULL;
|
---|
621 | _err = MoveDialogItem(_self->ob_itself,
|
---|
622 | inItemNo,
|
---|
623 | inHoriz,
|
---|
624 | inVert);
|
---|
625 | if (_err != noErr) return PyMac_Error(_err);
|
---|
626 | Py_INCREF(Py_None);
|
---|
627 | _res = Py_None;
|
---|
628 | return _res;
|
---|
629 | }
|
---|
630 |
|
---|
631 | static PyObject *DlgObj_SizeDialogItem(DialogObject *_self, PyObject *_args)
|
---|
632 | {
|
---|
633 | PyObject *_res = NULL;
|
---|
634 | OSErr _err;
|
---|
635 | SInt16 inItemNo;
|
---|
636 | SInt16 inWidth;
|
---|
637 | SInt16 inHeight;
|
---|
638 | #ifndef SizeDialogItem
|
---|
639 | PyMac_PRECHECK(SizeDialogItem);
|
---|
640 | #endif
|
---|
641 | if (!PyArg_ParseTuple(_args, "hhh",
|
---|
642 | &inItemNo,
|
---|
643 | &inWidth,
|
---|
644 | &inHeight))
|
---|
645 | return NULL;
|
---|
646 | _err = SizeDialogItem(_self->ob_itself,
|
---|
647 | inItemNo,
|
---|
648 | inWidth,
|
---|
649 | inHeight);
|
---|
650 | if (_err != noErr) return PyMac_Error(_err);
|
---|
651 | Py_INCREF(Py_None);
|
---|
652 | _res = Py_None;
|
---|
653 | return _res;
|
---|
654 | }
|
---|
655 |
|
---|
656 | static PyObject *DlgObj_AppendDialogItemList(DialogObject *_self, PyObject *_args)
|
---|
657 | {
|
---|
658 | PyObject *_res = NULL;
|
---|
659 | OSErr _err;
|
---|
660 | SInt16 ditlID;
|
---|
661 | DITLMethod method;
|
---|
662 | #ifndef AppendDialogItemList
|
---|
663 | PyMac_PRECHECK(AppendDialogItemList);
|
---|
664 | #endif
|
---|
665 | if (!PyArg_ParseTuple(_args, "hh",
|
---|
666 | &ditlID,
|
---|
667 | &method))
|
---|
668 | return NULL;
|
---|
669 | _err = AppendDialogItemList(_self->ob_itself,
|
---|
670 | ditlID,
|
---|
671 | method);
|
---|
672 | if (_err != noErr) return PyMac_Error(_err);
|
---|
673 | Py_INCREF(Py_None);
|
---|
674 | _res = Py_None;
|
---|
675 | return _res;
|
---|
676 | }
|
---|
677 |
|
---|
678 | static PyObject *DlgObj_SetDialogTimeout(DialogObject *_self, PyObject *_args)
|
---|
679 | {
|
---|
680 | PyObject *_res = NULL;
|
---|
681 | OSStatus _err;
|
---|
682 | SInt16 inButtonToPress;
|
---|
683 | UInt32 inSecondsToWait;
|
---|
684 | #ifndef SetDialogTimeout
|
---|
685 | PyMac_PRECHECK(SetDialogTimeout);
|
---|
686 | #endif
|
---|
687 | if (!PyArg_ParseTuple(_args, "hl",
|
---|
688 | &inButtonToPress,
|
---|
689 | &inSecondsToWait))
|
---|
690 | return NULL;
|
---|
691 | _err = SetDialogTimeout(_self->ob_itself,
|
---|
692 | inButtonToPress,
|
---|
693 | inSecondsToWait);
|
---|
694 | if (_err != noErr) return PyMac_Error(_err);
|
---|
695 | Py_INCREF(Py_None);
|
---|
696 | _res = Py_None;
|
---|
697 | return _res;
|
---|
698 | }
|
---|
699 |
|
---|
700 | static PyObject *DlgObj_GetDialogTimeout(DialogObject *_self, PyObject *_args)
|
---|
701 | {
|
---|
702 | PyObject *_res = NULL;
|
---|
703 | OSStatus _err;
|
---|
704 | SInt16 outButtonToPress;
|
---|
705 | UInt32 outSecondsToWait;
|
---|
706 | UInt32 outSecondsRemaining;
|
---|
707 | #ifndef GetDialogTimeout
|
---|
708 | PyMac_PRECHECK(GetDialogTimeout);
|
---|
709 | #endif
|
---|
710 | if (!PyArg_ParseTuple(_args, ""))
|
---|
711 | return NULL;
|
---|
712 | _err = GetDialogTimeout(_self->ob_itself,
|
---|
713 | &outButtonToPress,
|
---|
714 | &outSecondsToWait,
|
---|
715 | &outSecondsRemaining);
|
---|
716 | if (_err != noErr) return PyMac_Error(_err);
|
---|
717 | _res = Py_BuildValue("hll",
|
---|
718 | outButtonToPress,
|
---|
719 | outSecondsToWait,
|
---|
720 | outSecondsRemaining);
|
---|
721 | return _res;
|
---|
722 | }
|
---|
723 |
|
---|
724 | static PyObject *DlgObj_SetModalDialogEventMask(DialogObject *_self, PyObject *_args)
|
---|
725 | {
|
---|
726 | PyObject *_res = NULL;
|
---|
727 | OSStatus _err;
|
---|
728 | EventMask inMask;
|
---|
729 | #ifndef SetModalDialogEventMask
|
---|
730 | PyMac_PRECHECK(SetModalDialogEventMask);
|
---|
731 | #endif
|
---|
732 | if (!PyArg_ParseTuple(_args, "H",
|
---|
733 | &inMask))
|
---|
734 | return NULL;
|
---|
735 | _err = SetModalDialogEventMask(_self->ob_itself,
|
---|
736 | inMask);
|
---|
737 | if (_err != noErr) return PyMac_Error(_err);
|
---|
738 | Py_INCREF(Py_None);
|
---|
739 | _res = Py_None;
|
---|
740 | return _res;
|
---|
741 | }
|
---|
742 |
|
---|
743 | static PyObject *DlgObj_GetModalDialogEventMask(DialogObject *_self, PyObject *_args)
|
---|
744 | {
|
---|
745 | PyObject *_res = NULL;
|
---|
746 | OSStatus _err;
|
---|
747 | EventMask outMask;
|
---|
748 | #ifndef GetModalDialogEventMask
|
---|
749 | PyMac_PRECHECK(GetModalDialogEventMask);
|
---|
750 | #endif
|
---|
751 | if (!PyArg_ParseTuple(_args, ""))
|
---|
752 | return NULL;
|
---|
753 | _err = GetModalDialogEventMask(_self->ob_itself,
|
---|
754 | &outMask);
|
---|
755 | if (_err != noErr) return PyMac_Error(_err);
|
---|
756 | _res = Py_BuildValue("H",
|
---|
757 | outMask);
|
---|
758 | return _res;
|
---|
759 | }
|
---|
760 |
|
---|
761 | static PyObject *DlgObj_GetDialogWindow(DialogObject *_self, PyObject *_args)
|
---|
762 | {
|
---|
763 | PyObject *_res = NULL;
|
---|
764 | WindowPtr _rv;
|
---|
765 | #ifndef GetDialogWindow
|
---|
766 | PyMac_PRECHECK(GetDialogWindow);
|
---|
767 | #endif
|
---|
768 | if (!PyArg_ParseTuple(_args, ""))
|
---|
769 | return NULL;
|
---|
770 | _rv = GetDialogWindow(_self->ob_itself);
|
---|
771 | _res = Py_BuildValue("O&",
|
---|
772 | WinObj_New, _rv);
|
---|
773 | return _res;
|
---|
774 | }
|
---|
775 |
|
---|
776 | static PyObject *DlgObj_GetDialogTextEditHandle(DialogObject *_self, PyObject *_args)
|
---|
777 | {
|
---|
778 | PyObject *_res = NULL;
|
---|
779 | TEHandle _rv;
|
---|
780 | #ifndef GetDialogTextEditHandle
|
---|
781 | PyMac_PRECHECK(GetDialogTextEditHandle);
|
---|
782 | #endif
|
---|
783 | if (!PyArg_ParseTuple(_args, ""))
|
---|
784 | return NULL;
|
---|
785 | _rv = GetDialogTextEditHandle(_self->ob_itself);
|
---|
786 | _res = Py_BuildValue("O&",
|
---|
787 | ResObj_New, _rv);
|
---|
788 | return _res;
|
---|
789 | }
|
---|
790 |
|
---|
791 | static PyObject *DlgObj_GetDialogDefaultItem(DialogObject *_self, PyObject *_args)
|
---|
792 | {
|
---|
793 | PyObject *_res = NULL;
|
---|
794 | SInt16 _rv;
|
---|
795 | #ifndef GetDialogDefaultItem
|
---|
796 | PyMac_PRECHECK(GetDialogDefaultItem);
|
---|
797 | #endif
|
---|
798 | if (!PyArg_ParseTuple(_args, ""))
|
---|
799 | return NULL;
|
---|
800 | _rv = GetDialogDefaultItem(_self->ob_itself);
|
---|
801 | _res = Py_BuildValue("h",
|
---|
802 | _rv);
|
---|
803 | return _res;
|
---|
804 | }
|
---|
805 |
|
---|
806 | static PyObject *DlgObj_GetDialogCancelItem(DialogObject *_self, PyObject *_args)
|
---|
807 | {
|
---|
808 | PyObject *_res = NULL;
|
---|
809 | SInt16 _rv;
|
---|
810 | #ifndef GetDialogCancelItem
|
---|
811 | PyMac_PRECHECK(GetDialogCancelItem);
|
---|
812 | #endif
|
---|
813 | if (!PyArg_ParseTuple(_args, ""))
|
---|
814 | return NULL;
|
---|
815 | _rv = GetDialogCancelItem(_self->ob_itself);
|
---|
816 | _res = Py_BuildValue("h",
|
---|
817 | _rv);
|
---|
818 | return _res;
|
---|
819 | }
|
---|
820 |
|
---|
821 | static PyObject *DlgObj_GetDialogKeyboardFocusItem(DialogObject *_self, PyObject *_args)
|
---|
822 | {
|
---|
823 | PyObject *_res = NULL;
|
---|
824 | SInt16 _rv;
|
---|
825 | #ifndef GetDialogKeyboardFocusItem
|
---|
826 | PyMac_PRECHECK(GetDialogKeyboardFocusItem);
|
---|
827 | #endif
|
---|
828 | if (!PyArg_ParseTuple(_args, ""))
|
---|
829 | return NULL;
|
---|
830 | _rv = GetDialogKeyboardFocusItem(_self->ob_itself);
|
---|
831 | _res = Py_BuildValue("h",
|
---|
832 | _rv);
|
---|
833 | return _res;
|
---|
834 | }
|
---|
835 |
|
---|
836 | static PyObject *DlgObj_SetPortDialogPort(DialogObject *_self, PyObject *_args)
|
---|
837 | {
|
---|
838 | PyObject *_res = NULL;
|
---|
839 | #ifndef SetPortDialogPort
|
---|
840 | PyMac_PRECHECK(SetPortDialogPort);
|
---|
841 | #endif
|
---|
842 | if (!PyArg_ParseTuple(_args, ""))
|
---|
843 | return NULL;
|
---|
844 | SetPortDialogPort(_self->ob_itself);
|
---|
845 | Py_INCREF(Py_None);
|
---|
846 | _res = Py_None;
|
---|
847 | return _res;
|
---|
848 | }
|
---|
849 |
|
---|
850 | static PyObject *DlgObj_GetDialogPort(DialogObject *_self, PyObject *_args)
|
---|
851 | {
|
---|
852 | PyObject *_res = NULL;
|
---|
853 | CGrafPtr _rv;
|
---|
854 | #ifndef GetDialogPort
|
---|
855 | PyMac_PRECHECK(GetDialogPort);
|
---|
856 | #endif
|
---|
857 | if (!PyArg_ParseTuple(_args, ""))
|
---|
858 | return NULL;
|
---|
859 | _rv = GetDialogPort(_self->ob_itself);
|
---|
860 | _res = Py_BuildValue("O&",
|
---|
861 | GrafObj_New, _rv);
|
---|
862 | return _res;
|
---|
863 | }
|
---|
864 |
|
---|
865 | static PyMethodDef DlgObj_methods[] = {
|
---|
866 | {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1,
|
---|
867 | PyDoc_STR("() -> None")},
|
---|
868 | {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1,
|
---|
869 | PyDoc_STR("(RgnHandle updateRgn) -> None")},
|
---|
870 | {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1,
|
---|
871 | PyDoc_STR("(DialogItemIndex itemNo) -> None")},
|
---|
872 | {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1,
|
---|
873 | PyDoc_STR("(DialogItemIndex itemNo) -> None")},
|
---|
874 | {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1,
|
---|
875 | PyDoc_STR("(Point thePt) -> (DialogItemIndexZeroBased _rv)")},
|
---|
876 | {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1,
|
---|
877 | PyDoc_STR("() -> None")},
|
---|
878 | {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1,
|
---|
879 | PyDoc_STR("() -> None")},
|
---|
880 | {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1,
|
---|
881 | PyDoc_STR("() -> None")},
|
---|
882 | {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1,
|
---|
883 | PyDoc_STR("() -> None")},
|
---|
884 | {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1,
|
---|
885 | PyDoc_STR("(DialogItemIndex itemNo) -> (DialogItemType itemType, Handle item, Rect box)")},
|
---|
886 | {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1,
|
---|
887 | PyDoc_STR("(DialogItemIndex itemNo, DialogItemType itemType, Handle item, Rect box) -> None")},
|
---|
888 | {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1,
|
---|
889 | PyDoc_STR("(DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel) -> None")},
|
---|
890 | {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1,
|
---|
891 | PyDoc_STR("(Handle theHandle, DITLMethod method) -> None")},
|
---|
892 | {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1,
|
---|
893 | PyDoc_STR("() -> (DialogItemIndex _rv)")},
|
---|
894 | {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1,
|
---|
895 | PyDoc_STR("(DialogItemIndex numberItems) -> None")},
|
---|
896 | {"InsertDialogItem", (PyCFunction)DlgObj_InsertDialogItem, 1,
|
---|
897 | PyDoc_STR("(DialogItemIndex afterItem, DialogItemType itemType, Handle itemHandle, Rect box) -> None")},
|
---|
898 | {"RemoveDialogItems", (PyCFunction)DlgObj_RemoveDialogItems, 1,
|
---|
899 | PyDoc_STR("(DialogItemIndex itemNo, DialogItemIndex amountToRemove, Boolean disposeItemData) -> None")},
|
---|
900 | {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1,
|
---|
901 | PyDoc_STR("(EventRecord event, DialogItemIndex itemHit) -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)")},
|
---|
902 | {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1,
|
---|
903 | PyDoc_STR("(DialogItemIndex newItem) -> None")},
|
---|
904 | {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1,
|
---|
905 | PyDoc_STR("(DialogItemIndex newItem) -> None")},
|
---|
906 | {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1,
|
---|
907 | PyDoc_STR("(Boolean tracks) -> None")},
|
---|
908 | {"AutoSizeDialog", (PyCFunction)DlgObj_AutoSizeDialog, 1,
|
---|
909 | PyDoc_STR("() -> None")},
|
---|
910 | {"GetDialogItemAsControl", (PyCFunction)DlgObj_GetDialogItemAsControl, 1,
|
---|
911 | PyDoc_STR("(SInt16 inItemNo) -> (ControlHandle outControl)")},
|
---|
912 | {"MoveDialogItem", (PyCFunction)DlgObj_MoveDialogItem, 1,
|
---|
913 | PyDoc_STR("(SInt16 inItemNo, SInt16 inHoriz, SInt16 inVert) -> None")},
|
---|
914 | {"SizeDialogItem", (PyCFunction)DlgObj_SizeDialogItem, 1,
|
---|
915 | PyDoc_STR("(SInt16 inItemNo, SInt16 inWidth, SInt16 inHeight) -> None")},
|
---|
916 | {"AppendDialogItemList", (PyCFunction)DlgObj_AppendDialogItemList, 1,
|
---|
917 | PyDoc_STR("(SInt16 ditlID, DITLMethod method) -> None")},
|
---|
918 | {"SetDialogTimeout", (PyCFunction)DlgObj_SetDialogTimeout, 1,
|
---|
919 | PyDoc_STR("(SInt16 inButtonToPress, UInt32 inSecondsToWait) -> None")},
|
---|
920 | {"GetDialogTimeout", (PyCFunction)DlgObj_GetDialogTimeout, 1,
|
---|
921 | PyDoc_STR("() -> (SInt16 outButtonToPress, UInt32 outSecondsToWait, UInt32 outSecondsRemaining)")},
|
---|
922 | {"SetModalDialogEventMask", (PyCFunction)DlgObj_SetModalDialogEventMask, 1,
|
---|
923 | PyDoc_STR("(EventMask inMask) -> None")},
|
---|
924 | {"GetModalDialogEventMask", (PyCFunction)DlgObj_GetModalDialogEventMask, 1,
|
---|
925 | PyDoc_STR("() -> (EventMask outMask)")},
|
---|
926 | {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1,
|
---|
927 | PyDoc_STR("() -> (WindowPtr _rv)")},
|
---|
928 | {"GetDialogTextEditHandle", (PyCFunction)DlgObj_GetDialogTextEditHandle, 1,
|
---|
929 | PyDoc_STR("() -> (TEHandle _rv)")},
|
---|
930 | {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1,
|
---|
931 | PyDoc_STR("() -> (SInt16 _rv)")},
|
---|
932 | {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1,
|
---|
933 | PyDoc_STR("() -> (SInt16 _rv)")},
|
---|
934 | {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1,
|
---|
935 | PyDoc_STR("() -> (SInt16 _rv)")},
|
---|
936 | {"SetPortDialogPort", (PyCFunction)DlgObj_SetPortDialogPort, 1,
|
---|
937 | PyDoc_STR("() -> None")},
|
---|
938 | {"GetDialogPort", (PyCFunction)DlgObj_GetDialogPort, 1,
|
---|
939 | PyDoc_STR("() -> (CGrafPtr _rv)")},
|
---|
940 | {NULL, NULL, 0}
|
---|
941 | };
|
---|
942 |
|
---|
943 | #define DlgObj_getsetlist NULL
|
---|
944 |
|
---|
945 |
|
---|
946 | static int DlgObj_compare(DialogObject *self, DialogObject *other)
|
---|
947 | {
|
---|
948 | if ( self->ob_itself > other->ob_itself ) return 1;
|
---|
949 | if ( self->ob_itself < other->ob_itself ) return -1;
|
---|
950 | return 0;
|
---|
951 | }
|
---|
952 |
|
---|
953 | #define DlgObj_repr NULL
|
---|
954 |
|
---|
955 | static int DlgObj_hash(DialogObject *self)
|
---|
956 | {
|
---|
957 | return (int)self->ob_itself;
|
---|
958 | }
|
---|
959 | #define DlgObj_tp_init 0
|
---|
960 |
|
---|
961 | #define DlgObj_tp_alloc PyType_GenericAlloc
|
---|
962 |
|
---|
963 | static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
|
---|
964 | {
|
---|
965 | PyObject *_self;
|
---|
966 | DialogPtr itself;
|
---|
967 | char *kw[] = {"itself", 0};
|
---|
968 |
|
---|
969 | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL;
|
---|
970 | if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
|
---|
971 | ((DialogObject *)_self)->ob_itself = itself;
|
---|
972 | return _self;
|
---|
973 | }
|
---|
974 |
|
---|
975 | #define DlgObj_tp_free PyObject_Del
|
---|
976 |
|
---|
977 |
|
---|
978 | PyTypeObject Dialog_Type = {
|
---|
979 | PyObject_HEAD_INIT(NULL)
|
---|
980 | 0, /*ob_size*/
|
---|
981 | "_Dlg.Dialog", /*tp_name*/
|
---|
982 | sizeof(DialogObject), /*tp_basicsize*/
|
---|
983 | 0, /*tp_itemsize*/
|
---|
984 | /* methods */
|
---|
985 | (destructor) DlgObj_dealloc, /*tp_dealloc*/
|
---|
986 | 0, /*tp_print*/
|
---|
987 | (getattrfunc)0, /*tp_getattr*/
|
---|
988 | (setattrfunc)0, /*tp_setattr*/
|
---|
989 | (cmpfunc) DlgObj_compare, /*tp_compare*/
|
---|
990 | (reprfunc) DlgObj_repr, /*tp_repr*/
|
---|
991 | (PyNumberMethods *)0, /* tp_as_number */
|
---|
992 | (PySequenceMethods *)0, /* tp_as_sequence */
|
---|
993 | (PyMappingMethods *)0, /* tp_as_mapping */
|
---|
994 | (hashfunc) DlgObj_hash, /*tp_hash*/
|
---|
995 | 0, /*tp_call*/
|
---|
996 | 0, /*tp_str*/
|
---|
997 | PyObject_GenericGetAttr, /*tp_getattro*/
|
---|
998 | PyObject_GenericSetAttr, /*tp_setattro */
|
---|
999 | 0, /*tp_as_buffer*/
|
---|
1000 | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
---|
1001 | 0, /*tp_doc*/
|
---|
1002 | 0, /*tp_traverse*/
|
---|
1003 | 0, /*tp_clear*/
|
---|
1004 | 0, /*tp_richcompare*/
|
---|
1005 | 0, /*tp_weaklistoffset*/
|
---|
1006 | 0, /*tp_iter*/
|
---|
1007 | 0, /*tp_iternext*/
|
---|
1008 | DlgObj_methods, /* tp_methods */
|
---|
1009 | 0, /*tp_members*/
|
---|
1010 | DlgObj_getsetlist, /*tp_getset*/
|
---|
1011 | 0, /*tp_base*/
|
---|
1012 | 0, /*tp_dict*/
|
---|
1013 | 0, /*tp_descr_get*/
|
---|
1014 | 0, /*tp_descr_set*/
|
---|
1015 | 0, /*tp_dictoffset*/
|
---|
1016 | DlgObj_tp_init, /* tp_init */
|
---|
1017 | DlgObj_tp_alloc, /* tp_alloc */
|
---|
1018 | DlgObj_tp_new, /* tp_new */
|
---|
1019 | DlgObj_tp_free, /* tp_free */
|
---|
1020 | };
|
---|
1021 |
|
---|
1022 | /* --------------------- End object type Dialog --------------------- */
|
---|
1023 |
|
---|
1024 |
|
---|
1025 | static PyObject *Dlg_NewDialog(PyObject *_self, PyObject *_args)
|
---|
1026 | {
|
---|
1027 | PyObject *_res = NULL;
|
---|
1028 | DialogPtr _rv;
|
---|
1029 | Rect boundsRect;
|
---|
1030 | Str255 title;
|
---|
1031 | Boolean visible;
|
---|
1032 | SInt16 procID;
|
---|
1033 | WindowPtr behind;
|
---|
1034 | Boolean goAwayFlag;
|
---|
1035 | SInt32 refCon;
|
---|
1036 | Handle items;
|
---|
1037 | #ifndef NewDialog
|
---|
1038 | PyMac_PRECHECK(NewDialog);
|
---|
1039 | #endif
|
---|
1040 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
|
---|
1041 | PyMac_GetRect, &boundsRect,
|
---|
1042 | PyMac_GetStr255, title,
|
---|
1043 | &visible,
|
---|
1044 | &procID,
|
---|
1045 | WinObj_Convert, &behind,
|
---|
1046 | &goAwayFlag,
|
---|
1047 | &refCon,
|
---|
1048 | ResObj_Convert, &items))
|
---|
1049 | return NULL;
|
---|
1050 | _rv = NewDialog((void *)0,
|
---|
1051 | &boundsRect,
|
---|
1052 | title,
|
---|
1053 | visible,
|
---|
1054 | procID,
|
---|
1055 | behind,
|
---|
1056 | goAwayFlag,
|
---|
1057 | refCon,
|
---|
1058 | items);
|
---|
1059 | _res = Py_BuildValue("O&",
|
---|
1060 | DlgObj_New, _rv);
|
---|
1061 | return _res;
|
---|
1062 | }
|
---|
1063 |
|
---|
1064 | static PyObject *Dlg_GetNewDialog(PyObject *_self, PyObject *_args)
|
---|
1065 | {
|
---|
1066 | PyObject *_res = NULL;
|
---|
1067 | DialogPtr _rv;
|
---|
1068 | SInt16 dialogID;
|
---|
1069 | WindowPtr behind;
|
---|
1070 | #ifndef GetNewDialog
|
---|
1071 | PyMac_PRECHECK(GetNewDialog);
|
---|
1072 | #endif
|
---|
1073 | if (!PyArg_ParseTuple(_args, "hO&",
|
---|
1074 | &dialogID,
|
---|
1075 | WinObj_Convert, &behind))
|
---|
1076 | return NULL;
|
---|
1077 | _rv = GetNewDialog(dialogID,
|
---|
1078 | (void *)0,
|
---|
1079 | behind);
|
---|
1080 | _res = Py_BuildValue("O&",
|
---|
1081 | DlgObj_New, _rv);
|
---|
1082 | return _res;
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | static PyObject *Dlg_NewColorDialog(PyObject *_self, PyObject *_args)
|
---|
1086 | {
|
---|
1087 | PyObject *_res = NULL;
|
---|
1088 | DialogPtr _rv;
|
---|
1089 | Rect boundsRect;
|
---|
1090 | Str255 title;
|
---|
1091 | Boolean visible;
|
---|
1092 | SInt16 procID;
|
---|
1093 | WindowPtr behind;
|
---|
1094 | Boolean goAwayFlag;
|
---|
1095 | SInt32 refCon;
|
---|
1096 | Handle items;
|
---|
1097 | #ifndef NewColorDialog
|
---|
1098 | PyMac_PRECHECK(NewColorDialog);
|
---|
1099 | #endif
|
---|
1100 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
|
---|
1101 | PyMac_GetRect, &boundsRect,
|
---|
1102 | PyMac_GetStr255, title,
|
---|
1103 | &visible,
|
---|
1104 | &procID,
|
---|
1105 | WinObj_Convert, &behind,
|
---|
1106 | &goAwayFlag,
|
---|
1107 | &refCon,
|
---|
1108 | ResObj_Convert, &items))
|
---|
1109 | return NULL;
|
---|
1110 | _rv = NewColorDialog((void *)0,
|
---|
1111 | &boundsRect,
|
---|
1112 | title,
|
---|
1113 | visible,
|
---|
1114 | procID,
|
---|
1115 | behind,
|
---|
1116 | goAwayFlag,
|
---|
1117 | refCon,
|
---|
1118 | items);
|
---|
1119 | _res = Py_BuildValue("O&",
|
---|
1120 | DlgObj_New, _rv);
|
---|
1121 | return _res;
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 | static PyObject *Dlg_ModalDialog(PyObject *_self, PyObject *_args)
|
---|
1125 | {
|
---|
1126 | PyObject *_res = NULL;
|
---|
1127 | PyObject* modalFilter;
|
---|
1128 | DialogItemIndex itemHit;
|
---|
1129 | #ifndef ModalDialog
|
---|
1130 | PyMac_PRECHECK(ModalDialog);
|
---|
1131 | #endif
|
---|
1132 | if (!PyArg_ParseTuple(_args, "O",
|
---|
1133 | &modalFilter))
|
---|
1134 | return NULL;
|
---|
1135 | ModalDialog(Dlg_PassFilterProc(modalFilter),
|
---|
1136 | &itemHit);
|
---|
1137 | _res = Py_BuildValue("h",
|
---|
1138 | itemHit);
|
---|
1139 | return _res;
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 | static PyObject *Dlg_IsDialogEvent(PyObject *_self, PyObject *_args)
|
---|
1143 | {
|
---|
1144 | PyObject *_res = NULL;
|
---|
1145 | Boolean _rv;
|
---|
1146 | EventRecord theEvent;
|
---|
1147 | #ifndef IsDialogEvent
|
---|
1148 | PyMac_PRECHECK(IsDialogEvent);
|
---|
1149 | #endif
|
---|
1150 | if (!PyArg_ParseTuple(_args, "O&",
|
---|
1151 | PyMac_GetEventRecord, &theEvent))
|
---|
1152 | return NULL;
|
---|
1153 | _rv = IsDialogEvent(&theEvent);
|
---|
1154 | _res = Py_BuildValue("b",
|
---|
1155 | _rv);
|
---|
1156 | return _res;
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | static PyObject *Dlg_DialogSelect(PyObject *_self, PyObject *_args)
|
---|
1160 | {
|
---|
1161 | PyObject *_res = NULL;
|
---|
1162 | Boolean _rv;
|
---|
1163 | EventRecord theEvent;
|
---|
1164 | DialogPtr theDialog;
|
---|
1165 | DialogItemIndex itemHit;
|
---|
1166 | #ifndef DialogSelect
|
---|
1167 | PyMac_PRECHECK(DialogSelect);
|
---|
1168 | #endif
|
---|
1169 | if (!PyArg_ParseTuple(_args, "O&",
|
---|
1170 | PyMac_GetEventRecord, &theEvent))
|
---|
1171 | return NULL;
|
---|
1172 | _rv = DialogSelect(&theEvent,
|
---|
1173 | &theDialog,
|
---|
1174 | &itemHit);
|
---|
1175 | _res = Py_BuildValue("bO&h",
|
---|
1176 | _rv,
|
---|
1177 | DlgObj_WhichDialog, theDialog,
|
---|
1178 | itemHit);
|
---|
1179 | return _res;
|
---|
1180 | }
|
---|
1181 |
|
---|
1182 | static PyObject *Dlg_Alert(PyObject *_self, PyObject *_args)
|
---|
1183 | {
|
---|
1184 | PyObject *_res = NULL;
|
---|
1185 | DialogItemIndex _rv;
|
---|
1186 | SInt16 alertID;
|
---|
1187 | PyObject* modalFilter;
|
---|
1188 | #ifndef Alert
|
---|
1189 | PyMac_PRECHECK(Alert);
|
---|
1190 | #endif
|
---|
1191 | if (!PyArg_ParseTuple(_args, "hO",
|
---|
1192 | &alertID,
|
---|
1193 | &modalFilter))
|
---|
1194 | return NULL;
|
---|
1195 | _rv = Alert(alertID,
|
---|
1196 | Dlg_PassFilterProc(modalFilter));
|
---|
1197 | _res = Py_BuildValue("h",
|
---|
1198 | _rv);
|
---|
1199 | return _res;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | static PyObject *Dlg_StopAlert(PyObject *_self, PyObject *_args)
|
---|
1203 | {
|
---|
1204 | PyObject *_res = NULL;
|
---|
1205 | DialogItemIndex _rv;
|
---|
1206 | SInt16 alertID;
|
---|
1207 | PyObject* modalFilter;
|
---|
1208 | #ifndef StopAlert
|
---|
1209 | PyMac_PRECHECK(StopAlert);
|
---|
1210 | #endif
|
---|
1211 | if (!PyArg_ParseTuple(_args, "hO",
|
---|
1212 | &alertID,
|
---|
1213 | &modalFilter))
|
---|
1214 | return NULL;
|
---|
1215 | _rv = StopAlert(alertID,
|
---|
1216 | Dlg_PassFilterProc(modalFilter));
|
---|
1217 | _res = Py_BuildValue("h",
|
---|
1218 | _rv);
|
---|
1219 | return _res;
|
---|
1220 | }
|
---|
1221 |
|
---|
1222 | static PyObject *Dlg_NoteAlert(PyObject *_self, PyObject *_args)
|
---|
1223 | {
|
---|
1224 | PyObject *_res = NULL;
|
---|
1225 | DialogItemIndex _rv;
|
---|
1226 | SInt16 alertID;
|
---|
1227 | PyObject* modalFilter;
|
---|
1228 | #ifndef NoteAlert
|
---|
1229 | PyMac_PRECHECK(NoteAlert);
|
---|
1230 | #endif
|
---|
1231 | if (!PyArg_ParseTuple(_args, "hO",
|
---|
1232 | &alertID,
|
---|
1233 | &modalFilter))
|
---|
1234 | return NULL;
|
---|
1235 | _rv = NoteAlert(alertID,
|
---|
1236 | Dlg_PassFilterProc(modalFilter));
|
---|
1237 | _res = Py_BuildValue("h",
|
---|
1238 | _rv);
|
---|
1239 | return _res;
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | static PyObject *Dlg_CautionAlert(PyObject *_self, PyObject *_args)
|
---|
1243 | {
|
---|
1244 | PyObject *_res = NULL;
|
---|
1245 | DialogItemIndex _rv;
|
---|
1246 | SInt16 alertID;
|
---|
1247 | PyObject* modalFilter;
|
---|
1248 | #ifndef CautionAlert
|
---|
1249 | PyMac_PRECHECK(CautionAlert);
|
---|
1250 | #endif
|
---|
1251 | if (!PyArg_ParseTuple(_args, "hO",
|
---|
1252 | &alertID,
|
---|
1253 | &modalFilter))
|
---|
1254 | return NULL;
|
---|
1255 | _rv = CautionAlert(alertID,
|
---|
1256 | Dlg_PassFilterProc(modalFilter));
|
---|
1257 | _res = Py_BuildValue("h",
|
---|
1258 | _rv);
|
---|
1259 | return _res;
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | static PyObject *Dlg_ParamText(PyObject *_self, PyObject *_args)
|
---|
1263 | {
|
---|
1264 | PyObject *_res = NULL;
|
---|
1265 | Str255 param0;
|
---|
1266 | Str255 param1;
|
---|
1267 | Str255 param2;
|
---|
1268 | Str255 param3;
|
---|
1269 | #ifndef ParamText
|
---|
1270 | PyMac_PRECHECK(ParamText);
|
---|
1271 | #endif
|
---|
1272 | if (!PyArg_ParseTuple(_args, "O&O&O&O&",
|
---|
1273 | PyMac_GetStr255, param0,
|
---|
1274 | PyMac_GetStr255, param1,
|
---|
1275 | PyMac_GetStr255, param2,
|
---|
1276 | PyMac_GetStr255, param3))
|
---|
1277 | return NULL;
|
---|
1278 | ParamText(param0,
|
---|
1279 | param1,
|
---|
1280 | param2,
|
---|
1281 | param3);
|
---|
1282 | Py_INCREF(Py_None);
|
---|
1283 | _res = Py_None;
|
---|
1284 | return _res;
|
---|
1285 | }
|
---|
1286 |
|
---|
1287 | static PyObject *Dlg_GetDialogItemText(PyObject *_self, PyObject *_args)
|
---|
1288 | {
|
---|
1289 | PyObject *_res = NULL;
|
---|
1290 | Handle item;
|
---|
1291 | Str255 text;
|
---|
1292 | #ifndef GetDialogItemText
|
---|
1293 | PyMac_PRECHECK(GetDialogItemText);
|
---|
1294 | #endif
|
---|
1295 | if (!PyArg_ParseTuple(_args, "O&",
|
---|
1296 | ResObj_Convert, &item))
|
---|
1297 | return NULL;
|
---|
1298 | GetDialogItemText(item,
|
---|
1299 | text);
|
---|
1300 | _res = Py_BuildValue("O&",
|
---|
1301 | PyMac_BuildStr255, text);
|
---|
1302 | return _res;
|
---|
1303 | }
|
---|
1304 |
|
---|
1305 | static PyObject *Dlg_SetDialogItemText(PyObject *_self, PyObject *_args)
|
---|
1306 | {
|
---|
1307 | PyObject *_res = NULL;
|
---|
1308 | Handle item;
|
---|
1309 | Str255 text;
|
---|
1310 | #ifndef SetDialogItemText
|
---|
1311 | PyMac_PRECHECK(SetDialogItemText);
|
---|
1312 | #endif
|
---|
1313 | if (!PyArg_ParseTuple(_args, "O&O&",
|
---|
1314 | ResObj_Convert, &item,
|
---|
1315 | PyMac_GetStr255, text))
|
---|
1316 | return NULL;
|
---|
1317 | SetDialogItemText(item,
|
---|
1318 | text);
|
---|
1319 | Py_INCREF(Py_None);
|
---|
1320 | _res = Py_None;
|
---|
1321 | return _res;
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 | static PyObject *Dlg_GetAlertStage(PyObject *_self, PyObject *_args)
|
---|
1325 | {
|
---|
1326 | PyObject *_res = NULL;
|
---|
1327 | SInt16 _rv;
|
---|
1328 | #ifndef GetAlertStage
|
---|
1329 | PyMac_PRECHECK(GetAlertStage);
|
---|
1330 | #endif
|
---|
1331 | if (!PyArg_ParseTuple(_args, ""))
|
---|
1332 | return NULL;
|
---|
1333 | _rv = GetAlertStage();
|
---|
1334 | _res = Py_BuildValue("h",
|
---|
1335 | _rv);
|
---|
1336 | return _res;
|
---|
1337 | }
|
---|
1338 |
|
---|
1339 | static PyObject *Dlg_SetDialogFont(PyObject *_self, PyObject *_args)
|
---|
1340 | {
|
---|
1341 | PyObject *_res = NULL;
|
---|
1342 | SInt16 fontNum;
|
---|
1343 | #ifndef SetDialogFont
|
---|
1344 | PyMac_PRECHECK(SetDialogFont);
|
---|
1345 | #endif
|
---|
1346 | if (!PyArg_ParseTuple(_args, "h",
|
---|
1347 | &fontNum))
|
---|
1348 | return NULL;
|
---|
1349 | SetDialogFont(fontNum);
|
---|
1350 | Py_INCREF(Py_None);
|
---|
1351 | _res = Py_None;
|
---|
1352 | return _res;
|
---|
1353 | }
|
---|
1354 |
|
---|
1355 | static PyObject *Dlg_ResetAlertStage(PyObject *_self, PyObject *_args)
|
---|
1356 | {
|
---|
1357 | PyObject *_res = NULL;
|
---|
1358 | #ifndef ResetAlertStage
|
---|
1359 | PyMac_PRECHECK(ResetAlertStage);
|
---|
1360 | #endif
|
---|
1361 | if (!PyArg_ParseTuple(_args, ""))
|
---|
1362 | return NULL;
|
---|
1363 | ResetAlertStage();
|
---|
1364 | Py_INCREF(Py_None);
|
---|
1365 | _res = Py_None;
|
---|
1366 | return _res;
|
---|
1367 | }
|
---|
1368 |
|
---|
1369 | static PyObject *Dlg_GetParamText(PyObject *_self, PyObject *_args)
|
---|
1370 | {
|
---|
1371 | PyObject *_res = NULL;
|
---|
1372 | Str255 param0;
|
---|
1373 | Str255 param1;
|
---|
1374 | Str255 param2;
|
---|
1375 | Str255 param3;
|
---|
1376 | #ifndef GetParamText
|
---|
1377 | PyMac_PRECHECK(GetParamText);
|
---|
1378 | #endif
|
---|
1379 | if (!PyArg_ParseTuple(_args, "O&O&O&O&",
|
---|
1380 | PyMac_GetStr255, param0,
|
---|
1381 | PyMac_GetStr255, param1,
|
---|
1382 | PyMac_GetStr255, param2,
|
---|
1383 | PyMac_GetStr255, param3))
|
---|
1384 | return NULL;
|
---|
1385 | GetParamText(param0,
|
---|
1386 | param1,
|
---|
1387 | param2,
|
---|
1388 | param3);
|
---|
1389 | Py_INCREF(Py_None);
|
---|
1390 | _res = Py_None;
|
---|
1391 | return _res;
|
---|
1392 | }
|
---|
1393 |
|
---|
1394 | static PyObject *Dlg_NewFeaturesDialog(PyObject *_self, PyObject *_args)
|
---|
1395 | {
|
---|
1396 | PyObject *_res = NULL;
|
---|
1397 | DialogPtr _rv;
|
---|
1398 | Rect inBoundsRect;
|
---|
1399 | Str255 inTitle;
|
---|
1400 | Boolean inIsVisible;
|
---|
1401 | SInt16 inProcID;
|
---|
1402 | WindowPtr inBehind;
|
---|
1403 | Boolean inGoAwayFlag;
|
---|
1404 | SInt32 inRefCon;
|
---|
1405 | Handle inItemListHandle;
|
---|
1406 | UInt32 inFlags;
|
---|
1407 | #ifndef NewFeaturesDialog
|
---|
1408 | PyMac_PRECHECK(NewFeaturesDialog);
|
---|
1409 | #endif
|
---|
1410 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&l",
|
---|
1411 | PyMac_GetRect, &inBoundsRect,
|
---|
1412 | PyMac_GetStr255, inTitle,
|
---|
1413 | &inIsVisible,
|
---|
1414 | &inProcID,
|
---|
1415 | WinObj_Convert, &inBehind,
|
---|
1416 | &inGoAwayFlag,
|
---|
1417 | &inRefCon,
|
---|
1418 | ResObj_Convert, &inItemListHandle,
|
---|
1419 | &inFlags))
|
---|
1420 | return NULL;
|
---|
1421 | _rv = NewFeaturesDialog((void *)0,
|
---|
1422 | &inBoundsRect,
|
---|
1423 | inTitle,
|
---|
1424 | inIsVisible,
|
---|
1425 | inProcID,
|
---|
1426 | inBehind,
|
---|
1427 | inGoAwayFlag,
|
---|
1428 | inRefCon,
|
---|
1429 | inItemListHandle,
|
---|
1430 | inFlags);
|
---|
1431 | _res = Py_BuildValue("O&",
|
---|
1432 | DlgObj_New, _rv);
|
---|
1433 | return _res;
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | static PyObject *Dlg_GetDialogFromWindow(PyObject *_self, PyObject *_args)
|
---|
1437 | {
|
---|
1438 | PyObject *_res = NULL;
|
---|
1439 | DialogPtr _rv;
|
---|
1440 | WindowPtr window;
|
---|
1441 | #ifndef GetDialogFromWindow
|
---|
1442 | PyMac_PRECHECK(GetDialogFromWindow);
|
---|
1443 | #endif
|
---|
1444 | if (!PyArg_ParseTuple(_args, "O&",
|
---|
1445 | WinObj_Convert, &window))
|
---|
1446 | return NULL;
|
---|
1447 | _rv = GetDialogFromWindow(window);
|
---|
1448 | _res = Py_BuildValue("O&",
|
---|
1449 | DlgObj_New, _rv);
|
---|
1450 | return _res;
|
---|
1451 | }
|
---|
1452 |
|
---|
1453 | static PyObject *Dlg_SetUserItemHandler(PyObject *_self, PyObject *_args)
|
---|
1454 | {
|
---|
1455 | PyObject *_res = NULL;
|
---|
1456 |
|
---|
1457 | PyObject *new = NULL;
|
---|
1458 |
|
---|
1459 |
|
---|
1460 | if (!PyArg_ParseTuple(_args, "|O", &new))
|
---|
1461 | return NULL;
|
---|
1462 |
|
---|
1463 | if (Dlg_UserItemProc_callback && new && new != Py_None) {
|
---|
1464 | PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
|
---|
1465 | return NULL;
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | if (new == NULL || new == Py_None) {
|
---|
1469 | new = NULL;
|
---|
1470 | _res = Py_None;
|
---|
1471 | Py_INCREF(Py_None);
|
---|
1472 | } else {
|
---|
1473 | Py_INCREF(new);
|
---|
1474 | _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc));
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 | Dlg_UserItemProc_callback = new;
|
---|
1478 | return _res;
|
---|
1479 |
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | static PyMethodDef Dlg_methods[] = {
|
---|
1483 | {"NewDialog", (PyCFunction)Dlg_NewDialog, 1,
|
---|
1484 | PyDoc_STR("(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)")},
|
---|
1485 | {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1,
|
---|
1486 | PyDoc_STR("(SInt16 dialogID, WindowPtr behind) -> (DialogPtr _rv)")},
|
---|
1487 | {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1,
|
---|
1488 | PyDoc_STR("(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)")},
|
---|
1489 | {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1,
|
---|
1490 | PyDoc_STR("(PyObject* modalFilter) -> (DialogItemIndex itemHit)")},
|
---|
1491 | {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1,
|
---|
1492 | PyDoc_STR("(EventRecord theEvent) -> (Boolean _rv)")},
|
---|
1493 | {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1,
|
---|
1494 | PyDoc_STR("(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, DialogItemIndex itemHit)")},
|
---|
1495 | {"Alert", (PyCFunction)Dlg_Alert, 1,
|
---|
1496 | PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
---|
1497 | {"StopAlert", (PyCFunction)Dlg_StopAlert, 1,
|
---|
1498 | PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
---|
1499 | {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1,
|
---|
1500 | PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
---|
1501 | {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1,
|
---|
1502 | PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
---|
1503 | {"ParamText", (PyCFunction)Dlg_ParamText, 1,
|
---|
1504 | PyDoc_STR("(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None")},
|
---|
1505 | {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1,
|
---|
1506 | PyDoc_STR("(Handle item) -> (Str255 text)")},
|
---|
1507 | {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1,
|
---|
1508 | PyDoc_STR("(Handle item, Str255 text) -> None")},
|
---|
1509 | {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1,
|
---|
1510 | PyDoc_STR("() -> (SInt16 _rv)")},
|
---|
1511 | {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1,
|
---|
1512 | PyDoc_STR("(SInt16 fontNum) -> None")},
|
---|
1513 | {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1,
|
---|
1514 | PyDoc_STR("() -> None")},
|
---|
1515 | {"GetParamText", (PyCFunction)Dlg_GetParamText, 1,
|
---|
1516 | PyDoc_STR("(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None")},
|
---|
1517 | {"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1,
|
---|
1518 | PyDoc_STR("(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)")},
|
---|
1519 | {"GetDialogFromWindow", (PyCFunction)Dlg_GetDialogFromWindow, 1,
|
---|
1520 | PyDoc_STR("(WindowPtr window) -> (DialogPtr _rv)")},
|
---|
1521 | {"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1,
|
---|
1522 | PyDoc_STR(NULL)},
|
---|
1523 | {NULL, NULL, 0}
|
---|
1524 | };
|
---|
1525 |
|
---|
1526 |
|
---|
1527 |
|
---|
1528 | /* Return the WindowPtr corresponding to a DialogObject */
|
---|
1529 | #if 0
|
---|
1530 | WindowPtr
|
---|
1531 | DlgObj_ConvertToWindow(PyObject *self)
|
---|
1532 | {
|
---|
1533 | if ( DlgObj_Check(self) )
|
---|
1534 | return GetDialogWindow(((DialogObject *)self)->ob_itself);
|
---|
1535 | return NULL;
|
---|
1536 | }
|
---|
1537 | #endif
|
---|
1538 | /* Return the object corresponding to the dialog, or None */
|
---|
1539 |
|
---|
1540 | PyObject *
|
---|
1541 | DlgObj_WhichDialog(DialogPtr d)
|
---|
1542 | {
|
---|
1543 | PyObject *it;
|
---|
1544 |
|
---|
1545 | if (d == NULL) {
|
---|
1546 | it = Py_None;
|
---|
1547 | Py_INCREF(it);
|
---|
1548 | } else {
|
---|
1549 | WindowPtr w = GetDialogWindow(d);
|
---|
1550 |
|
---|
1551 | it = (PyObject *) GetWRefCon(w);
|
---|
1552 | if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) {
|
---|
1553 | #if 0
|
---|
1554 | /* Should do this, but we don't have an ob_freeit for dialogs yet. */
|
---|
1555 | it = WinObj_New(w);
|
---|
1556 | ((WindowObject *)it)->ob_freeit = NULL;
|
---|
1557 | #else
|
---|
1558 | it = Py_None;
|
---|
1559 | Py_INCREF(it);
|
---|
1560 | #endif
|
---|
1561 | } else {
|
---|
1562 | Py_INCREF(it);
|
---|
1563 | }
|
---|
1564 | }
|
---|
1565 | return it;
|
---|
1566 | }
|
---|
1567 |
|
---|
1568 | #else /* __LP64__ */
|
---|
1569 |
|
---|
1570 | static PyMethodDef Dlg_methods[] = {
|
---|
1571 | {NULL, NULL, 0}
|
---|
1572 | };
|
---|
1573 |
|
---|
1574 | #endif /* __LP64__ */
|
---|
1575 |
|
---|
1576 |
|
---|
1577 | void init_Dlg(void)
|
---|
1578 | {
|
---|
1579 | PyObject *m;
|
---|
1580 | #ifndef __LP64__
|
---|
1581 | PyObject *d;
|
---|
1582 |
|
---|
1583 |
|
---|
1584 |
|
---|
1585 | PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New);
|
---|
1586 | PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog);
|
---|
1587 | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert);
|
---|
1588 | #endif /* !__LP64__ */
|
---|
1589 |
|
---|
1590 | m = Py_InitModule("_Dlg", Dlg_methods);
|
---|
1591 |
|
---|
1592 | #ifndef __LP64__
|
---|
1593 | d = PyModule_GetDict(m);
|
---|
1594 | Dlg_Error = PyMac_GetOSErrException();
|
---|
1595 | if (Dlg_Error == NULL ||
|
---|
1596 | PyDict_SetItemString(d, "Error", Dlg_Error) != 0)
|
---|
1597 | return;
|
---|
1598 | Dialog_Type.ob_type = &PyType_Type;
|
---|
1599 | if (PyType_Ready(&Dialog_Type) < 0) return;
|
---|
1600 | Py_INCREF(&Dialog_Type);
|
---|
1601 | PyModule_AddObject(m, "Dialog", (PyObject *)&Dialog_Type);
|
---|
1602 | /* Backward-compatible name */
|
---|
1603 | Py_INCREF(&Dialog_Type);
|
---|
1604 | PyModule_AddObject(m, "DialogType", (PyObject *)&Dialog_Type);
|
---|
1605 | #endif /* !__LP64__ */
|
---|
1606 | }
|
---|
1607 |
|
---|
1608 | /* ======================== End module _Dlg ========================= */
|
---|
1609 |
|
---|