FontXML.cxx

Go to the documentation of this file.
00001 
00012 #include "FontXML.h"
00013 
00014 #include "XmlElement.h"
00015 
00016 #include "graphics/FontBase.h"
00017 
00018 #include <cassert>
00019 
00020 using std::string;
00021 
00022 namespace hippodraw {
00023 
00024 FontXML::FontXML ( XmlController * controller )
00025   : BaseXML ( "Font", controller ),
00026     m_family ( "family" ),
00027     m_italic ( "italic" ),
00028     m_size ( "size" ),
00029     m_weight ( "weight" )
00030 {
00031 }
00032 
00033 void
00034 FontXML::
00035 setAttributes ( XmlElement & tag, const FontBase & font )
00036 {
00037   string family = font.family ();
00038   tag.setAttribute ( m_family, family );
00039 
00040   bool italic = font.italic ();
00041   tag.setAttribute ( m_italic, italic );
00042 
00043   int size = font.pointSize ();
00044   tag.setAttribute ( m_size, size );
00045 
00046   int weight = font.weight ();
00047   tag.setAttribute ( m_weight, weight );
00048 }
00049 
00050 void
00051 FontXML::
00052 setAttributes ( const XmlElement * element, FontBase * font )
00053 {
00054   string family;
00055   bool ok = element -> attribute ( m_family, family );
00056   font -> setFamily ( family );
00057 
00058   bool italic;
00059   ok = element -> attribute ( m_italic, italic );
00060   assert ( ok );
00061   font -> setItalic ( italic );
00062 
00063   int size;
00064   ok = element -> attribute ( m_size, size );
00065   font -> setPointSize ( size );
00066 
00067   int weight;
00068   ok = element -> attribute ( m_weight, weight );
00069   font -> setWeight ( weight );
00070 
00071 }
00072 
00073 Axes::Type
00074 FontXML::
00075 getAxis ( const XmlElement * element, const std::string & tagname )
00076 {
00077   string value;
00078   bool ok = element -> attribute ( tagname, value );
00079   assert ( ok );
00080 
00081   return Axes::convert ( value );
00082 }
00083 
00084 } // namespace hippodraw
00085 

Generated for HippoDraw Class Library by doxygen