Today's Carbon Toolbox addition: QDTextBounds()

This commit is contained in:
Just van Rossum 2002-01-07 14:15:02 +00:00
parent e843e482ce
commit ca3b2ffbb9
3 changed files with 30 additions and 1 deletions

View File

@ -293,6 +293,24 @@ static PyObject *Fm_GetAppFont(PyObject *_self, PyObject *_args)
return _res;
}
static PyObject *Fm_QDTextBounds(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
char *inText__in__;
int inText__len__;
int inText__in_len__;
Rect bounds;
if (!PyArg_ParseTuple(_args, "s#",
&inText__in__, &inText__in_len__))
return NULL;
inText__len__ = inText__in_len__;
QDTextBounds(inText__len__, inText__in__,
&bounds);
_res = Py_BuildValue("O&",
PyMac_BuildRect, &bounds);
return _res;
}
static PyMethodDef Fm_methods[] = {
#if !TARGET_API_MAC_CARBON
@ -337,6 +355,8 @@ static PyMethodDef Fm_methods[] = {
"() -> (short _rv)"},
{"GetAppFont", (PyCFunction)Fm_GetAppFont, 1,
"() -> (short _rv)"},
{"QDTextBounds", (PyCFunction)Fm_QDTextBounds, 1,
"(Buffer inText) -> (Rect bounds)"},
{NULL, NULL, 0}
};

View File

@ -54,7 +54,7 @@ class MyScanner(Scanner):
return [
"FMInput_ptr", # Not needed for now
"FMOutPtr", # Ditto
"void_ptr", # Don't know how to do this right now
## "void_ptr", # Don't know how to do this right now
"FontInfo", # Ditto
]
@ -62,6 +62,8 @@ class MyScanner(Scanner):
return [
([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
[('TextBuffer', 'inText', 'InMode')]),
]
def writeinitialdefs(self):

View File

@ -18,6 +18,13 @@ from macsupport import *
# Create the type objects
class RevVarInputBufferType(VarInputBufferType):
def passInput(self, name):
return "%s__len__, %s__in__" % (name, name)
TextBuffer = RevVarInputBufferType()
includestuff = includestuff + """
#ifdef WITHOUT_FRAMEWORKS
#include <Fonts.h>