Community
Participate
Working Groups
Build Identifier: 20110916-0149 The conversion from tabs (\t) to whitespace is different for Text widget, StyledText widget and GC. The behaviour changes for different operating systems. Reproducible: Always Steps to Reproduce: public class SWTTabBug { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, true)); FontData fd = shell.getFont().getFontData()[0]; final Font font = new Font(display, fd.getName(), 60, SWT.BOLD | SWT.ITALIC); final Image image = new Image(display, 640, 480); final Rectangle rect = image.getBounds(); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_RED)); gc.fillOval(rect.x, rect.y, rect.width, rect.height); gc.dispose(); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { GC gc = event.gc; gc.drawText("Start\tEnd", 0, 50); } }); StyledText styledText = new StyledText(shell, SWT.NONE); styledText.setText("Start\tEnd"); GridData data = new GridData(); data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; styledText.setLayoutData(data); Text text = new Text(shell, SWT.NONE); text.setText("Start\tTab"); data = new GridData(); data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; text.setLayoutData(data); shell.setSize(shell.computeSize(rect.width / 2, rect.height / 2)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); font.dispose(); display.dispose(); } }
Created attachment 209013 [details] Tabs on windows 7
Created attachment 209014 [details] Tabs on Ubuntu
Created attachment 209024 [details] Tabs on Mac OSX Lion The following sreenshot shows how the snippet behaves on MacOSX.
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. -- The automated Eclipse Genie.