summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1998-06-19 13:35:14 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1998-06-19 13:35:14 (GMT)
commit4c704131ca47f185870c48326539d6b8a377db34 (patch)
treea2a420b8aedf4e43da8909c1fd2d2225c7c1e218
parentcef4c844df324979f25ffec172c141a5d5c4672e (diff)
downloadcpython-4c704131ca47f185870c48326539d6b8a377db34.zip
cpython-4c704131ca47f185870c48326539d6b8a377db34.tar.gz
cpython-4c704131ca47f185870c48326539d6b8a377db34.tar.bz2
Added {Get,Set}PopupData calls to get at the data for popup menu controls.
-rw-r--r--Mac/Modules/ctl/Ctlmodule.c48
-rw-r--r--Mac/Modules/ctl/ctlsupport.py37
2 files changed, 85 insertions, 0 deletions
diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c
index bfa88a1..6b43b68 100644
--- a/Mac/Modules/ctl/Ctlmodule.c
+++ b/Mac/Modules/ctl/Ctlmodule.c
@@ -866,6 +866,50 @@ static PyObject *CtlObj_TrackControl(_self, _args)
}
+static PyObject *CtlObj_GetPopupData(_self, _args)
+ ControlObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ PopupPrivateDataHandle hdl;
+
+ if ( (*_self->ob_itself)->contrlData == NULL ) {
+ PyErr_SetString(Ctl_Error, "No contrlData handle in control");
+ return 0;
+ }
+ hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
+ HLock((Handle)hdl);
+ _res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID);
+ HUnlock((Handle)hdl);
+ return _res;
+
+}
+
+static PyObject *CtlObj_SetPopupData(_self, _args)
+ ControlObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ PopupPrivateDataHandle hdl;
+ MenuHandle mHandle;
+ short mID;
+
+ if (!PyArg_ParseTuple(_args, "O&h", MenuObj_Convert, &mHandle, &mID) )
+ return 0;
+ if ( (*_self->ob_itself)->contrlData == NULL ) {
+ PyErr_SetString(Ctl_Error, "No contrlData handle in control");
+ return 0;
+ }
+ hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
+ (*hdl)->mHandle = mHandle;
+ (*hdl)->mID = mID;
+ Py_INCREF(Py_None);
+ return Py_None;
+
+}
+
static PyMethodDef CtlObj_methods[] = {
{"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1,
"(ControlPartCode hiliteState) -> None"},
@@ -953,6 +997,10 @@ static PyMethodDef CtlObj_methods[] = {
"() -> None"},
{"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
NULL},
+ {"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1,
+ NULL},
+ {"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1,
+ NULL},
{NULL, NULL, 0}
};
diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py
index 75e7aa7..e01e871 100644
--- a/Mac/Modules/ctl/ctlsupport.py
+++ b/Mac/Modules/ctl/ctlsupport.py
@@ -204,6 +204,43 @@ f = ManualGenerator("TrackControl", trackcontrol_body);
#f.docstring = "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
object.add(f)
+# And manual generators to get/set popup menu information
+getpopupdata_body = """
+PopupPrivateDataHandle hdl;
+
+if ( (*_self->ob_itself)->contrlData == NULL ) {
+ PyErr_SetString(Ctl_Error, "No contrlData handle in control");
+ return 0;
+}
+hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
+HLock((Handle)hdl);
+_res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID);
+HUnlock((Handle)hdl);
+return _res;
+"""
+f = ManualGenerator("GetPopupData", getpopupdata_body)
+object.add(f)
+
+setpopupdata_body = """
+PopupPrivateDataHandle hdl;
+MenuHandle mHandle;
+short mID;
+
+if (!PyArg_ParseTuple(_args, "O&h", MenuObj_Convert, &mHandle, &mID) )
+ return 0;
+if ( (*_self->ob_itself)->contrlData == NULL ) {
+ PyErr_SetString(Ctl_Error, "No contrlData handle in control");
+ return 0;
+}
+hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
+(*hdl)->mHandle = mHandle;
+(*hdl)->mID = mID;
+Py_INCREF(Py_None);
+return Py_None;
+"""
+f = ManualGenerator("SetPopupData", setpopupdata_body)
+object.add(f)
+
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)