From 85b88942cca1395ce7c827233e64aaa5eef838d2 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 11 Sep 2003 10:05:32 +0000 Subject: [PATCH] Applied patch [ 778625 ] wxSVGFileDC and UNICODE build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/svg/dcsvg.h | 1 + contrib/src/svg/dcsvg.cpp | 59 ++++++++++++++++------------------ include/wx/dcsvg.h | 1 + src/common/dcsvg.cpp | 59 ++++++++++++++++------------------ 4 files changed, 56 insertions(+), 64 deletions(-) diff --git a/contrib/include/wx/svg/dcsvg.h b/contrib/include/wx/svg/dcsvg.h index c2eef701b8..fefeea5084 100644 --- a/contrib/include/wx/svg/dcsvg.h +++ b/contrib/include/wx/svg/dcsvg.h @@ -191,6 +191,7 @@ class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC return (wxCoord)((double)(y) * m_scaleY - 0.5); } + void write(const wxString &s); public: diff --git a/contrib/src/svg/dcsvg.cpp b/contrib/src/svg/dcsvg.cpp index ed303084a4..baf6095050 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); } @@ -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) +{ + wxWX2MBbuf buf = s.mb_str(wxConvUTF8); + m_outfile->Write(buf, strlen((const char *)buf)); + m_OK = m_outfile->Ok(); +} #ifdef __BORLANDC__ #pragma warn .rch diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index c2eef701b8..fefeea5084 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -191,6 +191,7 @@ class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC return (wxCoord)((double)(y) * m_scaleY - 0.5); } + void write(const wxString &s); public: diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index ed303084a4..baf6095050 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/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); } @@ -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) +{ + wxWX2MBbuf buf = s.mb_str(wxConvUTF8); + m_outfile->Write(buf, strlen((const char *)buf)); + m_OK = m_outfile->Ok(); +} #ifdef __BORLANDC__ #pragma warn .rch -- 2.45.2