X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/66815259f590d8a88cab69e0a813bc6e8c6029cc..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/common/dcsvg.cpp diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 494d78b519..85105f91f2 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; @@ -153,21 +156,21 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, dou m_filename = filename; m_sub_images = 0; wxString s; - s = wxT("") + wxString(wxT("\n")); + s = wxT("\n"); write(s); - s = wxT(" ") + wxString(wxT("\n")); + s = wxT("\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"); write(s); - s = wxT(" \n"), NumStr(float(Width)/dpi*2.54), NumStr(float(Height)/dpi*2.54), Width, Height ); + s.Printf( wxT(" width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d \">\n"), NumStr(float(Width)/dpi*2.54), NumStr(float(Height)/dpi*2.54), Width, Height ); write(s); - s = wxT("SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" ") + wxT("\n"); + s = wxT("SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" \n"); write(s); - s = wxString (wxT("Picture generated by wxSVG ")) + wxSVGVersion + wxT(" ")+ wxT("\n"); + s = wxString (wxT("Picture generated by wxSVG ")) + wxSVGVersion + wxT(" \n"); write(s); - s = wxT("") + wxString(wxT("\n")); + s = wxT("\n"); write(s); } } @@ -219,7 +222,7 @@ void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1) { wxString s; NewGraphicsIfNeeded(); - s = wxT(" ") + wxString(wxT("\n")); + s = wxT(" \n"); write(s); DoDrawLine ( x1,y1,x1,y1 ); s = wxT(""); @@ -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; - wxString s, sBrush, sPenCap, sPenJoin, sPenStyle, sLast, sWarn; + write(wxS("\n")); + + DoStartNewGraphics(); +} + +void wxSVGFileDCImpl::DoStartNewGraphics() +{ + wxString s, sBrush, sPenCap, sPenJoin, sPenStyle, sLast; - sBrush = wxT("\n"), m_pen.GetWidth(), NumStr(m_logicalOriginX), NumStr(m_logicalOriginY), NumStr(m_scaleX), NumStr(m_scaleY) ); - s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + wxT("\n") + sWarn; + s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + wxT("\n"); write(s); }