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