X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c84c7347ba63a08a8a9b426055b7be5a0aca2617..8472511246c9160d4ff40ab86f635fc67c10b54a:/src/common/dcsvg.cpp diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index dcba364827..1be3feb2e7 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -130,6 +130,9 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, dou m_OK = true; + m_clipUniqueId = 0; + m_clipNestingLevel = 0; + m_mm_to_pix_x = dpi/25.4; m_mm_to_pix_y = dpi/25.4; @@ -206,7 +209,7 @@ void wxSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 CalcBoundingBox(x2, y2); } -void wxSVGFileDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxCoord yoffset ) +void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset , wxCoord yoffset ) { for ( int i = 1; i < n; i++ ) { @@ -319,7 +322,7 @@ void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width CalcBoundingBox(x + width, y + height); } -void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], +void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { @@ -470,6 +473,59 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h, } } +void wxSVGFileDCImpl::DoSetClippingRegion( int x, int y, int width, int height ) +{ + wxString svg; + + // End current graphics group to ensure proper xml nesting (e.g. so that + // graphics can be subsequently changed inside the clipping region) + svg << "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; + + write(svg); + + // Re-apply current graphics to ensure proper xml nesting + DoStartNewGraphics(); + + m_clipUniqueId++; + m_clipNestingLevel++; +} + +void wxSVGFileDCImpl::DestroyClippingRegion() +{ + wxString svg; + + // End current graphics element to ensure proper xml nesting (e.g. graphics + // might have been changed inside the clipping region) + svg << "\n"; + + // Close clipping group elements + for ( size_t i = 0; i < m_clipUniqueId; i++ ) + { + svg << ""; + } + svg << "\n"; + + write(svg); + + // Re-apply current graphics (e.g. brush may have been changed inside one + // of the clipped regions - that change will have been lost after xml + // elements for the clipped region have been closed). + DoStartNewGraphics(); + + m_clipUniqueId = 0; +} + void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , const wxFont *font) const { @@ -538,9 +594,16 @@ void wxSVGFileDCImpl::NewGraphicsIfNeeded() m_graphics_changed = false; + write(wxS("\n")); + + DoStartNewGraphics(); +} + +void wxSVGFileDCImpl::DoStartNewGraphics() +{ wxString s, sBrush, sPenCap, sPenJoin, sPenStyle, sLast; - sBrush = wxT("\n