]> Dogcows Code - chaz/openbox/blobdiff - otk/label.cc
set the _text
[chaz/openbox] / otk / label.cc
index 16fa25a0b674f249c460091676a258b585b45437..43d06f77aa6e8b0ad5e2ee1951ba51e976c200b3 100644 (file)
@@ -1,8 +1,6 @@
 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
 
-#ifdef HAVE_CONFIG_H
-# include "../config.h"
-#endif
+#include "config.h"
 
 #include "label.hh"
 #include "display.hh"
@@ -51,6 +49,7 @@ void Label::setText(const ustring &text)
   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;
@@ -71,11 +70,12 @@ void Label::setFont(const Font *f)
 
 void Label::calcDefaultSizes()
 {
-  unsigned int longest = 0;
+  int longest = 0;
   // find the longest line
   std::vector<ustring>::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,
@@ -101,10 +101,10 @@ void Label::styleChanged(const RenderStyle &style)
 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:
@@ -128,12 +128,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
 
This page took 0.020688 seconds and 4 git commands to generate.