Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Point


  public static boolean drawImage(GC gc, Image image, Point srcStart,
      Rectangle dstRect, Rectangle clipping, int hOffset, int vOffset,
      boolean clearArea)
  {
    Rectangle srcRect;
    Point dstAdj;

    if (clipping == null) {
      dstAdj = new Point(0, 0);
      srcRect = new Rectangle(srcStart.x, srcStart.y, dstRect.width,
          dstRect.height);
    } else {
      if (!dstRect.intersects(clipping)) {
        return false;
      }

      dstAdj = new Point(Math.max(0, clipping.x - dstRect.x), Math.max(0,
          clipping.y - dstRect.y));

      srcRect = new Rectangle(0, 0, 0, 0);
      srcRect.x = srcStart.x + dstAdj.x;
      srcRect.y = srcStart.y + dstAdj.y;
View Full Code Here


    int areaHeight = table.getClientArea().height;
    if (areaHeight <= table.getHeaderHeight())
      return -1;

    // 2 offset to be on the safe side
    TableItem bottomItem = table.getItem(new Point(2,
        table.getClientArea().height - 1));
    int iBottomIndex = (bottomItem != null) ? table.indexOf(bottomItem) :
      itemCount - 1;
    return iBottomIndex;
  }
View Full Code Here

    cBlockView.addMouseListener(new MouseAdapter() {
        public void mouseDown(MouseEvent e) {
          Table table = getTable();
          Rectangle r = cBlockView.getBounds();
          TableItem[] item = { table.getItem(new Point(r.x, r.y)) };
          if (item[0] != null) {
            table.setSelection(item);
          }
          table.setFocus();
        }
View Full Code Here

  }
 
  public Point getSize() {
    Rectangle bounds = getBounds();
    if(bounds == null)
      return new Point(0, 0);
    return new Point(bounds.width - (marginWidth * 2),
                     bounds.height - (marginHeight * 2));
  }
View Full Code Here

        if (index < 0) {
          // Trigger a Table._getItem, which assigns the item to the array
          // in Table, so indexOf(..) can find it.  This is a workaround for
          // a WinXP bug.
          Rectangle r = item.getBounds(0);
          table.getItem(new Point(r.x, r.y));
          index = table.indexOf(item);
          if (index < 0)
            return;
        }
       
      if (index % 2 == 0)
        item.setBackground(ROW_ALTERNATE_COLOR_2);
      else
        item.setBackground(ROW_ALTERNATE_COLOR_1);
       
      TableColumn tableColumn = tableColumns.get(index);
        //String sTitleLanguageKey = tableColumn.getTitleLanguageKey();
        item.setText(0, tableColumn.getText());
        item.setText(1, (String)tableColumn.getData(SWTConstants.COLUMN_DESC_KEY));
       
        //Causes SetData listener to be triggered again, which messes up SWT
          //table.getColumn(1).pack();

        final boolean bChecked = ((Boolean) newEnabledState.get(tableColumn));
        item.setChecked(bChecked);

      }
    });
    table.setItemCount(tableColumns.size());
   
    table.addMouseListener(new MouseAdapter() {
     
      public void mouseDown(MouseEvent arg0) {
        mousePressed = true;
        selectedItem = table.getItem(new Point(arg0.x,arg0.y));
      }
     
      public void mouseUp(MouseEvent e) {
        mousePressed = false;
        //1. Restore old image
        if(oldPoint != null) {
          table.redraw(oldPoint.x, oldPoint.y, shell.getSize().x,
              oldPoint.y + 2, false);
          oldPoint = null;
        }
        Point p = new Point(e.x,e.y);
        TableItem item = table.getItem(p);
        if(item != null && selectedItem != null) {
          int index = table.indexOf(item);
          int oldIndex = table.indexOf(selectedItem);
          if(index == oldIndex)
            return;

          TableColumn tableColumn =
                           (TableColumn)tableColumns.get(oldIndex);
         
          tableColumns.remove(tableColumn);
          tableColumns.add(index, tableColumn);
          table.clearAll();
        }
      }
    });
   
    table.addMouseMoveListener(new MouseMoveListener(){
      public void mouseMove(MouseEvent e) {
        if (!mousePressed || selectedItem == null)
          return;

        Point p = new Point(e.x,e.y);
        TableItem item = table.getItem(p);
        if (item == null)
          return;

        Rectangle bounds = item.getBounds(0);
        int selectedPosition = table.indexOf(selectedItem);
        int newPosition = table.indexOf(item);

        //1. Restore old area
        if(oldPoint != null) {
          table.redraw(oldPoint.x, oldPoint.y, bounds.width, oldPoint.y + 2, false);
          oldPoint = null;
        }           
        bounds.y += VerticalAligner.getTableAdjustVerticalBy(table);
        if(newPosition <= selectedPosition)
          oldPoint = new Point(bounds.x,bounds.y);
        else
          oldPoint = new Point(bounds.x,bounds.y+bounds.height);

        //3. Draw a thick line
        table.redraw(oldPoint.x, oldPoint.y, bounds.width, oldPoint.y + 2, false);
      }
    });
   
    table.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent e) {
        if (!mousePressed || selectedItem == null || oldPoint == null) {
          return;
        }
       
        Point p = new Point(e.x,e.y);
        TableItem item = table.getItem(p);
        if (item == null)
          return;
   
        Rectangle bounds = item.getBounds(0);
        GC gc = new GC(table);
        gc.setBackground(blue);
        gc.fillRectangle(oldPoint.x,oldPoint.y,bounds.width,2);
        gc.dispose();
      }
    });

    shell.pack();
    Point p = shell.getSize();
    p.x = 550;
    // For Windows, to get rid of the scrollbar
    p.y += 2;
   
    if (p.y + 64 > display.getClientArea().height)
View Full Code Here

    ((GridData) fFolderViewerContainer.getLayoutData()).exclude = !excluded;
    fFolderViewerContainer.getShell().layout();

    fAddFolderBar.setVisible(excluded);

    Point size = fFolderViewerContainer.getShell().getSize();
    fFolderViewerContainer.getShell().setSize(size.x, size.y + (excluded ? fViewerHeight : -fViewerHeight));

    if (excluded)
      fFolderViewer.getTree().setFocus();
    else
View Full Code Here

    }
  }

  private void onMouseDown(Event event) {
    boolean disableTrackerTemporary = false;
    Point p = new Point(event.x, event.y);
    TreeItem item = fCustomTree.getControl().getItem(p);

    /* Problem - return */
    if (item == null || item.isDisposed())
      return;
View Full Code Here

    if (disableTrackerTemporary)
      JobRunner.runDelayedFlagInversion(200, fBlockNewsStateTracker);
  }

  private void onMouseMove(Event event) {
    Point p = new Point(event.x, event.y);
    TreeItem item = fCustomTree.getControl().getItem(p);

    /* Problem / Group hovered - reset */
    if (item == null || item.isDisposed() || item.getData() instanceof EntityGroup) {
      if (fShowsHandCursor && !fCustomTree.getControl().isDisposed()) {
View Full Code Here

     * ISSUE: May have to create a interface with method: setSelection(Point p)
     * so that user's custom widgets can use this class. If we keep this option.
     */
    if (w instanceof Tree) {
      Tree tree = (Tree) w;
      TreeItem item = tree.getItem(new Point(e.x, e.y));
      if (item != null)
        tree.setSelection(new TreeItem[] { item });

      selEvent.item = item;
    } else if (w instanceof Table) {
      Table table = (Table) w;
      TableItem item = table.getItem(new Point(e.x, e.y));
      if (item != null)
        table.setSelection(new TableItem[] { item });

      selEvent.item = item;
    } else
View Full Code Here

     * @see org.eclipse.jface.dialogs.Dialog#getInitialLocation(org.eclipse.swt.graphics.Point)
     */
    @Override
    protected Point getInitialLocation(Point initialSize) {
      Rectangle displayBounds = getParentShell().getDisplay().getPrimaryMonitor().getBounds();
      Point shellSize = getInitialSize();
      int x = displayBounds.x + (displayBounds.width - shellSize.x) >> 1;
      int y = displayBounds.y + (displayBounds.height - shellSize.y) >> 1;

      return new Point(x, y);
    }
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.