+Label::Label(Widget *parent)
+ : Widget(parent),
+ _text(""),
+ _justify_horz(RenderStyle::LeftTopJustify),
+ _justify_vert(RenderStyle::LeftTopJustify),
+ _highlight(false)
+{
+ styleChanged(*RenderStyle::style(screen()));
+}
+
+Label::~Label()
+{
+}
+
+void Label::setHorizontalJustify(RenderStyle::Justify j)
+{
+ _justify_horz = j;
+ refresh();
+}
+
+void Label::setVerticalJustify(RenderStyle::Justify j)
+{
+ _justify_vert = j;
+ refresh();
+}
+
+void Label::setHighlighted(bool h)
+{
+ _highlight = h;
+ styleChanged(*RenderStyle::style(screen()));
+ refresh();
+}
+
+void Label::setText(const ustring &text)
+{
+ bool utf = text.utf8();
+ std::string s = text.c_str(); // use a normal string, for its functionality
+
+ _parsedtext.clear();
+ _text = text;
+
+ // parse it into multiple lines
+ std::string::size_type p = 0;
+ while (p != std::string::npos) {
+ std::string::size_type p2 = s.find('\n', p);
+ std::string s(s.substr(p, (p2==std::string::npos?p2:p2-p)));
+
+ // turn tabs into spaces (multiples of 8)
+ std::string::size_type t;
+ while ((t = s.find('\t')) != std::string::npos)
+ s.replace(t, 1, std::string(8 - t % 8, ' '));
+
+ _parsedtext.push_back(s);
+ _parsedtext.back().setUtf8(utf);
+ p = (p2==std::string::npos?p2:p2+1);
+ }
+ calcDefaultSizes();
+}
+
+void Label::setFont(const Font *f)