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