diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java index a931e23dcb..9619f0defc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java @@ -1323,8 +1323,8 @@ int handleContextMenuRequested(long pView, long pArgs) { // to PIXEL coordinates with the real native zoom value // independent from the swt.autoScale property: Point pt = new Point( // - Win32DPIUtils.pointToPixel(win32Point.x, DPIUtil.getNativeDeviceZoom()), // - Win32DPIUtils.pointToPixel(win32Point.y, DPIUtil.getNativeDeviceZoom())); + DPIUtil.pointToPixel(win32Point.x, DPIUtil.getNativeDeviceZoom()), // + DPIUtil.pointToPixel(win32Point.y, DPIUtil.getNativeDeviceZoom())); // - then, scale back down from PIXEL to DISPLAY coordinates, taking // swt.autoScale property into account // which is also later considered in Menu#setLocation() diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java index 73b34ac0b8..d74bd7e956 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java @@ -538,8 +538,8 @@ private void drag(Event dragEvent) { int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; OS.RedrawWindow (topControl.handle, null, 0, flags); POINT pt = new POINT (); - pt.x = Win32DPIUtils.pointToPixel(dragEvent.x, zoom);// To Pixels - pt.y = Win32DPIUtils.pointToPixel(dragEvent.y, zoom);// To Pixels + pt.x = DPIUtil.pointToPixel(dragEvent.x, zoom);// To Pixels + pt.y = DPIUtil.pointToPixel(dragEvent.y, zoom);// To Pixels OS.MapWindowPoints (control.handle, 0, pt, 1); RECT rect = new RECT (); OS.GetWindowRect (hwndDrag, rect); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java index 6b74adc9c2..c9f788da54 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java @@ -2616,9 +2616,14 @@ static void fillGradientRectangle(GC gc, Device device, RGB fromRGB, RGB toRGB, int redBits, int greenBits, int blueBits, int zoom) { /* Create the bitmap and tile it */ - ImageData band = createGradientBand(width, height, vertical, - fromRGB, toRGB, redBits, greenBits, blueBits); - Image image = new Image(device, band); + ImageDataProvider imageDataProvider = imageZoom -> { + int scaledWidth = DPIUtil.pointToPixel(width, imageZoom); + int scaledHeight = DPIUtil.pointToPixel(height, imageZoom); + return createGradientBand(scaledWidth, scaledHeight, vertical, fromRGB, toRGB, redBits, greenBits, + blueBits); + }; + Image image = new Image(device, imageDataProvider); + ImageData band = image.getImageData(zoom); if ((band.width == 1) || (band.height == 1)) { gc.drawImage(image, 0, 0, DPIUtil.pixelToPoint(band.width, zoom), DPIUtil.pixelToPoint(band.height, zoom), DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(width, zoom), diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java index bc55a3aac1..50e4abeebc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java @@ -257,6 +257,15 @@ public static void validateLinearScaling(ImageDataProvider provider) { } } +/** + * Auto-scale up int dimensions to match the given zoom level + */ +public static int pointToPixel(int size, int zoom) { + if (zoom == 100 || size == SWT.DEFAULT) return size; + float scaleFactor = getScalingFactor(zoom); + return Math.round (size * scaleFactor); +} + /** * Represents an element, such as some image data, at a specific zoom level. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java index dffdc18cfe..09e254d71d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java @@ -598,11 +598,11 @@ public HotspotAwareCursorHandleProvider(int hotspotX, int hotspotY) { } protected final int getHotpotXInPixels(int zoom) { - return Win32DPIUtils.pointToPixel(hotspotX, zoom); + return DPIUtil.pointToPixel(hotspotX, zoom); } protected final int getHotpotYInPixels(int zoom) { - return Win32DPIUtils.pointToPixel(hotspotY, zoom); + return DPIUtil.pointToPixel(hotspotY, zoom); } protected static final void validateHotspotInsideImage(ImageData source, int hotspotX, int hotspotY) { 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 10841f925f..d3b92474ce 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 @@ -2295,8 +2295,8 @@ private ImageHandle createHandle(int zoom) { private long initHandle(int zoom) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - int scaledWidth = Win32DPIUtils.pointToPixel (width, zoom); - int scaledHeight = Win32DPIUtils.pointToPixel (height, zoom); + int scaledWidth = DPIUtil.pointToPixel (width, zoom); + int scaledHeight = DPIUtil.pointToPixel (height, zoom); long hDC = device.internal_new_GC(null); long newHandle = OS.CreateCompatibleBitmap(hDC, scaledWidth, scaledHeight); /* @@ -2727,8 +2727,8 @@ protected ImageHandle newImageHandle(ZoomContext zoomContext) { int gcStyle = drawer.getGcStyle(); Image image; if ((gcStyle & SWT.TRANSPARENT) != 0) { - int scaledHeight = Win32DPIUtils.pointToPixel(height, targetZoom); - int scaledWidth = Win32DPIUtils.pointToPixel(width, targetZoom); + int scaledHeight = DPIUtil.pointToPixel(height, targetZoom); + int scaledWidth = DPIUtil.pointToPixel(width, targetZoom); /* Create a 24 bit image data with alpha channel */ final ImageData resultData = new ImageData (scaledWidth, scaledHeight, 24, new PaletteData (0xFF, 0xFF00, 0xFF0000)); resultData.alphaData = new byte [scaledWidth * scaledHeight]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java index b7ef62012b..fd56b80abc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java @@ -202,8 +202,8 @@ public boolean contains (int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); return applyUsingAnyHandle(regionHandle -> { int zoom = regionHandle.zoom(); - int xInPixels = Win32DPIUtils.pointToPixel(x, zoom); - int yInPixels = Win32DPIUtils.pointToPixel(y, zoom); + int xInPixels = DPIUtil.pointToPixel(x, zoom); + int yInPixels = DPIUtil.pointToPixel(y, zoom); return containsInPixels(regionHandle.handle(), xInPixels, yInPixels); }); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java index cf024b9d18..2f9a3c776c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java @@ -379,9 +379,9 @@ void computeRuns (GC gc) { } SCRIPT_LOGATTR logAttr = new SCRIPT_LOGATTR(); SCRIPT_PROPERTIES properties = new SCRIPT_PROPERTIES(); - int wrapIndentInPixels = Win32DPIUtils.pointToPixel(wrapIndent, getZoom(gc)); - int indentInPixels = Win32DPIUtils.pointToPixel(indent, getZoom(gc)); - int wrapWidthInPixels = Win32DPIUtils.pointToPixel(wrapWidth, getZoom(gc)); + int wrapIndentInPixels = DPIUtil.pointToPixel(wrapIndent, getZoom(gc)); + int indentInPixels = DPIUtil.pointToPixel(indent, getZoom(gc)); + int wrapWidthInPixels = DPIUtil.pointToPixel(wrapWidth, getZoom(gc)); int[] tabsInPixels = Win32DPIUtils.pointToPixel(tabs, getZoom(gc)); int lineWidth = indentInPixels, lineStart = 0, lineCount = 1; for (int i=0; i { - int scaledIconSize = Win32DPIUtils.pointToPixel(ICON_SIZE_AT_100, zoom); + int scaledIconSize = DPIUtil.pointToPixel(ICON_SIZE_AT_100, zoom); long [] hIcon = new long [1]; OS.LoadIconWithScaleDown(0, iconName, scaledIconSize, scaledIconSize, hIcon); Image image = Image.win32_new (this, SWT.ICON, hIcon[0], zoom); 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 06a5b5d988..52c6925d07 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 @@ -557,7 +557,7 @@ void setScrollbar () { */ public void setSpacing (int spacing) { checkWidget (); - setSpacingInPixels(Win32DPIUtils.pointToPixel(spacing, getZoom())); + setSpacingInPixels(DPIUtil.pointToPixel(spacing, getZoom())); } void setSpacingInPixels (int spacing) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java index 3bd4cd2f94..cce5f527a4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java @@ -182,8 +182,8 @@ void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) { long hDC = gc.handle; int headerHeightinPixels = getHeaderHeightInPixels(); int zoom = getZoom(); - int imageHeightInPixels = Win32DPIUtils.pointToPixel(imageHeight, zoom); - int imageWidthInPixels = Win32DPIUtils.pointToPixel(imageWidth, zoom); + int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, zoom); + int imageWidthInPixels = DPIUtil.pointToPixel(imageWidth, zoom); RECT rect = new RECT (); OS.SetRect (rect, x, y, x + width, y + headerHeightinPixels); @@ -307,7 +307,7 @@ public int getHeaderHeight () { int getHeaderHeightInPixels () { int headerHeightInPixels = parent.getBandHeight(); - int imageHeightInPixels = Win32DPIUtils.pointToPixel(imageHeight, getZoom()); + int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, getZoom()); int imageHeaderDiff = headerHeightInPixels - imageHeightInPixels; if (imageHeaderDiff < IMAGE_MARGIN) { headerHeightInPixels = imageHeightInPixels + IMAGE_MARGIN; @@ -376,8 +376,8 @@ void redraw (boolean all) { long parentHandle = parent.handle; int headerHeightInPixels = getHeaderHeightInPixels(); int zoom = getZoom(); - int imageHeightInPixels = Win32DPIUtils.pointToPixel(imageHeight, zoom); - int imageWidthInPixels = Win32DPIUtils.pointToPixel(imageWidth, zoom); + int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, zoom); + int imageWidthInPixels = DPIUtil.pointToPixel(imageWidth, zoom); RECT rect = new RECT (); int left = all ? x : x + width - headerHeightInPixels; OS.SetRect (rect, left, y, x + width, y + headerHeightInPixels); @@ -492,7 +492,7 @@ public void setExpanded (boolean expanded) { */ public void setHeight (int height) { checkWidget (); - setHeightInPixels(Win32DPIUtils.pointToPixel(height, getZoom())); + setHeightInPixels(DPIUtil.pointToPixel(height, getZoom())); } void setHeightInPixels (int height) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java index 225935490c..7fd85bd933 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java @@ -1359,7 +1359,7 @@ LRESULT wmMeasureChild (long wParam, long lParam) { if (parent.needsMenuCallback()) { Point point = calculateRenderedTextSize(); int menuZoom = getDisplay().isRescalingAtRuntime() ? super.getZoom() : getMonitorZoom(); - struct.itemHeight = Win32DPIUtils.pointToPixel(point.y, menuZoom); + struct.itemHeight = DPIUtil.pointToPixel(point.y, menuZoom); /* * Weirdness in Windows. Setting `HBMMENU_CALLBACK` causes * item sizes to mean something else. It seems that it is @@ -1369,7 +1369,7 @@ LRESULT wmMeasureChild (long wParam, long lParam) { * that value of 5 works well in matching text to mnemonic. */ int horizontalSpaceImage = this.image != null ? this.image.getBounds().width + IMAGE_TEXT_GAP: 0; - struct.itemWidth = Win32DPIUtils.pointToPixel(LEFT_TEXT_MARGIN + point.x - WINDOWS_OVERHEAD + horizontalSpaceImage, menuZoom); + struct.itemWidth = DPIUtil.pointToPixel(LEFT_TEXT_MARGIN + point.x - WINDOWS_OVERHEAD + horizontalSpaceImage, menuZoom); OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof); return null; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java index 0c8c6acbc2..520729cff3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java @@ -143,8 +143,8 @@ private Rectangle translateRectangleInPointsToPixels(int x, int y, int width, in monitor = getValidMonitorIfApplicable(x, y, width, height, monitor); Point topLeft = getPixelsFromPoint(monitor, x, y); int zoom = getApplicableMonitorZoom(monitor); - int widthInPixels = Win32DPIUtils.pointToPixel(width, zoom); - int heightInPixels = Win32DPIUtils.pointToPixel(height, zoom); + int widthInPixels = DPIUtil.pointToPixel(width, zoom); + int heightInPixels = DPIUtil.pointToPixel(height, zoom); return new Rectangle(topLeft.x, topLeft.y, widthInPixels, heightInPixels); } @@ -204,8 +204,8 @@ private Monitor getContainingMonitorForPoints(int x, int y, int width, int heigh for (Monitor currentMonitor : monitors) { // Obtain the rectangle in pixels per monitor for absolute comparison Point topLeftOfRectangle = getPixelsFromPoint(currentMonitor, x, y); - int widthInPixels = Win32DPIUtils.pointToPixel(width, getApplicableMonitorZoom(currentMonitor)); - int heightInPixels = Win32DPIUtils.pointToPixel(height, getApplicableMonitorZoom(currentMonitor)); + int widthInPixels = DPIUtil.pointToPixel(width, getApplicableMonitorZoom(currentMonitor)); + int heightInPixels = DPIUtil.pointToPixel(height, getApplicableMonitorZoom(currentMonitor)); Rectangle boundsInPixel = new Rectangle(topLeftOfRectangle.x, topLeftOfRectangle.y, widthInPixels, heightInPixels); Rectangle clientArea = getMonitorClientAreaInPixels(currentMonitor); Rectangle intersection = clientArea.intersection(boundsInPixel); @@ -251,15 +251,15 @@ private Monitor getContainingMonitorForPixels(int xInPixels, int yInPixels, int private Rectangle getMonitorClientAreaInPixels(Monitor monitor) { int zoom = getApplicableMonitorZoom(monitor); - int widthInPixels = Win32DPIUtils.pointToPixel(monitor.clientWidth, zoom); - int heightInPixels = Win32DPIUtils.pointToPixel(monitor.clientHeight, zoom); + int widthInPixels = DPIUtil.pointToPixel(monitor.clientWidth, zoom); + int heightInPixels = DPIUtil.pointToPixel(monitor.clientHeight, zoom); return new Rectangle(monitor.clientX, monitor.clientY, widthInPixels, heightInPixels); } private Point getPixelsFromPoint(Monitor monitor, int x, int y) { int zoom = getApplicableMonitorZoom(monitor); - int mappedX = Win32DPIUtils.pointToPixel(x - monitor.clientX, zoom) + monitor.clientX; - int mappedY = Win32DPIUtils.pointToPixel(y - monitor.clientY, zoom) + monitor.clientY; + int mappedX = DPIUtil.pointToPixel(x - monitor.clientX, zoom) + monitor.clientX; + int mappedY = DPIUtil.pointToPixel(y - monitor.clientY, zoom) + monitor.clientY; return new Point(mappedX, mappedY); } 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 85f2ea48cc..3acbaedf50 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 @@ -332,8 +332,8 @@ LRESULT WM_LBUTTONUP (long wParam, long lParam) { Rectangle bounds = event.getBounds(); if (event.doit) { if ((style & SWT.SMOOTH) != 0) { - int xInPixels = Win32DPIUtils.pointToPixel(bounds.x, getZoom()); - int yInPixels = Win32DPIUtils.pointToPixel(bounds.y, getZoom()); + int xInPixels = DPIUtil.pointToPixel(bounds.x, getZoom()); + int yInPixels = DPIUtil.pointToPixel(bounds.y, getZoom()); setBoundsInPixels (xInPixels, yInPixels, widthInPixels, heightInPixels); // widget could be disposed at this point } @@ -379,8 +379,8 @@ LRESULT WM_MOUSEMOVE (long wParam, long lParam) { if (isDisposed ()) return LRESULT.ZERO; if (event.doit) { Rectangle bounds = event.getBounds(); - lastX = Win32DPIUtils.pointToPixel(bounds.x, zoom); - lastY = Win32DPIUtils.pointToPixel(bounds.y, zoom); + lastX = DPIUtil.pointToPixel(bounds.x, zoom); + lastY = DPIUtil.pointToPixel(bounds.y, zoom); } int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; OS.RedrawWindow (hwndTrack, null, 0, flags); 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 39f87fbe19..bc380d4d38 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 @@ -1592,8 +1592,8 @@ public void setBounds(Rectangle rect) { // the WM_DPICHANGED event processing. So to avoid duplicate scaling, we always // have to scale width and height with the zoom of the original monitor (still // returned by getZoom()) here. - setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, Win32DPIUtils.pointToPixel(rect.width, getZoom()), - Win32DPIUtils.pointToPixel(rect.height, getZoom())); + setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, DPIUtil.pointToPixel(rect.width, getZoom()), + DPIUtil.pointToPixel(rect.height, getZoom())); } @Override @@ -1769,7 +1769,7 @@ public void setImeInputMode (int mode) { public void setMaximumSize (int width, int height) { checkWidget (); int zoom = getZoom(); - setMaximumSizeInPixels(Win32DPIUtils.pointToPixel(width, zoom), Win32DPIUtils.pointToPixel(height, zoom)); + setMaximumSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } /** @@ -1844,7 +1844,7 @@ void setMaximumSizeInPixels (int width, int height) { public void setMinimumSize (int width, int height) { checkWidget (); int zoom = getZoom(); - setMinimumSizeInPixels(Win32DPIUtils.pointToPixel(width, zoom), Win32DPIUtils.pointToPixel(height, zoom)); + setMinimumSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } void setMinimumSizeInPixels (int width, int height) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/SingleZoomCoordinateSystemMapper.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/SingleZoomCoordinateSystemMapper.java index 5a39ff266a..144385d8cd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/SingleZoomCoordinateSystemMapper.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/SingleZoomCoordinateSystemMapper.java @@ -55,18 +55,18 @@ public Rectangle map(Control from, Control to, Rectangle rectangle) { @Override public Point map(Control from, Control to, int x, int y) { int zoom = getZoomLevelForMapping(from, to); - x = Win32DPIUtils.pointToPixel(x, zoom); - y = Win32DPIUtils.pointToPixel(y, zoom); + x = DPIUtil.pointToPixel(x, zoom); + y = DPIUtil.pointToPixel(y, zoom); return Win32DPIUtils.pixelToPointAsLocation(display.mapInPixels(from, to, x, y), zoom); } @Override public Rectangle map(Control from, Control to, int x, int y, int width, int height) { int zoom = getZoomLevelForMapping(from, to); - x = Win32DPIUtils.pointToPixel(x, zoom); - y = Win32DPIUtils.pointToPixel(y, zoom); - width = Win32DPIUtils.pointToPixel(width, zoom); - height = Win32DPIUtils.pointToPixel(height, zoom); + x = DPIUtil.pointToPixel(x, zoom); + y = DPIUtil.pointToPixel(y, zoom); + width = DPIUtil.pointToPixel(width, zoom); + height = DPIUtil.pointToPixel(height, zoom); return Win32DPIUtils.pixelToPoint(display.mapInPixels(from, to, x, y, width, height), zoom); } @@ -105,7 +105,7 @@ public Point getCursorLocation() { @Override public void setCursorLocation(int x, int y) { int zoom = DPIUtil.getDeviceZoom(); - display.setCursorLocationInPixels(Win32DPIUtils.pointToPixel(x, zoom), Win32DPIUtils.pointToPixel(y, zoom)); + display.setCursorLocationInPixels(DPIUtil.pointToPixel(x, zoom), DPIUtil.pointToPixel(y, zoom)); } @Override 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 b3b475094d..83142154f6 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 @@ -2336,7 +2336,7 @@ public int getGridLineWidth () { } int getGridLineWidthInPixels () { - return Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom()); + return DPIUtil.pointToPixel(GRID_WIDTH, getZoom()); } /** @@ -3543,7 +3543,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long lParam, Event boolean backgroundWanted = !ignoreDrawHot || drawDrophilited || (!ignoreDrawSelection && clrSelectionBk != -1); if (backgroundWanted) { - int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom()); + int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, getZoom()); RECT pClipRect = new RECT (); OS.SetRect (pClipRect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); RECT rect = new RECT (); @@ -4859,7 +4859,7 @@ boolean setScrollWidth (TableItem item, boolean force) { if (hStateList != 0) { int [] cx = new int [1], cy = new int [1]; OS.ImageList_GetIconSize (hStateList, cx, cy); - newWidth += cx [0] + Win32DPIUtils.pointToPixel(INSET, getZoom()); + newWidth += cx [0] + DPIUtil.pointToPixel(INSET, getZoom()); } long hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0); if (hImageList != 0) { @@ -4879,7 +4879,7 @@ boolean setScrollWidth (TableItem item, boolean force) { */ newWidth++; } - newWidth += Win32DPIUtils.pointToPixel(INSET * 2, getZoom()) + Win32DPIUtils.pointToPixel(VISTA_EXTRA, getZoom()); + newWidth += DPIUtil.pointToPixel(INSET * 2, getZoom()) + DPIUtil.pointToPixel(VISTA_EXTRA, getZoom()); int oldWidth = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0); if (newWidth > oldWidth) { setScrollWidth (newWidth); @@ -5744,7 +5744,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) { OS.GetClientRect (handle, clientRect); TableItem item = _getItem (selection); RECT rect = item.getBounds (selection, 0, true, true, true); - int dragImageSizeInPixel = Win32DPIUtils.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); + int dragImageSizeInPixel = DPIUtil.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); if ((style & SWT.FULL_SELECTION) != 0) { int width = dragImageSizeInPixel; rect.left = Math.max (clientRect.left, mousePos.x - width / 2); @@ -6915,7 +6915,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) { * Sort indicator size needs to scale as per the Native Windows OS DPI level * when header is custom drawn. For more details refer bug 537097. */ - int leg = Win32DPIUtils.pointToPixel(3, nativeZoom); + int leg = DPIUtil.pointToPixel(3, nativeZoom); if (sortDirection == SWT.UP) { OS.Polyline(nmcd.hdc, new int[] {center-leg, 1+leg, center+1, 0}, 2); OS.Polyline(nmcd.hdc, new int[] {center+leg, 1+leg, center-1, 0}, 2); @@ -6961,7 +6961,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) { } } - int x = rects[i].left + Win32DPIUtils.pointToPixel(INSET + 2, getZoom()); + int x = rects[i].left + DPIUtil.pointToPixel(INSET + 2, getZoom()); if (columns[i].image != null) { GCData data = new GCData(); data.device = display; @@ -7302,9 +7302,9 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) { int zoom = getZoom(); rect = Win32DPIUtils.pixelToPoint(rect, zoom); gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom)); - x += size.x + Win32DPIUtils.pointToPixel(INSET + (pinfo.iSubItem == 0 ? -2 : 4), zoom); + x += size.x + DPIUtil.pointToPixel(INSET + (pinfo.iSubItem == 0 ? -2 : 4), zoom); } else { - x += Win32DPIUtils.pointToPixel(INSET + 2, getZoom()); + x += DPIUtil.pointToPixel(INSET + 2, getZoom()); } String string = item.getText (pinfo.iSubItem); if (string != null) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java index f8eda2e935..efa078bc4a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java @@ -432,7 +432,7 @@ public void pack () { if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); if (isDisposed () || parent.isDisposed ()) break; Rectangle bounds = event.getBounds(); - columnWidth = Math.max (columnWidth, Win32DPIUtils.pointToPixel(bounds.x + bounds.width, getZoom()) - headerRect.left); + columnWidth = Math.max (columnWidth, DPIUtil.pointToPixel(bounds.x + bounds.width, getZoom()) - headerRect.left); } } if (newFont != 0) OS.SelectObject (hDC, oldFont); @@ -846,7 +846,7 @@ public void setToolTipText (String string) { */ public void setWidth (int width) { checkWidget (); - setWidthInPixels(Win32DPIUtils.pointToPixel(width, getZoom())); + setWidthInPixels(DPIUtil.pointToPixel(width, getZoom())); } void setWidthInPixels (int width) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java index 2607e28089..87b67bed8b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java @@ -296,7 +296,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean } } if (!getImage) rect.left = rect.right; - rect.right += width + Win32DPIUtils.pointToPixel(Table.INSET * 2, getZoom()); + rect.right += width + DPIUtil.pointToPixel(Table.INSET * 2, getZoom()); } } else { if (getText) { @@ -373,7 +373,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean iconRect.top = column; iconRect.left = OS.LVIR_ICON; if (OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, iconRect) != 0) { - rect.left = iconRect.right + Win32DPIUtils.pointToPixel(Table.INSET / 2, getZoom()); + rect.left = iconRect.right + DPIUtil.pointToPixel(Table.INSET / 2, getZoom()); } } } else { @@ -400,7 +400,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean char [] buffer = string.toCharArray (); int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT; OS.DrawText (hDC, buffer, buffer.length, textRect, flags); - rect.right += textRect.right - textRect.left + Win32DPIUtils.pointToPixel(Table.INSET * 3 + 2, getZoom()); + rect.right += textRect.right - textRect.left + DPIUtil.pointToPixel(Table.INSET * 3 + 2, getZoom()); } } } @@ -696,9 +696,9 @@ Rectangle getTextBoundsInPixels (int index) { if (itemIndex == -1) return new Rectangle (0, 0, 0, 0); RECT rect = getBounds (itemIndex, index, true, false, true); rect.left += 2; - if (index != 0) rect.left += Win32DPIUtils.pointToPixel(Table.INSET, getZoom()); + if (index != 0) rect.left += DPIUtil.pointToPixel(Table.INSET, getZoom()); rect.left = Math.min (rect.left, rect.right); - rect.right = rect.right - Win32DPIUtils.pointToPixel(Table.INSET, getZoom()); + rect.right = rect.right - DPIUtil.pointToPixel(Table.INSET, getZoom()); int width = Math.max (0, rect.right - rect.left); int height = Math.max (0, rect.bottom - rect.top); return new Rectangle (rect.left, rect.top, width, height); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java index d8695b74ba..59fa20c511 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java @@ -1076,7 +1076,7 @@ public void setToolTipText (String string) { */ public void setWidth (int width) { checkWidget(); - setWidthInPixels(Win32DPIUtils.pointToPixel(width, getZoom())); + setWidthInPixels(DPIUtil.pointToPixel(width, getZoom())); } void setWidthInPixels (int width) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java index d678e7de31..1de01308bb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java @@ -358,7 +358,7 @@ public void setAutoHide (boolean autoHide) { public void setLocation (int x, int y) { checkWidget (); int zoom = getZoom(); - setLocationInPixels(Win32DPIUtils.pointToPixel(x, zoom), Win32DPIUtils.pointToPixel(y, zoom)); + setLocationInPixels(DPIUtil.pointToPixel(x, zoom), DPIUtil.pointToPixel(y, zoom)); } void setLocationInPixels (int x, int y) { 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 a215e4cce5..ebad3f7425 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 @@ -465,7 +465,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { if (explorerTheme) { if (hooks (SWT.EraseItem)) { RECT itemRect = item.getBounds (index, true, true, false, false, true, hDC); - int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom); + int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, zoom); itemRect.left -= explorerExtraInPixels; itemRect.right += explorerExtraInPixels + 1; pClipRect.left = itemRect.left; @@ -748,7 +748,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } } } - rect.left += Win32DPIUtils.pointToPixel(INSET - 1, zoom) ; + rect.left += DPIUtil.pointToPixel(INSET - 1, zoom) ; if (drawImage) { Image image = null; if (index == 0) { @@ -757,14 +757,14 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { Image [] images = item.images; if (images != null) image = images [index]; } - int inset = i != 0 ? Win32DPIUtils.pointToPixel(INSET, zoom) : 0; - int offset = i != 0 ? Win32DPIUtils.pointToPixel(INSET, zoom) : Win32DPIUtils.pointToPixel(INSET + 2, zoom); + int inset = i != 0 ? DPIUtil.pointToPixel(INSET, zoom) : 0; + int offset = i != 0 ? DPIUtil.pointToPixel(INSET, zoom) : DPIUtil.pointToPixel(INSET + 2, zoom); if (image != null) { Rectangle bounds = image.getBounds (); // Points if (size == null) size = Win32DPIUtils.pixelToPointAsSize (getImageSize (), zoom); // To Points if (!ignoreDrawForeground) { //int y1 = rect.top + (index == 0 ? (getItemHeight () - size.y) / 2 : 0); - int y1 = rect.top + Win32DPIUtils.pointToPixel((getItemHeight () - size.y) / 2, zoom); + int y1 = rect.top + DPIUtil.pointToPixel((getItemHeight () - size.y) / 2, zoom); int x1 = Math.max (rect.left, rect.left - inset + 1); GCData data = new GCData(); data.device = display; @@ -774,7 +774,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { OS.SelectClipRgn (hDC, 0); gc.dispose (); } - OS.SetRect (rect, rect.left + Win32DPIUtils.pointToPixel(size.x, zoom) + offset, rect.top, rect.right - inset, rect.bottom); + OS.SetRect (rect, rect.left + DPIUtil.pointToPixel(size.x, zoom) + offset, rect.top, rect.right - inset, rect.bottom); } else { if (i == 0) { if (OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) != 0) { @@ -1132,7 +1132,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { if ((style & SWT.FULL_SELECTION) == 0) { RECT pRect = item.getBounds (index, true, true, false, false, false, hDC); RECT pClipRect = item.getBounds (index, true, true, true, false, true, hDC); - int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom); + int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, zoom); if (measureEvent != null) { pRect.right = Math.min (pClipRect.right, boundsInPixels.x + boundsInPixels.width); } else { @@ -1209,7 +1209,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { OS.SaveDC (hDC); OS.SelectClipRgn (hDC, 0); if (explorerTheme) { - int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom()); + int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, getZoom()); itemRect.left -= explorerExtraInPixels; itemRect.right += explorerExtraInPixels; } @@ -2966,7 +2966,7 @@ public int getGridLineWidth () { } int getGridLineWidthInPixels () { - return Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom()); + return DPIUtil.pointToPixel(GRID_WIDTH, getZoom()); } /** @@ -5037,7 +5037,7 @@ void setScrollWidth (int width) { } } if (horizontalBar != null) { - horizontalBar.setIncrement (Win32DPIUtils.pointToPixel(INCREMENT, getZoom())); + horizontalBar.setIncrement (DPIUtil.pointToPixel(INCREMENT, getZoom())); horizontalBar.setPageIncrement (info.nPage); } OS.GetClientRect (hwndParent, rect); @@ -5373,7 +5373,7 @@ public void setTopItem (TreeItem item) { * In a Tree without imageList, the indent also controls the chevron (glyph) size. */ private void calculateAndApplyIndentSize() { - int indent = Win32DPIUtils.pointToPixel(DEFAULT_INDENT, nativeZoom); + int indent = DPIUtil.pointToPixel(DEFAULT_INDENT, nativeZoom); OS.SendMessage(handle, OS.TVM_SETINDENT, indent, 0); } @@ -5486,7 +5486,7 @@ public void showColumn (TreeColumn column) { SCROLLINFO info = new SCROLLINFO(); info.cbSize = SCROLLINFO.sizeof; info.fMask = OS.SIF_POS; - info.nPos = Math.max(0, headerRect.left - Win32DPIUtils.pointToPixel(INSET / 2, getZoom())); + info.nPos = Math.max(0, headerRect.left - DPIUtil.pointToPixel(INSET / 2, getZoom())); OS.SetScrollInfo(hwndParent, OS.SB_HORZ, info, true); setScrollWidth(); } else if (scrollBecauseRight) { @@ -5500,8 +5500,8 @@ public void showColumn (TreeColumn column) { // info.nPos + wideRect = headerRect.left + wideHeader // info.nPos = headerRect.left + wideHeader - wideRect info.nPos = Math.max(0, wideHeader + headerRect.left - wideRect - - Win32DPIUtils.pointToPixel(INSET / 2, getZoom()) ); - info.nPos = Math.min(rect.right - Win32DPIUtils.pointToPixel(INSET / 2, getZoom()), info.nPos); + - DPIUtil.pointToPixel(INSET / 2, getZoom()) ); + info.nPos = Math.min(rect.right - DPIUtil.pointToPixel(INSET / 2, getZoom()), info.nPos); OS.SetScrollInfo(hwndParent, OS.SB_HORZ, info, true); setScrollWidth(); @@ -6073,7 +6073,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) { RECT clientRect = new RECT (); OS.GetClientRect(handle, clientRect); RECT rect = items [0].getBounds (0, true, true, false); - int dragImageSizeInPixels = Win32DPIUtils.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); + int dragImageSizeInPixels = DPIUtil.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); if ((style & SWT.FULL_SELECTION) != 0) { int width = dragImageSizeInPixels; rect.left = Math.max (clientRect.left, mousePos.x - width / 2); @@ -7889,7 +7889,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) { * Sort indicator size needs to scale as per the Native Windows OS DPI level * when header is custom drawn. For more details refer bug 537097. */ - int leg = Win32DPIUtils.pointToPixel(3, nativeZoom); + int leg = DPIUtil.pointToPixel(3, nativeZoom); if (sortDirection == SWT.UP) { OS.Polyline(nmcd.hdc, new int[] {center-leg, 1+leg, center+1, 0}, 2); OS.Polyline(nmcd.hdc, new int[] {center+leg, 1+leg, center-1, 0}, 2); @@ -7928,7 +7928,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) { } } - int x = rects[i].left + Win32DPIUtils.pointToPixel(INSET + 2, getZoom()); + int x = rects[i].left + DPIUtil.pointToPixel(INSET + 2, getZoom()); if (columns[i].image != null) { GCData data = new GCData(); data.device = display; @@ -8246,7 +8246,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) { data.background = OS.GetBkColor (nmcd.hdc); data.font = Font.win32_new (display, hFont); GC gc = createNewGC(nmcd.hdc, data); - int x = cellRect [0].left + Win32DPIUtils.pointToPixel(INSET, getZoom()); + int x = cellRect [0].left + DPIUtil.pointToPixel(INSET, getZoom()); if (index [0] != 0) x -= gridWidth; Image image = item [0].getImage (index [0]); if (image != null || index [0] == 0) { @@ -8257,11 +8257,11 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) { Rectangle rect = image.getBounds (); // Points int zoom = getZoom(); gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(imageRect.top, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom)); - x += Win32DPIUtils.pointToPixel(INSET, getZoom()) + (index [0] == 0 ? 1 : 0); + x += DPIUtil.pointToPixel(INSET, getZoom()) + (index [0] == 0 ? 1 : 0); } x += size.x; } else { - x += Win32DPIUtils.pointToPixel(INSET, getZoom()); + x += DPIUtil.pointToPixel(INSET, getZoom()); } String string = item [0].getText (index [0]); if (string != null) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java index 5cf25c7c2d..f3c1ba6afa 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java @@ -355,7 +355,7 @@ public void pack () { Event event = parent.sendMeasureItemEvent (item, index, hDC, detail); if (isDisposed () || parent.isDisposed ()) break; Rectangle bounds = event.getBounds(); - itemRight = Win32DPIUtils.pointToPixel(bounds.x + bounds.width, getZoom()); + itemRight = DPIUtil.pointToPixel(bounds.x + bounds.width, getZoom()); } else { long hFont = item.fontHandle (index); if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); @@ -371,8 +371,8 @@ public void pack () { int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX; char [] buffer = text.toCharArray (); OS.DrawText (hDC, buffer, buffer.length, rect, flags); - int headerWidth = rect.right - rect.left + Win32DPIUtils.pointToPixel(Tree.HEADER_MARGIN, getZoom()); - if (OS.IsAppThemed ()) headerWidth += Win32DPIUtils.pointToPixel(Tree.HEADER_EXTRA, getZoom()); + int headerWidth = rect.right - rect.left + DPIUtil.pointToPixel(Tree.HEADER_MARGIN, getZoom()); + if (OS.IsAppThemed ()) headerWidth += DPIUtil.pointToPixel(Tree.HEADER_EXTRA, getZoom()); if (image != null) { Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); headerWidth += bounds.width; @@ -705,7 +705,7 @@ public void setToolTipText (String string) { */ public void setWidth (int width) { checkWidget (); - setWidthInPixels(Win32DPIUtils.pointToPixel(width, getZoom())); + setWidthInPixels(DPIUtil.pointToPixel(width, getZoom())); } void setWidthInPixels (int width) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java index 7d3a9f8099..0ea4e9bac7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java @@ -440,7 +440,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText, if (getImage && !fullImage) { if (OS.SendMessage (hwnd, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) != 0) { Point size = parent.getImageSize (); - rect.left -= size.x + Win32DPIUtils.pointToPixel(Tree.INSET, getZoom()); + rect.left -= size.x + DPIUtil.pointToPixel(Tree.INSET, getZoom()); if (!getText) rect.right = rect.left + size.x; } else { if (!getText) rect.right = rect.left; @@ -492,7 +492,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText, } if (getText) { if (fullText && clip) { - rect.left = rect.right + Win32DPIUtils.pointToPixel(Tree.INSET, getZoom()); + rect.left = rect.right + DPIUtil.pointToPixel(Tree.INSET, getZoom()); rect.right = headerRect.right; } else { String string = index == 0 ? text : strings != null ? strings [index] : null; @@ -513,10 +513,10 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText, OS.ReleaseDC (hwnd, hNewDC); } if (getImage) { - rect.right += textRect.right - textRect.left + Win32DPIUtils.pointToPixel(Tree.INSET * 3, getZoom()); + rect.right += textRect.right - textRect.left + DPIUtil.pointToPixel(Tree.INSET * 3, getZoom()); } else { - rect.left = rect.right + Win32DPIUtils.pointToPixel(Tree.INSET, getZoom()); - rect.right = rect.left + (textRect.right - textRect.left) + Win32DPIUtils.pointToPixel(Tree.INSET, getZoom()); + rect.left = rect.right + DPIUtil.pointToPixel(Tree.INSET, getZoom()); + rect.right = rect.left + (textRect.right - textRect.left) + DPIUtil.pointToPixel(Tree.INSET, getZoom()); } } } @@ -915,7 +915,7 @@ Rectangle getTextBoundsInPixels (int index) { if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); RECT rect = getBounds (index, true, false, true); rect.left = Math.min (rect.left, rect.right); - rect.right = rect.right + Win32DPIUtils.pointToPixel(Tree.INSET, getZoom()); // Add INSET margin to avoid truncation of text seen with "Segoe UI" font + rect.right = rect.right + DPIUtil.pointToPixel(Tree.INSET, getZoom()); // Add INSET margin to avoid truncation of text seen with "Segoe UI" font int width = Math.max (0, rect.right - rect.left); int height = Math.max (0, rect.bottom - rect.top); return new Rectangle (rect.left, rect.top, width, height); diff --git a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Win32DPIUtilTests.java b/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Win32DPIUtilTests.java index 7afaee3338..e8df976130 100644 --- a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Win32DPIUtilTests.java +++ b/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/Win32DPIUtilTests.java @@ -21,6 +21,7 @@ import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.DPIUtil; import org.eclipse.swt.internal.Win32DPIUtils; import org.junit.jupiter.api.Test; @@ -146,15 +147,15 @@ public void scaleUpInteger() { int valueAt150 = 8; int valueAt100 = 5; - int scaledValue = Win32DPIUtils.pointToPixel(valueAt100, 200); + int scaledValue = DPIUtil.pointToPixel(valueAt100, 200); assertEquals(valueAt200, scaledValue, "Scaling up integer to 200 failed"); scaledValue = Win32DPIUtils.pointToPixel((Device) null, valueAt100, 200); assertEquals(valueAt200, scaledValue, "Scaling up integer to 200 with device failed"); - scaledValue = Win32DPIUtils.pointToPixel(valueAt100, 150); + scaledValue = DPIUtil.pointToPixel(valueAt100, 150); assertEquals(valueAt150, scaledValue, "Scaling up integer to 150 failed"); scaledValue = Win32DPIUtils.pointToPixel((Device) null, valueAt100, 150); assertEquals(valueAt150, scaledValue, "Scaling up integer to 150 with device failed"); - scaledValue = Win32DPIUtils.pointToPixel(valueAt100, 100); + scaledValue = DPIUtil.pointToPixel(valueAt100, 100); assertSame(valueAt100, scaledValue, "Scaling up integer without zoom change failed"); scaledValue = Win32DPIUtils.pointToPixel((Device) null, valueAt100, 100); assertSame(valueAt100, scaledValue,"Scaling up integer without zoom change with device failed");