summaryrefslogtreecommitdiffstats
path: root/Mac/Modules
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1999-12-09 22:49:51 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1999-12-09 22:49:51 (GMT)
commit24c353144ad3afb0375b3a93bb74f6a3eb9bb12b (patch)
tree2acb40bfebdbcee510e15fd32a40b2d1213fd0eb /Mac/Modules
parentd60069cf2eaeac53dc731a8d36702daef79f6288 (diff)
downloadcpython-24c353144ad3afb0375b3a93bb74f6a3eb9bb12b.zip
cpython-24c353144ad3afb0375b3a93bb74f6a3eb9bb12b.tar.gz
cpython-24c353144ad3afb0375b3a93bb74f6a3eb9bb12b.tar.bz2
Fixed a linebreak I forgot, added docstrings, (temporarily) blacklisted a few routines that seem to be missing in my CW Pro 5.1.
Diffstat (limited to 'Mac/Modules')
-rw-r--r--Mac/Modules/ctl/Ctlmodule.c143
-rw-r--r--Mac/Modules/ctl/ctlscan.py12
-rw-r--r--Mac/Modules/ctl/ctlsupport.py9
3 files changed, 147 insertions, 17 deletions
diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c
index 895187e..627ca8f 100644
--- a/Mac/Modules/ctl/Ctlmodule.c
+++ b/Mac/Modules/ctl/Ctlmodule.c
@@ -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;
@@ -127,7 +127,7 @@ CtlObj_Convert(v, p_itself)
static void CtlObj_dealloc(self)
ControlObject *self;
{
- if (self->ob_itself) SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */
+ if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */
PyMem_DEL(self);
}
@@ -717,7 +717,7 @@ static PyObject *CtlObj_CountSubControls(_self, _args)
{
PyObject *_res = NULL;
OSErr _err;
- SInt16 outNumChildren;
+ UInt16 outNumChildren;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = CountSubControls(_self->ob_itself,
@@ -734,7 +734,7 @@ static PyObject *CtlObj_GetIndexedSubControl(_self, _args)
{
PyObject *_res = NULL;
OSErr _err;
- SInt16 inIndex;
+ UInt16 inIndex;
ControlHandle outSubControl;
if (!PyArg_ParseTuple(_args, "h",
&inIndex))
@@ -867,6 +867,119 @@ static PyObject *CtlObj_TrackControl(_self, _args)
}
+static PyObject *CtlObj_HandleControlClick(_self, _args)
+ ControlObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ 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;
+
+}
+
+static PyObject *CtlObj_SetControlData(_self, _args)
+ ControlObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ 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;
+
+}
+
+static PyObject *CtlObj_GetControlData(_self, _args)
+ ControlObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ 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;
+
+}
+
static PyObject *CtlObj_GetPopupData(_self, _args)
ControlObject *_self;
PyObject *_args;
@@ -983,9 +1096,9 @@ static PyMethodDef CtlObj_methods[] = {
{"GetSuperControl", (PyCFunction)CtlObj_GetSuperControl, 1,
"() -> (ControlHandle outParent)"},
{"CountSubControls", (PyCFunction)CtlObj_CountSubControls, 1,
- "() -> (SInt16 outNumChildren)"},
+ "() -> (UInt16 outNumChildren)"},
{"GetIndexedSubControl", (PyCFunction)CtlObj_GetIndexedSubControl, 1,
- "(SInt16 inIndex) -> (ControlHandle outSubControl)"},
+ "(UInt16 inIndex) -> (ControlHandle outSubControl)"},
{"SetControlSupervisor", (PyCFunction)CtlObj_SetControlSupervisor, 1,
"(ControlHandle inBoss) -> None"},
{"GetControlFeatures", (PyCFunction)CtlObj_GetControlFeatures, 1,
@@ -997,7 +1110,13 @@ static PyMethodDef CtlObj_methods[] = {
{"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1,
"() -> None"},
{"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
- NULL},
+ "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"},
+ {"HandleControlClick", (PyCFunction)CtlObj_HandleControlClick, 1,
+ "(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)"},
+ {"SetControlData", (PyCFunction)CtlObj_SetControlData, 1,
+ "(stuff) -> None"},
+ {"GetControlData", (PyCFunction)CtlObj_GetControlData, 1,
+ "(part, type) -> String"},
{"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1,
NULL},
{"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1,
@@ -1437,7 +1556,7 @@ PyObject *
CtlObj_WhichControl(ControlHandle c)
{
PyObject *it;
-
+
if (c == NULL)
it = Py_None;
else {
@@ -1478,7 +1597,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);
@@ -1487,7 +1606,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");
}
diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py
index fd060c0..dc954cf 100644
--- a/Mac/Modules/ctl/ctlscan.py
+++ b/Mac/Modules/ctl/ctlscan.py
@@ -61,6 +61,18 @@ class MyScanner(Scanner):
'SetDisclosureTriangleLastValue',
# Unavailable in CW Pro 3 libraries
'SetUpControlTextColor',
+ # Unavailable in Jack's CW Pro 5.1 libraries
+ 'GetControlRegion',
+ 'RemoveControlProperty',
+ 'IsValidControlHandle',
+ 'SetControl32BitMinimum',
+ 'GetControl32BitMinimum',
+ 'SetControl32BitMaximum',
+ 'GetControl32BitMaximum',
+ 'SetControl32BitValue',
+ 'GetControl32BitValue',
+ 'SetControlViewSize',
+ 'GetControlViewSize',
# Generally Bad News
'GetControlProperty',
'SetControlProperty',
diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py
index 79c83a7..70ae285 100644
--- a/Mac/Modules/ctl/ctlsupport.py
+++ b/Mac/Modules/ctl/ctlsupport.py
@@ -218,7 +218,7 @@ return _res;
"""
f = ManualGenerator("TrackControl", trackcontrol_body);
-#f.docstring = "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
+f.docstring = lambda: "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
object.add(f)
# CJW - added 5/12/99
@@ -254,8 +254,7 @@ return _res;
"""
f = ManualGenerator("HandleControlClick", handlecontrolclick_body);
-#f.docstring = "(Point startPoint, Integer modifiers, [,trackercallback])
--> (ControlPartCode _rv)"
+f.docstring = lambda: "(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)"
object.add(f)
# Manual Generator for SetControlData
@@ -285,7 +284,7 @@ return _res;
"""
f = ManualGenerator("SetControlData", setcontroldata_body);
-#f.docstring = "(stuff) -> None"
+f.docstring = lambda: "(stuff) -> None"
object.add(f)
# Manual Generator for GetControlData
@@ -330,7 +329,7 @@ return _res;
"""
f = ManualGenerator("GetControlData", getcontroldata_body);
-#f.docstring = "(part, type) -> String"
+f.docstring = lambda: "(part, type) -> String"
object.add(f)
# end CJW