3 #include <wx/wfstream.h>
7 #define WXDLLIMPEXP_SVG WXEXPORT
8 #elif defined(WXUSINGDLL)
9 #define WXDLLIMPEXP_SVG WXIMPORT
10 #else // not making nor using DLL
11 #define WXDLLIMPEXP_SVG
14 #define wxSVGVersion wxT("v0100")
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 #define mm2inches 0.0393700787402
25 #define inches2mm 25.4
26 #define mm2twips 56.6929133859
27 #define twips2mm 0.0176388888889
28 #define mm2pt 2.83464566929
29 #define pt2mm 0.352777777778
31 class WXDLLIMPEXP_SVG wxSVGFileDC
: public wxDC
35 wxFileOutputStream
* m_outfile
;
37 //holds number of png format images we have
39 bool m_OK
, m_graphics_changed
;
40 int m_width
, m_height
;
56 m_needComputeScaleY
; // not yet used
59 bool DoGetPixel(wxCoord
, wxCoord
, class wxColour
*) const
60 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return TRUE
; };
62 virtual bool DoBlit(wxCoord
, wxCoord
, wxCoord
, wxCoord
, class wxDC
*,
63 wxCoord
, wxCoord
, int = wxCOPY
, bool = 0, int = -1, int = -1) ;
65 void DoCrossHair(wxCoord
, wxCoord
)
66 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::CrossHair Call not implemented")); return ; };
68 void DoDrawArc(wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
);
70 void DoDrawBitmap(const class wxBitmap
&, wxCoord
, wxCoord
, bool = 0) ;
72 void DoDrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
74 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
76 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
) ;
78 void DoDrawIcon(const class wxIcon
&, wxCoord
, wxCoord
) ;
80 void DoDrawLine (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) ;
82 void DoDrawPoint(wxCoord
, wxCoord
) ;
84 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
,int fillStyle
) ;
86 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
88 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
) ;
90 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20) ;
92 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
94 bool DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), const wxColour
& WXUNUSED(col
),
95 int WXUNUSED(style
) = wxFLOOD_SURFACE
)
96 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); return FALSE
; };
98 void DoGetSize(int * x
, int *y
) const { *x
= m_width
; *y
= m_height
; return ; } ;
100 void DoGetTextExtent(const wxString
& string
, wxCoord
*w
, wxCoord
*h
, wxCoord
*descent
= NULL
, wxCoord
*externalLeading
= NULL
, wxFont
*font
= NULL
) const ;
102 void DoSetClippingRegionAsRegion(const class wxRegion
&)
103 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; };
105 void Init (wxString f
, int Width
, int Height
, float dpi
);
107 void NewGraphics () ;
112 wxCoord
XDEV2LOG(wxCoord x
) const
114 wxCoord new_x
= x
- m_deviceOriginX
;
116 return (wxCoord
)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
118 return (wxCoord
)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
123 wxCoord
XDEV2LOGREL(wxCoord x
) const
126 return (wxCoord
)((double)(x
) / m_scaleX
+ 0.5);
128 return (wxCoord
)((double)(x
) / m_scaleX
- 0.5);
133 wxCoord
YDEV2LOG(wxCoord y
) const
135 wxCoord new_y
= y
- m_deviceOriginY
;
137 return (wxCoord
)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
139 return (wxCoord
)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
144 wxCoord
YDEV2LOGREL(wxCoord y
) const
147 return (wxCoord
)((double)(y
) / m_scaleY
+ 0.5);
149 return (wxCoord
)((double)(y
) / m_scaleY
- 0.5);
154 wxCoord
XLOG2DEV(wxCoord x
) const
156 wxCoord new_x
= x
- m_logicalOriginX
;
158 return (wxCoord
)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
160 return (wxCoord
)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
165 wxCoord
XLOG2DEVREL(wxCoord x
) const
168 return (wxCoord
)((double)(x
) * m_scaleX
+ 0.5);
170 return (wxCoord
)((double)(x
) * m_scaleX
- 0.5);
175 wxCoord
YLOG2DEV(wxCoord y
) const
177 wxCoord new_y
= y
- m_logicalOriginY
;
179 return (wxCoord
)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
181 return (wxCoord
)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
186 wxCoord
YLOG2DEVREL(wxCoord y
) const
189 return (wxCoord
)((double)(y
) * m_scaleY
+ 0.5);
191 return (wxCoord
)((double)(y
) * m_scaleY
- 0.5);
194 void write(const wxString
&s
);
198 wxSVGFileDC (wxString f
);
199 wxSVGFileDC (wxString f
, int Width
, int Height
);
200 wxSVGFileDC (wxString f
, int Width
, int Height
, float dpi
);
204 bool CanDrawBitmap() const { return TRUE
; };
206 bool CanGetTextExtent() const { return TRUE
; };
209 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; };
211 void BeginDrawing() { return;};
213 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
, wxDC
* source
, wxCoord xsrc
, wxCoord ysrc
, int logicalFunc
= wxCOPY
, bool useMask
= FALSE
)
214 { return DoBlit(xdest
, ydest
, width
, height
, source
, xsrc
, ysrc
, logicalFunc
, useMask
); };
217 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; };
219 void CrossHair(wxCoord x
, wxCoord y
)
220 { DoCrossHair (x
,y
); return; };
222 void ComputeScaleAndOrigin() ;
224 void DestroyClippingRegion()
225 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; };
227 wxCoord
DeviceToLogicalX(wxCoord x
) const ;
229 wxCoord
DeviceToLogicalXRel(wxCoord x
) const ;
231 wxCoord
DeviceToLogicalY(wxCoord y
) const ;
233 wxCoord
DeviceToLogicalYRel(wxCoord y
) const ;
235 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool transparent
)
236 { DoDrawBitmap ( bitmap
, x
, y
, transparent
) ; return ;};
239 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
240 {DoDrawIcon(icon
, x
, y
) ; return ; };
242 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0) ;
253 void FloodFill(wxCoord x
, wxCoord y
, wxColour
*colour
, int style
=wxFLOOD_SURFACE
)
254 { DoFloodFill (x
, y
, *colour
, style
); return ;} ;
256 wxCoord
GetCharHeight() const;
258 wxCoord
GetCharWidth() const;
260 void GetClippingBox(wxCoord
*WXUNUSED(x
), wxCoord
*WXUNUSED(y
), wxCoord
* WXUNUSED(width
), wxCoord
* WXUNUSED(height
))
261 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; };
263 int GetLogicalFunction()
264 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY
; };
268 bool GetOptimization()
269 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetOptimization() No optimization code used")); return TRUE
; };
271 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*colour
)
272 { return DoGetPixel (x
, y
, colour
) ; } ;
274 void GetUserScale(double *x
, double *y
) const ;
276 wxCoord
LogicalToDeviceX(wxCoord x
) const ;
278 wxCoord
LogicalToDeviceXRel(wxCoord x
) const ;
280 wxCoord
LogicalToDeviceY(wxCoord y
) const ;
282 wxCoord
LogicalToDeviceYRel(wxCoord y
) const ;
284 bool Ok() const {return m_OK
;};
286 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
) ;
288 void SetClippingRegion(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxCoord
WXUNUSED(width
), wxCoord
WXUNUSED(height
))
289 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; };
291 void SetPalette(const wxPalette
& WXUNUSED(palette
))
292 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; };
294 void SetBackground( const wxBrush
&brush
) ;
296 void SetBackgroundMode( int mode
) ;
298 void SetBrush(const wxBrush
& brush
) ;
300 void SetFont(const wxFont
& font
) ;
302 void SetLogicalFunction(int WXUNUSED(function
))
303 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; };
305 void SetLogicalScale( double x
, double y
) ;
307 void SetLogicalOrigin( wxCoord x
, wxCoord y
) ;
309 void SetDeviceOrigin( wxCoord x
, wxCoord y
) ;
311 void SetMapMode(int anint
) ;
313 void SetOptimization(bool WXUNUSED(optimize
)) { return ; };
315 void SetPen(const wxPen
& pen
) ;
317 void SetUserScale(double xScale
, double yScale
) ;
319 bool StartDoc(const wxString
& WXUNUSED(message
))