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
import org.eclipse.swt.widgets.Layout;
/**
 * This layout manager arranges children of the composite parent in vertical
 * columns. All the columns are identical size and children are stretched
 * horizontally to fill the column width. The goal is to give layout some
 * reasonable range of column numbers to allow it to handle various parent
 * widths. That way, column number will drop to the lowest number in the range
 * when width decreases, and grow up to the highest number in the range when
 * allowed by the parent width.
 * <p>
 * In addition, the layout attempts to 'fill the space' equally i.e. to avoid
 * large gaps at the and of the last column.
 * <p>
 * Child controls are layed out according to their 'natural' (preferred) size.
 * For 'stretchy' controls that do not have natural preferred size, it is
 * possible to set width and/or height hints using ColumnLayoutData objects.
 * 
 * @see ColumnLayoutData
 * @since 3.0
 */
public final class ColumnLayout extends Layout implements ILayoutExtension {
	/**
	 * Minimum number of columns (default is 1).
	 */
	public int minNumColumns = 1;
	/**
	 * Maximum number of columns (default is 3).
	 */
	public int maxNumColumns = 3;
	/**