X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftoggle.cpp;h=6d2a10b16644d6254163b53b26c6f92ead7754ce;hb=39cf4c8d917dc60c087fb4af6885bfa78f6fba34;hp=43acaa3125b021161a489f91ab9603a044a7ec95;hpb=73afd124ab87e8bace98db55517a56c797a9b8c7;p=libs%2Fgltk.git diff --git a/source/toggle.cpp b/source/toggle.cpp index 43acaa3..6d2a10b 100644 --- a/source/toggle.cpp +++ b/source/toggle.cpp @@ -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)