Implement wxBRUSHSTYLE_BDIAGONAL_HATCH for wxSVGFileDC

Create new graphics group before writing brush pattern, so pattern appears in
the same group as the elements using it.
This commit is contained in:
Maarten Bent 2019-08-10 20:22:42 +02:00
parent e7c03a5646
commit 9412aea1f6

View File

@ -110,6 +110,7 @@ wxString wxFillString(wxColour c, int style = wxBRUSHSTYLE_SOLID)
switch ( style )
{
case wxBRUSHSTYLE_SOLID:
case wxBRUSHSTYLE_BDIAGONAL_HATCH:
case wxBRUSHSTYLE_FDIAGONAL_HATCH:
case wxBRUSHSTYLE_CROSSDIAG_HATCH:
case wxBRUSHSTYLE_CROSS_HATCH:
@ -236,6 +237,9 @@ wxString wxGetBrushStyleName(wxBrush const& brush)
switch (brush.GetStyle())
{
case wxBRUSHSTYLE_BDIAGONAL_HATCH:
brushStyle = wxS("BdiagonalHatch");
break;
case wxBRUSHSTYLE_FDIAGONAL_HATCH:
brushStyle = wxS("FdiagonalHatch");
break;
@ -254,7 +258,6 @@ wxString wxGetBrushStyleName(wxBrush const& brush)
case wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE:
case wxBRUSHSTYLE_STIPPLE_MASK:
case wxBRUSHSTYLE_STIPPLE:
case wxBRUSHSTYLE_BDIAGONAL_HATCH:
wxASSERT_MSG(false, wxS("wxSVGFileDC::Requested Brush Fill not available"));
break;
case wxBRUSHSTYLE_SOLID:
@ -288,6 +291,9 @@ wxString wxCreateBrushFill(wxBrush& brush)
wxString pattern;
switch (brush.GetStyle())
{
case wxBRUSHSTYLE_BDIAGONAL_HATCH:
pattern = wxS("d=\"M-1,1 l2,-2 M0,8 l8,-8 M7,9 l2,-2\"");
break;
case wxBRUSHSTYLE_FDIAGONAL_HATCH:
pattern = wxS("d=\"M7,-1 l2,2 M0,0 l8,8 M-1,7 l2,2\"");
break;
@ -1079,7 +1085,12 @@ void wxSVGFileDCImpl::SetBrush(const wxBrush& brush)
m_graphics_changed = true;
wxString pattern = wxCreateBrushFill(m_brush);
write(pattern);
if ( !pattern.IsEmpty() )
{
NewGraphicsIfNeeded();
write(pattern);
}
}
void wxSVGFileDCImpl::SetPen(const wxPen& pen)