+ autosize_rows(5);
+}
+
+void List::autosize_rows(unsigned n)
+{
+ if(!style)
+ return;
+
+ Widget::autosize();
+
+ if(items_part)
+ {
+ const Sides &margin = items_part->get_margin();
+ float font_size = style->get_font_size();
+
+ unsigned max_w = 0;
+ for(vector<string>::iterator i=items.begin(); i!=items.end(); ++i)
+ {
+ unsigned w = static_cast<unsigned>(style->get_font()->get_string_width(*i)*font_size);
+ max_w = max(max_w, w);
+ }
+
+ geom.w = max(geom.w, max_w+margin.left+margin.right);
+ geom.h = max(geom.h, n*row_height+margin.top+margin.bottom);
+ }
+
+ if(const Part *slider_part = style->get_part("slider"))
+ {
+ Geometry sgeom = slider_part->get_geometry();
+ if(!sgeom.w || !sgeom.h)
+ {
+ slider.autosize();
+ if(!sgeom.w)
+ sgeom.w = slider.get_geometry().w;
+ if(!sgeom.h)
+ sgeom.h = slider.get_geometry().h;
+ }
+
+ const Sides &margin = slider_part->get_margin();
+ geom.w = max(geom.w, sgeom.w+margin.left+margin.right);
+ geom.h = max(geom.h, sgeom.h+margin.top+margin.bottom);