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