]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/label.cpp
Implement autosize() method for most widgets
[libs/gltk.git] / source / label.cpp
index e3a46234519757df692a81d23ce4fb96f940af58..30ccd62d16859a6555e95eb2bd7d3180e58c0fc5 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgltk
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2009-2011  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -25,13 +25,13 @@ void Label::autosize()
        if(!style)
                return;
 
-       geom.h = text.get_height();
-       geom.w = text.get_width();
+       Widget::autosize();
+
        if(const Part *text_part = style->get_part("text"))
        {
                const Sides &margin = text_part->get_margin();
-               geom.w += margin.left+margin.right;
-               geom.h += margin.top+margin.bottom;
+               geom.w = max(geom.w, text.get_width()+margin.left+margin.right);
+               geom.h = max(geom.h, text.get_height()+margin.top+margin.bottom);
        }
 }