helpers and typemaps for new GraphicsContext methods

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-10-11 04:42:49 +00:00
parent 0f82eb02e4
commit 281c54cc42
6 changed files with 273 additions and 72 deletions
+3
View File
@@ -119,6 +119,9 @@ inline wxPyCoreAPI* wxPyGetCoreAPIPtr()
#define wxPyCheckForApp() (wxPyGetCoreAPIPtr()->p_wxPyCheckForApp())
#define wxArrayDouble2PyList_helper(a) (wxPyGetCoreAPIPtr()->p_wxArrayDoublePyList_helper(a))
#define wxPoint2D_LIST_helper(a,b) (wxPyGetCoreAPIPtr()->p_wxPoint2D_LIST_helper(a, b))
//----------------------------------------------------------------------
#endif
@@ -235,6 +235,7 @@ int* int_LIST_helper(PyObject* source);
long* long_LIST_helper(PyObject* source);
char** string_LIST_helper(PyObject* source);
wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
wxPoint2D* wxPoint2D_LIST_helper(PyObject* source, size_t* npoints);
wxBitmap** wxBitmap_LIST_helper(PyObject* source);
wxString* wxString_LIST_helper(PyObject* source);
wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
@@ -261,6 +262,7 @@ bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
PyObject* wxArrayString2PyList_helper(const wxArrayString& arr);
PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr);
PyObject* wxArrayDouble2PyList_helper(const wxArrayDouble& arr);
#endif // wxPyUSE_EXPORTED_API
@@ -422,8 +424,12 @@ struct wxPyCoreAPI {
bool (*p_wxPyCheckForApp)();
// Add all new items at the end...
PyObject* (*p_wxArrayDoublePyList_helper)(const wxArrayDouble& arr);
wxPoint2D* (*p_wxPoint2D_LIST_helper)(PyObject* source, size_t* npoints);
};
#ifdef wxPyUSE_EXPORTED_API
// Notice that this is static, not extern. This is by design, each module
// needs one, but doesn't have to use it.
+3 -1
View File
@@ -235,8 +235,10 @@ static wxPyCoreAPI API = {
wxPyInstance_Check,
wxPySwigInstance_Check,
wxPyCheckForApp
wxPyCheckForApp,
wxArrayDouble2PyList_helper,
wxPoint2D_LIST_helper
};
#endif
+60 -19
View File
@@ -20,6 +20,10 @@
#include <wx/graphics.h>
%}
// Turn off the aquisition of the Global Interpreter Lock for the classes and
// functions in this file
%threadWrapperOff
//---------------------------------------------------------------------------
@@ -140,6 +144,17 @@ public:
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
%typemap(in) (size_t points, wxPoint2D* points_array ) {
$2 = wxPoint2D_LIST_helper($input, &$1);
if ($2 == NULL) SWIG_fail;
}
%typemap(freearg) (size_t points, wxPoint2D* points_array ) {
if ($2) delete [] $2;
}
MustHaveApp(wxGraphicsPath);
MustHaveApp(wxGraphicsContext);
MustHaveApp(wxGCDC);
@@ -210,7 +225,7 @@ point and an end point", "");
DocDeclStr(
virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
"Appends an ellipsis as a new closed subpath fitting the passed rectangle", "");
"Appends a circle as a new closed subpath with the given radius.", "");
DocDeclStr(
@@ -351,23 +366,32 @@ public:
"", "");
DocDeclStr(
DocDeclStrName(
virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
"", "");
"", "",
DrawRotatedText);
DocDeclStr(
DocDeclAStr(
virtual void , GetTextExtent( const wxString &text,
wxDouble *OUTPUT /*width*/,
wxDouble *OUTPUT /*height*/,
wxDouble *OUTPUT /*descent*/,
wxDouble *OUTPUT /*externalLeading*/ ) const ,
"GetTextExtend(self, text) --> (width, height, descent, externalLeading)",
"", "");
DocDeclStr(
virtual void , GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const,
"", "");
%extend {
DocAStr(GetPartialTextExtents,
"GetPartialTextExtents(self, text) -> [widths]",
"", "");
wxArrayDouble GetPartialTextExtents(const wxString& text) {
wxArrayDouble widths;
self->GetPartialTextExtents(text, widths);
return widths;
}
}
//
@@ -392,23 +416,39 @@ public:
DocDeclStr(
virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
"", "");
// stroke lines connecting each of the points
DocDeclStr(
virtual void , StrokeLines( size_t n, const wxPoint2D *points),
DocDeclAStr(
virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
"StrokeLines(self, List points)",
"", "");
// stroke disconnected lines from begin to end points
DocDeclStr(
virtual void , StrokeLines( size_t n, const wxPoint2D *beginPoints, const wxPoint2D *endPoints),
"", "");
// // stroke disconnected lines from begin to end points
// virtual void StrokeLines( size_t n, const wxPoint2D *beginPoints, const wxPoint2D *endPoints);
// is there a better name for this?
%extend {
void StrokeDisconnectedLines(PyObject* beginPoints, PyObject* endPoints)
{
size_t c1, c2, count;
wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
if ( beginP != NULL && endP != NULL )
{
count = wxMin(c1, c2);
self->StrokeLines(count, beginP, endP);
}
delete [] beginP;
delete [] endP;
}
}
// draws a polygon
DocDeclStr(
virtual void , DrawLines( size_t n, const wxPoint2D *points, int fillStyle = wxWINDING_RULE ),
virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ),
"", "");
@@ -429,7 +469,6 @@ public:
virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
"", "");
};
@@ -449,6 +488,8 @@ public:
};
//---------------------------------------------------------------------------
// Turn GIL acquisition back on.
%threadWrapperOn
+169 -38
View File
File diff suppressed because it is too large Load Diff
+32 -14
View File
@@ -243,24 +243,42 @@ MAKE_INT_ARRAY_TYPEMAPS(styles, styles_field)
//---------------------------------------------------------------------------
// Typemaps to convert an array of ints to a list for return values
// %typemap(out) wxArrayInt& {
// $result = PyList_New(0);
// size_t idx;
// for (idx = 0; idx < $1->GetCount(); idx += 1) {
// PyObject* val = PyInt_FromLong( $1->Item(idx) );
// PyList_Append($result, val);
// Py_DECREF(val);
// }
// }
// %typemap(out) wxArrayInt {
// $result = PyList_New(0);
// size_t idx;
// for (idx = 0; idx < $1.GetCount(); idx += 1) {
// PyObject* val = PyInt_FromLong( $1.Item(idx) );
// PyList_Append($result, val);
// Py_DECREF(val);
// }
// }
%typemap(out) wxArrayInt& {
$result = PyList_New(0);
size_t idx;
for (idx = 0; idx < $1->GetCount(); idx += 1) {
PyObject* val = PyInt_FromLong( $1->Item(idx) );
PyList_Append($result, val);
Py_DECREF(val);
}
$result = wxArrayInt2PyList_helper(*$1);
}
%typemap(out) wxArrayInt {
$result = PyList_New(0);
size_t idx;
for (idx = 0; idx < $1.GetCount(); idx += 1) {
PyObject* val = PyInt_FromLong( $1.Item(idx) );
PyList_Append($result, val);
Py_DECREF(val);
}
$result = wxArrayInt2PyList_helper($1);
}
// convert array of doubles to a Python list
%typemap(out) wxArrayDouble& {
$result = wxArrayDouble2PyList_helper(*$1);
}
%typemap(out) wxArrayDouble {
$result = wxArrayDouble2PyList_helper($1);
}