Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Rectangle


  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)) {
          _doubleClick = true;
          _viewer.editElement(item.getData(), column);
          _doubleClick = false;
          return;
        }
View Full Code Here


    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(Tree tree) {
    TreeItem[] items= tree.getSelection();
    Rectangle clientArea= tree.getClientArea();
    switch (items.length) {
      case 0:
        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 {
View Full Code Here

   *  <code>null</code> if now position inside the widget can
   *  be computed
   */
  protected Point computeMenuLocation(Table table) {
    TableItem[] items= table.getSelection();
    Rectangle clientArea= table.getClientArea();
    switch (items.length) {
      case 0: {
        return null;
      } 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;
 
View Full Code Here

  }
 
  private Point[] getIncludedPositions(Rectangle[] rectangles, Rectangle widgetBounds) {
    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

    this.display = mainShell.getDisplay();
    minimized = ShellFactory.createShell(mainShell, SWT.ON_TOP);
    minimized.setText("Vuze"); //$NON-NLS-1$
    label = new Label(minimized, SWT.NULL);
    ImageLoader.getInstance().setLabelImage(label, "tray");
    final Rectangle bounds = label.getImage().getBounds();
    label.setSize(bounds.width, bounds.height);
    minimized.setSize(bounds.width + 2, bounds.height + 2);
    screen = display.getClientArea();
//NICO handle macosx and multiple monitors
    if (!Constants.isOSX) {
View Full Code Here

    boolean bImageBufferValid = imageBuffer != null && imageBuffer.length == drawWidth;

    Image image = (Image)infoObj.getData("PiecesImage");
    GC gcImage;
    boolean bImageChanged;
    Rectangle imageBounds;
    if (image == null || image.isDisposed()) {
      bImageChanged = true;
    } else {
      imageBounds = image.getBounds();
      bImageChanged = imageBounds.width != newWidth ||
View Full Code Here

      /*
       * Set default size and centers the shell if it's configuration does not exist yet
       */
      if (null == COConfigurationManager.getStringParameter(
          "options.rectangle", null)) {
        Rectangle shellBounds = shell.getMonitor().getBounds();
        Point size = new Point(shellBounds.width * 10 / 11,
            shellBounds.height * 10 / 11);
        if (size.x > 1400) {
          size.x = 1400;
        }
View Full Code Here

  public TestWindow(Display display) {
    super(display);   
   
    layout();
   
    Rectangle bounds = display.getClientArea();   
    x0 = bounds.x + bounds.width - 250;
    x1 = bounds.x + bounds.width;

    y0 = bounds.y + bounds.height;
    y1 = bounds.y + bounds.height - 150;
View Full Code Here

    //not be any smaller than 50 pixels.
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;

    Rectangle r = text.computeTrim(0, 0, 100, text.getLineHeight());
    editor.minimumHeight = r.height;


    // Open the text editor on the selected row.
    editor.setEditor (text, item);
View Full Code Here

TOP

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

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.