]>
Commit | Line | Data |
---|---|---|
e104adcd CE |
1 | #ifndef __DCSVG_H |
2 | #define __DCSVG_H | |
3 | #include <wx/wfstream.h> | |
4 | #include <wx/string.h> | |
5 | ||
0ca4ab85 VS |
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 | ||
e104adcd CE |
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 | ||
0ca4ab85 | 31 | class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC |
e104adcd CE |
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 ; | |
ea76a6a5 WS |
41 | |
42 | double | |
e104adcd CE |
43 | m_logicalScaleX, |
44 | m_logicalScaleY, | |
45 | m_userScaleX, | |
46 | m_userScaleY, | |
47 | m_scaleX, | |
48 | m_scaleY, | |
ea76a6a5 | 49 | m_OriginX, |
e104adcd CE |
50 | m_OriginY, |
51 | m_mm_to_pix_x, | |
52 | m_mm_to_pix_y; | |
53 | ||
ea76a6a5 WS |
54 | bool |
55 | m_needComputeScaleX, | |
e104adcd | 56 | m_needComputeScaleY; // not yet used |
e104adcd | 57 | |
ea76a6a5 WS |
58 | |
59 | bool DoGetPixel(wxCoord, wxCoord, class wxColour *) const | |
60 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; }; | |
e104adcd CE |
61 | |
62 | virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, class wxDC *, | |
63 | wxCoord, wxCoord, int = wxCOPY, bool = 0, int = -1, int = -1) ; | |
64 | ||
ea76a6a5 | 65 | void DoCrossHair(wxCoord, wxCoord) |
e104adcd CE |
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 | ||
9c11ecdb CE |
94 | bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour& WXUNUSED(col), |
95 | int WXUNUSED(style) = wxFLOOD_SURFACE) | |
e104adcd CE |
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 | ||
ea76a6a5 | 102 | void DoSetClippingRegionAsRegion(const class wxRegion &) |
e104adcd CE |
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 | ||
ea76a6a5 | 194 | void write(const wxString &s); |
e104adcd CE |
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 | ||
ea76a6a5 | 204 | bool CanDrawBitmap() const { return true; }; |
e104adcd | 205 | |
ea76a6a5 | 206 | bool CanGetTextExtent() const { return true; }; |
e104adcd CE |
207 | |
208 | int GetDepth() const | |
209 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; }; | |
ea76a6a5 | 210 | |
e104adcd CE |
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 | ||
e104adcd CE |
238 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) |
239 | {DoDrawIcon(icon, x, y) ; return ; }; | |
240 | ||
241 | void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) ; | |
242 | ||
243 | void EndDoc() | |
244 | { return ; }; | |
245 | ||
246 | void EndDrawing() | |
247 | { return ; }; | |
248 | ||
249 | void EndPage() | |
250 | { return ; }; | |
251 | ||
252 | void FloodFill(wxCoord x, wxCoord y, wxColour *colour, int style=wxFLOOD_SURFACE) | |
253 | { DoFloodFill (x, y, *colour, style); return ;} ; | |
254 | ||
255 | wxCoord GetCharHeight() const; | |
256 | ||
257 | wxCoord GetCharWidth() const; | |
258 | ||
9c11ecdb | 259 | void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), wxCoord * WXUNUSED(width), wxCoord * WXUNUSED(height)) |
e104adcd CE |
260 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; }; |
261 | ||
262 | int GetLogicalFunction() | |
263 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY ; }; | |
264 | ||
265 | int GetMapMode() ; | |
266 | ||
e104adcd CE |
267 | bool GetPixel(wxCoord x, wxCoord y, wxColour *colour) |
268 | { return DoGetPixel (x, y, colour) ; } ; | |
269 | ||
270 | void GetUserScale(double *x, double *y) const ; | |
271 | ||
272 | wxCoord LogicalToDeviceX(wxCoord x) const ; | |
273 | ||
274 | wxCoord LogicalToDeviceXRel(wxCoord x) const ; | |
275 | ||
276 | wxCoord LogicalToDeviceY(wxCoord y) const ; | |
277 | ||
278 | wxCoord LogicalToDeviceYRel(wxCoord y) const ; | |
279 | ||
280 | bool Ok() const {return m_OK;}; | |
281 | ||
282 | void SetAxisOrientation( bool xLeftRight, bool yBottomUp ) ; | |
283 | ||
9c11ecdb | 284 | void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxCoord WXUNUSED(width), wxCoord WXUNUSED(height)) |
e104adcd CE |
285 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; }; |
286 | ||
9c11ecdb | 287 | void SetPalette(const wxPalette& WXUNUSED(palette)) |
e104adcd CE |
288 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; }; |
289 | ||
290 | void SetBackground( const wxBrush &brush ) ; | |
291 | ||
292 | void SetBackgroundMode( int mode ) ; | |
293 | ||
294 | void SetBrush(const wxBrush& brush) ; | |
295 | ||
296 | void SetFont(const wxFont& font) ; | |
297 | ||
9c11ecdb | 298 | void SetLogicalFunction(int WXUNUSED(function)) |
e104adcd CE |
299 | { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; }; |
300 | ||
301 | void SetLogicalScale( double x, double y ) ; | |
302 | ||
303 | void SetLogicalOrigin( wxCoord x, wxCoord y ) ; | |
304 | ||
305 | void SetDeviceOrigin( wxCoord x, wxCoord y ) ; | |
306 | ||
307 | void SetMapMode(int anint) ; | |
308 | ||
e104adcd CE |
309 | void SetPen(const wxPen& pen) ; |
310 | ||
311 | void SetUserScale(double xScale, double yScale) ; | |
312 | ||
9c11ecdb | 313 | bool StartDoc(const wxString& WXUNUSED(message)) |
e104adcd CE |
314 | { return FALSE; }; |
315 | ||
316 | void StartPage() | |
317 | { return ; }; | |
318 | ||
319 | ||
320 | }; | |
321 | ||
322 | #ifdef __BORLANDC__ | |
323 | #pragma warn .rch | |
324 | #pragma warn .ccc | |
325 | #endif | |
326 | #endif |