summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1996-01-11 16:17:14 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1996-01-11 16:17:14 (GMT)
commit3a50f8a51eeb57b964b2a54c714249f2128fc2c6 (patch)
tree692c82422cddcfbc01fb40dac6e48e4e6037a892 /Mac
parentbf220a16aac34cb5a53bdef78c1ab49529d8c2d1 (diff)
downloadcpython-3a50f8a51eeb57b964b2a54c714249f2128fc2c6.zip
cpython-3a50f8a51eeb57b964b2a54c714249f2128fc2c6.tar.gz
cpython-3a50f8a51eeb57b964b2a54c714249f2128fc2c6.tar.bz2
- Added FontInfo support
- Added (read-)access to members of [C]GrafPort object
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Lib/toolbox/QuickDraw.py4
-rw-r--r--Mac/Modules/qd/Qdmodule.c104
-rw-r--r--Mac/Modules/qd/qdgen.py9
-rw-r--r--Mac/Modules/qd/qdscan.py7
-rw-r--r--Mac/Modules/qd/qdsupport.py91
5 files changed, 178 insertions, 37 deletions
diff --git a/Mac/Lib/toolbox/QuickDraw.py b/Mac/Lib/toolbox/QuickDraw.py
index b826210..18af679 100644
--- a/Mac/Lib/toolbox/QuickDraw.py
+++ b/Mac/Lib/toolbox/QuickDraw.py
@@ -1,4 +1,4 @@
-# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDraw.h'
+# Generated from 'flap:CodeWarrior:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDraw.h'
invalColReq = -1
srcCopy = 0
@@ -90,7 +90,7 @@ kVerticalConstraint = 1
kHorizontalConstraint = 2
kCursorImageMajorVersion = 0x0001
kCursorImageMinorVersion = 0x0000
-# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDrawText.h'
+# Generated from 'flap:CodeWarrior:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDrawText.h'
leftCaret = 0
rightCaret = -1
diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c
index adbba87..fd70eec 100644
--- a/Mac/Modules/qd/Qdmodule.c
+++ b/Mac/Modules/qd/Qdmodule.c
@@ -74,6 +74,19 @@ QdRGB_Convert(v, p_itself)
return 1;
}
+/*
+** Generate FontInfo records
+*/
+static
+PyObject *QdFI_New(itself)
+ FontInfo *itself;
+{
+
+ return Py_BuildValue("hhhh", itself->ascent, itself->descent,
+ itself->widMax, itself->leading);
+}
+
+
static PyObject *Qd_Error;
@@ -132,21 +145,70 @@ static PyObject *GrafObj_getattr(self, name)
GrafPortObject *self;
char *name;
{
- if ( strcmp(name, "device") == 0 )
- return PyInt_FromLong((long)self->ob_itself->device);
- if ( strcmp(name, "portBits") == 0 ) {
- CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
+
+ { CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
+
+ if ( strcmp(name, "data") == 0 )
+ return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort));
+
+ if ( (itself_color->portVersion&0xc000) == 0xc000 ) {
+ /* Color-only attributes */
- if ( (itself_color->portVersion&0xc000) == 0xc000 )
- /* XXXX Do we need HLock() stuff here?? */
- return BMObj_New((BitMapPtr)*itself_color->portPixMap);
- else
- return BMObj_New(&self->ob_itself->portBits);
+ if ( strcmp(name, "portBits") == 0 )
+ /* XXXX Do we need HLock() stuff here?? */
+ return BMObj_New((BitMapPtr)*itself_color->portPixMap);
+ if ( strcmp(name, "grafVars") == 0 )
+ return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn);
+ if ( strcmp(name, "chExtra") == 0 )
+ return Py_BuildValue("h", itself_color->chExtra);
+ if ( strcmp(name, "pnLocHFrac") == 0 )
+ return Py_BuildValue("h", itself_color->pnLocHFrac);
+ } else {
+ /* Mono-only attributes */
+ if ( strcmp(name, "portBits") == 0 )
+ return BMObj_New(&self->ob_itself->portBits);
+ }
+ /*
+ ** Accessible for both color/mono windows.
+ ** portVersion is really color-only, but we put it here
+ ** for convenience
+ */
+ if ( strcmp(name, "portVersion") == 0 )
+ return Py_BuildValue("h", itself_color->portVersion);
+ if ( strcmp(name, "device") == 0 )
+ return PyInt_FromLong((long)self->ob_itself->device);
+ if ( strcmp(name, "portRect") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
+ if ( strcmp(name, "visRgn") == 0 )
+ return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn);
+ if ( strcmp(name, "clipRgn") == 0 )
+ return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn);
+ if ( strcmp(name, "bkPat") == 0 )
+ return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern));
+ if ( strcmp(name, "fillPat") == 0 )
+ return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern));
+ if ( strcmp(name, "pnLoc") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc);
+ if ( strcmp(name, "pnSize") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize);
+ if ( strcmp(name, "pnMode") == 0 )
+ return Py_BuildValue("h", self->ob_itself->pnMode);
+ if ( strcmp(name, "pnPat") == 0 )
+ return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern));
+ if ( strcmp(name, "pnVis") == 0 )
+ return Py_BuildValue("h", self->ob_itself->pnVis);
+ if ( strcmp(name, "txFont") == 0 )
+ return Py_BuildValue("h", self->ob_itself->txFont);
+ if ( strcmp(name, "txFace") == 0 )
+ return Py_BuildValue("h", (short)self->ob_itself->txFace);
+ if ( strcmp(name, "txMode") == 0 )
+ return Py_BuildValue("h", self->ob_itself->txMode);
+ if ( strcmp(name, "txSize") == 0 )
+ return Py_BuildValue("h", self->ob_itself->txSize);
+ if ( strcmp(name, "spExtra") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra);
+ /* XXXX Add more, as needed */
}
- if ( strcmp(name, "portRect") == 0 )
- return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
- /* XXXX Add more, as needed */
-
return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name);
}
@@ -3323,6 +3385,20 @@ static PyObject *Qd_TextWidth(_self, _args)
return _res;
}
+static PyObject *Qd_GetFontInfo(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ FontInfo info;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ GetFontInfo(&info);
+ _res = Py_BuildValue("O&",
+ QdFI_New, &info);
+ return _res;
+}
+
static PyObject *Qd_CharExtra(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -3738,6 +3814,8 @@ static PyMethodDef Qd_methods[] = {
"(Str255 s) -> (short _rv)"},
{"TextWidth", (PyCFunction)Qd_TextWidth, 1,
"(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"},
+ {"GetFontInfo", (PyCFunction)Qd_GetFontInfo, 1,
+ "() -> (FontInfo info)"},
{"CharExtra", (PyCFunction)Qd_CharExtra, 1,
"(Fixed extra) -> None"},
{"BitMap", (PyCFunction)Qd_BitMap, 1,
diff --git a/Mac/Modules/qd/qdgen.py b/Mac/Modules/qd/qdgen.py
index df3ad98..4df58f7 100644
--- a/Mac/Modules/qd/qdgen.py
+++ b/Mac/Modules/qd/qdgen.py
@@ -1,4 +1,4 @@
-# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDraw.h'
+# Generated from 'flap:CodeWarrior:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDraw.h'
f = Function(void, 'SetPort',
(GrafPtr, 'port', InMode),
@@ -926,7 +926,7 @@ f = Function(void, 'GetIndPattern',
)
functions.append(f)
-# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDrawText.h'
+# Generated from 'flap:CodeWarrior:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDrawText.h'
f = Function(void, 'TextFont',
(short, 'font', InMode),
@@ -987,6 +987,11 @@ f = Function(short, 'TextWidth',
)
functions.append(f)
+f = Function(void, 'GetFontInfo',
+ (FontInfo, 'info', OutMode),
+)
+functions.append(f)
+
f = Function(void, 'CharExtra',
(Fixed, 'extra', InMode),
)
diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py
index 6c87ce0..fd654f3 100644
--- a/Mac/Modules/qd/qdscan.py
+++ b/Mac/Modules/qd/qdscan.py
@@ -85,17 +85,12 @@ class MyScanner(Scanner):
'ColorSearchProcPtr',
'ColorSearchUPP',
'ConstPatternParam',
-## 'Pattern_ptr',
-## 'Pattern',
-## 'Cursor_ptr',
'DeviceLoopDrawingProcPtr',
'DeviceLoopFlags',
- 'FontInfo',
+## 'FontInfo',
'GDHandle',
'GrafVerb',
'OpenCPicParams_ptr',
-## 'PenState',
-## 'PenState_ptr',
'Ptr',
'QDProcs',
'ReqListRec',
diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py
index e295c14..e40e2f5 100644
--- a/Mac/Modules/qd/qdsupport.py
+++ b/Mac/Modules/qd/qdsupport.py
@@ -45,6 +45,7 @@ GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj")
BitMap_ptr = OpaqueByValueType("BitMapPtr", "BMObj")
RGBColor = OpaqueType('RGBColor', 'QdRGB')
RGBColor_ptr = RGBColor
+FontInfo = OpaqueType('FontInfo', 'QdFI')
Cursor_ptr = StructInputBufferType('Cursor')
Pattern = StructOutputBufferType('Pattern')
@@ -82,6 +83,19 @@ QdRGB_Convert(v, p_itself)
return 1;
}
+/*
+** Generate FontInfo records
+*/
+static
+PyObject *QdFI_New(itself)
+ FontInfo *itself;
+{
+
+ return Py_BuildValue("hhhh", itself->ascent, itself->descent,
+ itself->widMax, itself->leading);
+}
+
+
"""
variablestuff = """
@@ -133,21 +147,70 @@ class MyGRObjectDefinition(GlobalObjectDefinition):
Output("return 1;")
OutRbrace()
def outputGetattrHook(self):
- Output("""if ( strcmp(name, "device") == 0 )
- return PyInt_FromLong((long)self->ob_itself->device);
- if ( strcmp(name, "portBits") == 0 ) {
- CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
+ Output("""
+ { CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
+
+ if ( strcmp(name, "data") == 0 )
+ return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort));
+
+ if ( (itself_color->portVersion&0xc000) == 0xc000 ) {
+ /* Color-only attributes */
- if ( (itself_color->portVersion&0xc000) == 0xc000 )
- /* XXXX Do we need HLock() stuff here?? */
- return BMObj_New((BitMapPtr)*itself_color->portPixMap);
- else
- return BMObj_New(&self->ob_itself->portBits);
- }
- if ( strcmp(name, "portRect") == 0 )
- return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
- /* XXXX Add more, as needed */
- """)
+ if ( strcmp(name, "portBits") == 0 )
+ /* XXXX Do we need HLock() stuff here?? */
+ return BMObj_New((BitMapPtr)*itself_color->portPixMap);
+ if ( strcmp(name, "grafVars") == 0 )
+ return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn);
+ if ( strcmp(name, "chExtra") == 0 )
+ return Py_BuildValue("h", itself_color->chExtra);
+ if ( strcmp(name, "pnLocHFrac") == 0 )
+ return Py_BuildValue("h", itself_color->pnLocHFrac);
+ } else {
+ /* Mono-only attributes */
+ if ( strcmp(name, "portBits") == 0 )
+ return BMObj_New(&self->ob_itself->portBits);
+ }
+ /*
+ ** Accessible for both color/mono windows.
+ ** portVersion is really color-only, but we put it here
+ ** for convenience
+ */
+ if ( strcmp(name, "portVersion") == 0 )
+ return Py_BuildValue("h", itself_color->portVersion);
+ if ( strcmp(name, "device") == 0 )
+ return PyInt_FromLong((long)self->ob_itself->device);
+ if ( strcmp(name, "portRect") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
+ if ( strcmp(name, "visRgn") == 0 )
+ return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn);
+ if ( strcmp(name, "clipRgn") == 0 )
+ return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn);
+ if ( strcmp(name, "bkPat") == 0 )
+ return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern));
+ if ( strcmp(name, "fillPat") == 0 )
+ return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern));
+ if ( strcmp(name, "pnLoc") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc);
+ if ( strcmp(name, "pnSize") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize);
+ if ( strcmp(name, "pnMode") == 0 )
+ return Py_BuildValue("h", self->ob_itself->pnMode);
+ if ( strcmp(name, "pnPat") == 0 )
+ return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern));
+ if ( strcmp(name, "pnVis") == 0 )
+ return Py_BuildValue("h", self->ob_itself->pnVis);
+ if ( strcmp(name, "txFont") == 0 )
+ return Py_BuildValue("h", self->ob_itself->txFont);
+ if ( strcmp(name, "txFace") == 0 )
+ return Py_BuildValue("h", (short)self->ob_itself->txFace);
+ if ( strcmp(name, "txMode") == 0 )
+ return Py_BuildValue("h", self->ob_itself->txMode);
+ if ( strcmp(name, "txSize") == 0 )
+ return Py_BuildValue("h", self->ob_itself->txSize);
+ if ( strcmp(name, "spExtra") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra);
+ /* XXXX Add more, as needed */
+ }""")
class MyBMObjectDefinition(GlobalObjectDefinition):
def outputCheckNewArg(self):