Community
Participate
Working Groups
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102814 Ubuntu/8.04 (hardy) Firefox/3.0.15 Build Identifier: 20090920-1017 A combo box contributed to a toolbar (either the main application toolbar or a view's toolbar) is displayed with incorrect height on Linux x86 (see attached screenshot). This problem does not occur on Linux x86_64 or Windows XP. The sample RCP application attached shows the problem and two possible workarounds to correct it: 1. Explicitly set the parent's size in the WorkbenchWindowControlContribution: @Override protected Control createControl(Composite parent) { Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); combo.add("Option 1"); combo.add("Option 2"); combo.add("Option 3"); combo.select(0); // this workaround fixes the problem // parent.setSize(combo.computeSize(SWT.DEFAULT, SWT.DEFAULT)); return combo; } 2. Add a command to the toolbar: <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar"> <toolbar id="test.toolbar1"> <!-- adding a command fixes the problem --> <!--command commandId="test.command1" icon="icons/alt_window_16.gif" style="push"> </command--> <control class="test.NullControlContribution"> </control> </toolbar> </menuContribution> Reproducible: Always Steps to Reproduce: 1. Run the attached sample application. 2. Verify that the combo boxes contributed to the toolbars are displayed with incorrect height on Linux x86. 3. Uncomment the workarounds to verify that they fix the problem.
Created attachment 151022 [details] Screenshot on Linux x86 (Ubuntu 8.04). Screenshot showing the problem on Linux x86 (Ubuntu 8.04).
Created attachment 151023 [details] Sample RCP application. Sample RCP application showing the problem and possible workarounds to fix it.
Maybe this could be related to bug 183003, or even a duplicate of it. I'm not sure as I don't know how the RCP contributions are translated into the basic SWT building blocks.
Created attachment 183754 [details] Screenshot on Windows Vista.
Created attachment 183755 [details] Screenshot on Windows 7.
Actually the problem occurs in Windows Vista and Windows 7 as well (see screenshots above), where the proposed workaround of setting parent.setSize(combo.computeSize(SWT.DEFAULT, SWT.DEFAULT)); does not work.
Created attachment 183792 [details] Sample RCP project demonstrating a workaround to this bug.
Based on the hack provided in bug 183003 comment 24, I've developed a new workaround that will work on Windows (this is evidence that this is indeed a duplicate of that bug). Unfortunately it doesn't work on Linux, but in that platform we can still resort to the first workaround of setting: parent.setSize(combo.computeSize(SWT.DEFAULT, SWT.DEFAULT)); I've attached another sample RCP project illustrating the complete workaround that will work in both platforms. It's getting too complex, and I'm not confident that it won't get broken by the next OS version of even Eclipse platform update... It would be great if that bug could start receiving some attention again. Below is a sample of the workaround for adding combo boxes in a view's toolbar. The workaround for a combo in the main application's toolbar is a slightly more complex; please have a look at the attached RCP project for details. @Override protected Control createControl(Composite parent) { final Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); combo.add("Option 1"); combo.add("Option 2"); combo.add("Option 3"); combo.select(0); // The applied workaround varies according to the platform. // Only the selected workaround will work for a given platform. if(SWT.getPlatform().equals("win32")) { parent.getDisplay().asyncExec(new Runnable() { @Override public void run() { getParent().add(new ContributionItem() { private ToolItem dummyItem; @Override public void fill(ToolBar parent, int index) { if(dummyItem == null) { dummyItem = new ToolItem(parent, SWT.PUSH, index); final Image image = new Image(parent.getDisplay(), 1, combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); GC gc = new GC(image); gc.setBackground(parent.getBackground()); gc.fillRectangle(image.getBounds()); gc.dispose(); dummyItem.setImage(image); dummyItem.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { image.dispose(); } }); setVisible(false); getParent().update(true); } } }); getParent().update(true); } }); } else { parent.setSize(combo.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } return combo; }
The workaround above for Win32 does not work for me. Still seeing the combobox cutoff from below. Attaching screen shot.
Created attachment 234584 [details] Combo cutoff on Win7, Eclipse 4.2.2
A working workaround (at least on Windows 7) is to use the Nebula TableCombo widget
I see a similar issue with buttons placed in a Composite with a grid layout with no margins. A single button displays OK and has computed height 25. The Composite also has a computed height of 25 but the buttons somehow grow larger and are clipped.
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. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. 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. -- The automated Eclipse Genie.