Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7eb48e3

Browse files
committed
Moved a bunch of routines from "blacklisted" to "graylisted", as they _are_
available in OSX (mach-o) but not in CarbonLib (neither on OSX or OS9).
1 parent c7cb9ed commit 7eb48e3

2 files changed

Lines changed: 263 additions & 10 deletions

File tree

Mac/Modules/ctl/_Ctlmodule.c

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,62 @@ static PyObject *CtlObj_SetControlVisibility(ControlObject *_self, PyObject *_ar
311311
return _res;
312312
}
313313

314+
#if TARGET_API_MAC_OSX
315+
316+
static PyObject *CtlObj_IsControlEnabled(ControlObject *_self, PyObject *_args)
317+
{
318+
PyObject *_res = NULL;
319+
Boolean _rv;
320+
#ifndef IsControlEnabled
321+
PyMac_PRECHECK(IsControlEnabled);
322+
#endif
323+
if (!PyArg_ParseTuple(_args, ""))
324+
return NULL;
325+
_rv = IsControlEnabled(_self->ob_itself);
326+
_res = Py_BuildValue("b",
327+
_rv);
328+
return _res;
329+
}
330+
#endif
331+
332+
#if TARGET_API_MAC_OSX
333+
334+
static PyObject *CtlObj_EnableControl(ControlObject *_self, PyObject *_args)
335+
{
336+
PyObject *_res = NULL;
337+
OSStatus _err;
338+
#ifndef EnableControl
339+
PyMac_PRECHECK(EnableControl);
340+
#endif
341+
if (!PyArg_ParseTuple(_args, ""))
342+
return NULL;
343+
_err = EnableControl(_self->ob_itself);
344+
if (_err != noErr) return PyMac_Error(_err);
345+
Py_INCREF(Py_None);
346+
_res = Py_None;
347+
return _res;
348+
}
349+
#endif
350+
351+
#if TARGET_API_MAC_OSX
352+
353+
static PyObject *CtlObj_DisableControl(ControlObject *_self, PyObject *_args)
354+
{
355+
PyObject *_res = NULL;
356+
OSStatus _err;
357+
#ifndef DisableControl
358+
PyMac_PRECHECK(DisableControl);
359+
#endif
360+
if (!PyArg_ParseTuple(_args, ""))
361+
return NULL;
362+
_err = DisableControl(_self->ob_itself);
363+
if (_err != noErr) return PyMac_Error(_err);
364+
Py_INCREF(Py_None);
365+
_res = Py_None;
366+
return _res;
367+
}
368+
#endif
369+
314370
static PyObject *CtlObj_Draw1Control(ControlObject *_self, PyObject *_args)
315371
{
316372
PyObject *_res = NULL;
@@ -2615,6 +2671,27 @@ static PyObject *CtlObj_SetDataBrowserEditText(ControlObject *_self, PyObject *_
26152671
}
26162672
#endif
26172673

2674+
#if TARGET_API_MAC_OSX
2675+
2676+
static PyObject *CtlObj_CopyDataBrowserEditText(ControlObject *_self, PyObject *_args)
2677+
{
2678+
PyObject *_res = NULL;
2679+
OSStatus _err;
2680+
CFStringRef text;
2681+
#ifndef CopyDataBrowserEditText
2682+
PyMac_PRECHECK(CopyDataBrowserEditText);
2683+
#endif
2684+
if (!PyArg_ParseTuple(_args, ""))
2685+
return NULL;
2686+
_err = CopyDataBrowserEditText(_self->ob_itself,
2687+
&text);
2688+
if (_err != noErr) return PyMac_Error(_err);
2689+
_res = Py_BuildValue("O&",
2690+
CFStringRefObj_New, text);
2691+
return _res;
2692+
}
2693+
#endif
2694+
26182695
#if TARGET_API_MAC_CARBON
26192696

26202697
static PyObject *CtlObj_GetDataBrowserEditText(ControlObject *_self, PyObject *_args)
@@ -3795,6 +3872,21 @@ static PyMethodDef CtlObj_methods[] = {
37953872
"() -> None"},
37963873
{"SetControlVisibility", (PyCFunction)CtlObj_SetControlVisibility, 1,
37973874
"(Boolean inIsVisible, Boolean inDoDraw) -> None"},
3875+
3876+
#if TARGET_API_MAC_OSX
3877+
{"IsControlEnabled", (PyCFunction)CtlObj_IsControlEnabled, 1,
3878+
"() -> (Boolean _rv)"},
3879+
#endif
3880+
3881+
#if TARGET_API_MAC_OSX
3882+
{"EnableControl", (PyCFunction)CtlObj_EnableControl, 1,
3883+
"() -> None"},
3884+
#endif
3885+
3886+
#if TARGET_API_MAC_OSX
3887+
{"DisableControl", (PyCFunction)CtlObj_DisableControl, 1,
3888+
"() -> None"},
3889+
#endif
37983890
{"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1,
37993891
"() -> None"},
38003892
{"GetBestControlRect", (PyCFunction)CtlObj_GetBestControlRect, 1,
@@ -4209,6 +4301,11 @@ static PyMethodDef CtlObj_methods[] = {
42094301
"(CFStringRef text) -> None"},
42104302
#endif
42114303

4304+
#if TARGET_API_MAC_OSX
4305+
{"CopyDataBrowserEditText", (PyCFunction)CtlObj_CopyDataBrowserEditText, 1,
4306+
"() -> (CFStringRef text)"},
4307+
#endif
4308+
42124309
#if TARGET_API_MAC_CARBON
42134310
{"GetDataBrowserEditText", (PyCFunction)CtlObj_GetDataBrowserEditText, 1,
42144311
"(CFMutableStringRef text) -> None"},
@@ -4971,6 +5068,41 @@ static PyObject *Ctl_CreateProgressBarControl(PyObject *_self, PyObject *_args)
49715068
}
49725069
#endif
49735070

5071+
#if TARGET_API_MAC_OSX
5072+
5073+
static PyObject *Ctl_CreateRelevanceBarControl(PyObject *_self, PyObject *_args)
5074+
{
5075+
PyObject *_res = NULL;
5076+
OSStatus _err;
5077+
WindowPtr window;
5078+
Rect boundsRect;
5079+
SInt32 value;
5080+
SInt32 minimum;
5081+
SInt32 maximum;
5082+
ControlHandle outControl;
5083+
#ifndef CreateRelevanceBarControl
5084+
PyMac_PRECHECK(CreateRelevanceBarControl);
5085+
#endif
5086+
if (!PyArg_ParseTuple(_args, "O&O&lll",
5087+
WinObj_Convert, &window,
5088+
PyMac_GetRect, &boundsRect,
5089+
&value,
5090+
&minimum,
5091+
&maximum))
5092+
return NULL;
5093+
_err = CreateRelevanceBarControl(window,
5094+
&boundsRect,
5095+
value,
5096+
minimum,
5097+
maximum,
5098+
&outControl);
5099+
if (_err != noErr) return PyMac_Error(_err);
5100+
_res = Py_BuildValue("O&",
5101+
CtlObj_New, outControl);
5102+
return _res;
5103+
}
5104+
#endif
5105+
49745106
#if TARGET_API_MAC_CARBON
49755107

49765108
static PyObject *Ctl_CreateLittleArrowsControl(PyObject *_self, PyObject *_args)
@@ -5734,6 +5866,70 @@ static PyObject *Ctl_CreateScrollingTextBoxControl(PyObject *_self, PyObject *_a
57345866
}
57355867
#endif
57365868

5869+
#if TARGET_API_MAC_OSX
5870+
5871+
static PyObject *Ctl_CreateDisclosureButtonControl(PyObject *_self, PyObject *_args)
5872+
{
5873+
PyObject *_res = NULL;
5874+
OSStatus _err;
5875+
WindowPtr inWindow;
5876+
Rect inBoundsRect;
5877+
SInt32 inValue;
5878+
Boolean inAutoToggles;
5879+
ControlHandle outControl;
5880+
#ifndef CreateDisclosureButtonControl
5881+
PyMac_PRECHECK(CreateDisclosureButtonControl);
5882+
#endif
5883+
if (!PyArg_ParseTuple(_args, "O&O&lb",
5884+
WinObj_Convert, &inWindow,
5885+
PyMac_GetRect, &inBoundsRect,
5886+
&inValue,
5887+
&inAutoToggles))
5888+
return NULL;
5889+
_err = CreateDisclosureButtonControl(inWindow,
5890+
&inBoundsRect,
5891+
inValue,
5892+
inAutoToggles,
5893+
&outControl);
5894+
if (_err != noErr) return PyMac_Error(_err);
5895+
_res = Py_BuildValue("O&",
5896+
CtlObj_New, outControl);
5897+
return _res;
5898+
}
5899+
#endif
5900+
5901+
#if TARGET_API_MAC_OSX
5902+
5903+
static PyObject *Ctl_CreateRoundButtonControl(PyObject *_self, PyObject *_args)
5904+
{
5905+
PyObject *_res = NULL;
5906+
OSStatus _err;
5907+
WindowPtr inWindow;
5908+
Rect inBoundsRect;
5909+
SInt16 inSize;
5910+
ControlButtonContentInfo inContent;
5911+
ControlHandle outControl;
5912+
#ifndef CreateRoundButtonControl
5913+
PyMac_PRECHECK(CreateRoundButtonControl);
5914+
#endif
5915+
if (!PyArg_ParseTuple(_args, "O&O&hO&",
5916+
WinObj_Convert, &inWindow,
5917+
PyMac_GetRect, &inBoundsRect,
5918+
&inSize,
5919+
ControlButtonContentInfo_Convert, &inContent))
5920+
return NULL;
5921+
_err = CreateRoundButtonControl(inWindow,
5922+
&inBoundsRect,
5923+
inSize,
5924+
&inContent,
5925+
&outControl);
5926+
if (_err != noErr) return PyMac_Error(_err);
5927+
_res = Py_BuildValue("O&",
5928+
CtlObj_New, outControl);
5929+
return _res;
5930+
}
5931+
#endif
5932+
57375933
#if TARGET_API_MAC_CARBON
57385934

57395935
static PyObject *Ctl_CreateDataBrowserControl(PyObject *_self, PyObject *_args)
@@ -5763,6 +5959,41 @@ static PyObject *Ctl_CreateDataBrowserControl(PyObject *_self, PyObject *_args)
57635959
}
57645960
#endif
57655961

5962+
#if TARGET_API_MAC_OSX
5963+
5964+
static PyObject *Ctl_CreateEditUnicodeTextControl(PyObject *_self, PyObject *_args)
5965+
{
5966+
PyObject *_res = NULL;
5967+
OSStatus _err;
5968+
WindowPtr window;
5969+
Rect boundsRect;
5970+
CFStringRef text;
5971+
Boolean isPassword;
5972+
ControlFontStyleRec style;
5973+
ControlHandle outControl;
5974+
#ifndef CreateEditUnicodeTextControl
5975+
PyMac_PRECHECK(CreateEditUnicodeTextControl);
5976+
#endif
5977+
if (!PyArg_ParseTuple(_args, "O&O&O&bO&",
5978+
WinObj_Convert, &window,
5979+
PyMac_GetRect, &boundsRect,
5980+
CFStringRefObj_Convert, &text,
5981+
&isPassword,
5982+
ControlFontStyle_Convert, &style))
5983+
return NULL;
5984+
_err = CreateEditUnicodeTextControl(window,
5985+
&boundsRect,
5986+
text,
5987+
isPassword,
5988+
&style,
5989+
&outControl);
5990+
if (_err != noErr) return PyMac_Error(_err);
5991+
_res = Py_BuildValue("O&",
5992+
CtlObj_New, outControl);
5993+
return _res;
5994+
}
5995+
#endif
5996+
57665997
static PyObject *Ctl_FindControlUnderMouse(PyObject *_self, PyObject *_args)
57675998
{
57685999
PyObject *_res = NULL;
@@ -5924,6 +6155,11 @@ static PyMethodDef Ctl_methods[] = {
59246155
"(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, Boolean indeterminate) -> (ControlHandle outControl)"},
59256156
#endif
59266157

6158+
#if TARGET_API_MAC_OSX
6159+
{"CreateRelevanceBarControl", (PyCFunction)Ctl_CreateRelevanceBarControl, 1,
6160+
"(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum) -> (ControlHandle outControl)"},
6161+
#endif
6162+
59276163
#if TARGET_API_MAC_CARBON
59286164
{"CreateLittleArrowsControl", (PyCFunction)Ctl_CreateLittleArrowsControl, 1,
59296165
"(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, SInt32 increment) -> (ControlHandle outControl)"},
@@ -6039,10 +6275,25 @@ static PyMethodDef Ctl_methods[] = {
60396275
"(WindowPtr window, Rect boundsRect, SInt16 contentResID, Boolean autoScroll, UInt32 delayBeforeAutoScroll, UInt32 delayBetweenAutoScroll, UInt16 autoScrollAmount) -> (ControlHandle outControl)"},
60406276
#endif
60416277

6278+
#if TARGET_API_MAC_OSX
6279+
{"CreateDisclosureButtonControl", (PyCFunction)Ctl_CreateDisclosureButtonControl, 1,
6280+
"(WindowPtr inWindow, Rect inBoundsRect, SInt32 inValue, Boolean inAutoToggles) -> (ControlHandle outControl)"},
6281+
#endif
6282+
6283+
#if TARGET_API_MAC_OSX
6284+
{"CreateRoundButtonControl", (PyCFunction)Ctl_CreateRoundButtonControl, 1,
6285+
"(WindowPtr inWindow, Rect inBoundsRect, SInt16 inSize, ControlButtonContentInfo inContent) -> (ControlHandle outControl)"},
6286+
#endif
6287+
60426288
#if TARGET_API_MAC_CARBON
60436289
{"CreateDataBrowserControl", (PyCFunction)Ctl_CreateDataBrowserControl, 1,
60446290
"(WindowPtr window, Rect boundsRect, OSType style) -> (ControlHandle outControl)"},
60456291
#endif
6292+
6293+
#if TARGET_API_MAC_OSX
6294+
{"CreateEditUnicodeTextControl", (PyCFunction)Ctl_CreateEditUnicodeTextControl, 1,
6295+
"(WindowPtr window, Rect boundsRect, CFStringRef text, Boolean isPassword, ControlFontStyleRec style) -> (ControlHandle outControl)"},
6296+
#endif
60466297
{"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1,
60476298
"(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)"},
60486299
{"as_Control", (PyCFunction)Ctl_as_Control, 1,

Mac/Modules/ctl/ctlscan.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ def makeblacklistnames(self):
8888
'GetControlPropertySize',
8989
'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
9090
'CreateTabsControl', # wrote manually
91-
# these are part of Carbon, yet not in CarbonLib; OSX-only
92-
'CreateRoundButtonControl',
93-
'CreateDisclosureButtonControl',
94-
'CreateRelevanceBarControl',
95-
'DisableControl',
96-
'EnableControl',
97-
'IsControlEnabled',
98-
'CreateEditUnicodeTextControl',
99-
'CopyDataBrowserEditText',
10091

10192
# too lazy for now
10293
'GetImageWellContentInfo',
@@ -252,7 +243,18 @@ def makegreylist(self):
252243
'SetControlBounds',
253244
'SetControlPopupMenuHandle',
254245
'SetControlPopupMenuID',
255-
])]
246+
]),
247+
('#if TARGET_API_MAC_OSX', [
248+
'CreateRoundButtonControl',
249+
'CreateDisclosureButtonControl',
250+
'CreateRelevanceBarControl',
251+
'DisableControl',
252+
'EnableControl',
253+
'IsControlEnabled',
254+
'CreateEditUnicodeTextControl',
255+
'CopyDataBrowserEditText',
256+
]),
257+
]
256258

257259
def makeblacklisttypes(self):
258260
return [

0 commit comments

Comments
 (0)