1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        graphics.h
3 // Purpose:     interface of various wxGraphics* classes
4 // Author:      wxWidgets team
5 // Licence:     wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
7 
8 /**
9     @class wxGraphicsPath
10 
11     A wxGraphicsPath is a native representation of a geometric path. The
12     contents are specific and private to the respective renderer. Instances are
13     reference counted and can therefore be assigned as usual. The only way to
14     get a valid instance is by using wxGraphicsContext::CreatePath() or
15     wxGraphicsRenderer::CreatePath().
16 
17     @library{wxcore}
18     @category{gdi}
19 */
20 class wxGraphicsPath : public wxGraphicsObject
21 {
22 public:
23     /**
24         Adds an arc of a circle.
25 
26         The circle is defined by the coordinates of its centre (@a x, @a y) or
27         @a c and its radius @a r. The arc goes from the starting angle @a
28         startAngle to @a endAngle either clockwise or counter-clockwise
29         depending on the value of @a clockwise argument.
30 
31         The angles are measured in radians but, contrary to the usual
32         mathematical convention, are always @e clockwise from the horizontal
33         axis.
34 
35         If for clockwise arc @a endAngle is less than @a startAngle it will be
36         progressively increased by 2*pi until it is greater than @a startAngle.
37         If for counter-clockwise arc @a endAngle is greater than @a startAngle
38         it will be progressively decreased by 2*pi until it is less than
39         @a startAngle.
40 
41         If there is a current point set, an initial line segment will be added
42         to the path to connect the current point to the beginning of the arc.
43     */
44     //@{
45     virtual void AddArc(wxDouble x, wxDouble y, wxDouble r,
46                         wxDouble startAngle, wxDouble endAngle,
47                         bool clockwise);
48     void AddArc(const wxPoint2DDouble& c, wxDouble r,
49                 wxDouble startAngle, wxDouble endAngle, bool clockwise);
50     //@}
51 
52     /**
53         Adds an arc (of a circle with radius @a r) that is tangent
54         to the line connecting current point and (@a x1, @a y1) and
55         to the line connecting (@a x1, @a y1) and (@a x2, @a y2).
56         If the current point and the starting point of the arc are different,
57         a straight line connecting these points is also appended.
58         If there is no current point before the call to AddArcToPoint() this
59         function will behave as if preceded by a call to MoveToPoint(0, 0).
60         After this call the current point will be at the ending point
61         of the arc.
62         @image html drawing-addarctopoint.png
63     */
64     virtual void AddArcToPoint(wxDouble x1, wxDouble y1, wxDouble x2,
65                                wxDouble y2, wxDouble r);
66 
67     /**
68         Appends a circle around (@a x,@a y) with radius @a r as a new closed
69         subpath.
70         After this call the current point will be at (@a x+@a r, @a y).
71     */
72     virtual void AddCircle(wxDouble x, wxDouble y, wxDouble r);
73 
74     /**
75         Adds a cubic bezier curve from the current point, using two control
76         points and an end point.
77         If there is no current point before the call to AddCurveToPoint() this
78         function will behave as if preceded by a call to
79         MoveToPoint(@a cx1, @a cy1).
80     */
81     virtual void AddCurveToPoint(wxDouble cx1, wxDouble cy1,
82                                  wxDouble cx2, wxDouble cy2,
83                                  wxDouble x, wxDouble y);
84     /**
85         Adds a cubic bezier curve from the current point, using two control
86         points and an end point.
87         If there is no current point before the call to AddCurveToPoint() this
88         function will behave as if preceded by a call to MoveToPoint(@a c1).
89     */
90     void AddCurveToPoint(const wxPoint2DDouble& c1,
91                          const wxPoint2DDouble& c2,
92                          const wxPoint2DDouble& e);
93 
94     /**
95         Appends an ellipse fitting into the passed in rectangle as a new
96         closed subpath.
97         After this call the current point will be at (@a x+@a w, @a y+@a h/2).
98     */
99     virtual void AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
100 
101     /**
102         Adds a straight line from the current point to (@a x,@a y).
103         If current point is not yet set before the call to AddLineToPoint()
104         this function will behave as MoveToPoint().
105     */
106     virtual void AddLineToPoint(wxDouble x, wxDouble y);
107     /**
108         Adds a straight line from the current point to @a p.
109         If current point is not yet set before the call to AddLineToPoint()
110         this function will behave as MoveToPoint().
111     */
112     void AddLineToPoint(const wxPoint2DDouble& p);
113 
114     /**
115         Adds another path onto the current path. After this call the current
116         point will be at the added path's current point.
117         For Direct2D the path being appended shouldn't contain
118         a started non-empty subpath when this function is called.
119     */
120     virtual void AddPath(const wxGraphicsPath& path);
121 
122     /**
123         Adds a quadratic bezier curve from the current point, using a control
124         point and an end point.
125         If there is no current point before the call to AddQuadCurveToPoint()
126         this function will behave as if preceded by a call to
127         MoveToPoint(@a cx, @a cy).
128     */
129     virtual void AddQuadCurveToPoint(wxDouble cx, wxDouble cy,
130                                      wxDouble x, wxDouble y);
131 
132     /**
133         Appends a rectangle as a new closed subpath. After this call
134         the current point will be at (@a x, @a y).
135     */
136     virtual void AddRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
137 
138     /**
139         Appends a rounded rectangle as a new closed subpath.
140         If @a radius equals 0 this function will behave as AddRectangle(),
141         otherwise after this call the current point will be at
142         (@a x+@a w, @a y+@a h/2).
143     */
144     virtual void AddRoundedRectangle(wxDouble x, wxDouble y, wxDouble w,
145                                      wxDouble h, wxDouble radius);
146 
147     /**
148         Closes the current sub-path. After this call the current point will be
149         at the joined endpoint of the sub-path.
150     */
151     virtual void CloseSubpath();
152 
153     /**
154         @return @true if the point is within the path.
155     */
156     bool Contains(const wxPoint2DDouble& c,
157                   wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const;
158     /**
159         @return @true if the point is within the path.
160     */
161     virtual bool Contains(wxDouble x, wxDouble y,
162                           wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const;
163 
164     /**
165         Gets the bounding box enclosing all points (possibly including control
166         points).
167     */
168     wxRect2DDouble GetBox() const;
169     /**
170         Gets the bounding box enclosing all points (possibly including control
171         points).
172     */
173     virtual void GetBox(wxDouble* x, wxDouble* y,
174                         wxDouble* w, wxDouble* h) const;
175 
176     /**
177         Gets the last point of the current path, (0,0) if not yet set.
178     */
179     virtual void GetCurrentPoint(wxDouble* x, wxDouble* y) const;
180     /**
181         Gets the last point of the current path, (0,0) if not yet set.
182     */
183     wxPoint2DDouble GetCurrentPoint() const;
184 
185     /**
186         Returns the native path (CGPathRef for Core Graphics, Path pointer for
187         GDIPlus and a cairo_path_t pointer for cairo).
188     */
189     virtual void* GetNativePath() const;
190 
191     /**
192         Begins a new subpath at (@a x,@a y).
193     */
194     virtual void MoveToPoint(wxDouble x, wxDouble y);
195     /**
196         Begins a new subpath at @a p.
197     */
198     void MoveToPoint(const wxPoint2DDouble& p);
199 
200     /**
201         Transforms each point of this path by the matrix.
202         For Direct2D the current path shouldn't contain
203         a started non-empty subpath when this function is called.
204     */
205     virtual void Transform(const wxGraphicsMatrix& matrix);
206 
207     /**
208         Gives back the native path returned by GetNativePath() because there
209         might be some deallocations necessary (e.g. on cairo the native path
210         returned by GetNativePath() is newly allocated each time).
211     */
212     virtual void UnGetNativePath(void* p) const;
213 };
214 
215 
216 
217 /**
218     @class wxGraphicsObject
219 
220     This class is the superclass of native graphics objects like pens etc. It
221     allows reference counting. Not instantiated by user code.
222 
223     @library{wxcore}
224     @category{gdi}
225 
226     @see wxGraphicsBrush, wxGraphicsPen, wxGraphicsMatrix, wxGraphicsPath
227 */
228 class wxGraphicsObject : public wxObject
229 {
230 public:
231     /**
232         Returns the renderer that was used to create this instance, or @NULL
233         if it has not been initialized yet.
234     */
235     wxGraphicsRenderer* GetRenderer() const;
236 
237     /**
238         @return @false if this object is valid, otherwise returns @true.
239     */
240     bool IsNull() const;
241 };
242 
243 /**
244     Anti-aliasing modes used by wxGraphicsContext::SetAntialiasMode().
245 */
246 enum wxAntialiasMode
247 {
248     /** No anti-aliasing */
249     wxANTIALIAS_NONE,
250 
251     /** The default anti-aliasing */
252     wxANTIALIAS_DEFAULT,
253 };
254 
255 /**
256     Interpolation quality used by wxGraphicsContext::SetInterpolationQuality().
257  */
258 enum wxInterpolationQuality
259 {
260     /** default interpolation, based on type of context, in general medium quality */
261     wxINTERPOLATION_DEFAULT,
262     /** no interpolation */
263     wxINTERPOLATION_NONE,
264     /** fast interpolation, suited for interactivity */
265     wxINTERPOLATION_FAST,
266     /** better quality */
267     wxINTERPOLATION_GOOD,
268     /** best quality, not suited for interactivity */
269     wxINTERPOLATION_BEST
270 };
271 
272 /**
273     Compositing is done using Porter-Duff compositions
274     (see http://keithp.com/~keithp/porterduff/p253-porter.pdf) with
275     wxGraphicsContext::SetCompositionMode().
276 
277     The description give a short equation on how the values of a resulting
278     pixel are calculated.
279     @e R = Result, @e S = Source, @e D = Destination, colors premultiplied with alpha
280     @e Ra, @e Sa, @e Da their alpha components
281 */
282 enum wxCompositionMode
283 {
284     /**
285         Indicates invalid or unsupported composition mode.
286 
287         This value can't be passed to wxGraphicsContext::SetCompositionMode().
288 
289         @since 2.9.2
290      */
291     wxCOMPOSITION_INVALID = -1,
292     wxCOMPOSITION_CLEAR, /**< @e R = 0 */
293     wxCOMPOSITION_SOURCE, /**< @e R = S */
294     wxCOMPOSITION_OVER, /**< @e R = @e S + @e D*(1 - @e Sa) */
295     wxCOMPOSITION_IN, /**< @e R = @e S*@e Da */
296     wxCOMPOSITION_OUT, /**< @e R = @e S*(1 - @e Da) */
297     wxCOMPOSITION_ATOP, /**< @e R = @e S*@e Da + @e D*(1 - @e Sa) */
298 
299     wxCOMPOSITION_DEST, /**< @e R = @e D, essentially a noop */
300     wxCOMPOSITION_DEST_OVER, /**< @e R = @e S*(1 - @e Da) + @e D */
301     wxCOMPOSITION_DEST_IN, /**< @e R = @e D*@e Sa */
302     wxCOMPOSITION_DEST_OUT, /**< @e R = @e D*(1 - @e Sa) */
303     wxCOMPOSITION_DEST_ATOP, /**< @e R = @e S*(1 - @e Da) + @e D*@e Sa */
304     wxCOMPOSITION_XOR, /**< @e R = @e S*(1 - @e Da) + @e D*(1 - @e Sa) */
305     wxCOMPOSITION_ADD  /**< @e R = @e S + @e D */
306 };
307 
308 /**
309    Used to indicate what kind of gradient is set in a wxGraphicsPenInfo
310    object.
311 
312    @since 3.1.3
313  */
314 enum wxGradientType {
315     wxGRADIENT_NONE,
316     wxGRADIENT_LINEAR,
317     wxGRADIENT_RADIAL
318 };
319 
320 
321 /**
322     Represents a bitmap.
323 
324     The objects of this class are not created directly but only via
325     wxGraphicsContext or wxGraphicsRenderer CreateBitmap(),
326     CreateBitmapFromImage() or CreateSubBitmap() methods. They can subsequently
327     be used with wxGraphicsContext::DrawBitmap(). The only other operation is
328     testing for the bitmap validity which can be performed using IsNull()
329     method inherited from the base class.
330  */
331 class wxGraphicsBitmap : public wxGraphicsObject
332 {
333 public:
334     /**
335         Default constructor creates an invalid bitmap.
336      */
337     wxGraphicsBitmap();
338 
339     /**
340         Return the contents of this bitmap as wxImage.
341 
342         Using this method is more efficient than converting wxGraphicsBitmap to
343         wxBitmap first and then to wxImage and can be useful if, for example,
344         you want to save wxGraphicsBitmap as a disk file in a format not
345         directly supported by wxBitmap.
346 
347         Invalid image is returned if the bitmap is invalid.
348 
349         @since 2.9.3
350      */
351     wxImage ConvertToImage() const;
352 
353     /**
354         Return the pointer to the native bitmap data. (CGImageRef for Core Graphics,
355         cairo_surface_t for Cairo, Bitmap* for GDI+.)
356 
357         @since 2.9.4
358      */
359     void* GetNativeBitmap() const;
360 };
361 
362 /**
363     @class wxGraphicsContext
364 
365     A wxGraphicsContext instance is the object that is drawn upon. It is
366     created by a renderer using wxGraphicsRenderer::CreateContext(). This can
367     be either directly using a renderer instance, or indirectly using the
368     static convenience Create() functions of wxGraphicsContext that always
369     delegate the task to the default renderer.
370 
371     @code
372     void MyCanvas::OnPaint(wxPaintEvent &event)
373     {
374         // Create paint DC
375         wxPaintDC dc(this);
376 
377         // Create graphics context from it
378         wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
379 
380         if (gc)
381         {
382             // make a path that contains a circle and some lines
383             gc->SetPen( *wxRED_PEN );
384             wxGraphicsPath path = gc->CreatePath();
385             path.AddCircle( 50.0, 50.0, 50.0 );
386             path.MoveToPoint(0.0, 50.0);
387             path.AddLineToPoint(100.0, 50.0);
388             path.MoveToPoint(50.0, 0.0);
389             path.AddLineToPoint(50.0, 100.0 );
390             path.CloseSubpath();
391             path.AddRectangle(25.0, 25.0, 50.0, 50.0);
392 
393             gc->StrokePath(path);
394 
395             delete gc;
396         }
397     }
398     @endcode
399 
400     @remarks For some renderers (like Direct2D or Cairo) processing
401     of drawing operations may be deferred (Direct2D render target normally
402     builds up a batch of rendering commands but defers processing of these
403     commands, Cairo operates on a separate surface) so to make drawing
404     results visible you need to update the content of the context
405     by calling wxGraphicsContext::Flush() or by destroying the context.
406 
407     @library{wxcore}
408     @category{gdi,dc}
409 
410     @see wxGraphicsRenderer::CreateContext(), wxGCDC, wxDC
411 */
412 class wxGraphicsContext : public wxGraphicsObject
413 {
414 public:
415     /**
416         @name Creating a context
417 
418         @{
419     */
420 
421     /**
422         Creates a wxGraphicsContext from a wxWindow.
423 
424         @see wxGraphicsRenderer::CreateContext()
425     */
426     static wxGraphicsContext* Create(wxWindow* window);
427 
428     /**
429         Creates a wxGraphicsContext from a wxWindowDC
430 
431         @see wxGraphicsRenderer::CreateContext()
432     */
433     static wxGraphicsContext* Create(const wxWindowDC& windowDC);
434 
435     /**
436         Creates a wxGraphicsContext from a wxMemoryDC
437 
438         @see wxGraphicsRenderer::CreateContext()
439     */
440     static wxGraphicsContext* Create(const wxMemoryDC& memoryDC);
441 
442     /**
443         Creates a wxGraphicsContext from a wxPrinterDC. Under GTK+, this will
444         only work when using the GtkPrint printing backend which is available
445         since GTK+ 2.10.
446 
447         @see wxGraphicsRenderer::CreateContext(), @ref overview_unixprinting
448     */
449     static wxGraphicsContext* Create(const wxPrinterDC& printerDC);
450 
451     /**
452         Creates a wxGraphicsContext from a wxEnhMetaFileDC.
453 
454         This function, as wxEnhMetaFileDC class itself, is only available only
455         under MSW.
456 
457         @see wxGraphicsRenderer::CreateContext()
458     */
459     static wxGraphicsContext* Create(const wxEnhMetaFileDC& metaFileDC);
460 
461     /**
462         Creates a wxGraphicsContext from a DC of unknown specific type.
463 
464         Creates a wxGraphicsContext if @a dc is a supported type (i.e. has a
465         corresponding Create() method, e.g. wxWindowDC or wxMemoryDC).
466         Returns @NULL if the DC is unsupported.
467 
468         This method is only useful as a helper in generic code that operates
469         with wxDC and doesn't known its exact type. Use Create() instead if
470         you know that the DC is e.g. wxWindowDC.
471 
472         @see wxGraphicsRenderer::CreateContextFromUnknownDC()
473 
474         @since 3.1.1
475      */
476     static wxGraphicsContext* CreateFromUnknownDC(wxDC& dc);
477 
478     /**
479         Creates a wxGraphicsContext associated with a wxImage.
480 
481         The image specifies the size of the context as well as whether alpha is
482         supported (if wxImage::HasAlpha()) or not and the initial contents of
483         the context. The @a image object must have a life time greater than
484         that of the new context as the context copies its contents back to the
485         image when it is destroyed.
486 
487         @since 2.9.3
488      */
489     static wxGraphicsContext* Create(wxImage& image);
490 
491     /**
492         Creates a wxGraphicsContext from a native context. This native context
493         must be a CGContextRef for Core Graphics, a Graphics pointer for
494         GDIPlus, or a cairo_t pointer for cairo.
495 
496         @see wxGraphicsRenderer::CreateContextFromNativeContext()
497     */
498     static wxGraphicsContext* CreateFromNative(void* context);
499 
500     /**
501         Creates a wxGraphicsContext from a native window.
502 
503         @see wxGraphicsRenderer::CreateContextFromNativeWindow()
504     */
505     static wxGraphicsContext* CreateFromNativeWindow(void* window);
506 
507     /**
508         Creates a wxGraphicsContext from a native DC handle. Windows only.
509 
510         @see wxGraphicsRenderer::CreateContextFromNativeHDC()
511 
512         @since 3.1.1
513     */
514     static wxGraphicsContext* CreateFromNativeHDC(WXHDC dc);
515 
516     /**
517        Create a lightweight context that can be used only for measuring text.
518     */
519     static wxGraphicsContext* Create();
520 
521     /** @}
522     */
523 
524     /**
525         @name Clipping region functions
526 
527         @{
528     */
529 
530     /**
531         Resets the clipping to original shape.
532     */
533     virtual void ResetClip() = 0;
534 
535     /**
536         Sets the clipping region to the intersection of the given region
537         and the previously set clipping region.
538         The clipping region is an area to which drawing is restricted.
539 
540         @remarks
541         - Clipping region should be given in logical coordinates.
542 
543         - Calling this function can only make the clipping region smaller,
544         never larger.
545 
546         - You need to call ResetClip() first if you want to set the clipping
547         region exactly to the region specified.
548 
549         - If resulting clipping region is empty, then all drawing upon the context
550         is clipped out (all changes made by drawing operations are masked out).
551     */
552     virtual void Clip(const wxRegion& region) = 0;
553 
554     /**
555         @overload
556     */
557     virtual void Clip(wxDouble x, wxDouble y, wxDouble w, wxDouble h) = 0;
558 
559     /**
560         Returns bounding box of the current clipping region.
561 
562         @remarks
563         - If clipping region is empty, then empty rectangle is returned
564         (@a x, @a y, @a w, @a h are set to zero).
565 
566         @since 3.1.1
567     */
568     virtual void GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) = 0;
569 
570     /** @}
571     */
572 
573     /**
574         @name Transformation matrix
575 
576         @{
577     */
578 
579     /**
580         Creates a native affine transformation matrix from the passed in
581         values. The default parameters result in an identity matrix.
582     */
583     virtual wxGraphicsMatrix CreateMatrix(wxDouble a = 1.0, wxDouble b = 0.0,
584                                           wxDouble c = 0.0, wxDouble d = 1.0,
585                                           wxDouble tx = 0.0,
586                                           wxDouble ty = 0.0) const;
587 
588     /**
589         Creates a native affine transformation matrix from the passed
590         generic one.
591 
592         @since 2.9.4
593     */
594     wxGraphicsMatrix CreateMatrix(const wxAffineMatrix2DBase& mat) const;
595 
596     /**
597         Concatenates the passed in transform with the current transform of this
598         context.
599     */
600     virtual void ConcatTransform(const wxGraphicsMatrix& matrix) = 0;
601 
602     /**
603         Gets the current transformation matrix of this context.
604     */
605     virtual wxGraphicsMatrix GetTransform() const = 0;
606 
607     /**
608         Rotates the current transformation matrix (in radians).
609     */
610     virtual void Rotate(wxDouble angle) = 0;
611 
612     /**
613         Scales the current transformation matrix.
614     */
615     virtual void Scale(wxDouble xScale, wxDouble yScale) = 0;
616 
617     /**
618         Sets the current transformation matrix of this context
619     */
620     virtual void SetTransform(const wxGraphicsMatrix& matrix) = 0;
621 
622     /**
623         Translates the current transformation matrix.
624     */
625     virtual void Translate(wxDouble dx, wxDouble dy) = 0;
626 
627     /** @}
628     */
629 
630     /**
631         @name Brush and pen functions
632 
633         @{
634     */
635 
636     /**
637         Creates a native brush from a wxBrush.
638     */
639     virtual wxGraphicsBrush CreateBrush(const wxBrush& brush) const;
640 
641     /**
642         Creates a native brush with a linear gradient.
643 
644         The brush starts at (@a x1, @a y1) and ends at (@a x2, @a y2). Either
645         just the start and end gradient colours (@a c1 and @a c2) or full set
646         of gradient @a stops can be specified.
647 
648         The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
649 
650         The @a matrix parameter was added in wxWidgets 3.1.3
651     */
652     wxGraphicsBrush
653     CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
654                               wxDouble x2, wxDouble y2,
655                               const wxColour& c1, const wxColour& c2,
656                               const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix) const;
657 
658     /**
659         @overload
660     */
661     wxGraphicsBrush
662     CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
663                               wxDouble x2, wxDouble y2,
664                               const wxGraphicsGradientStops& stops,
665                               const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix) const;
666 
667     /**
668         Creates a native brush with a radial gradient.
669 
670         The brush originates at (@a startX, @a startY) and ends on a circle around
671         (@a endX, @a endY) with the given @a radius.
672 
673         The gradient may be specified either by its start and end colours @a
674         oColor and @a cColor or by a full set of gradient @a stops.
675 
676         The version taking wxGraphicsGradientStops is new in wxWidgets 2.9.1.
677 
678         The ability to apply a transformation matrix to the gradient was added in 3.1.3
679     */
680     virtual wxGraphicsBrush
681     CreateRadialGradientBrush(wxDouble startX, wxDouble startY,
682                               wxDouble endX, wxDouble endY,
683                               wxDouble radius,
684                               const wxColour& oColor,
685                               const wxColour& cColor,
686                               const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix) const;
687 
688     /**
689         @overload
690     */
691     virtual wxGraphicsBrush
692     CreateRadialGradientBrush(wxDouble startX, wxDouble startY,
693                               wxDouble endX, wxDouble endY,
694                               wxDouble radius,
695                               const wxGraphicsGradientStops& stops,
696                               const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix) = 0;
697 
698     /**
699         Sets the brush for filling paths.
700     */
701     void SetBrush(const wxBrush& brush);
702 
703     /**
704         Sets the brush for filling paths.
705     */
706     virtual void SetBrush(const wxGraphicsBrush& brush);
707 
708     /**
709         Creates a native pen from a wxPen.
710 
711         Prefer to use the overload taking wxGraphicsPenInfo unless you already
712         have a wxPen as constructing one only to pass it to this method is
713         wasteful.
714     */
715     wxGraphicsPen CreatePen(const wxPen& pen) const;
716 
717     /**
718         Creates a native pen from a wxGraphicsPenInfo.
719 
720         @since 3.1.1
721     */
722     wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) const;
723 
724     /**
725         Sets the pen used for stroking.
726     */
727     void SetPen(const wxPen& pen);
728 
729     /**
730         Sets the pen used for stroking.
731     */
732     virtual void SetPen(const wxGraphicsPen& pen);
733 
734     /** @}
735     */
736 
737     /**
738         @name Drawing functions
739 
740         @{
741     */
742 
743     /**
744         Draws the bitmap. In case of a mono bitmap, this is treated as a mask
745         and the current brushed is used for filling.
746     */
747     virtual void DrawBitmap(const wxGraphicsBitmap& bmp,
748                             wxDouble x, wxDouble y,
749                             wxDouble w, wxDouble h ) = 0;
750 
751     /**
752         @overload
753     */
754     virtual void DrawBitmap(const wxBitmap& bmp,
755                             wxDouble x, wxDouble y,
756                             wxDouble w, wxDouble h) = 0;
757 
758     /**
759         Draws an ellipse.
760     */
761     virtual void DrawEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
762 
763     /**
764         Draws the icon.
765     */
766     virtual void DrawIcon(const wxIcon& icon, wxDouble x, wxDouble y,
767                           wxDouble w, wxDouble h) = 0;
768 
769     /**
770         Draws a polygon.
771     */
772     virtual void DrawLines(size_t n, const wxPoint2DDouble* points,
773                            wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
774 
775     /**
776         Draws the path by first filling and then stroking.
777     */
778     virtual void DrawPath(const wxGraphicsPath& path,
779                           wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
780 
781     /**
782         Draws a rectangle.
783     */
784     virtual void DrawRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
785 
786     /**
787         Draws a rounded rectangle.
788     */
789     virtual void DrawRoundedRectangle(wxDouble x, wxDouble y, wxDouble w,
790                                       wxDouble h, wxDouble radius);
791 
792     /**
793         Draws text at the defined position.
794     */
795     void DrawText(const wxString& str, wxDouble x, wxDouble y);
796 
797     /**
798         Draws text at the defined position.
799 
800         @param str
801             The text to draw.
802         @param x
803             The x coordinate position to draw the text at.
804         @param y
805             The y coordinate position to draw the text at.
806         @param angle
807             The angle, in radians, relative to the (default) horizontal
808             direction to draw the string.
809     */
810     void DrawText(const wxString& str, wxDouble x, wxDouble y, wxDouble angle);
811 
812     /**
813         Draws text at the defined position.
814 
815         @param str
816             The text to draw.
817         @param x
818             The x coordinate position to draw the text at.
819         @param y
820             The y coordinate position to draw the text at.
821         @param backgroundBrush
822             Brush to fill the text with.
823     */
824     void DrawText(const wxString& str, wxDouble x, wxDouble y,
825                   const wxGraphicsBrush& backgroundBrush);
826     /**
827         Draws text at the defined position.
828 
829         @param str
830             The text to draw.
831         @param x
832             The x coordinate position to draw the text at.
833         @param y
834             The y coordinate position to draw the text at.
835         @param angle
836             The angle, in radians, relative to the (default) horizontal
837             direction to draw the string.
838         @param backgroundBrush
839             Brush to fill the text with.
840     */
841     void DrawText(const wxString& str, wxDouble x, wxDouble y,
842                   wxDouble angle, const wxGraphicsBrush& backgroundBrush);
843 
844     /**
845         Creates a native graphics path which is initially empty.
846     */
847     wxGraphicsPath CreatePath() const;
848 
849     /**
850         Fills the path with the current brush.
851     */
852     virtual void FillPath(const wxGraphicsPath& path,
853                           wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0;
854 
855     /**
856         Strokes a single line.
857     */
858     virtual void StrokeLine(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2);
859 
860     /**
861         Stroke disconnected lines from begin to end points, fastest method
862         available for this purpose.
863     */
864 
865     virtual void StrokeLines(size_t n, const wxPoint2DDouble* beginPoints,
866                              const wxPoint2DDouble* endPoints);
867     /**
868         Stroke lines connecting all the points.
869 
870         Unlike the other overload of this function, this method draws a single
871         polyline and not a number of disconnected lines.
872     */
873     virtual void StrokeLines(size_t n, const wxPoint2DDouble* points);
874 
875     /**
876         Strokes along a path with the current pen.
877     */
878     virtual void StrokePath(const wxGraphicsPath& path) = 0;
879 
880     /** @}
881     */
882 
883     /**
884         @name Text functions
885 
886         @{
887     */
888 
889     /**
890         Creates a native graphics font from a wxFont and a text colour.
891 
892         @remarks
893         For Direct2D graphics fonts can be created from TrueType fonts only.
894     */
895     virtual wxGraphicsFont CreateFont(const wxFont& font,
896                                       const wxColour& col = *wxBLACK) const;
897 
898     /**
899         Creates a font object with the specified attributes.
900 
901         The use of overload taking wxFont is preferred, see
902         wxGraphicsRenderer::CreateFont() for more details.
903 
904         @remarks
905         For Direct2D graphics fonts can be created from TrueType fonts only.
906 
907         @since 2.9.3
908     */
909     virtual wxGraphicsFont CreateFont(double sizeInPixels,
910                                       const wxString& facename,
911                                       int flags = wxFONTFLAG_DEFAULT,
912                                       const wxColour& col = *wxBLACK) const;
913 
914     /**
915         Sets the font for drawing text.
916 
917         @remarks
918         For Direct2D only TrueType fonts can be used.
919     */
920     void SetFont(const wxFont& font, const wxColour& colour);
921 
922     /**
923         Sets the font for drawing text.
924     */
925     virtual void SetFont(const wxGraphicsFont& font);
926 
927     /**
928         Fills the @a widths array with the widths from the beginning of
929         @a text to the corresponding character of @a text.
930     */
931     virtual void GetPartialTextExtents(const wxString& text,
932                                        wxArrayDouble& widths) const = 0;
933 
934     /**
935         Gets the dimensions of the string using the currently selected font.
936 
937         @param text
938             The text string to measure.
939         @param width
940             Variable to store the total calculated width of the text.
941         @param height
942             Variable to store the total calculated height of the text.
943         @param descent
944             Variable to store the dimension from the baseline of the font to
945             the bottom of the descender.
946         @param externalLeading
947             Any extra vertical space added to the font by the font designer
948             (usually is zero).
949     */
950     virtual void GetTextExtent(const wxString& text, wxDouble* width,
951                                wxDouble* height, wxDouble* descent,
952                                wxDouble* externalLeading) const = 0;
953 
954     /** @}
955     */
956 
957     /**
958         @name Page and document start/end functions
959 
960         @{
961     */
962 
963     /**
964        Begin a new document (relevant only for printing / pdf etc.)
965        If there is a progress dialog, message will be shown.
966     */
967     virtual bool StartDoc( const wxString& message );
968 
969     /**
970        Done with that document (relevant only for printing / pdf etc.)
971     */
972     virtual void EndDoc();
973 
974     /**
975        Opens a new page (relevant only for printing / pdf etc.) with the given
976        size in points.  (If both are null the default page size will be used.)
977     */
978     virtual void StartPage( wxDouble width = 0, wxDouble height = 0 );
979 
980     /**
981        Ends the current page  (relevant only for printing / pdf etc.)
982     */
983     virtual void EndPage();
984 
985     /** @}
986     */
987 
988     /**
989         @name Bitmap functions
990 
991         @{
992     */
993 
994     /**
995         Creates wxGraphicsBitmap from an existing wxBitmap.
996 
997         Returns an invalid wxNullGraphicsBitmap on failure.
998      */
999     virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0;
1000 
1001     /**
1002         Creates wxGraphicsBitmap from an existing wxImage.
1003 
1004         This method is more efficient than converting wxImage to wxBitmap first
1005         and then calling CreateBitmap() but otherwise has the same effect.
1006 
1007         Returns an invalid wxNullGraphicsBitmap on failure.
1008 
1009         @since 2.9.3
1010      */
1011     virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image);
1012 
1013     /**
1014         Extracts a sub-bitmap from an existing bitmap.
1015      */
1016     virtual wxGraphicsBitmap CreateSubBitmap(const wxGraphicsBitmap& bitmap,
1017                                              wxDouble x, wxDouble y,
1018                                              wxDouble w, wxDouble h) = 0;
1019 
1020     /** @}
1021     */
1022 
1023     /**
1024         @name Modifying the state
1025 
1026         @{
1027     */
1028 
1029     /**
1030         All rendering will be done into a fully transparent temporary context.
1031         Layers can be nested by making balanced calls to BeginLayer()/EndLayer().
1032     */
1033     virtual void BeginLayer(wxDouble opacity) = 0;
1034 
1035     /**
1036         Composites back the drawings into the context with the opacity given at
1037         the BeginLayer() call.
1038     */
1039     virtual void EndLayer() = 0;
1040 
1041     /**
1042        Push the current state (like transformations, clipping region and quality
1043        settings) of the context on a stack.
1044        Multiple balanced calls to PushState() and PopState() can be nested.
1045 
1046        @see PopState()
1047     */
1048     virtual void PushState() = 0;
1049 
1050     /**
1051        Sets current state of the context to the state saved by a preceding call
1052        to PushState() and removes that state from the stack of saved states.
1053 
1054        @see PushState()
1055     */
1056     virtual void PopState() = 0;
1057 
1058     /**
1059        Make sure that the current content of this context is immediately visible.
1060     */
1061     virtual void Flush();
1062 
1063     /** @}
1064     */
1065 
1066     /**
1067         @name Getting/setting parameters
1068 
1069         @{
1070     */
1071 
1072     /**
1073         Returns the native context (CGContextRef for Core Graphics, Graphics
1074         pointer for GDIPlus and cairo_t pointer for cairo).
1075     */
1076     virtual void* GetNativeContext() = 0;
1077 
1078     /**
1079         Sets the antialiasing mode, returns true if it supported
1080     */
1081     virtual bool SetAntialiasMode(wxAntialiasMode antialias) = 0;
1082 
1083     /**
1084         Returns the current shape antialiasing mode
1085     */
1086     virtual wxAntialiasMode GetAntialiasMode() const ;
1087 
1088     /**
1089         Sets the interpolation quality, returns true if it is supported.
1090 
1091         @remarks
1092         Not implemented in Cairo backend currently.
1093      */
1094     virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) = 0;
1095 
1096     /**
1097         Returns the current interpolation quality.
1098      */
1099     virtual wxInterpolationQuality GetInterpolationQuality() const;
1100 
1101     /**
1102         Sets the compositing operator, returns true if it supported
1103     */
1104     virtual bool SetCompositionMode(wxCompositionMode op) = 0;
1105 
1106     /**
1107         Returns the current compositing operator
1108     */
1109     virtual wxCompositionMode GetCompositionMode() const;
1110 
1111     /**
1112        Returns the size of the graphics context in device coordinates.
1113     */
1114     void GetSize(wxDouble* width, wxDouble* height) const;
1115 
1116     /**
1117        Returns the resolution of the graphics context in device points per inch.
1118     */
1119     virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY) const;
1120 
1121     /**
1122         Returns the associated window if any.
1123 
1124         If this context was created using Create() overload taking wxWindow or
1125         wxWindowDC, this method returns the corresponding window. Otherwise
1126         returns @NULL.
1127 
1128         @return A possibly @NULL window pointer.
1129 
1130         @since 3.1.2
1131      */
1132     wxWindow* GetWindow() const;
1133 
1134     /** @}
1135     */
1136 
1137     /**
1138         @name Offset management
1139 
1140         @{
1141     */
1142 
1143     /**
1144         Helper to determine if a 0.5 offset should be applied
1145         for the drawing operation.
1146     */
1147     virtual bool ShouldOffset() const;
1148 
1149     /**
1150         Indicates whether the context should try to offset for pixel
1151         boundaries. This only makes sense on bitmap devices like screen.
1152         By default this is turned off.
1153     */
1154     virtual void EnableOffset(bool enable = true);
1155 
1156     void DisableOffset();
1157     bool OffsetEnabled() const;
1158 
1159     /** @}
1160     */
1161 };
1162 
1163 /**
1164     Represents a single gradient stop in a collection of gradient stops as
1165     represented by wxGraphicsGradientStops.
1166 
1167     @library{wxcore}
1168     @category{gdi}
1169 
1170     @since 2.9.1
1171 */
1172 class wxGraphicsGradientStop
1173 {
1174 public:
1175     /**
1176         Creates a stop with the given colour and position.
1177 
1178         @param col The colour of this stop. Note that the alpha component of
1179             the colour is honoured thus allowing the background colours to
1180             partially show through the gradient.
1181         @param pos The stop position, must be in [0, 1] range with 0 being the
1182             beginning and 1 the end of the gradient.
1183     */
1184     wxGraphicsGradientStop(wxColour col = wxTransparentColour, float pos = 0.);
1185 
1186     /// Return the stop colour.
1187     const wxColour& GetColour() const;
1188 
1189     /**
1190         Change the stop colour.
1191 
1192         @param col The new colour.
1193     */
1194     void SetColour(const wxColour& col);
1195 
1196     /// Return the stop position.
1197     float GetPosition() const;
1198 
1199     /**
1200         Change the stop position.
1201 
1202         @param pos The new position, must always be in [0, 1] range.
1203     */
1204     void SetPosition(float pos);
1205 };
1206 
1207 /**
1208     Represents a collection of wxGraphicGradientStop values for use with
1209     CreateLinearGradientBrush and CreateRadialGradientBrush.
1210 
1211     The stops are maintained in order of position.  If two or more stops are
1212     added with the same position then the one(s) added later come later.
1213     This can be useful for producing discontinuities in the colour gradient.
1214 
1215     Notice that this class is write-once, you can't modify the stops once they
1216     had been added.
1217 
1218     @library{wxcore}
1219     @category{gdi}
1220 
1221     @since 2.9.1
1222 */
1223 class wxGraphicsGradientStops
1224 {
1225 public:
1226     /**
1227         Initializes the gradient stops with the given boundary colours.
1228 
1229         Creates a wxGraphicsGradientStops instance with start colour given
1230         by @a startCol and end colour given by @a endCol.
1231     */
1232     wxGraphicsGradientStops(wxColour startCol = wxTransparentColour,
1233                             wxColour endCol = wxTransparentColour);
1234 
1235     /**
1236         Add a new stop.
1237     */
1238     //@{
1239     void Add(const wxGraphicsGradientStop& stop);
1240     void Add(wxColour col, float pos);
1241     //@}
1242 
1243     /**
1244         Returns the stop at the given index.
1245 
1246         @param n The index, must be in [0, GetCount()) range.
1247     */
1248     wxGraphicsGradientStop Item(unsigned n) const;
1249 
1250     /**
1251         Returns the number of stops.
1252     */
1253     size_t GetCount() const;
1254 
1255     /**
1256         Set the start colour to @a col
1257     */
1258     void SetStartColour(wxColour col);
1259 
1260     /**
1261         Returns the start colour.
1262     */
1263     wxColour GetStartColour() const;
1264 
1265     /**
1266         Set the end colour to @a col
1267     */
1268     void SetEndColour(wxColour col);
1269 
1270     /**
1271         Returns the end colour.
1272     */
1273     wxColour GetEndColour() const;
1274 };
1275 
1276 /**
1277     @class wxGraphicsRenderer
1278 
1279     A wxGraphicsRenderer is the instance corresponding to the rendering engine
1280     used. There may be multiple instances on a system, if there are different
1281     rendering engines present, but there is always only one instance per
1282     engine. This instance is pointed back to by all objects created by it
1283     (wxGraphicsContext, wxGraphicsPath etc.) and can be retrieved through their
1284     wxGraphicsObject::GetRenderer() method. Therefore you can create an
1285     additional instance of a path etc. by calling
1286     wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX()
1287     function of that renderer.
1288 
1289     @code
1290     wxGraphicsPath *path = // from somewhere
1291     wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH );
1292     @endcode
1293 
1294     @library{wxcore}
1295     @category{gdi}
1296 */
1297 class wxGraphicsRenderer : public wxObject
1298 {
1299 public:
1300     /**
1301         Creates wxGraphicsBitmap from an existing wxBitmap.
1302 
1303         Returns an invalid wxNullGraphicsBitmap on failure.
1304      */
1305     virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0;
1306 
1307     /**
1308         Creates wxGraphicsBitmap from an existing wxImage.
1309 
1310         This method is more efficient than converting wxImage to wxBitmap first
1311         and then calling CreateBitmap() but otherwise has the same effect.
1312 
1313         Returns an invalid wxNullGraphicsBitmap on failure.
1314 
1315         @since 2.9.3
1316      */
1317     virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image) = 0;
1318 
1319     /**
1320        Creates a wxImage from a wxGraphicsBitmap.
1321 
1322        This method is used by the more convenient wxGraphicsBitmap::ConvertToImage.
1323     */
1324     virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp) = 0;
1325 
1326     /**
1327         Creates wxGraphicsBitmap from a native bitmap handle.
1328 
1329         @a bitmap meaning is platform-dependent. Currently it's a GDI+ @c
1330         Bitmap pointer under MSW, @c CGImage pointer under macOS or a @c
1331         cairo_surface_t pointer when using Cairo under any platform.
1332 
1333         Notice that this method takes ownership of @a bitmap, i.e. it will be
1334         destroyed when the returned wxGraphicsBitmap is.
1335      */
1336     virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap( void* bitmap ) = 0;
1337 
1338     /**
1339         Creates a wxGraphicsContext from a wxWindow.
1340     */
1341     virtual wxGraphicsContext* CreateContext(wxWindow* window) = 0;
1342 
1343     /**
1344         Creates a wxGraphicsContext from a wxWindowDC
1345     */
1346     virtual wxGraphicsContext* CreateContext(const wxWindowDC& windowDC) = 0 ;
1347 
1348     /**
1349         Creates a wxGraphicsContext from a wxMemoryDC
1350     */
1351     virtual wxGraphicsContext* CreateContext(const wxMemoryDC& memoryDC) = 0 ;
1352 
1353     /**
1354         Creates a wxGraphicsContext from a wxPrinterDC.
1355         @remarks Not implemented for Direct2D renderer (on MSW).
1356     */
1357     virtual wxGraphicsContext* CreateContext(const wxPrinterDC& printerDC) = 0 ;
1358 
1359     /**
1360         Creates a wxGraphicsContext from a wxEnhMetaFileDC.
1361 
1362         This function, as wxEnhMetaFileDC class itself, is only available only
1363         under MSW (but not for Direct2D renderer).
1364     */
1365     virtual wxGraphicsContext* CreateContext(const wxEnhMetaFileDC& metaFileDC) = 0;
1366 
1367     /**
1368         Creates a wxGraphicsContext from a DC of unknown specific type.
1369 
1370         Creates a wxGraphicsContext if @a dc is a supported type (i.e. has a
1371         corresponding CreateContext() method, e.g. wxWindowDC or wxMemoryDC).
1372         Returns @NULL if the DC is unsupported.
1373 
1374         This method is only useful as a helper in generic code that operates
1375         with wxDC and doesn't known its exact type. Use the appropriate
1376         CreateContext() overload instead if you know that the DC is e.g.
1377         wxWindowDC.
1378 
1379         @see wxGraphicsContext::CreateFromUnknownDC()
1380 
1381         @since 3.1.3
1382      */
1383      wxGraphicsContext* CreateContextFromUnknownDC(wxDC& dc);
1384 
1385     /**
1386         Creates a wxGraphicsContext associated with a wxImage.
1387 
1388         This function is used by wxContext::CreateFromImage() and is not
1389         normally called directly.
1390 
1391         @since 2.9.3
1392      */
1393     wxGraphicsContext* CreateContextFromImage(wxImage& image);
1394 
1395     /**
1396         Creates a native brush from a wxBrush.
1397     */
1398     virtual wxGraphicsBrush CreateBrush(const wxBrush& brush) = 0;
1399 
1400     /**
1401         Creates a wxGraphicsContext from a native context. This native context
1402         must be a CGContextRef for Core Graphics, a Graphics pointer for
1403         GDIPlus, an ID2D1RenderTarget pointer for Direct2D, a cairo_t pointer
1404         or HDC for Cairo on MSW, or a cairo_t pointer for Cairo on any other
1405         platform.
1406     */
1407     virtual wxGraphicsContext* CreateContextFromNativeContext(void* context) = 0;
1408 
1409     /**
1410         Creates a wxGraphicsContext from a native window.
1411     */
1412     virtual wxGraphicsContext* CreateContextFromNativeWindow(void* window) = 0;
1413 
1414     /**
1415         Creates a wxGraphicsContext from a native DC handle. Windows only.
1416 
1417         @since 3.1.1
1418     */
1419     static wxGraphicsContext* CreateContextFromNativeHDC(WXHDC dc);
1420 
1421     /**
1422         Creates a wxGraphicsContext that can be used for measuring texts only.
1423         No drawing commands are allowed.
1424     */
1425     virtual wxGraphicsContext * CreateMeasuringContext() = 0;
1426 
1427     /**
1428         Creates a native graphics font from a wxFont and a text colour.
1429     */
1430     virtual wxGraphicsFont CreateFont(const wxFont& font,
1431                                       const wxColour& col = *wxBLACK) = 0;
1432 
1433     /**
1434         Creates a graphics font with the given characteristics.
1435 
1436         If possible, the CreateFont() overload taking wxFont should be used
1437         instead. The main advantage of this overload is that it can be used
1438         without X server connection under Unix when using Cairo.
1439 
1440         @param sizeInPixels
1441             Height of the font in user space units, i.e. normally pixels.
1442             Notice that this is different from the overload taking wxFont as
1443             wxFont size is specified in points.
1444         @param facename
1445             The name of the font. The same font name might not be available
1446             under all platforms so the font name can also be empty to use the
1447             default platform font.
1448         @param flags
1449             Combination of wxFontFlag enum elements. Currently only
1450             @c wxFONTFLAG_ITALIC and @c wxFONTFLAG_BOLD are supported. By
1451             default the normal font version is used.
1452         @param col
1453             The font colour, black by default.
1454 
1455         @since 2.9.3
1456      */
1457     virtual wxGraphicsFont CreateFont(double sizeInPixels,
1458                                       const wxString& facename,
1459                                       int flags = wxFONTFLAG_DEFAULT,
1460                                       const wxColour& col = *wxBLACK) = 0;
1461 
1462     /**
1463         Creates a native graphics font from a wxFont and a text colour.
1464 
1465         The specified DPI is used to convert the (fractional) wxFont point-size
1466         to a fractional pixel-size.
1467 
1468         @since 3.1.3
1469     */
1470     virtual wxGraphicsFont CreateFontAtDPI(const wxFont& font,
1471                                            const wxRealPoint& dpi,
1472                                            const wxColour& col = *wxBLACK) = 0;
1473 
1474     /**
1475         Creates a native brush with a linear gradient.
1476 
1477         Stops support is new since wxWidgets 2.9.1, previously only the start
1478         and end colours could be specified.
1479 
1480         The ability to apply a transformation matrix to the gradient was added in 3.1.3
1481 
1482     */
1483     virtual wxGraphicsBrush CreateLinearGradientBrush(wxDouble x1,
1484                                                       wxDouble y1,
1485                                                       wxDouble x2,
1486                                                       wxDouble y2,
1487                                                       const wxGraphicsGradientStops& stops,
1488                                                       const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix) = 0;
1489 
1490     /**
1491         Creates a native affine transformation matrix from the passed in
1492         values. The defaults result in an identity matrix.
1493     */
1494     virtual wxGraphicsMatrix CreateMatrix(wxDouble a = 1.0, wxDouble b = 0.0,
1495                                           wxDouble c = 0.0, wxDouble d = 1.0,
1496                                           wxDouble tx = 0.0,
1497                                           wxDouble ty = 0.0) = 0;
1498 
1499     /**
1500         Creates a native graphics path which is initially empty.
1501     */
1502     virtual wxGraphicsPath CreatePath() = 0;
1503 
1504     /**
1505         Creates a native pen from its description.
1506 
1507         @since 3.1.1
1508     */
1509     virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) = 0;
1510 
1511     /**
1512         Creates a native brush with a radial gradient.
1513 
1514         Stops support is new since wxWidgets 2.9.1, previously only the start
1515         and end colours could be specified.
1516 
1517         The ability to apply a transformation matrix to the gradient was added in 3.1.3
1518     */
1519     virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble startX, wxDouble startY,
1520                                                       wxDouble endX, wxDouble endY,
1521                                                       wxDouble radius,
1522                                                       const wxGraphicsGradientStops& stops,
1523                                                       const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix) = 0;
1524 
1525     /**
1526         Extracts a sub-bitmap from an existing bitmap.
1527      */
1528     virtual wxGraphicsBitmap CreateSubBitmap(const wxGraphicsBitmap& bitmap,
1529                                              wxDouble x, wxDouble y,
1530                                              wxDouble w, wxDouble h) = 0;
1531 
1532     /**
1533         Returns the name of the technology used by the renderer.
1534 
1535         Currently this function returns "gdiplus" for Windows GDI+
1536         implementation, "direct2d" for Windows Direct2D implementation,
1537         "cairo" for Cairo implementation and "cg" for macOS CoreGraphics
1538         implementation.
1539 
1540         @remarks The string returned by this method is not user-readable and is
1541         expected to be used internally by the program only.
1542 
1543         @since 3.1.0
1544      */
1545     virtual wxString GetName() const = 0;
1546 
1547     /**
1548         Returns the version major, minor and micro/build of the technology used
1549         by the renderer.
1550 
1551         Currently this function returns the OS major and minor versions in
1552         the parameters with the matching names and sets @a micro to 0 for
1553         the GDI+ and CoreGraphics engines which are considered to be parts of
1554         their respective OS.
1555 
1556         For Cairo, this is the major,minor,micro version of the Cairo library
1557         which is returned.
1558      */
1559     virtual void GetVersion(int* major, int* minor = NULL, int* micro=NULL) const = 0;
1560 
1561     /**
1562         Returns the default renderer on this platform. On macOS this is the Core
1563         Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and
1564         on GTK we currently default to the Cairo renderer.
1565     */
1566     static wxGraphicsRenderer* GetDefaultRenderer();
1567     /**
1568         Returns Cairo renderer.
1569     */
1570     static wxGraphicsRenderer* GetCairoRenderer();
1571     /**
1572         Returns GDI+ renderer (MSW only).
1573     */
1574     static wxGraphicsRenderer* GetGDIPlusRenderer();
1575     /**
1576         Returns Direct2D renderer (MSW only).
1577     */
1578     static wxGraphicsRenderer* GetDirect2DRenderer();
1579 };
1580 
1581 
1582 
1583 /**
1584     @class wxGraphicsBrush
1585 
1586     A wxGraphicsBrush is a native representation of a brush. The contents are
1587     specific and private to the respective renderer. Instances are ref counted
1588     and can therefore be assigned as usual. The only way to get a valid
1589     instance is via wxGraphicsContext::CreateBrush() or
1590     wxGraphicsRenderer::CreateBrush().
1591 
1592     @library{wxcore}
1593     @category{gdi}
1594 */
1595 class wxGraphicsBrush : public wxGraphicsObject
1596 {
1597 public:
1598 
1599 };
1600 
1601 
1602 
1603 /**
1604     @class wxGraphicsFont
1605 
1606     A wxGraphicsFont is a native representation of a font. The contents are
1607     specific and private to the respective renderer. Instances are ref counted
1608     and can therefore be assigned as usual. The only way to get a valid
1609     instance is via wxGraphicsContext::CreateFont() or
1610     wxGraphicsRenderer::CreateFont().
1611 
1612     @library{wxcore}
1613     @category{gdi}
1614 */
1615 class wxGraphicsFont : public wxGraphicsObject
1616 {
1617 public:
1618 
1619 };
1620 
1621 
1622 
1623 /**
1624     @class wxGraphicsPenInfo
1625 
1626     This class is a helper used for wxGraphicsPen creation using named parameter
1627     idiom: it allows specifying various wxGraphicsPen attributes using the chained
1628     calls to its clearly named methods instead of passing them in the fixed
1629     order to wxGraphicsPen constructors.
1630 
1631     Typically you would use wxGraphicsPenInfo with a wxGraphicsContext, e.g. to
1632     start drawing with a dotted blue pen slightly wider than normal you could
1633     write the following:
1634     @code
1635     wxGraphicsContext ctx = wxGraphicsContext::Create(dc);
1636 
1637     ctx.SetPen(wxGraphicsPenInfo(*wxBLUE).Width(1.25).Style(wxPENSTYLE_DOT));
1638     @endcode
1639 
1640     @since 3.1.1
1641  */
1642 class wxGraphicsPenInfo
1643 {
1644 public:
1645     explicit wxGraphicsPenInfo(const wxColour& colour = wxColour(),
1646                                wxDouble width = 1.0,
1647                                wxPenStyle style = wxPENSTYLE_SOLID);
1648 
1649     wxGraphicsPenInfo& Colour(const wxColour& col);
1650 
1651     wxGraphicsPenInfo& Width(wxDouble width);
1652 
1653     wxGraphicsPenInfo& Style(wxPenStyle style);
1654 
1655     wxGraphicsPenInfo& Stipple(const wxBitmap& stipple);
1656 
1657     wxGraphicsPenInfo& Dashes(int nb_dashes, const wxDash *dash);
1658 
1659     wxGraphicsPenInfo& Join(wxPenJoin join);
1660 
1661     wxGraphicsPenInfo& Cap(wxPenCap cap);
1662 
1663     wxGraphicsPenInfo&
1664     LinearGradient(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
1665                    const wxColour& c1, const wxColour& c2,
1666                    const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix);
1667 
1668     wxGraphicsPenInfo&
1669     LinearGradient(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
1670                    const wxGraphicsGradientStops& stops,
1671                    const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix);
1672 
1673     wxGraphicsPenInfo&
1674     RadialGradient(wxDouble startX, wxDouble startY,
1675                    wxDouble endX, wxDouble endY, wxDouble radius,
1676                    const wxColour& oColor, const wxColour& cColor,
1677                    const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix);
1678 
1679     wxGraphicsPenInfo&
1680     RadialGradient(wxDouble startX, wxDouble startY,
1681                    wxDouble endX, wxDouble endY,
1682                    wxDouble radius, const wxGraphicsGradientStops& stops,
1683                    const wxGraphicsMatrix& matrix = wxNullGraphicsMatrix);
1684 
1685     wxColour GetColour() const;
1686     wxBitmap GetStipple() const;
1687     wxPenStyle GetStyle() const;
1688     wxPenJoin GetJoin() const;
1689     wxPenCap GetCap() const;
1690     int GetDashes(wxDash **ptr);
1691     int GetDashCount() const;
1692     wxDash* GetDash() const;
1693     bool IsTransparent() const;
1694     wxDouble GetWidth() const;
1695     wxGradientType GetGradientType() const;
1696     wxDouble GetX1() const;
1697     wxDouble GetY1() const;
1698     wxDouble GetX2() const;
1699     wxDouble GetY2() const;
1700     wxDouble GetStartX() const;
1701     wxDouble GetStartY() const;
1702     wxDouble GetEndX() const;
1703     wxDouble GetEndY() const;
1704     wxDouble GetRadius() const;
1705     const wxGraphicsGradientStops& GetStops() const;
1706 };
1707 
1708 
1709 
1710 /**
1711     @class wxGraphicsPen
1712 
1713     A wxGraphicsPen is a native representation of a pen. The contents are
1714     specific and private to the respective renderer. Instances are ref counted
1715     and can therefore be assigned as usual. The only way to get a valid
1716     instance is via wxGraphicsContext::CreatePen() or
1717     wxGraphicsRenderer::CreatePen().
1718 
1719     @library{wxcore}
1720     @category{gdi}
1721 */
1722 class wxGraphicsPen : public wxGraphicsObject
1723 {
1724 public:
1725 
1726 };
1727 
1728 
1729 
1730 /**
1731     @class wxGraphicsMatrix
1732 
1733     A wxGraphicsMatrix is a native representation of an affine matrix. The
1734     contents are specific and private to the respective renderer. Instances are
1735     ref counted and can therefore be assigned as usual. The only way to get a
1736     valid instance is via wxGraphicsContext::CreateMatrix() or
1737     wxGraphicsRenderer::CreateMatrix().
1738 
1739     @library{wxcore}
1740     @category{gdi}
1741 */
1742 class wxGraphicsMatrix : public wxGraphicsObject
1743 {
1744 public:
1745     /**
1746         Concatenates the matrix passed with the current matrix.
1747         The effect of the resulting transformation is to first apply
1748         the transformation in @a t to the coordinates and then apply
1749         the transformation in the current matrix to the coordinates.
1750 
1751         @code
1752         // matrix = t x matrix
1753         @endcode
1754 
1755         @param t
1756             The parameter matrix is the multiplicand.
1757     */
1758     virtual void Concat(const wxGraphicsMatrix* t);
1759 
1760     /**
1761         @overload
1762     */
1763     void Concat(const wxGraphicsMatrix& t);
1764 
1765     /**
1766         Returns the component values of the matrix via the argument pointers.
1767     */
1768     virtual void Get(wxDouble* a = NULL, wxDouble* b = NULL,
1769                      wxDouble* c = NULL, wxDouble* d = NULL,
1770                      wxDouble* tx = NULL, wxDouble* ty = NULL) const;
1771 
1772     /**
1773         Returns the native representation of the matrix. For CoreGraphics this
1774         is a CFAffineMatrix pointer, for GDIPlus a Matrix Pointer, and for
1775         Cairo a cairo_matrix_t pointer.
1776     */
1777     virtual void* GetNativeMatrix() const;
1778 
1779     /**
1780         Inverts the matrix.
1781     */
1782     virtual void Invert();
1783 
1784     /**
1785         Returns @true if the elements of the transformation matrix are equal.
1786     */
1787     virtual bool IsEqual(const wxGraphicsMatrix* t) const;
1788     /**
1789         Returns @true if the elements of the transformation matrix are equal.
1790     */
1791     bool IsEqual(const wxGraphicsMatrix& t) const;
1792 
1793     /**
1794         Return @true if this is the identity matrix.
1795     */
1796     virtual bool IsIdentity() const;
1797 
1798     /**
1799         Rotates this matrix clockwise (in radians).
1800 
1801         @param angle
1802             Rotation angle in radians, clockwise.
1803     */
1804     virtual void Rotate(wxDouble angle);
1805 
1806     /**
1807         Scales this matrix.
1808     */
1809     virtual void Scale(wxDouble xScale, wxDouble yScale);
1810 
1811     /**
1812         Sets the matrix to the respective values (default values are the
1813         identity matrix).
1814     */
1815     virtual void Set(wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0,
1816                      wxDouble d = 1.0, wxDouble tx = 0.0, wxDouble ty = 0.0);
1817 
1818     /**
1819         Applies this matrix to a distance (ie. performs all transforms except
1820         translations).
1821     */
1822     virtual void TransformDistance(wxDouble* dx, wxDouble* dy) const;
1823 
1824     /**
1825         Applies this matrix to a point.
1826     */
1827     virtual void TransformPoint(wxDouble* x, wxDouble* y) const;
1828 
1829     /**
1830         Translates this matrix.
1831     */
1832     virtual void Translate(wxDouble dx, wxDouble dy);
1833 };
1834 
1835 
1836 const wxGraphicsPen     wxNullGraphicsPen;
1837 const wxGraphicsBrush   wxNullGraphicsBrush;
1838 const wxGraphicsFont    wxNullGraphicsFont;
1839 const wxGraphicsBitmap  wxNullGraphicsBitmap;
1840 const wxGraphicsMatrix  wxNullGraphicsMatrix;
1841 const wxGraphicsPath    wxNullGraphicsPath;
1842