Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Can't get Bidi to work like StyledText
Can't get Bidi to work like StyledText [message #445241] Fri, 29 October 2004 14:17 Go to next message
Randy Hudson is currently offline Randy HudsonFriend
Messages: 123
Registered: July 2009
Senior Member
I'm trying to reproduce Bidi text rendering. I can't figure out why the
following two controls paint the same text in a different way.

public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(SWT.SHELL_TRIM | SWT.RIGHT_TO_LEFT);
shell.setLayout(new GridLayout());

final String message = "ABC 890\n123 ABC def";

StyledText text = new StyledText(shell, SWT.MULTI | SWT.BORDER |
SWT.RIGHT_TO_LEFT);
text.setLayoutData(new GridData(GridData.FILL_BOTH));
text.setText(message);

final Canvas canvas = new Canvas(shell, SWT.BORDER | SWT.RIGHT_TO_LEFT);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
TextLayout layout = new TextLayout(shell.getDisplay());
layout.setWidth(shell.getClientArea().width);
layout.setOrientation(SWT.RIGHT_TO_LEFT);
layout.setText(message);
layout.draw(e.gc, 0, 0);
layout.dispose();
}
});

shell.setSize(400, 300);
shell.open();

while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
Re: Can't get Bidi to work like StyledText [message #445313 is a reply to message #445241] Mon, 01 November 2004 17:20 Go to previous message
Eclipse UserFriend
Originally posted by: felipe_heidrich.oti.com

StyledText never passes line breaks "\n" to TextLayout.
TextLayout on Windows is failing to reorder text containing "\n", pls file
a bug against SWT about this problem.

The correct reordering of string in the example is shown by StyledText.

Felipe


Randy Hudson wrote:

> I'm trying to reproduce Bidi text rendering. I can't figure out why the
> following two controls paint the same text in a different way.

> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(SWT.SHELL_TRIM | SWT.RIGHT_TO_LEFT);
> shell.setLayout(new GridLayout());

> final String message = "ABC 890n123 ABC def";

> StyledText text = new StyledText(shell, SWT.MULTI | SWT.BORDER |
> SWT.RIGHT_TO_LEFT);
> text.setLayoutData(new GridData(GridData.FILL_BOTH));
> text.setText(message);

> final Canvas canvas = new Canvas(shell, SWT.BORDER | SWT.RIGHT_TO_LEFT);
> canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
> canvas.addPaintListener(new PaintListener() {
> public void paintControl(PaintEvent e) {
> TextLayout layout = new TextLayout(shell.getDisplay());
> layout.setWidth(shell.getClientArea().width);
> layout.setOrientation(SWT.RIGHT_TO_LEFT);
> layout.setText(message);
> layout.draw(e.gc, 0, 0);
> layout.dispose();
> }
> });

> shell.setSize(400, 300);
> shell.open();

> while (!shell.isDisposed())
> if (!display.readAndDispatch())
> display.sleep();
> }
Previous Topic:ISharedTextColors implementation
Next Topic:Creating own widget from SWT Label
Goto Forum:
  


Current Time: Thu Apr 25 05:40:58 GMT 2024

Powered by FUDForum. Page generated in 0.03400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top