Enable usage of clipping regions in wxSVGFileDC.

It was implemented 3 and half years ago in 614e38d.
Close remaining clipping regions when closing the SVG file.
This commit is contained in:
Maarten Bent
2016-03-15 20:15:07 +01:00
parent 3eae97d2d7
commit ebab640578
2 changed files with 21 additions and 15 deletions

View File

@@ -279,7 +279,13 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, dou
wxSVGFileDCImpl::~wxSVGFileDCImpl()
{
wxString s = wxT("</g> \n</svg> \n");
wxString s;
// Close remaining clipping group elements
for (size_t i = 0; i < m_clipUniqueId; i++)
s += wxS("</g>\n");
s += wxS("</g>\n</svg>\n");
write(s);
delete m_outfile;
}
@@ -617,7 +623,7 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,
}
}
void wxSVGFileDCImpl::DoSetClippingRegion( int x, int y, int width, int height )
void wxSVGFileDCImpl::DoSetClippingRegion(int x, int y, int width, int height)
{
wxString svg;
@@ -625,14 +631,14 @@ void wxSVGFileDCImpl::DoSetClippingRegion( int x, int y, int width, int height
// graphics can be subsequently changed inside the clipping region)
svg << "</g>\n"
"<defs>\n"
"<clipPath id=\"clip" << m_clipNestingLevel << "\">\n"
"<rect id=\"cliprect" << m_clipNestingLevel << "\" "
" <clipPath id=\"clip" << m_clipNestingLevel << "\">\n"
" <rect id=\"cliprect" << m_clipNestingLevel << "\" "
"x=\"" << x << "\" "
"y=\"" << y << "\" "
"width=\"" << width << "\" "
"height=\"" << height << "\" "
"style=\"stroke: gray; fill: none;\"/>\n"
"</clipPath>\n"
" </clipPath>\n"
"</defs>\n"
"<g style=\"clip-path: url(#clip" << m_clipNestingLevel << ");\">\n";
@@ -656,9 +662,8 @@ void wxSVGFileDCImpl::DestroyClippingRegion()
// Close clipping group elements
for ( size_t i = 0; i < m_clipUniqueId; i++ )
{
svg << "</g>";
svg << "</g>\n";
}
svg << "\n";
write(svg);