Bug 124313 - [ViewForm] ViewForm makes Combo too wide
Summary: [ViewForm] ViewForm makes Combo too wide
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Duong Nguyen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-18 10:51 EST by Markus Keller CLA
Modified: 2019-09-06 16:07 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 Markus Keller CLA 2006-01-18 10:51:12 EST
I20060117-0800

When I set a Combo as topLeft of a ViewForm, the combo uses up too much horizontal space: it overlaps the button at topCenter. I would expect that the Combo uses up the available space on the top left, but does not steal space from the topCenter button. Works fine if CLabel or Label is used instead of Combo or CCombo.


import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.widgets.*;

public class ComboTest {
	public static void main (String [] args) {
		Display display = new Display ();
		Shell shell = new Shell (display);
		
		ViewForm form= new ViewForm(shell, SWT.NONE);
		form.setSize(400, 200);

		if (true) {
			Combo combo= new Combo(form, SWT.READ_ONLY);
			combo.setItems(new String[] { "Item 1", "Item 2" });
			combo.select(0);
			form.setTopLeft(combo);
		} else {
			Label label= new Label(form, SWT.NONE);
			label.setText("Text");
			label.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
			form.setTopLeft(label);
		}

		Button button= new Button(form, SWT.PUSH);
		button.setText("Button");
		form.setTopCenter(button);
		
		Text text= new Text(form, SWT.WRAP);
		form.setContent(text);
		
		shell.pack();
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
}
Comment 1 Markus Keller CLA 2006-01-26 10:44:45 EST
A workaround is to wrap the Combo in a Composite like this:

Composite comboComposite= new Composite(form, SWT.NONE);
GridLayout gl= new GridLayout(1, false);
gl.marginWidth= gl.marginHeight= 0;
comboComposite.setLayout(gl);

final Combo nestedCombo= new Combo(comboComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
nestedCombo.setItems(new String[] { "Item 1", "Item 2" });
nestedCombo.select(0);
nestedCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

form.setTopLeft(comboComposite);
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:07:34 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.