Leave only wxGraphicsRenderer::CreatePen(wxGraphicsPenInfo) overload

It doesn't make much sense to require all the graphics backends to
create wxGraphicsPen from either wxPen or wxGraphicsPenInfo when the
former can be handled just once in the common code.

So do just this, leaving CreatePen() overload taking wxGraphicsPenInfo
where the real pen construction takes place and implementing
wxGraphicsPen creation from wxPen in the common wxGraphicsContext code.

This is not 100% backwards-compatible as any code inheriting from
wxGraphicsRenderer and overriding its CreatePen() will now be broken,
however this should be extremely rare (there is no good reason to
inherit from this class in the user code) and result in compile errors
if it does happen.
This commit is contained in:
Vadim Zeitlin
2017-09-10 01:48:30 +02:00
parent af3581758b
commit 76fd05b147
8 changed files with 29 additions and 134 deletions

View File

@@ -512,9 +512,11 @@ public:
wxGraphicsPath CreatePath() const;
virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
wxGraphicsPen CreatePen(const wxPen& pen) const
{ return DoCreatePen(wxGraphicsPenInfo::CreateFromPen(pen)); }
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& pen) const;
wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) const
{ return DoCreatePen(info); }
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const;
@@ -779,6 +781,8 @@ protected:
// implementations of overloaded public functions: we use different names
// for them to avoid the virtual function hiding problems in the derived
// classes
virtual wxGraphicsPen DoCreatePen(const wxGraphicsPenInfo& info) const;
virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y) = 0;
virtual void DoDrawRotatedText(const wxString& str, wxDouble x, wxDouble y,
wxDouble angle);
@@ -896,8 +900,6 @@ public:
// Paints
virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) = 0;
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0;