}
private void command_SIZE_X(WidgetInfo widget, int width, ResizeDirection direction)
throws Exception {
Location location = getLocation(widget, true);
DocumentElement layer = location.layer;
Rectangle bounds = widget.getBounds();
// LeftWidth
if (location.leading != null && location.size != null) {
if (direction == ResizeDirection.LEADING) {
int oldLeft = bounds.left();
int deltaWidth = width - bounds.width;
int left = oldLeft - deltaWidth;
setPixels(location.leading, left);
}
setPixels(location.size, width);
return;
}
// RightWidth
if (location.trailing != null && location.size != null) {
if (direction == ResizeDirection.TRAILING) {
int oldRight = getBounds().width - bounds.right();
int deltaWidth = width - bounds.width;
int right = oldRight - deltaWidth;
setPixels(location.trailing, right);
}
setPixels(location.size, width);
return;
}
// LeftRight
if (location.leading != null && location.trailing != null) {
if (direction == ResizeDirection.LEADING) {
int oldLeft = bounds.left();
int deltaWidth = width - bounds.width;
int left = oldLeft - deltaWidth;
setPixels(location.leading, left);
}
if (direction == ResizeDirection.TRAILING) {
int oldRight = getBounds().width - bounds.right();
int deltaWidth = width - bounds.width;
int right = oldRight - deltaWidth;
setPixels(location.trailing, right);
}
return;
}
// new, use LeftWidth
if (direction == ResizeDirection.TRAILING) {
layer.setAttribute("left", "0px");
layer.setAttribute("width", width + "px");
}
}