Ejemplo n.º 1
0
  /** Moves the target control on top of the dummy control. */
  public void layout() {
    if (getTargetControl() == null) {
      return;
    }

    // Compute the unclipped bounds of the target in display coordinates
    Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());

    // Clip the bounds of the target so that it doesn't go outside the dummy control's parent
    Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
    displayBounds = displayBounds.intersection(clippingRegion);

    // Compute the bounds of the target, in the local coordinate system of its parent
    Rectangle targetBounds = Geometry.toControl(getTargetControl().getParent(), displayBounds);

    // Move the target
    getTargetControl().setBounds(targetBounds);
  }
Ejemplo n.º 2
0
  protected Point getInitialLocation(Point initialSize) {
    Composite parent = getParent();

    Rectangle parentBounds = parent.getClientArea();
    Point centerPoint = Geometry.centerPoint(parent.getBounds());

    return new Point(
        centerPoint.x - (initialSize.x / 2),
        Math.max(
            parentBounds.y,
            Math.min(
                centerPoint.y - (initialSize.y * 2 / 3),
                parentBounds.y + parentBounds.height - initialSize.y)));
  }
  public static Point getPoint(Rectangle bounds, int side) {
    Point centerPoint = Geometry.centerPoint(bounds);

    switch (side) {
      case SWT.TOP:
        return new Point(centerPoint.x, bounds.y + 1);
      case SWT.BOTTOM:
        return new Point(centerPoint.x, bounds.y + bounds.height - 1);
      case SWT.LEFT:
        return new Point(bounds.x + 1, centerPoint.y);
      case SWT.RIGHT:
        return new Point(bounds.x + bounds.width - 1, centerPoint.y);
    }

    return centerPoint;
  }
Ejemplo n.º 4
0
  /** Run the test */
  protected void runTest() throws CoreException, WorkbenchException {

    widgetFactory.init();
    final Composite widget = widgetFactory.getControl();
    final Point maxSize = widgetFactory.getMaxSize();
    Rectangle initialBounds = widget.getBounds();
    final Rectangle newBounds = Geometry.copy(initialBounds);

    // This test is different now duw to trim API changes so 'gray' it...
    setDegradationComment(
        "<a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=129001>See Bug 129001</a> ");

    for (int xIteration = 0; xIteration < xIterations; xIteration++) {

      processEvents();

      startMeasuring();

      for (int yIteration = 0; yIteration < yIterations; yIteration++) {
        // Avoid giving the same x value twice in a row in order to make
        // it hard to cache
        int xSize = maxSize.x * ((xIteration + yIteration) % xIterations) / xIterations;
        int ySize = maxSize.y * yIteration / yIterations;

        newBounds.width = xSize;
        newBounds.height = ySize;

        widget.setBounds(newBounds);
        widget.layout(flushState);
      }

      stopMeasuring();
    }

    commitMeasurements();
    assertPerformance();

    widget.setBounds(initialBounds);
    widgetFactory.done();
  }
 /* (non-Javadoc)
  * @see org.eclipse.ui.internal.skins.Presentation#computeMinimumSize()
  */
 public Point computeMinimumSize() {
   return Geometry.getSize(tabFolder.computeTrim(0, 0, 0, 0));
 }