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