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 
virtual bool italic() const =0
Returns true if the font is italic, othwise returns false.
std::string m_italic
The italic attribute name.
Definition: FontXML.h:44
std::string m_size
The point size attribute name.
Definition: FontXML.h:48
FontXML(const FontXML &)
A private copy constructor in order to avoid copying.
A pure virtual base class of XML element wrapper.
Definition: XmlElement.h:30
std::string m_weight
The font weight attribute name.
Definition: FontXML.h:52
A abstract base class for font handling.
Definition: FontBase.h:32
virtual std::string family() const =0
Get the family associated with the font.
bool ok
Definition: CanvasView.cxx:163
intp size(numeric::array arr)
Definition: num_util.cpp:296
XmlElement class interface.
std::string m_family
The family attribute name.
Definition: FontXML.h:40
FontBase class interface.
hippodraw::Axes::Type getAxis(const XmlElement *element, const std::string &tagname)
Returns the axis on which the FontBase object was used.
Definition: FontXML.cxx:75
A base class of XML element controllers.
Definition: BaseXML.h:35
virtual int pointSize() const =0
Get the pointsize of the font.
Type convert(const std::string &axis)
Converts from string representation ot Axes::Type representation.
Definition: AxesType.cxx:32
void setAttributes(XmlElement &, const FontBase &)
Sets the attributes of the element from FontBase object.
Definition: FontXML.cxx:35
A base class that is the interface between GUI and the XML serialization and deserialization.
Definition: XmlController.h:53
virtual int weight() const =0
Get the weight of the font.
Type
Axes constants.
Definition: AxesType.h:31
virtual void setAttribute(const std::string &name, bool value)=0
Sets attribute named name to the int value value.
FontXML class interface.

Generated for HippoDraw Class Library by doxygen