Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/examples_control.properties6
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java74
2 files changed, 76 insertions, 4 deletions
diff --git a/examples/org.eclipse.swt.examples/src/examples_control.properties b/examples/org.eclipse.swt.examples/src/examples_control.properties
index cba28732eb..ea82da6e03 100644
--- a/examples/org.eclipse.swt.examples/src/examples_control.properties
+++ b/examples/org.eclipse.swt.examples/src/examples_control.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2016 IBM Corporation and others.
+# Copyright (c) 2000, 2017 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
@@ -269,4 +269,6 @@ WebKitNotFound = Cannot use SWT.WEBKIT style: {0}\nSee http://www.eclipse.org/
ColorTitle_0 = Name
ColorTitle_1 = Type
ColorTitle_2 = RGB
-ColorTitle_3 = Color \ No newline at end of file
+ColorTitle_3 = Color
+Header_Foreground_Color = Header Foreground Color
+Header_Background_Color = Header Background Color \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
index 2801d3dc70..e962a13db5 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -55,7 +55,9 @@ class TableTab extends ScrollableTab {
static final int CELL_FOREGROUND_COLOR = 6;
static final int CELL_BACKGROUND_COLOR = 7;
static final int CELL_FONT = 8;
- Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor;
+ static final int HEADER_FOREGROUND_COLOR = 9;
+ static final int HEADER_BACKGROUND_COLOR = 10;
+ Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor, headerForegroundColor, headerBackgroundColor;
Font itemFont, cellFont;
static String [] columnTitles = {ControlExample.getResourceString("TableTitle_0"),
@@ -105,6 +107,10 @@ class TableTab extends ScrollableTab {
item.setText(ControlExample.getResourceString ("Cell_Background_Color"));
item = new TableItem(colorAndFontTable, SWT.None);
item.setText(ControlExample.getResourceString ("Cell_Font"));
+ item = new TableItem(colorAndFontTable, SWT.None);
+ item.setText(ControlExample.getResourceString ("Header_Foreground_Color"));
+ item = new TableItem(colorAndFontTable, SWT.None);
+ item.setText(ControlExample.getResourceString ("Header_Background_Color"));
shell.addDisposeListener(event -> {
if (itemBackgroundColor != null) itemBackgroundColor.dispose();
@@ -113,12 +119,16 @@ class TableTab extends ScrollableTab {
if (cellBackgroundColor != null) cellBackgroundColor.dispose();
if (cellForegroundColor != null) cellForegroundColor.dispose();
if (cellFont != null) cellFont.dispose();
+ if (headerBackgroundColor != null) headerBackgroundColor.dispose();
+ if (headerForegroundColor != null) headerForegroundColor.dispose();
itemBackgroundColor = null;
itemForegroundColor = null;
itemFont = null;
cellBackgroundColor = null;
cellForegroundColor = null;
cellFont = null;
+ headerForegroundColor = null;
+ headerBackgroundColor = null;
});
}
@@ -199,6 +209,30 @@ class TableTab extends ScrollableTab {
if (oldFont != null) oldFont.dispose ();
}
break;
+ case HEADER_FOREGROUND_COLOR: {
+ Color oldColor = headerForegroundColor;
+ if (oldColor == null) oldColor = table1.getHeaderForeground();
+ colorDialog.setRGB(oldColor.getRGB());
+ RGB rgb = colorDialog.open();
+ if (rgb == null) return;
+ oldColor = headerForegroundColor;
+ headerForegroundColor = new Color (display, rgb);
+ setHeaderForeground ();
+ if (oldColor != null) oldColor.dispose ();
+ }
+ break;
+ case HEADER_BACKGROUND_COLOR: {
+ Color oldColor = headerBackgroundColor;
+ if (oldColor == null) oldColor = table1.getHeaderBackground();
+ colorDialog.setRGB(oldColor.getRGB());
+ RGB rgb = colorDialog.open();
+ if (rgb == null) return;
+ oldColor = headerBackgroundColor;
+ headerBackgroundColor = new Color (display, rgb);
+ setHeaderBackground ();
+ if (oldColor != null) oldColor.dispose ();
+ }
+ break;
default:
super.changeFontOrColor(index);
}
@@ -501,6 +535,14 @@ class TableTab extends ScrollableTab {
cellFont = null;
setCellFont ();
if (oldFont != null) oldFont.dispose();
+ oldColor = headerBackgroundColor;
+ headerBackgroundColor = null;
+ setHeaderBackground ();
+ if (oldColor != null) oldColor.dispose();
+ oldColor = headerForegroundColor;
+ headerForegroundColor = null;
+ setHeaderForeground ();
+ if (oldColor != null) oldColor.dispose();
}
/**
@@ -603,6 +645,32 @@ class TableTab extends ScrollableTab {
colorAndFontTable.layout ();
}
+ void setHeaderBackground () {
+ if (!instance.startup) {
+ table1.setHeaderBackground (headerBackgroundColor);
+ }
+ /* Set the header background color item's image to match the header background color. */
+ Color color = headerBackgroundColor;
+ if (color == null) color = table1.getHeaderBackground();
+ TableItem item = colorAndFontTable.getItem(HEADER_BACKGROUND_COLOR);
+ Image oldImage = item.getImage();
+ if (oldImage != null) oldImage.dispose();
+ item.setImage (colorImage(color));
+ }
+
+ void setHeaderForeground () {
+ if (!instance.startup) {
+ table1.setHeaderForeground (headerForegroundColor);
+ }
+ /* Set the header foreground color item's image to match the header foreground color. */
+ Color color = headerForegroundColor;
+ if (color == null) color = table1.getHeaderForeground();
+ TableItem item = colorAndFontTable.getItem(HEADER_FOREGROUND_COLOR);
+ Image oldImage = item.getImage();
+ if (oldImage != null) oldImage.dispose();
+ item.setImage (colorImage(color));
+ }
+
/**
* Sets the moveable columns state of the "Example" widgets.
*/
@@ -636,6 +704,8 @@ class TableTab extends ScrollableTab {
setCellBackground ();
setCellForeground ();
setCellFont ();
+ setHeaderBackground ();
+ setHeaderForeground ();
if (!instance.startup) {
setColumnsMoveable ();
setColumnsResizable ();

Back to the top