]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_graphics.i
added IMPLEMENT_VARIANT_OBJECT_SHALLOWCMP(classname) macro for consistency
[wxWidgets.git] / wxPython / src / _graphics.i
CommitLineData
6d61d718
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _graphics.i
3// Purpose: Wrapper definitions for wx.GraphicsPath, wx.GraphicsContext
4//
5// Author: Robin Dunn
6//
7// Created: 2-Oct-2006
8// RCS-ID: $Id$
9// Copyright: (c) 2006 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19%{
20#include <wx/graphics.h>
95a76b75 21%}
6d61d718 22
281c54cc
RD
23// Turn off the aquisition of the Global Interpreter Lock for the classes and
24// functions in this file
25%threadWrapperOff
26
6d61d718 27
027aef71
RD
28//---------------------------------------------------------------------------
29//---------------------------------------------------------------------------
6d61d718
RD
30
31%{
32#if !wxUSE_GRAPHICS_CONTEXT
95a76b75
RD
33// C++ stub classes for platforms or build configurations that don't have
34// wxGraphicsContext yet.
6d61d718 35
027aef71 36
cbc3893c
KO
37class wxGraphicsObject : public wxObject
38{
39public :
95a76b75
RD
40 wxGraphicsObject( wxGraphicsRenderer* ) {
41 PyErr_SetString(PyExc_NotImplementedError,
42 "wx.GraphicsObject is not available on this platform.");
43 }
44 wxGraphicsObject( const wxGraphicsObject& ) {}
45 virtual ~wxGraphicsObject() {}
027aef71 46 bool IsNull() const { return false; }
95a76b75 47 wxGraphicsRenderer* GetRenderer() const { return NULL; }
cbc3893c
KO
48} ;
49
027aef71
RD
50
51
cbc3893c
KO
52class wxGraphicsPen : public wxGraphicsObject
53{
027aef71 54 wxGraphicsPen() {}
cbc3893c 55 virtual ~wxGraphicsPen() {}
cbc3893c 56} ;
027aef71
RD
57wxGraphicsPen wxNullGraphicsPen;
58
59
cbc3893c
KO
60
61class wxGraphicsBrush : public wxGraphicsObject
62{
63public :
027aef71 64 wxGraphicsBrush() {}
cbc3893c 65 virtual ~wxGraphicsBrush() {}
cbc3893c 66} ;
027aef71
RD
67wxGraphicsBrush wxNullGraphicsBrush;
68
69
cbc3893c
KO
70
71class wxGraphicsFont : public wxGraphicsObject
72{
73public :
027aef71 74 wxGraphicsFont() {}
cbc3893c 75 virtual ~wxGraphicsFont() {}
cbc3893c 76} ;
027aef71
RD
77wxGraphicsFont wxNullGraphicsFont;
78
79
cbc3893c 80
95a76b75 81class wxGraphicsPath : public wxGraphicsObject
6d61d718
RD
82{
83public :
95a76b75 84 wxGraphicsPath(wxGraphicsRenderer* ) {
6d61d718 85 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 86 "wx.GraphicsPath is not available on this platform.");
6d61d718
RD
87 }
88 virtual ~wxGraphicsPath() {}
95a76b75 89
6d61d718 90 void MoveToPoint( wxDouble, wxDouble ) {}
95a76b75
RD
91 void MoveToPoint( const wxPoint2DDouble& ) {}
92 void AddLineToPoint( wxDouble, wxDouble ) {}
93 void AddLineToPoint( const wxPoint2DDouble& ) {}
6d61d718 94 void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {}
95a76b75
RD
95 void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {}
96 void AddPath( const wxGraphicsPath* ) {}
6d61d718
RD
97 void CloseSubpath() {}
98 void GetCurrentPoint( wxDouble&, wxDouble&) {}
95a76b75 99 wxPoint2DDouble GetCurrentPoint() { reutrn wxPoint2D(0,0); }
6d61d718 100 void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {}
95a76b75 101 void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {}
6d61d718
RD
102
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 ) {}
107
95a76b75
RD
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); }
115
116 bool Contains( wxDouble , wxDouble , int ) { return false; }
117 bool Contains( const wxPoint2DDouble& , int ) { return false; }
6d61d718 118};
b8910074 119wxGraphicsPath wxNullGraphicsPath;
6d61d718
RD
120
121
95a76b75
RD
122class wxGraphicsMatrix : public wxGraphicsObject
123{
124public :
125 wxGraphicsMatrix(wxGraphicsRenderer* ) {
126 PyErr_SetString(PyExc_NotImplementedError,
127 "wx.GraphicsMatrix is not available on this platform.");
128 }
129 virtual ~wxGraphicsMatrix() {}
95a76b75
RD
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; }
143};
b8910074 144wxGraphicsMatrix wxNullGraphicsMatrix;
95a76b75
RD
145
146
147class wxGraphicsContext : public wxGraphicsObject
6d61d718
RD
148{
149public:
95a76b75
RD
150
151 wxGraphicsContext(wxGraphicsRenderer* ) {
6d61d718 152 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 153 "wx.GraphicsContext is not available on this platform.");
6d61d718 154 }
95a76b75 155
6d61d718 156 virtual ~wxGraphicsContext() {}
95a76b75
RD
157
158 static wxGraphicsContext* Create( const wxWindowDC& ) {
6d61d718 159 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 160 "wx.GraphicsContext is not available on this platform.");
6d61d718 161 }
b876c1e4 162
95a76b75 163 static wxGraphicsContext* CreateFromNative( void * ) {
b876c1e4 164 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 165 "wx.GraphicsContext is not available on this platform.");
cbc3893c
KO
166 }
167
95a76b75
RD
168 static wxGraphicsContext* CreateFromNativeWindow( void * ) {
169 PyErr_SetString(PyExc_NotImplementedError,
170 "wx.GraphicsContext is not available on this platform.");
171 }
cbc3893c 172
95a76b75
RD
173 static wxGraphicsContext* Create( wxWindow* ) {
174 PyErr_SetString(PyExc_NotImplementedError,
175 "wx.GraphicsContext is not available on this platform.");
176 }
cbc3893c 177
95a76b75
RD
178 wxGraphicsPath * CreatePath() { return NULL; }
179
027aef71 180 virtual wxGraphicsPen CreatePen(const wxPen& ) { return NULL; }
95a76b75 181
027aef71 182 virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return NULL; }
95a76b75 183
027aef71 184 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble ,
95a76b75
RD
185 const wxColour&, const wxColour&) { return NULL; }
186
027aef71 187 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
95a76b75
RD
188 wxDouble xc, wxDouble yc, wxDouble radius,
189 const wxColour &oColor, const wxColour &cColor) { return NULL; }
190
027aef71 191 virtual wxGraphicsFont CreateFont( const wxFont &, const wxColour & ) { return NULL; }
95a76b75
RD
192
193 virtual wxGraphicsMatrix* CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble,
194 wxDouble, wxDouble) { return NULL; }
195
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* ) {}
208
027aef71 209 virtual void SetPen( const wxGraphicsPen& ) {}
95a76b75
RD
210 void SetPen( const wxPen& ) {}
211
027aef71 212 virtual void SetBrush( const wxGraphicsBrush& ) {}
95a76b75
RD
213 void SetBrush( const wxBrush& ) {}
214
027aef71 215 virtual void SetFont( const wxGraphicsFont& ) {}
95a76b75
RD
216 void SetFont( const wxFont&, const wxColour& ) {}
217
218 virtual void StrokePath( const wxGraphicsPath * ) {}
219 virtual void FillPath( const wxGraphicsPath *, int ) {}
220 virtual void DrawPath( const wxGraphicsPath *, int ) {}
221
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 {}
227
228 virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
229 virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
230
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; }
239};
240
241
242class wxGraphicsRenderer : public wxObject
243{
244public :
245 wxGraphicsRenderer() {
246 PyErr_SetString(PyExc_NotImplementedError,
247 "wx.GraphicsRenderer is not available on this platform.");
248 }
249
250 virtual ~wxGraphicsRenderer() {}
b876c1e4 251
95a76b75
RD
252 static wxGraphicsRenderer* GetDefaultRenderer(
253 PyErr_SetString(PyExc_NotImplementedError,
254 "wx.GraphicsRenderer is not available on this platform.");
255 );
256
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; }
261
262 virtual wxGraphicsPath * CreatePath() { return NULL; }
263
264 virtual wxGraphicsMatrix * CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble ,
027aef71
RD
265 wxDouble , wxDouble ) { return NULL; }
266
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; }
6d61d718
RD
274};
275
276
95a76b75 277
6d61d718
RD
278class wxGCDC: public wxWindowDC
279{
280public:
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);
286 }
95a76b75 287
6d61d718
RD
288 wxGCDC() {
289 wxPyBlock_t blocked = wxPyBeginBlockThreads();
290 PyErr_SetString(PyExc_NotImplementedError,
291 "wxGCDC is not available on this platform.");
292 wxPyEndBlockThreads(blocked);
293 }
95a76b75 294
6d61d718
RD
295 virtual ~wxGCDC() {}
296
b876c1e4
RD
297 wxGraphicsContext* GetGraphicsContext() { return NULL; }
298 void SetGraphicsContext( wxGraphicsContext* ) {}
6d61d718
RD
299};
300
301#endif
302%}
303
304//---------------------------------------------------------------------------
305//---------------------------------------------------------------------------
306
281c54cc
RD
307
308%typemap(in) (size_t points, wxPoint2D* points_array ) {
309 $2 = wxPoint2D_LIST_helper($input, &$1);
310 if ($2 == NULL) SWIG_fail;
311}
312%typemap(freearg) (size_t points, wxPoint2D* points_array ) {
313 if ($2) delete [] $2;
314}
315
316
317
6d61d718
RD
318MustHaveApp(wxGraphicsPath);
319MustHaveApp(wxGraphicsContext);
320MustHaveApp(wxGCDC);
321
6d61d718
RD
322typedef double wxDouble;
323
324
027aef71
RD
325//---------------------------------------------------------------------------
326
6d61d718 327
215a6add
RD
328DocStr(wxGraphicsObject,
329"This class is the superclass of native graphics objects like pens
330etc. It provides the internal reference counting. It is not to be
331instantiated by user code.", "");
cbc3893c
KO
332class wxGraphicsObject : public wxObject
333{
334public :
95a76b75
RD
335 wxGraphicsObject( wxGraphicsRenderer* renderer = NULL );
336 virtual ~wxGraphicsObject();
215a6add
RD
337
338 DocDeclStr(
339 bool , IsNull() const ,
340 "Is this object valid (false) or still empty (true)?", "");
341
342 DocDeclStr(
343 wxGraphicsRenderer* , GetRenderer() const,
344 "Returns the renderer that was used to create this instance, or
345``None`` if it has not been initialized yet.", "");
346
95a76b75
RD
347};
348
cbc3893c 349
215a6add
RD
350DocStr(wxGraphicsPen,
351"A wx.GraphicsPen is a native representation of a pen. It is used for
352stroking a path on a `wx.GraphicsContext`. The contents are specific and
353private to the respective renderer. The only way to get a valid instance
354is via a CreatePen call on the graphics context or the renderer
355instance.", "");
cbc3893c
KO
356class wxGraphicsPen : public wxGraphicsObject
357{
358public :
027aef71 359 wxGraphicsPen();
cbc3893c 360 virtual ~wxGraphicsPen();
95a76b75
RD
361};
362
215a6add
RD
363DocStr(wxGraphicsBrush,
364"A wx.GraphicsBrush is a native representation of a brush. It is used
365for filling a path on a `wx.GraphicsContext`. The contents are
366specific and private to the respective renderer. The only way to get a
367valid instance is via a Create...Brush call on the graphics context or
368the renderer instance.", "");
cbc3893c
KO
369class wxGraphicsBrush : public wxGraphicsObject
370{
371public :
027aef71 372 wxGraphicsBrush();
cbc3893c 373 virtual ~wxGraphicsBrush();
95a76b75
RD
374};
375
cbc3893c 376
215a6add
RD
377DocStr(wxGraphicsFont,
378"A `wx.GraphicsFont` is a native representation of a font (including
379text colour). The contents are specific an private to the respective
380renderer. The only way to get a valid instance is via a CreateFont
381call on the graphics context or the renderer instance.", "");
cbc3893c
KO
382class wxGraphicsFont : public wxGraphicsObject
383{
384public :
027aef71 385 wxGraphicsFont();
cbc3893c 386 virtual ~wxGraphicsFont();
95a76b75
RD
387};
388
027aef71 389
b8910074
RD
390//---------------------------------------------------------------------------
391
215a6add
RD
392DocStr(wxGraphicsMatrix,
393"A wx.GraphicsMatrix is a native representation of an affine
394matrix. The contents are specific an private to the respective
395renderer. The only way to get a valid instance is via a CreateMatrix
396call on the graphics context or the renderer instance.", "");
b8910074
RD
397class wxGraphicsMatrix : public wxGraphicsObject
398{
399public :
8f514ab4 400 wxGraphicsMatrix();
b8910074
RD
401 virtual ~wxGraphicsMatrix();
402
403 DocDeclStr(
404 virtual void , Concat( const wxGraphicsMatrix& t ),
215a6add 405 "Concatenates the passed in matrix to the current matrix.", "");
b8910074 406
215a6add
RD
407// %extend {
408// DocStr(Copy,
409// "Copy the passed in matrix to this one.", "");
410// void Copy( const wxGraphicsMatrix& t ) {
411// *self = t;
412// }
413// }
b8910074
RD
414
415
416 DocDeclStr(
417 virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
418 wxDouble tx=0.0, wxDouble ty=0.0),
215a6add
RD
419 "Sets the matrix to the specified values (default values are the
420identity matrix.)", "");
b8910074
RD
421
422
423 DocDeclStr(
424 virtual void , Invert(),
215a6add 425 "Inverts the matrix.", "");
b8910074
RD
426
427
428 DocDeclStr(
429 virtual bool , IsEqual( const wxGraphicsMatrix& t) const,
215a6add 430 "Returns ``True`` if the elements of the transformation matrix are equal", "");
b8910074
RD
431
432
433 DocDeclStr(
434 virtual bool , IsIdentity() const,
215a6add 435 "Returns ``True`` if this is the identity matrix", "");
b8910074
RD
436
437
438 DocDeclStr(
439 virtual void , Translate( wxDouble dx , wxDouble dy ),
215a6add 440 "Add a translation to this matrix.", "");
b8910074
RD
441
442
443 DocDeclStr(
444 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
215a6add 445 "Scales this matrix.", "");
b8910074
RD
446
447
448 DocDeclStr(
449 virtual void , Rotate( wxDouble angle ),
215a6add 450 "Rotates this matrix. The angle should be specified in radians.", "");
b8910074
RD
451
452
453 DocDeclAStr(
454 virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ) const,
455 "TransformPoint(self, x, y) --> (x, y)",
215a6add 456 "Applies this matrix to a point, returns the resulting point values", "");
b8910074
RD
457
458
459 DocDeclAStr(
460 virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ) const,
461 "TransformDistance(self, dx, dy) --> (dx, dy)",
215a6add
RD
462 "Applies this matrix to a distance (ie. performs all transforms except
463translations)", "");
b8910074
RD
464
465
466 DocDeclStr(
467 virtual void * , GetNativeMatrix() const,
215a6add
RD
468 "Returns the native representation of the matrix. For CoreGraphics this
469is a CFAffineMatrix pointer. For GDIPlus a Matrix Pointer and for
470Cairo a cairo_matrix_t pointer. NOTE: For wxPython we still need a
471way to make this value usable.", "");
b8910074 472};
027aef71 473
95a76b75 474//---------------------------------------------------------------------------
cbc3893c 475
95a76b75 476class wxGraphicsPath : public wxGraphicsObject
6d61d718
RD
477{
478public :
8f514ab4 479 wxGraphicsPath();
6d61d718 480 virtual ~wxGraphicsPath();
95a76b75 481
027aef71
RD
482
483 %nokwargs MoveToPoint;
484 DocStr(MoveToPoint,
215a6add 485 "Begins a new subpath at the specified point.", "");
027aef71
RD
486 virtual void MoveToPoint( wxDouble x, wxDouble y );
487 void MoveToPoint( const wxPoint2D& p);
95a76b75 488
6d61d718 489
027aef71
RD
490 %nokwargs AddLineToPoint;
491 DocStr(AddLineToPoint,
215a6add 492 "Adds a straight line from the current point to the specified point.", "");
027aef71
RD
493 virtual void AddLineToPoint( wxDouble x, wxDouble y );
494 void AddLineToPoint( const wxPoint2D& p);
95a76b75 495
6d61d718 496
027aef71
RD
497 %nokwargs AddCurveToPoint;
498 DocStr(AddCurveToPoint,
6d61d718
RD
499 "Adds a cubic Bezier curve from the current point, using two control
500points and an end point", "");
027aef71
RD
501 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1,
502 wxDouble cx2, wxDouble cy2,
503 wxDouble x, wxDouble y );
504 void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e);
95a76b75
RD
505
506
507
508 DocDeclStr(
b8910074 509 virtual void , AddPath( const wxGraphicsPath& path ),
215a6add 510 "Adds another path", "");
95a76b75 511
6d61d718
RD
512
513 DocDeclStr(
514 virtual void , CloseSubpath(),
215a6add 515 "Closes the current sub-path.", "");
95a76b75 516
6d61d718 517
6d61d718 518 DocDeclStr(
b8910074 519 wxPoint2D , GetCurrentPoint() const,
6d61d718 520 "Gets the last point of the current path, (0,0) if not yet set", "");
95a76b75 521
6d61d718 522
027aef71
RD
523 %nokwargs AddArc;
524 DocStr(AddArc,
6d61d718
RD
525 "Adds an arc of a circle centering at (x,y) with radius (r) from
526startAngle to endAngle", "");
027aef71
RD
527 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r,
528 wxDouble startAngle, wxDouble endAngle, bool clockwise );
529 void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
95a76b75 530
6d61d718
RD
531
532 DocDeclStr(
533 virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ),
534 "Adds a quadratic Bezier curve from the current point, using a control
535point and an end point", "");
95a76b75 536
6d61d718
RD
537
538 DocDeclStr(
539 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
215a6add 540 "Appends a rectangle as a new closed subpath.", "");
95a76b75 541
6d61d718
RD
542
543 DocDeclStr(
544 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
215a6add 545 "Appends a circle around (x,y) with radius r as a new closed subpath.", "");
95a76b75 546
6d61d718
RD
547
548 DocDeclStr(
549 virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ,
215a6add 550 "Appends an arc to two tangents connecting (current) to (x1,y1) and (x1,y1)
6d61d718 551to (x2,y2), also a straight line from (current) to (x1,y1)", "");
95a76b75
RD
552
553
554 DocDeclStr(
555 virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
215a6add 556 "Appends an ellipse fitting into the passed in rectangle.", "");
95a76b75
RD
557
558
559 DocDeclStr(
560 virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
215a6add 561 "Appends a rounded rectangle.", "");
95a76b75
RD
562
563
564 DocDeclStr(
565 virtual void * , GetNativePath() const,
215a6add
RD
566 "Returns the native path (CGPathRef for Core Graphics, Path pointer for
567GDIPlus and a cairo_path_t pointer for cairo). NOTE: For wxPython we
568still need a way to make this value usable.", "");
95a76b75
RD
569
570
571 DocDeclStr(
b8910074 572 virtual void , UnGetNativePath(void *p) const,
215a6add
RD
573 "Gives back the native path returned by GetNativePath() because there
574might be some deallocations necessary (eg on cairo the native path
575returned by GetNativePath is newly allocated each time).", "");
95a76b75
RD
576
577
578 DocDeclStr(
b8910074 579 virtual void , Transform( const wxGraphicsMatrix& matrix ),
215a6add 580 "Transforms each point of this path by the matrix", "");
95a76b75
RD
581
582
95a76b75 583 DocDeclStr(
b8910074 584 wxRect2DDouble , GetBox() const,
215a6add 585 "Gets the bounding box enclosing all points (possibly including control points)", "");
95a76b75
RD
586
587
027aef71
RD
588 %nokwargs Contains;
589 DocStr(Contains,
215a6add 590 "Returns ``True`` if the point is within the path.", "");
b8910074
RD
591 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const;
592 bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE) const;
6d61d718
RD
593
594};
595
95a76b75 596
b8910074 597//---------------------------------------------------------------------------
95a76b75 598
b8910074
RD
599%immutable;
600const wxGraphicsPen wxNullGraphicsPen;
601const wxGraphicsBrush wxNullGraphicsBrush;
602const wxGraphicsFont wxNullGraphicsFont;
603const wxGraphicsMatrix wxNullGraphicsMatrix;
604const wxGraphicsPath wxNullGraphicsPath;
605%mutable;
95a76b75 606
6d61d718
RD
607//---------------------------------------------------------------------------
608
215a6add
RD
609DocStr(wxGraphicsContext,
610"A `wx.GraphicsContext` instance is the object that is drawn upon. It is
611created by a renderer using the CreateContext calls, this can be done
612either directly using a renderer instance, or indirectly using the
613static convenience CreateXXX functions of wx.GraphicsContext that
614always delegate the task to the default renderer.", "");
6d61d718 615
95a76b75 616class wxGraphicsContext : public wxGraphicsObject
6d61d718
RD
617{
618public:
215a6add 619 //wxGraphicsContext(); This is an ABC, use Create to make an instance...
6d61d718 620 virtual ~wxGraphicsContext();
8292b82b 621
2742805a 622 %newobject Create;
8292b82b 623 %nokwargs Create;
2742805a
RD
624 %pythonAppend Create
625 "val.__dc = args[0] # save a ref so the dc will not be deleted before self";
215a6add
RD
626 DocStr(Create,
627 "Creates a wx.GraphicsContext either from a window or a DC.", "");
6d61d718 628 static wxGraphicsContext* Create( const wxWindowDC& dc);
8292b82b
RD
629 static wxGraphicsContext* Create( wxWindow* window ) ;
630
215a6add 631
2742805a 632 %newobject CreateFromNative;
215a6add
RD
633 DocDeclStr(
634 static wxGraphicsContext* , CreateFromNative( void * context ) ,
635 "Creates a wx.GraphicsContext from a native context. This native context
636must be eg a CGContextRef for Core Graphics, a Graphics pointer for
637GDIPlus or a cairo_t pointer for Cairo.", "");
638
8292b82b 639
95a76b75 640 %newobject CreateFromNative;
215a6add
RD
641 DocDeclStr(
642 static wxGraphicsContext* , CreateFromNativeWindow( void * window ) ,
643 "Creates a wx.GraphicsContext from a native window.", "");
644
95a76b75 645
6d61d718 646
6d61d718 647 DocDeclStr(
b8910074 648 virtual wxGraphicsPath , CreatePath(),
215a6add 649 "Creates a native graphics path which is initially empty.", "");
95a76b75
RD
650
651
95a76b75 652 DocDeclStr(
027aef71 653 virtual wxGraphicsPen , CreatePen(const wxPen& pen),
215a6add 654 "Creates a native pen from a `wx.Pen`.", "");
cbc3893c 655
cbc3893c 656
95a76b75 657 DocDeclStr(
027aef71 658 virtual wxGraphicsBrush , CreateBrush(const wxBrush& brush ),
215a6add 659 "Creates a native brush from a `wx.Brush`.", "");
95a76b75
RD
660
661
95a76b75 662 DocDeclStr(
027aef71 663 virtual wxGraphicsBrush ,
95a76b75
RD
664 CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
665 const wxColour& c1, const wxColour& c2),
215a6add
RD
666 "Creates a native brush, having a linear gradient, starting at (x1,y1)
667with color c1 to (x2,y2) with color c2.", "");
6d61d718 668
8292b82b 669
95a76b75 670 DocDeclStr(
027aef71 671 virtual wxGraphicsBrush ,
95a76b75
RD
672 CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
673 const wxColour &oColor, const wxColour &cColor),
215a6add
RD
674 "Creates a native brush, having a radial gradient originating at
675point (xo,yc) with color oColour and ends on a circle around (xc,yc) with
676radius r and color cColour.", "");
95a76b75
RD
677
678
95a76b75 679 DocDeclStr(
027aef71 680 virtual wxGraphicsFont , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ),
215a6add 681 "Creates a native graphics font from a `wx.Font` and a text colour.", "");
95a76b75
RD
682
683
95a76b75 684 DocDeclStr(
b8910074
RD
685 virtual wxGraphicsMatrix , CreateMatrix( wxDouble a=1.0, wxDouble b=0.0,
686 wxDouble c=0.0, wxDouble d=1.0,
687 wxDouble tx=0.0, wxDouble ty=0.0),
215a6add
RD
688 "Creates a native affine transformation matrix from the passed in
689values. The defaults result in an identity matrix.", "");
95a76b75
RD
690
691
692
6d61d718
RD
693 DocDeclStr(
694 virtual void , PushState(),
95a76b75
RD
695 "push the current state of the context, ie the transformation matrix on a stack", "");
696
6d61d718 697
6d61d718
RD
698 DocDeclStr(
699 virtual void , PopState(),
95a76b75
RD
700 "pops a stored state from the stack", "");
701
6d61d718 702
8292b82b 703 DocDeclStrName(
6d61d718 704 virtual void , Clip( const wxRegion &region ),
215a6add 705 "Clips drawings to the region, combined to current clipping region.", "",
8292b82b 706 ClipRegion);
95a76b75 707
8292b82b 708
8292b82b
RD
709 DocDeclStr(
710 virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
215a6add 711 "Clips drawings to the rectangle.", "");
95a76b75
RD
712
713
8292b82b
RD
714 DocDeclStr(
715 virtual void , ResetClip(),
215a6add 716 "Resets the clipping to original shape.", "");
95a76b75 717
6d61d718 718
8292b82b
RD
719 DocDeclStr(
720 virtual void * , GetNativeContext(),
215a6add
RD
721 "Returns the native context (CGContextRef for Core Graphics, Graphics
722pointer for GDIPlus and cairo_t pointer for cairo).", "");
8292b82b
RD
723
724
6d61d718
RD
725 DocDeclStr(
726 virtual void , Translate( wxDouble dx , wxDouble dy ),
215a6add 727 "Translates the current transformation matrix.", "");
95a76b75 728
6d61d718 729
6d61d718
RD
730 DocDeclStr(
731 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
215a6add 732 "Scale the current transformation matrix of the context.", "");
95a76b75 733
6d61d718 734
6d61d718
RD
735 DocDeclStr(
736 virtual void , Rotate( wxDouble angle ),
215a6add
RD
737 "Rotate the current transformation matrix of the context. ``angle`` is
738specified in radians.", "");
6d61d718 739
6d61d718 740
b8910074
RD
741 DocDeclStr(
742 virtual void , ConcatTransform( const wxGraphicsMatrix& matrix ),
215a6add
RD
743 "Concatenates the passed in transform with the current transform of
744this context.", "");
b8910074
RD
745
746
747 DocDeclStr(
748 virtual void , SetTransform( const wxGraphicsMatrix& matrix ),
215a6add 749 "Sets the current transform of this context.", "");
b8910074
RD
750
751
752 DocDeclStr(
753 virtual wxGraphicsMatrix , GetTransform() const,
215a6add 754 "Gets the current transformation matrix of this context.", "");
b8910074
RD
755
756
757
6d61d718 758
215a6add 759 DocStr(SetPen, "Sets the stroke pen", "");
95a76b75 760 %nokwargs SetPen;
027aef71 761 virtual void SetPen( const wxGraphicsPen& pen );
95a76b75
RD
762 void SetPen( const wxPen& pen );
763
6d61d718 764
215a6add 765 DocStr(SetBrush, "Sets the brush for filling", "");
95a76b75 766 %nokwargs SetBrush;
027aef71 767 virtual void SetBrush( const wxGraphicsBrush& brush );
95a76b75
RD
768 void SetBrush( const wxBrush& brush );
769
cbc3893c 770
215a6add 771 DocStr(SetFont, "Sets the font", "");
95a76b75 772 %nokwargs SetFont;
027aef71 773 virtual void SetFont( const wxGraphicsFont& font );
95a76b75 774 void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK);
6d61d718 775
95a76b75
RD
776
777
6d61d718 778 DocDeclStr(
b8910074 779 virtual void , StrokePath( const wxGraphicsPath& path ),
215a6add 780 "Strokes along a path with the current pen.", "");
6d61d718 781
95a76b75 782
6d61d718 783 DocDeclStr(
b8910074 784 virtual void , FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ),
215a6add 785 "Fills a path with the current brush.", "");
6d61d718 786
95a76b75 787
6d61d718 788 DocDeclStr(
b8910074 789 virtual void , DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ),
215a6add 790 "Draws the path by first filling and then stroking.", "");
95a76b75 791
6d61d718 792
6d61d718
RD
793 DocDeclStr(
794 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
215a6add 795 "Draws a text at the defined position.", "");
95a76b75 796
6d61d718 797
281c54cc 798 DocDeclStrName(
6d61d718 799 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
215a6add 800 "Draws a text at the defined position, at the given angle.", "",
281c54cc 801 DrawRotatedText);
95a76b75 802
6d61d718 803
752d967c 804 DocDeclAStrName(
6d61d718
RD
805 virtual void , GetTextExtent( const wxString &text,
806 wxDouble *OUTPUT /*width*/,
807 wxDouble *OUTPUT /*height*/,
808 wxDouble *OUTPUT /*descent*/,
809 wxDouble *OUTPUT /*externalLeading*/ ) const ,
752d967c 810 "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)",
215a6add
RD
811 "Gets the dimensions of the string using the currently selected
812font. ``text`` is the string to measure, ``w`` and ``h`` are the total
813width and height respectively, ``descent`` is the dimension from the
814baseline of the font to the bottom of the descender, and
815``externalLeading`` is any extra vertical space added to the font by
816the font designer (usually is zero).", "",
752d967c
RD
817 GetFullTextExtent);
818
819 %extend {
820 DocAStr(GetTextExtent,
821 "GetTextExtent(self, text) --> (width, height)",
215a6add
RD
822 "Gets the dimensions of the string using the currently selected
823font. ``text`` is the string to measure, ``w`` and ``h`` are the total
824width and height respectively.", "");
95a76b75 825
752d967c
RD
826 PyObject* GetTextExtent( const wxString &text )
827 {
828 wxDouble width = 0.0,
829 height = 0.0;
830 self->GetTextExtent(text, &width, &height, NULL, NULL);
831 // thread wrapers are turned off for this .i file, so no need to acquire GIL...
832 PyObject* rv = PyTuple_New(2);
833 PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width));
834 PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height));
835 return rv;
836 }
837 }
95a76b75 838
6d61d718 839
281c54cc
RD
840 %extend {
841 DocAStr(GetPartialTextExtents,
842 "GetPartialTextExtents(self, text) -> [widths]",
215a6add
RD
843 "Returns a list of widths from the beginning of ``text`` to the
844coresponding character in ``text``.", "");
281c54cc
RD
845 wxArrayDouble GetPartialTextExtents(const wxString& text) {
846 wxArrayDouble widths;
847 self->GetPartialTextExtents(text, widths);
848 return widths;
849 }
850 }
6d61d718 851
6d61d718
RD
852
853 DocDeclStr(
854 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
215a6add
RD
855 "Draws the bitmap. In case of a mono bitmap, this is treated as a mask
856and the current brush is used for filling.", "");
95a76b75 857
6d61d718
RD
858
859 DocDeclStr(
860 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
215a6add 861 "Draws the icon.", "");
6d61d718 862
95a76b75
RD
863
864
6d61d718
RD
865 DocDeclStr(
866 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
215a6add 867 "Strokes a single line.", "");
6d61d718 868
281c54cc 869
281c54cc
RD
870 DocDeclAStr(
871 virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
872 "StrokeLines(self, List points)",
215a6add 873 "Stroke lines connecting each of the points", "");
6d61d718 874
281c54cc 875
281c54cc 876 %extend {
95a76b75 877 DocStr(StrokeLineSegements,
215a6add 878 "Stroke disconnected lines from begin to end points", "");
aa43bcc7 879 void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
281c54cc
RD
880 {
881 size_t c1, c2, count;
882 wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
883 wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
884
885 if ( beginP != NULL && endP != NULL )
886 {
887 count = wxMin(c1, c2);
888 self->StrokeLines(count, beginP, endP);
889 }
890 delete [] beginP;
891 delete [] endP;
892 }
893 }
6d61d718 894
95a76b75 895
6d61d718 896 DocDeclStr(
b8910074
RD
897 virtual void , DrawLines( size_t points, const wxPoint2D *points_array,
898 int fillStyle = wxODDEVEN_RULE ),
215a6add 899 "Draws a polygon.", "");
95a76b75 900
6d61d718 901
6d61d718
RD
902 DocDeclStr(
903 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
215a6add 904 "Draws a rectangle.", "");
95a76b75 905
6d61d718 906
6d61d718
RD
907 DocDeclStr(
908 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
215a6add 909 "Draws an ellipse.", "");
95a76b75 910
6d61d718 911
6d61d718
RD
912 DocDeclStr(
913 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
215a6add 914 "Draws a rounded rectangle", "");
95a76b75
RD
915
916
917
918 DocDeclStr(
919 virtual bool , ShouldOffset() const,
920 "helper to determine if a 0.5 offset should be applied for the drawing operation", "");
921
922};
923
924
925//---------------------------------------------------------------------------
926
927class wxGraphicsRenderer : public wxObject
928{
929public :
930 // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer
931
932 virtual ~wxGraphicsRenderer();
933
934 // %newobject GetDefaultRenderer; ???
935 static wxGraphicsRenderer* GetDefaultRenderer();
936
937 %nokwargs CreateContext;
938 %newobject CreateContext;
939 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ;
940 virtual wxGraphicsContext * CreateContext( wxWindow* window );
941
942 %newobject CreateContextFromNativeContext;
943 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
944
945 %newobject CreateContextFromNativeWindow;
946 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
947
948
b8910074 949 virtual wxGraphicsPath CreatePath();
95a76b75 950
b8910074
RD
951 virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
952 wxDouble tx=0.0, wxDouble ty=0.0);
95a76b75 953
027aef71 954 virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
95a76b75 955
027aef71 956 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
95a76b75 957
027aef71 958 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
95a76b75
RD
959 const wxColour&c1, const wxColour&c2);
960
027aef71 961 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
95a76b75
RD
962 const wxColour &oColor, const wxColour &cColor);
963
027aef71 964 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK );
6d61d718 965
6d61d718
RD
966};
967
968
95a76b75 969
6d61d718
RD
970//---------------------------------------------------------------------------
971
6240681f
RD
972%{
973#include "wx/dcgraph.h"
974%}
6d61d718
RD
975
976class wxGCDC: public wxDC
977{
978public:
0e4e6012
RD
979 %pythonAppend wxGCDC
980 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
6d61d718
RD
981 wxGCDC(const wxWindowDC& dc);
982 //wxGCDC();
983 virtual ~wxGCDC();
984
8292b82b
RD
985 wxGraphicsContext* GetGraphicsContext();
986 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
987
988 %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
6d61d718
RD
989};
990
991
281c54cc 992//---------------------------------------------------------------------------
6d61d718 993
281c54cc
RD
994// Turn GIL acquisition back on.
995%threadWrapperOn
6d61d718 996