Process review comments in wxSVGFileDC
This commit is contained in:
@@ -46,9 +46,10 @@ namespace
|
|||||||
// C locale (i.e. always using "." for the decimal separator) and with the
|
// C locale (i.e. always using "." for the decimal separator) and with the
|
||||||
// fixed precision (which is 2 for some unknown reason but this is what it was
|
// fixed precision (which is 2 for some unknown reason but this is what it was
|
||||||
// in this code originally).
|
// in this code originally).
|
||||||
inline wxString NumStr(double const& f)
|
inline wxString NumStr(const double f)
|
||||||
{
|
{
|
||||||
if ( f == 0 )
|
if ( f == 0 )
|
||||||
|
// prevent -0.00
|
||||||
return wxS("0.00");
|
return wxS("0.00");
|
||||||
else
|
else
|
||||||
return wxString::FromCDouble(f, 2);
|
return wxString::FromCDouble(f, 2);
|
||||||
@@ -70,13 +71,13 @@ wxString Col2SVG(wxColour c, float *opacity = NULL)
|
|||||||
else // No alpha.
|
else // No alpha.
|
||||||
{
|
{
|
||||||
if ( opacity )
|
if ( opacity )
|
||||||
*opacity = 1.;
|
*opacity = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.GetAsString(wxC2S_HTML_SYNTAX);
|
return c.GetAsString(wxC2S_HTML_SYNTAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxStrokeString(wxColour const& c, int style = wxPENSTYLE_SOLID)
|
wxString wxStrokeString(const wxColour& c, int style = wxPENSTYLE_SOLID)
|
||||||
{
|
{
|
||||||
float opacity;
|
float opacity;
|
||||||
wxString s = wxS("stroke:") + Col2SVG(c, &opacity) + wxS(";");
|
wxString s = wxS("stroke:") + Col2SVG(c, &opacity) + wxS(";");
|
||||||
@@ -102,7 +103,7 @@ wxString wxStrokeString(wxColour const& c, int style = wxPENSTYLE_SOLID)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFillString(wxColour c, int style = wxBRUSHSTYLE_SOLID)
|
wxString wxFillString(const wxColour& c, int style = wxBRUSHSTYLE_SOLID)
|
||||||
{
|
{
|
||||||
float opacity;
|
float opacity;
|
||||||
wxString s = wxS("fill:") + Col2SVG(c, &opacity) + wxS(";");
|
wxString s = wxS("fill:") + Col2SVG(c, &opacity) + wxS(";");
|
||||||
@@ -129,7 +130,7 @@ wxString wxFillString(wxColour c, int style = wxBRUSHSTYLE_SOLID)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGetPenPattern(wxPen const& pen)
|
wxString wxGetPenPattern(const wxPen& pen)
|
||||||
{
|
{
|
||||||
wxString s;
|
wxString s;
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ wxString wxGetPenPattern(wxPen const& pen)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGetPenStyle(wxPen const& pen)
|
wxString wxGetPenStyle(const wxPen& pen)
|
||||||
{
|
{
|
||||||
wxString penStyle;
|
wxString penStyle;
|
||||||
|
|
||||||
@@ -231,7 +232,7 @@ wxString wxGetPenStyle(wxPen const& pen)
|
|||||||
return penStyle;
|
return penStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGetBrushStyleName(wxBrush const& brush)
|
wxString wxGetBrushStyleName(const wxBrush& brush)
|
||||||
{
|
{
|
||||||
wxString brushStyle;
|
wxString brushStyle;
|
||||||
|
|
||||||
@@ -270,21 +271,22 @@ wxString wxGetBrushStyleName(wxBrush const& brush)
|
|||||||
return brushStyle;
|
return brushStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGetBrushFill(wxBrush const& brush)
|
wxString wxGetBrushFill(const wxBrush& brush)
|
||||||
{
|
{
|
||||||
wxString s;
|
wxString s;
|
||||||
wxString brushStyle = wxGetBrushStyleName(brush);
|
wxString brushStyle = wxGetBrushStyleName(brush);
|
||||||
|
|
||||||
if (!brushStyle.IsEmpty())
|
if (!brushStyle.empty())
|
||||||
s = wxS("fill=\"url(#") + brushStyle + Col2SVG(brush.GetColour()).substr(1) + wxS(")\"");
|
s = wxS("fill=\"url(#") + brushStyle + Col2SVG(brush.GetColour()).substr(1) + wxS(")\"");
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRenderMode(wxSVGShapeRenderingMode const& style)
|
wxString wxRenderMode(const wxSVGShapeRenderingMode style)
|
||||||
{
|
{
|
||||||
wxString mode;
|
wxString mode;
|
||||||
switch (style) {
|
switch (style)
|
||||||
|
{
|
||||||
case wxSVG_SHAPE_RENDERING_OPTIMIZE_SPEED:
|
case wxSVG_SHAPE_RENDERING_OPTIMIZE_SPEED:
|
||||||
mode = wxS("optimizeSpeed");
|
mode = wxS("optimizeSpeed");
|
||||||
break;
|
break;
|
||||||
@@ -295,7 +297,6 @@ wxString wxRenderMode(wxSVGShapeRenderingMode const& style)
|
|||||||
mode = wxS("geometricPrecision");
|
mode = wxS("geometricPrecision");
|
||||||
break;
|
break;
|
||||||
case wxSVG_SHAPE_RENDERING_AUTO:
|
case wxSVG_SHAPE_RENDERING_AUTO:
|
||||||
default:
|
|
||||||
mode = wxS("auto");
|
mode = wxS("auto");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -304,12 +305,12 @@ wxString wxRenderMode(wxSVGShapeRenderingMode const& style)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxCreateBrushFill(wxBrush& brush, wxSVGShapeRenderingMode mode)
|
wxString wxCreateBrushFill(const wxBrush& brush, wxSVGShapeRenderingMode mode)
|
||||||
{
|
{
|
||||||
wxString s;
|
wxString s;
|
||||||
wxString patternName = wxGetBrushStyleName(brush);
|
wxString patternName = wxGetBrushStyleName(brush);
|
||||||
|
|
||||||
if (!patternName.IsEmpty())
|
if (!patternName.empty())
|
||||||
{
|
{
|
||||||
wxString pattern;
|
wxString pattern;
|
||||||
switch (brush.GetStyle())
|
switch (brush.GetStyle())
|
||||||
@@ -437,7 +438,7 @@ wxSVGBitmapFileHandler::ProcessBitmap(const wxBitmap& bmp,
|
|||||||
{
|
{
|
||||||
sPNG.SetFullName(wxString::Format("%s%simage%d.png",
|
sPNG.SetFullName(wxString::Format("%s%simage%d.png",
|
||||||
sPNG.GetName(),
|
sPNG.GetName(),
|
||||||
sPNG.GetName().IsEmpty() ? "" : "_",
|
sPNG.GetName().empty() ? "" : "_",
|
||||||
sub_images++));
|
sub_images++));
|
||||||
}
|
}
|
||||||
while ( sPNG.FileExists() );
|
while ( sPNG.FileExists() );
|
||||||
@@ -522,7 +523,7 @@ void wxSVGFileDCImpl::Init(const wxString &filename, int Width, int Height,
|
|||||||
|
|
||||||
m_bmp_handler.reset();
|
m_bmp_handler.reset();
|
||||||
|
|
||||||
if ( m_filename.IsEmpty() )
|
if ( m_filename.empty() )
|
||||||
m_outfile.reset();
|
m_outfile.reset();
|
||||||
else
|
else
|
||||||
m_outfile.reset(new wxFileOutputStream(m_filename));
|
m_outfile.reset(new wxFileOutputStream(m_filename));
|
||||||
@@ -683,7 +684,7 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
|
|||||||
textDecoration += wxS(" underline");
|
textDecoration += wxS(" underline");
|
||||||
if (m_font.GetStrikethrough())
|
if (m_font.GetStrikethrough())
|
||||||
textDecoration += wxS(" line-through");
|
textDecoration += wxS(" line-through");
|
||||||
if (textDecoration.IsEmpty())
|
if (textDecoration.empty())
|
||||||
textDecoration = wxS(" none");
|
textDecoration = wxS(" none");
|
||||||
|
|
||||||
wxString style = wxS("style=\"");
|
wxString style = wxS("style=\"");
|
||||||
@@ -792,7 +793,7 @@ void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[],
|
|||||||
|
|
||||||
s += wxString::Format(wxS("\" %s %s %s style=\"fill-rule:%s;\"/>\n"),
|
s += wxString::Format(wxS("\" %s %s %s style=\"fill-rule:%s;\"/>\n"),
|
||||||
wxRenderMode(m_renderingMode), wxGetPenPattern(m_pen), wxGetBrushFill(m_brush),
|
wxRenderMode(m_renderingMode), wxGetPenPattern(m_pen), wxGetBrushFill(m_brush),
|
||||||
(fillStyle == wxODDEVEN_RULE) ? wxS("evenodd") : wxS("nonzero"));
|
fillStyle == wxODDEVEN_RULE ? wxS("evenodd") : wxS("nonzero"));
|
||||||
|
|
||||||
write(s);
|
write(s);
|
||||||
}
|
}
|
||||||
@@ -1155,7 +1156,12 @@ void wxSVGFileDCImpl::DestroyClippingRegion()
|
|||||||
wxDCImpl::DestroyClippingRegion();
|
wxDCImpl::DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent, wxCoord *externalLeading, const wxFont *font) const
|
void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string,
|
||||||
|
wxCoord* w,
|
||||||
|
wxCoord* h,
|
||||||
|
wxCoord* descent,
|
||||||
|
wxCoord* externalLeading,
|
||||||
|
const wxFont* font) const
|
||||||
{
|
{
|
||||||
wxScreenDC sDC;
|
wxScreenDC sDC;
|
||||||
wxSetScaledScreenDCFont(sDC, font ? *font : m_font);
|
wxSetScaledScreenDCFont(sDC, font ? *font : m_font);
|
||||||
@@ -1212,7 +1218,7 @@ void wxSVGFileDCImpl::SetBrush(const wxBrush& brush)
|
|||||||
m_graphics_changed = true;
|
m_graphics_changed = true;
|
||||||
|
|
||||||
wxString pattern = wxCreateBrushFill(m_brush, m_renderingMode);
|
wxString pattern = wxCreateBrushFill(m_brush, m_renderingMode);
|
||||||
if ( !pattern.IsEmpty() )
|
if ( !pattern.empty() )
|
||||||
{
|
{
|
||||||
NewGraphicsIfNeeded();
|
NewGraphicsIfNeeded();
|
||||||
|
|
||||||
@@ -1285,7 +1291,7 @@ bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y)
|
void wxSVGFileDCImpl::DoDrawIcon(const wxIcon& myIcon, wxCoord x, wxCoord y)
|
||||||
{
|
{
|
||||||
wxBitmap myBitmap(myIcon.GetWidth(), myIcon.GetHeight());
|
wxBitmap myBitmap(myIcon.GetWidth(), myIcon.GetHeight());
|
||||||
wxMemoryDC memDC;
|
wxMemoryDC memDC;
|
||||||
@@ -1295,7 +1301,7 @@ void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord
|
|||||||
DoDrawBitmap(myBitmap, x, y);
|
DoDrawBitmap(myBitmap, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y, bool WXUNUSED(bTransparent) /*=0*/)
|
void wxSVGFileDCImpl::DoDrawBitmap(const wxBitmap& bmp, wxCoord x, wxCoord y, bool WXUNUSED(bTransparent))
|
||||||
{
|
{
|
||||||
NewGraphicsIfNeeded();
|
NewGraphicsIfNeeded();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user