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