Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Groth2017-12-17 06:02:17 -0500
committerNiraj Modi2018-01-12 02:54:34 -0500
commitb36d03308555185440bae8c1c42b2dc3e90b95a4 (patch)
treea41d97ca3249d942ad608cd943cdf163f3a0e33e
parent4e7818d7bf67e4f52b39fc07b401a9ecc132a7e5 (diff)
downloadeclipse.platform.swt-b36d03308555185440bae8c1c42b2dc3e90b95a4.tar.gz
eclipse.platform.swt-b36d03308555185440bae8c1c42b2dc3e90b95a4.tar.xz
eclipse.platform.swt-b36d03308555185440bae8c1c42b2dc3e90b95a4.zip
Bug 525829 - [Win32] Group text dark in the dark theme on Windows
add custom WM_PAINT method to paint the group text if a custom foreground color was set. There's no windows API for this. Change-Id: I05fb4cef635cbf62afe186137cd9a46fa7f82968 Signed-off-by: Conrad Groth <info@conrad-groth.de>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java39
1 files changed, 38 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index 19fc56e3b8..d75df30f00 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -228,6 +228,9 @@ void enableWidget (boolean enabled) {
TCHAR buffer = new TCHAR (getCodePage (), string, true);
OS.SetWindowText (handle, buffer);
}
+ if (enabled && hasCustomForeground()) {
+ OS.InvalidateRect (handle, null, true);
+ }
}
String fixText (boolean enabled) {
@@ -507,6 +510,40 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
+LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+ LRESULT result = super.WM_PAINT(wParam, lParam);
+
+ if (hasCustomForeground() && text.length () != 0) {
+ String string = fixText (false);
+ TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, false);
+
+ // We cannot use BeginPaint and EndPaint, because that removes the group border
+ long /*int*/ hDC = OS.GetDC(handle);
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ rect.left += 3*CLIENT_INSET;
+
+ long /*int*/ newFont, oldFont = 0;
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+
+ OS.DrawText(hDC, buffer, buffer.length(), rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP | OS.DT_CALCRECT);
+ // The calculated rectangle is a little bit too small. Italic fonts would show some small part in the default color.
+ rect.right += CLIENT_INSET;
+ drawBackground(hDC, rect);
+ OS.SetBkMode(hDC, OS.TRANSPARENT);
+ OS.SetTextColor(hDC, getForegroundPixel());
+ OS.DrawText(hDC, buffer, buffer.length(), rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP);
+
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC(handle, hDC);
+ // Without validating the drawn area it would be overdrawn by windows
+ OS.ValidateRect(handle, rect);
+ }
+ return result;
+}
+
+@Override
LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
if (result != null) return result;

Back to the top