still draw the background when no text will fit

This commit is contained in:
Dana Jansens 2003-02-16 10:05:29 +00:00
parent c7d4901f41
commit afe1d9e3a8

View file

@ -437,37 +437,36 @@ void Frame::renderLabel()
otk::ustring t = _client->title(); // the actual text to draw otk::ustring t = _client->title(); // the actual text to draw
int x = geom.bevel; // x coord for the text int x = geom.bevel; // x coord for the text
if (x * 2 > geom.label_width) return; // no room at all if (x * 2 < geom.label_width) {
// find a string that will fit inside the area for text
otk::ustring::size_type text_len = t.size();
int length;
int maxsize = geom.label_width - geom.bevel * 2;
// find a string that will fit inside the area for text do {
otk::ustring::size_type text_len = t.size(); t.resize(text_len);
int length; length = font->measureString(t);// this returns an unsigned, so check < 0
int maxsize = geom.label_width - geom.bevel * 2; if (length < 0) length = maxsize;// if the string's that long just adjust
} while (length > maxsize && text_len-- > 0);
do { // justify the text
t.resize(text_len); switch (style->labelTextJustify()) {
length = font->measureString(t); // this returns an unsigned, so check < 0 case otk::RenderStyle::RightBottomJustify:
if (length < 0) length = maxsize; // if the string's that long just adjust x += maxsize - length;
} while (length > maxsize && text_len-- > 0); break;
case otk::RenderStyle::CenterJustify:
x += (maxsize - length) / 2;
break;
case otk::RenderStyle::LeftTopJustify:
break;
}
if (text_len <= 0) return; // won't fit anything if (text_len > 0)
control->drawString(*s, *font, x, 0,
// justify the text *(_client->focused() ? style->textFocusColor() :
switch (style->labelTextJustify()) { style->textUnfocusColor()), t);
case otk::RenderStyle::RightBottomJustify:
x += maxsize - length;
break;
case otk::RenderStyle::CenterJustify:
x += (maxsize - length) / 2;
break;
case otk::RenderStyle::LeftTopJustify:
break;
} }
control->drawString(*s, *font, x, 0,
*(_client->focused() ? style->textFocusColor() :
style->textUnfocusColor()), t);
XSetWindowBackgroundPixmap(**otk::display, _label, s->pixmap()); XSetWindowBackgroundPixmap(**otk::display, _label, s->pixmap());
XClearWindow(**otk::display, _label); XClearWindow(**otk::display, _label);
if (_label_sur) delete _label_sur; if (_label_sur) delete _label_sur;