Merge branch 'slakkimsetti/NeonhiDpiWork' of ssh://slakkimsetti@git.eclipse.org/gitroot/platform/eclipse.platform.swt.git into slakkimsetti/NeonhiDpiWork
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index 9dbed7e..5b7e890 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -73,7 +73,6 @@
Drawable drawable;
GCData data;
- boolean autoScaleEnabled;
static final int FOREGROUND = 1 << 0;
static final int BACKGROUND = 1 << 1;
@@ -170,7 +169,6 @@
if (device == null) device = Device.getDevice();
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = data.device = device;
- this.autoScaleEnabled = DPIUtil.getAutoScale ();
init (drawable, data, hDC);
init();
}
@@ -500,7 +498,12 @@
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-
+ srcX = DPIUtil.autoScaleUp(srcX, device);
+ srcY = DPIUtil.autoScaleUp(srcY, device);
+ width = DPIUtil.autoScaleUp(width, device);
+ height = DPIUtil.autoScaleUp(height, device);
+ destX = DPIUtil.autoScaleUp(destX, device);
+ destY = DPIUtil.autoScaleUp(destY, device);
/*
* Feature in WinCE. The function WindowFromDC is not part of the
* WinCE SDK. The fix is to remember the HWND.
@@ -1939,12 +1942,10 @@
*/
public void drawRectangle (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (autoScaleEnabled) {
- x = DPIUtil.autoScaleUp (x, device);
- y = DPIUtil.autoScaleUp (y, device);
- width = DPIUtil.autoScaleUp (width, device);
- height = DPIUtil.autoScaleUp (height, device);
- }
+ x = DPIUtil.autoScaleUp (x, device);
+ y = DPIUtil.autoScaleUp (y, device);
+ width = DPIUtil.autoScaleUp (width, device);
+ height = DPIUtil.autoScaleUp (height, device);
checkGC(DRAW);
long /*int*/ gdipGraphics = data.gdipGraphics;
if (gdipGraphics != 0) {
@@ -3067,12 +3068,10 @@
*/
public void fillRectangle (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (autoScaleEnabled) {
- x = DPIUtil.autoScaleUp (x, device);
- y = DPIUtil.autoScaleUp (y, device);
- width = DPIUtil.autoScaleUp (width, device);
- height = DPIUtil.autoScaleUp (height, device);
- }
+ x = DPIUtil.autoScaleUp (x, device);
+ y = DPIUtil.autoScaleUp (y, device);
+ width = DPIUtil.autoScaleUp (width, device);
+ height = DPIUtil.autoScaleUp (height, device);
checkGC(FILL);
if (data.gdipGraphics != 0) {
if (width < 0) {
@@ -3236,7 +3235,7 @@
if (OS.IsWinCE) {
SIZE size = new SIZE();
OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size);
- return size.cx;
+ return DPIUtil.autoScaleDown(size.cx, getDevice ());
}
int tch = ch;
if (ch > 0x7F) {
@@ -3245,7 +3244,7 @@
}
int[] width = new int[1];
OS.GetCharWidth(handle, tch, tch, width);
- return width[0];
+ return DPIUtil.autoScaleDown(width[0], getDevice ());
}
/**
@@ -3388,7 +3387,7 @@
}
int[] width = new int[3];
if (OS.GetCharABCWidths(handle, tch, tch, width)) {
- return width[1];
+ return DPIUtil.autoScaleDown(width[1], getDevice ());
}
}
@@ -3397,7 +3396,7 @@
OS.GetTextMetrics(handle, lptm);
SIZE size = new SIZE();
OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size);
- return size.cx - lptm.tmOverhang;
+ return DPIUtil.autoScaleDown(size.cx - lptm.tmOverhang, getDevice ());
}
/**
@@ -3420,11 +3419,11 @@
Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
Gdip.Graphics_GetVisibleClipBounds(gdipGraphics, rect);
Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
- return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
+ return DPIUtil.autoScaleDown(new Rectangle(rect.X, rect.Y, rect.Width, rect.Height), getDevice ());
}
RECT rect = new RECT();
OS.GetClipBox(handle, rect);
- return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ return DPIUtil.autoScaleDown(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getDevice ());
}
/**
@@ -4341,6 +4340,10 @@
*/
public void setClipping (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x, getDevice ());
+ y = DPIUtil.autoScaleUp(y, getDevice ());
+ width = DPIUtil.autoScaleUp(width, getDevice ());
+ height = DPIUtil.autoScaleUp(height, getDevice ());
long /*int*/ hRgn = OS.CreateRectRgn(x, y, x + width, y + height);
setClipping(hRgn);
OS.DeleteObject(hRgn);
@@ -4399,6 +4402,7 @@
*/
public void setClipping (Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ rect = DPIUtil.autoScaleUp(rect, getDevice ());
if (rect == null) {
setClipping(0);
} else {
@@ -5010,19 +5014,19 @@
if (gdipGraphics != 0) {
Point size = new Point(0, 0);
drawText(gdipGraphics, string, 0, 0, 0, size);
- return size;
+ return DPIUtil.autoScaleDown(size, getDevice ());
}
SIZE size = new SIZE();
if (length == 0) {
// OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
OS.GetTextExtentPoint32W(handle, new char[]{' '}, 1, size);
- return new Point(0, size.cy);
+ return DPIUtil.autoScaleDown(new Point(0, size.cy), getDevice ());
} else {
// TCHAR buffer = new TCHAR (getCodePage(), string, false);
char[] buffer = new char [length];
string.getChars(0, length, buffer, 0);
OS.GetTextExtentPoint32W(handle, buffer, length, size);
- return new Point(size.cx, size.cy);
+ return DPIUtil.autoScaleDown(new Point(size.cx, size.cy), getDevice ());
}
}
@@ -5088,13 +5092,13 @@
if (gdipGraphics != 0) {
Point size = new Point(0, 0);
drawText(gdipGraphics, string, 0, 0, flags, size);
- return size;
+ return DPIUtil.autoScaleDown(size, getDevice ());
}
if (string.length () == 0) {
SIZE size = new SIZE();
// OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
OS.GetTextExtentPoint32W(handle, new char [] {' '}, 1, size);
- return new Point(0, size.cy);
+ return DPIUtil.autoScaleDown(new Point(0, size.cy), getDevice ());
}
RECT rect = new RECT();
TCHAR buffer = new TCHAR(getCodePage(), string, false);
@@ -5103,7 +5107,7 @@
if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS;
if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX;
OS.DrawText(handle, buffer, buffer.length(), rect, uFormat);
- return new Point(rect.right, rect.bottom);
+ return DPIUtil.autoScaleDown(new Point(rect.right, rect.bottom), getDevice ());
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
index 37d5154..7b9f6b0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -197,6 +197,7 @@
*/
public Image(Device device, int width, int height) {
super(device);
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
width = DPIUtil.autoScaleUp (width, device);
height = DPIUtil.autoScaleUp (height, device);
init(width, height);
@@ -458,6 +459,7 @@
public Image(Device device, Rectangle bounds) {
super(device);
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
bounds = DPIUtil.autoScaleUp (bounds, device);
init(bounds.width, bounds.height);
init();
@@ -489,6 +491,7 @@
public Image(Device device, ImageData data) {
super(device);
if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
data = DPIUtil.autoScaleUp (data, device);
init(data);
init();
@@ -531,6 +534,7 @@
if (source.width != mask.width || source.height != mask.height) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
source = DPIUtil.autoScaleUp(source, device);
mask = DPIUtil.autoScaleUp(mask, device);
mask = ImageData.convertMask(mask);
@@ -593,7 +597,9 @@
*/
public Image (Device device, InputStream stream) {
super(device);
- init(new ImageData(stream));
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
+ ImageData data = DPIUtil.autoScaleUp(new ImageData(stream), device);
+ init(data);
init();
}
@@ -632,8 +638,9 @@
public Image (Device device, String filename) {
super(device);
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- initNative(filename);
- if (this.handle == 0) init(new ImageData(filename));
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
+ ImageData data = DPIUtil.autoScaleUp(new ImageData(filename), device);
+ init(data);
init();
}
@@ -669,7 +676,7 @@
public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
super(device);
this.imageFileNameProvider = imageFileNameProvider;
- currentDeviceZoom = device.getDeviceZoom ();
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
boolean[] found = new boolean[1];
String fileName = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, currentDeviceZoom, found);
if (found[0]) {
@@ -714,7 +721,7 @@
public Image(Device device, ImageDataProvider imageDataProvider) {
super(device);
this.imageDataProvider = imageDataProvider;
- currentDeviceZoom = device.getDeviceZoom ();
+ if (device != null) currentDeviceZoom = device.getDeviceZoom ();
boolean[] found = new boolean[1];
ImageData data = DPIUtil.validateAndGetImageDataAtZoom(imageDataProvider, currentDeviceZoom, found);
if (found[0]) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
index 3941a17..2838e36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
@@ -11,9 +11,9 @@
package org.eclipse.swt.internal;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
public class ImageList {
long /*int*/ handle;
@@ -402,7 +402,7 @@
* Note that the image size has to match the image list icon size.
*/
long /*int*/ hBitmap = 0, hMask = 0;
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageData (image.getDevice().getDeviceZoom());
switch (data.getTransparencyType ()) {
case SWT.TRANSPARENCY_ALPHA:
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 839ba18..cb1cf35 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a selectable user interface object that
@@ -168,8 +168,8 @@
if (image != null) {
switch (image.type) {
case SWT.BITMAP: {
- Rectangle rect = image.getBounds ();
- ImageData data = image.getImageData ();
+ Rectangle rect = image.getBounds (image.getDevice().getDeviceZoom());
+ ImageData data = image.getImageData (image.getDevice().getDeviceZoom());
switch (data.getTransparencyType ()) {
case SWT.TRANSPARENCY_PIXEL:
if (rect.width <= ICON_WIDTH && rect.height <= ICON_HEIGHT) {
@@ -400,6 +400,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0, border = getBorderWidth ();
if ((style & SWT.ARROW) != 0) {
if ((style & (SWT.UP | SWT.DOWN)) != 0) {
@@ -499,7 +501,7 @@
if (hHint != SWT.DEFAULT) height = hHint;
width += border * 2;
height += border * 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index 1c17b19..22dfddb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -11,9 +11,9 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide a surface for drawing
@@ -197,6 +197,12 @@
*/
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
checkWidget ();
+ destX = DPIUtil.autoScaleUp(destX, getDisplay());
+ destY = DPIUtil.autoScaleUp(destY, getDisplay());
+ x = DPIUtil.autoScaleUp(x, getDisplay());
+ y = DPIUtil.autoScaleUp(y, getDisplay());
+ width = DPIUtil.autoScaleUp(width, getDisplay());
+ height = DPIUtil.autoScaleUp(height, getDisplay());
forceResize ();
boolean isFocus = caret != null && caret.isFocusCaret ();
if (isFocus) caret.killFocus ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
index e3abaa9..9804db7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -12,11 +12,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class are controls that allow the user
@@ -625,6 +625,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0;
if (wHint == SWT.DEFAULT) {
long /*int*/ newFont, oldFont = 0;
@@ -698,7 +700,7 @@
if ((style & SWT.SIMPLE) != 0 && (style & SWT.H_SCROLL) != 0) {
height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
}
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
/**
@@ -1120,7 +1122,7 @@
checkWidget ();
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
if (result == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
- return result;
+ return DPIUtil.autoScaleDown(result, getDisplay());
}
/**
@@ -1997,6 +1999,10 @@
* items and ignore the height value that the programmer supplies.
*/
if ((style & SWT.DROP_DOWN) != 0) {
+ x = DPIUtil.autoScaleUp (x, getDisplay ());
+ y = DPIUtil.autoScaleUp (y, getDisplay ());
+ width = DPIUtil.autoScaleUp (width, getDisplay ());
+ height = DPIUtil.autoScaleUp (height, getDisplay());
int visibleCount = getItemCount() == 0 ? VISIBLE_COUNT : this.visibleCount;
height = getTextHeight () + (getItemHeight () * visibleCount) + 2;
/*
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 09b3f7a..7e6c9e5 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
@@ -230,6 +230,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
display.runSkin ();
Point size;
if (layout != null) {
@@ -247,6 +249,7 @@
}
if (wHint != SWT.DEFAULT) size.x = wHint;
if (hHint != SWT.DEFAULT) size.y = hHint;
+ size = DPIUtil.autoScaleDown(size, getDisplay ());
Rectangle trim = computeTrim (0, 0, size.x, size.y);
return new Point (trim.width, trim.height);
}
@@ -1072,6 +1075,7 @@
@Override
void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+ // AutoScaleUp taken care by super.setBounds
if (display.resizeCount > Display.RESIZE_LIMIT) {
defer = false;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 9a3f692..2442248 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -657,6 +657,8 @@
*/
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = DEFAULT_WIDTH;
int height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
@@ -664,7 +666,7 @@
int border = getBorderWidth ();
width += border * 2;
height += border * 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
Widget computeTabGroup () {
@@ -1226,7 +1228,7 @@
if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXEDGE);
if ((bits1 & OS.WS_EX_STATICEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
int bits2 = OS.GetWindowLong (borderHandle, OS.GWL_STYLE);
- if ((bits2 & OS.WS_BORDER) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
+ if ((bits2 & OS.WS_BORDER) != 0) return DPIUtil.autoScaleDown(OS.GetSystemMetrics (OS.SM_CXBORDER), getDisplay ());
return 0;
}
@@ -1252,7 +1254,7 @@
OS.MapWindowPoints (0, hwndParent, rect, 2);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, width, height), getDisplay ());
}
int getCodePage () {
@@ -1424,7 +1426,7 @@
OS.GetWindowRect (topHandle (), rect);
long /*int*/ hwndParent = parent == null ? 0 : parent.handle;
OS.MapWindowPoints (0, hwndParent, rect, 2);
- return new Point (rect.left, rect.top);
+ return DPIUtil.autoScaleDown(new Point (rect.left, rect.top), getDisplay ());
}
/**
@@ -1592,7 +1594,7 @@
OS.GetWindowRect (topHandle (), rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
/**
@@ -2427,6 +2429,10 @@
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x, getDisplay ());
+ y = DPIUtil.autoScaleUp(y, getDisplay ());
+ width = DPIUtil.autoScaleUp(width, getDisplay ());
+ height = DPIUtil.autoScaleUp(height, getDisplay ());
if (width <= 0 || height <= 0) return;
if (!OS.IsWindowVisible (handle)) return;
RECT rect = new RECT ();
@@ -3166,6 +3172,10 @@
}
void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+ x = DPIUtil.autoScaleUp(x, getDisplay ());
+ y = DPIUtil.autoScaleUp(y, getDisplay ());
+ width = DPIUtil.autoScaleUp(width, getDisplay ());
+ height = DPIUtil.autoScaleUp(height, getDisplay ());
if (findImageControl () != null) {
if (backgroundImage == null) flags |= OS.SWP_NOCOPYBITS;
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
index d68f57d..7d70c53 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -11,9 +11,9 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide an area for dynamically
@@ -143,10 +143,12 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0;
int border = getBorderWidth ();
- int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
- int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
+ int newWidth = wHint == SWT.DEFAULT ? DPIUtil.autoScaleUp(0x3FFF, getDisplay()) : wHint + (border * 2);
+ int newHeight = hHint == SWT.DEFAULT ? DPIUtil.autoScaleUp(0x3FFF, getDisplay()) : hHint + (border * 2);
int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (count != 0) {
ignoreResize = true;
@@ -207,7 +209,7 @@
if (hHint != SWT.DEFAULT) height = hHint;
height += border * 2;
width += border * 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
@@ -584,6 +586,9 @@
sizes [i] = new Point (rect.right - rect.left, rbBand.cyChild);
}
}
+ for (int i = 0; i < sizes.length; i++) {
+ sizes [i] = DPIUtil.autoScaleDown(sizes [i], getDisplay ());
+ }
return sizes;
}
@@ -905,6 +910,9 @@
*/
void setItemSizes (Point [] sizes) {
if (sizes == null) error (SWT.ERROR_NULL_ARGUMENT);
+ for (int i = 0; i < sizes.length; i++) {
+ sizes [i] = DPIUtil.autoScaleUp(sizes [i], getDisplay ());
+ }
int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (sizes.length != count) error (SWT.ERROR_INVALID_ARGUMENT);
REBARBANDINFO rbBand = new REBARBANDINFO ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
index 9742ca5..cba258f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are selectable user interface
@@ -185,6 +185,8 @@
*/
public Point computeSize (int wHint, int hHint) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
int width = wHint, height = hHint;
@@ -195,7 +197,7 @@
} else {
width += parent.getMargin (index);
}
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
@@ -234,9 +236,9 @@
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
if ((parent.style & SWT.VERTICAL) != 0) {
- return new Rectangle (rect.top, rect.left, height, width);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.top, rect.left, height, width), getDisplay ());
}
- return new Rectangle (rect.left, rect.top, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, width, height), getDisplay ());
}
Rectangle getClientArea () {
@@ -384,9 +386,9 @@
OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
int width = rbBand.cxIdeal + parent.getMargin (index);
if ((parent.style & SWT.VERTICAL) != 0) {
- return new Point (rbBand.cyMaxChild, width);
+ return DPIUtil.autoScaleDown(new Point (rbBand.cyMaxChild, width), getDisplay ());
}
- return new Point (width, rbBand.cyMaxChild);
+ return DPIUtil.autoScaleDown(new Point (width, rbBand.cyMaxChild), getDisplay ());
}
/**
@@ -402,6 +404,8 @@
*/
public void setPreferredSize (int width, int height) {
checkWidget ();
+ width = DPIUtil.autoScaleUp (width, getDisplay ());
+ height = DPIUtil.autoScaleUp (height, getDisplay ());
int index = parent.indexOf (this);
if (index == -1) return;
width = Math.max (0, width);
@@ -482,9 +486,9 @@
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
if ((parent.style & SWT.VERTICAL) != 0) {
- return new Point (height, width);
+ return DPIUtil.autoScaleDown(new Point (height, width), getDisplay ());
}
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
/**
@@ -505,6 +509,8 @@
*/
public void setSize (int width, int height) {
checkWidget ();
+ width = DPIUtil.autoScaleUp(width, getDisplay ());
+ height = DPIUtil.autoScaleUp(height, getDisplay ());
int index = parent.indexOf (this);
if (index == -1) return;
width = Math.max (0, width);
@@ -594,9 +600,9 @@
rbBand.fMask = OS.RBBIM_CHILDSIZE;
OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
if ((parent.style & SWT.VERTICAL) != 0) {
- return new Point (rbBand.cyMinChild, rbBand.cxMinChild);
+ return DPIUtil.autoScaleDown(new Point (rbBand.cyMinChild, rbBand.cxMinChild), getDisplay ());
}
- return new Point (rbBand.cxMinChild, rbBand.cyMinChild);
+ return DPIUtil.autoScaleDown(new Point (rbBand.cxMinChild, rbBand.cyMinChild), getDisplay ());
}
/**
@@ -615,6 +621,8 @@
*/
public void setMinimumSize (int width, int height) {
checkWidget ();
+ width = DPIUtil.autoScaleUp (width, getDisplay ());
+ height = DPIUtil.autoScaleUp (height, getDisplay ());
int index = parent.indexOf (this);
if (index == -1) return;
width = Math.max (0, width);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
index 828e7ab..0b60038 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are selectable user interface
@@ -250,6 +250,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
if ((style & SWT.CALENDAR) != 0) {
@@ -320,7 +322,7 @@
int border = getBorderWidth ();
width += border * 2;
height += border * 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index bf7af0a..f60d968 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -351,7 +351,10 @@
@Override
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
-
+ x = DPIUtil.autoScaleUp(x, getDisplay ());
+ y = DPIUtil.autoScaleUp(y, getDisplay ());
+ width = DPIUtil.autoScaleUp(width, getDisplay ());
+ height = DPIUtil.autoScaleUp(height, getDisplay ());
/* Get the size of the trimmings */
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
@@ -376,7 +379,7 @@
OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect);
}
}
- return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getDisplay ());
}
void createAccelerators () {
@@ -655,9 +658,9 @@
lpwndpl.length = WINDOWPLACEMENT.sizeof;
OS.GetWindowPlacement (handle, lpwndpl);
if ((lpwndpl.flags & OS.WPF_RESTORETOMAXIMIZED) != 0) {
- return new Point (maxRect.left, maxRect.top);
+ return DPIUtil.autoScaleDown(new Point (maxRect.left, maxRect.top), getDisplay ());
}
- return new Point (lpwndpl.left, lpwndpl.top);
+ return DPIUtil.autoScaleDown(new Point (lpwndpl.left, lpwndpl.top), getDisplay ());
}
}
return super.getLocation ();
@@ -737,11 +740,11 @@
if ((lpwndpl.flags & OS.WPF_RESTORETOMAXIMIZED) != 0) {
int width = maxRect.right - maxRect.left;
int height = maxRect.bottom - maxRect.top;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
int width = lpwndpl.right - lpwndpl.left;
int height = lpwndpl.bottom - lpwndpl.top;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
}
return super.getSize ();
@@ -872,6 +875,10 @@
@Override
void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+ x = DPIUtil.autoScaleUp (x, getDisplay ());
+ y = DPIUtil.autoScaleUp (y, getDisplay ());
+ width = DPIUtil.autoScaleUp (width, getDisplay());
+ height = DPIUtil.autoScaleUp (height, getDisplay());
swFlags = OS.SW_SHOWNOACTIVATE;
if (OS.IsWinCE) {
swFlags = OS.SW_RESTORE;
@@ -902,6 +909,10 @@
return;
}
}
+ x = DPIUtil.autoScaleDown (x, getDisplay ());
+ y = DPIUtil.autoScaleDown (y, getDisplay ());
+ width = DPIUtil.autoScaleDown (width, getDisplay());
+ height = DPIUtil.autoScaleDown (height, getDisplay());
super.setBounds (x, y, width, height, flags, defer);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 2571637..da25824 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -1086,7 +1086,7 @@
static Image createIcon (Image image) {
Device device = image.getDevice ();
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageData (device.getDeviceZoom ());
if (data.alpha == -1 && data.alphaData == null) {
ImageData mask = data.getTransparencyMask ();
return new Image (device, data, mask);
@@ -1586,13 +1586,13 @@
OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, width, height), this);
}
int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
- return new Rectangle (x, y, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (x, y, width, height), this);
}
Control getControl (long /*int*/ handle) {
@@ -1662,7 +1662,7 @@
checkDevice ();
POINT pt = new POINT ();
OS.GetCursorPos (pt);
- return new Point (pt.x, pt.y);
+ return DPIUtil.autoScaleDown(new Point (pt.x, pt.y), this);
}
/**
@@ -2995,10 +2995,10 @@
long /*int*/ hwndFrom = from != null ? from.handle : 0;
long /*int*/ hwndTo = to != null ? to.handle : 0;
POINT point = new POINT ();
- point.x = x;
- point.y = y;
+ point.x = DPIUtil.autoScaleUp(x, this);
+ point.y = DPIUtil.autoScaleUp(y, this);
OS.MapWindowPoints (hwndFrom, hwndTo, point, 1);
- return new Point (point.x, point.y);
+ return DPIUtil.autoScaleDown(new Point (point.x, point.y), this);
}
/**
@@ -3089,12 +3089,12 @@
long /*int*/ hwndFrom = from != null ? from.handle : 0;
long /*int*/ hwndTo = to != null ? to.handle : 0;
RECT rect = new RECT ();
- rect.left = x;
- rect.top = y;
- rect.right = x + width;
- rect.bottom = y + height;
+ rect.left = DPIUtil.autoScaleUp(x, this);
+ rect.top = DPIUtil.autoScaleUp(y, this);
+ rect.right = DPIUtil.autoScaleUp(x + width, this);
+ rect.bottom = DPIUtil.autoScaleUp(y + height, this);
OS.MapWindowPoints (hwndFrom, hwndTo, rect, 2);
- return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), this);
}
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
index ddfcb84..44a93a2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class support the layout of selectable
@@ -130,6 +130,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int height = 0, width = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
if (itemCount > 0) {
@@ -175,6 +177,8 @@
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
+ width = DPIUtil.autoScaleDown(width, getDisplay ());
+ height = DPIUtil.autoScaleDown(height, getDisplay ());
Rectangle trim = computeTrim (0, 0, width, height);
return new Point (trim.width, trim.height);
}
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 8436df5..c30b523 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
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.BidiUtil;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide an etched border
@@ -155,6 +155,7 @@
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
Point size = super.computeSize (wHint, hHint, changed);
+ size = DPIUtil.autoScaleUp(size, getDisplay ());
int length = text.length ();
if (length != 0) {
String string = fixText (false);
@@ -176,13 +177,14 @@
int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1;
size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6 + offsetY);
}
- return size;
+ return DPIUtil.autoScaleDown(size, getDisplay ());
}
@Override
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
Rectangle trim = super.computeTrim (x, y, width, height);
+ trim = DPIUtil.autoScaleUp(trim, getDisplay ());
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
@@ -196,7 +198,7 @@
trim.y -= tm.tmHeight + offsetY;
trim.width += CLIENT_INSET * 2;
trim.height += tm.tmHeight + CLIENT_INSET + offsetY;
- return trim;
+ return DPIUtil.autoScaleDown(trim, getDisplay ());
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 7133858..020b832 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -13,7 +13,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -131,6 +131,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0, border = getBorderWidth ();
if ((style & SWT.SEPARATOR) != 0) {
int lineWidth = OS.GetSystemMetrics (OS.SM_CXBORDER);
@@ -142,7 +144,7 @@
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
width += border * 2; height += border * 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
boolean drawText = true;
@@ -195,7 +197,7 @@
* this trim.
*/
if (OS.IsWinCE && !drawImage) width += 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index c1b6cd8..39696d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.BidiUtil;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
import org.eclipse.swt.accessibility.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a selectable
@@ -179,6 +179,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
int width, height;
@@ -226,7 +228,7 @@
int border = getBorderWidth ();
width += border * 2;
height += border * 2;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index ce40298..8e8348e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -14,7 +14,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -218,6 +218,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0;
if (wHint == SWT.DEFAULT) {
if ((style & SWT.H_SCROLL) != 0) {
@@ -268,7 +270,7 @@
if ((style & SWT.H_SCROLL) != 0) {
height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
}
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
@Override
@@ -479,7 +481,7 @@
checkWidget ();
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
- return result;
+ return DPIUtil.autoScaleDown(result, getDisplay ());
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
index efae7ca..ffb09fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of the receiver represent a selectable user interface object
@@ -129,6 +129,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int border = getBorderWidth ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
@@ -138,11 +140,15 @@
}
if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
void drawBand (int x, int y, int width, int height) {
if ((style & SWT.SMOOTH) != 0) return;
+ x = DPIUtil.autoScaleUp (x, getDisplay ());
+ y = DPIUtil.autoScaleUp (y, getDisplay ());
+ width = DPIUtil.autoScaleUp (width, getDisplay ());
+ height = DPIUtil.autoScaleUp (height, getDisplay ());
long /*int*/ hwndTrack = parent.handle;
byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
long /*int*/ stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);
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 a71d676..f14af0b 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
@@ -11,9 +11,9 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* This class is the abstract superclass of all classes which
@@ -116,6 +116,10 @@
*/
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
+ x = DPIUtil.autoScaleUp (x, getDisplay ());
+ y = DPIUtil.autoScaleUp (y, getDisplay ());
+ width = DPIUtil.autoScaleUp (width, getDisplay ());
+ height = DPIUtil.autoScaleUp (height, getDisplay ());
long /*int*/ scrolledHandle = scrolledHandle ();
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
@@ -125,7 +129,7 @@
if (horizontalBar != null) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
if (verticalBar != null) rect.right += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
int nWidth = rect.right - rect.left, nHeight = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, nWidth, nHeight);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, nWidth, nHeight), getDisplay ());
}
ScrollBar createScrollBar (int type) {
@@ -207,7 +211,7 @@
x = -rect.left;
y = -rect.top;
}
- return new Rectangle (x, y, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (x, y, width, height), getDisplay ());
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index fe67133..a451cae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -940,7 +940,7 @@
OS.GetWindowRect (handle, rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, width, height), getDisplay ());
}
ToolTip getCurrentToolTip () {
@@ -1040,7 +1040,7 @@
}
RECT rect = new RECT ();
OS.GetWindowRect (handle, rect);
- return new Point (rect.left, rect.top);
+ return DPIUtil.autoScaleDown(new Point (rect.left, rect.top), getDisplay ());
}
@Override
@@ -1140,7 +1140,7 @@
OS.GetWindowRect (handle, rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- return new Point (width, height);
+ return DPIUtil.autoScaleDown(new Point (width, height), getDisplay ());
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index 901aaf7..3108357 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class implement the notebook user interface
@@ -196,6 +196,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
Point size = super.computeSize (wHint, hHint, changed);
RECT insetRect = new RECT (), itemRect = new RECT ();
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect);
@@ -212,12 +214,16 @@
rect.left -= border; rect.right += border;
width = rect.right - rect.left;
size.x = Math.max (width, size.x);
- return size;
+ return DPIUtil.autoScaleDown(size, getDisplay ());
}
@Override
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x, getDisplay ());
+ y = DPIUtil.autoScaleUp(y, getDisplay ());
+ width = DPIUtil.autoScaleUp(width, getDisplay ());
+ height = DPIUtil.autoScaleUp(height, getDisplay ());
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect);
@@ -226,7 +232,7 @@
rect.top -= border; rect.bottom += border;
int newWidth = rect.right - rect.left;
int newHeight = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, newWidth, newHeight);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, newWidth, newHeight), getDisplay ());
}
void createItem (TabItem item, int index) {
@@ -338,7 +344,7 @@
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, width, height);
+ return DPIUtil.autoScaleDown(new Rectangle (rect.left, rect.top, width, height), getDisplay ());
}
/**
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 fabcfc8..e224817 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
@@ -2656,7 +2656,8 @@
if (!painted && hooks (SWT.MeasureItem)) hitTestSelection (0, 0, 0);
long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
- return OS.HIWORD (oneItem) - OS.HIWORD (empty);
+ int itemHeight = OS.HIWORD (oneItem) - OS.HIWORD (empty);
+ return DPIUtil.autoScaleDown(itemHeight, getDisplay ());
}
/**
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 35d889e..9382fd0 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
@@ -14,7 +14,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -667,6 +667,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int height = 0, width = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
long /*int*/ newFont, oldFont = 0;
@@ -709,6 +711,8 @@
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
+ width = DPIUtil.autoScaleDown(width, getDisplay ());
+ height = DPIUtil.autoScaleDown(height, getDisplay ());
Rectangle trim = computeTrim (0, 0, width, height);
return new Point (trim.width, trim.height);
}
@@ -717,6 +721,7 @@
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
Rectangle rect = super.computeTrim (x, y, width, height);
+ rect = DPIUtil.autoScaleUp(rect, getDisplay ());
/*
* The preferred height of a single-line text widget
* has been hand-crafted to be the same height as
@@ -733,7 +738,7 @@
rect.width += 2;
rect.height += 2;
}
- return rect;
+ return DPIUtil.autoScaleDown(rect, getDisplay ());
}
/**
@@ -907,7 +912,7 @@
// if ((style & SWT.BORDER) != 0 && (style & SWT.FLAT) != 0) {
// return OS.GetSystemMetrics (OS.SM_CXBORDER);
// }
- return super.getBorderWidth ();
+ return DPIUtil.autoScaleDown(super.getBorderWidth (), getDisplay ());
}
/**
@@ -982,7 +987,7 @@
OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
}
}
- return new Point (OS.GET_X_LPARAM (caretPos), OS.GET_Y_LPARAM (caretPos));
+ return DPIUtil.autoScaleDown(new Point (OS.GET_X_LPARAM (caretPos), OS.GET_Y_LPARAM (caretPos)), getDisplay ());
}
/**
@@ -1177,7 +1182,7 @@
OS.GetTextMetrics (hDC, tm);
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
- return tm.tmHeight;
+ return DPIUtil.autoScaleDown(tm.tmHeight, getDisplay ());
}
/**
@@ -1892,6 +1897,7 @@
@Override
void setBounds (int x, int y, int width, int height, int flags) {
+ // AutoScaleUp happens in super.setBounds
/*
* Feature in Windows. When the caret is moved,
* the text widget scrolls to show the new location.
@@ -1916,6 +1922,10 @@
int [] start = new int [1], end = new int [1];
OS.SendMessage (handle, OS.EM_GETSEL, start, end);
if (start [0] != 0 || end [0] != 0) {
+ x = DPIUtil.autoScaleUp(x, getDisplay ());
+ y = DPIUtil.autoScaleUp(y, getDisplay ());
+ width = DPIUtil.autoScaleUp(width, getDisplay ());
+ height = DPIUtil.autoScaleUp(height, getDisplay ());
SetWindowPos (handle, 0, x, y, width, height, flags);
OS.SendMessage (handle, OS.EM_SETSEL, 0, 0);
OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [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 a43e4f9..2d5b5b8 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
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class support the layout of selectable
@@ -191,6 +191,8 @@
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint, getDisplay ()) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint, getDisplay ()) : hHint);
int width = 0, height = 0;
if ((style & SWT.VERTICAL) != 0) {
RECT rect = new RECT ();
@@ -246,6 +248,8 @@
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
+ width = DPIUtil.autoScaleDown (width, getDisplay ());
+ height = DPIUtil.autoScaleDown (height, getDisplay ());
Rectangle trim = computeTrim (0, 0, width, height);
width = trim.width; height = trim.height;
return new Point (width, height);
@@ -255,9 +259,10 @@
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
Rectangle trim = super.computeTrim (x, y, width, height);
+ trim = DPIUtil.autoScaleUp(trim, getDisplay ());
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.CCS_NODIVIDER) == 0) trim.height += 2;
- return trim;
+ return DPIUtil.autoScaleDown(trim, getDisplay ());
}
@Override
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 1e0de9f..a2ade1d 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
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class provide a selectable user interface object
@@ -3270,7 +3270,8 @@
*/
public int getItemHeight () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
+ int itemHeight = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
+ return DPIUtil.autoScaleDown(itemHeight, getDisplay ());
}
/**