summaryrefslogtreecommitdiffstats
path: root/Mac/Modules
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1999-12-09 16:03:50 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1999-12-09 16:03:50 (GMT)
commit229c0868fe76eb83a74fdd6547cc119f1ff24eed (patch)
tree3278eeda66be6d70bbe2a534e34c0861407a4eb6 /Mac/Modules
parent4d56ecf69094824e408ab0be2e5b68ba4b1d9151 (diff)
downloadcpython-229c0868fe76eb83a74fdd6547cc119f1ff24eed.zip
cpython-229c0868fe76eb83a74fdd6547cc119f1ff24eed.tar.gz
cpython-229c0868fe76eb83a74fdd6547cc119f1ff24eed.tar.bz2
Changes by Corran Webster to support {Get,Set}ControlData and
HandleControlClick. Untested.
Diffstat (limited to 'Mac/Modules')
-rw-r--r--Mac/Modules/ctl/ctlscan.py15
-rw-r--r--Mac/Modules/ctl/ctlsupport.py129
2 files changed, 132 insertions, 12 deletions
diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py
index aba07c5..fd060c0 100644
--- a/Mac/Modules/ctl/ctlscan.py
+++ b/Mac/Modules/ctl/ctlscan.py
@@ -42,6 +42,9 @@ class MyScanner(Scanner):
'KillControls', # Implied by close of dialog
'SetCtlAction',
'TrackControl', # Generated manually
+ 'HandleControlClick', # Generated manually
+ 'SetControlData', # Generated manually
+ 'GetControlData', # Generated manually
'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
'kControlProgressBarIndeterminateTag', # ditto
# The following are unavailable for static 68k (appearance manager)
@@ -58,6 +61,10 @@ class MyScanner(Scanner):
'SetDisclosureTriangleLastValue',
# Unavailable in CW Pro 3 libraries
'SetUpControlTextColor',
+ # Generally Bad News
+ 'GetControlProperty',
+ 'SetControlProperty',
+ 'GetControlPropertySize',
]
def makeblacklisttypes(self):
@@ -72,21 +79,21 @@ class MyScanner(Scanner):
return [
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
[("InBuffer", "*", "*")]),
-
+
([("void", "*", "OutMode"), ("long", "*", "InMode"),
("long", "*", "OutMode")],
[("VarVarOutBuffer", "*", "InOutMode")]),
-
+
## # For TrackControl
## ([("ProcPtr", "actionProc", "InMode")],
## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
## ([("ControlActionUPP", "actionProc", "InMode")],
## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
-
+
# For GetControlTitle
([('Str255', 'title', 'InMode')],
[('Str255', 'title', 'OutMode')]),
-
+
([("ControlHandle", "*", "OutMode")],
[("ExistingControlHandle", "*", "*")]),
([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py
index 8d966f9..79c83a7 100644
--- a/Mac/Modules/ctl/ctlsupport.py
+++ b/Mac/Modules/ctl/ctlsupport.py
@@ -75,12 +75,12 @@ ControlFontStyle_Convert(v, itself)
ControlFontStyleRec *itself;
{
return PyArg_ParseTuple(v, "hhhhhhO&O&", &itself->flags,
- &itself->font, &itself->size, &itself->style, &itself->mode,
- &itself->just, QdRGB_Convert, &itself->foreColor,
+ &itself->font, &itself->size, &itself->style, &itself->mode,
+ &itself->just, QdRGB_Convert, &itself->foreColor,
QdRGB_Convert, &itself->backColor);
}
-/* TrackControl callback support */
+/* TrackControl and HandleControlClick callback support */
static PyObject *tracker;
static ControlActionUPP mytracker_upp;
@@ -104,7 +104,7 @@ PyObject *
CtlObj_WhichControl(ControlHandle c)
{
PyObject *it;
-
+
if (c == NULL)
it = Py_None;
else {
@@ -145,7 +145,7 @@ mytracker(ctl, part)
short part;
{
PyObject *args, *rv=0;
-
+
args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
if (args && tracker) {
rv = PyEval_CallObject(tracker, args);
@@ -154,7 +154,7 @@ mytracker(ctl, part)
if (rv)
Py_DECREF(rv);
else
- PySys_WriteStderr("TrackControl: exception in tracker function\\n");
+ PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
}
"""
@@ -169,8 +169,8 @@ class MyObjectDefinition(ObjectIdentityMixin, GlobalObjectDefinition):
GlobalObjectDefinition.outputInitStructMembers(self)
Output("SetControlReference(itself, (long)it);")
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
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
@@ -221,6 +221,119 @@ f = ManualGenerator("TrackControl", trackcontrol_body);
#f.docstring = "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
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
getpopupdata_body = """
PopupPrivateDataHandle hdl;