]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_graphics.i
Add wxPyTabArt
[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
cbc3893c
KO
328class wxGraphicsObject : public wxObject
329{
330public :
95a76b75
RD
331 wxGraphicsObject( wxGraphicsRenderer* renderer = NULL );
332 virtual ~wxGraphicsObject();
027aef71 333 bool IsNull() const ;
95a76b75
RD
334 wxGraphicsRenderer* GetRenderer() const;
335};
336
cbc3893c
KO
337
338class wxGraphicsPen : public wxGraphicsObject
339{
340public :
027aef71 341 wxGraphicsPen();
cbc3893c 342 virtual ~wxGraphicsPen();
95a76b75
RD
343};
344
cbc3893c
KO
345
346class wxGraphicsBrush : public wxGraphicsObject
347{
348public :
027aef71 349 wxGraphicsBrush();
cbc3893c 350 virtual ~wxGraphicsBrush();
95a76b75
RD
351};
352
cbc3893c
KO
353
354class wxGraphicsFont : public wxGraphicsObject
355{
356public :
027aef71 357 wxGraphicsFont();
cbc3893c 358 virtual ~wxGraphicsFont();
95a76b75
RD
359};
360
027aef71 361
b8910074
RD
362//---------------------------------------------------------------------------
363
364class wxGraphicsMatrix : public wxGraphicsObject
365{
366public :
367 // wxGraphicsMatrix(wxGraphicsRenderer* renderer); *** This class is an ABC
368
369 virtual ~wxGraphicsMatrix();
370
371 DocDeclStr(
372 virtual void , Concat( const wxGraphicsMatrix& t ),
373 "concatenates the matrix", "");
374
375 %extend {
376 DocStr(Copy,
377 "Copy the passed in matrix to this one.", "");
378 void Copy( const wxGraphicsMatrix& t ) {
379 *self = t;
380 }
381 }
382
383
384 DocDeclStr(
385 virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
386 wxDouble tx=0.0, wxDouble ty=0.0),
387 "sets the matrix to the respective values", "");
388
389
390 DocDeclStr(
391 virtual void , Invert(),
392 "makes this the inverse matrix", "");
393
394
395 DocDeclStr(
396 virtual bool , IsEqual( const wxGraphicsMatrix& t) const,
397 "returns true if the elements of the transformation matrix are equal", "");
398
399
400 DocDeclStr(
401 virtual bool , IsIdentity() const,
402 "return true if this is the identity matrix", "");
403
404
405 DocDeclStr(
406 virtual void , Translate( wxDouble dx , wxDouble dy ),
407 "add the translation to this matrix", "");
408
409
410 DocDeclStr(
411 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
412 "add the scale to this matrix", "");
413
414
415 DocDeclStr(
416 virtual void , Rotate( wxDouble angle ),
417 "add the rotation to this matrix (radians)", "");
418
419
420 DocDeclAStr(
421 virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ) const,
422 "TransformPoint(self, x, y) --> (x, y)",
423 "applies that matrix to the point", "");
424
425
426 DocDeclAStr(
427 virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ) const,
428 "TransformDistance(self, dx, dy) --> (dx, dy)",
429 "applies the matrix except for translations", "");
430
431
432 DocDeclStr(
433 virtual void * , GetNativeMatrix() const,
434 "returns the native representation", "");
435};
027aef71 436
95a76b75 437//---------------------------------------------------------------------------
cbc3893c 438
95a76b75 439class wxGraphicsPath : public wxGraphicsObject
6d61d718
RD
440{
441public :
95a76b75 442 //wxGraphicsPath(wxGraphicsRenderer* renderer); *** This class is an ABC, so we can't allow instances to be created directly
6d61d718 443 virtual ~wxGraphicsPath();
95a76b75 444
027aef71
RD
445
446 %nokwargs MoveToPoint;
447 DocStr(MoveToPoint,
6d61d718 448 "Begins a new subpath at (x,y)", "");
027aef71
RD
449 virtual void MoveToPoint( wxDouble x, wxDouble y );
450 void MoveToPoint( const wxPoint2D& p);
95a76b75 451
6d61d718 452
027aef71
RD
453 %nokwargs AddLineToPoint;
454 DocStr(AddLineToPoint,
6d61d718 455 "Adds a straight line from the current point to (x,y) ", "");
027aef71
RD
456 virtual void AddLineToPoint( wxDouble x, wxDouble y );
457 void AddLineToPoint( const wxPoint2D& p);
95a76b75 458
6d61d718 459
027aef71
RD
460 %nokwargs AddCurveToPoint;
461 DocStr(AddCurveToPoint,
6d61d718
RD
462 "Adds a cubic Bezier curve from the current point, using two control
463points and an end point", "");
027aef71
RD
464 virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1,
465 wxDouble cx2, wxDouble cy2,
466 wxDouble x, wxDouble y );
467 void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e);
95a76b75
RD
468
469
470
471 DocDeclStr(
b8910074 472 virtual void , AddPath( const wxGraphicsPath& path ),
95a76b75
RD
473 "adds another path", "");
474
6d61d718
RD
475
476 DocDeclStr(
477 virtual void , CloseSubpath(),
478 "closes the current sub-path", "");
95a76b75 479
6d61d718 480
6d61d718 481 DocDeclStr(
b8910074 482 wxPoint2D , GetCurrentPoint() const,
6d61d718 483 "Gets the last point of the current path, (0,0) if not yet set", "");
95a76b75 484
6d61d718 485
027aef71
RD
486 %nokwargs AddArc;
487 DocStr(AddArc,
6d61d718
RD
488 "Adds an arc of a circle centering at (x,y) with radius (r) from
489startAngle to endAngle", "");
027aef71
RD
490 virtual void AddArc( wxDouble x, wxDouble y, wxDouble r,
491 wxDouble startAngle, wxDouble endAngle, bool clockwise );
492 void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
95a76b75 493
6d61d718
RD
494
495 DocDeclStr(
496 virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ),
497 "Adds a quadratic Bezier curve from the current point, using a control
498point and an end point", "");
95a76b75 499
6d61d718
RD
500
501 DocDeclStr(
502 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
503 "Appends a rectangle as a new closed subpath", "");
95a76b75 504
6d61d718
RD
505
506 DocDeclStr(
507 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
281c54cc 508 "Appends a circle as a new closed subpath with the given radius.", "");
95a76b75 509
6d61d718
RD
510
511 DocDeclStr(
512 virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ,
513 "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1)
514to (x2,y2), also a straight line from (current) to (x1,y1)", "");
95a76b75
RD
515
516
517 DocDeclStr(
518 virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
519 "appends an ellipse", "");
520
521
522 DocDeclStr(
523 virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
524 "appends a rounded rectangle", "");
525
526
527 DocDeclStr(
528 virtual void * , GetNativePath() const,
529 "returns the native path", "");
530
531
532 DocDeclStr(
b8910074 533 virtual void , UnGetNativePath(void *p) const,
95a76b75
RD
534 "give the native path returned by GetNativePath() back (there might be some
535deallocations necessary)", "");
536
537
538 DocDeclStr(
b8910074 539 virtual void , Transform( const wxGraphicsMatrix& matrix ),
95a76b75
RD
540 "transforms each point of this path by the matrix", "");
541
542
95a76b75 543 DocDeclStr(
b8910074 544 wxRect2DDouble , GetBox() const,
95a76b75
RD
545 "gets the bounding box enclosing all points (possibly including control points)", "");
546
547
027aef71
RD
548 %nokwargs Contains;
549 DocStr(Contains,
95a76b75 550 "", "");
b8910074
RD
551 virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const;
552 bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE) const;
6d61d718
RD
553
554};
555
95a76b75 556
b8910074 557//---------------------------------------------------------------------------
95a76b75 558
b8910074
RD
559%immutable;
560const wxGraphicsPen wxNullGraphicsPen;
561const wxGraphicsBrush wxNullGraphicsBrush;
562const wxGraphicsFont wxNullGraphicsFont;
563const wxGraphicsMatrix wxNullGraphicsMatrix;
564const wxGraphicsPath wxNullGraphicsPath;
565%mutable;
95a76b75 566
6d61d718
RD
567//---------------------------------------------------------------------------
568
569
95a76b75 570class wxGraphicsContext : public wxGraphicsObject
6d61d718
RD
571{
572public:
573 // wxGraphicsContext() This is also an ABC, use Create to make an instance...
574 virtual ~wxGraphicsContext();
8292b82b 575
2742805a 576 %newobject Create;
8292b82b 577 %nokwargs Create;
2742805a
RD
578 %pythonAppend Create
579 "val.__dc = args[0] # save a ref so the dc will not be deleted before self";
6d61d718 580 static wxGraphicsContext* Create( const wxWindowDC& dc);
95a76b75 581
8292b82b
RD
582 static wxGraphicsContext* Create( wxWindow* window ) ;
583
2742805a 584 %newobject CreateFromNative;
8292b82b
RD
585 static wxGraphicsContext* CreateFromNative( void * context ) ;
586
95a76b75
RD
587 %newobject CreateFromNative;
588 static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
589
6d61d718 590
6d61d718 591 DocDeclStr(
b8910074 592 virtual wxGraphicsPath , CreatePath(),
95a76b75
RD
593 "creates a path instance that corresponds to the type of graphics context, ie GDIPlus, Cairo, CoreGraphics ...", "");
594
595
95a76b75 596 DocDeclStr(
027aef71 597 virtual wxGraphicsPen , CreatePen(const wxPen& pen),
6d61d718 598 "", "");
cbc3893c 599
cbc3893c 600
95a76b75 601 DocDeclStr(
027aef71 602 virtual wxGraphicsBrush , CreateBrush(const wxBrush& brush ),
95a76b75
RD
603 "", "");
604
605
95a76b75 606 DocDeclStr(
027aef71 607 virtual wxGraphicsBrush ,
95a76b75
RD
608 CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
609 const wxColour& c1, const wxColour& c2),
610 "sets the brush to a linear gradient, starting at (x1,y1) with color c1
611to (x2,y2) with color c2", "");
6d61d718 612
8292b82b 613
95a76b75 614 DocDeclStr(
027aef71 615 virtual wxGraphicsBrush ,
95a76b75
RD
616 CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
617 const wxColour &oColor, const wxColour &cColor),
618 "sets the brush to a radial gradient originating at (xo,yc) with color
619oColor and ends on a circle around (xc,yc) with radius r and color
620cColor
621", "");
622
623
95a76b75 624 DocDeclStr(
027aef71 625 virtual wxGraphicsFont , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ),
95a76b75
RD
626 "sets the font", "");
627
628
95a76b75 629 DocDeclStr(
b8910074
RD
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),
95a76b75
RD
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
b8910074
RD
683 DocDeclStr(
684 virtual void , ConcatTransform( const wxGraphicsMatrix& matrix ),
685 "concatenates this transform with the current transform of this context", "");
686
687
688 DocDeclStr(
689 virtual void , SetTransform( const wxGraphicsMatrix& matrix ),
690 "sets the transform of this context", "");
691
692
693 DocDeclStr(
694 virtual wxGraphicsMatrix , GetTransform() const,
695 "gets the matrix of this context", "");
696
697
698
6d61d718 699
95a76b75
RD
700 DocStr(SetPen, "sets the stroke pen", "");
701 %nokwargs SetPen;
027aef71 702 virtual void SetPen( const wxGraphicsPen& pen );
95a76b75
RD
703 void SetPen( const wxPen& pen );
704
6d61d718 705
95a76b75
RD
706 DocStr(SetBrush, "sets the brush for filling", "");
707 %nokwargs SetBrush;
027aef71 708 virtual void SetBrush( const wxGraphicsBrush& brush );
95a76b75
RD
709 void SetBrush( const wxBrush& brush );
710
cbc3893c 711
95a76b75
RD
712 DocStr(SetFont, "sets the font", "");
713 %nokwargs SetFont;
027aef71 714 virtual void SetFont( const wxGraphicsFont& font );
95a76b75 715 void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK);
6d61d718 716
95a76b75
RD
717
718
6d61d718 719 DocDeclStr(
b8910074 720 virtual void , StrokePath( const wxGraphicsPath& path ),
95a76b75 721 "strokes along a path with the current pen", "");
6d61d718 722
95a76b75 723
6d61d718 724 DocDeclStr(
b8910074 725 virtual void , FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ),
95a76b75 726 "fills a path with the current brush", "");
6d61d718 727
95a76b75 728
6d61d718 729 DocDeclStr(
b8910074 730 virtual void , DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ),
95a76b75
RD
731 "draws a path by first filling and then stroking", "");
732
6d61d718 733
6d61d718
RD
734 DocDeclStr(
735 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
736 "", "");
95a76b75 737
6d61d718 738
281c54cc 739 DocDeclStrName(
6d61d718 740 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
281c54cc
RD
741 "", "",
742 DrawRotatedText);
95a76b75 743
6d61d718 744
752d967c 745 DocDeclAStrName(
6d61d718
RD
746 virtual void , GetTextExtent( const wxString &text,
747 wxDouble *OUTPUT /*width*/,
748 wxDouble *OUTPUT /*height*/,
749 wxDouble *OUTPUT /*descent*/,
750 wxDouble *OUTPUT /*externalLeading*/ ) const ,
752d967c
RD
751 "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)",
752 "", "",
753 GetFullTextExtent);
754
755 %extend {
756 DocAStr(GetTextExtent,
757 "GetTextExtent(self, text) --> (width, height)",
758 "", "");
95a76b75 759
752d967c
RD
760 PyObject* GetTextExtent( const wxString &text )
761 {
762 wxDouble width = 0.0,
763 height = 0.0;
764 self->GetTextExtent(text, &width, &height, NULL, NULL);
765 // thread wrapers are turned off for this .i file, so no need to acquire GIL...
766 PyObject* rv = PyTuple_New(2);
767 PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width));
768 PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height));
769 return rv;
770 }
771 }
95a76b75 772
6d61d718 773
281c54cc
RD
774 %extend {
775 DocAStr(GetPartialTextExtents,
776 "GetPartialTextExtents(self, text) -> [widths]",
777 "", "");
778 wxArrayDouble GetPartialTextExtents(const wxString& text) {
779 wxArrayDouble widths;
780 self->GetPartialTextExtents(text, widths);
781 return widths;
782 }
783 }
6d61d718 784
6d61d718
RD
785
786 DocDeclStr(
787 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
788 "", "");
95a76b75 789
6d61d718
RD
790
791 DocDeclStr(
792 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
793 "", "");
6d61d718 794
95a76b75
RD
795
796
6d61d718
RD
797 DocDeclStr(
798 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
95a76b75 799 "strokes a single line", "");
6d61d718 800
281c54cc 801
281c54cc
RD
802 DocDeclAStr(
803 virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
804 "StrokeLines(self, List points)",
95a76b75 805 "stroke lines connecting each of the points", "");
6d61d718 806
281c54cc 807
281c54cc 808 %extend {
95a76b75
RD
809 DocStr(StrokeLineSegements,
810 "stroke disconnected lines from begin to end points", "");
aa43bcc7 811 void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
281c54cc
RD
812 {
813 size_t c1, c2, count;
814 wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
815 wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2);
816
817 if ( beginP != NULL && endP != NULL )
818 {
819 count = wxMin(c1, c2);
820 self->StrokeLines(count, beginP, endP);
821 }
822 delete [] beginP;
823 delete [] endP;
824 }
825 }
6d61d718 826
95a76b75 827
6d61d718 828 DocDeclStr(
b8910074
RD
829 virtual void , DrawLines( size_t points, const wxPoint2D *points_array,
830 int fillStyle = wxODDEVEN_RULE ),
95a76b75
RD
831 "draws a polygon", "");
832
6d61d718 833
6d61d718
RD
834 DocDeclStr(
835 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
95a76b75
RD
836 "draws a rectangle", "");
837
6d61d718 838
6d61d718
RD
839 DocDeclStr(
840 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
95a76b75
RD
841 "draws an ellipse", "");
842
6d61d718 843
6d61d718
RD
844 DocDeclStr(
845 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
95a76b75
RD
846 "draws a rounded rectangle", "");
847
848
849
850 DocDeclStr(
851 virtual bool , ShouldOffset() const,
852 "helper to determine if a 0.5 offset should be applied for the drawing operation", "");
853
854};
855
856
857//---------------------------------------------------------------------------
858
859class wxGraphicsRenderer : public wxObject
860{
861public :
862 // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer
863
864 virtual ~wxGraphicsRenderer();
865
866 // %newobject GetDefaultRenderer; ???
867 static wxGraphicsRenderer* GetDefaultRenderer();
868
869 %nokwargs CreateContext;
870 %newobject CreateContext;
871 virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ;
872 virtual wxGraphicsContext * CreateContext( wxWindow* window );
873
874 %newobject CreateContextFromNativeContext;
875 virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
876
877 %newobject CreateContextFromNativeWindow;
878 virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
879
880
b8910074 881 virtual wxGraphicsPath CreatePath();
95a76b75 882
b8910074
RD
883 virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
884 wxDouble tx=0.0, wxDouble ty=0.0);
95a76b75 885
027aef71 886 virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
95a76b75 887
027aef71 888 virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
95a76b75 889
027aef71 890 virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
95a76b75
RD
891 const wxColour&c1, const wxColour&c2);
892
027aef71 893 virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
95a76b75
RD
894 const wxColour &oColor, const wxColour &cColor);
895
027aef71 896 virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK );
6d61d718 897
6d61d718
RD
898};
899
900
95a76b75 901
6d61d718
RD
902//---------------------------------------------------------------------------
903
6240681f
RD
904%{
905#include "wx/dcgraph.h"
906%}
6d61d718
RD
907
908class wxGCDC: public wxDC
909{
910public:
0e4e6012
RD
911 %pythonAppend wxGCDC
912 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
6d61d718
RD
913 wxGCDC(const wxWindowDC& dc);
914 //wxGCDC();
915 virtual ~wxGCDC();
916
8292b82b
RD
917 wxGraphicsContext* GetGraphicsContext();
918 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
919
920 %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
6d61d718
RD
921};
922
923
281c54cc 924//---------------------------------------------------------------------------
6d61d718 925
281c54cc
RD
926// Turn GIL acquisition back on.
927%threadWrapperOn
6d61d718 928