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

x33g5p2x  于2022-01-30 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(125)

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

Scrollable.computeTrim介绍

[英]Given a desired client area for the receiver (as described by the arguments), returns the bounding rectangle which would be required to produce that client area.

In other words, it returns a rectangle such that, if the receiver's bounds were set to that rectangle, the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings") would be the rectangle described by the arguments (relative to the receiver's parent).
[中]给定接收器所需的客户区(如参数所述),返回生成该客户区所需的边框。
换句话说,它返回一个矩形,这样,如果接收器的边界被设置为该矩形,那么接收器能够显示数据的区域(即,不被“修剪”覆盖)将是参数描述的矩形(相对于接收器的父级)。

代码示例

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

@Override
public Rectangle computeTrim( int x, int y, int width, int height ) {
 Rectangle result = super.computeTrim( x, y, width, height );
 if( ( style & SWT.MULTI ) != 0 && ( style & SWT.H_SCROLL ) != 0 ) {
  result.width++;
 }
 return result;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}
@Override

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}
@Override

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}
protected boolean flushCache(Control control) {

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}
@Override

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

int computeTrim(Control c) {
  if (c instanceof Scrollable) {
    Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
    return rect.width;
  }
  return c.getBorderWidth () * 2;
}
@Override

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

/**
 * Try to figure out how much we need to subtract from the hints that we
 * pass into the given control's computeSize(...) method. This tries to
 * compensate for bug 46112. To be removed once SWT provides an "official"
 * way to compute one dimension of a control's size given the other known
 * dimension.
 *
 * @param control
 */
private void computeHintOffset(Control control) {
  if (control instanceof Scrollable) {
    // For scrollables, subtract off the trim size
    Scrollable scrollable = (Scrollable) control;
    Rectangle trim = scrollable.computeTrim(0, 0, 0, 0);
    widthAdjustment = trim.width;
    heightAdjustment = trim.height;
  } else {
    // For non-composites, subtract off 2 * the border size
    widthAdjustment = control.getBorderWidth() * 2;
    heightAdjustment = widthAdjustment;
  }
}

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

/**
 * Try to figure out how much we need to subtract from the hints that we
 * pass into the given control's computeSize(...) method. This tries to
 * compensate for bug 46112. To be removed once SWT provides an "official"
 * way to compute one dimension of a control's size given the other known
 * dimension.
 *
 * @param control
 */
private void computeHintOffset(Control control) {
  if (control instanceof Scrollable) {
    // For scrollables, subtract off the trim size
    Scrollable scrollable = (Scrollable) control;
    Rectangle trim = scrollable.computeTrim(0, 0, 0, 0);
    widthAdjustment = trim.width;
    heightAdjustment = trim.height;
  } else {
    // For non-composites, subtract off 2 * the border size
    widthAdjustment = control.getBorderWidth() * 2;
    heightAdjustment = widthAdjustment;
  }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

int computeTrim( Control c ) {
 if( c instanceof Scrollable ) {
  Rectangle rect = ( ( Scrollable )c ).computeTrim( 0, 0, 0, 0 );
  return rect.width;
 }
 BoxDimensions border = c.getAdapter( ControlThemeAdapter.class ).getBorder( c );
 return border.left + border.right;
}

代码示例来源:origin: com.miglayout/miglayout-swt

private Point computeSize(boolean hor, int sz)
{
  //Point p = c.getSize();
  int wHint = hor ? SWT.DEFAULT : sz;     //(hor || p.x <= 0) ? sz : p.x;
  int hHint = !hor ? SWT.DEFAULT : sz;    //(!hor || p.y <= 0) ? sz : p.y;
  if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
    int trim = 0;
    if (c instanceof Scrollable) {
      Rectangle rect = ((Scrollable) c).computeTrim(0, 0, 0, 0);
      trim = hor ? rect.width : rect.height;
    } else {
      trim = (c.getBorderWidth() << 1);
    }
    if (wHint == SWT.DEFAULT) {
      hHint = Math.max(0, hHint - trim);
    } else {
      wHint = Math.max(0, wHint - trim);
    }
  }
  return c.computeSize(wHint, hHint);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

int computeTrim( Control c ) {
 if( c instanceof Scrollable ) {
  Rectangle rect = ( ( Scrollable )c ).computeTrim( 0, 0, 0, 0 );
  return rect.width;
 }
 BoxDimensions border = c.getAdapter( ControlThemeAdapter.class ).getBorder( c );
 return border.left + border.right;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

Point computeChildSize (Control control, int wHint, int hHint, boolean flushCache) {
  FillData data = (FillData)control.getLayoutData ();
  if (data == null) {
    data = new FillData ();
    control.setLayoutData (data);
  }
  Point size = null;
  if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
    size = data.computeSize (control, wHint, hHint, flushCache);
  } else {
    // TEMPORARY CODE
    int trimX, trimY;
    if (control instanceof Scrollable) {
      Rectangle rect = ((Scrollable) control).computeTrim (0, 0, 0, 0);
      trimX = rect.width;
      trimY = rect.height;
    } else {
      trimX = trimY = control.getBorderWidth () * 2;
    }
    int w = wHint == SWT.DEFAULT ? wHint : Math.max (0, wHint - trimX);
    int h = hHint == SWT.DEFAULT ? hHint : Math.max (0, hHint - trimY);
    size = data.computeSize (control, w, h, flushCache);
  }
  return size;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

Point computeChildSize (Control control, int wHint, int hHint, boolean flushCache) {
  FillData data = (FillData)control.getLayoutData ();
  if (data == null) {
    data = new FillData ();
    control.setLayoutData (data);
  }
  Point size = null;
  if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
    size = data.computeSize (control, wHint, hHint, flushCache);
  } else {
    // TEMPORARY CODE
    int trimX, trimY;
    if (control instanceof Scrollable) {
      Rectangle rect = ((Scrollable) control).computeTrim (0, 0, 0, 0);
      trimX = rect.width;
      trimY = rect.height;
    } else {
      trimX = trimY = control.getBorderWidth () * 2;
    }
    int w = wHint == SWT.DEFAULT ? wHint : Math.max (0, wHint - trimX);
    int h = hHint == SWT.DEFAULT ? hHint : Math.max (0, hHint - trimY);
    size = data.computeSize (control, w, h, flushCache);
  }
  return size;
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

Point computeChildSize (Control control, int wHint, int hHint, boolean flushCache) {
  FillData data = (FillData)control.getLayoutData ();
  if (data == null) {
    data = new FillData ();
    control.setLayoutData (data);
  }
  Point size = null;
  if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
    size = data.computeSize (control, wHint, hHint, flushCache);
  } else {
    // TEMPORARY CODE
    int trimX, trimY;
    if (control instanceof Scrollable) {
      Rectangle rect = ((Scrollable) control).computeTrim (0, 0, 0, 0);
      trimX = rect.width;
      trimY = rect.height;
    } else {
      trimX = trimY = control.getBorderWidth () * 2;
    }
    int w = wHint == SWT.DEFAULT ? wHint : Math.max (0, wHint - trimX);
    int h = hHint == SWT.DEFAULT ? hHint : Math.max (0, hHint - trimY);
    size = data.computeSize (control, w, h, flushCache);
  }
  return size;
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

public Rectangle computeTrim (int x, int y, int width, int height) {
  Rectangle result = super.computeTrim (x, y, width, height);
  if ((style & SWT.SINGLE) != 0) {
    NSTextField widget = (NSTextField) view;
    if ((style & SWT.SEARCH) != 0) {
      NSSearchFieldCell cell = new NSSearchFieldCell (widget.cell ());
      int testWidth = 100;
      NSRect rect = new NSRect ();
      rect.width = testWidth;
      rect = cell.searchTextRectForBounds (rect);
      int leftIndent = (int)rect.x;
      int rightIndent = testWidth - leftIndent - (int)Math.ceil (rect.width);
      result.x -= leftIndent;
      result.width += leftIndent + rightIndent;
    }
    NSRect inset = widget.cell ().titleRectForBounds (new NSRect ());
    result.x -= inset.x;
    result.y -= inset.y;
    result.width -= inset.width;
    result.height -= inset.height;
  }
  return result;
}

相关文章

Scrollable类方法