开发平台是Fedora上的Eclipse RCP 3.4(它使用Gtk本机组件)。我需要避免自动换行。
即:“Hello World”显示为案例 N°1,但我需要案例 N°2。
1|Hello | 2|Hello Wor|
|World | |ld |
有简单的解决办法吗?
我已经看到 swt Text 句柄是用OS.GTK_WRAP_WORD_CHAR
换行模式。我想用常量来测试行为OS.GTK_WRAP_WORD
or OS.GTK_WRAP_NONE
但我不知道如何创造这个奇迹?是否可以通过编程方式修改特定于平台的配置?
EDIT 1- 我的一位同事提供了一个解决方案:
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();
}
}
}
}
结果正如预期的那样。我正在寻找解决方案http://dev.eclipse.org http://dev.eclipse.org.
不,我不明白你怎么能做到这一点。
顺便说一句,即使可以,将模式设置为 OS.GTK_WRAP_WORD 和 OS.GTK_WRAP_NONE 也不会获得所需的行为,因为第一个在单词之间换行,就像 OS.GTK_WRAP_WORD_CHAR 一样,而第二个则不会完全断线。您正在寻找的模式是 GTK_WRAP_CHAR。然而,事实上,像 OS.GTK_WRAP_CHAR 这样的常量甚至没有在org.eclipse.swt.internal.gtk.OS http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6.1/org.eclipse.swt.gtk.linux/x86_64/3.6.1/org/eclipse/swt/internal/gtk/OS.java表明 SWT 的创建者可能反对允许这种行为,即使在理论上也是如此。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)