X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/756ed80cb873d13303abf7c5e5b3e95db57de12d..13a7abf97312d2e9427898f3432eb9214f09427f:/wxPython/src/gdi.i diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index fa57df3de3..b5cee56b36 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -110,7 +110,7 @@ public: %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1); %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings); %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon); -%new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ); +%new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ); // #ifdef __WXMSW__ // %new wxBitmap* wxBitmapFromData(PyObject* data, long type, @@ -162,8 +162,11 @@ public: } - wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) { - return new wxBitmap(bits, width, height, depth); + wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ) { + char* buf; + int length; + PyString_AsStringAndSize(bits, &buf, &length); + return new wxBitmap(buf, width, height, depth); } @@ -583,6 +586,7 @@ public: int fill_style=wxODDEVEN_RULE); void DrawPoint(long x, long y); void DrawRectangle(long x, long y, long width, long height); + %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect); void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20); void DrawSpline(int PCOUNT, wxPoint* points); @@ -634,6 +638,7 @@ public: void SetBackgroundMode(int mode); void SetClippingRegion(long x, long y, long width, long height); %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); + %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); void SetPalette(const wxPalette& colourMap); void SetBrush(const wxBrush& brush); void SetFont(const wxFont& font); @@ -684,6 +689,8 @@ public: // Draw a point for every set of coordinants in pyPoints, optionally // setting a new pen for each PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) { + wxPyBeginBlockThreads(); + bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints); bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); int numObjs = 0; @@ -692,6 +699,7 @@ public: PyObject* obj; int x1, y1; int i = 0; + PyObject* retval; if (!PySequence_Check(pyPoints)) { goto err0; @@ -734,6 +742,13 @@ public: Py_DECREF(obj); goto err0; } + if (PyErr_Occurred()) { + retval = NULL; + if (!isFastPens) + Py_DECREF(obj); + goto exit; + } + // Now draw the point self->DrawPoint(x1, y1); @@ -743,20 +758,29 @@ public: } Py_INCREF(Py_None); - return Py_None; + retval = Py_None; + goto exit; err1: PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); - return NULL; + retval = NULL; + goto exit; err0: PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences."); - return NULL; + retval = NULL; + goto exit; + + exit: + wxPyEndBlockThreads(); + return retval; } // Draw a line for every set of coordinants in pyLines, optionally // setting a new pen for each PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) { + wxPyBeginBlockThreads(); + bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines); bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); int numObjs = 0; @@ -765,6 +789,7 @@ public: PyObject* obj; int x1, y1, x2, y2; int i = 0; + PyObject* retval; if (!PySequence_Check(pyLines)) { goto err0; @@ -807,6 +832,12 @@ public: Py_DECREF(obj); goto err0; } + if (PyErr_Occurred()) { + retval = NULL; + if (!isFastPens) + Py_DECREF(obj); + goto exit; + } // Now draw the line self->DrawLine(x1, y1, x2, y2); @@ -816,14 +847,22 @@ public: } Py_INCREF(Py_None); - return Py_None; + retval = Py_None; + goto exit; err1: PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); - return NULL; + retval = NULL; + goto exit; + err0: PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences."); - return NULL; + retval = NULL; + goto exit; + + exit: + wxPyEndBlockThreads(); + return retval; } } @@ -1044,6 +1083,9 @@ enum wxRegionContain { class wxRegion : public wxGDIObject { public: wxRegion(long x=0, long y=0, long width=0, long height=0); +#ifndef __WXMAC__ + %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE); +#endif ~wxRegion(); void Clear();