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);
197 wxSVGFileDC (wxString f
);
198 wxSVGFileDC (wxString f
, int Width
, int Height
);
199 wxSVGFileDC (wxString f
, int Width
, int Height
, float dpi
);
203 bool CanDrawBitmap() const { return TRUE
; };
205 bool CanGetTextExtent() const { return TRUE
; };
208 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; };
210 void BeginDrawing() { return;};
212 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
, wxDC
* source
, wxCoord xsrc
, wxCoord ysrc
, int logicalFunc
= wxCOPY
, bool useMask
= FALSE
)
213 { return DoBlit(xdest
, ydest
, width
, height
, source
, xsrc
, ysrc
, logicalFunc
, useMask
); };
216 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; };
218 void CrossHair(wxCoord x
, wxCoord y
)
219 { DoCrossHair (x
,y
); return; };
221 void ComputeScaleAndOrigin() ;
223 void DestroyClippingRegion()
224 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; };
226 wxCoord
DeviceToLogicalX(wxCoord x
) const ;
228 wxCoord
DeviceToLogicalXRel(wxCoord x
) const ;
230 wxCoord
DeviceToLogicalY(wxCoord y
) const ;
232 wxCoord
DeviceToLogicalYRel(wxCoord y
) const ;
234 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool transparent
)
235 { DoDrawBitmap ( bitmap
, x
, y
, transparent
) ; return ;};
238 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
239 {DoDrawIcon(icon
, x
, y
) ; return ; };
241 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0) ;
252 void FloodFill(wxCoord x
, wxCoord y
, wxColour
*colour
, int style
=wxFLOOD_SURFACE
)
253 { DoFloodFill (x
, y
, *colour
, style
); return ;} ;
255 wxCoord
GetCharHeight() const;
257 wxCoord
GetCharWidth() const;
259 void GetClippingBox(wxCoord
*WXUNUSED(x
), wxCoord
*WXUNUSED(y
), wxCoord
* WXUNUSED(width
), wxCoord
* WXUNUSED(height
))
260 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; };
262 int GetLogicalFunction()
263 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY
; };
267 bool GetOptimization()
268 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::GetOptimization() No optimization code used")); return TRUE
; };
270 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*colour
)
271 { return DoGetPixel (x
, y
, colour
) ; } ;
273 void GetUserScale(double *x
, double *y
) const ;
275 wxCoord
LogicalToDeviceX(wxCoord x
) const ;
277 wxCoord
LogicalToDeviceXRel(wxCoord x
) const ;
279 wxCoord
LogicalToDeviceY(wxCoord y
) const ;
281 wxCoord
LogicalToDeviceYRel(wxCoord y
) const ;
283 bool Ok() const {return m_OK
;};
285 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
) ;
287 void SetClippingRegion(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxCoord
WXUNUSED(width
), wxCoord
WXUNUSED(height
))
288 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; };
290 void SetPalette(const wxPalette
& WXUNUSED(palette
))
291 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; };
293 void SetBackground( const wxBrush
&brush
) ;
295 void SetBackgroundMode( int mode
) ;
297 void SetBrush(const wxBrush
& brush
) ;
299 void SetFont(const wxFont
& font
) ;
301 void SetLogicalFunction(int WXUNUSED(function
))
302 { wxASSERT_MSG (FALSE
, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; };
304 void SetLogicalScale( double x
, double y
) ;
306 void SetLogicalOrigin( wxCoord x
, wxCoord y
) ;
308 void SetDeviceOrigin( wxCoord x
, wxCoord y
) ;
310 void SetMapMode(int anint
) ;
312 void SetOptimization(bool WXUNUSED(optimize
)) { return ; };
314 void SetPen(const wxPen
& pen
) ;
316 void SetUserScale(double xScale
, double yScale
) ;
318 bool StartDoc(const wxString
& WXUNUSED(message
))