]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_graphics.i
daily updates and add wxGrpahicsPath overloads
[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
RD
89
90 virtual wxGraphicsPath *Clone() const { return NULL; }
91
6d61d718 92 void MoveToPoint( wxDouble, wxDouble ) {}
95a76b75
RD
93 void MoveToPoint( const wxPoint2DDouble& ) {}
94 void AddLineToPoint( wxDouble, wxDouble ) {}
95 void AddLineToPoint( const wxPoint2DDouble& ) {}
6d61d718 96 void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {}
95a76b75
RD
97 void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {}
98 void AddPath( const wxGraphicsPath* ) {}
6d61d718
RD
99 void CloseSubpath() {}
100 void GetCurrentPoint( wxDouble&, wxDouble&) {}
95a76b75 101 wxPoint2DDouble GetCurrentPoint() { reutrn wxPoint2D(0,0); }
6d61d718 102 void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {}
95a76b75 103 void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {}
6d61d718
RD
104
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 ) {}
109
95a76b75
RD
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); }
117
118 bool Contains( wxDouble , wxDouble , int ) { return false; }
119 bool Contains( const wxPoint2DDouble& , int ) { return false; }
6d61d718
RD
120};
121
122
95a76b75
RD
123class wxGraphicsMatrix : public wxGraphicsObject
124{
125public :
126 wxGraphicsMatrix(wxGraphicsRenderer* ) {
127 PyErr_SetString(PyExc_NotImplementedError,
128 "wx.GraphicsMatrix is not available on this platform.");
129 }
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; }
145};
146
147
148
149class wxGraphicsContext : public wxGraphicsObject
6d61d718
RD
150{
151public:
95a76b75
RD
152
153 wxGraphicsContext(wxGraphicsRenderer* ) {
6d61d718 154 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 155 "wx.GraphicsContext is not available on this platform.");
6d61d718 156 }
95a76b75 157
6d61d718 158 virtual ~wxGraphicsContext() {}
95a76b75
RD
159
160 static wxGraphicsContext* Create( const wxWindowDC& ) {
6d61d718 161 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 162 "wx.GraphicsContext is not available on this platform.");
6d61d718 163 }
b876c1e4 164
95a76b75 165 static wxGraphicsContext* CreateFromNative( void * ) {
b876c1e4 166 PyErr_SetString(PyExc_NotImplementedError,
95a76b75 167 "wx.GraphicsContext is not available on this platform.");
cbc3893c
KO
168 }
169
95a76b75
RD
170 static wxGraphicsContext* CreateFromNativeWindow( void * ) {
171 PyErr_SetString(PyExc_NotImplementedError,
172 "wx.GraphicsContext is not available on this platform.");
173 }
cbc3893c 174
95a76b75
RD
175 static wxGraphicsContext* Create( wxWindow* ) {
176 PyErr_SetString(PyExc_NotImplementedError,
177 "wx.GraphicsContext is not available on this platform.");
178 }
cbc3893c 179
95a76b75
RD
180 wxGraphicsPath * CreatePath() { return NULL; }
181
027aef71 182 virtual wxGraphicsPen CreatePen(const wxPen& ) { return NULL; }
95a76b75 183
027aef71 184 virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return NULL; }
95a76b75 185
027aef71 186 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble ,
95a76b75
RD
187 const wxColour&, const wxColour&) { return NULL; }
188
027aef71 189 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
95a76b75
RD
190 wxDouble xc, wxDouble yc, wxDouble radius,
191 const wxColour &oColor, const wxColour &cColor) { return NULL; }
192
027aef71 193 virtual wxGraphicsFont CreateFont( const wxFont &, const wxColour & ) { return NULL; }
95a76b75
RD
194
195 virtual wxGraphicsMatrix* CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble,
196 wxDouble, wxDouble) { return NULL; }
197
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* ) {}
210
027aef71 211 virtual void SetPen( const wxGraphicsPen& ) {}
95a76b75
RD
212 void SetPen( const wxPen& ) {}
213
027aef71 214 virtual void SetBrush( const wxGraphicsBrush& ) {}
95a76b75
RD
215 void SetBrush( const wxBrush& ) {}
216
027aef71 217 virtual void SetFont( const wxGraphicsFont& ) {}
95a76b75
RD
218 void SetFont( const wxFont&, const wxColour& ) {}
219
220 virtual void StrokePath( const wxGraphicsPath * ) {}
221 virtual void FillPath( const wxGraphicsPath *, int ) {}
222 virtual void DrawPath( const wxGraphicsPath *, int ) {}
223
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 {}
229
230 virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
231 virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
232
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; }
241};
242
243
244class wxGraphicsRenderer : public wxObject
245{
246public :
247 wxGraphicsRenderer() {
248 PyErr_SetString(PyExc_NotImplementedError,
249 "wx.GraphicsRenderer is not available on this platform.");
250 }
251
252 virtual ~wxGraphicsRenderer() {}
b876c1e4 253
95a76b75
RD
254 static wxGraphicsRenderer* GetDefaultRenderer(
255 PyErr_SetString(PyExc_NotImplementedError,
256 "wx.GraphicsRenderer is not available on this platform.");
257 );
258
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; }
263
264 virtual wxGraphicsPath * CreatePath() { return NULL; }
265
266 virtual wxGraphicsMatrix * CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble ,
027aef71
RD
267 wxDouble , wxDouble ) { return NULL; }
268
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; }
6d61d718
RD
276};
277
278
95a76b75 279
6d61d718
RD
280class wxGCDC: public wxWindowDC
281{
282public:
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);
288 }
95a76b75 289
6d61d718
RD
290 wxGCDC() {
291 wxPyBlock_t blocked = wxPyBeginBlockThreads();
292 PyErr_SetString(PyExc_NotImplementedError,
293 "wxGCDC is not available on this platform.");
294 wxPyEndBlockThreads(blocked);
295 }
95a76b75 296
6d61d718
RD
297 virtual ~wxGCDC() {}
298
b876c1e4
RD
299 wxGraphicsContext* GetGraphicsContext() { return NULL; }
300 void SetGraphicsContext( wxGraphicsContext* ) {}
6d61d718
RD
301};
302
303#endif
304%}
305
306//---------------------------------------------------------------------------
307//---------------------------------------------------------------------------
308
281c54cc
RD
309
310%typemap(in) (size_t points, wxPoint2D* points_array ) {
311 $2 = wxPoint2D_LIST_helper($input, &$1);
312 if ($2 == NULL) SWIG_fail;
313}
314%typemap(freearg) (size_t points, wxPoint2D* points_array ) {
315 if ($2) delete [] $2;
316}
317
318
319
6d61d718
RD
320MustHaveApp(wxGraphicsPath);
321MustHaveApp(wxGraphicsContext);
322MustHaveApp(wxGCDC);
323
6d61d718
RD
324typedef double wxDouble;
325
326
027aef71
RD
327//---------------------------------------------------------------------------
328
6d61d718 329
cbc3893c
KO
330class wxGraphicsObject : public wxObject
331{
332public :
95a76b75
RD
333 wxGraphicsObject( wxGraphicsRenderer* renderer = NULL );
334 virtual ~wxGraphicsObject();
027aef71 335 bool IsNull() const ;
95a76b75
RD
336 wxGraphicsRenderer* GetRenderer() const;
337};
338
cbc3893c
KO
339
340class wxGraphicsPen : public wxGraphicsObject
341{
342public :
027aef71 343 wxGraphicsPen();
cbc3893c 344 virtual ~wxGraphicsPen();
95a76b75
RD
345};
346
cbc3893c
KO
347
348class wxGraphicsBrush : public wxGraphicsObject
349{
350public :
027aef71 351 wxGraphicsBrush();
cbc3893c 352 virtual ~wxGraphicsBrush();
95a76b75
RD
353};
354
cbc3893c
KO
355
356class wxGraphicsFont : public wxGraphicsObject
357{
358public :
027aef71 359 wxGraphicsFont();
cbc3893c 360 virtual ~wxGraphicsFont();
95a76b75
RD
361};
362
027aef71
RD
363
364%immutable;
365const wxGraphicsPen wxNullGraphicsPen;
366const wxGraphicsBrush wxNullGraphicsBrush;
367const wxGraphicsFont wxNullGraphicsFont;
368%mutable;
369
95a76b75 370//---------------------------------------------------------------------------
cbc3893c 371
95a76b75 372class wxGraphicsPath : public wxGraphicsObject
6d61d718
RD
373{
374public :
95a76b75 375 //wxGraphicsPath(wxGraphicsRenderer* renderer); *** This class is an ABC, so we can't allow instances to be created directly
6d61d718 376 virtual ~wxGraphicsPath();
95a76b75
RD
377
378 virtual wxGraphicsPath *Clone() const = 0;
6d61d718 379
027aef71
RD
380
381 %nokwargs MoveToPoint;
382 DocStr(MoveToPoint,
6d61d718 383 "Begins a new subpath at (x,y)", "");
027aef71
RD
384 virtual void MoveToPoint( wxDouble x, wxDouble y );
385 void MoveToPoint( const wxPoint2D& p);
95a76b75 386
6d61d718 387
027aef71
RD
388 %nokwargs AddLineToPoint;
389 DocStr(AddLineToPoint,
6d61d718 390 "Adds a straight line from the current point to (x,y) ", "");
027aef71
RD
391 virtual void AddLineToPoint( wxDouble x, wxDouble y );
392 void AddLineToPoint( const wxPoint2D& p);
95a76b75 393
6d61d718 394
027aef71
RD
395 %nokwargs AddCurveToPoint;
396 DocStr(AddCurveToPoint,
6d61d718
RD
397 "Adds a cubic Bezier curve from the current point, using two control
398points and an end point", "");
027aef71
RD
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);
95a76b75
RD
403
404
405
406 DocDeclStr(
407 virtual void , AddPath( const wxGraphicsPath* path ),
408 "adds another path", "");
409
6d61d718
RD
410
411 DocDeclStr(
412 virtual void , CloseSubpath(),
413 "closes the current sub-path", "");
95a76b75 414
6d61d718 415
6d61d718
RD
416 DocDeclStr(
417 wxPoint2D , GetCurrentPoint(),
418 "Gets the last point of the current path, (0,0) if not yet set", "");
95a76b75 419
6d61d718 420
027aef71
RD
421 %nokwargs AddArc;
422 DocStr(AddArc,
6d61d718
RD
423 "Adds an arc of a circle centering at (x,y) with radius (r) from
424startAngle to endAngle", "");
027aef71
RD
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);
95a76b75 428
6d61d718
RD
429
430 DocDeclStr(
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
433point and an end point", "");
95a76b75 434
6d61d718
RD
435
436 DocDeclStr(
437 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
438 "Appends a rectangle as a new closed subpath", "");
95a76b75 439
6d61d718
RD
440
441 DocDeclStr(
442 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
281c54cc 443 "Appends a circle as a new closed subpath with the given radius.", "");
95a76b75 444
6d61d718
RD
445
446 DocDeclStr(
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)
449to (x2,y2), also a straight line from (current) to (x1,y1)", "");
95a76b75
RD
450
451
452 DocDeclStr(
453 virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
454 "appends an ellipse", "");
455
456
457 DocDeclStr(
458 virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
459 "appends a rounded rectangle", "");
460
461
462 DocDeclStr(
463 virtual void * , GetNativePath() const,
464 "returns the native path", "");
465
466
467 DocDeclStr(
468 virtual void , UnGetNativePath(void *p),
469 "give the native path returned by GetNativePath() back (there might be some
470deallocations necessary)", "");
471
472
473 DocDeclStr(
474 virtual void , Transform( wxGraphicsMatrix* matrix ),
475 "transforms each point of this path by the matrix", "");
476
477
95a76b75
RD
478 DocDeclStr(
479 wxRect2DDouble , GetBox(),
480 "gets the bounding box enclosing all points (possibly including control points)", "");
481
482
027aef71
RD
483 %nokwargs Contains;
484 DocStr(Contains,
95a76b75 485 "", "");
027aef71
RD
486 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxWINDING_RULE);
487 bool Contains( const wxPoint2DDouble& c, int fillStyle = wxWINDING_RULE);
6d61d718
RD
488
489};
490
8292b82b
RD
491//---------------------------------------------------------------------------
492
95a76b75 493class wxGraphicsMatrix : public wxGraphicsObject
8292b82b
RD
494{
495public :
95a76b75 496 // wxGraphicsMatrix(wxGraphicsRenderer* renderer); *** This class is an ABC
8292b82b 497
95a76b75 498 virtual ~wxGraphicsMatrix();
8292b82b 499
95a76b75
RD
500 virtual wxGraphicsMatrix *Clone() const;
501
502 DocDeclStr(
503 virtual void , Concat( const wxGraphicsMatrix *t ),
504 "concatenates the matrix", "");
505
506
507 DocDeclStr(
508 virtual void , Copy( const wxGraphicsMatrix *t ),
509 "copies the passed in matrix", "");
510
511
512 DocDeclStr(
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", "");
516
517
518 DocDeclStr(
519 virtual void , Invert(),
520 "makes this the inverse matrix", "");
521
522
523 DocDeclStr(
524 virtual bool , IsEqual( const wxGraphicsMatrix* t) const,
525 "returns true if the elements of the transformation matrix are equal", "");
8292b82b
RD
526
527
95a76b75
RD
528 DocDeclStr(
529 virtual bool , IsIdentity(),
530 "return true if this is the identity matrix", "");
531
532
533 DocDeclStr(
534 virtual void , Translate( wxDouble dx , wxDouble dy ),
535 "add the translation to this matrix", "");
536
537
538 DocDeclStr(
539 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
540 "add the scale to this matrix", "");
541
542
543 DocDeclStr(
544 virtual void , Rotate( wxDouble angle ),
545 "add the rotation to this matrix (radians)", "");
546
547
548 DocDeclAStr(
549 virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ),
550 "TransformPoint(self, x, y) --> (x, y)",
551 "applies that matrix to the point", "");
552
553
554 DocDeclAStr(
555 virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ),
556 "TransformDistance(self, dx, dy) --> (dx, dy)",
557 "applies the matrix except for translations", "");
558
559
560 DocDeclStr(
561 virtual void * , GetNativeMatrix() const,
562 "returns the native representation", "");
563};
564
6d61d718
RD
565//---------------------------------------------------------------------------
566
567
95a76b75 568class wxGraphicsContext : public wxGraphicsObject
6d61d718
RD
569{
570public:
571 // wxGraphicsContext() This is also an ABC, use Create to make an instance...
572 virtual ~wxGraphicsContext();
8292b82b 573
2742805a 574 %newobject Create;
8292b82b 575 %nokwargs Create;
2742805a
RD
576 %pythonAppend Create
577 "val.__dc = args[0] # save a ref so the dc will not be deleted before self";
6d61d718 578 static wxGraphicsContext* Create( const wxWindowDC& dc);
95a76b75 579
8292b82b
RD
580 static wxGraphicsContext* Create( wxWindow* window ) ;
581
2742805a 582 %newobject CreateFromNative;
8292b82b
RD
583 static wxGraphicsContext* CreateFromNative( void * context ) ;
584
95a76b75
RD
585 %newobject CreateFromNative;
586 static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
587
6d61d718 588
2742805a 589 %newobject CreatePath;
6d61d718
RD
590 DocDeclStr(
591 virtual wxGraphicsPath * , CreatePath(),
95a76b75
RD
592 "creates a path instance that corresponds to the type of graphics context, ie GDIPlus, Cairo, CoreGraphics ...", "");
593
594
95a76b75 595 DocDeclStr(
027aef71 596 virtual wxGraphicsPen , CreatePen(const wxPen& pen),
6d61d718 597 "", "");
cbc3893c 598
cbc3893c 599
95a76b75 600 DocDeclStr(
027aef71 601 virtual wxGraphicsBrush , CreateBrush(const wxBrush& brush ),
95a76b75
RD
602 "", "");
603
604
95a76b75 605 DocDeclStr(
027aef71 606 virtual wxGraphicsBrush ,
95a76b75
RD
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
610to (x2,y2) with color c2", "");
6d61d718 611
8292b82b 612
95a76b75 613 DocDeclStr(
027aef71 614 virtual wxGraphicsBrush ,
95a76b75
RD
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
618oColor and ends on a circle around (xc,yc) with radius r and color
619cColor
620", "");
621
622
95a76b75 623 DocDeclStr(
027aef71 624 virtual wxGraphicsFont , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ),
95a76b75
RD
625 "sets the font", "");
626
627
628 %newobject CreateMatrix;
629 DocDeclStr(
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", "");
634
635
636
6d61d718
RD
637 DocDeclStr(
638 virtual void , PushState(),
95a76b75
RD
639 "push the current state of the context, ie the transformation matrix on a stack", "");
640
6d61d718 641
6d61d718
RD
642 DocDeclStr(
643 virtual void , PopState(),
95a76b75
RD
644 "pops a stored state from the stack", "");
645
6d61d718 646
8292b82b 647 DocDeclStrName(
6d61d718 648 virtual void , Clip( const wxRegion &region ),
95a76b75 649 "clips drawings to the region", "",
8292b82b 650 ClipRegion);
95a76b75 651
8292b82b 652
8292b82b
RD
653 DocDeclStr(
654 virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
95a76b75
RD
655 "clips drawings to the rect", "");
656
657
8292b82b
RD
658 DocDeclStr(
659 virtual void , ResetClip(),
95a76b75
RD
660 "resets the clipping to original extent", "");
661
6d61d718 662
8292b82b
RD
663 DocDeclStr(
664 virtual void * , GetNativeContext(),
95a76b75 665 "returns the native context", "");
8292b82b
RD
666
667
6d61d718
RD
668 DocDeclStr(
669 virtual void , Translate( wxDouble dx , wxDouble dy ),
95a76b75
RD
670 "translate the current transformation matrix CTM of the context", "");
671
6d61d718 672
6d61d718
RD
673 DocDeclStr(
674 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
95a76b75
RD
675 "scale the current transformation matrix CTM of the context", "");
676
6d61d718 677
6d61d718
RD
678 DocDeclStr(
679 virtual void , Rotate( wxDouble angle ),
95a76b75 680 "rotate (radians) the current transformation matrix CTM of the context", "");
6d61d718 681
6d61d718 682
6d61d718 683
95a76b75
RD
684 DocStr(SetPen, "sets the stroke pen", "");
685 %nokwargs SetPen;
027aef71 686 virtual void SetPen( const wxGraphicsPen& pen );
95a76b75
RD
687 void SetPen( const wxPen& pen );
688
6d61d718 689
95a76b75
RD
690 DocStr(SetBrush, "sets the brush for filling", "");
691 %nokwargs SetBrush;
027aef71 692 virtual void SetBrush( const wxGraphicsBrush& brush );
95a76b75
RD
693 void SetBrush( const wxBrush& brush );
694
cbc3893c 695
95a76b75
RD
696 DocStr(SetFont, "sets the font", "");
697 %nokwargs SetFont;
027aef71 698 virtual void SetFont( const wxGraphicsFont& font );
95a76b75 699 void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK);
6d61d718 700
95a76b75
RD
701
702
6d61d718
RD
703 DocDeclStr(
704 virtual void , StrokePath( const wxGraphicsPath *path ),
95a76b75 705 "strokes along a path with the current pen", "");
6d61d718 706
95a76b75 707
6d61d718
RD
708 DocDeclStr(
709 virtual void , FillPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
95a76b75 710 "fills a path with the current brush", "");
6d61d718 711
95a76b75 712
6d61d718
RD
713 DocDeclStr(
714 virtual void , DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
95a76b75
RD
715 "draws a path by first filling and then stroking", "");
716
6d61d718 717
6d61d718
RD
718 DocDeclStr(
719 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
720 "", "");
95a76b75 721
6d61d718 722
281c54cc 723 DocDeclStrName(
6d61d718 724 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
281c54cc
RD
725 "", "",
726 DrawRotatedText);
95a76b75 727
6d61d718 728
752d967c 729 DocDeclAStrName(
6d61d718
RD
730 virtual void , GetTextExtent( const wxString &text,
731 wxDouble *OUTPUT /*width*/,
732 wxDouble *OUTPUT /*height*/,
733 wxDouble *OUTPUT /*descent*/,
734 wxDouble *OUTPUT /*externalLeading*/ ) const ,
752d967c
RD
735 "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)",
736 "", "",
737 GetFullTextExtent);
738
739 %extend {
740 DocAStr(GetTextExtent,
741 "GetTextExtent(self, text) --> (width, height)",
742 "", "");
95a76b75 743
752d967c
RD
744 PyObject* GetTextExtent( const wxString &text )
745 {
746 wxDouble width = 0.0,
747 height = 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));
753 return rv;
754 }
755 }
95a76b75 756
6d61d718 757
281c54cc
RD
758 %extend {
759 DocAStr(GetPartialTextExtents,
760 "GetPartialTextExtents(self, text) -> [widths]",
761 "", "");
762 wxArrayDouble GetPartialTextExtents(const wxString& text) {
763 wxArrayDouble widths;
764 self->GetPartialTextExtents(text, widths);
765 return widths;
766 }
767 }
6d61d718 768
6d61d718
RD
769
770 DocDeclStr(
771 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
772 "", "");
95a76b75 773
6d61d718
RD
774
775 DocDeclStr(
776 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
777 "", "");
6d61d718 778
95a76b75
RD
779
780
6d61d718
RD
781 DocDeclStr(
782 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
95a76b75 783 "strokes a single line", "");
6d61d718 784
281c54cc 785
281c54cc
RD
786 DocDeclAStr(
787 virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
788 "StrokeLines(self, List points)",
95a76b75 789 "stroke lines connecting each of the points", "");
6d61d718 790
281c54cc 791
281c54cc 792 %extend {
95a76b75
RD
793 DocStr(StrokeLineSegements,
794 "stroke disconnected lines from begin to end points", "");
aa43bcc7 795 void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
281c54cc
RD
796 {
797 size_t c1, c2, count;
798 wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
799 wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
800
801 if ( beginP != NULL && endP != NULL )
802 {
803 count = wxMin(c1, c2);
804 self->StrokeLines(count, beginP, endP);
805 }
806 delete [] beginP;
807 delete [] endP;
808 }
809 }
6d61d718 810
95a76b75 811
6d61d718 812 DocDeclStr(
281c54cc 813 virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ),
95a76b75
RD
814 "draws a polygon", "");
815
6d61d718 816
6d61d718
RD
817 DocDeclStr(
818 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
95a76b75
RD
819 "draws a rectangle", "");
820
6d61d718 821
6d61d718
RD
822 DocDeclStr(
823 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
95a76b75
RD
824 "draws an ellipse", "");
825
6d61d718 826
6d61d718
RD
827 DocDeclStr(
828 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
95a76b75
RD
829 "draws a rounded rectangle", "");
830
831
832
833 DocDeclStr(
834 virtual bool , ShouldOffset() const,
835 "helper to determine if a 0.5 offset should be applied for the drawing operation", "");
836
837};
838
839
840//---------------------------------------------------------------------------
841
842class wxGraphicsRenderer : public wxObject
843{
844public :
845 // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer
846
847 virtual ~wxGraphicsRenderer();
848
849 // %newobject GetDefaultRenderer; ???
850 static wxGraphicsRenderer* GetDefaultRenderer();
851
852 %nokwargs CreateContext;
853 %newobject CreateContext;
854 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ;
855 virtual wxGraphicsContext * CreateContext( wxWindow* window );
856
857 %newobject CreateContextFromNativeContext;
858 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
859
860 %newobject CreateContextFromNativeWindow;
861 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
862
863
864 %newobject CreatePath;
865 virtual wxGraphicsPath * CreatePath();
866
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);
870
027aef71 871 virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
95a76b75 872
027aef71 873 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
95a76b75 874
027aef71 875 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
95a76b75
RD
876 const wxColour&c1, const wxColour&c2);
877
027aef71 878 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
95a76b75
RD
879 const wxColour &oColor, const wxColour &cColor);
880
027aef71 881 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK );
6d61d718 882
6d61d718
RD
883};
884
885
95a76b75 886
6d61d718
RD
887//---------------------------------------------------------------------------
888
6240681f
RD
889%{
890#include "wx/dcgraph.h"
891%}
6d61d718
RD
892
893class wxGCDC: public wxDC
894{
895public:
0e4e6012
RD
896 %pythonAppend wxGCDC
897 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
6d61d718
RD
898 wxGCDC(const wxWindowDC& dc);
899 //wxGCDC();
900 virtual ~wxGCDC();
901
8292b82b
RD
902 wxGraphicsContext* GetGraphicsContext();
903 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
904
905 %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
6d61d718
RD
906};
907
908
281c54cc 909//---------------------------------------------------------------------------
6d61d718 910
281c54cc
RD
911// Turn GIL acquisition back on.
912%threadWrapperOn
6d61d718 913