Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2015-04-09 11:32:39 +0000
committerNiraj Modi2015-04-09 11:32:39 +0000
commitf462669e970460bddf7baab0e5475c20d3df4fdc (patch)
treed713e845858a58b183fe134ea672c29d7ac40b69
parent20f0171850697bbd54191846f4b1523289117444 (diff)
downloadeclipse.platform.swt-f462669e970460bddf7baab0e5475c20d3df4fdc.tar.gz
eclipse.platform.swt-f462669e970460bddf7baab0e5475c20d3df4fdc.tar.xz
eclipse.platform.swt-f462669e970460bddf7baab0e5475c20d3df4fdc.zip
Bug 463127 - [Win32] Transparent background not honored on Composite
with Scrollbars on Windows Change-Id: I015a9271c1b4756c0c151dd1529053ae08cdd701 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java5
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java33
7 files changed, 52 insertions, 29 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index babd1bc2d4..a50b8f650b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -3273,11 +3273,13 @@ public class SWT {
* Current limitations include:
* <ul><li>
* {@link org.eclipse.swt.widgets.Text Text} and {@link org.eclipse.swt.widgets.Combo Combo}
- * don't support transparent background and fall back to the default background.
+ * support transparent background on Windows only and on other platforms fall back to the default background.
* </li>
* <li>
- * {@link org.eclipse.swt.widgets.Table Table} and {@link org.eclipse.swt.widgets.Tree Tree}
- * support a transparent background on GTK3, but not on other platforms.
+ * {@link org.eclipse.swt.widgets.Table Table} supports transparent background on GTK3 only.
+ * </li>
+ * <li>
+ * {@link org.eclipse.swt.widgets.Tree Tree} supports transparent background on GTK3/Windows, but not on other platforms.
* </li>
* </ul>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index b74f39318c..cf479ba12c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -305,7 +305,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
void createHandle () {
super.createHandle ();
state |= CANVAS;
- if (applyThemeBackground ()) {
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0 || findThemeControl () == parent) {
state |= THEME_BACKGROUND;
}
if ((style & SWT.TRANSPARENT) != 0) {
@@ -316,7 +316,7 @@ void createHandle () {
}
@Override
-boolean applyThemeBackground () {
+int applyThemeBackground () {
/*
* Composite with scrollbars would not inherit the theme because it was
* probably being used to implement a control similar to a Text, List,
@@ -329,7 +329,7 @@ boolean applyThemeBackground () {
* enable the THEME_BACKGROUND in 'state' to support background transparent.
* Refer bug 463127 & related bug 234649.
*/
- return (super.applyThemeBackground() || (style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0 || findThemeControl () == parent);
+ return (backgroundAlpha == 0 || (style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0 || findThemeControl () == parent) ? 1 : 0;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
index 57edfda1f5..7e193cff33 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -144,19 +144,22 @@ void createWidget () {
@Override
void updateBackgroundColor () {
- if (applyThemeBackground ()) {
- state |= THEME_BACKGROUND;
- } else {
- state &= ~THEME_BACKGROUND;
+ switch (applyThemeBackground ()) {
+ case 0: state &= ~THEME_BACKGROUND; break;
+ case 1: state |= THEME_BACKGROUND; break;
+ default: /* No change */
}
super.updateBackgroundColor ();
}
/**
-* @return true if THEME_BACKGROUND needs to be applied.
-*/
-boolean applyThemeBackground () {
- return backgroundAlpha == 0;
+ * @return
+ * <li>0 to remove THEME_BACKGROUND</li>
+ * <li>1 to apply THEME_BACKGROUND</li>
+ * <li>otherwise don't change THEME_BACKGROUND state</li>
+ */
+int applyThemeBackground () {
+ return (backgroundAlpha == 0) ? 1 : 0;
}
void destroyScrollBar (int type) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index f30a6dcb86..f32b253f87 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -1629,12 +1629,12 @@ void createHandle () {
}
@Override
-boolean applyThemeBackground () {
+int applyThemeBackground () {
/*
* Just inheriting the THEME_BACKGROUND doesn't turn complete Table
* background transparent, TableItem background remains as-is.
*/
- return false;
+ return -1; /* No Change */
}
void createHeaderToolTips () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index aa13243d0b..a788ce5caf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -275,15 +275,15 @@ void createHandle () {
super.createHandle ();
OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0);
if ((style & SWT.READ_ONLY) != 0) {
- if (applyThemeBackground ()) {
+ if (applyThemeBackground () == 1) {
state |= THEME_BACKGROUND;
}
}
}
@Override
-boolean applyThemeBackground () {
- return (super.applyThemeBackground() || (style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) == 0);
+int applyThemeBackground () {
+ return (backgroundAlpha == 0 || (style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) == 0) ? 1 : 0;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index 1abd14583c..9b1ea0db98 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -402,6 +402,11 @@ void createWidget () {
lastFocusId = lastArrowId = lastHotId = -1;
}
+@Override
+int applyThemeBackground () {
+ return -1; /* No Change */
+}
+
int defaultBackground () {
if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_BTNFACE);
return super.defaultBackground ();
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java
index 1b96765b01..b9be917c52 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java
@@ -37,7 +37,8 @@ public class Snippet365 {
// Native
static Group nativeGroup;
static Button buttonCheckBox;
- static ToolBar bar;
+ static ToolBar toolBar;
+ static CoolBar coolBar;
static Label label;
static Link link;
static Scale scale;
@@ -121,7 +122,8 @@ public class Snippet365 {
// Native
nativeGroup.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
- bar.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
+ toolBar.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
+ coolBar.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
label.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
link.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
scale.setBackground(display.getSystemColor(SWT.COLOR_TRANSPARENT));
@@ -159,7 +161,8 @@ public class Snippet365 {
} else {
// Native
nativeGroup.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- bar.setBackground(null);
+ toolBar.setBackground(null);
+ coolBar.setBackground(null);
label.setBackground(null);
link.setBackground(null);
scale.setBackground(null);
@@ -276,11 +279,21 @@ public class Snippet365 {
push.setText("Push Button");
// Toolbar
- bar = new ToolBar(nativeGroup, SWT.FLAT);
- bar.pack();
- ToolItem item = new ToolItem(bar, SWT.PUSH);
+ toolBar = new ToolBar(nativeGroup, SWT.FLAT);
+ toolBar.pack();
+ ToolItem item = new ToolItem(toolBar, SWT.PUSH);
item.setText("ToolBar_Item");
+ // Coolbar
+ coolBar = new CoolBar(nativeGroup, SWT.BORDER);
+ for (int i=0; i<2; i++) {
+ CoolItem item2 = new CoolItem (coolBar, SWT.NONE);
+ Button button = new Button (coolBar, SWT.PUSH);
+ button.setText ("Button " + i);
+ Point size = button.computeSize (SWT.DEFAULT, SWT.DEFAULT);
+ item2.setPreferredSize (item2.computeSize (size.x, size.y));
+ item2.setControl (button);
+ }
// Scale
scale = new Scale(nativeGroup, SWT.None);
scale.setMaximum(100);
@@ -293,10 +306,10 @@ public class Snippet365 {
// List
list = new List(nativeGroup, SWT.BORDER);
list.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
- list.add("one");
- list.add("two");
- list.add("three");
- list.add("four");
+ list.add("List_one");
+ list.add("List_two");
+ list.add("List_three");
+ list.add("List_four");
// Canvas
canvas = new Canvas (containerGroup, SWT.NONE);

Back to the top