]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dcsvg.h
Fix for wxTextCtrl::GetSelection for singel line controls in GTK2 mode
[wxWidgets.git] / include / wx / dcsvg.h
CommitLineData
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 31class 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 ;
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
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
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
195 public:
196
197 wxSVGFileDC (wxString f);
198 wxSVGFileDC (wxString f, int Width, int Height);
199 wxSVGFileDC (wxString f, int Width, int Height, float dpi);
200 ~wxSVGFileDC();
201
202
203 bool CanDrawBitmap() const { return TRUE ; };
204
205 bool CanGetTextExtent() const { return TRUE ; };
206
207 int GetDepth() const
208 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; };
209
210 void BeginDrawing() { return;};
211
212 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, int logicalFunc = wxCOPY, bool useMask = FALSE)
213 { return DoBlit(xdest, ydest, width, height, source, xsrc, ysrc, logicalFunc, useMask); };
214
215 void Clear()
216 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; };
217
218 void CrossHair(wxCoord x, wxCoord y)
219 { DoCrossHair (x,y); return; };
220
221 void ComputeScaleAndOrigin() ;
222
223 void DestroyClippingRegion()
224 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; };
225
226 wxCoord DeviceToLogicalX(wxCoord x) const ;
227
228 wxCoord DeviceToLogicalXRel(wxCoord x) const ;
229
230 wxCoord DeviceToLogicalY(wxCoord y) const ;
231
232 wxCoord DeviceToLogicalYRel(wxCoord y) const ;
233
234 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool transparent)
235 { DoDrawBitmap ( bitmap, x, y, transparent ) ; return ;};
236
237
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
267 bool GetOptimization()
268 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::GetOptimization() No optimization code used")); return TRUE ; };
269
270 bool GetPixel(wxCoord x, wxCoord y, wxColour *colour)
271 { return DoGetPixel (x, y, colour) ; } ;
272
273 void GetUserScale(double *x, double *y) const ;
274
275 wxCoord LogicalToDeviceX(wxCoord x) const ;
276
277 wxCoord LogicalToDeviceXRel(wxCoord x) const ;
278
279 wxCoord LogicalToDeviceY(wxCoord y) const ;
280
281 wxCoord LogicalToDeviceYRel(wxCoord y) const ;
282
283 bool Ok() const {return m_OK;};
284
285 void SetAxisOrientation( bool xLeftRight, bool yBottomUp ) ;
286
9c11ecdb 287 void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxCoord WXUNUSED(width), wxCoord WXUNUSED(height))
e104adcd
CE
288 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; };
289
9c11ecdb 290 void SetPalette(const wxPalette& WXUNUSED(palette))
e104adcd
CE
291 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; };
292
293 void SetBackground( const wxBrush &brush ) ;
294
295 void SetBackgroundMode( int mode ) ;
296
297 void SetBrush(const wxBrush& brush) ;
298
299 void SetFont(const wxFont& font) ;
300
9c11ecdb 301 void SetLogicalFunction(int WXUNUSED(function))
e104adcd
CE
302 { wxASSERT_MSG (FALSE, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; };
303
304 void SetLogicalScale( double x, double y ) ;
305
306 void SetLogicalOrigin( wxCoord x, wxCoord y ) ;
307
308 void SetDeviceOrigin( wxCoord x, wxCoord y ) ;
309
310 void SetMapMode(int anint) ;
311
9c11ecdb 312 void SetOptimization(bool WXUNUSED(optimize)) { return ; };
e104adcd
CE
313
314 void SetPen(const wxPen& pen) ;
315
316 void SetUserScale(double xScale, double yScale) ;
317
9c11ecdb 318 bool StartDoc(const wxString& WXUNUSED(message))
e104adcd
CE
319 { return FALSE; };
320
321 void StartPage()
322 { return ; };
323
324
325};
326
327#ifdef __BORLANDC__
328#pragma warn .rch
329#pragma warn .ccc
330#endif
331#endif