]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dcsvg.h
Ensure that key events are sent to focused window first in wxGTK.
[wxWidgets.git] / include / wx / dcsvg.h
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 class WXDLLIMPEXP_FWD_CORE wxSVGFileDC;
32
33 class WXDLLIMPEXP_CORE wxSVGFileDCImpl : public wxDCImpl
34 {
35 public:
36 wxSVGFileDCImpl( wxSVGFileDC *owner, const wxString &filename,
37 int width=320, int height=240, double dpi=72.0 );
38
39 virtual ~wxSVGFileDCImpl();
40
41 bool IsOk() const { return m_OK; }
42
43 virtual bool CanDrawBitmap() const { return true; }
44 virtual bool CanGetTextExtent() const { return true; }
45
46 virtual int GetDepth() const
47 {
48 wxFAIL_MSG(wxT("wxSVGFILEDC::GetDepth Call not implemented"));
49 return -1;
50 }
51
52 virtual void Clear()
53 {
54 wxFAIL_MSG(wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?"));
55 }
56
57 virtual void DestroyClippingRegion()
58 {
59 wxFAIL_MSG(wxT("wxSVGFILEDC::void Call not yet implemented"));
60 }
61
62 virtual wxCoord GetCharHeight() const;
63 virtual wxCoord GetCharWidth() const;
64
65 virtual void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
66 wxCoord WXUNUSED(w), wxCoord WXUNUSED(h))
67 {
68 wxFAIL_MSG(wxT("wxSVGFILEDC::SetClippingRegion not implemented"));
69 }
70
71 virtual void SetPalette(const wxPalette& WXUNUSED(palette))
72 {
73 wxFAIL_MSG(wxT("wxSVGFILEDC::SetPalette not implemented"));
74 }
75
76 virtual void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y),
77 wxCoord *WXUNUSED(w), wxCoord *WXUNUSED(h))
78 {
79 wxFAIL_MSG(wxT("wxSVGFILEDC::GetClippingBox not implemented"));
80 }
81
82 virtual void SetLogicalFunction(wxRasterOperationMode WXUNUSED(function))
83 {
84 wxFAIL_MSG(wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented"));
85 }
86
87 virtual wxRasterOperationMode GetLogicalFunction() const
88 {
89 wxFAIL_MSG(wxT("wxSVGFILEDC::GetLogicalFunction() not implemented"));
90 return wxCOPY;
91 }
92
93 virtual void SetBackground( const wxBrush &brush );
94 virtual void SetBackgroundMode( int mode );
95 virtual void SetBrush(const wxBrush& brush);
96 virtual void SetFont(const wxFont& font);
97 virtual void SetPen(const wxPen& pen);
98
99 virtual void* GetHandle() const { return NULL; }
100
101 private:
102 virtual bool DoGetPixel(wxCoord, wxCoord, wxColour *) const
103 {
104 wxFAIL_MSG(wxT("wxSVGFILEDC::DoGetPixel Call not implemented"));
105 return true;
106 }
107
108 virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, wxDC *,
109 wxCoord, wxCoord, wxRasterOperationMode = wxCOPY,
110 bool = 0, int = -1, int = -1);
111
112 virtual void DoCrossHair(wxCoord, wxCoord)
113 {
114 wxFAIL_MSG(wxT("wxSVGFILEDC::CrossHair Call not implemented"));
115 }
116
117 virtual void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord);
118
119 virtual void DoDrawBitmap(const wxBitmap &, wxCoord, wxCoord, bool = false);
120
121 virtual void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
122
123 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
124
125 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
126 double sa, double ea);
127
128 virtual void DoDrawIcon(const wxIcon &, wxCoord, wxCoord);
129
130 virtual void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
131
132 virtual void DoDrawLines(int n, wxPoint points[],
133 wxCoord xoffset = 0, wxCoord yoffset = 0);
134
135 virtual void DoDrawPoint(wxCoord, wxCoord);
136
137 virtual void DoDrawPolygon(int n, wxPoint points[],
138 wxCoord xoffset, wxCoord yoffset,
139 wxPolygonFillMode fillStyle);
140
141 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
142
143 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
144 double angle);
145
146 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
147 wxCoord w, wxCoord h,
148 double radius = 20) ;
149
150 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
151
152 virtual bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
153 const wxColour& WXUNUSED(col),
154 wxFloodFillStyle WXUNUSED(style) = wxFLOOD_SURFACE)
155 {
156 wxFAIL_MSG(wxT("wxSVGFILEDC::DoFloodFill Call not implemented"));
157 return false;
158 }
159
160 virtual void DoGetSize(int * x, int *y) const
161 {
162 if ( x )
163 *x = m_width;
164 if ( y )
165 *y = m_height;
166 }
167
168 virtual void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h,
169 wxCoord *descent = NULL,
170 wxCoord *externalLeading = NULL,
171 const wxFont *font = NULL) const;
172
173 virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region))
174 {
175 wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetDeviceClippingRegion not yet implemented"));
176 }
177
178 virtual void DoSetClippingRegion( int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
179 {
180 wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetClippingRegion not yet implemented"));
181 }
182
183 virtual void DoGetSizeMM( int *width, int *height ) const;
184
185 virtual wxSize GetPPI() const;
186
187 void Init (const wxString &filename, int width, int height, double dpi);
188
189 void write( const wxString &s );
190
191 private:
192 // If m_graphics_changed is true, close the current <g> element and start a
193 // new one for the last pen/brush change.
194 void NewGraphicsIfNeeded();
195
196 wxFileOutputStream *m_outfile;
197 wxString m_filename;
198 int m_sub_images; // number of png format images we have
199 bool m_OK;
200 bool m_graphics_changed; // set by Set{Brush,Pen}()
201 int m_width, m_height;
202 double m_dpi;
203
204 private:
205 DECLARE_ABSTRACT_CLASS(wxSVGFileDCImpl)
206 };
207
208
209 class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC
210 {
211 public:
212 wxSVGFileDC(const wxString& filename,
213 int width = 320,
214 int height = 240,
215 double dpi = 72.0)
216 : wxDC(new wxSVGFileDCImpl(this, filename, width, height, dpi))
217 {
218 }
219 };
220
221 #endif // wxUSE_SVG
222
223 #endif // _WX_DCSVG_H_