LayoutManager layoutManager = LayoutManager.get(client);
Element element = getElement();
int paddingTop = layoutManager.getPaddingTop(element);
+ int paddingBottom = layoutManager.getPaddingBottom(element);
int y = paddingTop;
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < cells[i].length; j++) {
Cell cell = cells[i][j];
if (cell != null) {
- cell.layoutVertically(y);
+ int effectivePadding;
+ if (cell.rowspan + j >= cells[i].length) {
+ // Make room for layout padding for cells reaching the
+ // bottom of the layout
+ effectivePadding = paddingBottom;
+ } else {
+ effectivePadding = 0;
+ }
+ cell.layoutVertically(y, effectivePadding);
}
y += rowHeights[j] + verticalSpacing;
}
LayoutManager layoutManager = LayoutManager.get(client);
Element element = getElement();
int x = layoutManager.getPaddingLeft(element);
+ int paddingRight = layoutManager.getPaddingRight(element);
int horizontalSpacing = getHorizontalSpacing();
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < cells[i].length; j++) {
Cell cell = cells[i][j];
if (cell != null) {
- cell.layoutHorizontally(x);
+ int effectivePadding;
+ // Make room for layout padding for cells reaching the
+ // right edge of the layout
+ if (i + cell.colspan >= cells.length) {
+ effectivePadding = paddingRight;
+ } else {
+ effectivePadding = 0;
+ }
+ cell.layoutHorizontally(x, effectivePadding);
}
}
x += columnWidths[i] + horizontalSpacing;
return height;
}
- public void layoutHorizontally(int x) {
+ public void layoutHorizontally(int x, int paddingRight) {
if (slot != null) {
- slot.positionHorizontally(x, getAvailableWidth());
+ slot.positionHorizontally(x, getAvailableWidth(), paddingRight);
}
}
- public void layoutVertically(int y) {
+ public void layoutVertically(int y, int paddingBottom) {
if (slot != null) {
- slot.positionVertically(y, getAvailableHeight());
+ slot.positionVertically(y, getAvailableHeight(), paddingBottom);
}
}
}
public void positionHorizontally(double currentLocation,
- double allocatedSpace) {
+ double allocatedSpace, double paddingRight) {
Style style = wrapper.getStyle();
double availableWidth = allocatedSpace;
boolean captionAboveCompnent;
if (caption == null) {
captionAboveCompnent = false;
- style.clearPaddingRight();
} else {
captionAboveCompnent = !caption.shouldBePlacedAfterComponent();
if (!captionAboveCompnent) {
- style.setPaddingRight(captionWidth, Unit.PX);
+ paddingRight += captionWidth;
availableWidth -= captionWidth;
captionStyle.clearLeft();
captionStyle.setRight(0, Unit.PX);
} else {
- style.clearPaddingRight();
captionStyle.setLeft(0, Unit.PX);
captionStyle.clearRight();
}
}
+ if (paddingRight > 0) {
+ style.setPaddingRight(paddingRight, Unit.PX);
+ } else {
+ style.clearPaddingRight();
+ }
+
if (isRelativeWidth()) {
style.setPropertyPx("width", (int) availableWidth);
} else {
return Double.parseDouble(size.replaceAll("%", ""));
}
- public void positionVertically(double currentLocation, double allocatedSpace) {
+ public void positionVertically(double currentLocation,
+ double allocatedSpace, double paddingBottom) {
Style style = wrapper.getStyle();
double contentHeight = allocatedSpace;
style.setPaddingTop(captionHeight, Unit.PX);
}
+ if (paddingBottom > 0) {
+ style.setPaddingBottom(paddingBottom, Unit.PX);
+ } else {
+ style.clearPaddingBottom();
+ }
+
if (isRelativeHeight()) {
style.setHeight(contentHeight, Unit.PX);
} else {
}
public void positionInDirection(double currentLocation,
- double allocatedSpace, boolean isVertical) {
+ double allocatedSpace, double endingPadding, boolean isVertical) {
if (isVertical) {
- positionVertically(currentLocation, allocatedSpace);
+ positionVertically(currentLocation, allocatedSpace, endingPadding);
} else {
- positionHorizontally(currentLocation, allocatedSpace);
+ positionHorizontally(currentLocation, allocatedSpace, endingPadding);
}
}
boolean isUndefined = isUndefinedInDirection(isVertical);
int startPadding = getStartPadding(isVertical);
+ int endPadding = getEndPadding(isVertical);
int spacingSize = getSpacingInDirection(isVertical);
int allocatedSize;
}
allocatedSize = layout.layoutPrimaryDirection(spacingSize,
- allocatedSize, startPadding);
+ allocatedSize, startPadding, endPadding);
Style ownStyle = getWidget().getElement().getStyle();
if (isUndefined) {
boolean isUndefined = isUndefinedInDirection(!isVertical);
int startPadding = getStartPadding(!isVertical);
+ int endPadding = getEndPadding(!isVertical);
int allocatedSize;
if (isUndefined) {
}
allocatedSize = layout.layoutSecondaryDirection(allocatedSize,
- startPadding);
+ startPadding, endPadding);
Style ownStyle = getWidget().getElement().getStyle();
}
}
+ private int getEndPadding(boolean isVertical) {
+ if (isVertical) {
+ return getLayoutManager()
+ .getPaddingBottom(getWidget().getElement());
+ } else {
+ return getLayoutManager().getPaddingRight(getWidget().getElement());
+ }
+ }
+
public void layoutHorizontally() {
if (getWidget().isVertical) {
layoutSecondaryDirection();
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.WidgetCollection;
import com.vaadin.terminal.gwt.client.VCaption;
import com.vaadin.terminal.gwt.client.ui.VMarginInfo;
import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot;
}
public int layoutPrimaryDirection(int spacingSize, int allocatedSize,
- int startPadding) {
+ int startPadding, int endPadding) {
int actuallyAllocated = 0;
double totalExpand = 0;
double currentLocation = startPadding;
- for (Widget child : this) {
+ WidgetCollection children = getChildren();
+ for (int i = 0; i < children.size(); i++) {
+ Widget child = children.get(i);
if (child instanceof VCaption) {
continue;
}
*/
double roundedSpace = Math.round(endLocation) - roundedLocation;
- slot.positionInDirection(roundedLocation, roundedSpace, isVertical);
+ // Reserve room for the padding if we're at the end
+ double slotEndPadding;
+ if (i == children.size() - 1) {
+ slotEndPadding = endPadding;
+ } else {
+ slotEndPadding = 0;
+ }
+
+ slot.positionInDirection(roundedLocation, roundedSpace,
+ slotEndPadding, isVertical);
currentLocation = endLocation + spacingSize;
}
return allocatedSize;
}
- public int layoutSecondaryDirection(int allocatedSize, int startPadding) {
+ public int layoutSecondaryDirection(int allocatedSize, int startPadding,
+ int endPadding) {
int maxSize = 0;
for (Widget child : this) {
if (child instanceof VCaption) {
}
VLayoutSlot slot = getSlotForChild(child);
- slot.positionInDirection(startPadding, allocatedSize, !isVertical);
+ slot.positionInDirection(startPadding, allocatedSize, endPadding,
+ !isVertical);
}
return allocatedSize;