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