]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/drawlist.cpp
some methods missing wxPyBeginBlockThreads/wxPyEndBlockThreads
[wxWidgets.git] / wxPython / src / drawlist.cpp
index cba7952b24b9096f299b2dd7a658739a9029e317..724359e98af0cafc4c0535551aae9fa448804218 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        drawlist.cpp
 // Purpose:     Helper functions for optimized list drawing on a wxDC
 //
 // Name:        drawlist.cpp
 // Purpose:     Helper functions for optimized list drawing on a wxDC
 //
-// Author:      Robin Dunn Chris Barker
+// Author:      Robin Dunn Chris Barker
 //
 // Created:
 // RCS-ID:      $Id$
 //
 // Created:
 // RCS-ID:      $Id$
 
 #undef DEBUG
 #include <Python.h>
 
 #undef DEBUG
 #include <Python.h>
-#include "helpers.h"
+#include "wx/wxPython/wxPython.h"
+#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) {
 
 
-    wxPyBeginBlockThreads(); // _DrawXXXList
+PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw,
+                          PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
+{
+    bool blocked = wxPyBeginBlockThreads(); 
 
     bool      isFastSeq  = PyList_Check(pyCoords) || PyTuple_Check(pyCoords);
     bool      isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
 
     bool      isFastSeq  = PyList_Check(pyCoords) || PyTuple_Check(pyCoords);
     bool      isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
@@ -35,7 +42,6 @@ PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw,
     wxBrush*  brush;
     PyObject* obj;
     PyObject* coords;
     wxBrush*  brush;
     PyObject* obj;
     PyObject* coords;
-    int       x1, x2, x3, x4;
     int       i = 0;
     PyObject* retval;
 
     int       i = 0;
     PyObject* retval;
 
@@ -60,7 +66,7 @@ PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw,
             else {
                 obj = PySequence_GetItem(pyPens, i);
             }
             else {
                 obj = PySequence_GetItem(pyPens, i);
             }
-            if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+            if (! wxPyConvertSwigPtr(obj, (void **) &pen, wxT("wxPen"))) {
                 if (!isFastPens)
                     Py_DECREF(obj);
                 goto err1;
                 if (!isFastPens)
                     Py_DECREF(obj);
                 goto err1;
@@ -78,7 +84,7 @@ PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw,
             else {
                 obj = PySequence_GetItem(pyBrushes, i);
             }
             else {
                 obj = PySequence_GetItem(pyBrushes, i);
             }
-            if (SWIG_GetPtrObj(obj, (void **) &brush, "_wxBrush_p")) {
+            if (!wxPyConvertSwigPtr(obj, (void **) &brush, wxT("wxBrush"))) {
                 if (!isFastBrushes)
                     Py_DECREF(obj);
                 goto err2;
                 if (!isFastBrushes)
                     Py_DECREF(obj);
                 goto err2;
@@ -132,77 +138,83 @@ PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw,
 
 
  exit:
 
 
  exit:
-    wxPyEndBlockThreads();
+    wxPyEndBlockThreads(blocked);
     return retval;
 }
 
 
 
     return retval;
 }
 
 
 
-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.");
     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);
     }
     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.");
     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);
     }
     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.");
     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);
     }
     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.");
     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);
     }
     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.");
     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);
     }
     dc.DrawPolygon(numPoints, points);
-    return TRUE;
+    return True;
 }
 
 
 }
 
 
-//----------------------------------------------------------------------
+//---------------------------------------------------------------------------
 
 
 
 
 
 
-PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyObject* foregroundList, PyObject* backgroundList) {
-    wxPyBeginBlockThreads();
+PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyObject* foregroundList, PyObject* backgroundList)
+{
+    bool blocked = wxPyBeginBlockThreads();
 
     bool      isFastSeq  = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
     bool      isFastText = PyList_Check(textList) || PyTuple_Check(textList);
 
     bool      isFastSeq  = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
     bool      isFastText = PyList_Check(textList) || PyTuple_Check(textList);
@@ -262,7 +274,7 @@ PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyO
             else {
                 obj = PySequence_GetItem(foregroundList, i);
             }
             else {
                 obj = PySequence_GetItem(foregroundList, i);
             }
-            if (SWIG_GetPtrObj(obj, (void **) &color, "_wxColour_p")) {
+            if (! wxPyConvertSwigPtr(obj, (void **) &color, wxT("wxColour"))) {
                 if (!isFastForeground)
                     Py_DECREF(obj);
                 goto err2;
                 if (!isFastForeground)
                     Py_DECREF(obj);
                 goto err2;
@@ -280,7 +292,7 @@ PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyO
             else {
                 obj = PySequence_GetItem(backgroundList, i);
             }
             else {
                 obj = PySequence_GetItem(backgroundList, i);
             }
-            if (SWIG_GetPtrObj(obj, (void **) &color, "_wxColour_p")) {
+            if (! wxPyConvertSwigPtr(obj, (void **) &color, wxT("wxColour"))) {
                 if (!isFastBackground)
                     Py_DECREF(obj);
                 goto err3;
                 if (!isFastBackground)
                     Py_DECREF(obj);
                 goto err3;
@@ -341,10 +353,10 @@ PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, PyO
     goto exit;
 
  exit:
     goto exit;
 
  exit:
-    wxPyEndBlockThreads();
+    wxPyEndBlockThreads(blocked);
     return retval;
 }
 
 
 
     return retval;
 }
 
 
 
-//----------------------------------------------------------------------
+//---------------------------------------------------------------------------