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

The following examples show how to use org.eclipse.swt.SWT#EraseItem . 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
Source File: CenteredContentCellPaint.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
@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
Source File: CenteredContentCellPaint.java    From erflute with Apache License 2.0 6 votes vote down vote up
@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
Source File: CenteredContentCellPaint.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
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);
			}
		}
	}
}