FontXML.cxx
Go to the documentation of this file.
1 
12 #include "FontXML.h"
13 
14 #include "XmlElement.h"
15 
16 #include "graphics/FontBase.h"
17 
18 #include <cassert>
19 
20 using std::string;
21 
22 namespace hippodraw {
23 
25  : BaseXML ( "Font", controller ),
26  m_family ( "family" ),
27  m_italic ( "italic" ),
28  m_size ( "size" ),
29  m_weight ( "weight" )
30 {
31 }
32 
33 void
35 setAttributes ( XmlElement & tag, const FontBase & font )
36 {
37  string family = font.family ();
38  tag.setAttribute ( m_family, family );
39 
40  bool italic = font.italic ();
41  tag.setAttribute ( m_italic, italic );
42 
43  int size = font.pointSize ();
44  tag.setAttribute ( m_size, size );
45 
46  int weight = font.weight ();
47  tag.setAttribute ( m_weight, weight );
48 }
49 
50 void
52 setAttributes ( const XmlElement * element, FontBase * font )
53 {
54  string family;
55  bool ok = element -> attribute ( m_family, family );
56  font -> setFamily ( family );
57 
58  bool italic;
59  ok = element -> attribute ( m_italic, italic );
60  assert ( ok );
61  font -> setItalic ( italic );
62 
63  int size;
64  ok = element -> attribute ( m_size, size );
65  font -> setPointSize ( size );
66 
67  int weight;
68  ok = element -> attribute ( m_weight, weight );
69  font -> setWeight ( weight );
70 
71 }
72 
75 getAxis ( const XmlElement * element, const std::string & tagname )
76 {
77  string value;
78  bool ok = element -> attribute ( tagname, value );
79  assert ( ok );
80 
81  return Axes::convert ( value );
82 }
83 
84 } // namespace hippodraw
85 

Generated for HippoDraw Class Library by doxygen