Can I change how the Word swt widget wraps a word?

The development platform is Eclipse RCP 3.4 for Fedora (it uses its own Gtk component). I need to avoid word wrapping.

ie: "Hello World" appears as case N Β° 1, but I need case N Β° 2.

1|Hello | 2|Hello Wor| |World | |ld | 

Is there a simple solution?

I saw that the swt Text handle is being built with the wrap OS.GTK_WRAP_WORD_CHAR . I would like to test behavior with a constant like OS.GTK_WRAP_WORD or OS.GTK_WRAP_NONE , but I don’t know how this miracle is? Is it possible to programmatically modify the configuration of a specific platform?

EDIT 1 . Solution of one of my colleagues:

 import org.eclipse.swt.SWT; import org.eclipse.swt.internal.gtk.OS; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class SampleGrabExcess { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); shell.setSize(70, 70); GridData gridData = new GridData(); Text addressText = new Text(shell, SWT.BORDER | SWT.MULTI) { @Override protected void checkSubclass() {} @Override protected void checkWidget() { OS.gtk_text_view_set_wrap_mode(handle, 1); super.checkWidget(); } }; gridData = new GridData(); gridData.horizontalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; gridData.verticalAlignment = SWT.FILL; gridData.grabExcessVerticalSpace = true; addressText.setLayoutData(gridData); addressText.setText("Hello World."); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } } 

The result is expected. I am looking for a solution from http://dev.eclipse.org .

+4
source share
1 answer

No, I don’t understand how you could do this.

Btw, even if you could, by setting the OS.GTK_WRAP_WORD and OS.GTK_WRAP_NONE modes, you will not get the desired behavior, since the first breaks the line between words like OS.GTK_WRAP_WORD_CHAR, and the second does not break the lines at all. The mode you are looking for is GTK_WRAP_CHAR. However, the fact that a constant such as OS.GTK_WRAP_CHAR is not even declared in org.eclipse.swt.internal.gtk.OS indicates that the creators of SWT probably did not allow this behavior, even in theory.

0
source

All Articles