papyrus logo

svg.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSSVG_H
00021 #define PAPYRUSSVG_H
00022 
00023 #include <istream>
00024 #include <libxml++/libxml++.h>
00025 #include <map>
00026 #include <stack>
00027 
00028 #include <expat.h>
00029 #include <papyrus/group.h>
00030 
00031 namespace Papyrus
00032 {
00033 
00037   class SVG : public Group
00038   {
00039     public:
00040       
00041       typedef enum StrType {
00042         FILE,
00043         MEMORY
00044       } StrType;
00045 
00046     protected:
00047       SVG ( );
00048       
00049       SVG ( const Glib::ustring& id, const Glib::ustring& filename, StrType st );
00050 
00051     public:
00052       PAPYRUS_DRAWABLE(SVG);
00053 
00054       static pointer create( );
00055       
00056       static pointer create ( const Glib::ustring& s, StrType st = FILE );
00057 
00058       static pointer create ( const Glib::ustring& id, const Glib::ustring& s, StrType st );
00059 
00060       virtual ~SVG();
00061 
00062       bool set_from_file( const Glib::ustring& svg_filename );
00063 
00064       bool set_from_memory( const Glib::ustring& svg );
00065 
00066       bool set_from_memory( const unsigned char* contents, size_t bytes );
00067 
00068       bool set_from_stream( std::istream& in );
00069 
00070       bool set_from_document( const xmlpp::Document* doc );
00071 
00072       bool set_from_element( const xmlpp::Element* element );
00073 
00074       virtual Glib::ustring svg(unsigned depth=0);
00075 
00076     protected:
00077 
00078       bool process_element( const xmlpp::Element* element, Group& parent, bool in_defs_section, bool is_root=false );
00079 
00080     private:
00081 
00082       std::vector<Cairo::ColorStop> m_color_stops;
00083 
00084       Glib::ustring extract_id_from_uri( const Glib::ustring& uri );
00085       
00086       static void initialize_uri_regular_expression();
00087 
00088 
00089   };
00090 
00091 }
00092 
00093 #endif

Generated on Fri Apr 16 12:40:11 2010 for papyrus by doxygen 1.6.1