Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for

keys that expect a Handle, and have a ResObj as parameter.
This commit is contained in:
Jack Jansen 1999-12-19 00:05:50 +00:00
parent 54b9ce1c4f
commit 1f9249cea9
2 changed files with 148 additions and 1 deletions

View File

@ -1177,6 +1177,79 @@ static PyObject *CtlObj_GetControlData(_self, _args)
}
static PyObject *CtlObj_SetControlDataHandle(_self, _args)
ControlObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
ControlPartCode inPart;
ResType inTagName;
Handle buffer;
if (!PyArg_ParseTuple(_args, "hO&O&",
&inPart,
PyMac_GetOSType, &inTagName,
OptResObj_Convert, buffer))
return NULL;
_err = SetControlData(_self->ob_itself,
inPart,
inTagName,
sizeof(buffer),
(Ptr)buffer);
if (_err != noErr)
return PyMac_Error(_err);
_res = Py_None;
return _res;
}
static PyObject *CtlObj_GetControlDataHandle(_self, _args)
ControlObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
ControlPartCode inPart;
ResType inTagName;
Size bufferSize;
Handle hdl;
if (!PyArg_ParseTuple(_args, "hO&",
&inPart,
PyMac_GetOSType, &inTagName))
return NULL;
/* Check it is handle-sized */
_err = GetControlDataSize(_self->ob_itself,
inPart,
inTagName,
&bufferSize);
if (_err != noErr)
return PyMac_Error(_err);
if (bufferSize != sizeof(Handle)) {
PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
return NULL;
}
_err = GetControlData(_self->ob_itself,
inPart,
inTagName,
sizeof(Handle),
(Ptr)&hdl,
&bufferSize);
if (_err != noErr) {
return PyMac_Error(_err);
}
return Py_BuildValue("O&", OptResObj_New, hdl);
}
static PyObject *CtlObj_GetPopupData(_self, _args)
ControlObject *_self;
PyObject *_args;
@ -1338,6 +1411,10 @@ static PyMethodDef CtlObj_methods[] = {
"(stuff) -> None"},
{"GetControlData", (PyCFunction)CtlObj_GetControlData, 1,
"(part, type) -> String"},
{"SetControlDataHandle", (PyCFunction)CtlObj_SetControlDataHandle, 1,
"(ResObj) -> None"},
{"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1,
"(part, type) -> ResObj"},
{"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1,
NULL},
{"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1,

View File

@ -331,7 +331,77 @@ return _res;
f = ManualGenerator("GetControlData", getcontroldata_body);
f.docstring = lambda: "(part, type) -> String"
object.add(f)
# end CJW
# Manual Generator for SetControlDataHandle
setcontroldatahandle_body = """
OSErr _err;
ControlPartCode inPart;
ResType inTagName;
Handle buffer;
if (!PyArg_ParseTuple(_args, "hO&O&",
&inPart,
PyMac_GetOSType, &inTagName,
OptResObj_Convert, buffer))
return NULL;
_err = SetControlData(_self->ob_itself,
inPart,
inTagName,
sizeof(buffer),
(Ptr)buffer);
if (_err != noErr)
return PyMac_Error(_err);
_res = Py_None;
return _res;
"""
f = ManualGenerator("SetControlDataHandle", setcontroldatahandle_body);
f.docstring = lambda: "(ResObj) -> None"
object.add(f)
# Manual Generator for GetControlDataHandle
getcontroldatahandle_body = """
OSErr _err;
ControlPartCode inPart;
ResType inTagName;
Size bufferSize;
Handle hdl;
if (!PyArg_ParseTuple(_args, "hO&",
&inPart,
PyMac_GetOSType, &inTagName))
return NULL;
/* Check it is handle-sized */
_err = GetControlDataSize(_self->ob_itself,
inPart,
inTagName,
&bufferSize);
if (_err != noErr)
return PyMac_Error(_err);
if (bufferSize != sizeof(Handle)) {
PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
return NULL;
}
_err = GetControlData(_self->ob_itself,
inPart,
inTagName,
sizeof(Handle),
(Ptr)&hdl,
&bufferSize);
if (_err != noErr) {
return PyMac_Error(_err);
}
return Py_BuildValue("O&", OptResObj_New, hdl);
"""
f = ManualGenerator("GetControlDataHandle", getcontroldatahandle_body);
f.docstring = lambda: "(part, type) -> ResObj"
object.add(f)
# And manual generators to get/set popup menu information
getpopupdata_body = """