[pywin32-checkins] pywin32/win32/src win32gui.i,1.54,1.55
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-01-20 06:50:00
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8431 Modified Files: win32gui.i Log Message: Add GetTextExtentPoint32, GetMenuInfo, SetMenuInfo Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** win32gui.i 20 Jan 2005 03:02:32 -0000 1.54 --- win32gui.i 20 Jan 2005 06:49:50 -0000 1.55 *************** *** 2680,2683 **** --- 2680,2711 ---- BOOLAPI ClientToScreen(HWND hWnd,POINT *BOTH); + %{ + // @pyswig cx, cy|GetTextExtentPoint32|Computes the width and height of the specified string of text. + static PyObject *PyGetTextExtentPoint32(PyObject *self, PyObject *args) + { + // @pyparm int|dc||The device context + // @pyparm string|str||The string to measure. + int dc; + PyObject *obString; + if (!PyArg_ParseTuple(args, "iO:GetTextExtentPoint32", &dc, &obString)) + return NULL; + TCHAR *szString = NULL; + DWORD nchars; + if (!PyWinObject_AsTCHAR(obString, &szString, FALSE, &nchars)) + return FALSE; + SIZE size = {0,0}; + BOOL rc; + Py_BEGIN_ALLOW_THREADS + rc = GetTextExtentPoint32( (HDC)dc, szString, nchars, &size); + Py_END_ALLOW_THREADS + PyWinObject_FreeTCHAR(szString); + if (!rc) + return PyWin_SetAPIError("GetTextExtentPoint32"); + return Py_BuildValue("ll", size.cx, size.cy); + } + %} + + %native (GetTextExtentPoint32) PyGetTextExtentPoint32; + // @pyswig int|GetOpenFileName|Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open. // @rdesc If the user presses OK, the function returns TRUE. Otherwise, use CommDlgExtendedError for error details. *************** *** 2701,2704 **** --- 2729,2746 ---- } + %typemap (python, in) MENUINFO *INPUT (int target_size){ + if (0 != PyObject_AsReadBuffer($source, (const void **)&$target, &target_size)) + return NULL; + if (sizeof MENUINFO != target_size) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof MENUINFO, target_size); + } + + %typemap (python,in) MENUINFO *BOTH(int target_size) { + if (0 != PyObject_AsWriteBuffer($source, (void **)&$target, &target_size)) + return NULL; + if (sizeof MENUINFO != target_size) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof MENUINFO, target_size); + } + // @pyswig |InsertMenuItem|Inserts a menu item // @pyparm int|hMenu|| *************** *** 2783,2786 **** --- 2825,2841 ---- ); + // @pyswig |SetMenuInfo|Sets information for a specified menu. + BOOLAPI SetMenuInfo( + HMENU hmenu, // @pyparm int|hmenu||handle to menu + MENUINFO *INPUT // @pyparm <o MENUINFO>|info||menu information in the format of a buffer. + // See win32gui_struct for helper functions. + ); + + // @pyswig |GetMenuInfo|Sets information about a specified menu. + BOOLAPI GetMenuInfo( + HMENU hMenu, // @pyparm int|hmenu||handle to menu + MENUINFO *BOTH // @pyparm buffer|info||A buffer to fill with the information. + ); + BOOLAPI DrawFocusRect(HDC hDC, RECT *INPUT); |