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
*PMObj_New(PixMapHandle
);
44 extern int PMObj_Convert(PyObject
*, PixMapHandle
*);
46 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
51 ** Parse/generate ComponentDescriptor records
53 PyObject
*FMRec_New(itself
)
57 return Py_BuildValue("O&O&O&O&O&",
58 PyMac_BuildFixed
, itself
->ascent
,
59 PyMac_BuildFixed
, itself
->descent
,
60 PyMac_BuildFixed
, itself
->leading
,
61 PyMac_BuildFixed
, itself
->widMax
,
62 ResObj_New
, itself
->wTabHandle
);
67 FMRec_Convert(v
, p_itself
)
71 return PyArg_ParseTuple(v
, "O&O&O&O&O&",
72 PyMac_GetFixed
, &itself
->ascent
,
73 PyMac_GetFixed
, &itself
->descent
,
74 PyMac_GetFixed
, &itself
->leading
,
75 PyMac_GetFixed
, &itself
->widMax
,
76 ResObj_Convert
, &itself
->wTabHandle
);
81 static PyObject
*Fm_Error
;
83 static PyObject
*Fm_InitFonts(_self
, _args
)
87 PyObject
*_res
= NULL
;
88 if (!PyArg_ParseTuple(_args
, ""))
96 static PyObject
*Fm_GetFontName(_self
, _args
)
100 PyObject
*_res
= NULL
;
103 if (!PyArg_ParseTuple(_args
, "h",
106 GetFontName(familyID
,
108 _res
= Py_BuildValue("O&",
109 PyMac_BuildStr255
, name
);
113 static PyObject
*Fm_GetFNum(_self
, _args
)
117 PyObject
*_res
= NULL
;
120 if (!PyArg_ParseTuple(_args
, "O&",
121 PyMac_GetStr255
, name
))
125 _res
= Py_BuildValue("h",
130 static PyObject
*Fm_RealFont(_self
, _args
)
134 PyObject
*_res
= NULL
;
138 if (!PyArg_ParseTuple(_args
, "hh",
142 _rv
= RealFont(fontNum
,
144 _res
= Py_BuildValue("b",
149 static PyObject
*Fm_SetFontLock(_self
, _args
)
153 PyObject
*_res
= NULL
;
155 if (!PyArg_ParseTuple(_args
, "b",
158 SetFontLock(lockFlag
);
164 static PyObject
*Fm_SetFScaleDisable(_self
, _args
)
168 PyObject
*_res
= NULL
;
169 Boolean fscaleDisable
;
170 if (!PyArg_ParseTuple(_args
, "b",
173 SetFScaleDisable(fscaleDisable
);
179 static PyObject
*Fm_FontMetrics(_self
, _args
)
183 PyObject
*_res
= NULL
;
184 FMetricRec theMetrics
;
185 if (!PyArg_ParseTuple(_args
, ""))
187 FontMetrics(&theMetrics
);
188 _res
= Py_BuildValue("O&",
189 FMRec_New
, &theMetrics
);
193 static PyObject
*Fm_SetFractEnable(_self
, _args
)
197 PyObject
*_res
= NULL
;
199 if (!PyArg_ParseTuple(_args
, "b",
202 SetFractEnable(fractEnable
);
208 static PyObject
*Fm_GetDefFontSize(_self
, _args
)
212 PyObject
*_res
= NULL
;
214 if (!PyArg_ParseTuple(_args
, ""))
216 _rv
= GetDefFontSize();
217 _res
= Py_BuildValue("h",
222 static PyObject
*Fm_IsOutline(_self
, _args
)
226 PyObject
*_res
= NULL
;
230 if (!PyArg_ParseTuple(_args
, "O&O&",
231 PyMac_GetPoint
, &numer
,
232 PyMac_GetPoint
, &denom
))
234 _rv
= IsOutline(numer
,
236 _res
= Py_BuildValue("b",
241 static PyObject
*Fm_SetOutlinePreferred(_self
, _args
)
245 PyObject
*_res
= NULL
;
246 Boolean outlinePreferred
;
247 if (!PyArg_ParseTuple(_args
, "b",
250 SetOutlinePreferred(outlinePreferred
);
256 static PyObject
*Fm_GetOutlinePreferred(_self
, _args
)
260 PyObject
*_res
= NULL
;
262 if (!PyArg_ParseTuple(_args
, ""))
264 _rv
= GetOutlinePreferred();
265 _res
= Py_BuildValue("b",
270 static PyObject
*Fm_SetPreserveGlyph(_self
, _args
)
274 PyObject
*_res
= NULL
;
275 Boolean preserveGlyph
;
276 if (!PyArg_ParseTuple(_args
, "b",
279 SetPreserveGlyph(preserveGlyph
);
285 static PyObject
*Fm_GetPreserveGlyph(_self
, _args
)
289 PyObject
*_res
= NULL
;
291 if (!PyArg_ParseTuple(_args
, ""))
293 _rv
= GetPreserveGlyph();
294 _res
= Py_BuildValue("b",
299 static PyObject
*Fm_FlushFonts(_self
, _args
)
303 PyObject
*_res
= NULL
;
305 if (!PyArg_ParseTuple(_args
, ""))
308 if (_err
!= noErr
) return PyMac_Error(_err
);
314 static PyObject
*Fm_GetSysFont(_self
, _args
)
318 PyObject
*_res
= NULL
;
320 if (!PyArg_ParseTuple(_args
, ""))
323 _res
= Py_BuildValue("h",
328 static PyObject
*Fm_GetAppFont(_self
, _args
)
332 PyObject
*_res
= NULL
;
334 if (!PyArg_ParseTuple(_args
, ""))
337 _res
= Py_BuildValue("h",
342 static PyMethodDef Fm_methods
[] = {
343 {"InitFonts", (PyCFunction
)Fm_InitFonts
, 1,
345 {"GetFontName", (PyCFunction
)Fm_GetFontName
, 1,
346 "(short familyID) -> (Str255 name)"},
347 {"GetFNum", (PyCFunction
)Fm_GetFNum
, 1,
348 "(Str255 name) -> (short familyID)"},
349 {"RealFont", (PyCFunction
)Fm_RealFont
, 1,
350 "(short fontNum, short size) -> (Boolean _rv)"},
351 {"SetFontLock", (PyCFunction
)Fm_SetFontLock
, 1,
352 "(Boolean lockFlag) -> None"},
353 {"SetFScaleDisable", (PyCFunction
)Fm_SetFScaleDisable
, 1,
354 "(Boolean fscaleDisable) -> None"},
355 {"FontMetrics", (PyCFunction
)Fm_FontMetrics
, 1,
356 "() -> (FMetricRec theMetrics)"},
357 {"SetFractEnable", (PyCFunction
)Fm_SetFractEnable
, 1,
358 "(Boolean fractEnable) -> None"},
359 {"GetDefFontSize", (PyCFunction
)Fm_GetDefFontSize
, 1,
360 "() -> (short _rv)"},
361 {"IsOutline", (PyCFunction
)Fm_IsOutline
, 1,
362 "(Point numer, Point denom) -> (Boolean _rv)"},
363 {"SetOutlinePreferred", (PyCFunction
)Fm_SetOutlinePreferred
, 1,
364 "(Boolean outlinePreferred) -> None"},
365 {"GetOutlinePreferred", (PyCFunction
)Fm_GetOutlinePreferred
, 1,
366 "() -> (Boolean _rv)"},
367 {"SetPreserveGlyph", (PyCFunction
)Fm_SetPreserveGlyph
, 1,
368 "(Boolean preserveGlyph) -> None"},
369 {"GetPreserveGlyph", (PyCFunction
)Fm_GetPreserveGlyph
, 1,
370 "() -> (Boolean _rv)"},
371 {"FlushFonts", (PyCFunction
)Fm_FlushFonts
, 1,
373 {"GetSysFont", (PyCFunction
)Fm_GetSysFont
, 1,
374 "() -> (short _rv)"},
375 {"GetAppFont", (PyCFunction
)Fm_GetAppFont
, 1,
376 "() -> (short _rv)"},
391 m
= Py_InitModule("Fm", Fm_methods
);
392 d
= PyModule_GetDict(m
);
393 Fm_Error
= PyMac_GetOSErrException();
394 if (Fm_Error
== NULL
||
395 PyDict_SetItemString(d
, "Error", Fm_Error
) != 0)
396 Py_FatalError("can't initialize Fm.Error");
399 /* ========================= End module Fm ========================== */