[pywin32-checkins] /hgrepo/p/py/pywin32/pywin32: full LOGFONT support in win32ui, f...
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2011-11-05 05:23:21
|
changeset 2113b637ed40 in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=2113b637ed40 summary: full LOGFONT support in win32ui, from Kris Hardy diffstat: CHANGES.txt | 4 ++++ Pythonwin/win32font.cpp | 18 ++++++++++++------ Pythonwin/win32util.cpp | 49 +++++++++++++++++++++++++++++++------------------ 3 files changed, 47 insertions(+), 24 deletions(-) diffs (127 lines): diff -r 86f428f44fca -r 2113b637ed40 CHANGES.txt --- a/CHANGES.txt Sat Nov 05 14:41:55 2011 +1100 +++ b/CHANGES.txt Sat Nov 05 16:21:59 2011 +1100 @@ -6,6 +6,10 @@ Since build 216: ---------------- +* The LOGFONT struct implementation (win32util) was extended to support the + full LOGFONT struct as published by Microsoft. This includes changes to + win32util.LogFontToDict and win32util.DictToLogFont. (Feature request + 3433757 by Kris Hardy) * Remove some duplicated menu code from pythonwin which should avoid having py2exe pulling in most of the pythonwin framework in some cases diff -r 86f428f44fca -r 2113b637ed40 Pythonwin/win32font.cpp --- a/Pythonwin/win32font.cpp Sat Nov 05 14:41:55 2011 +1100 +++ b/Pythonwin/win32font.cpp Sat Nov 05 16:21:59 2011 +1100 @@ -27,14 +27,20 @@ PyObject *font_props; PyObject *pydc = NULL; // @pyparm dict|properties||A dictionary containing the font // properties. Valid dictionary keys are:<nl> - // name<nl> - // width<nl> - // height<nl> - // weight<nl> - // italic<nl> + // height<nl> + // width<nl> + // escapement<nl> + // orientation<nl> + // weight<nl> + // italic<nl> // underline<nl> + // strike out<nl> + // charset<nl> + // out precision<nl> + // clip precision<nl> + // quality<nl> // pitch and family<nl> - // charset + // name if (!PyArg_ParseTuple (args, "O|O", &font_props, &pydc) || !PyDict_Check (font_props)) diff -r 86f428f44fca -r 2113b637ed40 Pythonwin/win32util.cpp --- a/Pythonwin/win32util.cpp Sat Nov 05 14:41:55 2011 +1100 +++ b/Pythonwin/win32util.cpp Sat Nov 05 16:21:59 2011 +1100 @@ -240,38 +240,48 @@ // Font conversion utilities // // -static char *szFontQuality = "quality"; -static char *szFontName = "name"; +static char *szFontHeight = "height"; +static char *szFontWidth = "width"; +static char *szFontEscapement = "escapement"; +static char *szFontOrientation = "orientation"; static char *szFontWeight = "weight"; -static char *szFontWidth = "width"; -static char *szFontHeight = "height"; static char *szFontItalic = "italic"; static char *szFontUnderline = "underline"; +static char *szFontStrikeOut = "strike out"; +static char *szFontCharSet = "charset"; +static char *szFontOutPrecision = "out precision"; +static char *szFontClipPrecision = "clip precision"; +static char *szFontQuality = "quality"; static char *szFontPitch = "pitch and family"; -static char *szFontCharSet = "charset"; +static char *szFontName = "name"; PyObject *LogFontToDict(const LOGFONT &lf) { - // ??? This is missing a lot of members ??? - return Py_BuildValue("{s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N}", - szFontQuality, PyInt_FromLong(lf.lfQuality), - szFontName, PyWinObject_FromTCHAR(lf.lfFaceName), + return Py_BuildValue("{s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N, s:N}", szFontHeight, PyInt_FromLong(lf.lfHeight), szFontWidth, PyInt_FromLong(lf.lfWidth), + szFontEscapement, PyInt_FromLong(lf.lfEscapement), + szFontOrientation, PyInt_FromLong(lf.lfOrientation), szFontWeight, PyInt_FromLong(lf.lfWeight), + szFontItalic, PyBool_FromLong(lf.lfItalic), + szFontUnderline, PyBool_FromLong(lf.lfUnderline), + szFontStrikeOut, PyBool_FromLong(lf.lfStrikeOut), + szFontCharSet, PyInt_FromLong(lf.lfCharSet), + szFontOutPrecision, PyInt_FromLong(lf.lfOutPrecision), + szFontClipPrecision, PyInt_FromLong(lf.lfClipPrecision), + szFontQuality, PyInt_FromLong(lf.lfQuality), szFontPitch, PyInt_FromLong(lf.lfPitchAndFamily), - szFontCharSet, PyInt_FromLong(lf.lfCharSet), - szFontUnderline, PyBool_FromLong(lf.lfUnderline), - szFontItalic, PyBool_FromLong(lf.lfItalic)); + szFontName, PyWinObject_FromTCHAR(lf.lfFaceName)); } BOOL DictToLogFont(PyObject *font_props, LOGFONT *pLF) { ZeroMemory (pLF, sizeof(LOGFONT)); static char *keywords[]={ - szFontQuality, szFontName, szFontHeight, szFontWidth, szFontWeight, - szFontPitch, szFontCharSet, szFontUnderline, szFontItalic, NULL - }; + szFontHeight, szFontWidth, szFontEscapement, szFontOrientation, + szFontWeight, szFontItalic, szFontUnderline, szFontStrikeOut, + szFontCharSet, szFontOutPrecision, szFontClipPrecision, + szFontQuality, szFontPitch, szFontName, NULL}; // font default values pLF->lfCharSet = DEFAULT_CHARSET; // dont use ANSI_CHARSET to support Japanese charset. @@ -288,9 +298,12 @@ if (!dummy_tuple) return FALSE; - if (!PyArg_ParseTupleAndKeywords(dummy_tuple, font_props, "|bOlllbbbb:LOGFONT", keywords, - &pLF->lfQuality, &obFontName, &pLF->lfHeight, &pLF->lfWidth, &pLF->lfWeight, - &pLF->lfPitchAndFamily, &pLF->lfCharSet, &pLF->lfUnderline, &pLF->lfItalic)){ + if (!PyArg_ParseTupleAndKeywords(dummy_tuple, font_props, + "|lllllbbbbbbbbO:LOGFONT", keywords, &pLF->lfHeight, &pLF->lfWidth, + &pLF->lfEscapement, &pLF->lfOrientation, &pLF->lfWeight, + &pLF->lfItalic, &pLF->lfUnderline, &pLF->lfStrikeOut, + &pLF->lfCharSet, &pLF->lfOutPrecision, &pLF->lfClipPrecision, + &pLF->lfQuality, &pLF->lfPitchAndFamily, &obFontName)){ Py_DECREF(dummy_tuple); return FALSE; } |