 
/*******************************************************************************
 * Copyright (c) 2000, 2004 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
 *******************************************************************************/
/*
 * Table example snippet: color cells and rows in table
 *
 * @since 3.0
 */
module Snippet129;
import dwt.DWT;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import dwt.widgets.Table;
import dwt.widgets.TableItem;
import dwt.widgets.TableColumn;
import dwt.graphics.Color;
import dwt.layout.FillLayout;

//Note American spelling "Color", English " Colour"

 
void main(char[][] args) {
	Display display = new Display();
	
        Color red = display.getSystemColor(DWT.COLOR_RED);
	Color blue = display.getSystemColor(DWT.COLOR_BLUE);
	Color white = display.getSystemColor(DWT.COLOR_WHITE);
	Color gray = display.getSystemColor(DWT.COLOR_GRAY);
	Shell shell = new Shell(display);
	shell.setText("Colored Lines Display");
        shell.setLayout(new FillLayout());
	Table table = new Table(shell, DWT.BORDER | DWT.FULL_SELECTION);
	table.setBackground(gray);
	table.setLinesVisible (true);
        table.setHeaderVisible (true);
        TableColumn column1 = new TableColumn(table, DWT.NONE);
	column1.setText("Column 1");
        TableColumn column2 = new TableColumn(table, DWT.NONE);
	column2.setText("Column 2");
        TableColumn column3 = new TableColumn(table, DWT.NONE);
        column3.setText("Column 3");
	TableItem item = new TableItem(table, DWT.NONE);
        item.setText(0,"entire");
        item.setText(1,"row");
        item.setText(2,"redforeground");
	item.setForeground(red);

	item = new TableItem(table, DWT.NONE);
        item.setText(0,"entire");
        item.setText(1,"row");
        item.setText(2,"redbackground");
	item.setBackground(red);

	item = new TableItem(table, DWT.NONE);
        item.setText(0,"entire");
        item.setText(1,"row");
        item.setText(2,"whitefore/redback");
	item.setForeground(white);
	item.setBackground(red);

	item = new TableItem(table, DWT.NONE);
        item.setText(0,"normal");
        item.setText(1,"blueforeground");
        item.setText(2,"redforeground");
	item.setForeground(1, blue);
	item.setForeground(2, red);

	item = new TableItem(table, DWT.NONE);
        item.setText(0,"normal");
        item.setText(1,"bluebackground");
        item.setText(2,"redbackground");
	item.setBackground(1, blue);
	item.setBackground(2, red);

	item = new TableItem(table, DWT.NONE);
        item.setText(0,"white/blue");
        item.setText(1,"normal");
        item.setText(2,"white/red");
	item.setForeground(0, white);
	item.setBackground(0, blue);
	item.setForeground(2, white);
	item.setBackground(2, red);
	
	column1.pack();
	column2.pack();
	column3.pack();
	
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}

