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