+ set_geometry(Geometry(geom.x, geom.y, w, h));
+}
+
+void Widget::autosize()
+{
+ Geometry ageom;
+ autosize(ageom);
+ set_geometry(ageom);
+}
+
+void Widget::autosize(Geometry &ageom) const
+{
+ if(!style)
+ return;
+
+ ageom = Geometry(geom.x, geom.y, 0, 0);
+ for(const Part &p: style->get_parts())
+ {
+ if(p.get_name().empty())
+ {
+ const Geometry &pgeom = p.get_geometry();
+ const Sides &pmargin = p.get_margin();
+ ageom.w = max(ageom.w, pgeom.w+pmargin.left+pmargin.right);
+ ageom.h = max(ageom.h, pgeom.h+pmargin.top+pmargin.bottom);
+ }
+ else
+ autosize_special(p, ageom);
+ }