82 lines
1.6 KiB
C++
82 lines
1.6 KiB
C++
#include "menuitem.h"
|
|
|
|
MenuItem::MenuItem(std::string c) {
|
|
caption = c;
|
|
fontsizeadd = 0;
|
|
fontname = "menufont";
|
|
usevalue = false;
|
|
selectable = true;
|
|
grey = false;
|
|
novaluecenter = false;
|
|
|
|
fontengine.fontSelect(fontname);
|
|
}
|
|
|
|
std::string MenuItem::getValue() {
|
|
return value;
|
|
}
|
|
|
|
std::string MenuItem::getCaption() {
|
|
return caption;
|
|
}
|
|
|
|
void MenuItem::setCaption(std::string str) {
|
|
caption = str;
|
|
}
|
|
|
|
int MenuItem::getMaxValueLen() {
|
|
return (int)value.length();
|
|
}
|
|
|
|
void MenuItem::render(Punkt2D pos, bool center, int basefontsize, int maxwidth, int valuewidth, bool highlight, int caplen, int capvallen, int maxlen) {
|
|
fontengine.setSize(basefontsize+fontsizeadd);
|
|
if(highlight)
|
|
fontengine.setColor(1.0f, 0.0f, 0.0f);
|
|
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, (int)pos.x, (int)pos.y, center);
|
|
} else {
|
|
// center und position ggf. überarbeiten..
|
|
|
|
Punkt2D tmp = pos;
|
|
// tmp.x = pos.x - (caplen+vallen+valuewidth)/2;
|
|
tmp.x = pos.x - maxlen/2;
|
|
|
|
// tmp.x = pos.x - valuewidth/2 - fontengine.getTextWidth(caption)/2;
|
|
// tmp.x = pos.x - caplen - valuewidth/2;
|
|
fontengine.renderLine(caption, (int)tmp.x, (int)tmp.y, false);
|
|
|
|
tmp.x += capvallen+valuewidth;
|
|
fontengine.renderLine(value, (int)tmp.x, (int)tmp.y, false);
|
|
}
|
|
}
|
|
|
|
bool MenuItem::isSelectable() {
|
|
return (!grey)&&selectable;
|
|
}
|
|
|
|
bool MenuItem::hasValue() {
|
|
return usevalue;
|
|
}
|
|
|
|
void MenuItem::setFontSizeAdd(int fsa) {
|
|
fontsizeadd = fsa;
|
|
}
|
|
|
|
int MenuItem::getFontSizeAdd() {
|
|
return fontsizeadd;
|
|
}
|
|
|
|
void MenuItem::greyItem(bool _grey) {
|
|
grey = _grey;
|
|
}
|
|
|
|
MenuItem::~MenuItem() {
|
|
|
|
|
|
}
|