]>
Commit | Line | Data |
---|---|---|
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 | ||
12 | #ifndef __DCSVG_H | |
13 | #define __DCSVG_H | |
14 | ||
15 | #include "wx/wfstream.h" | |
16 | #include "wx/string.h" | |
17 | ||
18 | #define wxSVGVersion wxT("v0100") | |
19 | ||
20 | class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC | |
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 ; | |
30 | ||
31 | double | |
32 | m_logicalScaleX, | |
33 | m_logicalScaleY, | |
34 | m_userScaleX, | |
35 | m_userScaleY, | |
36 | m_scaleX, | |
37 | m_scaleY, | |
38 | m_OriginX, | |
39 | m_OriginY, | |
40 | m_mm_to_pix_x, | |
41 | m_mm_to_pix_y; | |
42 | ||
43 | bool | |
44 | m_needComputeScaleX, | |
45 | m_needComputeScaleY; // not yet used | |
46 | ||
47 | ||
48 | bool DoGetPixel(wxCoord, wxCoord, class wxColour *) const | |
49 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; } | |
50 | ||
51 | virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, class wxDC *, | |
52 | wxCoord, wxCoord, int = wxCOPY, bool = 0, int = -1, int = -1) ; | |
53 | ||
54 | void DoCrossHair(wxCoord, wxCoord) | |
55 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::CrossHair Call not implemented")); return ; } | |
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 | ||
83 | bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour& WXUNUSED(col), | |
84 | int WXUNUSED(style) = wxFLOOD_SURFACE) | |
85 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); return false ; } | |
86 | ||
87 | void DoGetSize(int * x, int *y) const { *x = m_width; *y = m_height ; return ; } | |
88 | ||
89 | void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, wxFont *font = NULL) const ; | |
90 | ||
91 | void DoSetClippingRegionAsRegion(const class wxRegion &) | |
92 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; } | |
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 | ||
183 | void write(const wxString &s); | |
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 | ||
193 | bool CanDrawBitmap() const { return true; } | |
194 | ||
195 | bool CanGetTextExtent() const { return true; } | |
196 | ||
197 | int GetDepth() const | |
198 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; } | |
199 | ||
200 | void BeginDrawing() { return;} | |
201 | ||
202 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, int logicalFunc = wxCOPY, bool useMask = false) | |
203 | { return DoBlit(xdest, ydest, width, height, source, xsrc, ysrc, logicalFunc, useMask); } | |
204 | ||
205 | void Clear() | |
206 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; } | |
207 | ||
208 | void CrossHair(wxCoord x, wxCoord y) | |
209 | { DoCrossHair (x,y); return; } | |
210 | ||
211 | virtual void ComputeScaleAndOrigin(); | |
212 | ||
213 | void DestroyClippingRegion() | |
214 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; } | |
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) | |
225 | { DoDrawBitmap ( bitmap, x, y, transparent ) ; return ;} | |
226 | ||
227 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) | |
228 | {DoDrawIcon(icon, x, y) ; return ; } | |
229 | ||
230 | void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) ; | |
231 | ||
232 | void EndDoc() | |
233 | { return ; } | |
234 | ||
235 | void EndDrawing() | |
236 | { return ; } | |
237 | ||
238 | void EndPage() | |
239 | { return ; } | |
240 | ||
241 | void FloodFill(wxCoord x, wxCoord y, wxColour *colour, int style=wxFLOOD_SURFACE) | |
242 | { DoFloodFill (x, y, *colour, style); return ;} | |
243 | ||
244 | wxCoord GetCharHeight() const; | |
245 | ||
246 | wxCoord GetCharWidth() const; | |
247 | ||
248 | void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), wxCoord * WXUNUSED(width), wxCoord * WXUNUSED(height)) | |
249 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; } | |
250 | ||
251 | int GetLogicalFunction() | |
252 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY ; } | |
253 | ||
254 | int GetMapMode() ; | |
255 | ||
256 | bool GetPixel(wxCoord x, wxCoord y, wxColour *colour) | |
257 | { return DoGetPixel (x, y, colour) ; } | |
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 | ||
269 | bool Ok() const {return m_OK;} | |
270 | ||
271 | void SetAxisOrientation( bool xLeftRight, bool yBottomUp ) ; | |
272 | ||
273 | void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxCoord WXUNUSED(width), wxCoord WXUNUSED(height)) | |
274 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; } | |
275 | ||
276 | void SetPalette(const wxPalette& WXUNUSED(palette)) | |
277 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; } | |
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 | ||
287 | void SetLogicalFunction(int WXUNUSED(function)) | |
288 | { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; } | |
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 | ||
298 | void SetPen(const wxPen& pen) ; | |
299 | ||
300 | void SetUserScale(double xScale, double yScale) ; | |
301 | ||
302 | bool StartDoc(const wxString& WXUNUSED(message)) | |
303 | { return false; } | |
304 | ||
305 | void StartPage() | |
306 | { return ; } | |
307 | }; | |
308 | ||
309 | #endif // __DCSVG_H |