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:
parent
af3581758b
commit
76fd05b147
@ -58,6 +58,10 @@ Changes in behaviour which may result in build errors
|
||||
- Never documented and not always available private wxGetClipboardData()
|
||||
function now doesn't exist at all any more in wxMSW, use wxClipboard instead.
|
||||
|
||||
- wxGraphicsRenderer::CreatePen() now takes wxGraphicsPenInfo and not a wxPen.
|
||||
This only affects code defining its own custom renderers, code just using
|
||||
wxGraphicsContext::CreatePen() continues to compile and work as before.
|
||||
|
||||
|
||||
3.1.1: (not released yet)
|
||||
----------------------------
|
||||
|
@ -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;
|
||||
|
@ -677,13 +677,19 @@ public:
|
||||
|
||||
/**
|
||||
Creates a native pen from a wxPen.
|
||||
|
||||
Prefer to use the overload taking wxGraphicsPenInfo unless you already
|
||||
have a wxPen as constructing one only to pass it to this method is
|
||||
wasteful.
|
||||
*/
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
|
||||
wxGraphicsPen CreatePen(const wxPen& pen) const;
|
||||
|
||||
/**
|
||||
Creates a native pen from a wxGraphicsPenInfo.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) const;
|
||||
wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) const;
|
||||
|
||||
/**
|
||||
Sets the pen used for stroking.
|
||||
@ -1420,9 +1426,11 @@ public:
|
||||
virtual wxGraphicsPath CreatePath() = 0;
|
||||
|
||||
/**
|
||||
Creates a native pen from a wxPen.
|
||||
Creates a native pen from its description.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) = 0;
|
||||
|
||||
/**
|
||||
Creates a native brush with a radial gradient.
|
||||
|
@ -120,6 +120,9 @@ WXDLLIMPEXP_DATA_CORE(wxGraphicsBitmap) wxNullGraphicsBitmap;
|
||||
/* static */
|
||||
wxGraphicsPenInfo wxGraphicsPenInfo::CreateFromPen(const wxPen& pen)
|
||||
{
|
||||
if ( !pen.IsOk() )
|
||||
return wxGraphicsPenInfo().Style(wxPENSTYLE_TRANSPARENT);
|
||||
|
||||
wxDash *dashes;
|
||||
int nb_dashes = pen.GetDashes(&dashes);
|
||||
return wxGraphicsPenInfo()
|
||||
@ -838,12 +841,7 @@ wxGraphicsPath wxGraphicsContext::CreatePath() const
|
||||
return GetRenderer()->CreatePath();
|
||||
}
|
||||
|
||||
wxGraphicsPen wxGraphicsContext::CreatePen(const wxPen& pen) const
|
||||
{
|
||||
return GetRenderer()->CreatePen(pen);
|
||||
}
|
||||
|
||||
wxGraphicsPen wxGraphicsContext::CreatePen(const wxGraphicsPenInfo& info) const
|
||||
wxGraphicsPen wxGraphicsContext::DoCreatePen(const wxGraphicsPenInfo& info) const
|
||||
{
|
||||
return GetRenderer()->CreatePen(info);
|
||||
}
|
||||
|
@ -284,12 +284,10 @@ private:
|
||||
class WXDLLIMPEXP_CORE wxCairoPenData : public wxCairoPenBrushBaseData
|
||||
{
|
||||
public:
|
||||
wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
||||
wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||
~wxCairoPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( const wxGraphicsPenInfo& info );
|
||||
|
||||
virtual void Apply( wxGraphicsContext* context ) wxOVERRIDE;
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
@ -735,19 +733,8 @@ void wxCairoPenData::Init()
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
||||
: wxCairoPenBrushBaseData(renderer, pen.GetColour(), pen.IsTransparent())
|
||||
{
|
||||
InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
|
||||
}
|
||||
|
||||
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||
: wxCairoPenBrushBaseData(renderer, info.GetColour(), info.IsTransparent())
|
||||
{
|
||||
InitFromPenInfo(info);
|
||||
}
|
||||
|
||||
void wxCairoPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
|
||||
{
|
||||
Init();
|
||||
m_width = info.GetWidth();
|
||||
@ -2916,7 +2903,6 @@ public :
|
||||
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
||||
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE ;
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE ;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
||||
@ -3093,17 +3079,6 @@ wxGraphicsMatrix wxCairoRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDouble
|
||||
return m;
|
||||
}
|
||||
|
||||
wxGraphicsPen wxCairoRenderer::CreatePen(const wxPen& pen)
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
ENSURE_LOADED_OR_RETURN(p);
|
||||
if (pen.IsOk() && pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
|
||||
{
|
||||
p.SetRefData(new wxCairoPenData( this, pen ));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
wxGraphicsPen wxCairoRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
|
@ -260,12 +260,10 @@ private:
|
||||
class wxGDIPlusPenData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public:
|
||||
wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
||||
wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||
~wxGDIPlusPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( const wxGraphicsPenInfo &info );
|
||||
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
virtual Pen* GetGDIPlusPen() { return m_pen; }
|
||||
@ -575,8 +573,6 @@ public :
|
||||
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
||||
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& pen) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE;
|
||||
@ -647,20 +643,9 @@ void wxGDIPlusPenData::Init()
|
||||
m_penBrush = NULL;
|
||||
}
|
||||
|
||||
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
||||
: wxGraphicsObjectRefData(renderer)
|
||||
{
|
||||
InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
|
||||
}
|
||||
|
||||
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer,
|
||||
const wxGraphicsPenInfo &info )
|
||||
: wxGraphicsObjectRefData(renderer)
|
||||
{
|
||||
InitFromPenInfo(info);
|
||||
}
|
||||
|
||||
void wxGDIPlusPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
|
||||
{
|
||||
Init();
|
||||
m_width = info.GetWidth();
|
||||
@ -2464,19 +2449,6 @@ wxGraphicsMatrix wxGDIPlusRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDoub
|
||||
return m;
|
||||
}
|
||||
|
||||
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxPen& pen)
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
|
||||
if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
return wxNullGraphicsPen;
|
||||
else
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
p.SetRefData(new wxGDIPlusPenData( this, pen ));
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
|
||||
|
@ -2458,11 +2458,9 @@ wxBrushStyle wxConvertPenStyleToBrushStyle(wxPenStyle penStyle)
|
||||
class wxD2DPenData : public wxGraphicsObjectRefData, public wxD2DManagedGraphicsData
|
||||
{
|
||||
public:
|
||||
wxD2DPenData(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, const wxPen& pen);
|
||||
|
||||
wxD2DPenData(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, const wxGraphicsPenInfo& info);
|
||||
|
||||
void Init(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory);
|
||||
wxD2DPenData(wxGraphicsRenderer* renderer,
|
||||
ID2D1Factory* direct2dFactory,
|
||||
const wxGraphicsPenInfo& info);
|
||||
|
||||
void CreateStrokeStyle(ID2D1Factory* const direct2dfactory);
|
||||
|
||||
@ -2497,17 +2495,6 @@ private:
|
||||
// wxD2DPenData implementation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxD2DPenData::wxD2DPenData(
|
||||
wxGraphicsRenderer* renderer,
|
||||
ID2D1Factory* direct2dFactory,
|
||||
const wxPen& pen)
|
||||
: wxGraphicsObjectRefData(renderer),
|
||||
m_penInfo(wxGraphicsPenInfo::CreateFromPen(pen)),
|
||||
m_width(pen.GetWidth())
|
||||
{
|
||||
Init(renderer, direct2dFactory);
|
||||
}
|
||||
|
||||
wxD2DPenData::wxD2DPenData(
|
||||
wxGraphicsRenderer* renderer,
|
||||
ID2D1Factory* direct2dFactory,
|
||||
@ -2515,13 +2502,6 @@ wxD2DPenData::wxD2DPenData(
|
||||
: wxGraphicsObjectRefData(renderer),
|
||||
m_penInfo(info),
|
||||
m_width(info.GetWidth())
|
||||
{
|
||||
Init(renderer, direct2dFactory);
|
||||
}
|
||||
|
||||
void wxD2DPenData::Init(
|
||||
wxGraphicsRenderer* renderer,
|
||||
ID2D1Factory* direct2dFactory)
|
||||
{
|
||||
CreateStrokeStyle(direct2dFactory);
|
||||
|
||||
@ -4408,8 +4388,6 @@ public :
|
||||
wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0, wxDouble d = 1.0,
|
||||
wxDouble tx = 0.0, wxDouble ty = 0.0) wxOVERRIDE;
|
||||
|
||||
wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE;
|
||||
|
||||
wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE;
|
||||
|
||||
wxGraphicsBrush CreateBrush(const wxBrush& brush) wxOVERRIDE;
|
||||
@ -4579,21 +4557,6 @@ wxGraphicsMatrix wxD2DRenderer::CreateMatrix(
|
||||
return matrix;
|
||||
}
|
||||
|
||||
wxGraphicsPen wxD2DRenderer::CreatePen(const wxPen& pen)
|
||||
{
|
||||
if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
{
|
||||
return wxNullGraphicsPen;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
wxD2DPenData* penData = new wxD2DPenData(this, m_direct2dFactory, pen);
|
||||
p.SetRefData(penData);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsPen wxD2DRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
|
@ -304,12 +304,10 @@ protected :
|
||||
class wxMacCoreGraphicsPenData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public:
|
||||
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
||||
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info );
|
||||
~wxMacCoreGraphicsPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( const wxGraphicsPenInfo& info );
|
||||
virtual void Apply( wxGraphicsContext* context );
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
|
||||
@ -331,20 +329,9 @@ protected :
|
||||
CGFloat* m_patternColorComponents;
|
||||
};
|
||||
|
||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) :
|
||||
wxGraphicsObjectRefData( renderer )
|
||||
{
|
||||
InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
|
||||
}
|
||||
|
||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer,
|
||||
const wxGraphicsPenInfo& info )
|
||||
: wxGraphicsObjectRefData( renderer )
|
||||
{
|
||||
InitFromPenInfo(info);
|
||||
}
|
||||
|
||||
void wxMacCoreGraphicsPenData::InitFromPenInfo( const wxGraphicsPenInfo& info )
|
||||
{
|
||||
Init();
|
||||
|
||||
@ -2550,8 +2537,6 @@ public :
|
||||
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
||||
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE ;
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE ;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
||||
@ -2721,18 +2706,6 @@ wxGraphicsMatrix wxMacCoreGraphicsRenderer::CreateMatrix( wxDouble a, wxDouble b
|
||||
return m;
|
||||
}
|
||||
|
||||
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
|
||||
{
|
||||
if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
return wxNullGraphicsPen;
|
||||
else
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
p.SetRefData(new wxMacCoreGraphicsPenData( this, pen ));
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
if ( info.IsTransparent() )
|
||||
|
Loading…
Reference in New Issue
Block a user