@Override public void handleEvent(Event event) { Rectangle clientArea = table.getClientArea(); Point pt = new Point(event.x, event.y); int index = table.getTopIndex(); int count = table.getItemCount(); while (index < count) { boolean visible = false; TableItem item = table.getItem(index); for (int i = 0; i < table.getColumnCount(); i++) { Rectangle rect = item.getBounds(i); if (rect.contains(pt)) { beforeEdit(); clickRow(item, i); return; } if (!visible && rect.intersects(clientArea)) { visible = true; } } if (!visible) return; index++; } } protected void beforeEdit() {
final TableItem item = table.getItem( index ); for ( int i = 0; i < table.getColumnCount(); i++ ) { Rectangle rect = item.getBounds( i ); if ( rect.contains( pt ) ) { activeTableItem = item;
@Override public Rectangle getBounds() { return item.getBounds(); }
private int getSelectedColumn(TableItem tableItem, int x, int y) { for (int i = 0; i < columns_.length; i++) { if (tableItem.getBounds(i).contains(x, y)) return i; } return -1; }
private int getSelectedColumn(TableItem tableItem, int x, int y) { for (int i = 0; i < columns_.length; i++) { if (tableItem.getBounds(i).contains(x, y)) return i; } return -1; }
private int getSelectedRow(Table table, int y) { TableItem[] tableItems = table.getItems(); for (int i = 0; i < tableItems.length; i++) { Rectangle rectangle = tableItems[i].getBounds(0); if (rectangle != null && y >= rectangle.y && y < (rectangle.y + rectangle.height)) return i; } return -1; }
private int getSelectedRow(Table table, int y) { TableItem[] tableItems = table.getItems(); for (int i = 0; i < tableItems.length; i++) { Rectangle rectangle = tableItems[i].getBounds(0); if (rectangle != null && y >= rectangle.y && y < (rectangle.y + rectangle.height)) return i; } return -1; }
/** * @param event * Event * @return Returns the {@link Rectangle} describing the bounds of a cell for an event. */ private Rectangle getViewerCellBounds(Event event) { if (event.item instanceof TableItem) { return ((TableItem) event.item).getBounds(event.index); } else if (event.item instanceof TreeItem) { return ((TreeItem) event.item).getBounds(event.index); } throw new RuntimeException("ImageFixStyledCellIndexLabelProvider can only run with tree or table"); }
/** * Returns the bounds of the given item, or <code>null</code> if it is not a * valid type of item. */ private Rectangle getBounds(Item item) { if (item instanceof TreeItem) return ((TreeItem) item).getBounds(); if (item instanceof TableItem) return ((TableItem) item).getBounds(0); return null; }
/** Marks the given row as requiring redraw. */ public void redrawRow(int row) { if (row < itemCount) { boolean redrawChildren = true; Rectangle itemBounds = table.getItem(row).getBounds(); table.redraw(0, itemBounds.y, width, rowHeight, redrawChildren); } }
Rectangle getTextBoundsInPixels (int index) { if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); int itemIndex = parent.indexOf (this); if (itemIndex == -1) return new Rectangle (0, 0, 0, 0); RECT rect = getBounds (itemIndex, index, true, false, true); rect.left += 2; if (index != 0) rect.left += Table.INSET; rect.left = Math.min (rect.left, rect.right); rect.right = rect.right - Table.INSET; int width = Math.max (0, rect.right - rect.left); int height = Math.max (0, rect.bottom - rect.top); return new Rectangle (rect.left, rect.top, width, height); }
void _resize() { if (row == null) { setBounds(-200, -200, 0, 0); } else { int columnIndex = column == null ? 0 : table.indexOf(column); setBounds(row.getBounds(columnIndex)); } } /**
void _resize() { if (row == null) { setBounds(-200, -200, 0, 0); } else { int columnIndex = column == null ? 0 : table.indexOf(column); setBounds(row.getBounds(columnIndex)); } } /**
void _resize() { if (row == null) { setBounds(-200, -200, 0, 0); } else { int columnIndex = column == null ? 0 : table.indexOf(column); setBounds(row.getBounds(columnIndex)); } } /**
void _resize() { if (row == null) { setBounds(-200, -200, 0, 0); } else { int columnIndex = column == null ? 0 : table.indexOf(column); setBounds(row.getBounds(columnIndex)); } } /**
protected Item getItemAt(Point p) { TableItem[] selection = table.getSelection(); if( selection.length == 1 ) { int columnCount = table.getColumnCount(); for( int i = 0; i < columnCount; i++ ) { if( selection[0].getBounds(i).contains(p) ) { return selection[0]; } } } return table.getItem(p); }
void redraw (int column, boolean drawText, boolean drawImage) { if (parent.currentItem == this || !parent.getDrawing ()) return; int /*long*/ hwnd = parent.handle; if (!OS.IsWindowVisible (hwnd)) return; int index = parent.indexOf (this); if (index == -1) return; RECT rect = getBounds (index, column, drawText, drawImage, true); OS.InvalidateRect (hwnd, rect, true); }
@Override protected Item getItemAt(Point p) { TableItem[] selection = table.getSelection(); if (selection.length == 1) { int columnCount = table.getColumnCount(); for (int i = 0; i < columnCount; i++) { if (selection[0].getBounds(i).contains(p)) { return selection[0]; } } } return table.getItem(p); }
Rectangle getBoundsInPixels () { if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); int itemIndex = parent.indexOf (this); if (itemIndex == -1) return new Rectangle (0, 0, 0, 0); RECT rect = getBounds (itemIndex, 0, true, false, false); int width = rect.right - rect.left, height = rect.bottom - rect.top; return new Rectangle (rect.left, rect.top, width, height); }
Rectangle getBoundsInPixels (int index) { if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); int itemIndex = parent.indexOf (this); if (itemIndex == -1) return new Rectangle (0, 0, 0, 0); RECT rect = getBounds (itemIndex, index, true, true, true); int width = rect.right - rect.left, height = rect.bottom - rect.top; return new Rectangle (rect.left, rect.top, width, height); }