Пример #1
0
 void createWidget() {
   super.createWidget();
   text = "";
   if (OS.COMCTL32_MAJOR < 6) {
     if ((style & SWT.MIRRORED) != 0) {
       layout.setOrientation(SWT.RIGHT_TO_LEFT);
     }
     initAccessible();
   }
 }
  @Test
  public void test_getOrientation() {
    TextLayout layout = new TextLayout(display);
    layout.setOrientation(SWT.LEFT_TO_RIGHT);
    assertEquals(SWT.LEFT_TO_RIGHT, layout.getOrientation());
    layout.setOrientation(SWT.RIGHT_TO_LEFT);
    assertEquals(SWT.RIGHT_TO_LEFT, layout.getOrientation());

    layout.setOrientation(SWT.PUSH);
    assertEquals(SWT.RIGHT_TO_LEFT, layout.getOrientation());

    layout.setOrientation(SWT.LEFT_TO_RIGHT | SWT.PUSH);
    assertEquals(SWT.LEFT_TO_RIGHT, layout.getOrientation());

    layout.setOrientation(SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
    assertEquals(SWT.LEFT_TO_RIGHT, layout.getOrientation());

    layout.dispose();
  }
 @Test
 public void test_getTextDirection() {
   if (!SwtTestUtil.isWindows) {
     // TODO Fix GTK and Cocoa failure.
     if (SwtTestUtil.verbose) {
       System.out.println(
           "Excluded test_getTextDirection(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_TextLayout).");
     }
     return;
   }
   int[] styles = {SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, SWT.NONE, -1};
   int n = styles.length;
   int prevDirection = SWT.NONE;
   TextLayout layout = new TextLayout(display);
   for (int i = 0; i < n; i++) {
     int orientation = styles[i];
     if (orientation != -1) {
       layout.setOrientation(orientation);
       if (orientation != 0) prevDirection = orientation;
     }
     for (int j = n - 1; j >= 0; j--) {
       int direction = styles[j];
       if (direction != -1) {
         layout.setTextDirection(direction);
       }
       if (direction == SWT.NONE || direction == -1) {
         assertEquals(
             "orientation: " + orientation + ", text direction: " + direction,
             layout.getTextDirection(),
             prevDirection);
       } else {
         prevDirection = direction;
         assertEquals(
             "orientation: " + orientation + ", text direction: " + direction,
             layout.getTextDirection(),
             direction);
       }
     }
   }
   layout.dispose();
 }
Пример #4
0
 @Override
 void setOrientation(boolean create) {
   super.setOrientation(create);
   layout.setOrientation(style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT));
   if (!create) redraw(true);
 }
Пример #5
0
  /**
   * Provides a TextLayout that can be used for Bidi purposes. This TextLayout should not be
   * disposed by clients.
   *
   * @return an SWT TextLayout instance
   */
  public synchronized TextLayout getTextLayout(int orientation) {
    if (layout == null || layout.isDisposed()) layout = new TextLayout(Display.getDefault());

    layout.setOrientation(orientation);
    return layout;
  }