org.eclipse.swt.widgets.Label.computeSize()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.eclipse.swt.widgets.Label.computeSize()方法的一些代码示例,展示了Label.computeSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.computeSize()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Label
类名称:Label
方法名:computeSize

Label.computeSize介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

void layout() {
 Composite parent = canvas.getParent();
 Rectangle rect = parent.getClientArea();
 int width = 0;
 String[] items = list.getItems();
 GC gc = new GC( list );
 for ( int i = 0; i < objects.length; i++ ) {
  width = Math.max( width, gc.stringExtent( items[i] ).x );
 }
 gc.dispose();
 Point size1 = start.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size2 = stop.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size3 = check.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size4 = label.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 width = Math.max( size1.x, Math.max( size2.x, Math.max( size3.x, width ) ) );
 width = Math.max( 64, Math.max( size4.x, list.computeSize( width, SWT.DEFAULT ).x ) );
 start.setBounds( 0, 0, width, size1.y );
 stop.setBounds( 0, size1.y, width, size2.y );
 check.setBounds( 0, size1.y + size2.y, width, size3.y );
 label.setBounds( 0, rect.height - size4.y, width, size4.y );
 int height = size1.y + size2.y + size3.y;
 list.setBounds( 0, height, width, rect.height - height - size4.y );
 text.setBounds( width, 0, rect.width - width, rect.height );
 canvas.setBounds( width, 0, rect.width - width, rect.height );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.editors

/**
 * Adds the internal trimmings to the given trim of the shell.
 *
 * @param trim the shell's trim, will be updated
 * @since 3.4
 */
private void addInternalTrim(Rectangle trim) {
  if (fStatusField != null) {
    trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Adds the internal trimmings to the given trim of the shell.
 *
 * @param trim the shell's trim, will be updated
 * @since 3.4
 */
private void addInternalTrim(Rectangle trim) {
  if (fStatusField != null) {
    trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public Point computeSize(int wHint, int hHint, boolean changed) {
    Point pt = super.computeSize(wHint, hHint, changed);
    if (pt.x > ptMax.x) {
      ptMax.x = pt.x;
    }
    if (pt.y > ptMax.y) {
      ptMax.y = pt.y;
    }
    return ptMax;
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Adds the internal trimmings to the given trim of the shell.
 *
 * @param trim the shell's trim, will be updated
 * @since 3.4
 */
private void addInternalTrim(Rectangle trim) {
  if (fStatusField != null) {
    trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.help.ui

public Point computeSize(int wHint, int hHint, boolean changed) {
  int innerWidth = wHint;
  if (innerWidth != SWT.DEFAULT)
    innerWidth -= 4;
  Point textSize = label.computeSize(wHint, hHint, changed);//computeTextSize(innerWidth,
  // hHint);
  int textWidth = textSize.x + 4;
  int textHeight = textSize.y + 6;
  return new Point(textWidth, textHeight);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

@Override
public Point computeSize(Composite editor, int wHint, int hHint,
    boolean force) {
  if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
    return new Point(wHint, hHint);
  }
  Point colorSize = colorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
      force);
  Point rgbSize = rgbLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
      force);
  return new Point(colorSize.x + GAP + rgbSize.x, Math.max(
      colorSize.y, rgbSize.y));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
public Point computeSize(Composite editor, int wHint, int hHint,
    boolean force) {
  if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
    return new Point(wHint, hHint);
  }
  Point colorSize = colorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
      force);
  Point rgbSize = rgbLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
      force);
  return new Point(colorSize.x + GAP + rgbSize.x, Math.max(
      colorSize.y, rgbSize.y));
}

代码示例来源:origin: org.codehaus.openxma/xmartserver

private void scalebyLabel(Composite comp) {
  Label label = new Label(comp,SWT.NONE);
  label.setText(scaleText);
  Point p = label.computeSize(SWT.DEFAULT,SWT.DEFAULT);
  double fx = (p.x-1)/44.55;
  double fy = p.y-1;
  //rem: divide first to overcome rounding errors in case of fx==SmallBaseX and fy==SmallBaseY
  factorX = (fx/smallBaseX); //+0.08;
  factorY = (fy/smallBaseY); //+0.08;
  label.dispose();
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 * Returns the width of this element.
 *
 * @return current width of this element
 */
public int getWidth() {
  int result= 2;
  if (fElementImage.getImage() != null)
    result+= fElementImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
  if (fTextVisible && fElementText.getText().length() > 0)
    result+= fElementText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
  return result;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 * Returns the width of this element.
 *
 * @return current width of this element
 */
public int getWidth() {
  int result= 2;
  if (fElementImage.getImage() != null)
    result+= fElementImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
  if (fTextVisible && fElementText.getText().length() > 0)
    result+= fElementText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
  return result;
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

private void scalebyLabel(Composite comp) {
  Label label = new Label(comp,SWT.NONE);
  label.setText(scaleText);
  Point p = label.computeSize(SWT.DEFAULT,SWT.DEFAULT);
  double fx = (p.x-1)/44.55;
  double fy = p.y-1;
  //rem: divide first to overcome rounding errors in case of fx==SmallBaseX and fy==SmallBaseY
  factorX = (fx/smallBaseX); //+0.08;
  factorY = (fy/smallBaseY); //+0.08;
  label.dispose();
}

代码示例来源:origin: org.eclipse/org.eclipse.ajdt.ui

public void setSize(int width, int height) {
  if (fStatusField != null) {
    GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
    Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.heightHint= height - statusSize.y - separatorSize.y;
  }
  fShell.setSize(width, height);
  if (fStatusField != null)
    fShell.pack(true);
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

public void setSize(int width, int height) {
  if (fStatusField != null) {
    GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
    Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.heightHint= height - statusSize.y - separatorSize.y;
  }
  fShell.setSize(width, height);
  if (fStatusField != null)
    fShell.pack(true);
}

代码示例来源:origin: org.eclipse/org.eclipse.ui.editors

public void setSize(int width, int height) {
  if (fStatusField != null) {
    GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
    Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.heightHint= height - statusSize.y - separatorSize.y;
  }
  fShell.setSize(width, height);
  if (fStatusField != null)
    fShell.pack(true);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@Override
public void setSize(int width, int height) {
  if (fStatusField != null) {
    GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
    Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.heightHint= height - statusSize.y - separatorSize.y;
  }
  fShell.setSize(width, height);
  if (fStatusField != null)
    fShell.pack(true);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
public void setSize(int width, int height) {
  if (fStatusField != null) {
    GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
    Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.heightHint= height - statusSize.y - separatorSize.y;
  }
  fShell.setSize(width, height);
  if (fStatusField != null)
    fShell.pack(true);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.editors

@Override
public void setSize(int width, int height) {
  if (fStatusField != null) {
    GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
    Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.heightHint= height - statusSize.y - separatorSize.y;
  }
  fShell.setSize(width, height);
  if (fStatusField != null)
    fShell.pack(true);
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

public Point computeSize(int wHint, int hHint, boolean changed) {
  if (wHint == SWT.DEFAULT) {
    GC gc = new GC(this);
    wHint = gc.textExtent("22").x;  //$NON-NLS-1$
    gc.dispose();
  }
  return super.computeSize(wHint, hHint, changed);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

void handleResize(ControlEvent event) {
  Rectangle rect = shell.getClientArea();
  Point cSize = coolBar.computeSize(rect.width, SWT.DEFAULT);
  Point sSize = statusBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  int statusMargin = 2;
  coolBar.setBounds(rect.x, rect.y, cSize.x, cSize.y);
  styledText.setBounds(rect.x, rect.y + cSize.y, rect.width, rect.height - cSize.y - (sSize.y + 2 * statusMargin));
  statusBar.setBounds(rect.x + statusMargin, rect.y + rect.height - sSize.y - statusMargin, rect.width - (2 * statusMargin), sSize.y);
}

相关文章