ExecutionUtils.refresh(this);
}
private void command_ANCHOR_horizontal(WidgetInfo widget, Anchor anchor) throws Exception {
Location location = getLocation(widget, true);
DocumentElement layer = location.layer;
Rectangle bounds = widget.getBounds();
if (location.leading != null && location.size != null) {
if (anchor == Anchor.NONE) {
layer.setAttribute("left", null);
layer.setAttribute("width", null);
}
if (anchor == Anchor.TRAILING) {
int right = getBounds().width - bounds.right();
layer.setAttribute("left", null);
setPixels(location.leading, "right", right);
}
if (anchor == Anchor.BOTH) {
int right = getBounds().width - bounds.right();
layer.setAttribute("width", null);
setPixels(location.leading, "right", right);
}
return;
}
if (location.trailing != null && location.size != null) {
if (anchor == Anchor.NONE) {
layer.setAttribute("right", null);
layer.setAttribute("width", null);
}
if (anchor == Anchor.LEADING) {
int left = bounds.left();
layer.setAttribute("right", null);
setPixels(location.trailing, "left", left);
}
if (anchor == Anchor.BOTH) {
int left = bounds.left();
layer.setAttribute("width", null);
setPixels(location.trailing, "left", left);
}
return;
}
if (location.leading != null && location.trailing != null) {
if (anchor == Anchor.NONE) {
layer.setAttribute("left", null);
layer.setAttribute("right", null);
}
if (anchor == Anchor.LEADING) {
layer.setAttribute("right", null);
setPixels(location.leading, "width", bounds.width);
}
if (anchor == Anchor.TRAILING) {
layer.setAttribute("left", null);
setPixels(location.trailing, "width", bounds.width);
}
return;
}
// no anchor yet
if (anchor != Anchor.NONE) {
if (anchor == Anchor.LEADING) {
layer.setAttribute("left", bounds.left() + "px");
layer.setAttribute("width", bounds.width + "px");
}
if (anchor == Anchor.TRAILING) {
layer.setAttribute("right", getBounds().width - bounds.right() + "px");
layer.setAttribute("width", bounds.width + "px");
}
if (anchor == Anchor.BOTH) {
layer.setAttribute("left", bounds.left() + "px");
layer.setAttribute("right", getBounds().width - bounds.right() + "px");
}
}
}