[pywin32-checkins] pywin32/win32/src win32gui.i,1.104,1.105
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-04-01 13:24:09
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23323/win32/src Modified Files: win32gui.i Log Message: Add DrawTextW Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** win32gui.i 28 Mar 2007 12:29:33 -0000 1.104 --- win32gui.i 1 Apr 2007 13:24:04 -0000 1.105 *************** *** 74,77 **** --- 74,79 ---- typedef DWORD (WINAPI *SetLayoutfunc)(HDC, DWORD); static SetLayoutfunc pfnSetLayout=NULL; + typedef int (WINAPI *DrawTextWfunc)(HDC,LPWSTR,int,LPRECT,UINT); + static DrawTextWfunc pfnDrawTextW = NULL; static PyObject *g_AtomMap = NULL; // Mapping class atoms to Python WNDPROC *************** *** 234,244 **** for (PyMethodDef *pmd = win32guiMethods; pmd->ml_name; pmd++) #endif ! if (strcmp(pmd->ml_name, "SetLayeredWindowAttributes")==0 || ! strcmp(pmd->ml_name, "GetLayeredWindowAttributes")==0 || ! strcmp(pmd->ml_name, "UpdateLayeredWindow")==0 || ! strcmp(pmd->ml_name, "AnimateWindow")==0 || ! strcmp(pmd->ml_name, "GetOpenFileNameW")==0 || ! strcmp(pmd->ml_name, "GetSaveFileNameW")==0 || ! strcmp(pmd->ml_name, "SystemParametersInfo")==0) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; --- 236,248 ---- for (PyMethodDef *pmd = win32guiMethods; pmd->ml_name; pmd++) #endif ! if (strcmp(pmd->ml_name, "SetLayeredWindowAttributes")==0 ! ||strcmp(pmd->ml_name, "GetLayeredWindowAttributes")==0 ! ||strcmp(pmd->ml_name, "UpdateLayeredWindow")==0 ! ||strcmp(pmd->ml_name, "AnimateWindow")==0 ! ||strcmp(pmd->ml_name, "GetOpenFileNameW")==0 ! ||strcmp(pmd->ml_name, "GetSaveFileNameW")==0 ! ||strcmp(pmd->ml_name, "SystemParametersInfo")==0 ! ||strcmp(pmd->ml_name, "DrawTextW")==0 ! ) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; *************** *** 253,256 **** --- 257,261 ---- pfnGetMenuInfo=(GetMenuInfofunc)GetProcAddress(hmodule,"GetMenuInfo"); pfnSetMenuInfo=(SetMenuInfofunc)GetProcAddress(hmodule,"SetMenuInfo"); + pfnDrawTextW=(DrawTextWfunc)GetProcAddress(hmodule, "DrawTextW"); } *************** *** 268,272 **** pfnGetLayout=(GetLayoutfunc)GetProcAddress(hmodule,"GetLayout"); pfnSetLayout=(SetLayoutfunc)GetProcAddress(hmodule,"SetLayout"); - } --- 273,276 ---- *************** *** 389,393 **** } - // @object PyRECT|Tuple of 4 ints defining a rectangle: (left, top, right, bottom) %typemap(python,in) RECT *INPUT(RECT rect_input) { --- 393,396 ---- *************** *** 7183,7184 **** --- 7186,7228 ---- %native (CreateBrushIndirect) PyCreateBrushIndirect; %native (ExtCreatePen) PyExtCreatePen; + + // @pyswig int,<o PyRECT>|DrawTextW|Draws Unicode text on a device context. + // @comm Accepts keyword args. + // @rdesc Returns the height of the drawn text, and the rectangle coordinates + %{ + PyObject *PyDrawTextW(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(DrawTextW); + static char *keywords[]={"hDC","String","Count","Rect","Format", NULL}; + HDC hdc; + WCHAR *input_text; + int len, height; + RECT rc; + UINT fmt; + PyObject *obhdc, *obtxt, *obrc; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOiOI:DrawTextW", keywords, + &obhdc, // @pyparm <o PyHANDLE>|hDC||Handle to a device context + &obtxt, // @pyparm <o PyUnicode>|String||Text to be drawn + &len, // @pyparm int|Count||Number of characters to draw, use -1 for entire null terminated string + &obrc, // @pyparm <o PyRECT>|Rect||Rectangle in which to draw text + &fmt)) // @pyparm int|Format||Formatting flags, combination of win32con.DT_* values + return NULL; + if (!PyWinObject_AsHANDLE(obhdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsRECT(obrc, &rc)) + return NULL; + if (!PyWinObject_AsWCHAR(obtxt, &input_text, FALSE)) + return NULL; + + height=(*pfnDrawTextW)(hdc, input_text, len, &rc, fmt); + PyWinObject_FreeWCHAR(input_text); + if (!height) + return PyWin_SetAPIError("DrawTextW"); + return Py_BuildValue("iN", + height, + PyWinObject_FromRECT(&rc)); + } + PyCFunction pfnPyDrawTextW=(PyCFunction)PyDrawTextW; + %} + %native (DrawTextW) pfnPyDrawTextW; |