Examples of textExtent()


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

        if (!item.isVisible()) continue;
        int cellLength = 0;
        if (item.getText().equals("-") || (item.getStyle() & SWT.SEPARATOR) != 0) cellLength = SEPARATOR_WIDTH;
        else
        {
          cellLength = cellMinLength + gc.textExtent(item.getText(), DRAW_FLAGS).x
              + 1;
        }

        Rectangle cellRect = new Rectangle(lengthStart, VERTICAL_GAP + rowHeight
            * rows, cellLength, rowHeight);
View Full Code Here

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

            cellLength = cellMinLength + imageWidth;
          }
          else if (item.getImage() == null)
          {
            cellLength = cellMinLength
                + gc.textExtent(item.getText(), DRAW_FLAGS).x;
          }
          else
          {
            if ((style & SWT.TOP) == 0 && (style & SWT.BOTTOM) == 0)
            {
View Full Code Here

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

          else
          {
            if ((style & SWT.TOP) == 0 && (style & SWT.BOTTOM) == 0)
            {
              cellLength = cellMinLength
                  + gc.textExtent(item.getText(), DRAW_FLAGS).x
                  + HORIZON_MARGIN;
              cellLength += imageWidth;
            }
            else
            {
View Full Code Here

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

                  + HORIZON_MARGIN;
              cellLength += imageWidth;
            }
            else
            {
              cellLength = gc.textExtent(item.getText(), DRAW_FLAGS).x;
              cellLength = cellLength < imageWidth ? imageWidth : cellLength;
              cellLength += (cellMinLength);
            }
            hasText = true;
          }
View Full Code Here

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

 
  private Point getTotalSize(String txt) {
    Point size = new Point(0, 0);   
    GC gc = new GC(this);
    if (txt != null && txt.length() > 0) {
      Point e = gc.textExtent(txt, DRAW_FLAGS);
      size.x += e.x;
      size.y = Math.max(size.y, e.y);     
    } else {
      size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
    }
View Full Code Here

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

    String[] lines = text == null ? null : splitString(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(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 + rect.width / 15, lineY, DRAW_FLAGS);
      lineY += lineHeight;
View Full Code Here

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

    GC gc = new GC(this);
    gc.setFont(getFont());
    if ((getStyle() & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
      extent = FormUtil.computeWrapSize(gc, getText(), wHint);
    } else {
      extent = gc.textExtent(getText());
    }
    gc.dispose();
    return extent;
  }
View Full Code Here

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

    if (getText() == null) {
      cellLength = cellMinLength;
      if (image != null) cellLength += image.getImageData().width;
    } else if (image == null) {
      cellLength = cellMinLength + gc.textExtent(getText(), DRAW_FLAGS).x*2;
    } else {
      if ((style & SWT.TOP) == 0 && (style & SWT.BOTTOM) == 0) {
        cellLength = cellMinLength + gc.textExtent(getText(), DRAW_FLAGS).x* 2 + HORIZON_MARGIN;
        if (image != null) cellLength += image.getImageData().width;
      } else {
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.