try {
if (layoutPanel == null || !init(layoutPanel)) {
return;
}
final Dimension box = DOM.getClientSize(layoutPanel.getElement());
int width = box.width - (paddings[1] + paddings[3]);
int height = box.height - (paddings[0] + paddings[2]);
int left = paddings[3];
int top = paddings[0];
final int spacing = layoutPanel.getWidgetSpacing();
// adjust for spacing
width -= ((cols - 1) * spacing);
height -= ((rows - 1) * spacing);
final int colWidth = width / cols;
final int rowHeight = height / rows;
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
Widget widget = widgetMatrix[c][r];
if (widget == null || widget == SPAN) {
continue;
}
if (widget instanceof DecoratorPanel) {
widget = ((DecoratorPanel) widget).getWidget();
}
int cellWidth;
int cellHeight;
final GridLayoutData layoutData = (GridLayoutData) getLayoutData(widget);
if (layoutData.hasDecoratorPanel()) {
final Dimension decPanelFrameSize = getDecoratorFrameSize(
layoutData.decoratorPanel, widget);
cellWidth = colWidth * layoutData.colspan - decPanelFrameSize.width
+ spacing * (layoutData.colspan - 1);
cellHeight = rowHeight * layoutData.rowspan
- decPanelFrameSize.height + spacing * (layoutData.rowspan - 1);