From 9e07ba8fae0b78c5d0b49d89dcb01084567eda81 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 4 Jun 2016 14:10:46 +0200 Subject: [PATCH] Support SetDeviceOrigin and SetAxisOrientation in wxSVGFileDC. Override SetDeviceOrigin, SetLogicalOrigin and SetAxisOrientation from wxDC and mark the graphics as changed, so the correct transform translations are applied. --- include/wx/dcsvg.h | 18 ++++++++++++++++++ src/common/dcsvg.cpp | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index 79ac74e026..d19bba169c 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -117,6 +117,24 @@ public: return wxCOPY; } + virtual void SetLogicalOrigin(wxCoord x, wxCoord y) wxOVERRIDE + { + wxDCImpl::SetLogicalOrigin(x, y); + m_graphics_changed = true; + } + + virtual void SetDeviceOrigin(wxCoord x, wxCoord y) wxOVERRIDE + { + wxDCImpl::SetDeviceOrigin(x, y); + m_graphics_changed = true; + } + + virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) wxOVERRIDE + { + wxDCImpl::SetAxisOrientation(xLeftRight, yBottomUp); + m_graphics_changed = true; + } + virtual void SetBackground( const wxBrush &brush ) wxOVERRIDE; virtual void SetBackgroundMode( int mode ) wxOVERRIDE; virtual void SetBrush(const wxBrush& brush) wxOVERRIDE; diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 209d35e54a..f93396065f 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -1023,8 +1023,12 @@ void wxSVGFileDCImpl::DoStartNewGraphics() sPenJoin = wxT("stroke-linejoin:round; "); } - sLast.Printf( wxT("stroke-width:%d\" \n transform=\"translate(%s %s) scale(%s %s)\">"), - m_pen.GetWidth(), NumStr(m_logicalOriginX), NumStr(m_logicalOriginY), NumStr(m_scaleX), NumStr(m_scaleY) ); + sLast.Printf(wxT("stroke-width:%d\" transform=\"translate(%s %s) scale(%s %s)\">"), + m_pen.GetWidth(), + NumStr((m_deviceOriginX - m_logicalOriginX)* m_signX), + NumStr((m_deviceOriginY - m_logicalOriginY)* m_signY), + NumStr(m_scaleX * m_signX), + NumStr(m_scaleY * m_signY)); s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + wxT("\n"); write(s);