Skip to content

Commit a26b66a

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Always use native zoom for OS theme calls
This commit changes all DPI dependent OS theme calls to use the native zoom instead of using the zoom adjusted by the swt.autoScale setting. This is neccessary, because theme dependent elements like the checkbox for a button will be drawn by the OS and must be calculated with the native zoom. Fixes #1573
1 parent df66a8b commit a26b66a

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ private int getCheckboxTextOffset(long hdc) {
13111311
SIZE size = new SIZE();
13121312

13131313
if (OS.IsAppThemed ()) {
1314-
OS.GetThemePartSize(display.hButtonTheme(getZoom()), hdc, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, null, OS.TS_TRUE, size);
1314+
OS.GetThemePartSize(display.hButtonTheme(nativeZoom), hdc, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, null, OS.TS_TRUE, size);
13151315
result += size.cx;
13161316
} else {
13171317
result += DPIUtil.scaleUp(13, nativeZoom);
@@ -1543,7 +1543,7 @@ LRESULT wmDrawChild (long wParam, long lParam) {
15431543
boolean pressed = ((struct.itemState & OS.ODS_SELECTED) != 0);
15441544
boolean enabled = getEnabled ();
15451545
int iStateId = getThemeStateId(style, pressed, enabled);
1546-
OS.DrawThemeBackground (display.hScrollBarThemeAuto (getZoom()), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null);
1546+
OS.DrawThemeBackground (display.hScrollBarThemeAuto(nativeZoom), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null);
15471547
} else {
15481548
int uState = OS.DFCS_SCROLLLEFT;
15491549
switch (style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) {

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ LRESULT wmNCPaint (long hwnd, long wParam, long lParam) {
18561856
rect.left = rect.top = 0;
18571857
int border = getSystemMetrics (OS.SM_CXEDGE);
18581858
OS.ExcludeClipRect (hDC, border, border, rect.right - border, rect.bottom - border);
1859-
OS.DrawThemeBackground (display.hEditTheme (getZoom()), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null);
1859+
OS.DrawThemeBackground(display.hEditTheme(nativeZoom), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null);
18601860
OS.ReleaseDC (hwnd, hDC);
18611861
return new LRESULT (code);
18621862
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int checkStyle (int style) {
137137
long hDC = OS.GetDC (handle);
138138
long hTheme = 0;
139139
if (isAppThemed ()) {
140-
hTheme = display.hExplorerBarTheme (getZoom());
140+
hTheme = display.hExplorerBarTheme(nativeZoom);
141141
}
142142
long hCurrentFont = 0, oldFont = 0;
143143
if (hTheme == 0) {
@@ -247,13 +247,13 @@ void drawThemeBackground (long hDC, long hwnd, RECT rect) {
247247
RECT rect2 = new RECT ();
248248
OS.GetClientRect (handle, rect2);
249249
OS.MapWindowPoints (handle, hwnd, rect2, 2);
250-
OS.DrawThemeBackground (display.hExplorerBarTheme (getZoom()), hDC, OS.EBP_NORMALGROUPBACKGROUND, 0, rect2, null);
250+
OS.DrawThemeBackground (display.hExplorerBarTheme(nativeZoom), hDC, OS.EBP_NORMALGROUPBACKGROUND, 0, rect2, null);
251251
}
252252

253253
void drawWidget (GC gc, RECT clipRect) {
254254
long hTheme = 0;
255255
if (isAppThemed ()) {
256-
hTheme = display.hExplorerBarTheme (getZoom());
256+
hTheme = display.hExplorerBarTheme(nativeZoom);
257257
}
258258
if (hTheme != 0) {
259259
RECT rect = new RECT ();

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void drawThemeBackground (long hDC, long hwnd, RECT rect) {
298298
OS.GetClientRect (handle, rect2);
299299
OS.MapWindowPoints (handle, hwnd, rect2, 2);
300300
if (OS.IntersectRect (new RECT (), rect2, rect)) {
301-
OS.DrawThemeBackground (display.hTabTheme (getZoom()), hDC, OS.TABP_BODY, 0, rect2, null);
301+
OS.DrawThemeBackground (display.hTabTheme(nativeZoom), hDC, OS.TABP_BODY, 0, rect2, null);
302302
}
303303
}
304304

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4263,14 +4263,14 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
42634263
* artifacts, limit the rectangle to actual checkbox bitmap size.
42644264
*/
42654265
SIZE size = new SIZE();
4266-
OS.GetThemePartSize(display.hButtonTheme(getZoom()), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size);
4266+
OS.GetThemePartSize(display.hButtonTheme(nativeZoom), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size);
42674267
itemWidth = Math.min (size.cx, itemWidth);
42684268
itemHeight = Math.min (size.cy, itemHeight);
42694269
}
42704270
int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2;
42714271
OS.SetRect (rect, left, top, left + itemWidth, top + itemHeight);
42724272
if (OS.IsAppThemed ()) {
4273-
long hTheme = display.hButtonTheme(getZoom());
4273+
long hTheme = display.hButtonTheme(nativeZoom);
42744274
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null);
42754275
rect.left += width; rect.right += width;
42764276
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null);

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ LRESULT WM_DRAWITEM (long wParam, long lParam) {
27512751
drawBackground (struct.hDC, rect, -1, pt.x, pt.y);
27522752
if (struct.CtlID == SWT.ICON_CANCEL && struct.hwndItem == hwndActiveIcon && OS.IsAppThemed()) {
27532753
int state = OS.GetKeyState (OS.VK_LBUTTON) < 0 ? OS.PBS_PRESSED : OS.PBS_HOT;
2754-
OS.DrawThemeBackground (display.hButtonThemeAuto (getZoom()), struct.hDC, OS.BP_PUSHBUTTON, state, rect, null);
2754+
OS.DrawThemeBackground(display.hButtonThemeAuto(nativeZoom), struct.hDC, OS.BP_PUSHBUTTON, state, rect, null);
27552755
}
27562756
int width = rect.right - rect.left;
27572757
int height = rect.bottom - rect.top;

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4781,14 +4781,14 @@ void setCheckboxImageList () {
47814781
* artifacts, limit the rectangle to actual checkbox bitmap size.
47824782
*/
47834783
SIZE size = new SIZE();
4784-
OS.GetThemePartSize(display.hButtonTheme(getZoom()), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size);
4784+
OS.GetThemePartSize(display.hButtonTheme(nativeZoom), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size);
47854785
itemWidth = Math.min (size.cx, itemWidth);
47864786
itemHeight = Math.min (size.cy, itemHeight);
47874787
}
47884788
int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1;
47894789
OS.SetRect (rect, left + width, top, left + width + itemWidth, top + itemHeight);
47904790
if (OS.IsAppThemed ()) {
4791-
long hTheme = display.hButtonTheme(getZoom());
4791+
long hTheme = display.hButtonTheme(nativeZoom);
47924792
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null);
47934793
rect.left += width; rect.right += width;
47944794
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null);

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,7 @@ LRESULT wmPrint (long hwnd, long wParam, long lParam) {
23492349
rect.left = rect.top = 0;
23502350
int border = getSystemMetrics (OS.SM_CXEDGE);
23512351
OS.ExcludeClipRect (wParam, border, border, rect.right - border, rect.bottom - border);
2352-
OS.DrawThemeBackground (display.hEditTheme (getZoom()), wParam, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null);
2352+
OS.DrawThemeBackground(display.hEditTheme(nativeZoom), wParam, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null);
23532353
return new LRESULT (code);
23542354
}
23552355
}

0 commit comments

Comments
 (0)