]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dcsvg.h
added missing #include "wx/buffer.h"
[wxWidgets.git] / include / wx / dcsvg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dcsvg.h
3 // Purpose: wxSVGFileDC
4 // Author: Chris Elliott
5 // Modified by:
6 // Created:
7 // Copyright: (c) Chris Elliott
8 // RCS-ID: $Id$
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __DCSVG_H
13 #define __DCSVG_H
14
15 #include "wx/wfstream.h"
16 #include "wx/string.h"
17
18 #define wxSVGVersion wxT("v0100")
19
20 #ifdef __BORLANDC__
21 #pragma warn -8008
22 #pragma warn -8066
23 #endif
24
25 class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC
26 {
27
28 private:
29 wxFileOutputStream * m_outfile ;
30 wxString m_filename ;
31 //holds number of png format images we have
32 int m_sub_images ;
33 bool m_OK, m_graphics_changed ;
34 int m_width, m_height ;
35
36 double
37 m_logicalScaleX,
38 m_logicalScaleY,
39 m_userScaleX,
40 m_userScaleY,
41 m_scaleX,
42 m_scaleY,
43 m_OriginX,
44 m_OriginY,
45 m_mm_to_pix_x,
46 m_mm_to_pix_y;
47
48 bool
49 m_needComputeScaleX,
50 m_needComputeScaleY; // not yet used
51
52
53 bool DoGetPixel(wxCoord, wxCoord, class wxColour *) const
54 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; }
55
56 virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, class wxDC *,
57 wxCoord, wxCoord, int = wxCOPY, bool = 0, int = -1, int = -1) ;
58
59 void DoCrossHair(wxCoord, wxCoord)
60 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::CrossHair Call not implemented")); return ; }
61
62 void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord);
63
64 void DoDrawBitmap(const class wxBitmap &, wxCoord, wxCoord, bool = 0) ;
65
66 void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height) ;
67
68 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) ;
69
70 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) ;
71
72 void DoDrawIcon(const class wxIcon &, wxCoord, wxCoord) ;
73
74 void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) ;
75
76 void DoDrawPoint(wxCoord, wxCoord) ;
77
78 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) ;
79
80 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) ;
81
82 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) ;
83
84 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20) ;
85
86 void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
87
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 ; }
91
92 void DoGetSize(int * x, int *y) const { *x = m_width; *y = m_height ; return ; }
93
94 void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, const wxFont *font = NULL) const ;
95
96 void DoSetClippingRegionAsRegion(const class wxRegion &)
97 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; }
98
99 void Init (wxString f, int Width, int Height, float dpi);
100
101 void NewGraphics () ;
102
103 #ifdef XDEV2LOG
104 #undef XDEV2LOG
105 #endif
106 wxCoord XDEV2LOG(wxCoord x) const
107 {
108 wxCoord new_x = x - m_deviceOriginX;
109 if (new_x > 0)
110 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
111 else
112 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
113 }
114 #ifdef XDEV2LOGREL
115 #undef XDEV2LOGREL
116 #endif
117 wxCoord XDEV2LOGREL(wxCoord x) const
118 {
119 if (x > 0)
120 return (wxCoord)((double)(x) / m_scaleX + 0.5);
121 else
122 return (wxCoord)((double)(x) / m_scaleX - 0.5);
123 }
124 #ifdef YDEV2LOG
125 #undef YDEV2LOG
126 #endif
127 wxCoord YDEV2LOG(wxCoord y) const
128 {
129 wxCoord new_y = y - m_deviceOriginY;
130 if (new_y > 0)
131 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
132 else
133 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
134 }
135 #ifdef YDEV2LOGREL
136 #undef YDEV2LOGREL
137 #endif
138 wxCoord YDEV2LOGREL(wxCoord y) const
139 {
140 if (y > 0)
141 return (wxCoord)((double)(y) / m_scaleY + 0.5);
142 else
143 return (wxCoord)((double)(y) / m_scaleY - 0.5);
144 }
145 #ifdef XLOG2DEV
146 #undef XLOG2DEV
147 #endif
148 wxCoord XLOG2DEV(wxCoord x) const
149 {
150 wxCoord new_x = x - m_logicalOriginX;
151 if (new_x > 0)
152 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
153 else
154 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
155 }
156 #ifdef XLOG2DEVREL
157 #undef XLOG2DEVREL
158 #endif
159 wxCoord XLOG2DEVREL(wxCoord x) const
160 {
161 if (x > 0)
162 return (wxCoord)((double)(x) * m_scaleX + 0.5);
163 else
164 return (wxCoord)((double)(x) * m_scaleX - 0.5);
165 }
166 #ifdef YLOG2DEV
167 #undef YLOG2DEV
168 #endif
169 wxCoord YLOG2DEV(wxCoord y) const
170 {
171 wxCoord new_y = y - m_logicalOriginY;
172 if (new_y > 0)
173 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
174 else
175 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
176 }
177 #ifdef YLOG2DEVREL
178 #undef YLOG2DEVREL
179 #endif
180 wxCoord YLOG2DEVREL(wxCoord y) const
181 {
182 if (y > 0)
183 return (wxCoord)((double)(y) * m_scaleY + 0.5);
184 else
185 return (wxCoord)((double)(y) * m_scaleY - 0.5);
186 }
187
188 void write(const wxString &s);
189
190 public:
191
192 wxSVGFileDC (wxString f);
193 wxSVGFileDC (wxString f, int Width, int Height);
194 wxSVGFileDC (wxString f, int Width, int Height, float dpi);
195 ~wxSVGFileDC();
196
197
198 bool CanDrawBitmap() const { return true; }
199
200 bool CanGetTextExtent() const { return true; }
201
202 int GetDepth() const
203 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; }
204
205 void BeginDrawing() { return;}
206
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); }
209
210 void Clear()
211 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; }
212
213 void CrossHair(wxCoord x, wxCoord y)
214 { DoCrossHair (x,y); return; }
215
216 virtual void ComputeScaleAndOrigin();
217
218 void DestroyClippingRegion()
219 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; }
220
221 wxCoord DeviceToLogicalX(wxCoord x) const ;
222
223 wxCoord DeviceToLogicalXRel(wxCoord x) const ;
224
225 wxCoord DeviceToLogicalY(wxCoord y) const ;
226
227 wxCoord DeviceToLogicalYRel(wxCoord y) const ;
228
229 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool transparent)
230 { DoDrawBitmap ( bitmap, x, y, transparent ) ; return ;}
231
232 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
233 {DoDrawIcon(icon, x, y) ; return ; }
234
235 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) ;
236
237 void EndDoc()
238 { return ; }
239
240 void EndDrawing()
241 { return ; }
242
243 void EndPage()
244 { return ; }
245
246 void FloodFill(wxCoord x, wxCoord y, wxColour *colour, int style=wxFLOOD_SURFACE)
247 { DoFloodFill (x, y, *colour, style); return ;}
248
249 wxCoord GetCharHeight() const;
250
251 wxCoord GetCharWidth() const;
252
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 ; }
255
256 int GetLogicalFunction() const
257 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY ; }
258
259 int GetMapMode() const ;
260
261 bool GetPixel(wxCoord x, wxCoord y, wxColour *colour)
262 { return DoGetPixel (x, y, colour) ; }
263
264 void GetUserScale(double *x, double *y) const ;
265
266 wxCoord LogicalToDeviceX(wxCoord x) const ;
267
268 wxCoord LogicalToDeviceXRel(wxCoord x) const ;
269
270 wxCoord LogicalToDeviceY(wxCoord y) const ;
271
272 wxCoord LogicalToDeviceYRel(wxCoord y) const ;
273
274 bool Ok() const {return m_OK;}
275
276 void SetAxisOrientation( bool xLeftRight, bool yBottomUp ) ;
277
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 ; }
280
281 void SetPalette(const wxPalette& WXUNUSED(palette))
282 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; }
283
284 void SetBackground( const wxBrush &brush ) ;
285
286 void SetBackgroundMode( int mode ) ;
287
288 void SetBrush(const wxBrush& brush) ;
289
290 void SetFont(const wxFont& font) ;
291
292 void SetLogicalFunction(int WXUNUSED(function))
293 { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented")); return ; }
294
295 void SetLogicalScale( double x, double y ) ;
296
297 void SetLogicalOrigin( wxCoord x, wxCoord y ) ;
298
299 void SetDeviceOrigin( wxCoord x, wxCoord y ) ;
300
301 void SetMapMode(int anint) ;
302
303 void SetPen(const wxPen& pen) ;
304
305 void SetUserScale(double xScale, double yScale) ;
306
307 bool StartDoc(const wxString& WXUNUSED(message))
308 { return false; }
309
310 void StartPage()
311 { return ; }
312 };
313
314 #endif // __DCSVG_H