X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcontainer.cpp;h=7c2e3fb4e8c8afb87b1aa41b49972575a27ffa62;hb=f0b600c3b1739f7e088da6ab8eb7c2e67adf592c;hp=e8b666d67344e854cedf0d948fe6f38d2874eab8;hpb=7675857c7cc7f0accc3c20b13d305318be57dde9;p=libs%2Fgltk.git diff --git a/source/container.cpp b/source/container.cpp index e8b666d..7c2e3fb 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -1,4 +1,5 @@ #include "container.h" +#include "part.h" using namespace std; @@ -51,6 +52,36 @@ Container::Child *Container::create_child(Widget *wdg) return new Child(*this, wdg); } +Geometry Container::determine_child_geometry(const Widget &child, const Part &part) const +{ + Geometry pgeom = part.get_geometry(); + if(!pgeom.w || !pgeom.h) + { + Geometry cgeom; + child.autosize(cgeom); + if(!pgeom.w) + pgeom.w = cgeom.w; + if(!pgeom.h) + pgeom.h = cgeom.h; + } + + part.get_alignment().apply(pgeom, geom, part.get_margin()); + return pgeom; +} + +void Container::autosize_child(const Widget &child, const Part &part, Geometry &ageom) const +{ + Geometry cgeom = determine_child_geometry(child, part); + const Sides &margin = part.get_margin(); + ageom.w = max(ageom.w, cgeom.w+margin.left+margin.right); + ageom.h = max(ageom.h, cgeom.h+margin.top+margin.bottom); +} + +void Container::reposition_child(Widget &child, const Part &part) const +{ + child.set_geometry(determine_child_geometry(child, part)); +} + list Container::get_children() const { list result; @@ -188,7 +219,13 @@ Widget *Container::get_pointer_target(int x, int y) else if(click_focus) return click_focus; else - return get_child_at(x, y); + { + Widget *child = get_child_at(x, y); + if(child && child->is_enabled()) + return child; + else + return 0; + } } void Container::pointer_leave()