X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=otk%2Flabel.cc;h=c17e295e49f4119c08551894f479a088fb3424a0;hb=74cfb1b4c115cdb4e05aa823b09d2b5ea9d0d690;hp=c56f91f8022aebfbc7920e48d76b3c3a440f187a;hpb=f51f1c775f3f09cf184ead323d111985c888d52e;p=chaz%2Fopenbox diff --git a/otk/label.cc b/otk/label.cc index c56f91f8..c17e295e 100644 --- a/otk/label.cc +++ b/otk/label.cc @@ -17,7 +17,7 @@ Label::Label(Widget *parent) _text(""), _justify_horz(RenderStyle::LeftTopJustify), _justify_vert(RenderStyle::LeftTopJustify), - _highlight(true) + _highlight(false) { styleChanged(*RenderStyle::style(screen())); } @@ -71,11 +71,12 @@ void Label::setFont(const Font *f) void Label::calcDefaultSizes() { - unsigned int longest = 0; + int longest = 0; // find the longest line std::vector::iterator it, end = _parsedtext.end(); for (it = _parsedtext.begin(); it != end; ++it) { - unsigned int length = _font->measureString(*it); + int length = _font->measureString(*it); + if (length < 0) continue; // lines too long get skipped if (length > longest) longest = length; } setMinSize(Size(longest + borderWidth() * 2 + bevel() * 4, @@ -92,18 +93,19 @@ void Label::styleChanged(const RenderStyle &style) _texture = style.labelUnfocusBackground(); _forecolor = style.textUnfocusColor(); } - _font = style.labelFont(); - Widget::styleChanged(style); - calcDefaultSizes(); + if (_font != style.labelFont()) { + _font = style.labelFont(); + calcDefaultSizes(); + } } void Label::renderForeground(Surface &surface) { const RenderControl *control = display->renderControl(screen()); - unsigned int sidemargin = bevel() * 2; + int sidemargin = bevel() * 2; int y = bevel(); - unsigned int w = area().width() - borderWidth() * 2 - sidemargin * 2; - unsigned int h = area().height() - borderWidth() * 2 - bevel() * 2; + int w = area().width() - borderWidth() * 2 - sidemargin * 2; + int h = area().height() - borderWidth() * 2 - bevel() * 2; switch (_justify_vert) { case RenderStyle::RightBottomJustify: @@ -127,12 +129,13 @@ void Label::renderForeground(Surface &surface) // find a string that will fit inside the area for text ustring::size_type text_len = t.size(); - unsigned int length; + int length; do { t.resize(text_len); length = _font->measureString(t); } while (length > w && text_len-- > 0); + if (length < 0) continue; // lines too long get skipped if (text_len <= 0) continue; // won't fit anything