AnimatLab  2
Test
StdFont.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 
9 namespace StdUtils
10 {
18 {
19  m_strName = "Arial";
20  m_fltSize = 8.25;
21  m_fltWeight = 400;
22  m_bBold = false;
23  m_bItalic = false;
24  m_bStrikethrough = false;
25  m_bUnderline = false;
26 }
27 
35 {
36 
37 }
38 
49 void CStdFont::Load(CStdXml &oXml, std::string strParamName, bool bThrowError)
50 {
51  if(oXml.FindChildElement(strParamName, bThrowError))
52  {
53  m_strName = oXml.GetChildAttribString("Name", false, false, m_strName);
54  m_fltSize = oXml.GetChildAttribFloat("Size", false, m_fltSize);
55  Std_InValidRange((float) 1, (float) 100, m_fltSize, true, (strParamName + "::Size"));
56 
57  m_fltWeight = oXml.GetChildAttribFloat("Weight", false, m_fltWeight);
58  Std_InValidRange((float) 0, (float) 1000, m_fltWeight, true, (strParamName + "::Weight"));
59 
60  m_bBold = oXml.GetChildAttribBool("Bold", false, m_bBold);
61  m_bItalic = oXml.GetChildAttribBool("Italic", false, m_bItalic);
62  m_bStrikethrough = oXml.GetChildAttribBool("Strikethrough", false, m_bStrikethrough);
63  m_bUnderline = oXml.GetChildAttribBool("Underline", false, m_bUnderline);
64  }
65 }
66 
76 void CStdFont::Save(CStdXml &oXml, std::string strParamName)
77 {
78  oXml.AddChildElement(strParamName);
79  oXml.SetChildAttrib("Name", m_strName);
80  oXml.SetChildAttrib("Size", m_fltSize);
81  oXml.SetChildAttrib("Weight", m_fltWeight);
82  oXml.SetChildAttrib("Bold", m_bBold);
83  oXml.SetChildAttrib("Italic", m_bItalic);
84  oXml.SetChildAttrib("Strikethrough", m_bStrikethrough);
85  oXml.SetChildAttrib("Underline", m_bUnderline);
86 }
87 
88 } //StdUtils
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Definition: StdXml.cpp:256
virtual float GetChildAttribFloat(std::string strAttribName, bool bThrowError=true, float fltDefault=0)
Gets a child attribute float.
Definition: StdXml.cpp:1436
bool m_bBold
true for bold font.
Definition: StdFont.h:30
float m_fltSize
Size of the font.
Definition: StdFont.h:24
virtual void AddChildElement(std::string strElementName)
Adds a child element to current element.
Definition: StdXml.cpp:799
virtual bool GetChildAttribBool(std::string strAttribName, bool bThrowError=true, bool bDefault=false)
Gets a child attribute bool.
Definition: StdXml.cpp:1468
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
bool m_bStrikethrough
true for Strikethrough font.
Definition: StdFont.h:36
std::string m_strName
Name of the font.
Definition: StdFont.h:21
virtual void SetChildAttrib(std::string strAttribName, std::string strVal)
Sets a child attribute.
Definition: StdXml.cpp:1500
bool m_bUnderline
true for Underline font.
Definition: StdFont.h:39
virtual ~CStdFont()
Destructor.
Definition: StdFont.cpp:34
A standard xml manipulation class.
Definition: StdXml.h:19
float m_fltWeight
The weight of the font.
Definition: StdFont.h:27
virtual void Save(CStdXml &oXml, std::string strParamName)
Saves the font.
Definition: StdFont.cpp:76
bool m_bItalic
true for italic font.
Definition: StdFont.h:33
Namespace for the standard utility objects.
Definition: MarkupSTL.cpp:19
virtual std::string GetChildAttribString(std::string strAttribName, bool bCanBeBlank=false, bool bThrowError=true, std::string strDefault="")
Gets a child attribute string.
Definition: StdXml.cpp:1307
CStdFont()
Default constructor.
Definition: StdFont.cpp:17
virtual void Load(CStdXml &oXml, std::string strParamName, bool bThrowError=false)
Loads the font.
Definition: StdFont.cpp:49