Applied patch [ 778625 ] wxSVGFileDC and UNICODE build
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -191,6 +191,7 @@ class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC
|
||||
return (wxCoord)((double)(y) * m_scaleY - 0.5);
|
||||
}
|
||||
|
||||
void write(const wxString &s);
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -120,22 +120,21 @@ void wxSVGFileDC::Init (wxString f, int Width, int Height, float dpi)
|
||||
m_sub_images = 0 ;
|
||||
wxString s ;
|
||||
s = wxT("<?xml version=\"1.0\" standalone=\"no\"?>") ; s = s + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" ") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"> ")+ newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s.Printf ( wxT("<svg width=\"%.2gcm\" height=\"%.2gcm\" viewBox=\"0 0 %d %d \"> \n"), float(Width)/dpi*2.54, float(Height)/dpi*2.54, Width, Height );
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("<title>SVG Picture created as ") + wxFileNameFromPath(f) + wxT(" </title>") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>")+ newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("<g style=\"fill:black; stroke:black; stroke-width:1\">") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
}
|
||||
|
||||
|
||||
@@ -159,8 +158,7 @@ wxSVGFileDC::wxSVGFileDC (wxString f, int Width, int Height, float dpi)
|
||||
wxSVGFileDC::~wxSVGFileDC()
|
||||
{
|
||||
wxString s = wxT("</g> \n</svg> \n") ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
delete m_outfile ;
|
||||
}
|
||||
|
||||
@@ -174,9 +172,8 @@ void wxSVGFileDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
s.Printf ( wxT("<path d=\"M%d %d L%d %d\" /> \n"), x1,y1,x2,y2 );
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawLine Call executed")) ;
|
||||
CalcBoundingBox(x1, y1) ;
|
||||
CalcBoundingBox(x2, y2) ;
|
||||
@@ -198,11 +195,10 @@ void wxSVGFileDC::DoDrawPoint (wxCoord x1, wxCoord y1)
|
||||
wxString s;
|
||||
if (m_graphics_changed) NewGraphics ();
|
||||
s = wxT("<g style = \"stroke-linecap:round;\" > ") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
DrawLine ( x1,y1,x1,y1 );
|
||||
s = wxT("</g>");
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +248,7 @@ void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y,
|
||||
s = s + wxT("stroke-width:1; stroke:#") + wxColStr (m_textBackgroundColour) + wxT("; ") ;
|
||||
sTmp.Printf ( wxT("\" transform=\"rotate( %.2g %d %d ) \">"), -angle, x,y ) ;
|
||||
s = s + sTmp + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
//now do the text itself
|
||||
s.Printf (wxT(" <text x=\"%d\" y=\"%d\" "),x,y );
|
||||
@@ -274,9 +270,8 @@ void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y,
|
||||
s = s + sTmp + sText + wxT("</text> ") + newline ;
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawRotatedText Call executed")) ;
|
||||
|
||||
}
|
||||
@@ -298,8 +293,7 @@ void wxSVGFileDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wx
|
||||
x, y, width, height, radius );
|
||||
|
||||
s = s + wxT(" /> ") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed")) ;
|
||||
CalcBoundingBox(x, y) ;
|
||||
@@ -328,8 +322,7 @@ void wxSVGFileDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoor
|
||||
}
|
||||
s = s + wxT("\" /> ") ;
|
||||
s = s + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawPolygon Call executed")) ;
|
||||
}
|
||||
@@ -347,8 +340,7 @@ void wxSVGFileDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord he
|
||||
s.Printf ( wxT("<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" "), x+rw,y+rh, rw, rh );
|
||||
s = s + wxT(" /> ") + newline ;
|
||||
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipse Call executed")) ;
|
||||
CalcBoundingBox(x, y) ;
|
||||
@@ -378,7 +370,7 @@ void wxSVGFileDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo
|
||||
if ( fabs ( r2-r1 ) > 3 ) //pixels
|
||||
{
|
||||
s = wxT("<!--- wxSVGFileDC::DoDrawArc Error in getting radii of circle --> \n") ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
|
||||
double theta1 = atan2(yc-y1,x1-xc);
|
||||
@@ -401,9 +393,8 @@ void wxSVGFileDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo
|
||||
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawArc Call executed")) ;
|
||||
}
|
||||
@@ -466,9 +457,8 @@ void wxSVGFileDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub
|
||||
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipticArc Call executed")) ;
|
||||
}
|
||||
@@ -598,8 +588,7 @@ void wxSVGFileDC::NewGraphics ()
|
||||
w, m_OriginX, m_OriginY, m_scaleX, m_scaleY );
|
||||
|
||||
s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + newline + sWarn;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
m_graphics_changed = FALSE ;
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::NewGraphics Call executed")) ;
|
||||
}
|
||||
@@ -789,7 +778,7 @@ void wxSVGFileDC::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y
|
||||
|
||||
if (m_OK && bPNG_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok () && bPNG_OK;
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawBitmap Call executed")) ;
|
||||
@@ -849,6 +838,12 @@ wxCoord wxSVGFileDC::LogicalToDeviceYRel(wxCoord y) const
|
||||
return YLOG2DEVREL(y);
|
||||
}
|
||||
|
||||
void wxSVGFileDC::write(const wxString &s)
|
||||
{
|
||||
wxWX2MBbuf buf = s.mb_str(wxConvUTF8);
|
||||
m_outfile->Write(buf, strlen((const char *)buf));
|
||||
m_OK = m_outfile->Ok();
|
||||
}
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma warn .rch
|
||||
|
@@ -191,6 +191,7 @@ class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC
|
||||
return (wxCoord)((double)(y) * m_scaleY - 0.5);
|
||||
}
|
||||
|
||||
void write(const wxString &s);
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -120,22 +120,21 @@ void wxSVGFileDC::Init (wxString f, int Width, int Height, float dpi)
|
||||
m_sub_images = 0 ;
|
||||
wxString s ;
|
||||
s = wxT("<?xml version=\"1.0\" standalone=\"no\"?>") ; s = s + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" ") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"> ")+ newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s.Printf ( wxT("<svg width=\"%.2gcm\" height=\"%.2gcm\" viewBox=\"0 0 %d %d \"> \n"), float(Width)/dpi*2.54, float(Height)/dpi*2.54, Width, Height );
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("<title>SVG Picture created as ") + wxFileNameFromPath(f) + wxT(" </title>") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>")+ newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
s = wxT("<g style=\"fill:black; stroke:black; stroke-width:1\">") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
}
|
||||
|
||||
|
||||
@@ -159,8 +158,7 @@ wxSVGFileDC::wxSVGFileDC (wxString f, int Width, int Height, float dpi)
|
||||
wxSVGFileDC::~wxSVGFileDC()
|
||||
{
|
||||
wxString s = wxT("</g> \n</svg> \n") ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
delete m_outfile ;
|
||||
}
|
||||
|
||||
@@ -174,9 +172,8 @@ void wxSVGFileDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
s.Printf ( wxT("<path d=\"M%d %d L%d %d\" /> \n"), x1,y1,x2,y2 );
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawLine Call executed")) ;
|
||||
CalcBoundingBox(x1, y1) ;
|
||||
CalcBoundingBox(x2, y2) ;
|
||||
@@ -198,11 +195,10 @@ void wxSVGFileDC::DoDrawPoint (wxCoord x1, wxCoord y1)
|
||||
wxString s;
|
||||
if (m_graphics_changed) NewGraphics ();
|
||||
s = wxT("<g style = \"stroke-linecap:round;\" > ") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
DrawLine ( x1,y1,x1,y1 );
|
||||
s = wxT("</g>");
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +248,7 @@ void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y,
|
||||
s = s + wxT("stroke-width:1; stroke:#") + wxColStr (m_textBackgroundColour) + wxT("; ") ;
|
||||
sTmp.Printf ( wxT("\" transform=\"rotate( %.2g %d %d ) \">"), -angle, x,y ) ;
|
||||
s = s + sTmp + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
//now do the text itself
|
||||
s.Printf (wxT(" <text x=\"%d\" y=\"%d\" "),x,y );
|
||||
@@ -274,9 +270,8 @@ void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y,
|
||||
s = s + sTmp + sText + wxT("</text> ") + newline ;
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawRotatedText Call executed")) ;
|
||||
|
||||
}
|
||||
@@ -298,8 +293,7 @@ void wxSVGFileDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wx
|
||||
x, y, width, height, radius );
|
||||
|
||||
s = s + wxT(" /> ") + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed")) ;
|
||||
CalcBoundingBox(x, y) ;
|
||||
@@ -328,8 +322,7 @@ void wxSVGFileDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoor
|
||||
}
|
||||
s = s + wxT("\" /> ") ;
|
||||
s = s + newline ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawPolygon Call executed")) ;
|
||||
}
|
||||
@@ -347,8 +340,7 @@ void wxSVGFileDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord he
|
||||
s.Printf ( wxT("<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" "), x+rw,y+rh, rw, rh );
|
||||
s = s + wxT(" /> ") + newline ;
|
||||
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipse Call executed")) ;
|
||||
CalcBoundingBox(x, y) ;
|
||||
@@ -378,7 +370,7 @@ void wxSVGFileDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo
|
||||
if ( fabs ( r2-r1 ) > 3 ) //pixels
|
||||
{
|
||||
s = wxT("<!--- wxSVGFileDC::DoDrawArc Error in getting radii of circle --> \n") ;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
|
||||
double theta1 = atan2(yc-y1,x1-xc);
|
||||
@@ -401,9 +393,8 @@ void wxSVGFileDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo
|
||||
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawArc Call executed")) ;
|
||||
}
|
||||
@@ -466,9 +457,8 @@ void wxSVGFileDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub
|
||||
|
||||
if (m_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok ();
|
||||
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipticArc Call executed")) ;
|
||||
}
|
||||
@@ -598,8 +588,7 @@ void wxSVGFileDC::NewGraphics ()
|
||||
w, m_OriginX, m_OriginY, m_scaleX, m_scaleY );
|
||||
|
||||
s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + newline + sWarn;
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
m_OK = m_outfile->Ok ();
|
||||
write(s);
|
||||
m_graphics_changed = FALSE ;
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::NewGraphics Call executed")) ;
|
||||
}
|
||||
@@ -789,7 +778,7 @@ void wxSVGFileDC::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y
|
||||
|
||||
if (m_OK && bPNG_OK)
|
||||
{
|
||||
m_outfile->Write (s.c_str(), s.Len() ) ;
|
||||
write(s);
|
||||
}
|
||||
m_OK = m_outfile->Ok () && bPNG_OK;
|
||||
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawBitmap Call executed")) ;
|
||||
@@ -849,6 +838,12 @@ wxCoord wxSVGFileDC::LogicalToDeviceYRel(wxCoord y) const
|
||||
return YLOG2DEVREL(y);
|
||||
}
|
||||
|
||||
void wxSVGFileDC::write(const wxString &s)
|
||||
{
|
||||
wxWX2MBbuf buf = s.mb_str(wxConvUTF8);
|
||||
m_outfile->Write(buf, strlen((const char *)buf));
|
||||
m_OK = m_outfile->Ok();
|
||||
}
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma warn .rch
|
||||
|
Reference in New Issue
Block a user