Bug 184345 [Forms] ColumnLayout calculates number of columns incorrectly
In package org.eclipse.ui.forms.widgets, class ColumnLayout, method layout, I believe the number of columns is calculated incorrectly. This can cause the columns to be considerably wider than they should be. The line is: int ncolumns = (carea.width - leftMargin - rightMargin - horizontalSpacing) / (cwidth + horizontalSpacing); I think it should be: int ncolumns = (carea.width - leftMargin - rightMargin + horizontalSpacing) / (cwidth + horizontalSpacing); because the horizontalSpacing is only between columns, and not also on the outsides of the columns. (i.e. There are only ncolumns-1 horizontalSpacing's.) The derivation is: ncolumns * cwidth + (ncolumns-1) * horizontalSpacing = carea.width - leftMargin - rightMargin ==> ncolumns * cwidth + ncolumns * horizontalSpacing = carea.width - leftMargin - rightMargin + horizontalSpacing ==> ncolumns * (cwidth + horizontalSpacing) = carea.width - leftMargin - rightMargin + horizontalSpacing
bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ColumnLayout.java
}
		int perColHeight = cheight / ncolumns;
		if (cheight % ncolumns != 0)
			perColHeight++;
		int colHeight = 0;
		int[] heights = new int[ncolumns];
		int ncol = 0;
		
		boolean fillIn = false;
		
		for (int i = 0; i < sizes.length; i++) {
			int childHeight = sizes[i].y;
			if (i>0 && colHeight + childHeight > perColHeight) {
				heights[ncol] = colHeight;
				ncol++;
				if (ncol == ncolumns || fillIn) {
					
					fillIn = true;
					ncol = findShortestColumn(heights);
				}
				colHeight = heights[ncol];
			}
			if (colHeight > 0)
				colHeight += verticalSpacing;
			colHeight += childHeight;
		}
		heights[ncol] = Math.max(heights[ncol],colHeight);
		
		Point size = new Point(0, 0);
		for (int i = 0; i < ncolumns; i++) {