}
protected void onLayout(Container container, Element target) {
super.onLayout(container, target);
WidgetContainer wc = (WidgetContainer) container;
Rectangle rect = MyDOM.getBounds(target, true);
int height = rect.height - (2 * margin);
int width = rect.width - (2 * margin);
int top = rect.y += margin;
int left = rect.x += margin;
int size = container.getWidgetCount();
int fillHeight = height;
int fillWidth = width;
RowData fillData = null;
for (int i = 0; i < size; i++) {
Widget widget = container.getWidget(i);
if (!widget.isVisible()) continue;
DOM.setStyleAttribute(widget.getElement(), "position", "absolute");
RowData data = (RowData) wc.getLayoutData(widget);
if (data == null) {
data = new RowData();
wc.setLayoutData(widget, data);
}
if (type == Style.HORIZONTAL) {
if (data.fillWidth) {
fillData = data;
} else if (data.width != Style.DEFAULT) {
fillWidth -= data.width;
} else {
int flowWidth = widget.getOffsetWidth();
fillWidth -= flowWidth;
data.width = flowWidth;
}
if (data.fillHeight) {
data.height = height;
} else if (data.height == Style.DEFAULT) {
data.height = widget.getOffsetHeight();
}
} else {
if (data.fillHeight) {
fillData = data;
} else if (data.height != Style.DEFAULT) {
fillHeight -= data.height;
} else {
int flowHeight = MyDOM.getComputedHeight(widget.getElement());
fillHeight -= flowHeight;
data.height = flowHeight;
}
if (data.fillWidth) {
data.width = width;
} else if (data.width == Style.DEFAULT) {
data.width = widget.getOffsetWidth();
}
}
}
if (fillData != null && type == Style.VERTICAL) {
fillData.height = fillHeight;
}
if (fillData != null && type == Style.HORIZONTAL) {
fillData.width = fillWidth;
}
for (int i = 0; i < size; i++) {
Widget widget = (Widget) container.getWidget(i);
if (!widget.isVisible()) continue;
RowData data = (RowData) wc.getLayoutData(widget);
int w = (int) data.width;
int h = (int) data.height;
top = Math.max(0, top);
setBounds(widget, left, top, w, h);