1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Wrapper definitions for wx.GraphicsPath, wx.GraphicsContext
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
20 #include <wx/graphics.h>
23 // Turn off the aquisition of the Global Interpreter Lock for the classes and
24 // functions in this file
28 //---------------------------------------------------------------------------
29 //---------------------------------------------------------------------------
32 #if !wxUSE_GRAPHICS_CONTEXT
33 // C++ stub classes for platforms or build configurations that don't have
34 // wxGraphicsContext yet.
37 class wxGraphicsObject : public wxObject
40 wxGraphicsObject( wxGraphicsRenderer* ) {
41 PyErr_SetString(PyExc_NotImplementedError,
42 "wx.GraphicsObject is not available on this platform.");
44 wxGraphicsObject( const wxGraphicsObject& ) {}
45 virtual ~wxGraphicsObject() {}
46 bool IsNull() const { return false; }
47 wxGraphicsRenderer* GetRenderer() const { return NULL; }
52 class wxGraphicsPen : public wxGraphicsObject
55 virtual ~wxGraphicsPen() {}
57 wxGraphicsPen wxNullGraphicsPen;
61 class wxGraphicsBrush : public wxGraphicsObject
65 virtual ~wxGraphicsBrush() {}
67 wxGraphicsBrush wxNullGraphicsBrush;
71 class wxGraphicsFont : public wxGraphicsObject
75 virtual ~wxGraphicsFont() {}
77 wxGraphicsFont wxNullGraphicsFont;
81 class wxGraphicsPath : public wxGraphicsObject
84 wxGraphicsPath(wxGraphicsRenderer* ) {
85 PyErr_SetString(PyExc_NotImplementedError,
86 "wx.GraphicsPath is not available on this platform.");
88 virtual ~wxGraphicsPath() {}
90 virtual wxGraphicsPath *Clone() const { return NULL; }
92 void MoveToPoint( wxDouble, wxDouble ) {}
93 void MoveToPoint( const wxPoint2DDouble& ) {}
94 void AddLineToPoint( wxDouble, wxDouble ) {}
95 void AddLineToPoint( const wxPoint2DDouble& ) {}
96 void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {}
97 void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {}
98 void AddPath( const wxGraphicsPath* ) {}
99 void CloseSubpath() {}
100 void GetCurrentPoint( wxDouble&, wxDouble&) {}
101 wxPoint2DDouble GetCurrentPoint() { reutrn wxPoint2D(0,0); }
102 void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {}
103 void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {}
105 void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {}
106 void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {}
107 void AddCircle( wxDouble, wxDouble, wxDouble ) {}
108 void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {}
110 void AddEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {}
111 void AddRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {}
112 void * GetNativePath() const { return NULL; }
113 void UnGetNativePath(void *) {}
114 void Transform( wxGraphicsMatrix* ) {}
115 void GetBox(wxDouble *, wxDouble *, wxDouble *, wxDouble *) {}
116 wxRect2D GetBox() { return wxRect2D(0,0,0,0); }
118 bool Contains( wxDouble , wxDouble , int ) { return false; }
119 bool Contains( const wxPoint2DDouble& , int ) { return false; }
123 class wxGraphicsMatrix : public wxGraphicsObject
126 wxGraphicsMatrix(wxGraphicsRenderer* ) {
127 PyErr_SetString(PyExc_NotImplementedError,
128 "wx.GraphicsMatrix is not available on this platform.");
130 virtual ~wxGraphicsMatrix() {}
131 virtual wxGraphicsMatrix *Clone() const { return NULL; }
132 virtual void Concat( const wxGraphicsMatrix * ) {}
133 virtual void Copy( const wxGraphicsMatrix * ) {}
134 virtual void Set(wxDouble , wxDouble , wxDouble , wxDouble ,
135 wxDouble , wxDouble ) {}
136 virtual void Invert() {}
137 virtual bool IsEqual( const wxGraphicsMatrix* t) const {}
138 virtual bool IsIdentity() { return false; }
139 virtual void Translate( wxDouble , wxDouble ) {}
140 virtual void Scale( wxDouble , wxDouble ) {}
141 virtual void Rotate( wxDouble ) {}
142 virtual void TransformPoint( wxDouble *, wxDouble * ) {}
143 virtual void TransformDistance( wxDouble *, wxDouble * ) {}
144 virtual void * GetNativeMatrix() const { return NULL; }
149 class wxGraphicsContext : public wxGraphicsObject
153 wxGraphicsContext(wxGraphicsRenderer* ) {
154 PyErr_SetString(PyExc_NotImplementedError,
155 "wx.GraphicsContext is not available on this platform.");
158 virtual ~wxGraphicsContext() {}
160 static wxGraphicsContext* Create( const wxWindowDC& ) {
161 PyErr_SetString(PyExc_NotImplementedError,
162 "wx.GraphicsContext is not available on this platform.");
165 static wxGraphicsContext* CreateFromNative( void * ) {
166 PyErr_SetString(PyExc_NotImplementedError,
167 "wx.GraphicsContext is not available on this platform.");
170 static wxGraphicsContext* CreateFromNativeWindow( void * ) {
171 PyErr_SetString(PyExc_NotImplementedError,
172 "wx.GraphicsContext is not available on this platform.");
175 static wxGraphicsContext* Create( wxWindow* ) {
176 PyErr_SetString(PyExc_NotImplementedError,
177 "wx.GraphicsContext is not available on this platform.");
180 wxGraphicsPath * CreatePath() { return NULL; }
182 virtual wxGraphicsPen CreatePen(const wxPen& ) { return NULL; }
184 virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return NULL; }
186 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble ,
187 const wxColour&, const wxColour&) { return NULL; }
189 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
190 wxDouble xc, wxDouble yc, wxDouble radius,
191 const wxColour &oColor, const wxColour &cColor) { return NULL; }
193 virtual wxGraphicsFont CreateFont( const wxFont &, const wxColour & ) { return NULL; }
195 virtual wxGraphicsMatrix* CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble,
196 wxDouble, wxDouble) { return NULL; }
198 virtual void PushState() {}
199 virtual void PopState() {}
200 virtual void Clip( const wxRegion & ) {}
201 virtual void Clip( wxDouble , wxDouble , wxDouble , wxDouble ) {}
202 virtual void ResetClip() {}
203 virtual void * GetNativeContext() { return NULL; }
204 virtual void Translate( wxDouble , wxDouble ) {}
205 virtual void Scale( wxDouble , wxDouble ) {}
206 virtual void Rotate( wxDouble ) {}
207 virtual void ConcatTransform( const wxGraphicsMatrix* ) {}
208 virtual void SetTransform( const wxGraphicsMatrix* ) {}
209 virtual void GetTransform( wxGraphicsMatrix* ) {}
211 virtual void SetPen( const wxGraphicsPen& ) {}
212 void SetPen( const wxPen& ) {}
214 virtual void SetBrush( const wxGraphicsBrush& ) {}
215 void SetBrush( const wxBrush& ) {}
217 virtual void SetFont( const wxGraphicsFont& ) {}
218 void SetFont( const wxFont&, const wxColour& ) {}
220 virtual void StrokePath( const wxGraphicsPath * ) {}
221 virtual void FillPath( const wxGraphicsPath *, int ) {}
222 virtual void DrawPath( const wxGraphicsPath *, int ) {}
224 virtual void DrawText( const wxString &, wxDouble , wxDouble ) {}
225 virtual void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {}
226 virtual void GetTextExtent( const wxString &, wxDouble *, wxDouble *,
227 wxDouble *, wxDouble * ) const {}
228 virtual void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {}
230 virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
231 virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
233 virtual void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {}
234 virtual void StrokeLines( size_t , const wxPoint2DDouble *) {}
235 virtual void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {}
236 virtual void DrawLines( size_t , const wxPoint2DDouble *, int ) {}
237 virtual void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {}
238 virtual void DrawEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {}
239 virtual void DrawRoundedRectangle( wxDouble wxDouble , wxDouble , wxDouble , wxDouble ) {}
240 virtual bool ShouldOffset() const { return false; }
244 class wxGraphicsRenderer : public wxObject
247 wxGraphicsRenderer() {
248 PyErr_SetString(PyExc_NotImplementedError,
249 "wx.GraphicsRenderer is not available on this platform.");
252 virtual ~wxGraphicsRenderer() {}
254 static wxGraphicsRenderer* GetDefaultRenderer(
255 PyErr_SetString(PyExc_NotImplementedError,
256 "wx.GraphicsRenderer is not available on this platform.");
259 virtual wxGraphicsContext * CreateContext( const wxWindowDC& ) { return NULL; }
260 virtual wxGraphicsContext * CreateContextFromNativeContext( void * ) { return NULL; }
261 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * ) { return NULL; }
262 virtual wxGraphicsContext * CreateContext( wxWindow* ) { return NULL; }
264 virtual wxGraphicsPath * CreatePath() { return NULL; }
266 virtual wxGraphicsMatrix * CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble ,
267 wxDouble , wxDouble ) { return NULL; }
269 virtual wxGraphicsPen CreatePen(const wxPen& ) { return wxNullGaphicsPen; }
270 virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return wxNullGaphicsBrush; }
271 virtual wxGraphicsBrush CreateLinearGradientBrush(xDouble , wxDouble , wxDouble , wxDouble ,
272 const wxColour&, const wxColour&) { return wxNullGaphicsBrush; }
273 virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ,
274 const wxColour &, const wxColour &) { return wxNullGaphicsBrush; }
275 virtual wxGraphicsFont CreateFont( const wxFont & , const wxColour & ) { return wxNullGaphicsFont; }
280 class wxGCDC: public wxWindowDC
283 wxGCDC(const wxWindowDC&) {
284 wxPyBlock_t blocked = wxPyBeginBlockThreads();
285 PyErr_SetString(PyExc_NotImplementedError,
286 "wxGCDC is not available on this platform.");
287 wxPyEndBlockThreads(blocked);
291 wxPyBlock_t blocked = wxPyBeginBlockThreads();
292 PyErr_SetString(PyExc_NotImplementedError,
293 "wxGCDC is not available on this platform.");
294 wxPyEndBlockThreads(blocked);
299 wxGraphicsContext* GetGraphicsContext() { return NULL; }
300 void SetGraphicsContext( wxGraphicsContext* ) {}
306 //---------------------------------------------------------------------------
307 //---------------------------------------------------------------------------
310 %typemap(in) (size_t points, wxPoint2D* points_array ) {
311 $2 = wxPoint2D_LIST_helper($input, &$1);
312 if ($2 == NULL) SWIG_fail;
314 %typemap(freearg) (size_t points, wxPoint2D* points_array ) {
315 if ($2) delete [] $2;
320 MustHaveApp(wxGraphicsPath);
321 MustHaveApp(wxGraphicsContext);
324 typedef double wxDouble;
327 //---------------------------------------------------------------------------
330 class wxGraphicsObject : public wxObject
333 wxGraphicsObject( wxGraphicsRenderer* renderer = NULL );
334 virtual ~wxGraphicsObject();
335 bool IsNull() const ;
336 wxGraphicsRenderer* GetRenderer() const;
340 class wxGraphicsPen : public wxGraphicsObject
344 virtual ~wxGraphicsPen();
348 class wxGraphicsBrush : public wxGraphicsObject
352 virtual ~wxGraphicsBrush();
356 class wxGraphicsFont : public wxGraphicsObject
360 virtual ~wxGraphicsFont();
365 const wxGraphicsPen wxNullGraphicsPen;
366 const wxGraphicsBrush wxNullGraphicsBrush;
367 const wxGraphicsFont wxNullGraphicsFont;
370 //---------------------------------------------------------------------------
372 class wxGraphicsPath : public wxGraphicsObject
375 //wxGraphicsPath(wxGraphicsRenderer* renderer); *** This class is an ABC, so we can't allow instances to be created directly
376 virtual ~wxGraphicsPath();
378 virtual wxGraphicsPath *Clone() const = 0;
381 %nokwargs MoveToPoint;
383 "Begins a new subpath at (x,y)", "");
384 virtual void MoveToPoint( wxDouble x, wxDouble y );
385 void MoveToPoint( const wxPoint2D& p);
388 %nokwargs AddLineToPoint;
389 DocStr(AddLineToPoint,
390 "Adds a straight line from the current point to (x,y) ", "");
391 virtual void AddLineToPoint( wxDouble x, wxDouble y );
392 void AddLineToPoint( const wxPoint2D& p);
395 %nokwargs AddCurveToPoint;
396 DocStr(AddCurveToPoint,
397 "Adds a cubic Bezier curve from the current point, using two control
398 points and an end point", "");
399 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1,
400 wxDouble cx2, wxDouble cy2,
401 wxDouble x, wxDouble y );
402 void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e);
407 virtual void , AddPath( const wxGraphicsPath* path ),
408 "adds another path", "");
412 virtual void , CloseSubpath(),
413 "closes the current sub-path", "");
417 wxPoint2D , GetCurrentPoint(),
418 "Gets the last point of the current path, (0,0) if not yet set", "");
423 "Adds an arc of a circle centering at (x,y) with radius (r) from
424 startAngle to endAngle", "");
425 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r,
426 wxDouble startAngle, wxDouble endAngle, bool clockwise );
427 void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
431 virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ),
432 "Adds a quadratic Bezier curve from the current point, using a control
433 point and an end point", "");
437 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
438 "Appends a rectangle as a new closed subpath", "");
442 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
443 "Appends a circle as a new closed subpath with the given radius.", "");
447 virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ,
448 "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1)
449 to (x2,y2), also a straight line from (current) to (x1,y1)", "");
453 virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
454 "appends an ellipse", "");
458 virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
459 "appends a rounded rectangle", "");
463 virtual void * , GetNativePath() const,
464 "returns the native path", "");
468 virtual void , UnGetNativePath(void *p),
469 "give the native path returned by GetNativePath() back (there might be some
470 deallocations necessary)", "");
474 virtual void , Transform( wxGraphicsMatrix* matrix ),
475 "transforms each point of this path by the matrix", "");
479 wxRect2DDouble , GetBox(),
480 "gets the bounding box enclosing all points (possibly including control points)", "");
486 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxWINDING_RULE);
487 bool Contains( const wxPoint2DDouble& c, int fillStyle = wxWINDING_RULE);
491 //---------------------------------------------------------------------------
493 class wxGraphicsMatrix : public wxGraphicsObject
496 // wxGraphicsMatrix(wxGraphicsRenderer* renderer); *** This class is an ABC
498 virtual ~wxGraphicsMatrix();
500 virtual wxGraphicsMatrix *Clone() const;
503 virtual void , Concat( const wxGraphicsMatrix *t ),
504 "concatenates the matrix", "");
508 virtual void , Copy( const wxGraphicsMatrix *t ),
509 "copies the passed in matrix", "");
513 virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
514 wxDouble tx=0.0, wxDouble ty=0.0),
515 "sets the matrix to the respective values", "");
519 virtual void , Invert(),
520 "makes this the inverse matrix", "");
524 virtual bool , IsEqual( const wxGraphicsMatrix* t) const,
525 "returns true if the elements of the transformation matrix are equal", "");
529 virtual bool , IsIdentity(),
530 "return true if this is the identity matrix", "");
534 virtual void , Translate( wxDouble dx , wxDouble dy ),
535 "add the translation to this matrix", "");
539 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
540 "add the scale to this matrix", "");
544 virtual void , Rotate( wxDouble angle ),
545 "add the rotation to this matrix (radians)", "");
549 virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ),
550 "TransformPoint(self, x, y) --> (x, y)",
551 "applies that matrix to the point", "");
555 virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ),
556 "TransformDistance(self, dx, dy) --> (dx, dy)",
557 "applies the matrix except for translations", "");
561 virtual void * , GetNativeMatrix() const,
562 "returns the native representation", "");
565 //---------------------------------------------------------------------------
568 class wxGraphicsContext : public wxGraphicsObject
571 // wxGraphicsContext() This is also an ABC, use Create to make an instance...
572 virtual ~wxGraphicsContext();
577 "val.__dc = args[0] # save a ref so the dc will not be deleted before self";
578 static wxGraphicsContext* Create( const wxWindowDC& dc);
580 static wxGraphicsContext* Create( wxWindow* window ) ;
582 %newobject CreateFromNative;
583 static wxGraphicsContext* CreateFromNative( void * context ) ;
585 %newobject CreateFromNative;
586 static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
589 %newobject CreatePath;
591 virtual wxGraphicsPath * , CreatePath(),
592 "creates a path instance that corresponds to the type of graphics context, ie GDIPlus, Cairo, CoreGraphics ...", "");
596 virtual wxGraphicsPen , CreatePen(const wxPen& pen),
601 virtual wxGraphicsBrush , CreateBrush(const wxBrush& brush ),
606 virtual wxGraphicsBrush ,
607 CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
608 const wxColour& c1, const wxColour& c2),
609 "sets the brush to a linear gradient, starting at (x1,y1) with color c1
610 to (x2,y2) with color c2", "");
614 virtual wxGraphicsBrush ,
615 CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
616 const wxColour &oColor, const wxColour &cColor),
617 "sets the brush to a radial gradient originating at (xo,yc) with color
618 oColor and ends on a circle around (xc,yc) with radius r and color
624 virtual wxGraphicsFont , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ),
625 "sets the font", "");
628 %newobject CreateMatrix;
630 virtual wxGraphicsMatrix* , CreateMatrix( wxDouble a=1.0, wxDouble b=0.0,
631 wxDouble c=0.0, wxDouble d=1.0,
632 wxDouble tx=0.0, wxDouble ty=0.0),
633 "create a 'native' matrix corresponding to these values", "");
638 virtual void , PushState(),
639 "push the current state of the context, ie the transformation matrix on a stack", "");
643 virtual void , PopState(),
644 "pops a stored state from the stack", "");
648 virtual void , Clip( const wxRegion ®ion ),
649 "clips drawings to the region", "",
654 virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
655 "clips drawings to the rect", "");
659 virtual void , ResetClip(),
660 "resets the clipping to original extent", "");
664 virtual void * , GetNativeContext(),
665 "returns the native context", "");
669 virtual void , Translate( wxDouble dx , wxDouble dy ),
670 "translate the current transformation matrix CTM of the context", "");
674 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
675 "scale the current transformation matrix CTM of the context", "");
679 virtual void , Rotate( wxDouble angle ),
680 "rotate (radians) the current transformation matrix CTM of the context", "");
684 DocStr(SetPen, "sets the stroke pen", "");
686 virtual void SetPen( const wxGraphicsPen& pen );
687 void SetPen( const wxPen& pen );
690 DocStr(SetBrush, "sets the brush for filling", "");
692 virtual void SetBrush( const wxGraphicsBrush& brush );
693 void SetBrush( const wxBrush& brush );
696 DocStr(SetFont, "sets the font", "");
698 virtual void SetFont( const wxGraphicsFont& font );
699 void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK);
704 virtual void , StrokePath( const wxGraphicsPath *path ),
705 "strokes along a path with the current pen", "");
709 virtual void , FillPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
710 "fills a path with the current brush", "");
714 virtual void , DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
715 "draws a path by first filling and then stroking", "");
719 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
724 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
730 virtual void , GetTextExtent( const wxString &text,
731 wxDouble *OUTPUT /*width*/,
732 wxDouble *OUTPUT /*height*/,
733 wxDouble *OUTPUT /*descent*/,
734 wxDouble *OUTPUT /*externalLeading*/ ) const ,
735 "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)",
740 DocAStr(GetTextExtent,
741 "GetTextExtent(self, text) --> (width, height)",
744 PyObject* GetTextExtent( const wxString &text )
746 wxDouble width = 0.0,
748 self->GetTextExtent(text, &width, &height, NULL, NULL);
749 // thread wrapers are turned off for this .i file, so no need to acquire GIL...
750 PyObject* rv = PyTuple_New(2);
751 PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width));
752 PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height));
759 DocAStr(GetPartialTextExtents,
760 "GetPartialTextExtents(self, text) -> [widths]",
762 wxArrayDouble GetPartialTextExtents(const wxString& text) {
763 wxArrayDouble widths;
764 self->GetPartialTextExtents(text, widths);
771 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
776 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
782 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
783 "strokes a single line", "");
787 virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
788 "StrokeLines(self, List points)",
789 "stroke lines connecting each of the points", "");
793 DocStr(StrokeLineSegements,
794 "stroke disconnected lines from begin to end points", "");
795 void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
797 size_t c1, c2, count;
798 wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
799 wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
801 if ( beginP != NULL && endP != NULL )
803 count = wxMin(c1, c2);
804 self->StrokeLines(count, beginP, endP);
813 virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ),
814 "draws a polygon", "");
818 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
819 "draws a rectangle", "");
823 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
824 "draws an ellipse", "");
828 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
829 "draws a rounded rectangle", "");
834 virtual bool , ShouldOffset() const,
835 "helper to determine if a 0.5 offset should be applied for the drawing operation", "");
840 //---------------------------------------------------------------------------
842 class wxGraphicsRenderer : public wxObject
845 // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer
847 virtual ~wxGraphicsRenderer();
849 // %newobject GetDefaultRenderer; ???
850 static wxGraphicsRenderer* GetDefaultRenderer();
852 %nokwargs CreateContext;
853 %newobject CreateContext;
854 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ;
855 virtual wxGraphicsContext * CreateContext( wxWindow* window );
857 %newobject CreateContextFromNativeContext;
858 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
860 %newobject CreateContextFromNativeWindow;
861 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
864 %newobject CreatePath;
865 virtual wxGraphicsPath * CreatePath();
867 %newobject CreateMatrix;
868 virtual wxGraphicsMatrix * CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
869 wxDouble tx=0.0, wxDouble ty=0.0);
871 virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
873 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
875 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
876 const wxColour&c1, const wxColour&c2);
878 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
879 const wxColour &oColor, const wxColour &cColor);
881 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK );
887 //---------------------------------------------------------------------------
890 #include "wx/dcgraph.h"
893 class wxGCDC: public wxDC
897 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
898 wxGCDC(const wxWindowDC& dc);
902 wxGraphicsContext* GetGraphicsContext();
903 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
905 %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
909 //---------------------------------------------------------------------------
911 // Turn GIL acquisition back on.