Package org.eclipse.swt.graphics

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


        Rectangle imageBounds = anItem.getImage().getBounds();
        bounds.height = Math.max(bounds.height, imageBounds.height);
      }
     
      if (anItem.getText() != null && !anItem.getText().isEmpty()) {
        Point textSize = gc.stringExtent(anItem.getText());
        bounds.height = Math.max(bounds.height, textSize.y);
      }
     
      Image closeButtonImage = UIImageResource.T.closeNormal10();
      Rectangle closeButtonImageBounds = closeButtonImage.getBounds();
View Full Code Here


      if (anItem.getText() != null && !anItem.getText().isEmpty()) {
        if (anItem.getImage() != null) {
          extent += spacing;
        }
       
        Point textSize = gc.stringExtent(anItem.getText());
        extent += textSize.x;
      }

      if (anItem.getImage() != null || (anItem.getText() != null && !anItem.getText().isEmpty())) {
        extent += spacing;
View Full Code Here

      if (item.getImage() != null) {
        result.x += spacing;
      }
     
      GC gc = new GC(this);
      Point textSize = gc.stringExtent(item.getText());
      result.y -= textSize.y / 2;
      result.width = textSize.x;
      result.height = textSize.y;
      gc.dispose();
    }
View Full Code Here

  public Point getTextSize() {
    Point textSize = new Point(0, 0);
   
    if (hasText()) {
      GC gc = new GC(parent);
      textSize = gc.stringExtent(getText());
      gc.dispose();
    }
   
    return textSize;
  }
View Full Code Here

public Point computeSize (int wHint, int hHint, boolean changed) {
  checkWidget ();
  int width = 0, height = 0;
  String[] items = list.getItems ();
  GC gc = new GC (text);
  int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
  int textWidth = gc.stringExtent (text.getText ()).x;
  for (int i = 0; i < items.length; i++) {
    textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
  }
  gc.dispose ();
View Full Code Here

  checkWidget ();
  int width = 0, height = 0;
  String[] items = list.getItems ();
  GC gc = new GC (text);
  int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
  int textWidth = gc.stringExtent (text.getText ()).x;
  for (int i = 0; i < items.length; i++) {
    textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
  }
  gc.dispose ();
  Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
View Full Code Here

  String[] items = list.getItems ();
  GC gc = new GC (text);
  int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
  int textWidth = gc.stringExtent (text.getText ()).x;
  for (int i = 0; i < items.length; i++) {
    textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
  }
  gc.dispose ();
  Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
  Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
  Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
View Full Code Here

    Image image = new Image(Display.getCurrent(), imageData);
    GC gc = new GC(image);

    String styleString = style.getStyle().name().substring(0, 2);
    Point p = gc.stringExtent(styleString);

    gc.dispose();
    image.dispose();

    imageData = new ImageData(p.x + 4, p.y, 1, paletteData);
View Full Code Here

  private Caret createOverwriteCaret(StyledText styledText) {
    Caret caret= new Caret(styledText, SWT.NULL);
    GC gc= new GC(styledText);
    // XXX: this overwrite box is not proportional-font aware
    // take 'a' as a medium sized character
    Point charSize= gc.stringExtent("a"); //$NON-NLS-1$

    // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612
    caret.setSize(charSize.x, styledText.getLineHeight());
    caret.setFont(styledText.getFont());
View Full Code Here

    paletteCanvas.getVerticalBar().setVisible(true);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    GC gc = new GC(paletteLabel);
    paletteWidth = gc.stringExtent(ImageAnalyzer.bundle.getString("Max_length_string")).x;
    gc.dispose();
    gridData.widthHint = paletteWidth;
    gridData.heightHint = 16 * 11; // show at least 16 colors
    paletteCanvas.setLayoutData(gridData);
    paletteCanvas.addPaintListener(new PaintListener() {
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.