papyrus logo

renderable.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 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 PAPYRUSRENDERABLE_H
00021 #define PAPYRUSRENDERABLE_H
00022 
00023 #include <map>
00024 #include <glibmm/ustring.h>
00025 #include <papyrus/pointer.h>
00026 
00027 #include <papyrus/object.h>
00028 #include <papyrus/utility.h>
00029 #include <cairomm/cairomm.h>
00030 
00031 namespace Papyrus
00032 {
00033 
00058   class Renderable: public Object
00059   {
00060     protected:
00061       Renderable ( const Glib::ustring& id ) : Object ( id )
00062       { }
00063 
00064     public:
00065       typedef PapyrusPointer<Renderable> pointer;
00066 
00067       virtual ~Renderable()
00068       { }
00069 
00070       virtual void render ( Cairo::RefPtr<Cairo::Context> cairo ) const = 0;
00071 
00072       virtual void render( Cairo::RefPtr<Cairo::Context> cairo, double x, double y, double w, double h ) const { this->render(cairo); }
00073 
00077       virtual Glib::ustring svg(unsigned depth=0) /*= 0;*/ { return Glib::ustring(); }
00078 
00079       PAPYRUS_CLASS_NAME ( "Renderable" );
00080 
00081     protected:
00082   
00083       Glib::ustring svg_spacing(unsigned depth)
00084       {
00085         Glib::ustring s;
00086         for ( unsigned i = 0; i < depth; i++ )
00087           s += "  ";
00088         return s;
00089       }
00090 
00091       Glib::ustring svg_id()
00092       {
00093         Glib::ustring s;
00094         if ( ! m_id.empty() )
00095           s += "id=\"" + m_id + "\" ";
00096         return s;
00097       }
00098 
00099 
00100   };
00101 
00102 };
00103 
00104 #endif

Generated on Wed Mar 18 12:34:04 2009 for papyrus by doxygen 1.5.7.1