]> git.saurik.com Git - wxWidgets.git/commitdiff
Added some optimization methods to wxPython's wxDC
authorRobin Dunn <robin@alldunn.com>
Tue, 16 Oct 2001 19:06:09 +0000 (19:06 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 16 Oct 2001 19:06:09 +0000 (19:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/CHANGES.txt
wxPython/demo/DrawXXXList.py [new file with mode: 0644]
wxPython/demo/Main.py
wxPython/src/controls2.i
wxPython/src/gdi.i
wxPython/src/helpers.cpp
wxPython/src/helpers.h
wxPython/src/msw/gdi.cpp
wxPython/src/msw/gdi.py
wxPython/src/msw/html.cpp
wxPython/src/msw/printfw.py

index 1bb7e375a4b8de8f307b95b20dbab8bb6ae8fa35..1d0da2e49d1428c6be066f309d130bb1ef28145c 100644 (file)
@@ -54,6 +54,9 @@ Added wxFindReplaceDialog.
 The second phase of OOR is implemented (for wxEvtHandler and derived
 classes at least.)
 
+Added some optimization methods to wxDC: GetBoundingBox, DrawLineList,
+DrawPointList.
+
 
 
 
diff --git a/wxPython/demo/DrawXXXList.py b/wxPython/demo/DrawXXXList.py
new file mode 100644 (file)
index 0000000..46afed8
--- /dev/null
@@ -0,0 +1,135 @@
+
+from wxPython.wx import *
+import whrandom, time
+
+#----------------------------------------------------------------------
+
+colours = [
+    "BLACK",
+    "BLUE",
+    "BLUE VIOLET",
+    "BROWN",
+    "CYAN",
+    "DARK GREY",
+    "DARK GREEN",
+    "GOLD",
+    "GREY",
+    "GREEN",
+    "MAGENTA",
+    "NAVY",
+    "PINK",
+    "RED",
+    "SKY BLUE",
+    "VIOLET",
+    "YELLOW",
+    ]
+
+#----------------------------------------------------------------------
+
+def makeRandomPoints(num, w, h):
+    pnts = []
+    for i in range(num):
+        x = whrandom.randint(0, w)
+        y = whrandom.randint(0, h)
+        pnts.append( (x,y) )
+    return pnts
+
+
+def makeRandomLines(num, w, h):
+    pnts = []
+    for i in range(num):
+        x1 = whrandom.randint(0, w)
+        y1 = whrandom.randint(0, h)
+        x2 = whrandom.randint(0, w)
+        y2 = whrandom.randint(0, h)
+        pnts.append( (x1,y1, x2,y2) )
+    return pnts
+
+
+def makeRandomPens(num, cache):
+    pens = []
+    for i in range(num):
+        c = whrandom.choice(colours)
+        t = whrandom.randint(1, 4)
+        if not cache.has_key( (c, t) ):
+            cache[(c, t)] = wxPen(c, t)
+        pens.append( cache[(c, t)] )
+    return pens
+
+
+class TestPanel(wxPanel):
+    def __init__(self, parent, size, log):
+        wxPanel.__init__(self, parent, -1, size=size)
+        self.log = log
+        self.SetBackgroundColour(wxWHITE)
+
+        w = size.width
+        h = size.height
+        pencache = {}
+
+        # make some lists of random points
+        self.pnts1 = makeRandomPoints(1000, w, h)
+        self.pnts2 = makeRandomPoints(1000, w, h)
+        self.pnts3 = makeRandomPoints(1000, w, h)
+        self.pens1  = makeRandomPens(1000, pencache)
+
+        # and now some lines
+        self.lines1 = makeRandomLines(500, w, h)
+        self.lines2 = makeRandomLines(500, w, h)
+        self.lines3 = makeRandomLines(500, w, h)
+        self.pens2  = makeRandomPens(500, pencache)
+
+        EVT_PAINT(self, self.OnPaint)
+
+
+    def OnPaint(self, evt):
+        dc = wxPaintDC(self)
+        dc.BeginDrawing()
+        start = time.time()
+
+        dc.SetPen(wxPen("BLACK", 1))
+        dc.DrawPointList(self.pnts1)
+        dc.DrawPointList(self.pnts2, wxPen("RED", 2))
+        dc.DrawPointList(self.pnts3, self.pens1)
+
+        dc.SetPen(wxPen("BLACK", 1))
+        dc.DrawLineList(self.lines1)
+        dc.DrawLineList(self.lines2, wxPen("RED", 2))
+        dc.DrawLineList(self.lines3, self.pens2)
+
+        dc.EndDrawing()
+        self.log.write("DrawTime: %s seconds\n" % (time.time() - start))
+        self.log.write("GetBoundingBox: %s\n" % (dc.GetBoundingBox(), ))
+
+#----------------------------------------------------------------------
+
+def runTest(frame, nb, log):
+    w = nb.GetClientSize().width
+    h = nb.GetClientSize().height
+    if w < 300: w = 300
+    if h < 300: h = 300
+    win = TestPanel(nb, wxSize(w, h), log)
+    return win
+
+#----------------------------------------------------------------------
+
+
+overview = """\
+
+Some methods have been added to wxDC to help with optimization of
+drawing routines.  Currently they are:
+
+<pre>
+    DrawPointList(sequence, pens=None)
+</pre>
+    Where sequence is a tuple, list, whatever of 2 element tuples
+    (x, y) and pens is either None, a single pen or a list of pens.
+
+<pre>
+    DrawLineList(sequence, pens=None)
+</pre>
+     Where sequence is a tuple, list, whatever of 4 element tuples
+     (x1,y1, x2,y2) andd pens is either None, a single pen or a list
+     of pens.
+
+"""
index 72c65951c32496c8ec61449ca914456e45dae10e..088d034b97de9b81c5ab8cdd750ccbdd650e6e29 100644 (file)
@@ -30,6 +30,7 @@ _treeList = [
                                 'TablePrint',
                                 'OOR',
                                 'wxFindReplaceDialog',
+                                'DrawXXXList',
                                 ##'wxPopupWindow',
                                 ]),
 
@@ -63,7 +64,7 @@ _treeList = [
                         'PythonEvents', 'Threads',
                         'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE',
                         'wxDragImage', "wxProcess", "FancyText", "OOR", "wxWave",
-                        'wxJoystick',
+                        'wxJoystick', 'DrawXXXList',
                         ]),
 
     ('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog',
index 871049d0cf85c951d31a3f103a4cc1d8fa03a029..d0b3ae8bea83806a06034673a9514f2b6ee700fd 100644 (file)
@@ -517,7 +517,7 @@ public:
     int GetItemCount() const;
 
     // Gets the number of columns in the list control
-    int GetColumnCount() const { return m_colCount; }
+    int GetColumnCount() const;
 
     // Retrieves the spacing between icons in pixels.
     // If small is TRUE, gets the spacing for the small icon
index f80dd7e1caca279ebc25c9340925c3c464eaaef4..41e9a47f33590db756fecba8123156d8b9a6ef39 100644 (file)
@@ -818,12 +818,192 @@ public:
     void CalcBoundingBox(int x, int y);
     void ResetBoundingBox();
 
+    %addmethods {
+        void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
+        // See below for implementation
+    }
+
 #ifdef __WXMSW__
     long GetHDC();
 #endif
+
+
+    %addmethods {
+        // Draw a point for every set of coordinants in pyPoints, optionally
+        // setting a new pen for each
+        PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
+            bool      isFastSeq  = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
+            bool      isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
+            int       numObjs = 0;
+            int       numPens = 0;
+            wxPen*    pen;
+            PyObject* obj;
+            int       x1, y1;
+            int       i = 0;
+
+            if (!PySequence_Check(pyPoints)) {
+                goto err0;
+            }
+            if (!PySequence_Check(pyPens)) {
+                goto err1;
+            }
+            numObjs = PySequence_Length(pyPoints);
+            numPens = PySequence_Length(pyPens);
+
+            for (i = 0; i < numObjs; i++) {
+                // Use a new pen?
+                if (i < numPens) {
+                    if (isFastPens) {
+                        obj = PySequence_Fast_GET_ITEM(pyPens, i);
+                    }
+                    else {
+                        obj = PySequence_GetItem(pyPens, i);
+                    }
+                    if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+                        goto err1;
+                    }
+
+                    self->SetPen(*pen);
+                    if (!isFastPens)
+                        Py_DECREF(obj);
+                }
+
+                // Get the point coordinants
+                if (isFastSeq) {
+                    obj = PySequence_Fast_GET_ITEM(pyPoints, i);
+                }
+                else {
+                    obj = PySequence_GetItem(pyPoints, i);
+                }
+                if (! _2int_seq_helper(obj, &x1, &y1)) {
+                    Py_DECREF(obj);
+                    goto err0;
+                }
+
+                // Now draw the point
+                self->DrawPoint(x1, y1);
+
+                if (!isFastSeq)
+                    Py_DECREF(obj);
+            }
+
+            Py_INCREF(Py_None);
+            return Py_None;
+
+        err1:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
+            return NULL;
+        err0:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
+            return NULL;
+        }
+
+
+        // Draw a line for every set of coordinants in pyLines, optionally
+        // setting a new pen for each
+        PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
+            bool      isFastSeq  = PyList_Check(pyLines) || PyTuple_Check(pyLines);
+            bool      isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
+            int       numObjs = 0;
+            int       numPens = 0;
+            wxPen*    pen;
+            PyObject* obj;
+            int       x1, y1, x2, y2;
+            int       i = 0;
+
+            if (!PySequence_Check(pyLines)) {
+                goto err0;
+            }
+            if (!PySequence_Check(pyPens)) {
+                goto err1;
+            }
+            numObjs = PySequence_Length(pyLines);
+            numPens = PySequence_Length(pyPens);
+
+            for (i = 0; i < numObjs; i++) {
+                // Use a new pen?
+                if (i < numPens) {
+                    if (isFastPens) {
+                        obj = PySequence_Fast_GET_ITEM(pyPens, i);
+                    }
+                    else {
+                        obj = PySequence_GetItem(pyPens, i);
+                    }
+                    if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+                        goto err1;
+                    }
+
+                    self->SetPen(*pen);
+                    if (!isFastPens)
+                        Py_DECREF(obj);
+                }
+
+                // Get the line coordinants
+                if (isFastSeq) {
+                    obj = PySequence_Fast_GET_ITEM(pyLines, i);
+                }
+                else {
+                    obj = PySequence_GetItem(pyLines, i);
+                }
+                if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
+                    Py_DECREF(obj);
+                    goto err0;
+                }
+
+                // Now draw the line
+                self->DrawLine(x1, y1, x2, y2);
+
+                if (!isFastSeq)
+                    Py_DECREF(obj);
+            }
+
+            Py_INCREF(Py_None);
+            return Py_None;
+
+        err1:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
+            return NULL;
+        err0:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
+            return NULL;
+        }
+    }
+
+
+    %pragma(python) addtoclass = "
+    def DrawPointList(self, points, pens=None):
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(points):
+           raise ValueError('points and pens must have same length')
+        return self._DrawPointList(points, pens)
+
+    def DrawLineList(self, lines, pens=None):
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(lines):
+           raise ValueError('lines and pens must have same length')
+        return self._DrawLineList(lines, pens)
+"
+
+
 };
 
 
+
+%{
+static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
+    *x1 = dc->MinX();
+    *y1 = dc->MinY();
+    *x2 = dc->MaxX();
+    *y2 = dc->MaxY();
+}
+%}
+
 //----------------------------------------------------------------------
 
 class wxMemoryDC : public wxDC {
index 2783d56dc824db00ea046789547a28c0b158b694..e4c6354b20035cb3741b7c88652ca90145e4e8c6 100644 (file)
@@ -893,23 +893,19 @@ static inline bool wxPointFromObjects(PyObject* o1, PyObject* o2, wxPoint* point
 }
 
 
-#if PYTHON_API_VERSION < 1009
-#define PySequence_Fast_GET_ITEM(o, i)\
-     (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
-#endif
-
 wxPoint* wxPoint_LIST_helper(PyObject* source, int *count) {
     // Putting all of the declarations here allows
     // us to put the error handling all in one place.
     int x;
     wxPoint* temp;
     PyObject *o, *o1, *o2;
-    int isFast = PyList_Check(source) || PyTuple_Check(source);
+    bool isFast = PyList_Check(source) || PyTuple_Check(source);
 
-    // The length of the sequence is returned in count.
     if (!PySequence_Check(source)) {
         goto error0;
     }
+
+    // The length of the sequence is returned in count.
     *count = PySequence_Length(source);
     if (*count < 0) {
         goto error0;
@@ -1085,6 +1081,99 @@ wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source) {
 }
 
 
+wxPen** wxPen_LIST_helper(PyObject* source) {
+    if (!PyList_Check(source)) {
+        PyErr_SetString(PyExc_TypeError, "Expected a list object.");
+        return NULL;
+    }
+    int count = PyList_Size(source);
+    wxPen** temp = new wxPen*[count];
+    if (!temp) {
+        PyErr_SetString(PyExc_MemoryError, "Unable to allocate temporary array");
+        return NULL;
+    }
+    for (int x=0; x<count; x++) {
+        PyObject* o = PyList_GetItem(source, x);
+        if (PyInstance_Check(o)) {
+            wxPen*  pt;
+            if (SWIG_GetPtrObj(o, (void **) &pt,"_wxPen_p")) {
+                delete temp;
+                PyErr_SetString(PyExc_TypeError,"Expected _wxPen_p.");
+                return NULL;
+            }
+            temp[x] = pt;
+        }
+        else {
+            delete temp;
+            PyErr_SetString(PyExc_TypeError, "Expected a list of wxPens.");
+            return NULL;
+        }
+    }
+    return temp;
+}
+
+
+bool _2int_seq_helper(PyObject* source, int* i1, int* i2) {
+    bool isFast = PyList_Check(source) || PyTuple_Check(source);
+    PyObject *o1, *o2;
+
+    if (!PySequence_Check(source) || PySequence_Length(source) != 2)
+        return FALSE;
+
+    if (isFast) {
+        o1 = PySequence_Fast_GET_ITEM(source, 0);
+        o2 = PySequence_Fast_GET_ITEM(source, 1);
+    }
+    else {
+        o1 = PySequence_GetItem(source, 0);
+        o2 = PySequence_GetItem(source, 1);
+    }
+
+    *i1 = PyInt_AsLong(o1);
+    *i2 = PyInt_AsLong(o2);
+
+    if (! isFast) {
+        Py_DECREF(o1);
+        Py_DECREF(o2);
+    }
+    return TRUE;
+}
+
+
+bool _4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4) {
+    bool isFast = PyList_Check(source) || PyTuple_Check(source);
+    PyObject *o1, *o2, *o3, *o4;
+
+    if (!PySequence_Check(source) || PySequence_Length(source) != 4)
+        return FALSE;
+
+    if (isFast) {
+        o1 = PySequence_Fast_GET_ITEM(source, 0);
+        o2 = PySequence_Fast_GET_ITEM(source, 1);
+        o3 = PySequence_Fast_GET_ITEM(source, 2);
+        o4 = PySequence_Fast_GET_ITEM(source, 3);
+    }
+    else {
+        o1 = PySequence_GetItem(source, 0);
+        o2 = PySequence_GetItem(source, 1);
+        o3 = PySequence_GetItem(source, 2);
+        o4 = PySequence_GetItem(source, 3);
+    }
+
+    *i1 = PyInt_AsLong(o1);
+    *i2 = PyInt_AsLong(o2);
+    *i3 = PyInt_AsLong(o3);
+    *i4 = PyInt_AsLong(o4);
+
+    if (! isFast) {
+        Py_DECREF(o1);
+        Py_DECREF(o2);
+        Py_DECREF(o3);
+        Py_DECREF(o4);
+    }
+    return TRUE;
+}
+
 
 //----------------------------------------------------------------------
 
index b9c07e3a84b4d4b688560b4aaf82923b772187ae..750107f6bd921c50015590b52d9ba862a007819f 100644 (file)
@@ -134,6 +134,7 @@ wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
 wxBitmap** wxBitmap_LIST_helper(PyObject* source);
 wxString* wxString_LIST_helper(PyObject* source);
 wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
+wxPen** wxPen_LIST_helper(PyObject* source);
 
 bool wxSize_helper(PyObject* source, wxSize** obj);
 bool wxPoint_helper(PyObject* source, wxPoint** obj);
@@ -141,6 +142,15 @@ bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
 bool wxRect_helper(PyObject* source, wxRect** obj);
 bool wxColour_helper(PyObject* source, wxColour** obj);
 
+#if PYTHON_API_VERSION < 1009
+#define PySequence_Fast_GET_ITEM(o, i) \
+     (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
+#endif
+
+bool _2int_seq_helper(PyObject* source, int* i1, int* i2);
+bool _4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
+
+
 //----------------------------------------------------------------------
 
 #ifndef SWIGCODE
@@ -1505,6 +1515,7 @@ public:
         wxPyEndBlockThreads(state); \
         if (! found) \
             return PCLASS::CBNAME(e); \
+        return rval; \
     } \
     bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
         return PCLASS::CBNAME(e); \
index 69219688f17a35e5aa2927a6048666c5bbffe592..4bbf57cda2ddde6445df5c17dba5d8af908221b7 100644 (file)
@@ -207,6 +207,13 @@ public:
 private:
     wxDash* m_dash;
 };
+
+static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
+    *x1 = dc->MinX();
+    *y1 = dc->MinY();
+    *x2 = dc->MaxX();
+    *y2 = dc->MaxY();
+}
                                       // Alternate 'constructor'
     wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
         return new wxMemoryDC(oldDC);
@@ -9350,6 +9357,73 @@ static PyObject *_wrap_wxDC_ResetBoundingBox(PyObject *self, PyObject *args, PyO
     return _resultobj;
 }
 
+static PyObject *_wrap_wxDC_GetBoundingBox(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    wxDC * _arg0;
+    int * _arg1;
+    int  temp;
+    int * _arg2;
+    int  temp0;
+    int * _arg3;
+    int  temp1;
+    int * _arg4;
+    int  temp2;
+    PyObject * _argo0 = 0;
+    char *_kwnames[] = { "self", NULL };
+
+    self = self;
+{
+  _arg1 = &temp;
+}
+{
+  _arg2 = &temp0;
+}
+{
+  _arg3 = &temp1;
+}
+{
+  _arg4 = &temp2;
+}
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxDC_GetBoundingBox",_kwnames,&_argo0)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxDC_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxDC_GetBoundingBox. Expected _wxDC_p.");
+        return NULL;
+        }
+    }
+{
+    wxPy_BEGIN_ALLOW_THREADS;
+        wxDC_GetBoundingBox(_arg0,_arg1,_arg2,_arg3,_arg4);
+
+    wxPy_END_ALLOW_THREADS;
+    if (PyErr_Occurred()) return NULL;
+}    Py_INCREF(Py_None);
+    _resultobj = Py_None;
+{
+    PyObject *o;
+    o = PyInt_FromLong((long) (*_arg1));
+    _resultobj = t_output_helper(_resultobj, o);
+}
+{
+    PyObject *o;
+    o = PyInt_FromLong((long) (*_arg2));
+    _resultobj = t_output_helper(_resultobj, o);
+}
+{
+    PyObject *o;
+    o = PyInt_FromLong((long) (*_arg3));
+    _resultobj = t_output_helper(_resultobj, o);
+}
+{
+    PyObject *o;
+    o = PyInt_FromLong((long) (*_arg4));
+    _resultobj = t_output_helper(_resultobj, o);
+}
+    return _resultobj;
+}
+
 #define wxDC_GetHDC(_swigobj)  (_swigobj->GetHDC())
 static PyObject *_wrap_wxDC_GetHDC(PyObject *self, PyObject *args, PyObject *kwargs) {
     PyObject * _resultobj;
@@ -9378,6 +9452,216 @@ static PyObject *_wrap_wxDC_GetHDC(PyObject *self, PyObject *args, PyObject *kwa
     return _resultobj;
 }
 
+static PyObject * wxDC__DrawPointList(wxDC *self,PyObject * pyPoints,PyObject * pyPens) {
+            bool      isFastSeq  = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
+            bool      isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
+            int       numObjs = 0;
+            int       numPens = 0;
+            wxPen*    pen;
+            PyObject* obj;
+            int       x1, y1;
+            int       i = 0;
+
+            if (!PySequence_Check(pyPoints)) {
+                goto err0;
+            }
+            if (!PySequence_Check(pyPens)) {
+                goto err1;
+            }
+            numObjs = PySequence_Length(pyPoints);
+            numPens = PySequence_Length(pyPens);
+
+            for (i = 0; i < numObjs; i++) {
+                // Use a new pen?
+                if (i < numPens) {
+                    if (isFastPens) {
+                        obj = PySequence_Fast_GET_ITEM(pyPens, i);
+                    }
+                    else {
+                        obj = PySequence_GetItem(pyPens, i);
+                    }
+                    if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+                        goto err1;
+                    }
+
+                    self->SetPen(*pen);
+                    if (!isFastPens)
+                        Py_DECREF(obj);
+                }
+
+                // Get the point coordinants
+                if (isFastSeq) {
+                    obj = PySequence_Fast_GET_ITEM(pyPoints, i);
+                }
+                else {
+                    obj = PySequence_GetItem(pyPoints, i);
+                }
+                if (! _2int_seq_helper(obj, &x1, &y1)) {
+                    Py_DECREF(obj);
+                    goto err0;
+                }
+
+                // Now draw the point
+                self->DrawPoint(x1, y1);
+
+                if (!isFastSeq)
+                    Py_DECREF(obj);
+            }
+
+            Py_INCREF(Py_None);
+            return Py_None;
+
+        err1:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
+            return NULL;
+        err0:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
+            return NULL;
+        }
+static PyObject *_wrap_wxDC__DrawPointList(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    PyObject * _result;
+    wxDC * _arg0;
+    PyObject * _arg1;
+    PyObject * _arg2;
+    PyObject * _argo0 = 0;
+    PyObject * _obj1 = 0;
+    PyObject * _obj2 = 0;
+    char *_kwnames[] = { "self","pyPoints","pyPens", NULL };
+
+    self = self;
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OOO:wxDC__DrawPointList",_kwnames,&_argo0,&_obj1,&_obj2)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxDC_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxDC__DrawPointList. Expected _wxDC_p.");
+        return NULL;
+        }
+    }
+{
+  _arg1 = _obj1;
+}
+{
+  _arg2 = _obj2;
+}
+{
+    wxPy_BEGIN_ALLOW_THREADS;
+        _result = (PyObject *)wxDC__DrawPointList(_arg0,_arg1,_arg2);
+
+    wxPy_END_ALLOW_THREADS;
+    if (PyErr_Occurred()) return NULL;
+}{
+  _resultobj = _result;
+}
+    return _resultobj;
+}
+
+static PyObject * wxDC__DrawLineList(wxDC *self,PyObject * pyLines,PyObject * pyPens) {
+            bool      isFastSeq  = PyList_Check(pyLines) || PyTuple_Check(pyLines);
+            bool      isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
+            int       numObjs = 0;
+            int       numPens = 0;
+            wxPen*    pen;
+            PyObject* obj;
+            int       x1, y1, x2, y2;
+            int       i = 0;
+
+            if (!PySequence_Check(pyLines)) {
+                goto err0;
+            }
+            if (!PySequence_Check(pyPens)) {
+                goto err1;
+            }
+            numObjs = PySequence_Length(pyLines);
+            numPens = PySequence_Length(pyPens);
+
+            for (i = 0; i < numObjs; i++) {
+                // Use a new pen?
+                if (i < numPens) {
+                    if (isFastPens) {
+                        obj = PySequence_Fast_GET_ITEM(pyPens, i);
+                    }
+                    else {
+                        obj = PySequence_GetItem(pyPens, i);
+                    }
+                    if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+                        goto err1;
+                    }
+
+                    self->SetPen(*pen);
+                    if (!isFastPens)
+                        Py_DECREF(obj);
+                }
+
+                // Get the line coordinants
+                if (isFastSeq) {
+                    obj = PySequence_Fast_GET_ITEM(pyLines, i);
+                }
+                else {
+                    obj = PySequence_GetItem(pyLines, i);
+                }
+                if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
+                    Py_DECREF(obj);
+                    goto err0;
+                }
+
+                // Now draw the line
+                self->DrawLine(x1, y1, x2, y2);
+
+                if (!isFastSeq)
+                    Py_DECREF(obj);
+            }
+
+            Py_INCREF(Py_None);
+            return Py_None;
+
+        err1:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
+            return NULL;
+        err0:
+            PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
+            return NULL;
+        }
+static PyObject *_wrap_wxDC__DrawLineList(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    PyObject * _result;
+    wxDC * _arg0;
+    PyObject * _arg1;
+    PyObject * _arg2;
+    PyObject * _argo0 = 0;
+    PyObject * _obj1 = 0;
+    PyObject * _obj2 = 0;
+    char *_kwnames[] = { "self","pyLines","pyPens", NULL };
+
+    self = self;
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OOO:wxDC__DrawLineList",_kwnames,&_argo0,&_obj1,&_obj2)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxDC_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxDC__DrawLineList. Expected _wxDC_p.");
+        return NULL;
+        }
+    }
+{
+  _arg1 = _obj1;
+}
+{
+  _arg2 = _obj2;
+}
+{
+    wxPy_BEGIN_ALLOW_THREADS;
+        _result = (PyObject *)wxDC__DrawLineList(_arg0,_arg1,_arg2);
+
+    wxPy_END_ALLOW_THREADS;
+    if (PyErr_Occurred()) return NULL;
+}{
+  _resultobj = _result;
+}
+    return _resultobj;
+}
+
 static void *SwigwxMemoryDCTowxDC(void *ptr) {
     wxMemoryDC *src;
     wxDC *dest;
@@ -11633,7 +11917,10 @@ static PyMethodDef gdicMethods[] = {
         { "new_wxScreenDC", (PyCFunction) _wrap_new_wxScreenDC, METH_VARARGS | METH_KEYWORDS },
         { "wxMemoryDC_SelectObject", (PyCFunction) _wrap_wxMemoryDC_SelectObject, METH_VARARGS | METH_KEYWORDS },
         { "new_wxMemoryDC", (PyCFunction) _wrap_new_wxMemoryDC, METH_VARARGS | METH_KEYWORDS },
+        { "wxDC__DrawLineList", (PyCFunction) _wrap_wxDC__DrawLineList, METH_VARARGS | METH_KEYWORDS },
+        { "wxDC__DrawPointList", (PyCFunction) _wrap_wxDC__DrawPointList, METH_VARARGS | METH_KEYWORDS },
         { "wxDC_GetHDC", (PyCFunction) _wrap_wxDC_GetHDC, METH_VARARGS | METH_KEYWORDS },
+        { "wxDC_GetBoundingBox", (PyCFunction) _wrap_wxDC_GetBoundingBox, METH_VARARGS | METH_KEYWORDS },
         { "wxDC_ResetBoundingBox", (PyCFunction) _wrap_wxDC_ResetBoundingBox, METH_VARARGS | METH_KEYWORDS },
         { "wxDC_CalcBoundingBox", (PyCFunction) _wrap_wxDC_CalcBoundingBox, METH_VARARGS | METH_KEYWORDS },
         { "wxDC_SetAxisOrientation", (PyCFunction) _wrap_wxDC_SetAxisOrientation, METH_VARARGS | METH_KEYWORDS },
index d93f9670c9c471cad985db29301e0ed69ba4fe11..314869001d4c7a0dd6789aa9d4294e93d9475957 100644 (file)
@@ -910,11 +910,39 @@ class wxDCPtr(wxObjectPtr):
     def ResetBoundingBox(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_ResetBoundingBox,(self,) + _args, _kwargs)
         return val
+    def GetBoundingBox(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC_GetBoundingBox,(self,) + _args, _kwargs)
+        return val
     def GetHDC(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_GetHDC,(self,) + _args, _kwargs)
         return val
+    def _DrawPointList(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC__DrawPointList,(self,) + _args, _kwargs)
+        return val
+    def _DrawLineList(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC__DrawLineList,(self,) + _args, _kwargs)
+        return val
     def __repr__(self):
         return "<C wxDC instance at %s>" % (self.this,)
+    
+    def DrawPointList(self, points, pens=None):
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(points):
+           raise ValueError('points and pens must have same length')
+        return self._DrawPointList(points, pens)
+
+    def DrawLineList(self, lines, pens=None):
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(lines):
+           raise ValueError('lines and pens must have same length')
+        return self._DrawLineList(lines, pens)
+
 class wxDC(wxDCPtr):
     def __init__(self,this):
         self.this = this
index aa8058f317dc5dbf1876858b21cc7a5bcd41eed6..fa722814e8b099a9a115c4881f984cc239810bb7 100644 (file)
@@ -4215,6 +4215,57 @@ static PyObject *_wrap_wxHtmlWindow_LoadPage(PyObject *self, PyObject *args, PyO
     return _resultobj;
 }
 
+#define wxHtmlWindow_AppendToPage(_swigobj,_swigarg0)  (_swigobj->AppendToPage(_swigarg0))
+static PyObject *_wrap_wxHtmlWindow_AppendToPage(PyObject *self, PyObject *args, PyObject *kwargs) {
+    PyObject * _resultobj;
+    bool  _result;
+    wxPyHtmlWindow * _arg0;
+    wxString * _arg1;
+    PyObject * _argo0 = 0;
+    PyObject * _obj1 = 0;
+    char *_kwnames[] = { "self","source", NULL };
+
+    self = self;
+    if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxHtmlWindow_AppendToPage",_kwnames,&_argo0,&_obj1)) 
+        return NULL;
+    if (_argo0) {
+        if (_argo0 == Py_None) { _arg0 = NULL; }
+        else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyHtmlWindow_p")) {
+            PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxHtmlWindow_AppendToPage. Expected _wxPyHtmlWindow_p.");
+        return NULL;
+        }
+    }
+{
+#if PYTHON_API_VERSION >= 1009
+    char* tmpPtr; int tmpSize;
+    if (!PyString_Check(_obj1) && !PyUnicode_Check(_obj1)) {
+        PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
+        return NULL;
+    }
+    if (PyString_AsStringAndSize(_obj1, &tmpPtr, &tmpSize) == -1)
+        return NULL;
+    _arg1 = new wxString(tmpPtr, tmpSize);
+#else
+    if (!PyString_Check(_obj1)) {
+        PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
+        return NULL;
+    }
+    _arg1 = new wxString(PyString_AS_STRING(_obj1), PyString_GET_SIZE(_obj1));
+#endif
+}
+{
+    wxPy_BEGIN_ALLOW_THREADS;
+        _result = (bool )wxHtmlWindow_AppendToPage(_arg0,*_arg1);
+
+    wxPy_END_ALLOW_THREADS;
+}    _resultobj = Py_BuildValue("i",_result);
+{
+    if (_obj1)
+        delete _arg1;
+}
+    return _resultobj;
+}
+
 #define wxHtmlWindow_GetOpenedPage(_swigobj)  (_swigobj->GetOpenedPage())
 static PyObject *_wrap_wxHtmlWindow_GetOpenedPage(PyObject *self, PyObject *args, PyObject *kwargs) {
     PyObject * _resultobj;
@@ -6211,6 +6262,7 @@ static PyMethodDef htmlcMethods[] = {
         { "wxHtmlWindow_GetOpenedPageTitle", (PyCFunction) _wrap_wxHtmlWindow_GetOpenedPageTitle, METH_VARARGS | METH_KEYWORDS },
         { "wxHtmlWindow_GetOpenedAnchor", (PyCFunction) _wrap_wxHtmlWindow_GetOpenedAnchor, METH_VARARGS | METH_KEYWORDS },
         { "wxHtmlWindow_GetOpenedPage", (PyCFunction) _wrap_wxHtmlWindow_GetOpenedPage, METH_VARARGS | METH_KEYWORDS },
+        { "wxHtmlWindow_AppendToPage", (PyCFunction) _wrap_wxHtmlWindow_AppendToPage, METH_VARARGS | METH_KEYWORDS },
         { "wxHtmlWindow_LoadPage", (PyCFunction) _wrap_wxHtmlWindow_LoadPage, METH_VARARGS | METH_KEYWORDS },
         { "wxHtmlWindow_SetPage", (PyCFunction) _wrap_wxHtmlWindow_SetPage, METH_VARARGS | METH_KEYWORDS },
         { "wxHtmlWindow__setCallbackInfo", (PyCFunction) _wrap_wxHtmlWindow__setCallbackInfo, METH_VARARGS | METH_KEYWORDS },
index ca0d083fe15b2ebb00d78c54705c1168e90fe49e..756c036cbd0d1c5852f378f3be2de25302885bd7 100644 (file)
@@ -11,13 +11,13 @@ from clip_dnd import *
 
 from cmndlgs import *
 
+from events import *
+
 from frames import *
 
 from stattool import *
 
 from controls import *
-
-from events import *
 import wx
 class wxPrintDataPtr(wxObjectPtr):
     def __init__(self,this):