]> granicus.if.org Git - python/commitdiff
Today's Carbon Toolbox addition: QDTextBounds()
authorJust van Rossum <just@letterror.com>
Mon, 7 Jan 2002 14:15:02 +0000 (14:15 +0000)
committerJust van Rossum <just@letterror.com>
Mon, 7 Jan 2002 14:15:02 +0000 (14:15 +0000)
Mac/Modules/fm/_Fmmodule.c
Mac/Modules/fm/fmscan.py
Mac/Modules/fm/fmsupport.py

index c5ab18a14d6bb2c4b9aee9adcaaf87f861d22aed..009f34d2f92bed3030f33b82d963e650e4a7c250 100644 (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}
 };
 
index 6ade54707acca86560bc8a8f3f093a3140d4c88f..7b2b142aee128ab5cd82c944a0f47805444c2fb1 100644 (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):
index 3b407160debbdffc2c74ba2264562fb5314e263a..10d3fce801f534688166f257f65102a071bde6e6 100644 (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>