Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Is it possible to modify how Text swt widget wrap word?(org.eclipse.swt.widgets.Text wrapping)
Is it possible to modify how Text swt widget wrap word? [message #804974] Thu, 23 February 2012 07:56
Sokaris Mykerinos is currently offline Sokaris MykerinosFriend
Messages: 3
Registered: September 2011
Location: Paris
Junior Member
Hi,

I need to avoid word wrapping.

i.e.: "Hello World" is displayed as case N°1 but I need the case N°2.

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

Is it possible to have this behaviour with SWT.CONSTANT style ?

The development platform is an Eclipse RCP 3.4 on Fedora (It's using Gtk native component).
I've seen that swt Text handle is build with OS.GTK_WRAP_WORD_CHAR wrap mode. I would like to test the behaviour with constant like OS.GTK_WRAP_WORD or OS.GTK_WRAP_NONE.

Is it possible to modify platform specific configuration programmatically without override swt Text widget?

This snippet can do the trick, but it's platform dependant:
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();
         }
      }
   }
}

Previous Topic:How to embed OleControlSite in a MultiPageEditor?
Next Topic:Setting XULRunner properties programmatically
Goto Forum:
  


Current Time: Sat Nov 29 01:26:56 GMT 2014

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

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