« Return to Thread: OwnerDraw in SWT

OwnerDraw in SWT

by philk :: Rate this Message:

Reply to Author | View in Thread

I wonder why it is so difficult and also time consuming to find the right item to paint

This is my code and the several lookups to the filteredList and indexOf slow the custom painting down.

public void handleEvent(final Event event) {
                        final IColumn<E> column = getColumn(event.index);
                        final TableItemPainter painter = getPainter(column);
                        if (painter != null) {

                                final TableItem item = (TableItem) event.item;
                                final int indexOf = item.getParent().indexOf(item);
                                final E baseObject = FilteredViewer.this.filteredList.getFilteredList().get(indexOf);
                                final Object cellValue = column.getValue(baseObject);

                                switch (event.type) {
                                case SWT.MeasureItem:
                                        painter.measureTableItem(event, cellValue);
                                        break;
                                case SWT.EraseItem:
                                        painter.eraseTableItem(event, cellValue);
                                        break;
                                case SWT.PaintItem:
                                        painter.paintTableItem(event, cellValue);
                                        break;
                                }

                        }
                }

Any ideas how to improve that?

Thanks,
Phil

 « Return to Thread: OwnerDraw in SWT