X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..52f52ebc4e0be6a9899d328b08db9eb14629d219:/wxPython/src/drawlist.cpp diff --git a/wxPython/src/drawlist.cpp b/wxPython/src/drawlist.cpp index f05bf8b3dd..b0516571e9 100644 --- a/wxPython/src/drawlist.cpp +++ b/wxPython/src/drawlist.cpp @@ -17,18 +17,21 @@ #include "wx/wxPython/pydrawxxx.h" -//---------------------------------------------------------------------- +//--------------------------------------------------------------------------- +// Called from _gdiinit so we can do the API import while the GIL is held +void wxPyDrawList_SetAPIPtr() +{ + wxPyCoreAPI_IMPORT(); +} -PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw, - PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) { +PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw, + PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) +{ wxPyBeginBlockThreads(); - if ( !wxPyCoreAPIPtr) - wxPyCoreAPI_IMPORT(); - bool isFastSeq = PyList_Check(pyCoords) || PyTuple_Check(pyCoords); bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); bool isFastBrushes = PyList_Check(pyBrushes) || PyTuple_Check(pyBrushes); @@ -141,75 +144,78 @@ PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw, -bool wxPyDrawXXXPoint(wxDC& dc, PyObject* coords) { +bool wxPyDrawXXXPoint(wxDC& dc, PyObject* coords) +{ int x, y; if (! wxPy2int_seq_helper(coords, &x, &y)) { PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences."); - return FALSE; + return False; } dc.DrawPoint(x, y); - return TRUE; + return True; } -bool wxPyDrawXXXLine(wxDC& dc, PyObject* coords) { +bool wxPyDrawXXXLine(wxDC& dc, PyObject* coords) +{ int x1, y1, x2, y2; if (! wxPy4int_seq_helper(coords, &x1, &y1, &x2, &y2)) { PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x1,y2) sequences."); - return FALSE; + return False; } dc.DrawLine(x1,y1, x2,y2); - return TRUE; + return True; } -bool wxPyDrawXXXRectangle(wxDC& dc, PyObject* coords) { +bool wxPyDrawXXXRectangle(wxDC& dc, PyObject* coords) +{ int x, y, w, h; if (! wxPy4int_seq_helper(coords, &x, &y, &w, &h)) { PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y, w,h) sequences."); - return FALSE; + return False; } dc.DrawRectangle(x, y, w, h); - return TRUE; + return True; } -bool wxPyDrawXXXEllipse(wxDC& dc, PyObject* coords) { +bool wxPyDrawXXXEllipse(wxDC& dc, PyObject* coords) +{ int x, y, w, h; if (! wxPy4int_seq_helper(coords, &x, &y, &w, &h)) { PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y, w,h) sequences."); - return FALSE; + return False; } dc.DrawEllipse(x, y, w, h); - return TRUE; + return True; } -bool wxPyDrawXXXPolygon(wxDC& dc, PyObject* coords) { +bool wxPyDrawXXXPolygon(wxDC& dc, PyObject* coords) +{ wxPoint* points; int numPoints; points = wxPoint_LIST_helper(coords, &numPoints); if (! points) { PyErr_SetString(PyExc_TypeError, "Expected a sequence of sequences of (x,y) sequences."); - return FALSE; + return False; } dc.DrawPolygon(numPoints, points); - return TRUE; + return True; } -//---------------------------------------------------------------------- +//--------------------------------------------------------------------------- -PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyObject* foregroundList, PyObject* backgroundList) { +PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyObject* foregroundList, PyObject* backgroundList) +{ wxPyBeginBlockThreads(); - if ( !wxPyCoreAPIPtr) - wxPyCoreAPI_IMPORT(); - bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints); bool isFastText = PyList_Check(textList) || PyTuple_Check(textList); bool isFastForeground = PyList_Check(foregroundList) || PyTuple_Check(foregroundList); @@ -268,7 +274,7 @@ PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyO else { obj = PySequence_GetItem(foregroundList, i); } - if (! wxPyConvertSwigPtr(obj, (void **) &color, wxT("wxColour_p"))) { + if (! wxPyConvertSwigPtr(obj, (void **) &color, wxT("wxColour"))) { if (!isFastForeground) Py_DECREF(obj); goto err2; @@ -353,4 +359,4 @@ PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyO -//---------------------------------------------------------------------- +//---------------------------------------------------------------------------