Package org.eclipse.swt.graphics

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


  }

  private void setWidthForSampleText(Text control, String sampleText) {
    GC gc = new GC(control);
    try {
      Point sampleSize = gc.textExtent(sampleText);
      Point currentSize = control.getSize();
      sampleSize.y = currentSize.y;
      control.setSize(sampleSize);
      return;
    } finally {
View Full Code Here


  }

  private void setWidthForSampleText(Text control, String sampleText) {
    GC gc = new GC(control);
    try {
      Point sampleSize = gc.textExtent(sampleText);
      Point currentSize = control.getSize();
      sampleSize.y = currentSize.y;
      control.setSize(sampleSize);
      return;
    } finally {
View Full Code Here

  }

  private void setWidthForSampleText(Text control, String sampleText) {
    GC gc = new GC(control);
    try {
      Point sampleSize = gc.textExtent(sampleText);
      Point currentSize = control.getSize();
      sampleSize.y = currentSize.y;
      control.setSize(sampleSize);
      return;
    } finally {
View Full Code Here

    if (textValue == null) {
      return null;
    }
    GC gc = new GC(control);
    int maxWidth = control.getBounds().width - 5;
    if (gc.textExtent(textValue).x < maxWidth) {
      gc.dispose();
      return textValue;
    }
    int length = textValue.length();
    int ellipsisWidth = gc.textExtent(ellipsis).x;
View Full Code Here

    if (gc.textExtent(textValue).x < maxWidth) {
      gc.dispose();
      return textValue;
    }
    int length = textValue.length();
    int ellipsisWidth = gc.textExtent(ellipsis).x;
    // Find the second space seperator and start from there
    int secondWord = findSecondWhitespace(textValue, gc, maxWidth);
    int pivot = ((length - secondWord) / 2) + secondWord;
    int start = pivot;
    int end = pivot + 1;
View Full Code Here

    int start = pivot;
    int end = pivot + 1;
    while (start >= secondWord && end < length) {
      String s1 = textValue.substring(0, start);
      String s2 = textValue.substring(end, length);
      int l1 = gc.textExtent(s1).x;
      int l2 = gc.textExtent(s2).x;
      if (l1 + ellipsisWidth + l2 < maxWidth) {
        gc.dispose();
        return s1 + ellipsis + s2;
      }
View Full Code Here

    int end = pivot + 1;
    while (start >= secondWord && end < length) {
      String s1 = textValue.substring(0, start);
      String s2 = textValue.substring(end, length);
      int l1 = gc.textExtent(s1).x;
      int l2 = gc.textExtent(s2).x;
      if (l1 + ellipsisWidth + l2 < maxWidth) {
        gc.dispose();
        return s1 + ellipsis + s2;
      }
      start--;
View Full Code Here

        // draw image
        DrawUtils.drawScaledImage(gc, image, clientArea);
        // draw size message
        {
          String message = image.getBounds().width + "x" + image.getBounds().height;
          Point extent = gc.textExtent(message);
          int x = (clientArea.width - extent.x) / 2;
          int y = clientArea.height - extent.y - 5;
          gc.drawText(message, x, y);
        }
      }
View Full Code Here

        // same height as the awt one
        if (ensureSameSize) {
            GC tmpGC = new GC(device);
            Font tmpFont = new Font(device, fontData);
            tmpGC.setFont(tmpFont);
            if (tmpGC.textExtent(Az).x
                    > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                while (tmpGC.textExtent(Az).x
                        > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                    tmpFont.dispose();
                    height--;
View Full Code Here

            GC tmpGC = new GC(device);
            Font tmpFont = new Font(device, fontData);
            tmpGC.setFont(tmpFont);
            if (tmpGC.textExtent(Az).x
                    > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                while (tmpGC.textExtent(Az).x
                        > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                    tmpFont.dispose();
                    height--;
                    fontData.setHeight(height);
                    tmpFont = new Font(device, fontData);
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.