Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2015-04-08 08:28:13 +0000
committerNiraj Modi2015-04-08 08:28:13 +0000
commit476b88e18102db1fbb9ef3a7784dd7270d0ecf3b (patch)
tree68766e95bb2ef1ad462b8e47e968b8e73389e934
parentc1df6c3c3b82aac3a25df9fa149d33844b5e7c77 (diff)
downloadeclipse.platform.swt-476b88e18102db1fbb9ef3a7784dd7270d0ecf3b.tar.gz
eclipse.platform.swt-476b88e18102db1fbb9ef3a7784dd7270d0ecf3b.tar.xz
eclipse.platform.swt-476b88e18102db1fbb9ef3a7784dd7270d0ecf3b.zip
Bug 463127 - [Win32] Transparent background not honored on Composite
with Scrollbars on Windows Change-Id: I3e0df1bf9468583f933fe94e21b3decf7ec53d84 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java7
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java7
5 files changed, 54 insertions, 5 deletions
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 8c92131e4d..b74f39318c 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 ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0 || findThemeControl () == parent) {
+ if (applyThemeBackground ()) {
state |= THEME_BACKGROUND;
}
if ((style & SWT.TRANSPARENT) != 0) {
@@ -315,6 +315,23 @@ void createHandle () {
}
}
+@Override
+boolean applyThemeBackground () {
+ /*
+ * Composite with scrollbars would not inherit the theme because it was
+ * probably being used to implement a control similar to a Text, List,
+ * Table, or Tree, and those controls do not inherit the background theme.
+ * We assume that a Composite that did not have scrollbars was probably just
+ * being used to group some other controls, therefore it should inherit.
+ *
+ * But when Composite background is set to COLOR_TRANSPARENT (i.e.
+ * backgroundAlpha as '0') which means parent theme should be inherited, so
+ * 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);
+}
+
/**
* Fills the interior of the rectangle specified by the arguments,
* with the receiver's background.
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 8adb7f7792..57edfda1f5 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
@@ -142,6 +142,23 @@ void createWidget () {
if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
}
+@Override
+void updateBackgroundColor () {
+ if (applyThemeBackground ()) {
+ state |= THEME_BACKGROUND;
+ } else {
+ state &= ~THEME_BACKGROUND;
+ }
+ super.updateBackgroundColor ();
+}
+
+/**
+* @return true if THEME_BACKGROUND needs to be applied.
+*/
+boolean applyThemeBackground () {
+ return backgroundAlpha == 0;
+}
+
void destroyScrollBar (int type) {
long /*int*/ hwnd = scrolledHandle ();
int bits = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
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 b0a87fa38e..f30a6dcb86 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
@@ -1628,6 +1628,15 @@ void createHandle () {
}
}
+@Override
+boolean applyThemeBackground () {
+ /*
+ * Just inheriting the THEME_BACKGROUND doesn't turn complete Table
+ * background transparent, TableItem background remains as-is.
+ */
+ return false;
+}
+
void createHeaderToolTips () {
if (OS.IsWinCE) return;
if (headerToolTipHandle != 0) return;
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 f0e5feaf3f..aa13243d0b 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,12 +275,17 @@ void createHandle () {
super.createHandle ();
OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0);
if ((style & SWT.READ_ONLY) != 0) {
- if ((style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
+ if (applyThemeBackground ()) {
state |= THEME_BACKGROUND;
}
}
}
+@Override
+boolean applyThemeBackground () {
+ return (super.applyThemeBackground() || (style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) == 0);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's text is modified, by sending
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 34e03f364c..1b96765b01 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
@@ -169,7 +169,7 @@ public class Snippet365 {
group.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
sash.setBackground(display.getSystemColor(SWT.COLOR_DARK_CYAN));
slider.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
- list.setBackground(null);
+ list.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
text.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
// ContainerGroup
@@ -197,8 +197,8 @@ public class Snippet365 {
// Default
defaultBackgroundGroup.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
push.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- combo.setBackground(null);
- ccombo.setBackground(null);
+ combo.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
+ ccombo.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
dateTime.setBackground(null);
progressBar.setBackground(null);
expandBar.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
@@ -292,6 +292,7 @@ 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");

Back to the top