#include "container.h"
+#include "part.h"
using namespace std;
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<Widget *> Container::get_children() const
{
list<Widget *> result;
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()