]>
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 _WX_DCSVG_H_ | |
13 | #define _WX_DCSVG_H_ | |
14 | ||
15 | #include "wx/string.h" | |
16 | #include "wx/dc.h" | |
17 | ||
18 | #if wxUSE_SVG | |
19 | ||
20 | #define wxSVGVersion wxT("v0100") | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma warn -8008 | |
24 | #pragma warn -8066 | |
25 | #endif | |
26 | ||
27 | class WXDLLIMPEXP_FWD_BASE wxFileOutputStream; | |
28 | ||
29 | ||
30 | ||
31 | #if wxUSE_NEW_DC | |
32 | class WXDLLIMPEXP_FWD_BASE wxSVGFileDC; | |
33 | ||
34 | class WXDLLIMPEXP_CORE wxSVGFileImplDC : public wxImplDC | |
35 | #else | |
36 | #define wxSVGFileImplDC wxSVGFileDC | |
37 | class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC | |
38 | #endif | |
39 | { | |
40 | public: | |
41 | ||
42 | #if wxUSE_NEW_DC | |
43 | wxSVGFileImplDC( wxSVGFileDC *owner, const wxString &filename, | |
44 | int width=320, int height=240, double dpi=72.0 ); | |
45 | #else | |
46 | wxSVGFileDC( const wxString &filename, | |
47 | int width=320, int height=240, double dpi=72.0 ); | |
48 | #endif | |
49 | ||
50 | virtual ~wxSVGFileImplDC(); | |
51 | ||
52 | bool IsOk() const { return m_OK; } | |
53 | ||
54 | virtual bool CanDrawBitmap() const { return true; } | |
55 | virtual bool CanGetTextExtent() const { return true; } | |
56 | ||
57 | virtual int GetDepth() const | |
58 | { | |
59 | wxFAIL_MSG(wxT("wxSVGFILEDC::GetDepth Call not implemented")); | |
60 | return -1; | |
61 | } | |
62 | ||
63 | virtual void Clear() | |
64 | { | |
65 | wxFAIL_MSG(wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); | |
66 | } | |
67 | ||
68 | virtual void DestroyClippingRegion() | |
69 | { | |
70 | wxFAIL_MSG(wxT("wxSVGFILEDC::void Call not yet implemented")); | |
71 | } | |
72 | ||
73 | virtual wxCoord GetCharHeight() const; | |
74 | virtual wxCoord GetCharWidth() const; | |
75 | ||
76 | virtual void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), | |
77 | wxCoord WXUNUSED(w), wxCoord WXUNUSED(h)) | |
78 | { | |
79 | wxFAIL_MSG(wxT("wxSVGFILEDC::SetClippingRegion not implemented")); | |
80 | } | |
81 | ||
82 | virtual void SetPalette(const wxPalette& WXUNUSED(palette)) | |
83 | { | |
84 | wxFAIL_MSG(wxT("wxSVGFILEDC::SetPalette not implemented")); | |
85 | } | |
86 | ||
87 | virtual void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), | |
88 | wxCoord *WXUNUSED(w), wxCoord *WXUNUSED(h)) | |
89 | { | |
90 | wxFAIL_MSG(wxT("wxSVGFILEDC::GetClippingBox not implemented")); | |
91 | } | |
92 | ||
93 | virtual void SetLogicalFunction(int WXUNUSED(function)) | |
94 | { | |
95 | wxFAIL_MSG(wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented")); | |
96 | } | |
97 | ||
98 | virtual int GetLogicalFunction() const | |
99 | { | |
100 | wxFAIL_MSG(wxT("wxSVGFILEDC::GetLogicalFunction() not implemented")); | |
101 | return -1; | |
102 | } | |
103 | ||
104 | virtual void SetBackground( const wxBrush &brush ); | |
105 | virtual void SetBackgroundMode( int mode ); | |
106 | virtual void SetBrush(const wxBrush& brush); | |
107 | virtual void SetFont(const wxFont& font); | |
108 | virtual void SetPen(const wxPen& pen); | |
109 | ||
110 | #if wxUSE_NEW_DC | |
111 | #else | |
112 | virtual void SetMapMode( int mode ); | |
113 | virtual void SetUserScale( double x, double y ); | |
114 | virtual void SetLogicalScale( double x, double y ); | |
115 | virtual void SetLogicalOrigin( wxCoord x, wxCoord y ); | |
116 | virtual void SetDeviceOrigin( wxCoord x, wxCoord y ); | |
117 | virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); | |
118 | #endif | |
119 | ||
120 | private: | |
121 | virtual bool DoGetPixel(wxCoord, wxCoord, wxColour *) const | |
122 | { | |
123 | wxFAIL_MSG(wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); | |
124 | return true; | |
125 | } | |
126 | ||
127 | virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, wxDC *, | |
128 | wxCoord, wxCoord, int = wxCOPY, | |
129 | bool = 0, int = -1, int = -1); | |
130 | ||
131 | virtual void DoCrossHair(wxCoord, wxCoord) | |
132 | { | |
133 | wxFAIL_MSG(wxT("wxSVGFILEDC::CrossHair Call not implemented")); | |
134 | } | |
135 | ||
136 | virtual void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord); | |
137 | ||
138 | virtual void DoDrawBitmap(const wxBitmap &, wxCoord, wxCoord, bool = 0); | |
139 | ||
140 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord w, wxCoord h); | |
141 | ||
142 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h); | |
143 | ||
144 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
145 | double sa, double ea); | |
146 | ||
147 | virtual void DoDrawIcon(const wxIcon &, wxCoord, wxCoord); | |
148 | ||
149 | virtual void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
150 | ||
151 | virtual void DoDrawLines(int n, wxPoint points[], | |
152 | wxCoord xoffset = 0, wxCoord yoffset = 0); | |
153 | ||
154 | virtual void DoDrawPoint(wxCoord, wxCoord); | |
155 | ||
156 | virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle); | |
157 | ||
158 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h); | |
159 | ||
160 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
161 | double angle); | |
162 | ||
163 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
164 | wxCoord w, wxCoord h, | |
165 | double radius = 20) ; | |
166 | ||
167 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
168 | ||
169 | virtual bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), | |
170 | const wxColour& WXUNUSED(col), | |
171 | int WXUNUSED(style) = wxFLOOD_SURFACE) | |
172 | { | |
173 | wxFAIL_MSG(wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); | |
174 | return false; | |
175 | } | |
176 | ||
177 | virtual void DoGetSize(int * x, int *y) const | |
178 | { | |
179 | if ( x ) | |
180 | *x = m_width; | |
181 | if ( y ) | |
182 | *y = m_height; | |
183 | } | |
184 | ||
185 | virtual void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, | |
186 | wxCoord *descent = NULL, | |
187 | wxCoord *externalLeading = NULL, | |
188 | const wxFont *font = NULL) const; | |
189 | ||
190 | virtual void DoSetClippingRegionAsRegion(const wxRegion& WXUNUSED(region)) | |
191 | { | |
192 | wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion not yet implemented")); | |
193 | } | |
194 | ||
195 | virtual void DoSetClippingRegion( int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) | |
196 | { | |
197 | wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetClippingRegion not yet implemented")); | |
198 | } | |
199 | ||
200 | virtual void DoGetSizeMM( int *width, int *height ) const; | |
201 | ||
202 | virtual wxSize GetPPI() const; | |
203 | ||
204 | void Init (const wxString &filename, int width, int height, double dpi); | |
205 | ||
206 | void NewGraphics(); | |
207 | ||
208 | void write( const wxString &s ); | |
209 | ||
210 | private: | |
211 | wxFileOutputStream *m_outfile; | |
212 | wxString m_filename; | |
213 | int m_sub_images; // number of png format images we have | |
214 | bool m_OK; | |
215 | bool m_graphics_changed; | |
216 | int m_width, m_height; | |
217 | double m_dpi; | |
218 | ||
219 | private: | |
220 | DECLARE_ABSTRACT_CLASS(wxSVGFileImplDC) | |
221 | }; | |
222 | ||
223 | ||
224 | #if wxUSE_NEW_DC | |
225 | class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC | |
226 | { | |
227 | public: | |
228 | wxSVGFileDC( const wxString &filename, | |
229 | int width=320, int height=240, double dpi=72.0 ) | |
230 | { | |
231 | m_pimpl = new wxSVGFileImplDC( this, filename, width, height, dpi ); | |
232 | } | |
233 | }; | |
234 | #endif | |
235 | ||
236 | ||
237 | #endif // wxUSE_SVG | |
238 | ||
239 | #endif // _WX_DCSVG_H_ |