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