renderable.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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) { 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