2 /* =========================== Module Fm ============================ */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
48 ** Parse/generate ComponentDescriptor records
50 PyObject
*FMRec_New(itself
)
54 return Py_BuildValue("O&O&O&O&O&",
55 PyMac_BuildFixed
, itself
->ascent
,
56 PyMac_BuildFixed
, itself
->descent
,
57 PyMac_BuildFixed
, itself
->leading
,
58 PyMac_BuildFixed
, itself
->widMax
,
59 ResObj_New
, itself
->wTabHandle
);
64 FMRec_Convert(v
, p_itself
)
68 return PyArg_ParseTuple(v
, "O&O&O&O&O&",
69 PyMac_GetFixed
, &itself
->ascent
,
70 PyMac_GetFixed
, &itself
->descent
,
71 PyMac_GetFixed
, &itself
->leading
,
72 PyMac_GetFixed
, &itself
->widMax
,
73 ResObj_Convert
, &itself
->wTabHandle
);
78 static PyObject
*Fm_Error
;
80 static PyObject
*Fm_InitFonts(_self
, _args
)
84 PyObject
*_res
= NULL
;
85 if (!PyArg_ParseTuple(_args
, ""))
93 static PyObject
*Fm_GetFontName(_self
, _args
)
97 PyObject
*_res
= NULL
;
100 if (!PyArg_ParseTuple(_args
, "h",
103 GetFontName(familyID
,
105 _res
= Py_BuildValue("O&",
106 PyMac_BuildStr255
, name
);
110 static PyObject
*Fm_GetFNum(_self
, _args
)
114 PyObject
*_res
= NULL
;
117 if (!PyArg_ParseTuple(_args
, "O&",
118 PyMac_GetStr255
, name
))
122 _res
= Py_BuildValue("h",
127 static PyObject
*Fm_RealFont(_self
, _args
)
131 PyObject
*_res
= NULL
;
135 if (!PyArg_ParseTuple(_args
, "hh",
139 _rv
= RealFont(fontNum
,
141 _res
= Py_BuildValue("b",
146 static PyObject
*Fm_SetFontLock(_self
, _args
)
150 PyObject
*_res
= NULL
;
152 if (!PyArg_ParseTuple(_args
, "b",
155 SetFontLock(lockFlag
);
161 static PyObject
*Fm_SetFScaleDisable(_self
, _args
)
165 PyObject
*_res
= NULL
;
166 Boolean fscaleDisable
;
167 if (!PyArg_ParseTuple(_args
, "b",
170 SetFScaleDisable(fscaleDisable
);
176 static PyObject
*Fm_FontMetrics(_self
, _args
)
180 PyObject
*_res
= NULL
;
181 FMetricRec theMetrics
;
182 if (!PyArg_ParseTuple(_args
, ""))
184 FontMetrics(&theMetrics
);
185 _res
= Py_BuildValue("O&",
186 FMRec_New
, &theMetrics
);
190 static PyObject
*Fm_SetFractEnable(_self
, _args
)
194 PyObject
*_res
= NULL
;
196 if (!PyArg_ParseTuple(_args
, "b",
199 SetFractEnable(fractEnable
);
205 static PyObject
*Fm_GetDefFontSize(_self
, _args
)
209 PyObject
*_res
= NULL
;
211 if (!PyArg_ParseTuple(_args
, ""))
213 _rv
= GetDefFontSize();
214 _res
= Py_BuildValue("h",
219 static PyObject
*Fm_IsOutline(_self
, _args
)
223 PyObject
*_res
= NULL
;
227 if (!PyArg_ParseTuple(_args
, "O&O&",
228 PyMac_GetPoint
, &numer
,
229 PyMac_GetPoint
, &denom
))
231 _rv
= IsOutline(numer
,
233 _res
= Py_BuildValue("b",
238 static PyObject
*Fm_SetOutlinePreferred(_self
, _args
)
242 PyObject
*_res
= NULL
;
243 Boolean outlinePreferred
;
244 if (!PyArg_ParseTuple(_args
, "b",
247 SetOutlinePreferred(outlinePreferred
);
253 static PyObject
*Fm_GetOutlinePreferred(_self
, _args
)
257 PyObject
*_res
= NULL
;
259 if (!PyArg_ParseTuple(_args
, ""))
261 _rv
= GetOutlinePreferred();
262 _res
= Py_BuildValue("b",
267 static PyObject
*Fm_SetPreserveGlyph(_self
, _args
)
271 PyObject
*_res
= NULL
;
272 Boolean preserveGlyph
;
273 if (!PyArg_ParseTuple(_args
, "b",
276 SetPreserveGlyph(preserveGlyph
);
282 static PyObject
*Fm_GetPreserveGlyph(_self
, _args
)
286 PyObject
*_res
= NULL
;
288 if (!PyArg_ParseTuple(_args
, ""))
290 _rv
= GetPreserveGlyph();
291 _res
= Py_BuildValue("b",
296 static PyObject
*Fm_FlushFonts(_self
, _args
)
300 PyObject
*_res
= NULL
;
302 if (!PyArg_ParseTuple(_args
, ""))
305 if (_err
!= noErr
) return PyMac_Error(_err
);
311 static PyObject
*Fm_GetSysFont(_self
, _args
)
315 PyObject
*_res
= NULL
;
317 if (!PyArg_ParseTuple(_args
, ""))
320 _res
= Py_BuildValue("h",
325 static PyObject
*Fm_GetAppFont(_self
, _args
)
329 PyObject
*_res
= NULL
;
331 if (!PyArg_ParseTuple(_args
, ""))
334 _res
= Py_BuildValue("h",
339 static PyMethodDef Fm_methods
[] = {
340 {"InitFonts", (PyCFunction
)Fm_InitFonts
, 1,
342 {"GetFontName", (PyCFunction
)Fm_GetFontName
, 1,
343 "(short familyID) -> (Str255 name)"},
344 {"GetFNum", (PyCFunction
)Fm_GetFNum
, 1,
345 "(Str255 name) -> (short familyID)"},
346 {"RealFont", (PyCFunction
)Fm_RealFont
, 1,
347 "(short fontNum, short size) -> (Boolean _rv)"},
348 {"SetFontLock", (PyCFunction
)Fm_SetFontLock
, 1,
349 "(Boolean lockFlag) -> None"},
350 {"SetFScaleDisable", (PyCFunction
)Fm_SetFScaleDisable
, 1,
351 "(Boolean fscaleDisable) -> None"},
352 {"FontMetrics", (PyCFunction
)Fm_FontMetrics
, 1,
353 "() -> (FMetricRec theMetrics)"},
354 {"SetFractEnable", (PyCFunction
)Fm_SetFractEnable
, 1,
355 "(Boolean fractEnable) -> None"},
356 {"GetDefFontSize", (PyCFunction
)Fm_GetDefFontSize
, 1,
357 "() -> (short _rv)"},
358 {"IsOutline", (PyCFunction
)Fm_IsOutline
, 1,
359 "(Point numer, Point denom) -> (Boolean _rv)"},
360 {"SetOutlinePreferred", (PyCFunction
)Fm_SetOutlinePreferred
, 1,
361 "(Boolean outlinePreferred) -> None"},
362 {"GetOutlinePreferred", (PyCFunction
)Fm_GetOutlinePreferred
, 1,
363 "() -> (Boolean _rv)"},
364 {"SetPreserveGlyph", (PyCFunction
)Fm_SetPreserveGlyph
, 1,
365 "(Boolean preserveGlyph) -> None"},
366 {"GetPreserveGlyph", (PyCFunction
)Fm_GetPreserveGlyph
, 1,
367 "() -> (Boolean _rv)"},
368 {"FlushFonts", (PyCFunction
)Fm_FlushFonts
, 1,
370 {"GetSysFont", (PyCFunction
)Fm_GetSysFont
, 1,
371 "() -> (short _rv)"},
372 {"GetAppFont", (PyCFunction
)Fm_GetAppFont
, 1,
373 "() -> (short _rv)"},
388 m
= Py_InitModule("Fm", Fm_methods
);
389 d
= PyModule_GetDict(m
);
390 Fm_Error
= PyMac_GetOSErrException();
391 if (Fm_Error
== NULL
||
392 PyDict_SetItemString(d
, "Error", Fm_Error
) != 0)
393 Py_FatalError("can't initialize Fm.Error");
396 /* ========================= End module Fm ========================== */