libsegl/glmenu/menuitem.cpp

40 lines
880 B
C++

#include "menuitem.h"
MenuItem::MenuItem(std::string c) {
caption = c;
fontsizeadd = 0;
fontname = "menufont";
usevalue = false;
fontengine.fontSelect(fontname);
}
void MenuItem::render(Punkt2D pos, bool center, int basefontsize, int maxwidth, int valuewidth, bool highlight) {
fontengine.setSize(basefontsize+fontsizeadd);
if(highlight)
fontengine.setColor(1.0f, 0.0f, 0.0f);
else
fontengine.setColor(1.0f, 1.0f, 1.0f);
if(!usevalue) {
fontengine.renderLine(caption, pos.x, pos.y, center);
} else {
// center und position ggf. überarbeiten..
Punkt2D tmp;
tmp = pos - valuewidth/2 - fontengine.getTextWidth(caption)/2;
fontengine.renderLine(caption, tmp.x, tmp.y, center);
tmp = pos + valuewidth/2;
fontengine.renderLine(value, tmp.x, tmp.y, false);
}
}
int MenuItem::getFontSizeAdd() {
return fontsizeadd;
}
MenuItem::~MenuItem() {
}