X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a55595e69e5c5a3847fef936d7d7caa3df800de..822e690b221486b63895b5f14a7fbee2bc966fe5:/contrib/src/svg/dcsvg.cpp diff --git a/contrib/src/svg/dcsvg.cpp b/contrib/src/svg/dcsvg.cpp index ed303084a4..3369f14b01 100644 --- a/contrib/src/svg/dcsvg.cpp +++ b/contrib/src/svg/dcsvg.cpp @@ -120,22 +120,21 @@ void wxSVGFileDC::Init (wxString f, int Width, int Height, float dpi) m_sub_images = 0 ; wxString s ; s = wxT("") ; s = s + newline ; - m_outfile->Write (s.c_str(), s.Len() ) ; + write(s); s = wxT("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(" \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("SVG Picture created as ") + wxFileNameFromPath(f) + wxT(" ") + newline ; - m_outfile->Write (s.c_str(), s.Len() ) ; + write(s); s = wxString (wxT("Picture generated by wxSVG ")) + wxSVGVersion + wxT(" ")+ newline ; - m_outfile->Write (s.c_str(), s.Len() ) ; + write(s); s = wxT("") + 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(" \n \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(" \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(" ") + newline ; - m_outfile->Write (s.c_str(), s.Len() ) ; + write(s); DrawLine ( x1,y1,x1,y1 ); s = wxT(""); - m_outfile->Write (s.c_str(), s.Len() ) ; - m_OK = m_outfile->Ok (); + write(s); } @@ -233,13 +229,13 @@ void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, // wxT("upper left") and wxT("upper right") CalcBoundingBox(x, y); - CalcBoundingBox(x + w*cos(rad), y - h*sin(rad)); + CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad))); // wxT("bottom left") and wxT("bottom right") x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); CalcBoundingBox(x, y); - CalcBoundingBox(x + h*sin(rad), y + h*cos(rad)); + CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad))); if (m_backgroundMode == wxSOLID) { @@ -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(" ") + 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(" ") + 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(" \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) +{ + const wxWX2MBbuf buf = s.mb_str(wxConvUTF8); + m_outfile->Write(buf, strlen((const char *)buf)); + m_OK = m_outfile->Ok(); +} #ifdef __BORLANDC__ #pragma warn .rch