]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/toggle.cpp
Avoid generating events during destruction of a widget
[libs/gltk.git] / source / toggle.cpp
index 43acaa3125b021161a489f91ab9603a044a7ec95..41e38cba93d393b8af4d650997ae9c8987b2b483 100644 (file)
@@ -7,6 +7,7 @@ Distributed under the LGPL
 
 #include "panel.h"
 #include "part.h"
+#include "style.h"
 #include "toggle.h"
 
 using namespace std;
@@ -23,9 +24,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)