Changes by Corran Webster to support {Get,Set}ControlData and
HandleControlClick. Untested.
This commit is contained in:
parent
4d56ecf690
commit
229c0868fe
|
@ -42,6 +42,9 @@ class MyScanner(Scanner):
|
||||||
'KillControls', # Implied by close of dialog
|
'KillControls', # Implied by close of dialog
|
||||||
'SetCtlAction',
|
'SetCtlAction',
|
||||||
'TrackControl', # Generated manually
|
'TrackControl', # Generated manually
|
||||||
|
'HandleControlClick', # Generated manually
|
||||||
|
'SetControlData', # Generated manually
|
||||||
|
'GetControlData', # Generated manually
|
||||||
'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
|
'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
|
||||||
'kControlProgressBarIndeterminateTag', # ditto
|
'kControlProgressBarIndeterminateTag', # ditto
|
||||||
# The following are unavailable for static 68k (appearance manager)
|
# The following are unavailable for static 68k (appearance manager)
|
||||||
|
@ -58,6 +61,10 @@ class MyScanner(Scanner):
|
||||||
'SetDisclosureTriangleLastValue',
|
'SetDisclosureTriangleLastValue',
|
||||||
# Unavailable in CW Pro 3 libraries
|
# Unavailable in CW Pro 3 libraries
|
||||||
'SetUpControlTextColor',
|
'SetUpControlTextColor',
|
||||||
|
# Generally Bad News
|
||||||
|
'GetControlProperty',
|
||||||
|
'SetControlProperty',
|
||||||
|
'GetControlPropertySize',
|
||||||
]
|
]
|
||||||
|
|
||||||
def makeblacklisttypes(self):
|
def makeblacklisttypes(self):
|
||||||
|
|
|
@ -80,7 +80,7 @@ ControlFontStyle_Convert(v, itself)
|
||||||
QdRGB_Convert, &itself->backColor);
|
QdRGB_Convert, &itself->backColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TrackControl callback support */
|
/* TrackControl and HandleControlClick callback support */
|
||||||
static PyObject *tracker;
|
static PyObject *tracker;
|
||||||
static ControlActionUPP mytracker_upp;
|
static ControlActionUPP mytracker_upp;
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ mytracker(ctl, part)
|
||||||
if (rv)
|
if (rv)
|
||||||
Py_DECREF(rv);
|
Py_DECREF(rv);
|
||||||
else
|
else
|
||||||
PySys_WriteStderr("TrackControl: exception in tracker function\\n");
|
PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class MyObjectDefinition(ObjectIdentityMixin, GlobalObjectDefinition):
|
||||||
GlobalObjectDefinition.outputInitStructMembers(self)
|
GlobalObjectDefinition.outputInitStructMembers(self)
|
||||||
Output("SetControlReference(itself, (long)it);")
|
Output("SetControlReference(itself, (long)it);")
|
||||||
def outputCleanupStructMembers(self):
|
def outputCleanupStructMembers(self):
|
||||||
Output("if (self->ob_itself) SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
|
Output("if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
|
||||||
|
|
||||||
# Create the generator groups and link them
|
# Create the generator groups and link them
|
||||||
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
|
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
|
||||||
|
@ -221,6 +221,119 @@ f = ManualGenerator("TrackControl", trackcontrol_body);
|
||||||
#f.docstring = "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
|
#f.docstring = "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
|
||||||
object.add(f)
|
object.add(f)
|
||||||
|
|
||||||
|
# CJW - added 5/12/99
|
||||||
|
# Manual generator for HandleControlClick, as for TrackControl
|
||||||
|
handlecontrolclick_body = """
|
||||||
|
ControlPartCode _rv;
|
||||||
|
Point startPoint;
|
||||||
|
SInt16 modifiers;
|
||||||
|
ControlActionUPP upp = 0;
|
||||||
|
PyObject *callback = 0;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(_args, "O&h|O",
|
||||||
|
PyMac_GetPoint, &startPoint,
|
||||||
|
&modifiers,
|
||||||
|
&callback))
|
||||||
|
return NULL;
|
||||||
|
if (callback && callback != Py_None) {
|
||||||
|
if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
|
||||||
|
upp = (ControlActionUPP)-1;
|
||||||
|
else {
|
||||||
|
settrackfunc(callback);
|
||||||
|
upp = mytracker_upp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_rv = HandleControlClick(_self->ob_itself,
|
||||||
|
startPoint,
|
||||||
|
modifiers,
|
||||||
|
upp);
|
||||||
|
clrtrackfunc();
|
||||||
|
_res = Py_BuildValue("h",
|
||||||
|
_rv);
|
||||||
|
return _res;
|
||||||
|
"""
|
||||||
|
|
||||||
|
f = ManualGenerator("HandleControlClick", handlecontrolclick_body);
|
||||||
|
#f.docstring = "(Point startPoint, Integer modifiers, [,trackercallback])
|
||||||
|
-> (ControlPartCode _rv)"
|
||||||
|
object.add(f)
|
||||||
|
|
||||||
|
# Manual Generator for SetControlData
|
||||||
|
setcontroldata_body = """
|
||||||
|
OSErr _err;
|
||||||
|
ControlPartCode inPart;
|
||||||
|
ResType inTagName;
|
||||||
|
Size bufferSize;
|
||||||
|
Ptr buffer;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(_args, "hO&s#",
|
||||||
|
&inPart,
|
||||||
|
PyMac_GetOSType, &inTagName,
|
||||||
|
&buffer, &bufferSize))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
_err = SetControlData(_self->ob_itself,
|
||||||
|
inPart,
|
||||||
|
inTagName,
|
||||||
|
bufferSize,
|
||||||
|
buffer);
|
||||||
|
|
||||||
|
if (_err != noErr)
|
||||||
|
return PyMac_Error(_err);
|
||||||
|
_res = Py_None;
|
||||||
|
return _res;
|
||||||
|
"""
|
||||||
|
|
||||||
|
f = ManualGenerator("SetControlData", setcontroldata_body);
|
||||||
|
#f.docstring = "(stuff) -> None"
|
||||||
|
object.add(f)
|
||||||
|
|
||||||
|
# Manual Generator for GetControlData
|
||||||
|
getcontroldata_body = """
|
||||||
|
OSErr _err;
|
||||||
|
ControlPartCode inPart;
|
||||||
|
ResType inTagName;
|
||||||
|
Size bufferSize;
|
||||||
|
Ptr buffer;
|
||||||
|
Size outSize;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(_args, "hO&",
|
||||||
|
&inPart,
|
||||||
|
PyMac_GetOSType, &inTagName))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* allocate a buffer for the data */
|
||||||
|
_err = GetControlDataSize(_self->ob_itself,
|
||||||
|
inPart,
|
||||||
|
inTagName,
|
||||||
|
&bufferSize);
|
||||||
|
if (_err != noErr)
|
||||||
|
return PyMac_Error(_err);
|
||||||
|
buffer = PyMem_NEW(char, bufferSize);
|
||||||
|
if (buffer == NULL)
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
|
||||||
|
_err = GetControlData(_self->ob_itself,
|
||||||
|
inPart,
|
||||||
|
inTagName,
|
||||||
|
bufferSize,
|
||||||
|
buffer,
|
||||||
|
&outSize);
|
||||||
|
|
||||||
|
if (_err != noErr) {
|
||||||
|
PyMem_DEL(buffer);
|
||||||
|
return PyMac_Error(_err);
|
||||||
|
}
|
||||||
|
_res = Py_BuildValue("s#", buffer, outSize);
|
||||||
|
PyMem_DEL(buffer);
|
||||||
|
return _res;
|
||||||
|
"""
|
||||||
|
|
||||||
|
f = ManualGenerator("GetControlData", getcontroldata_body);
|
||||||
|
#f.docstring = "(part, type) -> String"
|
||||||
|
object.add(f)
|
||||||
|
# end CJW
|
||||||
|
|
||||||
# And manual generators to get/set popup menu information
|
# And manual generators to get/set popup menu information
|
||||||
getpopupdata_body = """
|
getpopupdata_body = """
|
||||||
PopupPrivateDataHandle hdl;
|
PopupPrivateDataHandle hdl;
|
||||||
|
|
Loading…
Reference in New Issue