Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Point


    _viewer.refresh(element);
  }
 

  public void handleEvent(Event event) {
    final Point pt = new Point(event.x, event.y);
    final TableItem item = _viewer.getTable().getItem(pt);   
    if (item != null) {
      for (int column = 0; column < _viewer.getTable().getColumnCount(); column++) {
        Rectangle rect = item.getBounds(column);
        if (rect.contains(pt)) {
View Full Code Here


      return;
   
    MenuManager menu= new MenuManager();
    fillMenu(menu);
    final Menu widget= menu.createContextMenu(focus.getShell());
    Point location= computeMenuLocation(focus, widget);
    if (location == null)
      return;
    widget.setLocation(location);
    widget.setVisible(true);
    while (!widget.isDisposed() && widget.isVisible()) {
View Full Code Here

      return null;
    return bindingService.getBestActiveBindingFormattedFor(getActionDefinitionId());
  }

  private Point computeMenuLocation(Control focus, Menu menu) {
    Point cursorLocation= focus.getDisplay().getCursorLocation();
    Rectangle clientArea= null;
    Point result= null;
    if (focus instanceof StyledText) {
      StyledText styledText= (StyledText)focus;
      clientArea= styledText.getClientArea();
      result= computeMenuLocation(styledText);
    } else if (focus instanceof Tree) {
      Tree tree= (Tree)focus;
      clientArea= tree.getClientArea();
      result= computeMenuLocation(tree);
    } else if (focus instanceof Table) {
      Table table= (Table)focus;
      clientArea= table.getClientArea();
      result= computeMenuLocation(table);
    }
    if (result == null) {
      result= focus.toControl(cursorLocation);
    }
    if (clientArea != null && !clientArea.contains(result)) {
      result= new Point(
        clientArea.x + clientArea.width  / 2,
        clientArea.y + clientArea.height / 2);
    }
    Rectangle shellArea= focus.getShell().getClientArea();
    if (!shellArea.contains(focus.getShell().toControl(focus.toDisplay(result)))) {
      result= new Point(
        shellArea.x + shellArea.width  / 2,
        shellArea.y + shellArea.height / 2);
    }
    return focus.toDisplay(result);
  }
View Full Code Here

   *  <code>null</code> if now position inside the widget can
   *  be computed
   */
  protected Point computeMenuLocation(StyledText text) {
    int offset= text.getCaretOffset();
    Point result= text.getLocationAtOffset(offset);
    result.y+= text.getLineHeight(offset);
    if (!text.getClientArea().contains(result))
      return null;
    return result;
  }
View Full Code Here

        return null;
      case 1:
        Rectangle bounds= items[0].getBounds();
        Rectangle intersect= clientArea.intersection(bounds);
        if (intersect != null && intersect.height == bounds.height) {
          return new Point(
            Math.max(0, bounds.x + getAvarageCharWith(tree) * CHAR_INDENT),
            bounds.y + bounds.height);
        } else {
          return null;
        }
      default:
        Rectangle[] rectangles= new Rectangle[items.length];
        for (int i= 0; i < rectangles.length; i++) {
          rectangles[i]= items[i].getBounds();
        }
        Point cursorLocation= tree.getDisplay().getCursorLocation();
        Point result= findBestLocation(getIncludedPositions(rectangles, clientArea),
          tree.toControl(cursorLocation));
        if (result != null)
          result.x= result.x + getAvarageCharWith(tree) * CHAR_INDENT;
        return result;
    }
View Full Code Here

      } case 1: {
        Rectangle bounds= items[0].getBounds(0);
        Rectangle iBounds= items[0].getImageBounds(0);
        Rectangle intersect= clientArea.intersection(bounds);
        if (intersect != null && intersect.height == bounds.height) {
          return new Point(
            Math.max(0, bounds.x + iBounds.width + getAvarageCharWith(table) * CHAR_INDENT),
            bounds.y + bounds.height);
        } else {
          return null;
        }
      } default: {
        Rectangle[] rectangles= new Rectangle[items.length];
        for (int i= 0; i < rectangles.length; i++) {
          rectangles[i]= items[i].getBounds(0);
        }
        Rectangle iBounds= items[0].getImageBounds(0);
        Point cursorLocation= table.getDisplay().getCursorLocation();
        Point result= findBestLocation(getIncludedPositions(rectangles, clientArea),
          table.toControl(cursorLocation));
        if (result != null)
          result.x= result.x + iBounds.width + getAvarageCharWith(table) * CHAR_INDENT;
        return result;
      }
View Full Code Here

    List result= new ArrayList();
    for (int i= 0; i < rectangles.length; i++) {
      Rectangle rectangle= rectangles[i];
      Rectangle intersect= widgetBounds.intersection(rectangle);
      if (intersect != null && intersect.height == rectangle.height) {
        result.add(new Point(intersect.x, intersect.y + intersect.height));
      }
    }
    return (Point[]) result.toArray(new Point[result.size()]);
  }
View Full Code Here

    }
    return (Point[]) result.toArray(new Point[result.size()]);
  }
 
  private Point findBestLocation(Point[] points, Point relativeCursor) {
    Point result= null;
    double bestDist= Double.MAX_VALUE;
    for (int i= 0; i < points.length; i++) {
      Point point= points[i];
      int a= 0;
      int b= 0;
      if (point.x > relativeCursor.x) {
        a= point.x - relativeCursor.x;
      } else {
View Full Code Here

    MouseMoveListener mMoveListener = new MouseMoveListener() {
      public void mouseMove(MouseEvent e) {
        if (moving) {
          int dX = xPressed - e.x;
          int dY = yPressed - e.y;
          Point currentLoc = minimized.getLocation();
          int x = currentLoc.x - dX;
          int y = currentLoc.y - dY;
          if (x < 10)
            x = 0;
          if (x > screen.width - (bounds.width + 12))
View Full Code Here

     * Since detail panel automatically grows to show the entire list of detail messages
     * we want to at least place a limit on its height just in case the list is too long.
     * A vertical scrollbar will appear so the user can scroll through the rest of the list
     */

    Point computedSize = detailSection.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    detailSectionData.heightHint = computedSize.y;

    if ((STANDALONE & style) != 0) {
      if (computedSize.y > maxPreferredDetailPanelHeight_Standalone) {
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.Point

Copyright © 2018 www.massapicom. 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.