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