Bug 180775 - [layout] RowLayout with SWT.VERTICAL does not claim needed horizontal space
Summary: [layout] RowLayout with SWT.VERTICAL does not claim needed horizontal space
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-03 14:52 EDT by Grant Gayed CLA
Modified: 2019-09-06 15:30 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grant Gayed CLA 2007-04-03 14:52:16 EDT
(originally from the newsgroup)

- run the snippet below
- works: resize the shell to make it narrower and note that the buttons in the top-left corner wrap to a second row, and in the process take away some of the yellow composite's space
- doesn't work: now resize the shell to make it shorter and note that while the vertical row of buttons in the middle does wrap (a button is never only partially-visibile at the bottom), the second column of buttons does not appear because the blue composite to the right does not give up any of its space
-> I can make the column of buttons wrap by uncommenting the line in the createComposite5() method, but this results in the buttons composite initially taking more horizontal space than it needs

public class Test {
	private static Shell sShell = null;
	private static Composite composite, composite1, composite2, composite3, composite4, composite5;
	public static void main(String[] args) {
		Display display = new Display();
		sShell = new Shell();
		composite = new Composite(sShell, SWT.NONE);
		composite.setLayout(new GridLayout());
		createComposite2();
		createComposite1();
		createComposite3();
		sShell.setLayout(new FillLayout());
		sShell.open();
		sShell.pack();
		while (!sShell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}

	static void createComposite2() {
		composite2 = new Composite(composite, SWT.NONE);
		composite2.setLayout(new RowLayout(SWT.HORIZONTAL));
		GridData gridData = new GridData(GridData.GRAB_HORIZONTAL);
		composite2.setLayoutData(gridData);
		for (int i = 0; i < 6; i++) {
			new Button(composite2, SWT.NONE).setText("Button");
		}
	}

	static void createComposite1() {
		composite1 = new Composite(composite, SWT.NONE);
		composite1.setLayout(new GridLayout());
		composite1.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
		GridData gridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
		composite1.setLayoutData(gridData);
	}

	static void createComposite3() {
		composite3 = new Composite(sShell, SWT.NONE);
		createComposite5();
		GridLayout gridLayout = new GridLayout(2, false);
		composite3.setLayout(gridLayout);
		createComposite4();
	}

	static void createComposite4() {
		composite4 = new Composite(composite3, SWT.NONE);
		composite4.setLayout(new GridLayout());
		composite4.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_BLUE));
		GridData gridData = new GridData(GridData.FILL_BOTH);
		composite4.setLayoutData(gridData);
	}

	static void createComposite5() {
		GridData gridData = new GridData();
		gridData.grabExcessVerticalSpace = true;
		//gridData.grabExcessHorizontalSpace = true;
		gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		composite5 = new Composite(composite3, SWT.NONE);
		composite5.setLayoutData(gridData);
		composite5.setLayout(new RowLayout(SWT.VERTICAL));
		for (int i = 0; i < 6; i++) {
			new Button(composite5, SWT.NONE).setText("Button");
		}
	}
}
Comment 1 Eclipse Webmaster CLA 2019-09-06 15:30:21 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.