}
private void command_ANCHOR_vertical(WidgetInfo widget, Anchor anchor) throws Exception {
Location location = getLocation(widget, false);
DocumentElement layer = location.layer;
Rectangle bounds = widget.getBounds();
if (location.leading != null && location.size != null) {
if (anchor == Anchor.NONE) {
layer.setAttribute("top", null);
layer.setAttribute("height", null);
}
if (anchor == Anchor.TRAILING) {
int bottom = getBounds().height - bounds.bottom();
layer.setAttribute("top", null);
setPixels(location.leading, "bottom", bottom);
}
if (anchor == Anchor.BOTH) {
int bottom = getBounds().height - bounds.bottom();
layer.setAttribute("height", null);
setPixels(location.leading, "bottom", bottom);
}
return;
}
if (location.trailing != null && location.size != null) {
if (anchor == Anchor.NONE) {
layer.setAttribute("bottom", null);
layer.setAttribute("height", null);
}
if (anchor == Anchor.LEADING) {
int top = bounds.top();
layer.setAttribute("bottom", null);
setPixels(location.trailing, "top", top);
}
if (anchor == Anchor.BOTH) {
int top = bounds.top();
layer.setAttribute("height", null);
setPixels(location.trailing, "top", top);
}
return;
}
if (location.leading != null && location.trailing != null) {
if (anchor == Anchor.NONE) {
layer.setAttribute("top", null);
layer.setAttribute("bottom", null);
}
if (anchor == Anchor.LEADING) {
layer.setAttribute("bottom", null);
setPixels(location.leading, "height", bounds.height);
}
if (anchor == Anchor.TRAILING) {
layer.setAttribute("top", null);
setPixels(location.trailing, "height", bounds.height);
}
return;
}
// no anchor yet
if (anchor != Anchor.NONE) {
if (anchor == Anchor.LEADING) {
layer.setAttribute("top", bounds.top() + "px");
layer.setAttribute("height", bounds.height + "px");
}
if (anchor == Anchor.TRAILING) {
layer.setAttribute("bottom", getBounds().height - bounds.bottom() + "px");
layer.setAttribute("height", bounds.height + "px");
}
if (anchor == Anchor.BOTH) {
layer.setAttribute("top", bounds.top() + "px");
layer.setAttribute("bottom", getBounds().height - bounds.bottom() + "px");
}
}
}