Community
Participate
Working Groups
I was retesting PR 1FUC0NM. I used the main method suggested by Steve and included below. For my image I used a 24 by 32 pixel gif. Run the example. Resize the toolbar so that only part of the combo box is visible. Now make the toolbar slightly bigger - notice that the line below the combo box is all broken. Also, when resizing the toolbar, the combo box does not get wrapped to the next line unless a wrap is required by one of the images. Also, there is vertical line behind the combo box which looks funny. package com.oti.dbaeumer.swt.prs; import com.ibm.swt.*; import com.ibm.swt.graphics.*; import com.ibm.swt.widgets.*; public class PR_1FUC0NM { public static void main(String[] args) { Display display = Display.getDefault(); @@@@@ FIX THIS PATH @@@@@ Image image = new Image(display, PR1FUC0NM.class.getResourceAsStream("test1.gif")); final Shell shell = new Shell(display); final ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.WRAP); final Text text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Combo combo = new Combo(toolBar, SWT.NULL); for (int i = 0; i < 16; i++) { combo.add("Item " + i); } for (int i = 0; i < 5; i++) { new ToolItem(toolBar, SWT.PUSH).setImage(image); new ToolItem(toolBar, SWT.SEPARATOR); } ToolItem item = new ToolItem(toolBar, SWT.SEPARATOR); item.setWidth(100); item.setControl(combo); new ToolItem(toolBar, SWT.SEPARATOR); new ToolItem(toolBar, SWT.NULL).setImage(image); toolBar.pack(); Listener resizeListener = new Listener() { public void handleEvent(Event event) { Point size = toolBar.getSize(); Rectangle rect = shell.getClientArea(); toolBar.setSize(rect.width, size.y); int toolHeight = toolBar.getSize().y, count = toolBar.getItemCount(); if (count > 0) { Rectangle itemRect = toolBar.getItems()[count - 1].getBounds(); toolBar.setSize(rect.width, toolHeight = itemRect.y + itemRect.height); } text.setBounds(rect.x, rect.y + toolHeight, rect.width, rect.height - toolHeight); } }; shell.addListener(SWT.Resize, resizeListener); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); } } NOTES: SN (2/5/01 5:32:10 PM) Platform problem. No work around at this time.
PRODUCT VERSION: 25a VA Java WIN 2000
We have some comboboxes on the toolbar, so this bug is critical for us.
Here is new code that shows the cheese problem: package steve; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; import java.io.*; public class PR_4533 { public static void main(String[] args) { Display display = Display.getDefault(); Image image = null; try { image = new Image(display, new FileInputStream ("j:\\teamswt\\malice\\cello.gif")); } catch (Exception ex) { System.out.println("failed"); System.exit(0); } final Shell shell = new Shell(display); final ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.WRAP); final Text text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); // Combo combo = new Combo(toolBar, SWT.NULL); // for (int i = 0; i < 16; i++) { // combo.add("Item " + i); // } Button combo = new Button (toolBar, SWT.PUSH); combo.setText ("Fred"); for (int i = 0; i < 5; i++) { new ToolItem(toolBar, SWT.PUSH).setImage(image); new ToolItem(toolBar, SWT.SEPARATOR); } ToolItem item = new ToolItem(toolBar, SWT.SEPARATOR); item.setWidth(100); item.setControl(combo); new ToolItem(toolBar, SWT.SEPARATOR); new ToolItem(toolBar, SWT.NULL).setImage(image); toolBar.pack(); Listener resizeListener = new Listener() { public void handleEvent(Event event) { Point size = toolBar.getSize(); Rectangle rect = shell.getClientArea(); toolBar.setSize(rect.width, size.y); // int toolHeight = size.y /*toolBar.getSize().y*/, count = toolBar.getItemCount(); int toolHeight = toolBar.getSize().y, count = toolBar.getItemCount(); if (count > 0) { Rectangle itemRect = toolBar.getItems()[count - 1].getBounds(); toolBar.setSize(rect.width, toolHeight = itemRect.y + itemRect.height); } text.setBounds(rect.x, rect.y + toolHeight, rect.width, rect.height - toolHeight); } }; shell.addListener(SWT.Resize, resizeListener); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); } }
If this bug is not fixed in 2.0, at least we need workaround for this. Please let me know status of this bug ?
Please let me know the status. Freeze will come soon. Why Windows SWT has this bug, while Linux SWT works fine?
We are not going to fix this for 2.0. It is considered very low priority because eclipse removed all of its combo boxes from the toolbars. The difference between windows and linux is because this is a bug in the Windows OS that we will have to work around.
Why this is considered as priority low ? Eclipse is a platform not an application. Any tools on the Eclipse platform can put any control on Toolbar. That is a functionality which is provided for the tool developer of Eclipse. Actually our tool want to put combobox on the toolbar, so this bug is critical for us. If cannot fix, please give me workaround.
I have a couple of observations and questions for you. 1) I believe that the first type of cheese mentioned ("the line below the combo box is all broken") is no longer a problem - I can't see it any more. 2) If I use 16 x 16 icons, the vertical line cheese (a separator behind the combo) does not show up because the combo is the same height as the icons. (I don't know if that helps, because maybe you need to have 24 x 32 icons, but I just thought I'd mention it). 3) I agree that the wrap behavior is unfortunately not correct. The toolbar thinks that the item is a separator, so the toolbar doesn't think it needs to wrap until the next icon to the left wraps. 4) Eclipse now uses CoolBars instead of ToolBars. I believe that if you put your combo into a CoolBar, this fixes all of your problems, because: a) There is no such thing as "wrap" any more - CoolItems can be repositioned by the user. b) There does not seem to be any more cheese or anything - I will send you a little example that shows this. So please let us know if the latest stable build of Eclipse (called F1) works for you, and if you are happy with having CoolBars instead of ToolBars. Here is the little class that shows how to rewrite your little SWT example code to use CoolBar: import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.events.*; public class PR_1FUC0NM { public static void main(String[] args) { Display display = Display.getDefault(); @@@@ fix this path @@@@ Image image = new Image(display, "j:\\teamswt\\malice\\cello.gif"); final Shell shell = new Shell(display); final CoolBar coolBar = new CoolBar(shell, SWT.BORDER | SWT.FLAT); final Text text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT); for (int i = 0; i < 5; i++) { new ToolItem(toolBar, SWT.PUSH).setImage(image); new ToolItem(toolBar, SWT.SEPARATOR); } toolBar.pack(); CoolItem coolItem = new CoolItem(coolBar, SWT.DROP_DOWN); coolItem.setControl(toolBar); Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point pt = coolItem.computeSize (size.x, size.y); coolItem.setSize(pt); coolItem.setMinimumSize(24, pt.y); Combo combo = new Combo(coolBar, SWT.NULL); for (int i = 0; i < 16; i++) { combo.add("Item " + i); } coolItem = new CoolItem(coolBar, SWT.NONE); coolItem.setControl(combo); size = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT); coolItem.setSize(coolItem.computeSize (size.x, size.y)); coolItem.setMinimumSize(combo.computeSize(SWT.DEFAULT, SWT.DEFAULT, true)); Listener resizeListener = new Listener() { public void handleEvent(Event event) { Point size = coolBar.getSize(); Rectangle rect = shell.getClientArea(); coolBar.setSize(rect.width, size.y); int toolHeight = coolBar.getSize().y, count = coolBar.getItemCount(); if (count > 0) { Rectangle itemRect = coolBar.getItems()[count - 1].getBounds(); coolBar.setSize(rect.width, toolHeight = itemRect.y + itemRect.height); } text.setBounds(rect.x, rect.y + toolHeight, rect.width, rect.height - toolHeight); } }; shell.addListener(SWT.Resize, resizeListener); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); } }
SSQ and I fixed the cheese problem. The wrap problem is Windows behavior. I'm not sure how to work around this.
Thank you for the comment. I understand the wrap problem is come from Windows problem. We have tried to implement our toolbar on Coolbar on F1 build. Then, we have some troubles. Another bug (17477) is opened to track the problem.
The cheese is fixed. The wrap problem is a bug in Windows that I cannot work around at this time. I'm closing this PR because the other PR's cover the remaining issues.