Examples of textExtent()


Examples of org.eclipse.swt.graphics.GC.textExtent()

          if (align == SWT.CENTER) {
            int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
            lineX = x + Math.max(0, (extent.x - lineWidth) / 2);
          }
          if (align == SWT.RIGHT) {
            int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
            lineX = Math.max(x, rect.x + rect.width - hIndent - lineWidth);
          }
        }
        gc.drawText(lines[i], lineX, lineY, DRAW_FLAGS);
        lineY += lineHeight;
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

      size.y += r.height;
    }

    GC gc = new GC(this);
    if (text != null && text.length() > 0) {
      Point e = gc.textExtent(text, DRAW_FLAGS);
      size.x += e.x;
      size.y = Math.max(size.y, e.y);
      if (image != null)
        size.x += GAP;
    } else {
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

    // shorten the text
    if (shortenText) {
      extent.x = 0;
      for (int i = 0; i < lines.length; i++) {
        Point e = gc.textExtent(lines[i], DRAW_FLAGS);
        if (e.x > availableWidth) {
          lines[i] = shortenText(gc, lines[i], availableWidth);
          extent.x = Math.max(extent.x, getTotalSize(null, lines[i]).x);
        } else {
          extent.x = Math.max(extent.x, e.x);
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

      gc.setForeground(getForeground());
      for (int i = 0; i < lines.length; i++) {
        int lineX = x;
        if (lines.length > 1) {
          if (align == SWT.CENTER) {
            int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
            lineX = x + Math.max(0, (extent.x - lineWidth) / 2);
          }
          if (align == SWT.RIGHT) {
            int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
            lineX = Math.max(x, rect.x + rect.width - hIndent - lineWidth);
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

          if (align == SWT.CENTER) {
            int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
            lineX = x + Math.max(0, (extent.x - lineWidth) / 2);
          }
          if (align == SWT.RIGHT) {
            int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
            lineX = Math.max(x, rect.x + rect.width - hIndent - lineWidth);
          }
        }
        gc.drawText(lines[i], lineX, lineY, DRAW_FLAGS);
        lineY += lineHeight;
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

    GridData gd = new GridData();
    gd.horizontalSpan = numColumns - 1;
    if (widthInChars != UNLIMITED) {
      GC gc = new GC(spinner);
      try {
        Point extent = gc.textExtent("X");//$NON-NLS-1$
        gd.widthHint = widthInChars * extent.x;
      } finally {
        gc.dispose();
      }
    } else {
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

        GridData gd = new GridData();
        gd.horizontalSpan = numColumns - 1;
        if (widthInChars != UNLIMITED) {
            GC gc = new GC(textField);
            try {
                Point extent = gc.textExtent("X");//$NON-NLS-1$
                gd.widthHint = widthInChars * extent.x;
            } finally {
                gc.dispose();
            }
        } else {
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

    GC gc = new GC(item.getParent());

    int maxWidth = item.getImage().getBounds().width * 4;

    if (gc.textExtent(textValue).x < maxWidth) {
      gc.dispose();
      return textValue;
    }

    for (int i = textValue.length(); i > 0; i--) {
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

    }

    for (int i = textValue.length(); i > 0; i--) {
      String test = textValue.substring(0, i);
      test = test + ellipsis;
      if (gc.textExtent(test).x < maxWidth) {
        gc.dispose();
        return test;
      }

    }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC.textExtent()

    /*
     * Compute the extent of the hover for the current text.
     */
    Point getExtent() {
      GC gc = new GC(hoverShell);
      Point e = gc.textExtent(text);
      gc.dispose();
      e.x += hm * 2;
      e.y += hm * 2;
      return e;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.