diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-06-02 21:35:07 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-06-02 21:35:07 (GMT) |
commit | e79dc76f53dfa18fb08c35f71b049259642c0142 (patch) | |
tree | 2d9cc6228cc713336a01d9ff09571eacff3a2ba0 /Mac/Modules/ctl | |
parent | 33d1ad28cba273b94c70ffc22deb6c53b0c1b068 (diff) | |
download | cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.zip cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.tar.gz cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.tar.bz2 |
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Macmodule and macosmodule have also been carbonified. Some functionality is still missing there.
Diffstat (limited to 'Mac/Modules/ctl')
-rw-r--r-- | Mac/Modules/ctl/Ctlmodule.c | 236 | ||||
-rw-r--r-- | Mac/Modules/ctl/ctlscan.py | 23 | ||||
-rw-r--r-- | Mac/Modules/ctl/ctlsupport.py | 22 |
3 files changed, 246 insertions, 35 deletions
diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c index 3cdf377..37f8c5a 100644 --- a/Mac/Modules/ctl/Ctlmodule.c +++ b/Mac/Modules/ctl/Ctlmodule.c @@ -46,8 +46,11 @@ extern PyObject *WinObj_WhichWindow(WindowPtr); #define as_Control(h) ((ControlHandle)h) #define as_Resource(ctl) ((Handle)ctl) +#ifdef TARGET_API_MAC_CARBON +#define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp) +#else #define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect)) - +#endif #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */ @@ -85,10 +88,12 @@ ControlFontStyle_Convert(v, itself) /* TrackControl and HandleControlClick callback support */ static PyObject *tracker; static ControlActionUPP mytracker_upp; +#ifndef TARGET_API_MAC_CARBON_NOTYET static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneTrackingUPP mytrackingproc_upp; +#endif extern int settrackfunc(PyObject *); /* forward */ extern void clrtrackfunc(void); /* forward */ @@ -730,18 +735,19 @@ static PyObject *CtlObj_RemoveControlProperty(_self, _args) PyObject *_args; { PyObject *_res = NULL; - OSStatus _rv; + OSStatus _err; OSType propertyCreator; OSType propertyTag; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &propertyCreator, PyMac_GetOSType, &propertyTag)) return NULL; - _rv = RemoveControlProperty(_self->ob_itself, - propertyCreator, - propertyTag); - _res = Py_BuildValue("l", - _rv); + _err = RemoveControlProperty(_self->ob_itself, + propertyCreator, + propertyTag); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; return _res; } @@ -750,18 +756,19 @@ static PyObject *CtlObj_GetControlRegion(_self, _args) PyObject *_args; { PyObject *_res = NULL; - OSStatus _rv; + OSStatus _err; ControlPartCode inPart; RgnHandle outRegion; if (!PyArg_ParseTuple(_args, "hO&", &inPart, ResObj_Convert, &outRegion)) return NULL; - _rv = GetControlRegion(_self->ob_itself, - inPart, - outRegion); - _res = Py_BuildValue("l", - _rv); + _err = GetControlRegion(_self->ob_itself, + inPart, + outRegion); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; return _res; } @@ -809,6 +816,8 @@ static PyObject *CtlObj_GetControlReference(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *CtlObj_GetAuxiliaryControlRecord(_self, _args) ControlObject *_self; PyObject *_args; @@ -825,6 +834,9 @@ static PyObject *CtlObj_GetAuxiliaryControlRecord(_self, _args) ResObj_New, acHndl); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *CtlObj_SetControlColor(_self, _args) ControlObject *_self; @@ -841,6 +853,151 @@ static PyObject *CtlObj_SetControlColor(_self, _args) _res = Py_None; return _res; } +#endif + +static PyObject *CtlObj_GetBevelButtonMenuValue(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 outValue; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetBevelButtonMenuValue(_self->ob_itself, + &outValue); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("h", + outValue); + return _res; +} + +static PyObject *CtlObj_SetBevelButtonMenuValue(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 inValue; + if (!PyArg_ParseTuple(_args, "h", + &inValue)) + return NULL; + _err = SetBevelButtonMenuValue(_self->ob_itself, + inValue); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_GetBevelButtonMenuHandle(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + MenuHandle outHandle; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetBevelButtonMenuHandle(_self->ob_itself, + &outHandle); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + MenuObj_New, outHandle); + return _res; +} + +static PyObject *CtlObj_SetBevelButtonTransform(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + IconTransformType transform; + if (!PyArg_ParseTuple(_args, "h", + &transform)) + return NULL; + _err = SetBevelButtonTransform(_self->ob_itself, + transform); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_SetImageWellTransform(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + IconTransformType inTransform; + if (!PyArg_ParseTuple(_args, "h", + &inTransform)) + return NULL; + _err = SetImageWellTransform(_self->ob_itself, + inTransform); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_GetTabContentRect(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + Rect outContentRect; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetTabContentRect(_self->ob_itself, + &outContentRect); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &outContentRect); + return _res; +} + +static PyObject *CtlObj_SetTabEnabled(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 inTabToHilite; + Boolean inEnabled; + if (!PyArg_ParseTuple(_args, "hb", + &inTabToHilite, + &inEnabled)) + return NULL; + _err = SetTabEnabled(_self->ob_itself, + inTabToHilite, + inEnabled); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_SetDisclosureTriangleLastValue(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 inValue; + if (!PyArg_ParseTuple(_args, "h", + &inValue)) + return NULL; + _err = SetDisclosureTriangleLastValue(_self->ob_itself, + inValue); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} static PyObject *CtlObj_SendControlMessage(_self, _args) ControlObject *_self; @@ -1276,6 +1433,8 @@ static PyObject *CtlObj_GetControlDataHandle(_self, _args) } +#ifndef TARGET_API_MAC_CARBON_NOTYET + static PyObject *CtlObj_SetControlDataCallback(_self, _args) ControlObject *_self; PyObject *_args; @@ -1308,6 +1467,9 @@ static PyObject *CtlObj_SetControlDataCallback(_self, _args) return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET static PyObject *CtlObj_GetPopupData(_self, _args) ControlObject *_self; @@ -1328,6 +1490,9 @@ static PyObject *CtlObj_GetPopupData(_self, _args) return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET static PyObject *CtlObj_SetPopupData(_self, _args) ControlObject *_self; @@ -1352,6 +1517,7 @@ static PyObject *CtlObj_SetPopupData(_self, _args) return Py_None; } +#endif static PyMethodDef CtlObj_methods[] = { {"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1, @@ -1427,19 +1593,41 @@ static PyMethodDef CtlObj_methods[] = { {"IsValidControlHandle", (PyCFunction)CtlObj_IsValidControlHandle, 1, "() -> (Boolean _rv)"}, {"RemoveControlProperty", (PyCFunction)CtlObj_RemoveControlProperty, 1, - "(OSType propertyCreator, OSType propertyTag) -> (OSStatus _rv)"}, + "(OSType propertyCreator, OSType propertyTag) -> None"}, {"GetControlRegion", (PyCFunction)CtlObj_GetControlRegion, 1, - "(ControlPartCode inPart, RgnHandle outRegion) -> (OSStatus _rv)"}, + "(ControlPartCode inPart, RgnHandle outRegion) -> None"}, {"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1, "() -> (ControlVariant _rv)"}, {"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1, "(SInt32 data) -> None"}, {"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1, "() -> (SInt32 _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"GetAuxiliaryControlRecord", (PyCFunction)CtlObj_GetAuxiliaryControlRecord, 1, "() -> (Boolean _rv, AuxCtlHandle acHndl)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"SetControlColor", (PyCFunction)CtlObj_SetControlColor, 1, "(CCTabHandle newColorTable) -> None"}, +#endif + {"GetBevelButtonMenuValue", (PyCFunction)CtlObj_GetBevelButtonMenuValue, 1, + "() -> (SInt16 outValue)"}, + {"SetBevelButtonMenuValue", (PyCFunction)CtlObj_SetBevelButtonMenuValue, 1, + "(SInt16 inValue) -> None"}, + {"GetBevelButtonMenuHandle", (PyCFunction)CtlObj_GetBevelButtonMenuHandle, 1, + "() -> (MenuHandle outHandle)"}, + {"SetBevelButtonTransform", (PyCFunction)CtlObj_SetBevelButtonTransform, 1, + "(IconTransformType transform) -> None"}, + {"SetImageWellTransform", (PyCFunction)CtlObj_SetImageWellTransform, 1, + "(IconTransformType inTransform) -> None"}, + {"GetTabContentRect", (PyCFunction)CtlObj_GetTabContentRect, 1, + "() -> (Rect outContentRect)"}, + {"SetTabEnabled", (PyCFunction)CtlObj_SetTabEnabled, 1, + "(SInt16 inTabToHilite, Boolean inEnabled) -> None"}, + {"SetDisclosureTriangleLastValue", (PyCFunction)CtlObj_SetDisclosureTriangleLastValue, 1, + "(SInt16 inValue) -> None"}, {"SendControlMessage", (PyCFunction)CtlObj_SendControlMessage, 1, "(SInt16 inMessage, SInt32 inParam) -> (SInt32 _rv)"}, {"EmbedControl", (PyCFunction)CtlObj_EmbedControl, 1, @@ -1476,12 +1664,21 @@ static PyMethodDef CtlObj_methods[] = { "(ResObj) -> None"}, {"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1, "(part, type) -> ResObj"}, + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"SetControlDataCallback", (PyCFunction)CtlObj_SetControlDataCallback, 1, "(callbackfunc) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1, NULL}, +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1, NULL}, +#endif {NULL, NULL, 0} }; @@ -1954,9 +2151,7 @@ clrtrackfunc() } static pascal void -mytracker(ctl, part) - ControlHandle ctl; - short part; +mytracker(ControlHandle ctl, short part) { PyObject *args, *rv=0; @@ -1971,6 +2166,7 @@ mytracker(ctl, part) PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n"); } +#ifndef TARGET_API_MAC_CARBON_NOTYET static int setcallback(self, which, callback, uppp) ControlObject *self; @@ -2086,7 +2282,7 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc Py_XDECREF(rv); return (ControlPartCode)c_rv; } - +#endif void initCtl() @@ -2097,10 +2293,12 @@ void initCtl() mytracker_upp = NewControlActionProc(mytracker); +#ifndef TARGET_API_MAC_CARBON_NOTYET mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc); myidleproc_upp = NewControlUserPaneIdleProc(myidleproc); myhittestproc_upp = NewControlUserPaneHitTestProc(myhittestproc); mytrackingproc_upp = NewControlUserPaneTrackingProc(mytrackingproc); +#endif m = Py_InitModule("Ctl", Ctl_methods); diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py index 63d32f3..0f46c0e 100644 --- a/Mac/Modules/ctl/ctlscan.py +++ b/Mac/Modules/ctl/ctlscan.py @@ -48,17 +48,17 @@ class MyScanner(Scanner): 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition 'kControlProgressBarIndeterminateTag', # ditto # The following are unavailable for static 68k (appearance manager) - 'GetBevelButtonMenuValue', - 'SetBevelButtonMenuValue', - 'GetBevelButtonMenuHandle', - 'SetBevelButtonTransform', +## 'GetBevelButtonMenuValue', +## 'SetBevelButtonMenuValue', +## 'GetBevelButtonMenuHandle', +## 'SetBevelButtonTransform', 'SetBevelButtonGraphicAlignment', 'SetBevelButtonTextAlignment', 'SetBevelButtonTextPlacement', - 'SetImageWellTransform', - 'GetTabContentRect', - 'SetTabEnabled', - 'SetDisclosureTriangleLastValue', +## 'SetImageWellTransform', +## 'GetTabContentRect', +## 'SetTabEnabled', +## 'SetDisclosureTriangleLastValue', ## # Unavailable in CW Pro 3 libraries ## 'SetUpControlTextColor', ## # Unavailable in Jack's CW Pro 5.1 libraries @@ -79,6 +79,13 @@ class MyScanner(Scanner): 'GetControlPropertySize', ] + def makegreylist(self): + return [ + ('#ifndef TARGET_API_MAC_CARBON', [ + 'GetAuxiliaryControlRecord', + 'SetControlColor', + ])] + def makeblacklisttypes(self): return [ 'ProcPtr', diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py index f2d4be1..a8c2d64 100644 --- a/Mac/Modules/ctl/ctlsupport.py +++ b/Mac/Modules/ctl/ctlsupport.py @@ -46,8 +46,11 @@ includestuff = includestuff + """ #define as_Control(h) ((ControlHandle)h) #define as_Resource(ctl) ((Handle)ctl) +#ifdef TARGET_API_MAC_CARBON +#define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp) +#else #define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect)) - +#endif #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */ @@ -85,10 +88,12 @@ ControlFontStyle_Convert(v, itself) /* TrackControl and HandleControlClick callback support */ static PyObject *tracker; static ControlActionUPP mytracker_upp; +#ifndef TARGET_API_MAC_CARBON_NOTYET static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneTrackingUPP mytrackingproc_upp; +#endif extern int settrackfunc(PyObject *); /* forward */ extern void clrtrackfunc(void); /* forward */ @@ -147,9 +152,7 @@ clrtrackfunc() } static pascal void -mytracker(ctl, part) - ControlHandle ctl; - short part; +mytracker(ControlHandle ctl, short part) { PyObject *args, *rv=0; @@ -164,6 +167,7 @@ mytracker(ctl, part) PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n"); } +#ifndef TARGET_API_MAC_CARBON_NOTYET static int setcallback(self, which, callback, uppp) ControlObject *self; @@ -279,15 +283,17 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc Py_XDECREF(rv); return (ControlPartCode)c_rv; } - +#endif """ initstuff = initstuff + """ mytracker_upp = NewControlActionProc(mytracker); +#ifndef TARGET_API_MAC_CARBON_NOTYET mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc); myidleproc_upp = NewControlUserPaneIdleProc(myidleproc); myhittestproc_upp = NewControlUserPaneHitTestProc(myhittestproc); mytrackingproc_upp = NewControlUserPaneTrackingProc(mytrackingproc); +#endif """ class MyObjectDefinition(ObjectIdentityMixin, GlobalObjectDefinition): @@ -564,7 +570,7 @@ _res = Py_None; return _res; """ -f = ManualGenerator("SetControlDataCallback", setcontroldatacallback_body); +f = ManualGenerator("SetControlDataCallback", setcontroldatacallback_body, condition="#ifndef TARGET_API_MAC_CARBON_NOTYET"); f.docstring = lambda: "(callbackfunc) -> None" object.add(f) @@ -582,7 +588,7 @@ _res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID); HUnlock((Handle)hdl); return _res; """ -f = ManualGenerator("GetPopupData", getpopupdata_body) +f = ManualGenerator("GetPopupData", getpopupdata_body, condition="#ifndef TARGET_API_MAC_CARBON_NOTYET") object.add(f) setpopupdata_body = """ @@ -602,7 +608,7 @@ hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData; Py_INCREF(Py_None); return Py_None; """ -f = ManualGenerator("SetPopupData", setpopupdata_body) +f = ManualGenerator("SetPopupData", setpopupdata_body, condition="#ifndef TARGET_API_MAC_CARBON_NOTYET") object.add(f) |