X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwidget.cpp;h=3d3b0068ad6f394b905d8e6854dafdfeebf9769e;hb=baa066405c5a9e6a34ce5df962bcce7e7e8d319a;hp=bbd2e8877af608b1255d21eb10d9b23d2506fba4;hpb=5d219b2f7e8ce196486c225e971f76ceab5538c5;p=libs%2Fgltk.git diff --git a/source/widget.cpp b/source/widget.cpp index bbd2e88..3d3b006 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -30,30 +30,29 @@ Widget::~Widget() void Widget::set_position(int x, int y) { - geom.x = x; - geom.y = y; - on_geometry_change(); - rebuild(); + set_geometry(Geometry(x, y, geom.w, geom.h)); } void Widget::set_size(unsigned w, unsigned h) { - geom.w = w; - geom.h = h; - on_geometry_change(); - rebuild(); + set_geometry(Geometry(geom.x, geom.y, w, h)); } void Widget::autosize() { + if(!style) + return; + geom.w = 0; geom.h = 0; const Style::PartSeq &parts = style->get_parts(); for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i) if(i->get_name().empty()) { - geom.w = max(geom.w, i->get_geometry().w); - geom.h = max(geom.h, i->get_geometry().h); + const Geometry &pgeom = i->get_geometry(); + const Sides &pmargin = i->get_margin(); + geom.w = max(geom.w, pgeom.w+pmargin.left+pmargin.right); + geom.h = max(geom.h, pgeom.h+pmargin.top+pmargin.bottom); } }