#include <string>
#include <vContext.h>
#include <vTitleTab.h>
#include <sTypes.h>
vTitleTab::vTitleTab(vContext * parent) : vContext(parent) {
// Allocate a new font
font = new ogBitFont();
// Set the title to nothing
title = "";
// Retrieve the default font filename out of the style tree
sString * fontFileName = dynamic_cast<sString *>(GetStyle("default.font.filename"));
// Attempt to load the font
if (NULL != fontFileName) {
// I should check for failure here, although everything fails quietly...
// so even if it does fail it won't matter much
font->Load(fontFileName->c_str(), 0);
}
sRGBA8Color * color = dynamic_cast<sRGBA8Color *>(GetStyle("default.font.color.background"));
if (NULL != color)
font->SetBGColor(color->red, color->blue, color->green, color->alpha);
color = dynamic_cast<sRGBA8Color *>(GetStyle("defualt.font.color.foreground"));
if (NULL != color)
font->SetFGColor(color->red, color->blue, color->green, color->alpha);
return;
} // vTitleTab::vTitleTab
void
vTitleTab::Draw(void) {
ogPoint2d points[4];
sBGColor * BGColor = dynamic_cast<sBGColor *>(GetStyle("passive title color"));
if (NULL == BGColor) return;
points[0].x = points[0].y = points[1].y = points[3].x = 0;
points[1].x = points[2].x = GetMaxX()+1;
points[2].y = points[3].y = GetMaxY();
FillGouraudPolygon(4, points, BGColor->colors);
font->JustifyText(*this, centerText, centerText, title.c_str());
return;
} // vTitleTab::Draw()
void
vTitleTab::SetTitle(const std::string newTitle) {
title = newTitle;
return;
} // vTitleTab::SetTitle
vTitleTab::~vTitleTab(void) {
delete font;
font = NULL;
return;
} // vTitleTab::~vTitleTab