1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSVGFileDC
4 // Author: Chris Elliott
7 // Copyright: (c) Chris Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/wfstream.h"
16 #include "wx/string.h"
18 #define wxSVGVersion wxT("v0100")
25 class WXDLLIMPEXP_CORE wxSVGFileDC
: public wxDC
29 wxFileOutputStream
* m_outfile
;
31 //holds number of png format images we have
33 bool m_OK
, m_graphics_changed
;
34 int m_width
, m_height
;
50 m_needComputeScaleY
; // not yet used
53 bool DoGetPixel(wxCoord
, wxCoord
, class wxColour
*) const
54 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; }
56 virtual bool DoBlit(wxCoord
, wxCoord
, wxCoord
, wxCoord
, class wxDC
*,
57 wxCoord
, wxCoord
, int = wxCOPY
, bool = 0, int = -1, int = -1) ;
59 void DoCrossHair(wxCoord
, wxCoord
)
60 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::CrossHair Call not implemented")); return ; }
62 void DoDrawArc(wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
);
64 void DoDrawBitmap(const class wxBitmap
&, wxCoord
, wxCoord
, bool = 0) ;
66 void DoDrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
68 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
70 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
) ;
72 void DoDrawIcon(const class wxIcon
&, wxCoord
, wxCoord
) ;
74 void DoDrawLine (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) ;
76 void DoDrawPoint(wxCoord
, wxCoord
) ;
78 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
,int fillStyle
) ;
80 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
82 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
) ;
84 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20) ;
86 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
88 bool DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), const wxColour
& WXUNUSED(col
),
89 int WXUNUSED(style
) = wxFLOOD_SURFACE
)
90 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); return false ; }
92 void DoGetSize(int * x
, int *y
) const { *x
= m_width
; *y
= m_height
; return ; }
94 void DoGetTextExtent(const wxString
& string
, wxCoord
*w
, wxCoord
*h
, wxCoord
*descent
= NULL
, wxCoord
*externalLeading
= NULL
, const wxFont
*font
= NULL
) const ;
96 void DoSetClippingRegionAsRegion(const class wxRegion
&)
97 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; }
99 void Init (wxString f
, int Width
, int Height
, float dpi
);
101 void NewGraphics () ;
106 wxCoord
XDEV2LOG(wxCoord x
) const
108 wxCoord new_x
= x
- m_deviceOriginX
;
110 return (wxCoord
)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
112 return (wxCoord
)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
117 wxCoord
XDEV2LOGREL(wxCoord x
) const
120 return (wxCoord
)((double)(x
) / m_scaleX
+ 0.5);
122 return (wxCoord
)((double)(x
) / m_scaleX
- 0.5);
127 wxCoord
YDEV2LOG(wxCoord y
) const
129 wxCoord new_y
= y
- m_deviceOriginY
;
131 return (wxCoord
)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
133 return (wxCoord
)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
138 wxCoord
YDEV2LOGREL(wxCoord y
) const
141 return (wxCoord
)((double)(y
) / m_scaleY
+ 0.5);
143 return (wxCoord
)((double)(y
) / m_scaleY
- 0.5);
148 wxCoord
XLOG2DEV(wxCoord x
) const
150 wxCoord new_x
= x
- m_logicalOriginX
;
152 return (wxCoord
)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
154 return (wxCoord
)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
159 wxCoord
XLOG2DEVREL(wxCoord x
) const
162 return (wxCoord
)((double)(x
) * m_scaleX
+ 0.5);
164 return (wxCoord
)((double)(x
) * m_scaleX
- 0.5);
169 wxCoord
YLOG2DEV(wxCoord y
) const
171 wxCoord new_y
= y
- m_logicalOriginY
;
173 return (wxCoord
)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
175 return (wxCoord
)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
180 wxCoord
YLOG2DEVREL(wxCoord y
) const
183 return (wxCoord
)((double)(y
) * m_scaleY
+ 0.5);
185 return (wxCoord
)((double)(y
) * m_scaleY
- 0.5);
188 void write(const wxString
&s
);
192 wxSVGFileDC (wxString f
);
193 wxSVGFileDC (wxString f
, int Width
, int Height
);
194 wxSVGFileDC (wxString f
, int Width
, int Height
, float dpi
);
198 bool CanDrawBitmap() const { return true; }
200 bool CanGetTextExtent() const { return true; }
203 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; }
205 void BeginDrawing() { return;}
207 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
, wxDC
* source
, wxCoord xsrc
, wxCoord ysrc
, int logicalFunc
= wxCOPY
, bool useMask
= false)
208 { return DoBlit(xdest
, ydest
, width
, height
, source
, xsrc
, ysrc
, logicalFunc
, useMask
); }
211 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; }
213 void CrossHair(wxCoord x
, wxCoord y
)
214 { DoCrossHair (x
,y
); return; }
216 virtual void ComputeScaleAndOrigin();
218 void DestroyClippingRegion()
219 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; }
221 wxCoord
DeviceToLogicalX(wxCoord x
) const ;
223 wxCoord
DeviceToLogicalXRel(wxCoord x
) const ;
225 wxCoord
DeviceToLogicalY(wxCoord y
) const ;
227 wxCoord
DeviceToLogicalYRel(wxCoord y
) const ;
229 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool transparent
)
230 { DoDrawBitmap ( bitmap
, x
, y
, transparent
) ; return ;}
232 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
233 {DoDrawIcon(icon
, x
, y
) ; return ; }
235 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0) ;
246 void FloodFill(wxCoord x
, wxCoord y
, wxColour
*colour
, int style
=wxFLOOD_SURFACE
)
247 { DoFloodFill (x
, y
, *colour
, style
); return ;}
249 wxCoord
GetCharHeight() const;
251 wxCoord
GetCharWidth() const;
253 void GetClippingBox(wxCoord
*WXUNUSED(x
), wxCoord
*WXUNUSED(y
), wxCoord
* WXUNUSED(width
), wxCoord
* WXUNUSED(height
))
254 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; }
256 int GetLogicalFunction() const
257 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY
; }
259 int GetMapMode() const ;
261 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*colour
)
262 { return DoGetPixel (x
, y
, colour
) ; }
264 void GetUserScale(double *x
, double *y
) const ;
266 wxCoord
LogicalToDeviceX(wxCoord x
) const ;
268 wxCoord
LogicalToDeviceXRel(wxCoord x
) const ;
270 wxCoord
LogicalToDeviceY(wxCoord y
) const ;
272 wxCoord
LogicalToDeviceYRel(wxCoord y
) const ;
274 bool Ok() const {return m_OK
;}
276 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
) ;
278 void SetClippingRegion(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxCoord
WXUNUSED(width
), wxCoord
WXUNUSED(height
))
279 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; }
281 void SetPalette(const wxPalette
& WXUNUSED(palette
))
282 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; }
284 void SetBackground( const wxBrush
&brush
) ;
286 void SetBackgroundMode( int mode
) ;
288 void SetBrush(const wxBrush
& brush
) ;
290 void SetFont(const wxFont
& font
) ;
292 void SetLogicalFunction(int WXUNUSED(function
))
293 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented")); return ; }
295 void SetLogicalScale( double x
, double y
) ;
297 void SetLogicalOrigin( wxCoord x
, wxCoord y
) ;
299 void SetDeviceOrigin( wxCoord x
, wxCoord y
) ;
301 void SetMapMode(int anint
) ;
303 void SetPen(const wxPen
& pen
) ;
305 void SetUserScale(double xScale
, double yScale
) ;
307 bool StartDoc(const wxString
& WXUNUSED(message
))