Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2018-04-17 08:59:21 -0400
committerNiraj Modi2018-05-03 04:18:06 -0400
commit0fcc40f73f7b6cf079f4211b7bab6c91c2bc977e (patch)
treeb0812403deff7513877f87cabd630a08779fe925 /bundles/org.eclipse.swt/Eclipse SWT/win32
parent9ee8b1444497d29c83291d4df9544a3f4d627fd3 (diff)
downloadeclipse.platform.swt-0fcc40f73f7b6cf079f4211b7bab6c91c2bc977e.tar.gz
eclipse.platform.swt-0fcc40f73f7b6cf079f4211b7bab6c91c2bc977e.tar.xz
eclipse.platform.swt-0fcc40f73f7b6cf079f4211b7bab6c91c2bc977e.zip
Bug 184951 - [Win32] Tree/Table checkboxes render jagged at a high DPI
DrawThemeBackground stretches the checkbox bitmap to fill the provided rectangle. To avoid stretching artifacts, limit the rectangle to actual checkbox bitmap size. This change also supersedes the fix for bug 489828. Change-Id: Ib227b874716b7858dc52596c5103ceb598e68cbb Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java21
2 files changed, 22 insertions, 20 deletions
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 0936214622..248276e875 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
@@ -2195,16 +2195,6 @@ void fixCheckboxImageList (boolean fixScroll) {
if (hImageList == 0) return;
int [] cx = new int [1], cy = new int [1];
OS.ImageList_GetIconSize (hImageList, cx, cy);
- /*
- * On Windows when OS level custom zoom is more than 150% then OS
- * doesn't support auto-scaling of the native check-box images and hence
- * the size of native check-box never goes more than 20px wide. So, to
- * handle this special case in Table/Tree, need to apply the same upper
- * cap to the size of custom drawn check-box images, so check-box images
- * look in proper ratio. For more details refer bug 489828.
- */
- cx [0] = Math.min (20, cx [0]);
- cy [0] = Math.min (20, cy [0]);
long /*int*/ hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
if (hStateList == 0) return;
int [] stateCx = new int [1], stateCy = new int [1];
@@ -4287,6 +4277,17 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
OS.SelectObject (hDC, oldFont);
int itemWidth = Math.min (tm.tmHeight, width);
int itemHeight = Math.min (tm.tmHeight, height);
+ if (OS.IsAppThemed()) {
+ /*
+ * Feature in Windows. DrawThemeBackground stretches the checkbox
+ * bitmap to fill the provided rectangle. To avoid stretching
+ * artifacts, limit the rectangle to actual checkbox bitmap size.
+ */
+ SIZE size = new SIZE();
+ OS.GetThemePartSize(display.hButtonTheme(), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size);
+ itemWidth = Math.min (size.cx, itemWidth);
+ itemHeight = Math.min (size.cy, itemHeight);
+ }
int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2;
OS.SetRect (rect, left, top, left + itemWidth, top + itemHeight);
if (OS.IsAppThemed ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index e9f88b3f63..5386a5cbe6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -4598,16 +4598,17 @@ void setCheckboxImageList () {
OS.SelectObject (hDC, oldFont);
int itemWidth = Math.min (tm.tmHeight, width);
int itemHeight = Math.min (tm.tmHeight, height);
- /*
- * On Windows when OS level custom zoom is more than 150% then OS
- * doesn't support auto-scaling of the native check-box images and hence
- * the size of native check-box never goes more than 20px wide. So, to
- * handle this special case in Table/Tree, need to apply the same upper
- * cap to the size of custom drawn check-box images, so check-box images
- * look in proper ratio. For more details refer bug 489828.
- */
- itemWidth = Math.min (20, itemWidth);
- itemHeight = Math.min (20, itemHeight);
+ if (OS.IsAppThemed()) {
+ /*
+ * Feature in Windows. DrawThemeBackground stretches the checkbox
+ * bitmap to fill the provided rectangle. To avoid stretching
+ * artifacts, limit the rectangle to actual checkbox bitmap size.
+ */
+ SIZE size = new SIZE();
+ OS.GetThemePartSize(display.hButtonTheme(), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size);
+ itemWidth = Math.min (size.cx, itemWidth);
+ itemHeight = Math.min (size.cy, itemHeight);
+ }
int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1;
OS.SetRect (rect, left + width, top, left + width + itemWidth, top + itemHeight);
if (OS.IsAppThemed ()) {

Back to the top