1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSVGFileDC
4 // Author: Chris Elliott
7 // Copyright: (c) Chris Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/string.h"
20 #define wxSVGVersion wxT("v0100")
27 class WXDLLIMPEXP_FWD_BASE wxFileOutputStream
;
31 class WXDLLIMPEXP_FWD_CORE wxSVGFileDC
;
33 class WXDLLIMPEXP_CORE wxSVGFileDCImpl
: public wxDCImpl
36 wxSVGFileDCImpl( wxSVGFileDC
*owner
, const wxString
&filename
,
37 int width
=320, int height
=240, double dpi
=72.0 );
39 virtual ~wxSVGFileDCImpl();
41 bool IsOk() const { return m_OK
; }
43 virtual bool CanDrawBitmap() const { return true; }
44 virtual bool CanGetTextExtent() const { return true; }
46 virtual int GetDepth() const
48 wxFAIL_MSG(wxT("wxSVGFILEDC::GetDepth Call not implemented"));
54 wxFAIL_MSG(wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?"));
57 virtual void DestroyClippingRegion();
59 virtual wxCoord
GetCharHeight() const;
60 virtual wxCoord
GetCharWidth() const;
62 virtual void SetClippingRegion(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
),
63 wxCoord
WXUNUSED(w
), wxCoord
WXUNUSED(h
))
65 wxFAIL_MSG(wxT("wxSVGFILEDC::SetClippingRegion not implemented"));
68 virtual void SetPalette(const wxPalette
& WXUNUSED(palette
))
70 wxFAIL_MSG(wxT("wxSVGFILEDC::SetPalette not implemented"));
73 virtual void GetClippingBox(wxCoord
*WXUNUSED(x
), wxCoord
*WXUNUSED(y
),
74 wxCoord
*WXUNUSED(w
), wxCoord
*WXUNUSED(h
))
76 wxFAIL_MSG(wxT("wxSVGFILEDC::GetClippingBox not implemented"));
79 virtual void SetLogicalFunction(wxRasterOperationMode
WXUNUSED(function
))
81 wxFAIL_MSG(wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented"));
84 virtual wxRasterOperationMode
GetLogicalFunction() const
86 wxFAIL_MSG(wxT("wxSVGFILEDC::GetLogicalFunction() not implemented"));
90 virtual void SetBackground( const wxBrush
&brush
);
91 virtual void SetBackgroundMode( int mode
);
92 virtual void SetBrush(const wxBrush
& brush
);
93 virtual void SetFont(const wxFont
& font
);
94 virtual void SetPen(const wxPen
& pen
);
96 virtual void* GetHandle() const { return NULL
; }
99 virtual bool DoGetPixel(wxCoord
, wxCoord
, wxColour
*) const
101 wxFAIL_MSG(wxT("wxSVGFILEDC::DoGetPixel Call not implemented"));
105 virtual bool DoBlit(wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxDC
*,
106 wxCoord
, wxCoord
, wxRasterOperationMode
= wxCOPY
,
107 bool = 0, int = -1, int = -1);
109 virtual void DoCrossHair(wxCoord
, wxCoord
)
111 wxFAIL_MSG(wxT("wxSVGFILEDC::CrossHair Call not implemented"));
114 virtual void DoDrawArc(wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
, wxCoord
);
116 virtual void DoDrawBitmap(const wxBitmap
&, wxCoord
, wxCoord
, bool = false);
118 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
120 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
122 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
123 double sa
, double ea
);
125 virtual void DoDrawIcon(const wxIcon
&, wxCoord
, wxCoord
);
127 virtual void DoDrawLine (wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
129 virtual void DoDrawLines(int n
, const wxPoint points
[],
130 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
132 virtual void DoDrawPoint(wxCoord
, wxCoord
);
134 virtual void DoDrawPolygon(int n
, const wxPoint points
[],
135 wxCoord xoffset
, wxCoord yoffset
,
136 wxPolygonFillMode fillStyle
);
138 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
140 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
143 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
144 wxCoord w
, wxCoord h
,
145 double radius
= 20) ;
147 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
149 virtual bool DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
),
150 const wxColour
& WXUNUSED(col
),
151 wxFloodFillStyle
WXUNUSED(style
) = wxFLOOD_SURFACE
)
153 wxFAIL_MSG(wxT("wxSVGFILEDC::DoFloodFill Call not implemented"));
157 virtual void DoGetSize(int * x
, int *y
) const
165 virtual void DoGetTextExtent(const wxString
& string
, wxCoord
*w
, wxCoord
*h
,
166 wxCoord
*descent
= NULL
,
167 wxCoord
*externalLeading
= NULL
,
168 const wxFont
*font
= NULL
) const;
170 virtual void DoSetDeviceClippingRegion(const wxRegion
& WXUNUSED(region
))
172 wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetDeviceClippingRegion not yet implemented"));
175 virtual void DoSetClippingRegion(int x
, int y
, int width
, int height
);
177 virtual void DoGetSizeMM( int *width
, int *height
) const;
179 virtual wxSize
GetPPI() const;
181 void Init (const wxString
&filename
, int width
, int height
, double dpi
);
183 void write( const wxString
&s
);
186 // If m_graphics_changed is true, close the current <g> element and start a
187 // new one for the last pen/brush change.
188 void NewGraphicsIfNeeded();
190 // Open a new graphics group setting up all the attributes according to
191 // their current values in wxDC.
192 void DoStartNewGraphics();
194 wxFileOutputStream
*m_outfile
;
196 int m_sub_images
; // number of png format images we have
198 bool m_graphics_changed
; // set by Set{Brush,Pen}()
199 int m_width
, m_height
;
202 // The clipping nesting level is incremented by every call to
203 // SetClippingRegion() and reset when DestroyClippingRegion() is called.
204 size_t m_clipNestingLevel
;
206 // Unique ID for every clipping graphics group: this is simply always
207 // incremented in each SetClippingRegion() call.
208 size_t m_clipUniqueId
;
210 DECLARE_ABSTRACT_CLASS(wxSVGFileDCImpl
)
214 class WXDLLIMPEXP_CORE wxSVGFileDC
: public wxDC
217 wxSVGFileDC(const wxString
& filename
,
221 : wxDC(new wxSVGFileDCImpl(this, filename
, width
, height
, dpi
))
228 #endif // _WX_DCSVG_H_