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 void MoveToPoint( wxDouble, wxDouble ) {}
91 void MoveToPoint( const wxPoint2DDouble& ) {}
92 void AddLineToPoint( wxDouble, wxDouble ) {}
93 void AddLineToPoint( const wxPoint2DDouble& ) {}
94 void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {}
95 void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {}
96 void AddPath( const wxGraphicsPath* ) {}
97 void CloseSubpath() {}
98 void GetCurrentPoint( wxDouble&, wxDouble&) {}
99 wxPoint2DDouble GetCurrentPoint() { reutrn wxPoint2D(0,0); }
100 void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {}
101 void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {}
103 void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {}
104 void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {}
105 void AddCircle( wxDouble, wxDouble, wxDouble ) {}
106 void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {}
108 void AddEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {}
109 void AddRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {}
110 void * GetNativePath() const { return NULL; }
111 void UnGetNativePath(void *) {}
112 void Transform( wxGraphicsMatrix* ) {}
113 void GetBox(wxDouble *, wxDouble *, wxDouble *, wxDouble *) {}
114 wxRect2D GetBox() { return wxRect2D(0,0,0,0); }
116 bool Contains( wxDouble , wxDouble , int ) { return false; }
117 bool Contains( const wxPoint2DDouble& , int ) { return false; }
119 wxGraphicsPath wxNullGraphicsPath;
122 class wxGraphicsMatrix : public wxGraphicsObject
125 wxGraphicsMatrix(wxGraphicsRenderer* ) {
126 PyErr_SetString(PyExc_NotImplementedError,
127 "wx.GraphicsMatrix is not available on this platform.");
129 virtual ~wxGraphicsMatrix() {}
130 virtual void Concat( const wxGraphicsMatrix * ) {}
131 virtual void Copy( const wxGraphicsMatrix * ) {}
132 virtual void Set(wxDouble , wxDouble , wxDouble , wxDouble ,
133 wxDouble , wxDouble ) {}
134 virtual void Invert() {}
135 virtual bool IsEqual( const wxGraphicsMatrix* t) const {}
136 virtual bool IsIdentity() { return false; }
137 virtual void Translate( wxDouble , wxDouble ) {}
138 virtual void Scale( wxDouble , wxDouble ) {}
139 virtual void Rotate( wxDouble ) {}
140 virtual void TransformPoint( wxDouble *, wxDouble * ) {}
141 virtual void TransformDistance( wxDouble *, wxDouble * ) {}
142 virtual void * GetNativeMatrix() const { return NULL; }
144 wxGraphicsMatrix wxNullGraphicsMatrix;
147 class wxGraphicsContext : public wxGraphicsObject
151 wxGraphicsContext(wxGraphicsRenderer* ) {
152 PyErr_SetString(PyExc_NotImplementedError,
153 "wx.GraphicsContext is not available on this platform.");
156 virtual ~wxGraphicsContext() {}
158 static wxGraphicsContext* Create( const wxWindowDC& ) {
159 PyErr_SetString(PyExc_NotImplementedError,
160 "wx.GraphicsContext is not available on this platform.");
163 static wxGraphicsContext* CreateFromNative( void * ) {
164 PyErr_SetString(PyExc_NotImplementedError,
165 "wx.GraphicsContext is not available on this platform.");
168 static wxGraphicsContext* CreateFromNativeWindow( void * ) {
169 PyErr_SetString(PyExc_NotImplementedError,
170 "wx.GraphicsContext is not available on this platform.");
173 static wxGraphicsContext* Create( wxWindow* ) {
174 PyErr_SetString(PyExc_NotImplementedError,
175 "wx.GraphicsContext is not available on this platform.");
178 wxGraphicsPath * CreatePath() { return NULL; }
180 virtual wxGraphicsPen CreatePen(const wxPen& ) { return NULL; }
182 virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return NULL; }
184 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble ,
185 const wxColour&, const wxColour&) { return NULL; }
187 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
188 wxDouble xc, wxDouble yc, wxDouble radius,
189 const wxColour &oColor, const wxColour &cColor) { return NULL; }
191 virtual wxGraphicsFont CreateFont( const wxFont &, const wxColour & ) { return NULL; }
193 virtual wxGraphicsMatrix* CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble,
194 wxDouble, wxDouble) { return NULL; }
196 virtual void PushState() {}
197 virtual void PopState() {}
198 virtual void Clip( const wxRegion & ) {}
199 virtual void Clip( wxDouble , wxDouble , wxDouble , wxDouble ) {}
200 virtual void ResetClip() {}
201 virtual void * GetNativeContext() { return NULL; }
202 virtual void Translate( wxDouble , wxDouble ) {}
203 virtual void Scale( wxDouble , wxDouble ) {}
204 virtual void Rotate( wxDouble ) {}
205 virtual void ConcatTransform( const wxGraphicsMatrix* ) {}
206 virtual void SetTransform( const wxGraphicsMatrix* ) {}
207 virtual void GetTransform( wxGraphicsMatrix* ) {}
209 virtual void SetPen( const wxGraphicsPen& ) {}
210 void SetPen( const wxPen& ) {}
212 virtual void SetBrush( const wxGraphicsBrush& ) {}
213 void SetBrush( const wxBrush& ) {}
215 virtual void SetFont( const wxGraphicsFont& ) {}
216 void SetFont( const wxFont&, const wxColour& ) {}
218 virtual void StrokePath( const wxGraphicsPath * ) {}
219 virtual void FillPath( const wxGraphicsPath *, int ) {}
220 virtual void DrawPath( const wxGraphicsPath *, int ) {}
222 virtual void DrawText( const wxString &, wxDouble , wxDouble ) {}
223 virtual void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {}
224 virtual void GetTextExtent( const wxString &, wxDouble *, wxDouble *,
225 wxDouble *, wxDouble * ) const {}
226 virtual void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {}
228 virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
229 virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
231 virtual void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {}
232 virtual void StrokeLines( size_t , const wxPoint2DDouble *) {}
233 virtual void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {}
234 virtual void DrawLines( size_t , const wxPoint2DDouble *, int ) {}
235 virtual void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {}
236 virtual void DrawEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {}
237 virtual void DrawRoundedRectangle( wxDouble wxDouble , wxDouble , wxDouble , wxDouble ) {}
238 virtual bool ShouldOffset() const { return false; }
242 class wxGraphicsRenderer : public wxObject
245 wxGraphicsRenderer() {
246 PyErr_SetString(PyExc_NotImplementedError,
247 "wx.GraphicsRenderer is not available on this platform.");
250 virtual ~wxGraphicsRenderer() {}
252 static wxGraphicsRenderer* GetDefaultRenderer(
253 PyErr_SetString(PyExc_NotImplementedError,
254 "wx.GraphicsRenderer is not available on this platform.");
257 virtual wxGraphicsContext * CreateContext( const wxWindowDC& ) { return NULL; }
258 virtual wxGraphicsContext * CreateContextFromNativeContext( void * ) { return NULL; }
259 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * ) { return NULL; }
260 virtual wxGraphicsContext * CreateContext( wxWindow* ) { return NULL; }
262 virtual wxGraphicsPath * CreatePath() { return NULL; }
264 virtual wxGraphicsMatrix * CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble ,
265 wxDouble , wxDouble ) { return NULL; }
267 virtual wxGraphicsPen CreatePen(const wxPen& ) { return wxNullGaphicsPen; }
268 virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return wxNullGaphicsBrush; }
269 virtual wxGraphicsBrush CreateLinearGradientBrush(xDouble , wxDouble , wxDouble , wxDouble ,
270 const wxColour&, const wxColour&) { return wxNullGaphicsBrush; }
271 virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ,
272 const wxColour &, const wxColour &) { return wxNullGaphicsBrush; }
273 virtual wxGraphicsFont CreateFont( const wxFont & , const wxColour & ) { return wxNullGaphicsFont; }
278 class wxGCDC: public wxWindowDC
281 wxGCDC(const wxWindowDC&) {
282 wxPyBlock_t blocked = wxPyBeginBlockThreads();
283 PyErr_SetString(PyExc_NotImplementedError,
284 "wxGCDC is not available on this platform.");
285 wxPyEndBlockThreads(blocked);
289 wxPyBlock_t blocked = wxPyBeginBlockThreads();
290 PyErr_SetString(PyExc_NotImplementedError,
291 "wxGCDC is not available on this platform.");
292 wxPyEndBlockThreads(blocked);
297 wxGraphicsContext* GetGraphicsContext() { return NULL; }
298 void SetGraphicsContext( wxGraphicsContext* ) {}
304 //---------------------------------------------------------------------------
305 //---------------------------------------------------------------------------
308 %typemap(in) (size_t points, wxPoint2D* points_array ) {
309 $2 = wxPoint2D_LIST_helper($input, &$1);
310 if ($2 == NULL) SWIG_fail;
312 %typemap(freearg) (size_t points, wxPoint2D* points_array ) {
313 if ($2) delete [] $2;
318 MustHaveApp(wxGraphicsPath);
319 MustHaveApp(wxGraphicsContext);
322 typedef double wxDouble;
325 //---------------------------------------------------------------------------
328 class wxGraphicsObject : public wxObject
331 wxGraphicsObject( wxGraphicsRenderer* renderer = NULL );
332 virtual ~wxGraphicsObject();
333 bool IsNull() const ;
334 wxGraphicsRenderer* GetRenderer() const;
338 class wxGraphicsPen : public wxGraphicsObject
342 virtual ~wxGraphicsPen();
346 class wxGraphicsBrush : public wxGraphicsObject
350 virtual ~wxGraphicsBrush();
354 class wxGraphicsFont : public wxGraphicsObject
358 virtual ~wxGraphicsFont();
362 //---------------------------------------------------------------------------
364 class wxGraphicsMatrix : public wxGraphicsObject
368 virtual ~wxGraphicsMatrix();
371 virtual void , Concat( const wxGraphicsMatrix& t ),
372 "concatenates the matrix", "");
376 "Copy the passed in matrix to this one.", "");
377 void Copy( const wxGraphicsMatrix& t ) {
384 virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
385 wxDouble tx=0.0, wxDouble ty=0.0),
386 "sets the matrix to the respective values", "");
390 virtual void , Invert(),
391 "makes this the inverse matrix", "");
395 virtual bool , IsEqual( const wxGraphicsMatrix& t) const,
396 "returns true if the elements of the transformation matrix are equal", "");
400 virtual bool , IsIdentity() const,
401 "return true if this is the identity matrix", "");
405 virtual void , Translate( wxDouble dx , wxDouble dy ),
406 "add the translation to this matrix", "");
410 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
411 "add the scale to this matrix", "");
415 virtual void , Rotate( wxDouble angle ),
416 "add the rotation to this matrix (radians)", "");
420 virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ) const,
421 "TransformPoint(self, x, y) --> (x, y)",
422 "applies that matrix to the point", "");
426 virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ) const,
427 "TransformDistance(self, dx, dy) --> (dx, dy)",
428 "applies the matrix except for translations", "");
432 virtual void * , GetNativeMatrix() const,
433 "returns the native representation", "");
436 //---------------------------------------------------------------------------
438 class wxGraphicsPath : public wxGraphicsObject
442 virtual ~wxGraphicsPath();
445 %nokwargs MoveToPoint;
447 "Begins a new subpath at (x,y)", "");
448 virtual void MoveToPoint( wxDouble x, wxDouble y );
449 void MoveToPoint( const wxPoint2D& p);
452 %nokwargs AddLineToPoint;
453 DocStr(AddLineToPoint,
454 "Adds a straight line from the current point to (x,y) ", "");
455 virtual void AddLineToPoint( wxDouble x, wxDouble y );
456 void AddLineToPoint( const wxPoint2D& p);
459 %nokwargs AddCurveToPoint;
460 DocStr(AddCurveToPoint,
461 "Adds a cubic Bezier curve from the current point, using two control
462 points and an end point", "");
463 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1,
464 wxDouble cx2, wxDouble cy2,
465 wxDouble x, wxDouble y );
466 void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e);
471 virtual void , AddPath( const wxGraphicsPath& path ),
472 "adds another path", "");
476 virtual void , CloseSubpath(),
477 "closes the current sub-path", "");
481 wxPoint2D , GetCurrentPoint() const,
482 "Gets the last point of the current path, (0,0) if not yet set", "");
487 "Adds an arc of a circle centering at (x,y) with radius (r) from
488 startAngle to endAngle", "");
489 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r,
490 wxDouble startAngle, wxDouble endAngle, bool clockwise );
491 void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
495 virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ),
496 "Adds a quadratic Bezier curve from the current point, using a control
497 point and an end point", "");
501 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
502 "Appends a rectangle as a new closed subpath", "");
506 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
507 "Appends a circle as a new closed subpath with the given radius.", "");
511 virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ,
512 "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1)
513 to (x2,y2), also a straight line from (current) to (x1,y1)", "");
517 virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
518 "appends an ellipse", "");
522 virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
523 "appends a rounded rectangle", "");
527 virtual void * , GetNativePath() const,
528 "returns the native path", "");
532 virtual void , UnGetNativePath(void *p) const,
533 "give the native path returned by GetNativePath() back (there might be some
534 deallocations necessary)", "");
538 virtual void , Transform( const wxGraphicsMatrix& matrix ),
539 "transforms each point of this path by the matrix", "");
543 wxRect2DDouble , GetBox() const,
544 "gets the bounding box enclosing all points (possibly including control points)", "");
550 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const;
551 bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE) const;
556 //---------------------------------------------------------------------------
559 const wxGraphicsPen wxNullGraphicsPen;
560 const wxGraphicsBrush wxNullGraphicsBrush;
561 const wxGraphicsFont wxNullGraphicsFont;
562 const wxGraphicsMatrix wxNullGraphicsMatrix;
563 const wxGraphicsPath wxNullGraphicsPath;
566 //---------------------------------------------------------------------------
569 class wxGraphicsContext : public wxGraphicsObject
572 // wxGraphicsContext() This is an ABC, use Create to make an instance...
573 virtual ~wxGraphicsContext();
578 "val.__dc = args[0] # save a ref so the dc will not be deleted before self";
579 static wxGraphicsContext* Create( const wxWindowDC& dc);
581 static wxGraphicsContext* Create( wxWindow* window ) ;
583 %newobject CreateFromNative;
584 static wxGraphicsContext* CreateFromNative( void * context ) ;
586 %newobject CreateFromNative;
587 static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
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", "");
629 virtual wxGraphicsMatrix , CreateMatrix( wxDouble a=1.0, wxDouble b=0.0,
630 wxDouble c=0.0, wxDouble d=1.0,
631 wxDouble tx=0.0, wxDouble ty=0.0),
632 "create a 'native' matrix corresponding to these values", "");
637 virtual void , PushState(),
638 "push the current state of the context, ie the transformation matrix on a stack", "");
642 virtual void , PopState(),
643 "pops a stored state from the stack", "");
647 virtual void , Clip( const wxRegion ®ion ),
648 "clips drawings to the region", "",
653 virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
654 "clips drawings to the rect", "");
658 virtual void , ResetClip(),
659 "resets the clipping to original extent", "");
663 virtual void * , GetNativeContext(),
664 "returns the native context", "");
668 virtual void , Translate( wxDouble dx , wxDouble dy ),
669 "translate the current transformation matrix CTM of the context", "");
673 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
674 "scale the current transformation matrix CTM of the context", "");
678 virtual void , Rotate( wxDouble angle ),
679 "rotate (radians) the current transformation matrix CTM of the context", "");
683 virtual void , ConcatTransform( const wxGraphicsMatrix& matrix ),
684 "concatenates this transform with the current transform of this context", "");
688 virtual void , SetTransform( const wxGraphicsMatrix& matrix ),
689 "sets the transform of this context", "");
693 virtual wxGraphicsMatrix , GetTransform() const,
694 "gets the matrix of this context", "");
699 DocStr(SetPen, "sets the stroke pen", "");
701 virtual void SetPen( const wxGraphicsPen& pen );
702 void SetPen( const wxPen& pen );
705 DocStr(SetBrush, "sets the brush for filling", "");
707 virtual void SetBrush( const wxGraphicsBrush& brush );
708 void SetBrush( const wxBrush& brush );
711 DocStr(SetFont, "sets the font", "");
713 virtual void SetFont( const wxGraphicsFont& font );
714 void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK);
719 virtual void , StrokePath( const wxGraphicsPath& path ),
720 "strokes along a path with the current pen", "");
724 virtual void , FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ),
725 "fills a path with the current brush", "");
729 virtual void , DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ),
730 "draws a path by first filling and then stroking", "");
734 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
739 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
745 virtual void , GetTextExtent( const wxString &text,
746 wxDouble *OUTPUT /*width*/,
747 wxDouble *OUTPUT /*height*/,
748 wxDouble *OUTPUT /*descent*/,
749 wxDouble *OUTPUT /*externalLeading*/ ) const ,
750 "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)",
755 DocAStr(GetTextExtent,
756 "GetTextExtent(self, text) --> (width, height)",
759 PyObject* GetTextExtent( const wxString &text )
761 wxDouble width = 0.0,
763 self->GetTextExtent(text, &width, &height, NULL, NULL);
764 // thread wrapers are turned off for this .i file, so no need to acquire GIL...
765 PyObject* rv = PyTuple_New(2);
766 PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width));
767 PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height));
774 DocAStr(GetPartialTextExtents,
775 "GetPartialTextExtents(self, text) -> [widths]",
777 wxArrayDouble GetPartialTextExtents(const wxString& text) {
778 wxArrayDouble widths;
779 self->GetPartialTextExtents(text, widths);
786 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
791 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
797 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
798 "strokes a single line", "");
802 virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
803 "StrokeLines(self, List points)",
804 "stroke lines connecting each of the points", "");
808 DocStr(StrokeLineSegements,
809 "stroke disconnected lines from begin to end points", "");
810 void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
812 size_t c1, c2, count;
813 wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
814 wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
816 if ( beginP != NULL && endP != NULL )
818 count = wxMin(c1, c2);
819 self->StrokeLines(count, beginP, endP);
828 virtual void , DrawLines( size_t points, const wxPoint2D *points_array,
829 int fillStyle = wxODDEVEN_RULE ),
830 "draws a polygon", "");
834 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
835 "draws a rectangle", "");
839 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
840 "draws an ellipse", "");
844 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
845 "draws a rounded rectangle", "");
850 virtual bool , ShouldOffset() const,
851 "helper to determine if a 0.5 offset should be applied for the drawing operation", "");
856 //---------------------------------------------------------------------------
858 class wxGraphicsRenderer : public wxObject
861 // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer
863 virtual ~wxGraphicsRenderer();
865 // %newobject GetDefaultRenderer; ???
866 static wxGraphicsRenderer* GetDefaultRenderer();
868 %nokwargs CreateContext;
869 %newobject CreateContext;
870 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ;
871 virtual wxGraphicsContext * CreateContext( wxWindow* window );
873 %newobject CreateContextFromNativeContext;
874 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
876 %newobject CreateContextFromNativeWindow;
877 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
880 virtual wxGraphicsPath CreatePath();
882 virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
883 wxDouble tx=0.0, wxDouble ty=0.0);
885 virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
887 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
889 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
890 const wxColour&c1, const wxColour&c2);
892 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
893 const wxColour &oColor, const wxColour &cColor);
895 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK );
901 //---------------------------------------------------------------------------
904 #include "wx/dcgraph.h"
907 class wxGCDC: public wxDC
911 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
912 wxGCDC(const wxWindowDC& dc);
916 wxGraphicsContext* GetGraphicsContext();
917 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
919 %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
923 //---------------------------------------------------------------------------
925 // Turn GIL acquisition back on.