2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
/* ========================== Module _Dlg =========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
#include "pymactoolbox.h"
|
|
|
|
|
2016-09-16 10:08:45 -03:00
|
|
|
#if APPLE_SUPPORTS_QUICKTIME
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
/* Macro to test whether a weak-loaded CFM function exists */
|
|
|
|
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
2010-05-09 11:46:46 -03:00
|
|
|
PyErr_SetString(PyExc_NotImplementedError, \
|
|
|
|
"Not available in this shared library/OS version"); \
|
|
|
|
return NULL; \
|
2001-08-23 11:02:09 -03:00
|
|
|
}} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
|
|
|
|
#ifdef USE_TOOLBOX_OBJECT_GLUE
|
|
|
|
extern PyObject *_DlgObj_New(DialogRef);
|
|
|
|
extern PyObject *_DlgObj_WhichDialog(DialogRef);
|
|
|
|
extern int _DlgObj_Convert(PyObject *, DialogRef *);
|
|
|
|
|
|
|
|
#define DlgObj_New _DlgObj_New
|
|
|
|
#define DlgObj_WhichDialog _DlgObj_WhichDialog
|
|
|
|
#define DlgObj_Convert _DlgObj_Convert
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* XXX Shouldn't this be a stack? */
|
|
|
|
static PyObject *Dlg_FilterProc_callback = NULL;
|
|
|
|
|
|
|
|
static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
|
|
|
|
EventRecord *event,
|
|
|
|
short *itemHit)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
Boolean rv;
|
|
|
|
PyObject *args, *res;
|
|
|
|
PyObject *callback = Dlg_FilterProc_callback;
|
|
|
|
if (callback == NULL)
|
|
|
|
return 0; /* Default behavior */
|
|
|
|
Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
|
|
|
|
args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event);
|
|
|
|
if (args == NULL)
|
|
|
|
res = NULL;
|
|
|
|
else {
|
|
|
|
res = PyEval_CallObject(callback, args);
|
|
|
|
Py_DECREF(args);
|
|
|
|
}
|
|
|
|
if (res == NULL) {
|
|
|
|
PySys_WriteStderr("Exception in Dialog Filter\n");
|
|
|
|
PyErr_Print();
|
|
|
|
*itemHit = -1; /* Fake return item */
|
|
|
|
return 1; /* We handled it */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Dlg_FilterProc_callback = callback;
|
|
|
|
if (PyInt_Check(res)) {
|
|
|
|
*itemHit = PyInt_AsLong(res);
|
|
|
|
rv = 1;
|
2005-07-03 17:59:44 -03:00
|
|
|
}
|
2010-05-09 11:46:46 -03:00
|
|
|
else
|
|
|
|
rv = PyObject_IsTrue(res);
|
|
|
|
}
|
|
|
|
Py_DECREF(res);
|
|
|
|
return rv;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static ModalFilterUPP
|
|
|
|
Dlg_PassFilterProc(PyObject *callback)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *tmp = Dlg_FilterProc_callback;
|
|
|
|
static ModalFilterUPP UnivFilterUpp = NULL;
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
Dlg_FilterProc_callback = NULL;
|
|
|
|
if (callback == Py_None) {
|
2005-07-03 17:59:44 -03:00
|
|
|
Py_XDECREF(tmp);
|
2010-05-09 11:46:46 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_INCREF(callback);
|
|
|
|
Dlg_FilterProc_callback = callback;
|
|
|
|
Py_XDECREF(tmp);
|
|
|
|
if ( UnivFilterUpp == NULL )
|
|
|
|
UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
|
|
|
|
return UnivFilterUpp;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_UserItemProc_callback = NULL;
|
|
|
|
|
|
|
|
static pascal void Dlg_UnivUserItemProc(DialogPtr dialog,
|
|
|
|
short item)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *args, *res;
|
|
|
|
|
|
|
|
if (Dlg_UserItemProc_callback == NULL)
|
|
|
|
return; /* Default behavior */
|
|
|
|
Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
|
|
|
|
args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item);
|
|
|
|
if (args == NULL)
|
|
|
|
res = NULL;
|
|
|
|
else {
|
|
|
|
res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
|
|
|
|
Py_DECREF(args);
|
|
|
|
}
|
|
|
|
if (res == NULL) {
|
|
|
|
PySys_WriteStderr("Exception in Dialog UserItem proc\n");
|
|
|
|
PyErr_Print();
|
|
|
|
}
|
|
|
|
Py_XDECREF(res);
|
|
|
|
return;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
** Treating DialogObjects as WindowObjects is (I think) illegal under Carbon.
|
|
|
|
** However, as they are still identical under MacOS9 Carbon this is a problem, even
|
|
|
|
** if we neatly call GetDialogWindow() at the right places: there's one refcon field
|
|
|
|
** and it points to the DialogObject, so WinObj_WhichWindow will smartly return the
|
|
|
|
** dialog object, and therefore we still don't have a WindowObject.
|
|
|
|
** I'll leave the chaining code in place for now, with this comment to warn the
|
|
|
|
** unsuspecting victims (i.e. me, probably, in a few weeks:-)
|
|
|
|
*/
|
|
|
|
extern PyMethodChain WinObj_chain;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static PyObject *Dlg_Error;
|
|
|
|
|
|
|
|
/* ----------------------- Object type Dialog ----------------------- */
|
|
|
|
|
|
|
|
PyTypeObject Dialog_Type;
|
|
|
|
|
2002-12-19 17:24:35 -04:00
|
|
|
#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type || PyObject_TypeCheck((x), &Dialog_Type))
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
typedef struct DialogObject {
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject_HEAD
|
|
|
|
DialogPtr ob_itself;
|
2001-08-23 11:02:09 -03:00
|
|
|
} DialogObject;
|
|
|
|
|
|
|
|
PyObject *DlgObj_New(DialogPtr itself)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
DialogObject *it;
|
|
|
|
if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }
|
|
|
|
it = PyObject_NEW(DialogObject, &Dialog_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
|
|
|
SetWRefCon(GetDialogWindow(itself), (long)it);
|
|
|
|
return (PyObject *)it;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2001-09-04 19:19:18 -03:00
|
|
|
int DlgObj_Convert(PyObject *v, DialogPtr *p_itself)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
if (v == Py_None) { *p_itself = NULL; return 1; }
|
|
|
|
if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);
|
|
|
|
return 1; }
|
|
|
|
if (!DlgObj_Check(v))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Dialog required");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*p_itself = ((DialogObject *)v)->ob_itself;
|
|
|
|
return 1;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void DlgObj_dealloc(DialogObject *self)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
DisposeDialog(self->ob_itself);
|
|
|
|
self->ob_type->tp_free((PyObject *)self);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_DrawDialog(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef DrawDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(DrawDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
DrawDialog(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_UpdateDialog(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
RgnHandle updateRgn;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef UpdateDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(UpdateDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &updateRgn))
|
|
|
|
return NULL;
|
|
|
|
UpdateDialog(_self->ob_itself,
|
|
|
|
updateRgn);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_HideDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex itemNo;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef HideDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(HideDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&itemNo))
|
|
|
|
return NULL;
|
|
|
|
HideDialogItem(_self->ob_itself,
|
|
|
|
itemNo);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_ShowDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex itemNo;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef ShowDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(ShowDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&itemNo))
|
|
|
|
return NULL;
|
|
|
|
ShowDialogItem(_self->ob_itself,
|
|
|
|
itemNo);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_FindDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndexZeroBased _rv;
|
|
|
|
Point thePt;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef FindDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(FindDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetPoint, &thePt))
|
|
|
|
return NULL;
|
|
|
|
_rv = FindDialogItem(_self->ob_itself,
|
|
|
|
thePt);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_DialogCut(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef DialogCut
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(DialogCut);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
DialogCut(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_DialogPaste(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef DialogPaste
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(DialogPaste);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
DialogPaste(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_DialogCopy(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef DialogCopy
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(DialogCopy);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
DialogCopy(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_DialogDelete(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef DialogDelete
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(DialogDelete);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
DialogDelete(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex itemNo;
|
|
|
|
DialogItemType itemType;
|
|
|
|
Handle item;
|
|
|
|
Rect box;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&itemNo))
|
|
|
|
return NULL;
|
|
|
|
GetDialogItem(_self->ob_itself,
|
|
|
|
itemNo,
|
|
|
|
&itemType,
|
|
|
|
&item,
|
|
|
|
&box);
|
|
|
|
_res = Py_BuildValue("hO&O&",
|
|
|
|
itemType,
|
|
|
|
OptResObj_New, item,
|
|
|
|
PyMac_BuildRect, &box);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex itemNo;
|
|
|
|
DialogItemType itemType;
|
|
|
|
Handle item;
|
|
|
|
Rect box;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hhO&O&",
|
|
|
|
&itemNo,
|
|
|
|
&itemType,
|
|
|
|
ResObj_Convert, &item,
|
|
|
|
PyMac_GetRect, &box))
|
|
|
|
return NULL;
|
|
|
|
SetDialogItem(_self->ob_itself,
|
|
|
|
itemNo,
|
|
|
|
itemType,
|
|
|
|
item,
|
|
|
|
&box);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SelectDialogItemText(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex itemNo;
|
|
|
|
SInt16 strtSel;
|
|
|
|
SInt16 endSel;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SelectDialogItemText
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SelectDialogItemText);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hhh",
|
|
|
|
&itemNo,
|
|
|
|
&strtSel,
|
|
|
|
&endSel))
|
|
|
|
return NULL;
|
|
|
|
SelectDialogItemText(_self->ob_itself,
|
|
|
|
itemNo,
|
|
|
|
strtSel,
|
|
|
|
endSel);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_AppendDITL(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Handle theHandle;
|
|
|
|
DITLMethod method;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef AppendDITL
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(AppendDITL);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&h",
|
|
|
|
ResObj_Convert, &theHandle,
|
|
|
|
&method))
|
|
|
|
return NULL;
|
|
|
|
AppendDITL(_self->ob_itself,
|
|
|
|
theHandle,
|
|
|
|
method);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_CountDITL(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef CountDITL
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(CountDITL);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = CountDITL(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_ShortenDITL(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex numberItems;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef ShortenDITL
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(ShortenDITL);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&numberItems))
|
|
|
|
return NULL;
|
|
|
|
ShortenDITL(_self->ob_itself,
|
|
|
|
numberItems);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_InsertDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
DialogItemIndex afterItem;
|
|
|
|
DialogItemType itemType;
|
|
|
|
Handle itemHandle;
|
|
|
|
Rect box;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef InsertDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(InsertDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hhO&O&",
|
|
|
|
&afterItem,
|
|
|
|
&itemType,
|
|
|
|
ResObj_Convert, &itemHandle,
|
|
|
|
PyMac_GetRect, &box))
|
|
|
|
return NULL;
|
|
|
|
_err = InsertDialogItem(_self->ob_itself,
|
|
|
|
afterItem,
|
|
|
|
itemType,
|
|
|
|
itemHandle,
|
|
|
|
&box);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_RemoveDialogItems(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
DialogItemIndex itemNo;
|
|
|
|
DialogItemIndex amountToRemove;
|
|
|
|
Boolean disposeItemData;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef RemoveDialogItems
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(RemoveDialogItems);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hhb",
|
|
|
|
&itemNo,
|
|
|
|
&amountToRemove,
|
|
|
|
&disposeItemData))
|
|
|
|
return NULL;
|
|
|
|
_err = RemoveDialogItems(_self->ob_itself,
|
|
|
|
itemNo,
|
|
|
|
amountToRemove,
|
|
|
|
disposeItemData);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_StdFilterProc(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
EventRecord event;
|
|
|
|
DialogItemIndex itemHit;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef StdFilterProc
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(StdFilterProc);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&h",
|
|
|
|
PyMac_GetEventRecord, &event,
|
|
|
|
&itemHit))
|
|
|
|
return NULL;
|
|
|
|
_rv = StdFilterProc(_self->ob_itself,
|
|
|
|
&event,
|
|
|
|
&itemHit);
|
|
|
|
_res = Py_BuildValue("bO&h",
|
|
|
|
_rv,
|
|
|
|
PyMac_BuildEventRecord, &event,
|
|
|
|
itemHit);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetDialogDefaultItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
DialogItemIndex newItem;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogDefaultItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogDefaultItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&newItem))
|
|
|
|
return NULL;
|
|
|
|
_err = SetDialogDefaultItem(_self->ob_itself,
|
|
|
|
newItem);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetDialogCancelItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
DialogItemIndex newItem;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogCancelItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogCancelItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&newItem))
|
|
|
|
return NULL;
|
|
|
|
_err = SetDialogCancelItem(_self->ob_itself,
|
|
|
|
newItem);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetDialogTracksCursor(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Boolean tracks;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogTracksCursor
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogTracksCursor);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "b",
|
|
|
|
&tracks))
|
|
|
|
return NULL;
|
|
|
|
_err = SetDialogTracksCursor(_self->ob_itself,
|
|
|
|
tracks);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_AutoSizeDialog(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef AutoSizeDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(AutoSizeDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = AutoSizeDialog(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogItemAsControl(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inItemNo;
|
|
|
|
ControlHandle outControl;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogItemAsControl
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogItemAsControl);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&inItemNo))
|
|
|
|
return NULL;
|
|
|
|
_err = GetDialogItemAsControl(_self->ob_itself,
|
|
|
|
inItemNo,
|
|
|
|
&outControl);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_New, outControl);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_MoveDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inItemNo;
|
|
|
|
SInt16 inHoriz;
|
|
|
|
SInt16 inVert;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef MoveDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(MoveDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hhh",
|
|
|
|
&inItemNo,
|
|
|
|
&inHoriz,
|
|
|
|
&inVert))
|
|
|
|
return NULL;
|
|
|
|
_err = MoveDialogItem(_self->ob_itself,
|
|
|
|
inItemNo,
|
|
|
|
inHoriz,
|
|
|
|
inVert);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SizeDialogItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inItemNo;
|
|
|
|
SInt16 inWidth;
|
|
|
|
SInt16 inHeight;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SizeDialogItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SizeDialogItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hhh",
|
|
|
|
&inItemNo,
|
|
|
|
&inWidth,
|
|
|
|
&inHeight))
|
|
|
|
return NULL;
|
|
|
|
_err = SizeDialogItem(_self->ob_itself,
|
|
|
|
inItemNo,
|
|
|
|
inWidth,
|
|
|
|
inHeight);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_AppendDialogItemList(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 ditlID;
|
|
|
|
DITLMethod method;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef AppendDialogItemList
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(AppendDialogItemList);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hh",
|
|
|
|
&ditlID,
|
|
|
|
&method))
|
|
|
|
return NULL;
|
|
|
|
_err = AppendDialogItemList(_self->ob_itself,
|
|
|
|
ditlID,
|
|
|
|
method);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetDialogTimeout(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
SInt16 inButtonToPress;
|
|
|
|
UInt32 inSecondsToWait;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogTimeout
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogTimeout);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hl",
|
|
|
|
&inButtonToPress,
|
|
|
|
&inSecondsToWait))
|
|
|
|
return NULL;
|
|
|
|
_err = SetDialogTimeout(_self->ob_itself,
|
|
|
|
inButtonToPress,
|
|
|
|
inSecondsToWait);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogTimeout(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
SInt16 outButtonToPress;
|
|
|
|
UInt32 outSecondsToWait;
|
|
|
|
UInt32 outSecondsRemaining;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogTimeout
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogTimeout);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetDialogTimeout(_self->ob_itself,
|
|
|
|
&outButtonToPress,
|
|
|
|
&outSecondsToWait,
|
|
|
|
&outSecondsRemaining);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("hll",
|
|
|
|
outButtonToPress,
|
|
|
|
outSecondsToWait,
|
|
|
|
outSecondsRemaining);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetModalDialogEventMask(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
EventMask inMask;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetModalDialogEventMask
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetModalDialogEventMask);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "H",
|
|
|
|
&inMask))
|
|
|
|
return NULL;
|
|
|
|
_err = SetModalDialogEventMask(_self->ob_itself,
|
|
|
|
inMask);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetModalDialogEventMask(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
EventMask outMask;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetModalDialogEventMask
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetModalDialogEventMask);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetModalDialogEventMask(_self->ob_itself,
|
|
|
|
&outMask);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("H",
|
|
|
|
outMask);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogWindow(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
WindowPtr _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogWindow
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogWindow);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogWindow(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
WinObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogTextEditHandle(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
TEHandle _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogTextEditHandle
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogTextEditHandle);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogTextEditHandle(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogDefaultItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt16 _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogDefaultItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogDefaultItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogDefaultItem(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogCancelItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt16 _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogCancelItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogCancelItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogCancelItem(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogKeyboardFocusItem(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt16 _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogKeyboardFocusItem
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogKeyboardFocusItem);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogKeyboardFocusItem(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_SetPortDialogPort(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetPortDialogPort
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetPortDialogPort);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
SetPortDialogPort(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *DlgObj_GetDialogPort(DialogObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
CGrafPtr _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogPort
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogPort);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogPort(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
GrafObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef DlgObj_methods[] = {
|
2010-05-09 11:46:46 -03:00
|
|
|
{"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1,
|
|
|
|
PyDoc_STR("(RgnHandle updateRgn) -> None")},
|
|
|
|
{"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex itemNo) -> None")},
|
|
|
|
{"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex itemNo) -> None")},
|
|
|
|
{"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1,
|
|
|
|
PyDoc_STR("(Point thePt) -> (DialogItemIndexZeroBased _rv)")},
|
|
|
|
{"DialogCut", (PyCFunction)DlgObj_DialogCut, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex itemNo) -> (DialogItemType itemType, Handle item, Rect box)")},
|
|
|
|
{"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex itemNo, DialogItemType itemType, Handle item, Rect box) -> None")},
|
|
|
|
{"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel) -> None")},
|
|
|
|
{"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1,
|
|
|
|
PyDoc_STR("(Handle theHandle, DITLMethod method) -> None")},
|
|
|
|
{"CountDITL", (PyCFunction)DlgObj_CountDITL, 1,
|
|
|
|
PyDoc_STR("() -> (DialogItemIndex _rv)")},
|
|
|
|
{"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex numberItems) -> None")},
|
|
|
|
{"InsertDialogItem", (PyCFunction)DlgObj_InsertDialogItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex afterItem, DialogItemType itemType, Handle itemHandle, Rect box) -> None")},
|
|
|
|
{"RemoveDialogItems", (PyCFunction)DlgObj_RemoveDialogItems, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex itemNo, DialogItemIndex amountToRemove, Boolean disposeItemData) -> None")},
|
|
|
|
{"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1,
|
|
|
|
PyDoc_STR("(EventRecord event, DialogItemIndex itemHit) -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)")},
|
|
|
|
{"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex newItem) -> None")},
|
|
|
|
{"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1,
|
|
|
|
PyDoc_STR("(DialogItemIndex newItem) -> None")},
|
|
|
|
{"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1,
|
|
|
|
PyDoc_STR("(Boolean tracks) -> None")},
|
|
|
|
{"AutoSizeDialog", (PyCFunction)DlgObj_AutoSizeDialog, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"GetDialogItemAsControl", (PyCFunction)DlgObj_GetDialogItemAsControl, 1,
|
|
|
|
PyDoc_STR("(SInt16 inItemNo) -> (ControlHandle outControl)")},
|
|
|
|
{"MoveDialogItem", (PyCFunction)DlgObj_MoveDialogItem, 1,
|
|
|
|
PyDoc_STR("(SInt16 inItemNo, SInt16 inHoriz, SInt16 inVert) -> None")},
|
|
|
|
{"SizeDialogItem", (PyCFunction)DlgObj_SizeDialogItem, 1,
|
|
|
|
PyDoc_STR("(SInt16 inItemNo, SInt16 inWidth, SInt16 inHeight) -> None")},
|
|
|
|
{"AppendDialogItemList", (PyCFunction)DlgObj_AppendDialogItemList, 1,
|
|
|
|
PyDoc_STR("(SInt16 ditlID, DITLMethod method) -> None")},
|
|
|
|
{"SetDialogTimeout", (PyCFunction)DlgObj_SetDialogTimeout, 1,
|
|
|
|
PyDoc_STR("(SInt16 inButtonToPress, UInt32 inSecondsToWait) -> None")},
|
|
|
|
{"GetDialogTimeout", (PyCFunction)DlgObj_GetDialogTimeout, 1,
|
|
|
|
PyDoc_STR("() -> (SInt16 outButtonToPress, UInt32 outSecondsToWait, UInt32 outSecondsRemaining)")},
|
|
|
|
{"SetModalDialogEventMask", (PyCFunction)DlgObj_SetModalDialogEventMask, 1,
|
|
|
|
PyDoc_STR("(EventMask inMask) -> None")},
|
|
|
|
{"GetModalDialogEventMask", (PyCFunction)DlgObj_GetModalDialogEventMask, 1,
|
|
|
|
PyDoc_STR("() -> (EventMask outMask)")},
|
|
|
|
{"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1,
|
|
|
|
PyDoc_STR("() -> (WindowPtr _rv)")},
|
|
|
|
{"GetDialogTextEditHandle", (PyCFunction)DlgObj_GetDialogTextEditHandle, 1,
|
|
|
|
PyDoc_STR("() -> (TEHandle _rv)")},
|
|
|
|
{"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1,
|
|
|
|
PyDoc_STR("() -> (SInt16 _rv)")},
|
|
|
|
{"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1,
|
|
|
|
PyDoc_STR("() -> (SInt16 _rv)")},
|
|
|
|
{"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1,
|
|
|
|
PyDoc_STR("() -> (SInt16 _rv)")},
|
|
|
|
{"SetPortDialogPort", (PyCFunction)DlgObj_SetPortDialogPort, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"GetDialogPort", (PyCFunction)DlgObj_GetDialogPort, 1,
|
|
|
|
PyDoc_STR("() -> (CGrafPtr _rv)")},
|
|
|
|
{NULL, NULL, 0}
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
2002-11-29 19:40:48 -04:00
|
|
|
#define DlgObj_getsetlist NULL
|
2001-08-23 11:02:09 -03:00
|
|
|
|
2002-12-03 19:40:22 -04:00
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
static int DlgObj_compare(DialogObject *self, DialogObject *other)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
if ( self->ob_itself > other->ob_itself ) return 1;
|
|
|
|
if ( self->ob_itself < other->ob_itself ) return -1;
|
|
|
|
return 0;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DlgObj_repr NULL
|
|
|
|
|
|
|
|
static int DlgObj_hash(DialogObject *self)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
return (int)self->ob_itself;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
2002-12-03 19:40:22 -04:00
|
|
|
#define DlgObj_tp_init 0
|
|
|
|
|
|
|
|
#define DlgObj_tp_alloc PyType_GenericAlloc
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
|
2002-12-03 19:40:22 -04:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_self;
|
|
|
|
DialogPtr itself;
|
|
|
|
char *kw[] = {"itself", 0};
|
2002-12-03 19:40:22 -04:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL;
|
|
|
|
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
|
|
|
|
((DialogObject *)_self)->ob_itself = itself;
|
|
|
|
return _self;
|
2002-12-03 19:40:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DlgObj_tp_free PyObject_Del
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
PyTypeObject Dialog_Type = {
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject_HEAD_INIT(NULL)
|
|
|
|
0, /*ob_size*/
|
|
|
|
"_Dlg.Dialog", /*tp_name*/
|
|
|
|
sizeof(DialogObject), /*tp_basicsize*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
|
|
|
(destructor) DlgObj_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
|
|
|
(getattrfunc)0, /*tp_getattr*/
|
|
|
|
(setattrfunc)0, /*tp_setattr*/
|
|
|
|
(cmpfunc) DlgObj_compare, /*tp_compare*/
|
|
|
|
(reprfunc) DlgObj_repr, /*tp_repr*/
|
|
|
|
(PyNumberMethods *)0, /* tp_as_number */
|
|
|
|
(PySequenceMethods *)0, /* tp_as_sequence */
|
|
|
|
(PyMappingMethods *)0, /* tp_as_mapping */
|
|
|
|
(hashfunc) DlgObj_hash, /*tp_hash*/
|
|
|
|
0, /*tp_call*/
|
|
|
|
0, /*tp_str*/
|
|
|
|
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
|
|
PyObject_GenericSetAttr, /*tp_setattro */
|
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
|
|
|
0, /*tp_doc*/
|
|
|
|
0, /*tp_traverse*/
|
|
|
|
0, /*tp_clear*/
|
|
|
|
0, /*tp_richcompare*/
|
|
|
|
0, /*tp_weaklistoffset*/
|
|
|
|
0, /*tp_iter*/
|
|
|
|
0, /*tp_iternext*/
|
|
|
|
DlgObj_methods, /* tp_methods */
|
|
|
|
0, /*tp_members*/
|
|
|
|
DlgObj_getsetlist, /*tp_getset*/
|
|
|
|
0, /*tp_base*/
|
|
|
|
0, /*tp_dict*/
|
|
|
|
0, /*tp_descr_get*/
|
|
|
|
0, /*tp_descr_set*/
|
|
|
|
0, /*tp_dictoffset*/
|
|
|
|
DlgObj_tp_init, /* tp_init */
|
|
|
|
DlgObj_tp_alloc, /* tp_alloc */
|
|
|
|
DlgObj_tp_new, /* tp_new */
|
|
|
|
DlgObj_tp_free, /* tp_free */
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* --------------------- End object type Dialog --------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Dlg_NewDialog(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogPtr _rv;
|
|
|
|
Rect boundsRect;
|
|
|
|
Str255 title;
|
|
|
|
Boolean visible;
|
|
|
|
SInt16 procID;
|
|
|
|
WindowPtr behind;
|
|
|
|
Boolean goAwayFlag;
|
|
|
|
SInt32 refCon;
|
|
|
|
Handle items;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef NewDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(NewDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
|
|
|
|
PyMac_GetRect, &boundsRect,
|
|
|
|
PyMac_GetStr255, title,
|
|
|
|
&visible,
|
|
|
|
&procID,
|
|
|
|
WinObj_Convert, &behind,
|
|
|
|
&goAwayFlag,
|
|
|
|
&refCon,
|
|
|
|
ResObj_Convert, &items))
|
|
|
|
return NULL;
|
|
|
|
_rv = NewDialog((void *)0,
|
|
|
|
&boundsRect,
|
|
|
|
title,
|
|
|
|
visible,
|
|
|
|
procID,
|
|
|
|
behind,
|
|
|
|
goAwayFlag,
|
|
|
|
refCon,
|
|
|
|
items);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
DlgObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_GetNewDialog(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogPtr _rv;
|
|
|
|
SInt16 dialogID;
|
|
|
|
WindowPtr behind;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetNewDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetNewDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&dialogID,
|
|
|
|
WinObj_Convert, &behind))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetNewDialog(dialogID,
|
|
|
|
(void *)0,
|
|
|
|
behind);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
DlgObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_NewColorDialog(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogPtr _rv;
|
|
|
|
Rect boundsRect;
|
|
|
|
Str255 title;
|
|
|
|
Boolean visible;
|
|
|
|
SInt16 procID;
|
|
|
|
WindowPtr behind;
|
|
|
|
Boolean goAwayFlag;
|
|
|
|
SInt32 refCon;
|
|
|
|
Handle items;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef NewColorDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(NewColorDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
|
|
|
|
PyMac_GetRect, &boundsRect,
|
|
|
|
PyMac_GetStr255, title,
|
|
|
|
&visible,
|
|
|
|
&procID,
|
|
|
|
WinObj_Convert, &behind,
|
|
|
|
&goAwayFlag,
|
|
|
|
&refCon,
|
|
|
|
ResObj_Convert, &items))
|
|
|
|
return NULL;
|
|
|
|
_rv = NewColorDialog((void *)0,
|
|
|
|
&boundsRect,
|
|
|
|
title,
|
|
|
|
visible,
|
|
|
|
procID,
|
|
|
|
behind,
|
|
|
|
goAwayFlag,
|
|
|
|
refCon,
|
|
|
|
items);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
DlgObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_ModalDialog(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
PyObject* modalFilter;
|
|
|
|
DialogItemIndex itemHit;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef ModalDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(ModalDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O",
|
|
|
|
&modalFilter))
|
|
|
|
return NULL;
|
|
|
|
ModalDialog(Dlg_PassFilterProc(modalFilter),
|
|
|
|
&itemHit);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
itemHit);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_IsDialogEvent(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
EventRecord theEvent;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef IsDialogEvent
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(IsDialogEvent);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetEventRecord, &theEvent))
|
|
|
|
return NULL;
|
|
|
|
_rv = IsDialogEvent(&theEvent);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_DialogSelect(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
EventRecord theEvent;
|
|
|
|
DialogPtr theDialog;
|
|
|
|
DialogItemIndex itemHit;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef DialogSelect
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(DialogSelect);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetEventRecord, &theEvent))
|
|
|
|
return NULL;
|
|
|
|
_rv = DialogSelect(&theEvent,
|
|
|
|
&theDialog,
|
|
|
|
&itemHit);
|
|
|
|
_res = Py_BuildValue("bO&h",
|
|
|
|
_rv,
|
|
|
|
DlgObj_WhichDialog, theDialog,
|
|
|
|
itemHit);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_Alert(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex _rv;
|
|
|
|
SInt16 alertID;
|
|
|
|
PyObject* modalFilter;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef Alert
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(Alert);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO",
|
|
|
|
&alertID,
|
|
|
|
&modalFilter))
|
|
|
|
return NULL;
|
|
|
|
_rv = Alert(alertID,
|
|
|
|
Dlg_PassFilterProc(modalFilter));
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_StopAlert(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex _rv;
|
|
|
|
SInt16 alertID;
|
|
|
|
PyObject* modalFilter;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef StopAlert
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(StopAlert);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO",
|
|
|
|
&alertID,
|
|
|
|
&modalFilter))
|
|
|
|
return NULL;
|
|
|
|
_rv = StopAlert(alertID,
|
|
|
|
Dlg_PassFilterProc(modalFilter));
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_NoteAlert(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex _rv;
|
|
|
|
SInt16 alertID;
|
|
|
|
PyObject* modalFilter;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef NoteAlert
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(NoteAlert);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO",
|
|
|
|
&alertID,
|
|
|
|
&modalFilter))
|
|
|
|
return NULL;
|
|
|
|
_rv = NoteAlert(alertID,
|
|
|
|
Dlg_PassFilterProc(modalFilter));
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_CautionAlert(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogItemIndex _rv;
|
|
|
|
SInt16 alertID;
|
|
|
|
PyObject* modalFilter;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef CautionAlert
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(CautionAlert);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO",
|
|
|
|
&alertID,
|
|
|
|
&modalFilter))
|
|
|
|
return NULL;
|
|
|
|
_rv = CautionAlert(alertID,
|
|
|
|
Dlg_PassFilterProc(modalFilter));
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_ParamText(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Str255 param0;
|
|
|
|
Str255 param1;
|
|
|
|
Str255 param2;
|
|
|
|
Str255 param3;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef ParamText
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(ParamText);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&O&",
|
|
|
|
PyMac_GetStr255, param0,
|
|
|
|
PyMac_GetStr255, param1,
|
|
|
|
PyMac_GetStr255, param2,
|
|
|
|
PyMac_GetStr255, param3))
|
|
|
|
return NULL;
|
|
|
|
ParamText(param0,
|
|
|
|
param1,
|
|
|
|
param2,
|
|
|
|
param3);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_GetDialogItemText(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Handle item;
|
|
|
|
Str255 text;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogItemText
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogItemText);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &item))
|
|
|
|
return NULL;
|
|
|
|
GetDialogItemText(item,
|
|
|
|
text);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildStr255, text);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_SetDialogItemText(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Handle item;
|
|
|
|
Str255 text;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogItemText
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogItemText);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
ResObj_Convert, &item,
|
|
|
|
PyMac_GetStr255, text))
|
|
|
|
return NULL;
|
|
|
|
SetDialogItemText(item,
|
|
|
|
text);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_GetAlertStage(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt16 _rv;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetAlertStage
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetAlertStage);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetAlertStage();
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_SetDialogFont(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt16 fontNum;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef SetDialogFont
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(SetDialogFont);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&fontNum))
|
|
|
|
return NULL;
|
|
|
|
SetDialogFont(fontNum);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_ResetAlertStage(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef ResetAlertStage
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(ResetAlertStage);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
ResetAlertStage();
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_GetParamText(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Str255 param0;
|
|
|
|
Str255 param1;
|
|
|
|
Str255 param2;
|
|
|
|
Str255 param3;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetParamText
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetParamText);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&O&",
|
|
|
|
PyMac_GetStr255, param0,
|
|
|
|
PyMac_GetStr255, param1,
|
|
|
|
PyMac_GetStr255, param2,
|
|
|
|
PyMac_GetStr255, param3))
|
|
|
|
return NULL;
|
|
|
|
GetParamText(param0,
|
|
|
|
param1,
|
|
|
|
param2,
|
|
|
|
param3);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_NewFeaturesDialog(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogPtr _rv;
|
|
|
|
Rect inBoundsRect;
|
|
|
|
Str255 inTitle;
|
|
|
|
Boolean inIsVisible;
|
|
|
|
SInt16 inProcID;
|
|
|
|
WindowPtr inBehind;
|
|
|
|
Boolean inGoAwayFlag;
|
|
|
|
SInt32 inRefCon;
|
|
|
|
Handle inItemListHandle;
|
|
|
|
UInt32 inFlags;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef NewFeaturesDialog
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(NewFeaturesDialog);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&l",
|
|
|
|
PyMac_GetRect, &inBoundsRect,
|
|
|
|
PyMac_GetStr255, inTitle,
|
|
|
|
&inIsVisible,
|
|
|
|
&inProcID,
|
|
|
|
WinObj_Convert, &inBehind,
|
|
|
|
&inGoAwayFlag,
|
|
|
|
&inRefCon,
|
|
|
|
ResObj_Convert, &inItemListHandle,
|
|
|
|
&inFlags))
|
|
|
|
return NULL;
|
|
|
|
_rv = NewFeaturesDialog((void *)0,
|
|
|
|
&inBoundsRect,
|
|
|
|
inTitle,
|
|
|
|
inIsVisible,
|
|
|
|
inProcID,
|
|
|
|
inBehind,
|
|
|
|
inGoAwayFlag,
|
|
|
|
inRefCon,
|
|
|
|
inItemListHandle,
|
|
|
|
inFlags);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
DlgObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_GetDialogFromWindow(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
DialogPtr _rv;
|
|
|
|
WindowPtr window;
|
2001-11-30 10:16:36 -04:00
|
|
|
#ifndef GetDialogFromWindow
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_PRECHECK(GetDialogFromWindow);
|
2001-11-30 10:16:36 -04:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &window))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetDialogFromWindow(window);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
DlgObj_New, _rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Dlg_SetUserItemHandler(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
2001-08-23 11:02:09 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *new = NULL;
|
2005-07-03 17:59:44 -03:00
|
|
|
|
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "|O", &new))
|
|
|
|
return NULL;
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
if (Dlg_UserItemProc_callback && new && new != Py_None) {
|
|
|
|
PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
if (new == NULL || new == Py_None) {
|
|
|
|
new = NULL;
|
|
|
|
_res = Py_None;
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
} else {
|
|
|
|
Py_INCREF(new);
|
|
|
|
_res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc));
|
|
|
|
}
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
Dlg_UserItemProc_callback = new;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Dlg_methods[] = {
|
2010-05-09 11:46:46 -03:00
|
|
|
{"NewDialog", (PyCFunction)Dlg_NewDialog, 1,
|
|
|
|
PyDoc_STR("(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)")},
|
|
|
|
{"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1,
|
|
|
|
PyDoc_STR("(SInt16 dialogID, WindowPtr behind) -> (DialogPtr _rv)")},
|
|
|
|
{"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1,
|
|
|
|
PyDoc_STR("(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)")},
|
|
|
|
{"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1,
|
|
|
|
PyDoc_STR("(PyObject* modalFilter) -> (DialogItemIndex itemHit)")},
|
|
|
|
{"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1,
|
|
|
|
PyDoc_STR("(EventRecord theEvent) -> (Boolean _rv)")},
|
|
|
|
{"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1,
|
|
|
|
PyDoc_STR("(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, DialogItemIndex itemHit)")},
|
|
|
|
{"Alert", (PyCFunction)Dlg_Alert, 1,
|
|
|
|
PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
|
|
|
{"StopAlert", (PyCFunction)Dlg_StopAlert, 1,
|
|
|
|
PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
|
|
|
{"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1,
|
|
|
|
PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
|
|
|
{"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1,
|
|
|
|
PyDoc_STR("(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)")},
|
|
|
|
{"ParamText", (PyCFunction)Dlg_ParamText, 1,
|
|
|
|
PyDoc_STR("(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None")},
|
|
|
|
{"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1,
|
|
|
|
PyDoc_STR("(Handle item) -> (Str255 text)")},
|
|
|
|
{"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1,
|
|
|
|
PyDoc_STR("(Handle item, Str255 text) -> None")},
|
|
|
|
{"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1,
|
|
|
|
PyDoc_STR("() -> (SInt16 _rv)")},
|
|
|
|
{"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1,
|
|
|
|
PyDoc_STR("(SInt16 fontNum) -> None")},
|
|
|
|
{"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
|
|
|
{"GetParamText", (PyCFunction)Dlg_GetParamText, 1,
|
|
|
|
PyDoc_STR("(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None")},
|
|
|
|
{"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1,
|
|
|
|
PyDoc_STR("(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)")},
|
|
|
|
{"GetDialogFromWindow", (PyCFunction)Dlg_GetDialogFromWindow, 1,
|
|
|
|
PyDoc_STR("(WindowPtr window) -> (DialogPtr _rv)")},
|
|
|
|
{"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1,
|
|
|
|
PyDoc_STR(NULL)},
|
|
|
|
{NULL, NULL, 0}
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the WindowPtr corresponding to a DialogObject */
|
|
|
|
#if 0
|
|
|
|
WindowPtr
|
|
|
|
DlgObj_ConvertToWindow(PyObject *self)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
if ( DlgObj_Check(self) )
|
|
|
|
return GetDialogWindow(((DialogObject *)self)->ob_itself);
|
|
|
|
return NULL;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* Return the object corresponding to the dialog, or None */
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
DlgObj_WhichDialog(DialogPtr d)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *it;
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
if (d == NULL) {
|
|
|
|
it = Py_None;
|
|
|
|
Py_INCREF(it);
|
|
|
|
} else {
|
|
|
|
WindowPtr w = GetDialogWindow(d);
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
it = (PyObject *) GetWRefCon(w);
|
|
|
|
if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) {
|
2001-08-23 11:02:09 -03:00
|
|
|
#if 0
|
2010-05-09 11:46:46 -03:00
|
|
|
/* Should do this, but we don't have an ob_freeit for dialogs yet. */
|
|
|
|
it = WinObj_New(w);
|
|
|
|
((WindowObject *)it)->ob_freeit = NULL;
|
2001-08-23 11:02:09 -03:00
|
|
|
#else
|
2010-05-09 11:46:46 -03:00
|
|
|
it = Py_None;
|
|
|
|
Py_INCREF(it);
|
2001-08-23 11:02:09 -03:00
|
|
|
#endif
|
2010-05-09 11:46:46 -03:00
|
|
|
} else {
|
|
|
|
Py_INCREF(it);
|
2005-07-03 17:59:44 -03:00
|
|
|
}
|
2010-05-09 11:46:46 -03:00
|
|
|
}
|
|
|
|
return it;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:58:24 -03:00
|
|
|
#else /* __LP64__ */
|
|
|
|
|
|
|
|
static PyMethodDef Dlg_methods[] = {
|
2010-05-09 11:46:46 -03:00
|
|
|
{NULL, NULL, 0}
|
2008-06-05 09:58:24 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __LP64__ */
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
void init_Dlg(void)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *m;
|
2016-09-16 10:08:45 -03:00
|
|
|
#if APPLE_SUPPORTS_QUICKTIME
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *d;
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New);
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog);
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert);
|
2016-09-16 10:08:45 -03:00
|
|
|
#endif /* APPLE_SUPPORTS_QUICKTIME */
|
2001-08-23 11:02:09 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
m = Py_InitModule("_Dlg", Dlg_methods);
|
2008-06-05 09:58:24 -03:00
|
|
|
|
2016-09-16 10:08:45 -03:00
|
|
|
#if APPLE_SUPPORTS_QUICKTIME
|
2010-05-09 11:46:46 -03:00
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Dlg_Error = PyMac_GetOSErrException();
|
|
|
|
if (Dlg_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Dlg_Error) != 0)
|
|
|
|
return;
|
|
|
|
Dialog_Type.ob_type = &PyType_Type;
|
|
|
|
if (PyType_Ready(&Dialog_Type) < 0) return;
|
|
|
|
Py_INCREF(&Dialog_Type);
|
|
|
|
PyModule_AddObject(m, "Dialog", (PyObject *)&Dialog_Type);
|
|
|
|
/* Backward-compatible name */
|
|
|
|
Py_INCREF(&Dialog_Type);
|
|
|
|
PyModule_AddObject(m, "DialogType", (PyObject *)&Dialog_Type);
|
2016-09-16 10:08:45 -03:00
|
|
|
#endif /* APPLE_SUPPORTS_QUICKTIME */
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================== End module _Dlg ========================= */
|
|
|
|
|