/******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.snippets; /* * Table example snippet: Draw left aligned icon, text and selection * * For more info on custom-drawing TableItem and TreeItem content see * http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class Snippet283 { public static void main(String[] args) { Display display = new Display(); Image image = new Image (display, Snippet283.class.getResourceAsStream("eclipse.png")); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Table table = new Table(shell, SWT.FULL_SELECTION); for (int i = 0; i < 8; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText ("Item " + i + " with long text that scrolls."); if (i % 2 == 1) item.setImage (image); } table.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { Rectangle rect = table.getClientArea (); Point point = new Point (event.x, event.y); if (table.getItem(point) != null) return; for (int i=table.getTopIndex (); i