1 ////////////////////////////////////////////////////////////////////////////// 2 // Name: svgctrl.h 3 // Purpose: svg control widget 4 // Author: Alex Thuering 5 // Created: 2005/05/07 6 // RCS-ID: $Id: svgctrl.h,v 1.12 2010/07/22 20:20:42 ntalex Exp $ 7 // Copyright: (c) 2005 Alex Thuering 8 // Licence: wxWindows licence 9 ////////////////////////////////////////////////////////////////////////////// 10 11 #ifndef wxSVG_CTRL_H 12 #define wxSVG_CTRL_H 13 14 #include "SVGDocument.h" 15 #include "SVGRectElement.h" 16 #include "SVGTransformable.h" 17 #include <wx/control.h> 18 #include <wx/bitmap.h> 19 20 class wxSVGCtrlBase: public wxControl { 21 public: 22 wxSVGCtrlBase(); 23 wxSVGCtrlBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, 24 const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, 25 const wxString& name = wxPanelNameStr); 26 virtual ~wxSVGCtrlBase(); 27 28 void SetFitToFrame(bool fit = true) { m_fitToFrame = fit; } 29 double GetScale() const; 30 double GetScaleX() const; 31 double GetScaleY() const; 32 wxSVGMatrix GetScreenCTM() const; 33 34 void SetSVG(wxSVGDocument* doc); GetSVG()35 wxSVGDocument* GetSVG() { return m_doc; } 36 /** clears SVGCtrl (deletes svg document) */ 37 void Clear(); 38 39 /** loads svg file */ 40 bool Load(const wxString& filename); 41 /** renders svg and repaints window */ 42 void Refresh(bool eraseBackground = true, const wxRect* rect = NULL); 43 void Refresh(const wxSVGRect* rect); 44 /** Redraws the contents of the given rectangle: 45 only the area inside it will be repainted. */ RefreshRect(const wxRect & rect)46 void RefreshRect(const wxRect& rect) { Refresh(true, &rect); } RefreshRect(const wxSVGRect & rect)47 void RefreshRect(const wxSVGRect& rect) { Refresh(&rect); } 48 49 void MoveElement(wxSVGElement* elem, double Xposition, double Yposition); 50 51 protected: 52 wxSVGDocument* m_doc; 53 bool m_docDelete; 54 bool m_repaint; 55 wxRect m_repaintRect; 56 wxBitmap m_buffer; 57 bool m_fitToFrame; 58 59 virtual void Init(); 60 virtual void OnPaint(wxPaintEvent& event); OnResize(wxSizeEvent & event)61 virtual void OnResize(wxSizeEvent& event) { Refresh(); } OnEraseBackground(wxEraseEvent & event)62 virtual void OnEraseBackground(wxEraseEvent &event) {} 63 virtual void RepaintBuffer(); 64 65 private: 66 DECLARE_ABSTRACT_CLASS(wxSVGCtrlBase) 67 DECLARE_EVENT_TABLE() 68 }; 69 70 class wxSVGCtrl: public wxSVGCtrlBase { 71 public: 72 wxSVGCtrl(); 73 wxSVGCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, 74 const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr); 75 private: 76 DECLARE_DYNAMIC_CLASS(wxSVGCtrl) 77 }; 78 79 80 #endif // wxSVG_CTRL_H 81