#include ".\state_capital_report_generator.h"
void Xport_report_suite::state_capital_report_generator::create_header(Xport::document& doc) const
{
using namespace Xport;
*doc.title() << "State Capital Report";
markup::iterator it = doc.body()->insert(element(Xport::div, "id_header"));
it = it->insert(element(Xport::div, "id_header_img"));
it = it->insert(element(img));
it->attribute(src, "../img/us_regions.png");
it = doc.body()->begin();
it = it->insert(element(h1));
it->insert("State Capital Report");
}
void Xport_report_suite::state_capital_report_generator::create_report_body(Xport::document& doc) const
{
using namespace Xport;
std::vector<state_info> siv;
us_state_report_generator::get_state_data(siv, sf_name, ascending);
std::vector<state_info>::const_iterator it = siv.begin();
element tbl(table);
create_table_header(tbl);
for (; it != siv.end(); ++it) {
element row(tr);
row << (element(td, "", "state_name") << it->name());
row << (element(td, "", "state_abbr") << it->abbr());
row << (element(td, "", "capital") << it->capital());
tbl << row;
}
*doc.body() << tbl;
}
void Xport_report_suite::state_capital_report_generator::create_table_header(Xport::element& tbl) const
{
using namespace Xport;
element tbl_hdr(tr);
tbl_hdr << (element(th, "", "state_name") << "State");
tbl_hdr << (element(th, "", "state_abbr") << "Abbr");
tbl_hdr << (element(th, "", "capital") << "Capital");
tbl << tbl_hdr;
}
void Xport_report_suite::state_capital_report_generator::create_footer(Xport::document& doc) const
{
using namespace Xport;
element footer(Xport::div, "id_footer");
element lnk(a);
lnk.attribute(href, "http://www.xportpro.com");
lnk << "Xport";
footer << (element(h4) << "Report and stylesheet created by " << lnk);
*doc.body() << footer;
}
void Xport_report_suite::state_capital_report_generator::create_stylesheet(Xport::document& doc, Xport::stylesheet& ss) const
{
using namespace Xport;
stylesheet::iterator it = ss.insert(stylesheet_rule("body"));
*it << declaration(css::margin, "0px")
<< declaration(background_color, "#fxfae1");
it = ss.insert(stylesheet_rule("#id_header"));
*it << declaration(css::height, "200px")
<< declaration(background_color, "#fbe497")
<< declaration(margin_bottom, "70px")
<< declaration(border_bottom, "4px solid #b9121b");
it = ss.insert(stylesheet_rule("#id_header_img"));
*it << declaration(css::float_css, "left")
<< declaration(css::width, "200px")
<< declaration(css::height, "100%")
<< declaration(background_color, "white");
it = ss.insert(stylesheet_rule("#id_header_img img"));
*it << declaration(css::width, "150px")
<< declaration(margin_left, "25px")
<< declaration(margin_top, "30px");
it = ss.insert(stylesheet_rule("#id_header h1"));
*it << declaration(text_align, "center")
<< declaration(padding_top, "50px")
<< declaration(css::margin, "0px");
it = ss.insert(stylesheet_rule("table"));
*it << declaration(css::clear, "left")
<< declaration(css::width, "50%")
<< declaration(margin_left, "auto")
<< declaration(margin_right, "auto")
<< declaration(border_collapse, "collapse")
<< declaration(css::border, "4px solid #4c1b1b");
it = ss.insert(stylesheet_rule("th"));
*it << declaration(background_color, "#bd8d46")
<< declaration(line_height, "200%")
<< declaration(border_bottom, "2px solid #4c1b1b")
<< declaration(css::color, "#4c1b1b")
<< declaration(text_align, "left")
<< declaration(padding_left, "10px");
it = ss.insert(stylesheet_rule("td"));
*it << declaration(padding_left, "5px")
<< declaration(background_color, "white")
<< declaration(border_bottom, "1px solid #4c1b1b")
<< declaration(line_height, "150%");
it = ss.insert(stylesheet_rule(".state_name"));
*it << declaration(css::width, "20%");
it = ss.insert(stylesheet_rule("state_abbr"));
*it << declaration(css::width, "50%");
it = ss.insert(stylesheet_rule("td.capital"));
*it << declaration(font_weight, "bold");
*it << declaration(css::color, "#4c1b1b");
it = ss.insert(stylesheet_rule("#id_footer"));
*it << declaration(css::height, "50px")
<< declaration(background_color, "#bd8d46")
<< declaration(css::width, "50%")
<< declaration(css::border, "4px solid #b9121b")
<< declaration(margin_left, "auto")
<< declaration(margin_right, "auto")
<< declaration(margin_top, "50px");
it = ss.insert(stylesheet_rule("#id_footer h4"));
*it << declaration(text_align, "center")
<< declaration(margin_top, "15px");
element css_link(Xport::link);
css_link.attribute(rel, "stylesheet");
css_link.attribute(type, "text/css");
css_link.attribute(href, "state_capital_report.css");
*doc.head() << css_link;
}