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
27 //---------------------------------------------------------------------------
31 #if !wxUSE_GRAPHICS_CONTEXT
32 // C++ stub classes for platforms or build configurations that don't have
33 // wxGraphicsContext yet.
35 class wxGraphicsObject : public wxObject
38 wxGraphicsObject( wxGraphicsRenderer* ) {
39 PyErr_SetString(PyExc_NotImplementedError,
40 "wx.GraphicsObject is not available on this platform.");
42 wxGraphicsObject( const wxGraphicsObject& ) {}
43 virtual ~wxGraphicsObject() {}
44 wxGraphicsRenderer* GetRenderer() const { return NULL; }
47 class wxGraphicsPen : public wxGraphicsObject
49 //wxGraphicsPen(wxGraphicsRenderer* ) {}
50 virtual ~wxGraphicsPen() {}
51 virtual void Apply( wxGraphicsContext* ) {}
52 virtual wxDouble GetWidth() { return 0; }
55 class wxGraphicsBrush : public wxGraphicsObject
58 //wxGraphicsBrush(wxGraphicsRenderer* renderer) {}
59 virtual ~wxGraphicsBrush() {}
60 virtual void Apply( wxGraphicsContext* ) {}
63 class wxGraphicsFont : public wxGraphicsObject
66 //wxGraphicsFont(wxGraphicsRenderer* renderer) {}
67 virtual ~wxGraphicsFont() {}
68 virtual void Apply( wxGraphicsContext* ) {}
71 class wxGraphicsPath : public wxGraphicsObject
74 wxGraphicsPath(wxGraphicsRenderer* ) {
75 PyErr_SetString(PyExc_NotImplementedError,
76 "wx.GraphicsPath is not available on this platform.");
78 virtual ~wxGraphicsPath() {}
80 virtual wxGraphicsPath *Clone() const { return NULL; }
82 void MoveToPoint( wxDouble, wxDouble ) {}
83 void MoveToPoint( const wxPoint2DDouble& ) {}
84 void AddLineToPoint( wxDouble, wxDouble ) {}
85 void AddLineToPoint( const wxPoint2DDouble& ) {}
86 void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {}
87 void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {}
88 void AddPath( const wxGraphicsPath* ) {}
89 void CloseSubpath() {}
90 void GetCurrentPoint( wxDouble&, wxDouble&) {}
91 wxPoint2DDouble GetCurrentPoint() { reutrn wxPoint2D(0,0); }
92 void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {}
93 void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {}
95 void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {}
96 void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {}
97 void AddCircle( wxDouble, wxDouble, wxDouble ) {}
98 void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {}
100 void AddEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {}
101 void AddRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {}
102 void * GetNativePath() const { return NULL; }
103 void UnGetNativePath(void *) {}
104 void Transform( wxGraphicsMatrix* ) {}
105 void GetBox(wxDouble *, wxDouble *, wxDouble *, wxDouble *) {}
106 wxRect2D GetBox() { return wxRect2D(0,0,0,0); }
108 bool Contains( wxDouble , wxDouble , int ) { return false; }
109 bool Contains( const wxPoint2DDouble& , int ) { return false; }
113 class wxGraphicsMatrix : public wxGraphicsObject
116 wxGraphicsMatrix(wxGraphicsRenderer* ) {
117 PyErr_SetString(PyExc_NotImplementedError,
118 "wx.GraphicsMatrix is not available on this platform.");
120 virtual ~wxGraphicsMatrix() {}
121 virtual wxGraphicsMatrix *Clone() const { return NULL; }
122 virtual void Concat( const wxGraphicsMatrix * ) {}
123 virtual void Copy( const wxGraphicsMatrix * ) {}
124 virtual void Set(wxDouble , wxDouble , wxDouble , wxDouble ,
125 wxDouble , wxDouble ) {}
126 virtual void Invert() {}
127 virtual bool IsEqual( const wxGraphicsMatrix* t) const {}
128 virtual bool IsIdentity() { return false; }
129 virtual void Translate( wxDouble , wxDouble ) {}
130 virtual void Scale( wxDouble , wxDouble ) {}
131 virtual void Rotate( wxDouble ) {}
132 virtual void TransformPoint( wxDouble *, wxDouble * ) {}
133 virtual void TransformDistance( wxDouble *, wxDouble * ) {}
134 virtual void * GetNativeMatrix() const { return NULL; }
139 class wxGraphicsContext : public wxGraphicsObject
143 wxGraphicsContext(wxGraphicsRenderer* ) {
144 PyErr_SetString(PyExc_NotImplementedError,
145 "wx.GraphicsContext is not available on this platform.");
148 virtual ~wxGraphicsContext() {}
150 static wxGraphicsContext* Create( const wxWindowDC& ) {
151 PyErr_SetString(PyExc_NotImplementedError,
152 "wx.GraphicsContext is not available on this platform.");
155 static wxGraphicsContext* CreateFromNative( void * ) {
156 PyErr_SetString(PyExc_NotImplementedError,
157 "wx.GraphicsContext is not available on this platform.");
160 static wxGraphicsContext* CreateFromNativeWindow( void * ) {
161 PyErr_SetString(PyExc_NotImplementedError,
162 "wx.GraphicsContext is not available on this platform.");
165 static wxGraphicsContext* Create( wxWindow* ) {
166 PyErr_SetString(PyExc_NotImplementedError,
167 "wx.GraphicsContext is not available on this platform.");
170 wxGraphicsPath * CreatePath() { return NULL; }
172 virtual wxGraphicsPen* CreatePen(const wxPen& ) { return NULL; }
174 virtual wxGraphicsBrush* CreateBrush(const wxBrush& ) { return NULL; }
176 virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble ,
177 const wxColour&, const wxColour&) { return NULL; }
179 virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
180 wxDouble xc, wxDouble yc, wxDouble radius,
181 const wxColour &oColor, const wxColour &cColor) { return NULL; }
183 virtual wxGraphicsFont* CreateFont( const wxFont &, const wxColour & ) { return NULL; }
185 virtual wxGraphicsMatrix* CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble,
186 wxDouble, wxDouble) { return NULL; }
188 virtual void PushState() {}
189 virtual void PopState() {}
190 virtual void Clip( const wxRegion & ) {}
191 virtual void Clip( wxDouble , wxDouble , wxDouble , wxDouble ) {}
192 virtual void ResetClip() {}
193 virtual void * GetNativeContext() { return NULL; }
194 virtual void Translate( wxDouble , wxDouble ) {}
195 virtual void Scale( wxDouble , wxDouble ) {}
196 virtual void Rotate( wxDouble ) {}
197 virtual void ConcatTransform( const wxGraphicsMatrix* ) {}
198 virtual void SetTransform( const wxGraphicsMatrix* ) {}
199 virtual void GetTransform( wxGraphicsMatrix* ) {}
201 virtual void SetPen( wxGraphicsPen* , bool ) {}
202 void SetPen( const wxPen& ) {}
204 virtual void SetBrush( wxGraphicsBrush* , bool ) {}
205 void SetBrush( const wxBrush& ) {}
207 virtual void SetFont( wxGraphicsFont*, bool ) {}
208 void SetFont( const wxFont&, const wxColour& ) {}
210 virtual void StrokePath( const wxGraphicsPath * ) {}
211 virtual void FillPath( const wxGraphicsPath *, int ) {}
212 virtual void DrawPath( const wxGraphicsPath *, int ) {}
214 virtual void DrawText( const wxString &, wxDouble , wxDouble ) {}
215 virtual void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {}
216 virtual void GetTextExtent( const wxString &, wxDouble *, wxDouble *,
217 wxDouble *, wxDouble * ) const {}
218 virtual void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {}
220 virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
221 virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
223 virtual void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {}
224 virtual void StrokeLines( size_t , const wxPoint2DDouble *) {}
225 virtual void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {}
226 virtual void DrawLines( size_t , const wxPoint2DDouble *, int ) {}
227 virtual void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {}
228 virtual void DrawEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {}
229 virtual void DrawRoundedRectangle( wxDouble wxDouble , wxDouble , wxDouble , wxDouble ) {}
230 virtual bool ShouldOffset() const { return false; }
234 class wxGraphicsRenderer : public wxObject
237 wxGraphicsRenderer() {
238 PyErr_SetString(PyExc_NotImplementedError,
239 "wx.GraphicsRenderer is not available on this platform.");
242 virtual ~wxGraphicsRenderer() {}
244 static wxGraphicsRenderer* GetDefaultRenderer(
245 PyErr_SetString(PyExc_NotImplementedError,
246 "wx.GraphicsRenderer is not available on this platform.");
249 virtual wxGraphicsContext * CreateContext( const wxWindowDC& ) { return NULL; }
250 virtual wxGraphicsContext * CreateContextFromNativeContext( void * ) { return NULL; }
251 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * ) { return NULL; }
252 virtual wxGraphicsContext * CreateContext( wxWindow* ) { return NULL; }
254 virtual wxGraphicsPath * CreatePath() { return NULL; }
256 virtual wxGraphicsMatrix * CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble ,
257 wxDouble , wxDouble ) {}
259 virtual wxGraphicsPen* CreatePen(const wxPen& ) { return NULL; }
260 virtual wxGraphicsBrush* CreateBrush(const wxBrush& ) { return NULL; }
261 virtual wxGraphicsBrush* CreateLinearGradientBrush(
262 wxDouble , wxDouble , wxDouble , wxDouble ,
263 const wxColour&, const wxColour&) { return NULL; }
264 virtual wxGraphicsBrush* CreateRadialGradientBrush(
265 wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ,
266 const wxColour &, const wxColour &) { return NULL; }
267 virtual wxGraphicsFont* CreateFont( const wxFont & , const wxColour & ) { return NULL; }
272 class wxGCDC: public wxWindowDC
275 wxGCDC(const wxWindowDC&) {
276 wxPyBlock_t blocked = wxPyBeginBlockThreads();
277 PyErr_SetString(PyExc_NotImplementedError,
278 "wxGCDC is not available on this platform.");
279 wxPyEndBlockThreads(blocked);
283 wxPyBlock_t blocked = wxPyBeginBlockThreads();
284 PyErr_SetString(PyExc_NotImplementedError,
285 "wxGCDC is not available on this platform.");
286 wxPyEndBlockThreads(blocked);
291 wxGraphicsContext* GetGraphicsContext() { return NULL; }
292 void SetGraphicsContext( wxGraphicsContext* ) {}
298 //---------------------------------------------------------------------------
299 //---------------------------------------------------------------------------
302 %typemap(in) (size_t points, wxPoint2D* points_array ) {
303 $2 = wxPoint2D_LIST_helper($input, &$1);
304 if ($2 == NULL) SWIG_fail;
306 %typemap(freearg) (size_t points, wxPoint2D* points_array ) {
307 if ($2) delete [] $2;
312 MustHaveApp(wxGraphicsPath);
313 MustHaveApp(wxGraphicsContext);
316 typedef double wxDouble;
320 class wxGraphicsObject : public wxObject
323 wxGraphicsObject( wxGraphicsRenderer* renderer = NULL );
324 virtual ~wxGraphicsObject();
325 wxGraphicsRenderer* GetRenderer() const;
329 class wxGraphicsPen : public wxGraphicsObject
332 //wxGraphicsPen(wxGraphicsRenderer* renderer);
333 virtual ~wxGraphicsPen();
334 virtual void Apply( wxGraphicsContext* context);
335 virtual wxDouble GetWidth();
339 class wxGraphicsBrush : public wxGraphicsObject
342 //wxGraphicsBrush(wxGraphicsRenderer* renderer);
343 virtual ~wxGraphicsBrush();
344 virtual void Apply( wxGraphicsContext* context);
348 class wxGraphicsFont : public wxGraphicsObject
351 //wxGraphicsFont(wxGraphicsRenderer* renderer);
352 virtual ~wxGraphicsFont();
353 virtual void Apply( wxGraphicsContext* context);
356 //---------------------------------------------------------------------------
358 class wxGraphicsPath : public wxGraphicsObject
361 //wxGraphicsPath(wxGraphicsRenderer* renderer); *** This class is an ABC, so we can't allow instances to be created directly
362 virtual ~wxGraphicsPath();
364 virtual wxGraphicsPath *Clone() const = 0;
367 virtual void , MoveToPoint( wxDouble x, wxDouble y ),
368 "Begins a new subpath at (x,y)", "");
369 // void MoveToPoint( const wxPoint2D& p);
373 virtual void , AddLineToPoint( wxDouble x, wxDouble y ),
374 "Adds a straight line from the current point to (x,y) ", "");
375 // void AddLineToPoint( const wxPoint2D& p);
379 virtual void , AddCurveToPoint( wxDouble cx1, wxDouble cy1,
380 wxDouble cx2, wxDouble cy2,
381 wxDouble x, wxDouble y ),
382 "Adds a cubic Bezier curve from the current point, using two control
383 points and an end point", "");
384 // void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e);
389 virtual void , AddPath( const wxGraphicsPath* path ),
390 "adds another path", "");
394 virtual void , CloseSubpath(),
395 "closes the current sub-path", "");
398 //virtual void , GetCurrentPoint( wxDouble& x, wxDouble&y),
400 wxPoint2D , GetCurrentPoint(),
401 "Gets the last point of the current path, (0,0) if not yet set", "");
405 virtual void , AddArc( wxDouble x, wxDouble y, wxDouble r,
406 wxDouble startAngle, wxDouble endAngle, bool clockwise ),
407 "Adds an arc of a circle centering at (x,y) with radius (r) from
408 startAngle to endAngle", "");
409 // void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
413 virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ),
414 "Adds a quadratic Bezier curve from the current point, using a control
415 point and an end point", "");
419 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
420 "Appends a rectangle as a new closed subpath", "");
424 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
425 "Appends a circle as a new closed subpath with the given radius.", "");
429 virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ,
430 "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1)
431 to (x2,y2), also a straight line from (current) to (x1,y1)", "");
435 virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
436 "appends an ellipse", "");
440 virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
441 "appends a rounded rectangle", "");
445 virtual void * , GetNativePath() const,
446 "returns the native path", "");
450 virtual void , UnGetNativePath(void *p),
451 "give the native path returned by GetNativePath() back (there might be some
452 deallocations necessary)", "");
456 virtual void , Transform( wxGraphicsMatrix* matrix ),
457 "transforms each point of this path by the matrix", "");
460 //virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) =0;
462 wxRect2DDouble , GetBox(),
463 "gets the bounding box enclosing all points (possibly including control points)", "");
467 virtual bool , Contains( wxDouble x, wxDouble y, int fillStyle = wxWINDING_RULE),
469 //bool Contains( const wxPoint2DDouble& c, int fillStyle = wxWINDING_RULE);
473 //---------------------------------------------------------------------------
475 class wxGraphicsMatrix : public wxGraphicsObject
478 // wxGraphicsMatrix(wxGraphicsRenderer* renderer); *** This class is an ABC
480 virtual ~wxGraphicsMatrix();
482 virtual wxGraphicsMatrix *Clone() const;
485 virtual void , Concat( const wxGraphicsMatrix *t ),
486 "concatenates the matrix", "");
490 virtual void , Copy( const wxGraphicsMatrix *t ),
491 "copies the passed in matrix", "");
495 virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
496 wxDouble tx=0.0, wxDouble ty=0.0),
497 "sets the matrix to the respective values", "");
501 virtual void , Invert(),
502 "makes this the inverse matrix", "");
506 virtual bool , IsEqual( const wxGraphicsMatrix* t) const,
507 "returns true if the elements of the transformation matrix are equal", "");
511 virtual bool , IsIdentity(),
512 "return true if this is the identity matrix", "");
516 virtual void , Translate( wxDouble dx , wxDouble dy ),
517 "add the translation to this matrix", "");
521 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
522 "add the scale to this matrix", "");
526 virtual void , Rotate( wxDouble angle ),
527 "add the rotation to this matrix (radians)", "");
531 virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ),
532 "TransformPoint(self, x, y) --> (x, y)",
533 "applies that matrix to the point", "");
537 virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ),
538 "TransformDistance(self, dx, dy) --> (dx, dy)",
539 "applies the matrix except for translations", "");
543 virtual void * , GetNativeMatrix() const,
544 "returns the native representation", "");
547 //---------------------------------------------------------------------------
550 class wxGraphicsContext : public wxGraphicsObject
553 // wxGraphicsContext() This is also an ABC, use Create to make an instance...
554 virtual ~wxGraphicsContext();
559 "val.__dc = args[0] # save a ref so the dc will not be deleted before self";
560 static wxGraphicsContext* Create( const wxWindowDC& dc);
562 static wxGraphicsContext* Create( wxWindow* window ) ;
564 %newobject CreateFromNative;
565 static wxGraphicsContext* CreateFromNative( void * context ) ;
567 %newobject CreateFromNative;
568 static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
571 %newobject CreatePath;
573 virtual wxGraphicsPath * , CreatePath(),
574 "creates a path instance that corresponds to the type of graphics context, ie GDIPlus, Cairo, CoreGraphics ...", "");
577 %newobject CreatePen;
579 virtual wxGraphicsPen* , CreatePen(const wxPen& pen),
583 %newobject CreateBrush;
585 virtual wxGraphicsBrush* , CreateBrush(const wxBrush& brush ),
589 %newobject CreateLinearGradientBrush;
591 virtual wxGraphicsBrush* ,
592 CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
593 const wxColour& c1, const wxColour& c2),
594 "sets the brush to a linear gradient, starting at (x1,y1) with color c1
595 to (x2,y2) with color c2", "");
598 %newobject CreateRadialGradientBrush;
600 virtual wxGraphicsBrush* ,
601 CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
602 const wxColour &oColor, const wxColour &cColor),
603 "sets the brush to a radial gradient originating at (xo,yc) with color
604 oColor and ends on a circle around (xc,yc) with radius r and color
609 %newobject CreateFont;
611 virtual wxGraphicsFont* , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ),
612 "sets the font", "");
615 %newobject CreateMatrix;
617 virtual wxGraphicsMatrix* , CreateMatrix( wxDouble a=1.0, wxDouble b=0.0,
618 wxDouble c=0.0, wxDouble d=1.0,
619 wxDouble tx=0.0, wxDouble ty=0.0),
620 "create a 'native' matrix corresponding to these values", "");
625 virtual void , PushState(),
626 "push the current state of the context, ie the transformation matrix on a stack", "");
630 virtual void , PopState(),
631 "pops a stored state from the stack", "");
635 virtual void , Clip( const wxRegion ®ion ),
636 "clips drawings to the region", "",
641 virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
642 "clips drawings to the rect", "");
646 virtual void , ResetClip(),
647 "resets the clipping to original extent", "");
651 virtual void * , GetNativeContext(),
652 "returns the native context", "");
656 virtual void , Translate( wxDouble dx , wxDouble dy ),
657 "translate the current transformation matrix CTM of the context", "");
661 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
662 "scale the current transformation matrix CTM of the context", "");
666 virtual void , Rotate( wxDouble angle ),
667 "rotate (radians) the current transformation matrix CTM of the context", "");
671 DocStr(SetPen, "sets the stroke pen", "");
673 virtual void SetPen( wxGraphicsPen* pen , bool release = true );
674 void SetPen( const wxPen& pen );
677 DocStr(SetBrush, "sets the brush for filling", "");
679 virtual void SetBrush( wxGraphicsBrush* brush , bool release = true );
680 void SetBrush( const wxBrush& brush );
683 DocStr(SetFont, "sets the font", "");
685 virtual void SetFont( wxGraphicsFont* font, bool release = true );
686 void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK);
691 virtual void , StrokePath( const wxGraphicsPath *path ),
692 "strokes along a path with the current pen", "");
696 virtual void , FillPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
697 "fills a path with the current brush", "");
701 virtual void , DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
702 "draws a path by first filling and then stroking", "");
706 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
711 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
717 virtual void , GetTextExtent( const wxString &text,
718 wxDouble *OUTPUT /*width*/,
719 wxDouble *OUTPUT /*height*/,
720 wxDouble *OUTPUT /*descent*/,
721 wxDouble *OUTPUT /*externalLeading*/ ) const ,
722 "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)",
727 DocAStr(GetTextExtent,
728 "GetTextExtent(self, text) --> (width, height)",
731 PyObject* GetTextExtent( const wxString &text )
733 wxDouble width = 0.0,
735 self->GetTextExtent(text, &width, &height, NULL, NULL);
736 // thread wrapers are turned off for this .i file, so no need to acquire GIL...
737 PyObject* rv = PyTuple_New(2);
738 PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width));
739 PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height));
746 DocAStr(GetPartialTextExtents,
747 "GetPartialTextExtents(self, text) -> [widths]",
749 wxArrayDouble GetPartialTextExtents(const wxString& text) {
750 wxArrayDouble widths;
751 self->GetPartialTextExtents(text, widths);
758 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
763 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
769 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
770 "strokes a single line", "");
774 virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
775 "StrokeLines(self, List points)",
776 "stroke lines connecting each of the points", "");
780 DocStr(StrokeLineSegements,
781 "stroke disconnected lines from begin to end points", "");
782 void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
784 size_t c1, c2, count;
785 wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
786 wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
788 if ( beginP != NULL && endP != NULL )
790 count = wxMin(c1, c2);
791 self->StrokeLines(count, beginP, endP);
800 virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ),
801 "draws a polygon", "");
805 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
806 "draws a rectangle", "");
810 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
811 "draws an ellipse", "");
815 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
816 "draws a rounded rectangle", "");
821 virtual bool , ShouldOffset() const,
822 "helper to determine if a 0.5 offset should be applied for the drawing operation", "");
827 //---------------------------------------------------------------------------
829 class wxGraphicsRenderer : public wxObject
832 // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer
834 virtual ~wxGraphicsRenderer();
836 // %newobject GetDefaultRenderer; ???
837 static wxGraphicsRenderer* GetDefaultRenderer();
839 %nokwargs CreateContext;
840 %newobject CreateContext;
841 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ;
842 virtual wxGraphicsContext * CreateContext( wxWindow* window );
844 %newobject CreateContextFromNativeContext;
845 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
847 %newobject CreateContextFromNativeWindow;
848 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
851 %newobject CreatePath;
852 virtual wxGraphicsPath * CreatePath();
854 %newobject CreateMatrix;
855 virtual wxGraphicsMatrix * CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
856 wxDouble tx=0.0, wxDouble ty=0.0);
858 %newobject CreatePen;
859 virtual wxGraphicsPen* CreatePen(const wxPen& pen) ;
861 %newobject CreateBrush;
862 virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ) ;
864 %newobject CreateLinearGradientBrush;
865 virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
866 const wxColour&c1, const wxColour&c2);
868 %newobject CreateRadialGradientBrush;
869 virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
870 const wxColour &oColor, const wxColour &cColor);
872 %newobject CreateFont;
873 virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK );
879 //---------------------------------------------------------------------------
882 #include "wx/dcgraph.h"
885 class wxGCDC: public wxDC
889 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
890 wxGCDC(const wxWindowDC& dc);
894 wxGraphicsContext* GetGraphicsContext();
895 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
897 %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
901 //---------------------------------------------------------------------------
903 // Turn GIL acquisition back on.