only formatting changes. s/FALSE/false and s/TRUE/true; remove excessive empty lines; remove TABs; s/ ;/;

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-01-05 19:12:41 +00:00
parent 992ff3310e
commit 13cfc51d63

View File

@@ -28,14 +28,19 @@
#include "wx/wfstream.h" #include "wx/wfstream.h"
#include "wx/filename.h" #include "wx/filename.h"
#define wxSVG_DEBUG FALSE #define wxSVG_DEBUG false
// or TRUE to see the calls being executed // or true to see the calls being executed
#define newline wxString(wxT("\n")) #define newline wxString(wxT("\n"))
#define space wxString(wxT(" ")) #define space wxString(wxT(" "))
#define semicolon wxString(wxT(";")) #define semicolon wxString(wxT(";"))
#define wx_round(a) (int)((a)+.5) #define wx_round(a) (int)((a)+.5)
// ----------------------------------------------------------
// Global utilities
// ----------------------------------------------------------
static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
wxString wxColStr ( wxColour c ) wxString wxColStr ( wxColour c )
@@ -64,7 +69,7 @@ wxString wxBrushString ( wxColour c, int style )
break; break;
default : default :
wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::Requested Brush Style not available")) ; wxASSERT_MSG(false, wxT("wxSVGFileDC::Requested Brush Style not available"));
} }
s = s + newline; s = s + newline;
@@ -72,7 +77,7 @@ wxString wxBrushString ( wxColour c, int style )
} }
// ---------------------------------------------------------- // ----------------------------------------------------------
// wxSVGFileDC // wxSVGFileDCImpl
// ---------------------------------------------------------- // ----------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxSVGFileDCImpl, wxDC) IMPLEMENT_ABSTRACT_CLASS(wxSVGFileDCImpl, wxDC)
@@ -91,7 +96,7 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, dou
m_dpi = dpi; m_dpi = dpi;
m_OK = TRUE; m_OK = true;
m_mm_to_pix_x = dpi/25.4; m_mm_to_pix_x = dpi/25.4;
m_mm_to_pix_y = dpi/25.4; m_mm_to_pix_y = dpi/25.4;
@@ -105,7 +110,7 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, dou
m_font = *wxNORMAL_FONT; m_font = *wxNORMAL_FONT;
m_brush = *wxWHITE_BRUSH; m_brush = *wxWHITE_BRUSH;
m_graphics_changed = TRUE ; m_graphics_changed = true;
////////////////////code here ////////////////////code here
@@ -126,18 +131,15 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, dou
write(s); write(s);
s.Printf( wxT(" width=\"%.2gcm\" height=\"%.2gcm\" viewBox=\"0 0 %d %d \"> \n"), float(Width)/dpi*2.54, float(Height)/dpi*2.54, Width, Height ); s.Printf( wxT(" width=\"%.2gcm\" height=\"%.2gcm\" viewBox=\"0 0 %d %d \"> \n"), float(Width)/dpi*2.54, float(Height)/dpi*2.54, Width, Height );
write(s); write(s);
s = wxT("<title>SVG Picture created as ") + wxFileNameFromPath(filename) + wxT(" </title>") + newline ; s = wxT("<title>SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" </title>") + newline;
write(s); write(s);
s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>")+ newline; s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>")+ newline;
write(s); write(s);
s = wxT("<g style=\"fill:black; stroke:black; stroke-width:1\">") + newline; s = wxT("<g style=\"fill:black; stroke:black; stroke-width:1\">") + newline;
write(s); write(s);
} }
} }
wxSVGFileDCImpl::~wxSVGFileDCImpl() wxSVGFileDCImpl::~wxSVGFileDCImpl()
{ {
wxString s = wxT("</g> \n</svg> \n"); wxString s = wxT("</g> \n</svg> \n");
@@ -183,7 +185,6 @@ void wxSVGFileDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxC
} }
} }
void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1) void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1)
{ {
wxString s; wxString s;
@@ -195,20 +196,17 @@ void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1)
write(s); write(s);
} }
void wxSVGFileDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) void wxSVGFileDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height)
{ {
wxDCImpl::DoDrawCheckMark (x1,y1,width,height); wxDCImpl::DoDrawCheckMark (x1,y1,width,height);
} }
void wxSVGFileDCImpl::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1) void wxSVGFileDCImpl::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1)
{ {
DoDrawRotatedText(text, x1,y1,0.0); DoDrawRotatedText(text, x1,y1,0.0);
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawText Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawText Call executed"));
} }
void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle)
{ {
//known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW
@@ -267,16 +265,13 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
write(s); write(s);
} }
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawRotatedText Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawRotatedText Call executed"));
} }
void wxSVGFileDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) void wxSVGFileDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ {
DoDrawRoundedRectangle(x, y, width, height, 0); DoDrawRoundedRectangle(x, y, width, height, 0);
} }
void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
{ {
@@ -292,10 +287,8 @@ void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed"));
CalcBoundingBox(x, y); CalcBoundingBox(x, y);
CalcBoundingBox(x + width, y + height); CalcBoundingBox(x + width, y + height);
} }
void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle)
{ {
if (m_graphics_changed) NewGraphics (); if (m_graphics_changed) NewGraphics ();
@@ -321,7 +314,6 @@ void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wx
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawPolygon Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawPolygon Call executed"));
} }
void wxSVGFileDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) void wxSVGFileDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ {
@@ -341,7 +333,6 @@ void wxSVGFileDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoor
CalcBoundingBox(x + width, y + height); CalcBoundingBox(x + width, y + height);
} }
void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
{ {
/* Draws an arc of a circle, centred on (xc, yc), with starting point /* Draws an arc of a circle, centred on (xc, yc), with starting point
@@ -393,7 +384,6 @@ void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawArc Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawArc Call executed"));
} }
void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
{ {
/* /*
@@ -457,7 +447,6 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipticArc Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipticArc Call executed"));
} }
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
{ {
@@ -469,7 +458,6 @@ void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoor
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::GetTextExtent Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::GetTextExtent Call executed"));
} }
wxCoord wxSVGFileDCImpl::GetCharHeight() const wxCoord wxSVGFileDCImpl::GetCharHeight() const
{ {
@@ -481,7 +469,6 @@ wxCoord wxSVGFileDCImpl::GetCharHeight() const
} }
wxCoord wxSVGFileDCImpl::GetCharWidth() const wxCoord wxSVGFileDCImpl::GetCharWidth() const
{ {
wxScreenDC sDC; wxScreenDC sDC;
@@ -493,7 +480,10 @@ wxCoord wxSVGFileDCImpl::GetCharWidth() const
} }
/// Set Functions ///////////////////////////////////////////////////////////////// // ----------------------------------------------------------
// wxSVGFileDCImpl - set functions
// ----------------------------------------------------------
void wxSVGFileDCImpl::SetBackground( const wxBrush &brush ) void wxSVGFileDCImpl::SetBackground( const wxBrush &brush )
{ {
@@ -514,7 +504,7 @@ void wxSVGFileDCImpl::SetBrush(const wxBrush& brush)
{ {
m_brush = brush; m_brush = brush;
m_graphics_changed = TRUE ; m_graphics_changed = true;
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetBrush Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetBrush Call executed"));
} }
@@ -525,7 +515,7 @@ void wxSVGFileDCImpl::SetPen(const wxPen& pen)
// dashes, stipple : not implemented // dashes, stipple : not implemented
m_pen = pen; m_pen = pen;
m_graphics_changed = TRUE ; m_graphics_changed = true;
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetPen Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetPen Call executed"));
} }
@@ -574,7 +564,7 @@ void wxSVGFileDCImpl::NewGraphics ()
sPenStyle = wxT("stroke-opacity:0.0; stroke-opacity:0.0; "); sPenStyle = wxT("stroke-opacity:0.0; stroke-opacity:0.0; ");
break; break;
default : default :
wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::SetPen Call called to set a Style which is not available")) ; wxASSERT_MSG(false, wxT("wxSVGFileDC::SetPen Call called to set a Style which is not available"));
sWarn = sWarn + wxT("<!--- wxSVGFileDC::SetPen Call called to set a Style which is not available --> \n"); sWarn = sWarn + wxT("<!--- wxSVGFileDC::SetPen Call called to set a Style which is not available --> \n");
} }
@@ -583,7 +573,7 @@ void wxSVGFileDCImpl::NewGraphics ()
s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + newline + sWarn; s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + newline + sWarn;
write(s); write(s);
m_graphics_changed = FALSE ; m_graphics_changed = false;
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::NewGraphics Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::NewGraphics Call executed"));
} }
@@ -596,22 +586,21 @@ void wxSVGFileDCImpl::SetFont(const wxFont& font)
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetFont Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetFont Call executed"));
} }
// export a bitmap as a raster image in png // export a bitmap as a raster image in png
bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC* source, wxCoord xsrc, wxCoord ysrc, wxDC* source, wxCoord xsrc, wxCoord ysrc,
int logicalFunc /*= wxCOPY*/, bool useMask /*= FALSE*/, int logicalFunc /*= wxCOPY*/, bool useMask /*= false*/,
wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/) wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/)
{ {
if (logicalFunc != wxCOPY) if (logicalFunc != wxCOPY)
{ {
wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::DoBlit Call requested nonCopy mode; this is not possible")) ; wxASSERT_MSG(false, wxT("wxSVGFileDC::DoBlit Call requested nonCopy mode; this is not possible"));
return FALSE ; return false;
} }
if (useMask != FALSE) if (useMask != false)
{ {
wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::DoBlit Call requested False mask ; this is not possible")) ; wxASSERT_MSG(false, wxT("wxSVGFileDC::DoBlit Call requested false mask; this is not possible"));
return FALSE ; return false;
} }
wxBitmap myBitmap (width, height); wxBitmap myBitmap (width, height);
wxMemoryDC memDC; wxMemoryDC memDC;
@@ -620,7 +609,7 @@ bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoor
memDC.SelectObject( wxNullBitmap ); memDC.SelectObject( wxNullBitmap );
DoDrawBitmap(myBitmap, xdest, ydest); DoDrawBitmap(myBitmap, xdest, ydest);
wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoBlit Call executed")); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoBlit Call executed"));
return FALSE ; return false;
} }
void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y)
@@ -662,7 +651,7 @@ void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoor
// only use filename & ext // only use filename & ext
sPNG = sPNG.AfterLast(wxFileName::GetPathSeparator()); sPNG = sPNG.AfterLast(wxFileName::GetPathSeparator());
// refrence the bitmap from the SVG doc // reference the bitmap from the SVG doc
int w = myBitmap.GetWidth(); int w = myBitmap.GetWidth();
int h = myBitmap.GetHeight(); int h = myBitmap.GetHeight();
sTmp.Printf ( wxT(" <image x=\"%d\" y=\"%d\" width=\"%dpx\" height=\"%dpx\" "), x,y,w,h ); sTmp.Printf ( wxT(" <image x=\"%d\" y=\"%d\" width=\"%dpx\" height=\"%dpx\" "), x,y,w,h );