]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/toggle.cpp
Fix a crash if the linear program contains an empty column
[libs/gltk.git] / source / toggle.cpp
index 43acaa3125b021161a489f91ab9603a044a7ec95..6d2a10b16644d6254163b53b26c6f92ead7754ce 100644 (file)
@@ -1,12 +1,6 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007-2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "panel.h"
 #include "part.h"
+#include "style.h"
 #include "toggle.h"
 
 using namespace std;
@@ -23,9 +17,25 @@ Toggle::Toggle(const string &t):
        set_text(t);
 }
 
+void Toggle::autosize()
+{
+       if(!style)
+               return;
+
+       Widget::autosize();
+
+       if(const Part *text_part = style->get_part("text"))
+       {
+               const Sides &margin = text_part->get_margin();
+               geom.w = max(geom.w, text.get_width()+margin.left+margin.right);
+               geom.h = max(geom.h, text.get_height()+margin.top+margin.bottom);
+       }
+}
+
 void Toggle::set_text(const string &t)
 {
        text = t;
+       signal_autosize_changed.emit();
 }
 
 void Toggle::set_exclusive(bool e)