Added some optimization methods to wxPython's wxDC

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-10-16 19:06:09 +00:00
parent 9e0a12c958
commit 9d37f96428
11 changed files with 797 additions and 11 deletions

View File

@@ -54,6 +54,9 @@ Added wxFindReplaceDialog.
The second phase of OOR is implemented (for wxEvtHandler and derived The second phase of OOR is implemented (for wxEvtHandler and derived
classes at least.) classes at least.)
Added some optimization methods to wxDC: GetBoundingBox, DrawLineList,
DrawPointList.

View File

@@ -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.
"""

View File

@@ -30,6 +30,7 @@ _treeList = [
'TablePrint', 'TablePrint',
'OOR', 'OOR',
'wxFindReplaceDialog', 'wxFindReplaceDialog',
'DrawXXXList',
##'wxPopupWindow', ##'wxPopupWindow',
]), ]),
@@ -63,7 +64,7 @@ _treeList = [
'PythonEvents', 'Threads', 'PythonEvents', 'Threads',
'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE', 'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE',
'wxDragImage', "wxProcess", "FancyText", "OOR", "wxWave", 'wxDragImage', "wxProcess", "FancyText", "OOR", "wxWave",
'wxJoystick', 'wxJoystick', 'DrawXXXList',
]), ]),
('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog', ('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog',

View File

@@ -517,7 +517,7 @@ public:
int GetItemCount() const; int GetItemCount() const;
// Gets the number of columns in the list control // 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. // Retrieves the spacing between icons in pixels.
// If small is TRUE, gets the spacing for the small icon // If small is TRUE, gets the spacing for the small icon

View File

@@ -818,12 +818,192 @@ public:
void CalcBoundingBox(int x, int y); void CalcBoundingBox(int x, int y);
void ResetBoundingBox(); void ResetBoundingBox();
%addmethods {
void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
// See below for implementation
}
#ifdef __WXMSW__ #ifdef __WXMSW__
long GetHDC(); long GetHDC();
#endif #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 { class wxMemoryDC : public wxDC {

View 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) { wxPoint* wxPoint_LIST_helper(PyObject* source, int *count) {
// Putting all of the declarations here allows // Putting all of the declarations here allows
// us to put the error handling all in one place. // us to put the error handling all in one place.
int x; int x;
wxPoint* temp; wxPoint* temp;
PyObject *o, *o1, *o2; 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)) { if (!PySequence_Check(source)) {
goto error0; goto error0;
} }
// The length of the sequence is returned in count.
*count = PySequence_Length(source); *count = PySequence_Length(source);
if (*count < 0) { if (*count < 0) {
goto error0; 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;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -134,6 +134,7 @@ wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
wxBitmap** wxBitmap_LIST_helper(PyObject* source); wxBitmap** wxBitmap_LIST_helper(PyObject* source);
wxString* wxString_LIST_helper(PyObject* source); wxString* wxString_LIST_helper(PyObject* source);
wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source); wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
wxPen** wxPen_LIST_helper(PyObject* source);
bool wxSize_helper(PyObject* source, wxSize** obj); bool wxSize_helper(PyObject* source, wxSize** obj);
bool wxPoint_helper(PyObject* source, wxPoint** 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 wxRect_helper(PyObject* source, wxRect** obj);
bool wxColour_helper(PyObject* source, wxColour** 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 #ifndef SWIGCODE
@@ -1505,6 +1515,7 @@ public:
wxPyEndBlockThreads(state); \ wxPyEndBlockThreads(state); \
if (! found) \ if (! found) \
return PCLASS::CBNAME(e); \ return PCLASS::CBNAME(e); \
return rval; \
} \ } \
bool CLASS::base_##CBNAME(wxMouseEvent& e) { \ bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
return PCLASS::CBNAME(e); \ return PCLASS::CBNAME(e); \

View File

@@ -207,6 +207,13 @@ public:
private: private:
wxDash* m_dash; 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' // Alternate 'constructor'
wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) { wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
return new wxMemoryDC(oldDC); return new wxMemoryDC(oldDC);
@@ -9350,6 +9357,73 @@ static PyObject *_wrap_wxDC_ResetBoundingBox(PyObject *self, PyObject *args, PyO
return _resultobj; 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()) #define wxDC_GetHDC(_swigobj) (_swigobj->GetHDC())
static PyObject *_wrap_wxDC_GetHDC(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxDC_GetHDC(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
@@ -9378,6 +9452,216 @@ static PyObject *_wrap_wxDC_GetHDC(PyObject *self, PyObject *args, PyObject *kwa
return _resultobj; 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) { static void *SwigwxMemoryDCTowxDC(void *ptr) {
wxMemoryDC *src; wxMemoryDC *src;
wxDC *dest; wxDC *dest;
@@ -11633,7 +11917,10 @@ static PyMethodDef gdicMethods[] = {
{ "new_wxScreenDC", (PyCFunction) _wrap_new_wxScreenDC, METH_VARARGS | METH_KEYWORDS }, { "new_wxScreenDC", (PyCFunction) _wrap_new_wxScreenDC, METH_VARARGS | METH_KEYWORDS },
{ "wxMemoryDC_SelectObject", (PyCFunction) _wrap_wxMemoryDC_SelectObject, METH_VARARGS | METH_KEYWORDS }, { "wxMemoryDC_SelectObject", (PyCFunction) _wrap_wxMemoryDC_SelectObject, METH_VARARGS | METH_KEYWORDS },
{ "new_wxMemoryDC", (PyCFunction) _wrap_new_wxMemoryDC, 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_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_ResetBoundingBox", (PyCFunction) _wrap_wxDC_ResetBoundingBox, METH_VARARGS | METH_KEYWORDS },
{ "wxDC_CalcBoundingBox", (PyCFunction) _wrap_wxDC_CalcBoundingBox, METH_VARARGS | METH_KEYWORDS }, { "wxDC_CalcBoundingBox", (PyCFunction) _wrap_wxDC_CalcBoundingBox, METH_VARARGS | METH_KEYWORDS },
{ "wxDC_SetAxisOrientation", (PyCFunction) _wrap_wxDC_SetAxisOrientation, METH_VARARGS | METH_KEYWORDS }, { "wxDC_SetAxisOrientation", (PyCFunction) _wrap_wxDC_SetAxisOrientation, METH_VARARGS | METH_KEYWORDS },

View File

@@ -910,11 +910,39 @@ class wxDCPtr(wxObjectPtr):
def ResetBoundingBox(self, *_args, **_kwargs): def ResetBoundingBox(self, *_args, **_kwargs):
val = apply(gdic.wxDC_ResetBoundingBox,(self,) + _args, _kwargs) val = apply(gdic.wxDC_ResetBoundingBox,(self,) + _args, _kwargs)
return val return val
def GetBoundingBox(self, *_args, **_kwargs):
val = apply(gdic.wxDC_GetBoundingBox,(self,) + _args, _kwargs)
return val
def GetHDC(self, *_args, **_kwargs): def GetHDC(self, *_args, **_kwargs):
val = apply(gdic.wxDC_GetHDC,(self,) + _args, _kwargs) val = apply(gdic.wxDC_GetHDC,(self,) + _args, _kwargs)
return val 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): def __repr__(self):
return "<C wxDC instance at %s>" % (self.this,) 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): class wxDC(wxDCPtr):
def __init__(self,this): def __init__(self,this):
self.this = this self.this = this

View File

@@ -4215,6 +4215,57 @@ static PyObject *_wrap_wxHtmlWindow_LoadPage(PyObject *self, PyObject *args, PyO
return _resultobj; 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()) #define wxHtmlWindow_GetOpenedPage(_swigobj) (_swigobj->GetOpenedPage())
static PyObject *_wrap_wxHtmlWindow_GetOpenedPage(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxHtmlWindow_GetOpenedPage(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
@@ -6211,6 +6262,7 @@ static PyMethodDef htmlcMethods[] = {
{ "wxHtmlWindow_GetOpenedPageTitle", (PyCFunction) _wrap_wxHtmlWindow_GetOpenedPageTitle, METH_VARARGS | METH_KEYWORDS }, { "wxHtmlWindow_GetOpenedPageTitle", (PyCFunction) _wrap_wxHtmlWindow_GetOpenedPageTitle, METH_VARARGS | METH_KEYWORDS },
{ "wxHtmlWindow_GetOpenedAnchor", (PyCFunction) _wrap_wxHtmlWindow_GetOpenedAnchor, 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_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_LoadPage", (PyCFunction) _wrap_wxHtmlWindow_LoadPage, METH_VARARGS | METH_KEYWORDS },
{ "wxHtmlWindow_SetPage", (PyCFunction) _wrap_wxHtmlWindow_SetPage, METH_VARARGS | METH_KEYWORDS }, { "wxHtmlWindow_SetPage", (PyCFunction) _wrap_wxHtmlWindow_SetPage, METH_VARARGS | METH_KEYWORDS },
{ "wxHtmlWindow__setCallbackInfo", (PyCFunction) _wrap_wxHtmlWindow__setCallbackInfo, METH_VARARGS | METH_KEYWORDS }, { "wxHtmlWindow__setCallbackInfo", (PyCFunction) _wrap_wxHtmlWindow__setCallbackInfo, METH_VARARGS | METH_KEYWORDS },

View File

@@ -11,13 +11,13 @@ from clip_dnd import *
from cmndlgs import * from cmndlgs import *
from events import *
from frames import * from frames import *
from stattool import * from stattool import *
from controls import * from controls import *
from events import *
import wx import wx
class wxPrintDataPtr(wxObjectPtr): class wxPrintDataPtr(wxObjectPtr):
def __init__(self,this): def __init__(self,this):