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