I am creating an SWT application with two TreeViewers
and a TableViewer
in between them.
The TableViewer
contains images in each row that indicate something about the date in that row of the TreeViewer
.
However the problem is that the images in the TableViewer
are not properly aligning with the rows in the TreeViewer
. Is there any way for me to ensure that their rows stay exactly leveld?
Thanks
ADDED
You can change the way the height of a row is measured by overriding the behaviour of the "measuring method", i.e. adding a Listener
to SWT.MeasureItem
. There is a good example here. Just use the height of the icon you use in the TreeViewer
plus maybe a couple of border pixels.
Here is the important code part:
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,250);
final Table table = new Table(shell, SWT.NONE);
table.setBounds(10,10,150,200);
table.setLinesVisible(true);
for (int i = 0; i < 5; i++) {
new TableItem(table, SWT.NONE).setText("item " + i);
}
table.addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
int clientWidth = table.getClientArea().width;
event.height = event.gc.getFontMetrics().getHeight() * 2;
event.width = clientWidth * 2;
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();