line wrapping [message #214240] |
Fri, 14 April 2006 13:19 |
Kanstantsin Chernysh Messages: 8 Registered: July 2009 |
Junior Member |
|
|
The following snippet shows wrong behavior while line wrapping in
TextFlow. The comma is drawn on the second line separately but the whole
word hello), should be moved to the next line. Is there any possibility
to correct this issue?
import org.eclipse.draw2d.*;
import org.eclipse.draw2d.text.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class TestLayout {
/**
*
*/
private static final String STRING_1 =
"Test test test test test test test test test (test test hello)";
private static final String STRING_2 = ", next line";
protected static final Font FONT = new Font(Display.getDefault(),
"Arial", 12, 0);
protected FigureCanvas fc;
protected IFigure contents;
protected Shell shell;
Display d;
protected void run(){
d = Display.getDefault();
shell = new Shell(d);
String appName = getClass().getName();
appName = appName.substring(appName.lastIndexOf('.')+1);
shell.setText(appName);
shell.setLayout(new GridLayout(1, false));
fc = new FigureCanvas(shell);
fc.setContents(contents = getContents());
fc.getViewport().setContentsTracksHeight(true);
fc.getViewport().setContentsTracksWidth(true);
shell.setFont(FONT);
sizeShell();
shell.pack();
shell.open();
while (!shell.isDisposed())
while (!d.readAndDispatch())
d.sleep();
}
protected void sizeShell() {
GC gc = new GC(shell);
Point size = gc.textExtent(STRING_1);
gc.dispose();
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
data.widthHint = size.x;
data.heightHint = 200;
fc.setLayoutData(data);
}
protected IFigure getContents() {
FlowPage page = new FlowPage();
page.setOpaque(true);
BlockFlow block = new BlockFlow();
TextFlow text = new TextFlow(STRING_1 + STRING_2);
block.add(text);
block.setFont(FONT);
page.add(block);
return page;
}
public static void main(String[] args) {
new TestLayout().run();
}
}
|
|
|
Re: line wrapping [message #214310 is a reply to message #214240] |
Fri, 14 April 2006 21:12 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Please open a bugzilla. If you have any ideas about fixing it, let us know.
In some places we append the letter "a" and see if we can break before it.
Maybe we could do the same using prepend.
"Kanstantsin Chernys" <Krotzzz@tut.by> wrote in message
news:48de48c176c04461738650dc5e995538$1@www.eclipse.org...
> The following snippet shows wrong behavior while line wrapping in
> TextFlow. The comma is drawn on the second line separately but the whole
> word
|
|
|
Powered by
FUDForum. Page generated in 0.04122 seconds