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:
@@ -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 },
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user