2008-03-08 23:03:26 +01:00
|
|
|
|
#include "menuitem.h"
|
|
|
|
|
|
2008-08-10 17:14:54 +02:00
|
|
|
|
namespace segl {
|
|
|
|
|
|
2008-03-08 23:03:26 +01:00
|
|
|
|
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;
|
2008-03-08 23:03:26 +01:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-31 13:00:13 +02:00
|
|
|
|
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) {
|
2008-03-08 23:03:26 +01:00
|
|
|
|
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);
|
2008-03-08 23:03:26 +01:00
|
|
|
|
else
|
|
|
|
|
fontengine.setColor(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
|
|
if(!usevalue) {
|
2008-03-31 00:14:35 +02:00
|
|
|
|
fontengine.renderLine(caption, (int)pos.x, (int)pos.y, center);
|
2008-03-08 23:03:26 +01:00
|
|
|
|
} else {
|
2008-08-10 17:14:54 +02:00
|
|
|
|
// center und position ggf. <20>berarbeiten..
|
2008-03-08 23:03:26 +01:00
|
|
|
|
|
2008-03-23 18:00:55 +01:00
|
|
|
|
Punkt2D tmp = pos;
|
2008-03-31 13:00:13 +02:00
|
|
|
|
// tmp.x = pos.x - (caplen+vallen+valuewidth)/2;
|
|
|
|
|
tmp.x = pos.x - maxlen/2;
|
2008-03-23 18:00:55 +01:00
|
|
|
|
|
2008-03-31 00:14:35 +02:00
|
|
|
|
// 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);
|
2008-03-23 18:00:55 +01:00
|
|
|
|
|
2008-03-31 13:00:13 +02:00
|
|
|
|
tmp.x += capvallen+valuewidth;
|
2008-03-31 00:14:35 +02:00
|
|
|
|
fontengine.renderLine(value, (int)tmp.x, (int)tmp.y, false);
|
2008-03-08 23:03:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-23 18:00:55 +01:00
|
|
|
|
bool MenuItem::isSelectable() {
|
|
|
|
|
return (!grey)&&selectable;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-31 13:00:13 +02:00
|
|
|
|
bool MenuItem::hasValue() {
|
|
|
|
|
return usevalue;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-23 18:00:55 +01:00
|
|
|
|
void MenuItem::setFontSizeAdd(int fsa) {
|
|
|
|
|
fontsizeadd = fsa;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-08 23:03:26 +01:00
|
|
|
|
int MenuItem::getFontSizeAdd() {
|
|
|
|
|
return fontsizeadd;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-23 18:00:55 +01:00
|
|
|
|
void MenuItem::greyItem(bool _grey) {
|
|
|
|
|
grey = _grey;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-08 23:03:26 +01:00
|
|
|
|
MenuItem::~MenuItem() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2008-08-10 17:14:54 +02:00
|
|
|
|
|
|
|
|
|
} // namespace segl
|