summaryrefslogtreecommitdiff
path: root/src/labelwidget.cc
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-12-27 16:29:32 +0000
committerDana Jansens <danakj@orodu.net>2002-12-27 16:29:32 +0000
commitd222c565432a146313fe4673b67c517b6d649182 (patch)
treeb7429a203bbcac318ef9b41a339d656610cd02ee /src/labelwidget.cc
parent5fdd493d0d2255f134114e69f028371366f4dfd3 (diff)
draw only when needed
Diffstat (limited to 'src/labelwidget.cc')
-rw-r--r--src/labelwidget.cc58
1 files changed, 31 insertions, 27 deletions
diff --git a/src/labelwidget.cc b/src/labelwidget.cc
index 491deadc..f00f738b 100644
--- a/src/labelwidget.cc
+++ b/src/labelwidget.cc
@@ -72,38 +72,42 @@ void OBLabelWidget::unfocus()
void OBLabelWidget::update()
{
- OtkWidget::update();
+ bool draw = _dirty;
- std::string t = _text;
- int x = _sidemargin; // x coord for the text
+ OtkWidget::update();
- // find a string that will fit inside the area for text
- int max_length = width() - _sidemargin * 2;
- if (max_length <= 0) {
- t = ""; // can't fit anything
- } else {
- size_t text_len = t.size();
- int length;
+ if (draw) {
+ std::string t = _text;
+ int x = _sidemargin; // x coord for the text
+
+ // find a string that will fit inside the area for text
+ int max_length = width() - _sidemargin * 2;
+ if (max_length <= 0) {
+ t = ""; // can't fit anything
+ } else {
+ size_t text_len = t.size();
+ int length;
- do {
- t.resize(text_len);
- length = _font->measureString(t);
- } while (length > max_length && text_len-- > 0);
-
- // justify the text
- switch (_justify) {
- case otk::Style::RightJustify:
- x += max_length - length;
- break;
- case otk::Style::CenterJustify:
- x += (max_length - length) / 2;
- break;
- case otk::Style::LeftJustify:
- break;
+ do {
+ t.resize(text_len);
+ length = _font->measureString(t);
+ } while (length > max_length && text_len-- > 0);
+
+ // justify the text
+ switch (_justify) {
+ case otk::Style::RightJustify:
+ x += max_length - length;
+ break;
+ case otk::Style::CenterJustify:
+ x += (max_length - length) / 2;
+ break;
+ case otk::Style::LeftJustify:
+ break;
+ }
}
- }
- _font->drawString(_xftdraw, x, 0, *_text_color, t);
+ _font->drawString(_xftdraw, x, 0, *_text_color, t);
+ }
}