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

Skip to content

Commit 4f6fe52

Browse files
committed
- Added DrawThemeTextBox()
- fixed GetThemeTextDimensions(): it has an in/out Point arg, not just out.
1 parent 1ca65c0 commit 4f6fe52

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

Mac/Modules/app/_Appmodule.c

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,40 @@ static PyObject *App_UseThemeFont(PyObject *_self, PyObject *_args)
660660

661661
#if TARGET_API_MAC_CARBON
662662

663+
static PyObject *App_DrawThemeTextBox(PyObject *_self, PyObject *_args)
664+
{
665+
PyObject *_res = NULL;
666+
OSStatus _err;
667+
CFStringRef inString;
668+
ThemeFontID inFontID;
669+
ThemeDrawState inState;
670+
Boolean inWrapToWidth;
671+
Rect inBoundingBox;
672+
SInt16 inJust;
673+
if (!PyArg_ParseTuple(_args, "O&HlbO&h",
674+
CFStringRefObj_Convert, &inString,
675+
&inFontID,
676+
&inState,
677+
&inWrapToWidth,
678+
PyMac_GetRect, &inBoundingBox,
679+
&inJust))
680+
return NULL;
681+
_err = DrawThemeTextBox(inString,
682+
inFontID,
683+
inState,
684+
inWrapToWidth,
685+
&inBoundingBox,
686+
inJust,
687+
NULL);
688+
if (_err != noErr) return PyMac_Error(_err);
689+
Py_INCREF(Py_None);
690+
_res = Py_None;
691+
return _res;
692+
}
693+
#endif
694+
695+
#if TARGET_API_MAC_CARBON
696+
663697
static PyObject *App_TruncateThemeText(PyObject *_self, PyObject *_args)
664698
{
665699
PyObject *_res = NULL;
@@ -702,11 +736,12 @@ static PyObject *App_GetThemeTextDimensions(PyObject *_self, PyObject *_args)
702736
Boolean inWrapToWidth;
703737
Point ioBounds;
704738
SInt16 outBaseline;
705-
if (!PyArg_ParseTuple(_args, "O&Hlb",
739+
if (!PyArg_ParseTuple(_args, "O&HlbO&",
706740
CFStringRefObj_Convert, &inString,
707741
&inFontID,
708742
&inState,
709-
&inWrapToWidth))
743+
&inWrapToWidth,
744+
PyMac_GetPoint, &ioBounds))
710745
return NULL;
711746
_err = GetThemeTextDimensions(inString,
712747
inFontID,
@@ -1203,14 +1238,19 @@ static PyMethodDef App_methods[] = {
12031238
{"UseThemeFont", (PyCFunction)App_UseThemeFont, 1,
12041239
"(ThemeFontID inFontID, ScriptCode inScript) -> None"},
12051240

1241+
#if TARGET_API_MAC_CARBON
1242+
{"DrawThemeTextBox", (PyCFunction)App_DrawThemeTextBox, 1,
1243+
"(CFStringRef inString, ThemeFontID inFontID, ThemeDrawState inState, Boolean inWrapToWidth, Rect inBoundingBox, SInt16 inJust) -> None"},
1244+
#endif
1245+
12061246
#if TARGET_API_MAC_CARBON
12071247
{"TruncateThemeText", (PyCFunction)App_TruncateThemeText, 1,
12081248
"(CFMutableStringRef inString, ThemeFontID inFontID, ThemeDrawState inState, SInt16 inPixelWidthLimit, TruncCode inTruncWhere) -> (Boolean outTruncated)"},
12091249
#endif
12101250

12111251
#if TARGET_API_MAC_CARBON
12121252
{"GetThemeTextDimensions", (PyCFunction)App_GetThemeTextDimensions, 1,
1213-
"(CFStringRef inString, ThemeFontID inFontID, ThemeDrawState inState, Boolean inWrapToWidth) -> (Point ioBounds, SInt16 outBaseline)"},
1253+
"(CFStringRef inString, ThemeFontID inFontID, ThemeDrawState inState, Boolean inWrapToWidth, Point ioBounds) -> (Point ioBounds, SInt16 outBaseline)"},
12141254
#endif
12151255

12161256
#if TARGET_API_MAC_CARBON

Mac/Modules/app/appscan.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def makeblacklistnames(self):
4848
"appearanceBadTextColorIndexErr",
4949
"appearanceThemeHasNoAccents",
5050
"appearanceBadCursorIndexErr",
51-
"DrawThemeTextBox", # Funny void* out param
5251
]
5352

5453
def makegreylist(self):
@@ -58,6 +57,7 @@ def makegreylist(self):
5857
'GetThemeTextShadowOutset',
5958
'GetThemeTextDimensions',
6059
'TruncateThemeText',
60+
'DrawThemeTextBox',
6161
])]
6262

6363
def makeblacklisttypes(self):
@@ -80,6 +80,10 @@ def makeblacklisttypes(self):
8080

8181
def makerepairinstructions(self):
8282
return [
83+
([("void", 'inContext', "OutMode")],
84+
[("NULL", 'inContext', "InMode")]),
85+
([("Point", 'ioBounds', "OutMode")],
86+
[("Point", 'ioBounds', "InOutMode")]),
8387
]
8488

8589
if __name__ == "__main__":

Mac/Modules/app/appsupport.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX)
2828

2929
RgnHandle = FakeType("(RgnHandle)0")
30+
NULL = FakeType("NULL")
31+
3032
# XXXX Should be next, but this will break a lot of code...
3133
# RgnHandle = OpaqueByValueType("RgnHandle", "OptResObj")
3234

0 commit comments

Comments
 (0)