libsegl/glmenu/menuitem.cpp

72 lines
1.4 KiB
C++
Raw Normal View History

#include "menuitem.h"
MenuItem::MenuItem(std::string c) {
caption = c;
fontsizeadd = 0;
fontname = "menufont";
usevalue = false;
2008-03-23 18:00:55 +01:00
selectable = true;
grey = false;
novaluecenter = false;
fontengine.fontSelect(fontname);
}
2008-03-23 18:00:55 +01:00
std::string MenuItem::getValue() {
return value;
}
std::string MenuItem::getCaption() {
return caption;
}
void MenuItem::setCaption(std::string str) {
caption = str;
}
void MenuItem::render(Punkt2D pos, bool center, int basefontsize, int maxwidth, int valuewidth, bool highlight, int caplen, int vallen) {
fontengine.setSize(basefontsize+fontsizeadd);
if(highlight)
fontengine.setColor(1.0f, 0.0f, 0.0f);
2008-03-23 18:00:55 +01:00
else if(grey)
fontengine.setColor(0.8f, 0.8f, 0.8f);
else
fontengine.setColor(1.0f, 1.0f, 1.0f);
if(!usevalue) {
fontengine.renderLine(caption, pos.x, pos.y, center);
} else {
// center und position ggf. <20>berarbeiten..
2008-03-23 18:00:55 +01:00
Punkt2D tmp = pos;
tmp.x = pos.x - valuewidth/2 - fontengine.getTextWidth(caption)/2;
fontengine.renderLine(caption, tmp.x, tmp.y, center);
2008-03-23 18:00:55 +01:00
tmp.x = pos.x + valuewidth/2;
fontengine.renderLine(value, tmp.x, tmp.y, false);
2008-03-23 18:00:55 +01:00
// std::cout << "Value: " << value << std::endl;
}
}
2008-03-23 18:00:55 +01:00
bool MenuItem::isSelectable() {
return (!grey)&&selectable;
}
void MenuItem::setFontSizeAdd(int fsa) {
fontsizeadd = fsa;
}
int MenuItem::getFontSizeAdd() {
return fontsizeadd;
}
2008-03-23 18:00:55 +01:00
void MenuItem::greyItem(bool _grey) {
grey = _grey;
}
MenuItem::~MenuItem() {
}