Java Code Examples for org.eclipse.swt.SWT#EraseItem

The following examples show how to use org.eclipse.swt.SWT#EraseItem . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void handleEvent(final Event event) {
    if (event.index == colIndex) {
        if (event.type == SWT.EraseItem) {
            event.detail &= (Integer.MAX_VALUE ^ SWT.FOREGROUND);

        } else if (event.type == SWT.PaintItem) {
            final TableItem item = (TableItem) event.item;
            final Image img = item.getImage(colIndex);
            if (img != null) {
                final Rectangle size = img.getBounds();
                final Table tbl = (Table) event.widget;
                event.gc.drawImage(img, event.x + (tbl.getColumn(colIndex).getWidth() - size.width) / 2, event.y + (tbl.getItemHeight() - size.height) / 2);
            }
        }
    }
}
 
Example 2
@Override
public void handleEvent(Event event) {
    if (event.index == colIndex) {
        if (event.type == SWT.EraseItem) {
            event.detail &= (Integer.MAX_VALUE ^ SWT.FOREGROUND);

        } else if (event.type == SWT.PaintItem) {
            final TableItem item = (TableItem) event.item;
            final Image img = item.getImage(colIndex);
            if (img != null) {
                final Rectangle size = img.getBounds();
                final Table tbl = (Table) event.widget;
                event.gc.drawImage(img, event.x + (tbl.getColumn(colIndex).getWidth() - size.width) / 2,
                        event.y + (tbl.getItemHeight() - size.height) / 2);
            }
        }
    }
}
 
Example 3
public void handleEvent(Event event) {
	if (event.index == colIndex) {
		if (event.type == SWT.EraseItem) {
			event.detail &= (Integer.MAX_VALUE ^ SWT.FOREGROUND);
			
		} else if (event.type == SWT.PaintItem) {
			TableItem item = (TableItem) event.item;
			Image img = item.getImage(colIndex);
			if (img != null) {
				Rectangle size = img.getBounds();
				Table tbl = (Table) event.widget;
				event.gc.drawImage(img, event.x
						+ (tbl.getColumn(colIndex).getWidth() - size.width)
						/ 2, event.y + (tbl.getItemHeight() - size.height)
						/ 2);
			}
		}
	}
}