Strange alignment and layout in tableviewer with image
Asked Answered
A

1

6

I use a TableViewer with two columns. The first should contain text and the second an image depending on the state of the object. The label provider is a custom provider which extends LabelProvider and implements ITableLayoutProvider.

When no image is displayed, the layout is correct and the text in the first column is aligned to the left. correct

But when at least one image is displayed the text in the first column is aligned somewhere between right and center - looks kind of ugly.

incorrect

The layout is quite simple:

availableDevicesList = new TableViewer(this, SWT.SINGLE | SWT.BORDER
| SWT.FULL_SELECTION);
availableDevicesList.setContentProvider(new ArrayContentProvider());

Table table = availableDevicesList.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);

table.setLinesVisible(true);

tableLayout.addColumnData(new ColumnWeightData(3));
new TableColumn(table, SWT.LEFT);
tableLayout.addColumnData(new ColumnWeightData(1));
new TableColumn(table, SWT.RIGHT);

What causes this problem?

Ardelia answered 16/6, 2011 at 12:1 Comment(0)
A
2

It's a bug in Windows API see SWT bug report. It affects only first column in table, so official workaround is to "skip" first column and set it to zero size (see last comment on bug report), but on Mac OS X table column cannot have zero size, so there will be visible first column with size 1 or something like this..

Yeah, hate this bug in Win API too..

Assets answered 17/6, 2011 at 7:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.