Thread: [pywin32-checkins] pywin32/win32/src win32gui.i,1.86,1.87
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2006-12-11 05:27:36
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24498/win32/src Modified Files: win32gui.i Log Message: Add some more drawing functions Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** win32gui.i 9 Dec 2006 08:31:28 -0000 1.86 --- win32gui.i 11 Dec 2006 05:27:34 -0000 1.87 *************** *** 2656,2659 **** --- 2656,2668 ---- HDC GetDC( HWND hWnd ); + // @pyswig int|SaveDC|Save the state of a device context + // @rdesc Returns a value identifying the state that can be passed to <om win32gui.RestoreDC>. On error, returns 0. + int SaveDC(HDC hdc); // @pyparm <o PyHANDLE>|hdc||Handle to device context + + // @pyswig |RestoreDC|Restores a device context state + BOOLAPI RestoreDC( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + int SavedDC); // @pyparm int|SavedDC||Identifier of state to be restored, as returned by <om win32gui.SaveDC>. + // @pyswig |DeleteDC|Deletes a DC BOOLAPI DeleteDC( *************** *** 3578,3586 **** // @rdesc Returns the previous position as (X, Y) BOOLAPI MoveToEx( ! HDC hdc, // @pyparm <o PyHANDLE>|hcl||Device context handle int X, // @pyparm int|X||Horizontal pos in logical units int Y, // @pyparm int|Y||Vertical pos in logical units POINT *OUTPUT); %{ --- 3587,3784 ---- // @rdesc Returns the previous position as (X, Y) BOOLAPI MoveToEx( ! HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context handle int X, // @pyparm int|X||Horizontal pos in logical units int Y, // @pyparm int|Y||Vertical pos in logical units POINT *OUTPUT); + // @pyswig (int,int)|GetCurrentPositionEx|Returns a device context's current drawing position + BOOLAPI GetCurrentPositionEx( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context + POINT *OUTPUT); + + // @pyswig int|GetArcDirection|Returns the direction in which rectangles and arcs are drawn + // @rdesc Recturns one of win32con.AD_* values + int GetArcDirection( + HDC hdc); // @pyparm <o PyHANDLE>|hdc||Handle to a device context + + // @pyswig int|SetArcDirection|Sets the drawing direction for arcs and rectangles + // @rdesc Returns the previous direction, or 0 on error. + int SetArcDirection( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + int ArcDirection); // @pyparm int|ArcDirection||One of win32con.AD_* constants + + %{ + BOOL PyWinObject_AsPOINTArray(PyObject *obpoints, POINT **ppoints, DWORD *item_cnt) + { + BOOL ret=TRUE; + DWORD bufsize, tuple_index; + PyObject *points_tuple=NULL, *tuple_item; + *ppoints=NULL; + *item_cnt=0; + + if ((points_tuple=PySequence_Tuple(obpoints))==NULL) + return FALSE; + *item_cnt=PyTuple_GET_SIZE(points_tuple); + bufsize=*item_cnt * sizeof(POINT); + *ppoints=(POINT *)malloc(bufsize); + if (*ppoints==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + ret=FALSE; + } + else + for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ + tuple_item=PyTuple_GET_ITEM(points_tuple,tuple_index); + if (!PyWinObject_AsPOINT(tuple_item, &(*ppoints)[tuple_index])){ + ret=FALSE; + break; + } + } + if (!ret) + if (*ppoints!=NULL){ + free(*ppoints); + *ppoints=NULL; + *item_cnt=0; + } + Py_XDECREF(points_tuple); + return ret; + } + + // @pyswig |Polygon|Draws a closed filled polygon defined by a sequence of points + static PyObject *PyPolygon(PyObject *self, PyObject *args) + { + HDC hdc; + POINT *points=NULL; + DWORD point_cnt; + PyObject *obpoints, *obdc, *ret=NULL; + if (!PyArg_ParseTuple(args, "OO:PolyGon", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + &obpoints)) // @pyparm [(int,int),...]|Points||Sequence of POINT tuples: ((x,y),...) + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsPOINTArray(obpoints, &points, &point_cnt)) + return NULL; + if (!Polygon(hdc, points, point_cnt)) + PyWin_SetAPIError("PolyGon"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + if (points) + free(points); + return ret; + } + + // @pyswig |Polyline|Connects a sequence of points using currently selected pen + static PyObject *PyPolyline(PyObject *self, PyObject *args) + { + HDC hdc; + POINT *points=NULL; + DWORD point_cnt; + PyObject *obpoints, *obdc, *ret=NULL; + if (!PyArg_ParseTuple(args, "OO:Polyline", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + &obpoints)) // @pyparm [(int,int),...]|Points||Sequence of POINT tuples: ((x,y),...) + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsPOINTArray(obpoints, &points, &point_cnt)) + return NULL; + if (!Polyline(hdc, points, point_cnt)) + PyWin_SetAPIError("Polyline"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + if (points) + free(points); + return ret; + } + + // @pyswig |PolylineTo|Draws a series of lines starting from current position. Updates current position with end point. + static PyObject *PyPolylineTo(PyObject *self, PyObject *args) + { + HDC hdc; + POINT *points=NULL; + DWORD point_cnt; + PyObject *obpoints, *obdc, *ret=NULL; + if (!PyArg_ParseTuple(args, "OO:PolylineTo", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + &obpoints)) // @pyparm [(int,int),...]|Points||Sequence of POINT tuples: ((x,y),...) + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsPOINTArray(obpoints, &points, &point_cnt)) + return NULL; + if (!PolylineTo(hdc, points, point_cnt)) + PyWin_SetAPIError("PolylineTo"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + if (points) + free(points); + return ret; + } + + // @pyswig |PolyBezier|Draws a series of Bezier curves starting from first point specified. + // @comm Number of points must be a multiple of 3 plus 1. + static PyObject *PyPolyBezier(PyObject *self, PyObject *args) + { + HDC hdc; + POINT *points=NULL; + DWORD point_cnt; + PyObject *obpoints, *obdc, *ret=NULL; + if (!PyArg_ParseTuple(args, "OO:PolyBezier", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + &obpoints)) // @pyparm [(int,int),...]|Points||Sequence of POINT tuples: ((x,y),...). + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsPOINTArray(obpoints, &points, &point_cnt)) + return NULL; + if (!PolyBezier(hdc, points, point_cnt)) + PyWin_SetAPIError("PolyBezier"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + if (points) + free(points); + return ret; + } + + // @pyswig |PolyBezierTo|Draws a series of Bezier curves starting from current drawing position. + // @comm Points must contain 3 points for each curve. Current position is updated with last endpoint. + static PyObject *PyPolyBezierTo(PyObject *self, PyObject *args) + { + HDC hdc; + POINT *points=NULL; + DWORD point_cnt; + PyObject *obpoints, *obdc, *ret=NULL; + if (!PyArg_ParseTuple(args, "OO:PolyBezierTo", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + &obpoints)) // @pyparm [(int,int),...]|Points||Sequence of POINT tuples: ((x,y),...). + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsPOINTArray(obpoints, &points, &point_cnt)) + return NULL; + if (!PolyBezierTo(hdc, points, point_cnt)) + PyWin_SetAPIError("PolyBezierTo"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + if (points) + free(points); + return ret; + } + %} + %native (Polygon) PyPolygon; + %native (Polyline) PyPolyline; + %native (PolylineTo) PyPolylineTo; + %native (PolyBezier) PyPolyBezier; + %native (PolyBezierTo) PyPolyBezierTo; %{ *************** *** 3734,3737 **** --- 3932,3940 ---- #endif /* not MS_WINCE */ + // @pyswig |InvertRect|Inverts the colors in a regtangular region + BOOLAPI InvertRect( + HDC hDC, // @pyparm <o PyHANDLE>|hDC||Handle to a device context + RECT *INPUT); // @pyparm <o RECT>|rc||Coordinates of rectangle to invert + // @pyswig |GetUpdateRgn| int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase); *************** *** 3742,3748 **** int nLeftRect, // @pyparm int|LeftRect||Position of left edge of rectangle int nTopRect, // @pyparm int|TopRect||Position of top edge of rectangle ! int nRightRect, // @pyparm int|RightRect||Posistion of right edge of rectangle int nBottomRect); // @pyparm int|BottomRect||Position of bottom edge of rectangle // @pyswig hdc, paintstruct|BeginPaint| HDC BeginPaint(HWND hwnd, PAINTSTRUCT *OUTPUT); --- 3945,3961 ---- int nLeftRect, // @pyparm int|LeftRect||Position of left edge of rectangle int nTopRect, // @pyparm int|TopRect||Position of top edge of rectangle ! int nRightRect, // @pyparm int|RightRect||Position of right edge of rectangle int nBottomRect); // @pyparm int|BottomRect||Position of bottom edge of rectangle + // @pyswig |RoundRect|Draws a rectangle with elliptically rounded corners, filled using using current brush + BOOLAPI RoundRect( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to device context + int nLeftRect, // @pyparm int|LeftRect||Position of left edge of rectangle + int nTopRect, // @pyparm int|TopRect||Position of top edge of rectangle + int nRightRect, // @pyparm int|RightRect||Position of right edge of rectangle + int nBottomRect, // @pyparm int|BottomRect||Position of bottom edge of rectangle + int Width, // @pyparm int|Width||Width of ellipse + int Height); // @pyparm int|Height||Height of ellipse + // @pyswig hdc, paintstruct|BeginPaint| HDC BeginPaint(HWND hwnd, PAINTSTRUCT *OUTPUT); |