Project: SWT
Bug 52935 Emulated Coolbar does not support wrapping
Reported: 2004-02-24 09:42:21 | Status: resolved fixed

The emulated coolbar does not support wrapping. In eclipse this results in bad resize behaviour in the top toolbar area on Mac, Motif, and GTK. Wrapping only occurs if the wrap indices are explicitely set through the API setWrapIndices. It should occur when there is not enough horizontal room to show all the coolitems but there is enough vertical room. Also, CoolBar.computeSize does not give a wrapped height if the width is less than the default width. See the following example: public static void main(String[] args) { Display display = new Display(); Image smallImage = new Image(display, EclipseLAF.class.getResourceAsStream("../images/monochrome16x16.bmp")); Shell shell = new Shell(display); final CoolBar coolbar1 = new CoolBar (shell, SWT.FLAT | SWT.WRAP); coolbar1.setBackground(display.getSystemColor(SWT.COLOR_RED)); ToolBar toolBar1 = new ToolBar (coolbar1, SWT.FLAT); for (int i = 0; i < 20; i++) { ToolItem coolToolItem = new ToolItem (toolBar1, SWT.PUSH); coolToolItem.setImage(smallImage); } CoolItem coolItem1 = new CoolItem (coolbar1, SWT.NONE); coolItem1.setControl (toolBar1); Point size = toolBar1.computeSize (SWT.DEFAULT, SWT.DEFAULT); coolItem1.setMinimumSize(toolBar1.computeSize (size.x, size.y)); coolItem1.setSize(coolItem1.computeSize (size.x, size.y)); toolBar1 = new ToolBar (coolbar1, SWT.FLAT); for (int i = 0; i < 20; i++) { ToolItem coolToolItem = new ToolItem (toolBar1, SWT.PUSH); coolToolItem.setImage(smallImage); } coolItem1 = new CoolItem (coolbar1, SWT.NONE); coolItem1.setControl (toolBar1); size = toolBar1.computeSize (SWT.DEFAULT, SWT.DEFAULT); coolItem1.setMinimumSize(toolBar1.computeSize (size.x, size.y)); coolItem1.setSize(coolItem1.computeSize (size.x, size.y)); toolBar1 = new ToolBar (coolbar1, SWT.FLAT); for (int i = 0; i < 20; i++) { ToolItem coolToolItem = new ToolItem (toolBar1, SWT.PUSH); coolToolItem.setImage(smallImage); } coolItem1 = new CoolItem (coolbar1, SWT.NONE); coolItem1.setControl (toolBar1); size = toolBar1.computeSize (SWT.DEFAULT, SWT.DEFAULT); coolItem1.setMinimumSize(toolBar1.computeSize (size.x, size.y)); coolItem1.setSize(coolItem1.computeSize (size.x, size.y)); System.out.println(coolbar1.computeSize(100, SWT.DEFAULT)); System.out.println(coolbar1.computeSize(400, SWT.DEFAULT)); coolbar1.setSize(150, 200); coolbar1.setLocation(10, 10); shell.setSize(500, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java