#include <map>
#include "DocStyle.h"
#include "Util.h"
struct TextRoleProperties
{
std::string m_fontName;
float m_fontSize;
float m_foregoundColor[4];
float m_backgoundColor[4];
};
struct DocStyle::Pimpl
{
TextRoleProperties m_defaults;
std::map<TextRole, TextRoleProperties> m_rolePropertiesMap;
//fontStyles[currentStyle], fontSizes[currentHeadingLevel[stackDepth]]
//HPDF_Font* fontStyles[4];
};
DocStyle::DocStyle() : m_pimpl(std::make_unique<Pimpl>())
{
}
DocStyle::~DocStyle()
{
}
void DocStyle::readStyleFile(const char* /*a_fileName*/)
{
/*
NormalRole,
Heading1Role,
Heading2Role,
Heading3Role,
Heading4Role,
BoldRole,
ItalicsRole,
QuoteRole,
CodeRole,
ListRole,
LinkRole,
EmailAddressRole,
OtherRole
*/
}
void DocStyle::writeStyleFile(const char* /*a_fileName*/)
{
}
void DocStyle::font(TextRole a_role, std::string& a_fontName, float& a_fontSize)
{
TextRoleProperties props = m_pimpl->m_defaults;
if (m_pimpl->m_rolePropertiesMap.find(a_role) != m_pimpl->m_rolePropertiesMap.end())
props = m_pimpl->m_rolePropertiesMap[a_role];
a_fontName = props.m_fontName;
a_fontSize = props.m_fontSize;
}
void DocStyle::foregroundColor(TextRole a_role, float& a_red, float& a_green, float& a_blue, float& a_alpha)
{
TextRoleProperties props = m_pimpl->m_defaults;
if (m_pimpl->m_rolePropertiesMap.find(a_role) != m_pimpl->m_rolePropertiesMap.end())
props = m_pimpl->m_rolePropertiesMap[a_role];
a_red = props.m_foregoundColor[0];
a_green = props.m_foregoundColor[1];
a_blue = props.m_foregoundColor[2];
a_alpha = props.m_foregoundColor[3];
}
void DocStyle::backgroundColor(TextRole a_role, float& a_red, float& a_green, float& a_blue, float& a_alpha)
{
TextRoleProperties props = m_pimpl->m_defaults;
if (m_pimpl->m_rolePropertiesMap.find(a_role) != m_pimpl->m_rolePropertiesMap.end())
props = m_pimpl->m_rolePropertiesMap[a_role];
a_red = props.m_backgoundColor[0];
a_green = props.m_backgoundColor[1];
a_blue = props.m_backgoundColor[2];
a_alpha = props.m_backgoundColor[3];
}
void DocStyle::adornNewPage(DocOutputPage& page)
{
page.setFontSize(0, 12.0f);
page.setColor(0xff0000);
page.drawText(2.0f, 12.0f, "Some Header Text");
page.drawText(2.0f, page.height() - 12.0f, "Some Footer Text");
}