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")
20 class WXDLLIMPEXP_CORE wxSVGFileDC
: public wxDC
24 wxFileOutputStream
* m_outfile
;
26 //holds number of png format images we have
28 bool m_OK
, m_graphics_changed
;
29 int m_width
, m_height
;
45 m_needComputeScaleY
; // not yet used
48 bool DoGetPixel(wxCoord
, wxCoord
, class wxColour
*) const
49 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; };
51 virtual bool DoBlit(wxCoord
, wxCoord
, wxCoord
, wxCoord
, class wxDC
*,
52 wxCoord
, wxCoord
, int = wxCOPY
, bool = 0, int = -1, int = -1) ;
54 void DoCrossHair(wxCoord
, wxCoord
)
55 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::CrossHair Call not implemented")); return ; };
57 void DoDrawArc(wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
);
59 void DoDrawBitmap(const class wxBitmap
&, wxCoord
, wxCoord
, bool = 0) ;
61 void DoDrawCheckMark(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
63 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
65 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
) ;
67 void DoDrawIcon(const class wxIcon
&, wxCoord
, wxCoord
) ;
69 void DoDrawLine (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) ;
71 void DoDrawPoint(wxCoord
, wxCoord
) ;
73 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
,int fillStyle
) ;
75 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) ;
77 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
) ;
79 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20) ;
81 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
83 bool DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), const wxColour
& WXUNUSED(col
),
84 int WXUNUSED(style
) = wxFLOOD_SURFACE
)
85 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); return false ; };
87 void DoGetSize(int * x
, int *y
) const { *x
= m_width
; *y
= m_height
; return ; } ;
89 void DoGetTextExtent(const wxString
& string
, wxCoord
*w
, wxCoord
*h
, wxCoord
*descent
= NULL
, wxCoord
*externalLeading
= NULL
, wxFont
*font
= NULL
) const ;
91 void DoSetClippingRegionAsRegion(const class wxRegion
&)
92 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; };
94 void Init (wxString f
, int Width
, int Height
, float dpi
);
101 wxCoord
XDEV2LOG(wxCoord x
) const
103 wxCoord new_x
= x
- m_deviceOriginX
;
105 return (wxCoord
)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
107 return (wxCoord
)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
112 wxCoord
XDEV2LOGREL(wxCoord x
) const
115 return (wxCoord
)((double)(x
) / m_scaleX
+ 0.5);
117 return (wxCoord
)((double)(x
) / m_scaleX
- 0.5);
122 wxCoord
YDEV2LOG(wxCoord y
) const
124 wxCoord new_y
= y
- m_deviceOriginY
;
126 return (wxCoord
)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
128 return (wxCoord
)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
133 wxCoord
YDEV2LOGREL(wxCoord y
) const
136 return (wxCoord
)((double)(y
) / m_scaleY
+ 0.5);
138 return (wxCoord
)((double)(y
) / m_scaleY
- 0.5);
143 wxCoord
XLOG2DEV(wxCoord x
) const
145 wxCoord new_x
= x
- m_logicalOriginX
;
147 return (wxCoord
)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
149 return (wxCoord
)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
154 wxCoord
XLOG2DEVREL(wxCoord x
) const
157 return (wxCoord
)((double)(x
) * m_scaleX
+ 0.5);
159 return (wxCoord
)((double)(x
) * m_scaleX
- 0.5);
164 wxCoord
YLOG2DEV(wxCoord y
) const
166 wxCoord new_y
= y
- m_logicalOriginY
;
168 return (wxCoord
)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
170 return (wxCoord
)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
175 wxCoord
YLOG2DEVREL(wxCoord y
) const
178 return (wxCoord
)((double)(y
) * m_scaleY
+ 0.5);
180 return (wxCoord
)((double)(y
) * m_scaleY
- 0.5);
183 void write(const wxString
&s
);
187 wxSVGFileDC (wxString f
);
188 wxSVGFileDC (wxString f
, int Width
, int Height
);
189 wxSVGFileDC (wxString f
, int Width
, int Height
, float dpi
);
193 bool CanDrawBitmap() const { return true; };
195 bool CanGetTextExtent() const { return true; };
198 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; };
200 void BeginDrawing() { return;};
202 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
, wxDC
* source
, wxCoord xsrc
, wxCoord ysrc
, int logicalFunc
= wxCOPY
, bool useMask
= false)
203 { return DoBlit(xdest
, ydest
, width
, height
, source
, xsrc
, ysrc
, logicalFunc
, useMask
); };
206 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; };
208 void CrossHair(wxCoord x
, wxCoord y
)
209 { DoCrossHair (x
,y
); return; };
211 virtual void ComputeScaleAndOrigin();
213 void DestroyClippingRegion()
214 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; };
216 wxCoord
DeviceToLogicalX(wxCoord x
) const ;
218 wxCoord
DeviceToLogicalXRel(wxCoord x
) const ;
220 wxCoord
DeviceToLogicalY(wxCoord y
) const ;
222 wxCoord
DeviceToLogicalYRel(wxCoord y
) const ;
224 void DrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool transparent
)
225 { DoDrawBitmap ( bitmap
, x
, y
, transparent
) ; return ;};
227 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
228 {DoDrawIcon(icon
, x
, y
) ; return ; };
230 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0) ;
241 void FloodFill(wxCoord x
, wxCoord y
, wxColour
*colour
, int style
=wxFLOOD_SURFACE
)
242 { DoFloodFill (x
, y
, *colour
, style
); return ;} ;
244 wxCoord
GetCharHeight() const;
246 wxCoord
GetCharWidth() const;
248 void GetClippingBox(wxCoord
*WXUNUSED(x
), wxCoord
*WXUNUSED(y
), wxCoord
* WXUNUSED(width
), wxCoord
* WXUNUSED(height
))
249 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; };
251 int GetLogicalFunction()
252 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY
; };
256 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*colour
)
257 { return DoGetPixel (x
, y
, colour
) ; } ;
259 void GetUserScale(double *x
, double *y
) const ;
261 wxCoord
LogicalToDeviceX(wxCoord x
) const ;
263 wxCoord
LogicalToDeviceXRel(wxCoord x
) const ;
265 wxCoord
LogicalToDeviceY(wxCoord y
) const ;
267 wxCoord
LogicalToDeviceYRel(wxCoord y
) const ;
269 bool Ok() const {return m_OK
;};
271 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
) ;
273 void SetClippingRegion(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxCoord
WXUNUSED(width
), wxCoord
WXUNUSED(height
))
274 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; };
276 void SetPalette(const wxPalette
& WXUNUSED(palette
))
277 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; };
279 void SetBackground( const wxBrush
&brush
) ;
281 void SetBackgroundMode( int mode
) ;
283 void SetBrush(const wxBrush
& brush
) ;
285 void SetFont(const wxFont
& font
) ;
287 void SetLogicalFunction(int WXUNUSED(function
))
288 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; };
290 void SetLogicalScale( double x
, double y
) ;
292 void SetLogicalOrigin( wxCoord x
, wxCoord y
) ;
294 void SetDeviceOrigin( wxCoord x
, wxCoord y
) ;
296 void SetMapMode(int anint
) ;
298 void SetPen(const wxPen
& pen
) ;
300 void SetUserScale(double xScale
, double yScale
) ;
302 bool StartDoc(const wxString
& WXUNUSED(message
))