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