diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1998-07-10 15:47:48 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1998-07-10 15:47:48 (GMT) |
commit | df901dfdea08e29730aff9872a051e05b0104dfe (patch) | |
tree | c447d547cbd4e09153c607f5af662f10dc622712 /Mac/Modules/dlg/dlgsupport.py | |
parent | ba0d0611e7916265a1be2a57cdf3921cc42c5e5d (diff) | |
download | cpython-df901dfdea08e29730aff9872a051e05b0104dfe.zip cpython-df901dfdea08e29730aff9872a051e05b0104dfe.tar.gz cpython-df901dfdea08e29730aff9872a051e05b0104dfe.tar.bz2 |
Added a function SetUserItemHandler: this takes a function(dialog,
item) as parameter and returns a handle suitable for passing to
SetDialogItem as a user-item redraw routine. Note that you can
only make one of these, for now.
Diffstat (limited to 'Mac/Modules/dlg/dlgsupport.py')
-rw-r--r-- | Mac/Modules/dlg/dlgsupport.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py index cbec130..8af8fe7 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -92,6 +92,31 @@ Dlg_PassFilterProc(PyObject *callback) return &Dlg_UnivFilterProc; } +static PyObject *Dlg_UserItemProc_callback = NULL; + +static pascal void Dlg_UnivUserItemProc(DialogPtr dialog, + short item) +{ + 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", WinObj_WhichWindow, dialog, item); + if (args == NULL) + res = NULL; + else { + res = PyEval_CallObject(Dlg_UserItemProc_callback, args); + Py_DECREF(args); + } + if (res == NULL) { + fprintf(stderr, "Exception in Dialog UserItem proc\\n"); + PyErr_Print(); + } + Py_XDECREF(res); + return; +} + extern PyMethodChain WinObj_chain; """ @@ -145,6 +170,33 @@ object.add(f) f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode)) object.add(f) +setuseritembody = """ + PyObject *new = NULL; + + + if (!PyArg_ParseTuple(_args, "|O", &new)) + return NULL; + + if (Dlg_UserItemProc_callback && new && new != Py_None) { + PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed"); + return NULL; + } + + if (new == Py_None) { + new = NULL; + _res = Py_None; + Py_INCREF(Py_None); + } else { + Py_INCREF(new); + _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemProc(Dlg_UnivUserItemProc)); + } + + Dlg_UserItemProc_callback = new; + return _res; +""" +f = ManualGenerator("SetUserItemHandler", setuseritembody) +module.add(f) + # generate output SetOutputFileName('Dlgmodule.c') module.generate() |