diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/WidgetWin32Tests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/WidgetWin32Tests.java index 18d1780ed2..e7222e0371 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/WidgetWin32Tests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/WidgetWin32Tests.java @@ -40,10 +40,10 @@ public void testWidgetZoomShouldChangeOnZoomLevelChange() { button.setText("Widget Test"); button.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_CYAN)); shell.open(); - assertEquals("The initial zoom is wrong", zoom, button.getZoom()); // pre-condition + assertEquals("The initial zoom is wrong", zoom, button.getAutoscalingZoom()); // pre-condition DPITestUtil.changeDPIZoom(shell, scaledZoom); assertEquals("The Zoom Level should be updated for button on zoom change event on its shell", scaledZoom, - button.getZoom()); + button.getAutoscalingZoom()); } @Test diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java index 45943a568e..ca5bb9dfd5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java @@ -18,6 +18,7 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cocoa.*; /** @@ -1992,6 +1993,21 @@ public void setModified (boolean modified) { window.setDocumentEdited (modified); } +/** + * Returns the zoom of the shell. + *
+ * Hint: The returned value is the zoom of the shell as originally considered by + * the OS and not an adjusted zoom value as considered by SWT autoscaling capabilities. + *
+ * + * @return the zoom for this shell + * + * @since 3.133 + */ +public int getZoom() { + return DPIUtil.getNativeDeviceZoom(); +} + /** * Sets the shape of the shell to the region specified * by the argument. When the argument is null, the diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 97beba00c1..f38cdaa33a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -2786,6 +2786,21 @@ public void setModified (boolean modified) { this.modified = modified; } +/** + * Returns the zoom of the shell. + *+ * Hint: The returned value is the zoom of the shell as originally considered by + * the OS and not an adjusted zoom value as considered by SWT autoscaling capabilities. + *
+ * + * @return the zoom for this shell + * + * @since 3.133 + */ +public int getZoom() { + return DPIUtil.getNativeDeviceZoom(); +} + /** * Sets the shape of the shell to the region specified * by the argument. When the argument is null, the 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 bc23c9b785..5a4e7ca575 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 @@ -138,7 +138,7 @@ void _setImage (Image image) { if (imageList != null) imageList.dispose (); imageList = null; if (image != null) { - imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getZoom()); + imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getAutoscalingZoom()); if (OS.IsWindowEnabled (handle)) { imageList.add (image); } else { @@ -147,7 +147,7 @@ void _setImage (Image image) { imageList.add (disabledImage); } BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST (); - buttonImageList.himl = imageList.getHandle(getZoom()); + buttonImageList.himl = imageList.getHandle(getAutoscalingZoom()); int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; newBits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT); if ((style & SWT.LEFT) != 0) newBits |= OS.BS_LEFT; @@ -188,7 +188,7 @@ void _setText (String text) { if ((style & SWT.RIGHT) != 0) newBits |= OS.BS_RIGHT; if (imageList != null) { BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST (); - buttonImageList.himl = imageList.getHandle(getZoom()); + buttonImageList.himl = imageList.getHandle(getAutoscalingZoom()); if (text.length () == 0) { if ((style & SWT.LEFT) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; if ((style & SWT.CENTER) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER; @@ -295,7 +295,7 @@ int computeLeftMargin () { if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) return MARGIN; int margin = 0; if (image != null && text.length () != 0) { - Rectangle bounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100); + Rectangle bounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100); margin += bounds.width + MARGIN * 2; long oldFont = 0; long hDC = OS.GetDC (handle); @@ -359,13 +359,13 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { boolean hasImage = image != null, hasText = true; if (hasImage) { if (image != null) { - Rectangle rect = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100); + Rectangle rect = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100); width = rect.width; if (hasText && text.length () != 0) { - width += DPIUtil.pointToPixel(MARGIN * 2, getZoom());; + width += DPIUtil.pointToPixel(MARGIN * 2, getAutoscalingZoom());; } height = rect.height; - extra = DPIUtil.pointToPixel(MARGIN * 2, getZoom());; + extra = DPIUtil.pointToPixel(MARGIN * 2, getAutoscalingZoom());; } } if (hasText) { @@ -379,7 +379,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { if (length == 0) { height = Math.max (height, lptm.tmHeight); } else { - extra = Math.max (DPIUtil.pointToPixel(MARGIN * 2, getZoom()), lptm.tmAveCharWidth); + extra = Math.max (DPIUtil.pointToPixel(MARGIN * 2, getAutoscalingZoom()), lptm.tmAveCharWidth); char [] buffer = text.toCharArray (); RECT rect = new RECT (); int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE; @@ -780,7 +780,7 @@ public void setAlignment (int alignment) { if ((style & SWT.RIGHT) != 0) newBits |= OS.BS_RIGHT; if (imageList != null) { BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST (); - buttonImageList.himl = imageList.getHandle(getZoom()); + buttonImageList.himl = imageList.getHandle(getAutoscalingZoom()); if (text.length () == 0) { if ((style & SWT.LEFT) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; if ((style & SWT.CENTER) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER; @@ -1035,7 +1035,7 @@ void updateImageList () { BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST (); OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, buttonImageList); if (imageList != null) imageList.dispose (); - imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getZoom()); + imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getAutoscalingZoom()); if (OS.IsWindowEnabled (handle)) { imageList.add (image); } else { @@ -1043,7 +1043,7 @@ void updateImageList () { disabledImage = new Image (display, image, SWT.IMAGE_DISABLE); imageList.add (disabledImage); } - buttonImageList.himl = imageList.getHandle(getZoom()); + buttonImageList.himl = imageList.getHandle(getAutoscalingZoom()); OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList); /* * Bug in Windows. Under certain cirumstances yet to be @@ -1392,13 +1392,13 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) { GC gc = createNewGC(nmcd.hdc, data); int margin = computeLeftMargin(); - Rectangle imageBounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100); + Rectangle imageBounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100); int imageWidth = imageBounds.width; left += (imageWidth + (isRadioOrCheck() ? 2 * MARGIN : MARGIN)); // for SWT.RIGHT_TO_LEFT right and left are inverted int x = margin + (isRadioOrCheck() ? radioOrCheckTextPadding : 3); int y = Math.max (0, (nmcd.bottom - imageBounds.height) / 2); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); gc.drawImage (image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom)); gc.dispose (); } 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 e50f166d7b..c86893f3c7 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 @@ -103,7 +103,7 @@ public Canvas (Composite parent, int style) { * @since 3.2 */ public void drawBackground (GC gc, int x, int y, int width, int height) { - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom); drawBackgroundInPixels(gc, rectangle.x, rectangle.y, rectangle.width, rectangle.height, 0, 0); } @@ -197,7 +197,7 @@ void reskinChildren (int flags) { */ public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); destX = DPIUtil.pointToPixel(destX, zoom); destY = DPIUtil.pointToPixel(destY, zoom); Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java index 0f3c71299c..c73727aca7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java @@ -119,12 +119,12 @@ long defaultFont () { */ public Rectangle getBounds () { checkWidget(); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom()); } Rectangle getBoundsInPixels () { if (image != null) { - Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); return new Rectangle (getXInPixels(), getYInPixels(), rect.width, rect.height); } if (width == 0) { @@ -223,12 +223,12 @@ public Canvas getParent () { */ public Point getSize () { checkWidget(); - return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getAutoscalingZoom()); } Point getSizeInPixels () { if (image != null) { - Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); return new Point (rect.width, rect.height); } if (width == 0) { @@ -241,19 +241,19 @@ Point getSizeInPixels () { } private int getWidthInPixels() { - return DPIUtil.pointToPixel(width, getZoom()); + return DPIUtil.pointToPixel(width, getAutoscalingZoom()); } private int getHeightInPixels() { - return DPIUtil.pointToPixel(height, getZoom()); + return DPIUtil.pointToPixel(height, getAutoscalingZoom()); } private int getXInPixels() { - return DPIUtil.pointToPixel(x, getZoom()); + return DPIUtil.pointToPixel(x, getAutoscalingZoom()); } private int getYInPixels() { - return DPIUtil.pointToPixel(y, getZoom()); + return DPIUtil.pointToPixel(y, getAutoscalingZoom()); } /** @@ -373,7 +373,7 @@ void resize () { resized = false; long hwnd = parent.handle; OS.DestroyCaret (); - long hBitmap = image != null ? Image.win32_getHandle(image, getZoom()) : 0; + long hBitmap = image != null ? Image.win32_getHandle(image, getAutoscalingZoom()) : 0; int widthInPixels = this.getWidthInPixels(); if (image == null && widthInPixels == 0) { OptionalInt systemCaretWidthInPixelsForCurrentMonitor = getSystemCaretWidthInPixelsForCurrentMonitor(); @@ -452,7 +452,7 @@ public void setBounds (Rectangle rect) { void setFocus () { long hwnd = parent.handle; long hBitmap = 0; - if (image != null) hBitmap = Image.win32_getHandle(image, getZoom()); + if (image != null) hBitmap = Image.win32_getHandle(image, getAutoscalingZoom()); int widthInPixels = this.getWidthInPixels(); if (image == null && widthInPixels == 0) { OptionalInt systemCaretWidthInPixelsForCurrentMonitor = getSystemCaretWidthInPixelsForCurrentMonitor(); 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 63d749968d..f10bde00b2 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 @@ -911,7 +911,7 @@ boolean dragDetect (long hwnd, int x, int y, boolean filter, boolean [] detect, */ public Point getCaretLocation () { checkWidget (); - return Win32DPIUtils.pixelToPointAsLocation(getCaretLocationInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsLocation(getCaretLocationInPixels(), getAutoscalingZoom()); } Point getCaretLocationInPixels () { @@ -1079,7 +1079,7 @@ public int getItemCount () { */ public int getItemHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getItemHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getItemHeightInPixels(), getAutoscalingZoom()); } int getItemHeightInPixels () { @@ -1345,7 +1345,7 @@ public String getText () { */ public int getTextHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getTextHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getTextHeightInPixels(), getAutoscalingZoom()); } int getTextHeightInPixels () { 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 fc4a8919a4..00ef86e6bd 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 @@ -229,7 +229,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { * Since computeTrim can be overridden by subclasses, we cannot * call computeTrimInPixels directly. */ - Rectangle trim = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(computeTrim (0, 0, sizeInPoints.x, sizeInPoints.y), getZoom()); + Rectangle trim = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(computeTrim (0, 0, sizeInPoints.x, sizeInPoints.y), getAutoscalingZoom()); return new Point (trim.width, trim.height); } @@ -349,7 +349,7 @@ int applyThemeBackground () { */ public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom); offsetX = DPIUtil.pointToPixel(offsetX, zoom); offsetY = DPIUtil.pointToPixel(offsetY, zoom); @@ -1532,7 +1532,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { Event event = new Event (); event.gc = gc; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle.OfFloat(ps.left, ps.top, width, height), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle.OfFloat(ps.left, ps.top, width, height), getAutoscalingZoom())); sendEvent (SWT.Paint, event); if (data.focusDrawn && !isDisposed ()) updateUIState (); gc.dispose (); @@ -1603,7 +1603,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { Event event = new Event (); event.gc = gc; RECT rect = null; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); if ((style & SWT.NO_MERGE_PAINTS) != 0 && OS.GetRgnBox (sysRgn, rect = new RECT ()) == OS.COMPLEXREGION) { int nBytes = OS.GetRegionData (sysRgn, 0, null); int [] lpRgnData = new int [nBytes / 4]; @@ -1700,7 +1700,7 @@ LRESULT WM_PRINTCLIENT (long wParam, long lParam) { GC gc = createNewGC(wParam, data); Event event = new Event (); event.gc = gc; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getAutoscalingZoom())); sendEvent (SWT.Paint, event); event.gc = null; gc.dispose (); 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 4b8c7ad85d..257b147534 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 @@ -796,7 +796,7 @@ public boolean dragDetect (Event event) { checkWidget (); if (event == null) error (SWT.ERROR_NULL_ARGUMENT); Point loc = event.getLocation(); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); return dragDetect (event.button, event.count, event.stateMask, DPIUtil.pointToPixel(loc.x, zoom), DPIUtil.pointToPixel(loc.y, zoom)); } @@ -839,7 +839,7 @@ public boolean dragDetect (Event event) { public boolean dragDetect (MouseEvent event) { checkWidget (); if (event == null) error (SWT.ERROR_NULL_ARGUMENT); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); return dragDetect (event.button, event.count, event.stateMask, DPIUtil.pointToPixel(event.x, zoom), DPIUtil.pointToPixel(event.y, zoom)); // To Pixels } @@ -962,7 +962,7 @@ void fillImageBackground (long hDC, Control control, RECT rect, int tx, int ty) if (control != null) { Image image = control.backgroundImage; if (image != null) { - control.drawImageBackground (hDC, handle, Image.win32_getHandle(image, getZoom()), rect, tx, ty); + control.drawImageBackground (hDC, handle, Image.win32_getHandle(image, getAutoscalingZoom()), rect, tx, ty); } } } @@ -1174,7 +1174,7 @@ int getBackgroundPixel () { */ public int getBorderWidth () { checkWidget (); - return DPIUtil.pixelToPoint(getBorderWidthInPixels (), getZoom()); + return DPIUtil.pixelToPoint(getBorderWidthInPixels (), getAutoscalingZoom()); } int getBorderWidthInPixels () { @@ -2024,7 +2024,7 @@ void mapEvent (long hwnd, Event event) { if (hwnd != handle) { POINT point = new POINT (); Point loc = event.getLocation(); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); point.x = DPIUtil.pointToPixel(loc.x, zoom); point.y = DPIUtil.pointToPixel(loc.y, zoom); OS.MapWindowPoints (hwnd, handle, point, 1); @@ -2486,7 +2486,7 @@ public void redraw () { */ public void redraw (int x, int y, int width, int height, boolean all) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); if (width <= 0 || height <= 0) return; Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom); @@ -2989,7 +2989,7 @@ boolean sendGestureEvent (GESTUREINFO gi) { int type = 0; Point globalPt = new Point(gi.x, gi.y); Point point = toControlInPixels(globalPt.x, globalPt.y); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(point.x, zoom), DPIUtil.pixelToPoint(point.y, zoom)); switch (gi.dwID) { case OS.GID_ZOOM: @@ -3070,7 +3070,7 @@ void sendTouchEvent (TOUCHINPUT touchInput []) { POINT pt = new POINT (); OS.GetCursorPos (pt); OS.ScreenToClient (handle, pt); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(pt.x, zoom), DPIUtil.pixelToPoint(pt.y, zoom)); Touch [] touches = new Touch [touchInput.length]; Monitor monitor = getMonitor (); @@ -3097,7 +3097,7 @@ void setBackground () { if (control.backgroundImage != null) { Shell shell = getShell (); shell.releaseBrushes (); - setBackgroundImage (Image.win32_getHandle(control.backgroundImage, getZoom())); + setBackgroundImage (Image.win32_getHandle(control.backgroundImage, getAutoscalingZoom())); } else { setBackgroundPixel (control.background == -1 ? control.defaultBackground() : control.background); } @@ -3834,7 +3834,7 @@ public void setRegion (Region region) { long hRegion = 0; if (region != null) { hRegion = OS.CreateRectRgn (0, 0, 0, 0); - OS.CombineRgn (hRegion, Region.win32_getHandle(region, getZoom()), hRegion, OS.RGN_OR); + OS.CombineRgn (hRegion, Region.win32_getHandle(region, getAutoscalingZoom()), hRegion, OS.RGN_OR); } OS.SetWindowRgn (handle, hRegion, true); this.region = region; @@ -4123,7 +4123,7 @@ public Point toControl (int x, int y) { checkWidget (); Point displayPointInPixels = getDisplay().translateToDisplayCoordinates(new Point(x, y)); final Point controlPointInPixels = toControlInPixels(displayPointInPixels.x, displayPointInPixels.y); - return Win32DPIUtils.pixelToPointAsLocation(controlPointInPixels, getZoom()); + return Win32DPIUtils.pixelToPointAsLocation(controlPointInPixels, getAutoscalingZoom()); } Point toControlInPixels (int x, int y) { @@ -4181,7 +4181,7 @@ public Point toControl (Point point) { */ public Point toDisplay (int x, int y) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Point displayPointInPixels = toDisplayInPixels(DPIUtil.pointToPixel(x, zoom), DPIUtil.pointToPixel(y, zoom)); return getDisplay().translateFromDisplayCoordinates(displayPointInPixels); } @@ -4723,7 +4723,7 @@ void updateBackgroundColor () { void updateBackgroundImage () { Control control = findBackgroundControl (); Image image = control != null ? control.backgroundImage : backgroundImage; - setBackgroundImage (image != null ? Image.win32_getHandle(image, getZoom()) : 0); + setBackgroundImage (image != null ? Image.win32_getHandle(image, getAutoscalingZoom()) : 0); } void updateBackgroundMode () { @@ -4872,11 +4872,11 @@ GC createNewGC(long hDC, GCData data) { } @Override -int getZoom() { +int getAutoscalingZoom() { if (autoScaleDisabled) { return 100; } - return super.getZoom(); + return super.getAutoscalingZoom(); } int getShellZoom() { @@ -4888,16 +4888,16 @@ int getShellZoom() { int computeGetBoundsZoom() { if (parent != null && !autoScaleDisabled) { - return parent.getZoom(); + return parent.getAutoscalingZoom(); } - return getZoom(); + return getAutoscalingZoom(); } int computeBoundsZoom() { if (parent != null) { - return parent.getZoom(); + return parent.getAutoscalingZoom(); } - return getZoom(); + return getAutoscalingZoom(); } abstract TCHAR windowClass (); @@ -5789,7 +5789,7 @@ LRESULT WM_TABLET_FLICK (long wParam, long lParam) { event.yDirection = 1; break; } - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(fPoint.x, zoom), DPIUtil.pixelToPoint(fPoint.y, zoom)); event.type = SWT.Gesture; event.detail = SWT.GESTURE_SWIPE; @@ -5927,7 +5927,7 @@ LRESULT wmColorChild (long wParam, long lParam) { RECT rect = new RECT (); OS.GetClientRect (handle, rect); long hwnd = control.handle; - long hBitmap = Image.win32_getHandle(control.backgroundImage, getZoom()); + long hBitmap = Image.win32_getHandle(control.backgroundImage, getAutoscalingZoom()); OS.MapWindowPoints (handle, hwnd, rect, 2); POINT lpPoint = new POINT (); OS.GetWindowOrgEx (wParam, lpPoint); 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 2fb22468a4..62239223e9 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 @@ -413,7 +413,7 @@ int getMargin (int index) { } if ((style & SWT.FLAT) == 0) { if (!isLastItemOfRow (index)) { - margin += DPIUtil.pointToPixel(SEPARATOR_WIDTH, getZoom()); + margin += DPIUtil.pointToPixel(SEPARATOR_WIDTH, getAutoscalingZoom()); } } return margin; @@ -550,7 +550,7 @@ public int getItemCount () { Point [] sizes = getItemSizesInPixels(); if (sizes != null) { for (int i = 0; i < sizes.length; i++) { - sizes[i] = Win32DPIUtils.pixelToPointAsSize(sizes[i], getZoom()); + sizes[i] = Win32DPIUtils.pixelToPointAsSize(sizes[i], getAutoscalingZoom()); } } return sizes; @@ -810,7 +810,7 @@ public void setItemLayout (int [] itemOrder, int [] wrapIndices, Point [] sizes) if (sizes == null) error (SWT.ERROR_NULL_ARGUMENT); Point [] sizesInPoints = new Point [sizes.length]; for (int i = 0; i < sizes.length; i++) { - sizesInPoints[i] = Win32DPIUtils.pointToPixelAsSize(sizes[i], getZoom()); + sizesInPoints[i] = Win32DPIUtils.pointToPixelAsSize(sizes[i], getAutoscalingZoom()); } setItemLayoutInPixels (itemOrder, wrapIndices, sizesInPoints); } @@ -1174,7 +1174,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) { if (item != null) { Event event = new Event(); event.detail = SWT.ARROW; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); if ((style & SWT.VERTICAL) != 0) { event.setLocation(DPIUtil.pixelToPoint(lpnm.right, zoom), DPIUtil.pixelToPoint(lpnm.top, zoom)); } else { @@ -1227,7 +1227,7 @@ void handleDPIChange(Event event, float scalingFactor) { item.setControl(control); } - Point preferredControlSize = item.getControl().computeSizeInPixels(new Point(SWT.DEFAULT, SWT.DEFAULT), getZoom(), true); + Point preferredControlSize = item.getControl().computeSizeInPixels(new Point(SWT.DEFAULT, SWT.DEFAULT), getAutoscalingZoom(), true); int controlWidth = preferredControlSize.x; int controlHeight = preferredControlSize.y; if (((style & SWT.VERTICAL) != 0)) { 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 7988f7ebb7..f803a3985a 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 @@ -185,11 +185,11 @@ protected void checkSubclass () { */ public Point computeSize (int wHint, int hHint) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); return Win32DPIUtils.pixelToPointAsSufficientlyLargeSize(computeSizeInPixels(new Point(wHint, hHint)), zoom); } Point computeSizeInPixels (Point sizeHintInPoints) { - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Point sizeHintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(sizeHintInPoints, zoom); int index = parent.indexOf (this); if (index == -1) return new Point (0, 0); @@ -223,7 +223,7 @@ void destroyWidget () { */ public Rectangle getBounds () { checkWidget (); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom()); } Rectangle getBoundsInPixels () { @@ -383,7 +383,7 @@ public void setControl (Control control) { */ public Point getPreferredSize () { checkWidget (); - return Win32DPIUtils.pixelToPointAsSize(getPreferredSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getPreferredSizeInPixels(), getAutoscalingZoom()); } Point getPreferredSizeInPixels () { @@ -414,7 +414,7 @@ Point getPreferredSizeInPixels () { */ public void setPreferredSize (int width, int height) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); setPreferredSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } @@ -464,7 +464,7 @@ void setPreferredSizeInPixels (int width, int height) { public void setPreferredSize (Point size) { checkWidget (); if (size == null) error(SWT.ERROR_NULL_ARGUMENT); - size = Win32DPIUtils.pointToPixelAsSize(size, getZoom()); + size = Win32DPIUtils.pointToPixelAsSize(size, getAutoscalingZoom()); setPreferredSizeInPixels(size.x, size.y); } @@ -483,7 +483,7 @@ public void setPreferredSize (Point size) { */ public Point getSize () { checkWidget (); - return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getAutoscalingZoom()); } Point getSizeInPixels() { @@ -525,7 +525,7 @@ Point getSizeInPixels() { */ public void setSize (int width, int height) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); setSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } @@ -592,7 +592,7 @@ void setSizeInPixels (int width, int height) { public void setSize (Point size) { checkWidget (); if (size == null) error(SWT.ERROR_NULL_ARGUMENT); - size = Win32DPIUtils.pointToPixelAsSize(size, getZoom()); + size = Win32DPIUtils.pointToPixelAsSize(size, getAutoscalingZoom()); setSizeInPixels(size.x, size.y); } @@ -611,7 +611,7 @@ public void setSize (Point size) { */ public Point getMinimumSize () { checkWidget (); - return Win32DPIUtils.pixelToPointAsSize(getMinimumSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getMinimumSizeInPixels(), getAutoscalingZoom()); } Point getMinimumSizeInPixels () { @@ -644,7 +644,7 @@ Point getMinimumSizeInPixels () { */ public void setMinimumSize (int width, int height) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); setMinimumSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } @@ -695,7 +695,7 @@ void setMinimumSizeInPixels (int width, int height) { public void setMinimumSize (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - size = Win32DPIUtils.pointToPixelAsSize(size, getZoom()); + size = Win32DPIUtils.pointToPixelAsSize(size, getAutoscalingZoom()); setMinimumSizeInPixels(size.x, size.y); } 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 74c73b0f83..b290f3783a 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 @@ -389,7 +389,7 @@ public int getItemCount () { */ public int getSpacing () { checkWidget (); - return DPIUtil.pixelToPoint(getSpacingInPixels (), getZoom()); + return DPIUtil.pixelToPoint(getSpacingInPixels (), getAutoscalingZoom()); } int getSpacingInPixels () { @@ -559,7 +559,7 @@ void setScrollbar () { */ public void setSpacing (int spacing) { checkWidget (); - setSpacingInPixels(DPIUtil.pointToPixel(spacing, getZoom())); + setSpacingInPixels(DPIUtil.pointToPixel(spacing, getAutoscalingZoom())); } void setSpacingInPixels (int spacing) { @@ -787,7 +787,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { if (hooks (SWT.Paint) || filters (SWT.Paint)) { Event event = new Event (); event.gc = gc; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, width, height), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, width, height), getAutoscalingZoom())); sendEvent (SWT.Paint, event); event.gc = null; } 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 cce5f527a4..a510df48ce 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 @@ -181,7 +181,7 @@ private void drawChevron (long hDC, RECT rect) { void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) { long hDC = gc.handle; int headerHeightinPixels = getHeaderHeightInPixels(); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, zoom); int imageWidthInPixels = DPIUtil.pointToPixel(imageWidth, zoom); @@ -302,12 +302,12 @@ public boolean getExpanded () { */ public int getHeaderHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getHeaderHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getHeaderHeightInPixels(), getAutoscalingZoom()); } int getHeaderHeightInPixels () { int headerHeightInPixels = parent.getBandHeight(); - int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, getZoom()); + int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, getAutoscalingZoom()); int imageHeaderDiff = headerHeightInPixels - imageHeightInPixels; if (imageHeaderDiff < IMAGE_MARGIN) { headerHeightInPixels = imageHeightInPixels + IMAGE_MARGIN; @@ -327,7 +327,7 @@ int getHeaderHeightInPixels () { */ public int getHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getHeightInPixels(), getAutoscalingZoom()); } int getHeightInPixels () { @@ -375,7 +375,7 @@ boolean isHover (int x, int y) { void redraw (boolean all) { long parentHandle = parent.handle; int headerHeightInPixels = getHeaderHeightInPixels(); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); int imageHeightInPixels = DPIUtil.pointToPixel(imageHeight, zoom); int imageWidthInPixels = DPIUtil.pointToPixel(imageWidth, zoom); RECT rect = new RECT (); @@ -492,7 +492,7 @@ public void setExpanded (boolean expanded) { */ public void setHeight (int height) { checkWidget (); - setHeightInPixels(DPIUtil.pointToPixel(height, getZoom())); + setHeightInPixels(DPIUtil.pointToPixel(height, getAutoscalingZoom())); } void setHeightInPixels (int height) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java index 1c66255e3a..38ab4f874f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java @@ -567,7 +567,7 @@ LRESULT WM_LBUTTONDOWN (long wParam, long lParam) { if (OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (char [])null, 0) > 0) { Event event = new Event (); event.detail = SWT.COMPOSITION_OFFSET; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(OS.GET_X_LPARAM (lParam), zoom), DPIUtil.pixelToPoint(OS.GET_Y_LPARAM (lParam), zoom)); sendEvent (SWT.ImeComposition, event); int offset = event.index; 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 7910970b3c..d5903741a7 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 @@ -148,7 +148,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { return new Point (width, height); } if (isImageMode) { - Rectangle rect = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100); + Rectangle rect = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100); width += rect.width; height += rect.height; } else { @@ -554,7 +554,7 @@ void wmDrawChildImage(DRAWITEMSTRUCT struct) { int height = struct.bottom - struct.top; if (width == 0 || height == 0) return; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Rectangle imageRect = Win32DPIUtils.scaleBounds(image.getBounds(), zoom, 100); int x = 0; 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 03fd6875c3..65cce194f3 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 @@ -474,7 +474,7 @@ public int getItemCount () { */ public int getItemHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getItemHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getItemHeightInPixels(), getAutoscalingZoom()); } int getItemHeightInPixels () { @@ -1564,7 +1564,7 @@ void updateMenuLocation (Event event) { y = Math.min (y, clientArea.y + clientArea.height); } Point pt = toDisplayInPixels (x, y); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(pt.x, zoom), DPIUtil.pixelToPoint(pt.y, zoom)); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java index 96221188c9..999eb975f3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java @@ -1314,7 +1314,7 @@ void updateBackground () { hBrush = 0; if (backgroundImage != null) - hBrush = OS.CreatePatternBrush (Image.win32_getHandle(backgroundImage, getZoom())); + hBrush = OS.CreatePatternBrush (Image.win32_getHandle(backgroundImage, getAutoscalingZoom())); else if (background != -1) hBrush = OS.CreateSolidBrush (background); 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 42a77983c9..918aa4b1ea 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 @@ -1288,7 +1288,7 @@ private int getMonitorZoom() { private int getMenuZoom() { if (getDisplay().isRescalingAtRuntime()) { - return super.getZoom(); + return super.getAutoscalingZoom(); } else { return DPIUtil.getZoomForAutoscaleProperty(getMonitorZoom()); } @@ -1361,7 +1361,7 @@ LRESULT wmMeasureChild (long wParam, long lParam) { if ((parent.style & SWT.BAR) != 0) { if (parent.needsMenuCallback()) { Point point = calculateRenderedTextSize(); - int menuZoom = getDisplay().isRescalingAtRuntime() ? super.getZoom() : getMonitorZoom(); + int menuZoom = getDisplay().isRescalingAtRuntime() ? super.getAutoscalingZoom() : getMonitorZoom(); struct.itemHeight = DPIUtil.pointToPixel(point.y, menuZoom); /* * Weirdness in Windows. Setting `HBMMENU_CALLBACK` causes @@ -1380,7 +1380,7 @@ LRESULT wmMeasureChild (long wParam, long lParam) { int width = 0, height = 0; if (image != null) { - Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); width = rect.width; height = rect.height; } else { @@ -1402,7 +1402,7 @@ LRESULT wmMeasureChild (long wParam, long lParam) { if ((lpcmi.dwStyle & OS.MNS_CHECKORBMP) == 0) { for (MenuItem item : parent.getItems ()) { if (item.image != null) { - Rectangle rect = Win32DPIUtils.pointToPixel(item.image.getBounds(), getZoom()); + Rectangle rect = Win32DPIUtils.pointToPixel(item.image.getBounds(), getAutoscalingZoom()); width = Math.max (width, rect.width); } } 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 70daf5a83d..542470e1c1 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 @@ -49,14 +49,14 @@ public Point map(Control from, Control to, int x, int y) { if (from == null) { Point mappedPointInpixels = display.mapInPixels(from, to, getPixelsFromPoint(to.getShell().getMonitor(), x, y)); - mappedPointInPoints = Win32DPIUtils.pixelToPointAsLocation(mappedPointInpixels, to.getZoom()); + mappedPointInPoints = Win32DPIUtils.pixelToPointAsLocation(mappedPointInpixels, to.getAutoscalingZoom()); } else if (to == null) { - Point mappedPointInpixels = display.mapInPixels(from, to, Win32DPIUtils.pointToPixelAsLocation(new Point(x, y), from.getZoom())); + Point mappedPointInpixels = display.mapInPixels(from, to, Win32DPIUtils.pointToPixelAsLocation(new Point(x, y), from.getAutoscalingZoom())); mappedPointInPoints = getPointFromPixels(from.getShell().getMonitor(), mappedPointInpixels.x, mappedPointInpixels.y); } else { - Point mappedPointInpixels = display.mapInPixels(from, to, Win32DPIUtils.pointToPixelAsLocation(new Point(x, y), from.getZoom())); - mappedPointInPoints = Win32DPIUtils.pixelToPointAsLocation(mappedPointInpixels, to.getZoom()); + Point mappedPointInpixels = display.mapInPixels(from, to, Win32DPIUtils.pointToPixelAsLocation(new Point(x, y), from.getAutoscalingZoom())); + mappedPointInPoints = Win32DPIUtils.pixelToPointAsLocation(mappedPointInpixels, to.getAutoscalingZoom()); } return mappedPointInPoints; } @@ -68,17 +68,17 @@ public Rectangle map(Control from, Control to, int x, int y, int width, int heig Rectangle mappedRectangleInPixels = display.mapInPixels(from, to, translateRectangleInPointsToPixels(x, y, width, height, to.getShell().getMonitor())); - mappedRectangleInPoints = Win32DPIUtils.pixelToPoint(mappedRectangleInPixels, to.getZoom()); + mappedRectangleInPoints = Win32DPIUtils.pixelToPoint(mappedRectangleInPixels, to.getAutoscalingZoom()); } else if (to == null) { Rectangle mappedRectangleInPixels = display.mapInPixels(from, to, - Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), from.getZoom())); + Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), from.getAutoscalingZoom())); mappedRectangleInPoints = translateRectangleInPixelsToPoints(mappedRectangleInPixels.x, mappedRectangleInPixels.y, mappedRectangleInPixels.width, mappedRectangleInPixels.height, from.getShell().getMonitor()); } else { Rectangle mappedRectangleInPixels = display.mapInPixels(from, to, - Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), from.getZoom())); - mappedRectangleInPoints = Win32DPIUtils.pixelToPoint(mappedRectangleInPixels, to.getZoom()); + Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), from.getAutoscalingZoom())); + mappedRectangleInPoints = Win32DPIUtils.pixelToPoint(mappedRectangleInPixels, to.getAutoscalingZoom()); } return mappedRectangleInPoints; } 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 17c71a1cba..e2d15f7d6d 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 @@ -246,7 +246,7 @@ LRESULT WM_KEYDOWN (long wParam, long lParam) { OS.SetCursorPos (cursorPt.x, cursorPt.y); Event event = new Event (); - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(newX, newY, width, height), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(newX, newY, width, height), getAutoscalingZoom())); sendSelectionEvent (SWT.Selection, event, true); if (isDisposed ()) return LRESULT.ZERO; if (event.doit) { @@ -286,7 +286,7 @@ LRESULT WM_LBUTTONDOWN (long wParam, long lParam) { /* The event must be sent because doit flag is used */ Event event = new Event (); - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(lastX, lastY, width, height), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(lastX, lastY, width, height), getAutoscalingZoom())); if ((style & SWT.SMOOTH) == 0) { event.detail = SWT.DRAG; } @@ -294,7 +294,7 @@ LRESULT WM_LBUTTONDOWN (long wParam, long lParam) { if (isDisposed ()) return LRESULT.ZERO; /* Draw the banding rectangle */ - Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()); + Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()); if (event.doit) { dragging = true; lastX = boundsInPixels.x; @@ -327,15 +327,15 @@ LRESULT WM_LBUTTONUP (long wParam, long lParam) { /* The event must be sent because doit flag is used */ Event event = new Event (); - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(lastX, lastY, widthInPixels, heightInPixels), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(lastX, lastY, widthInPixels, heightInPixels), getAutoscalingZoom())); drawBand (lastX, lastY, widthInPixels, heightInPixels); sendSelectionEvent (SWT.Selection, event, true); if (isDisposed ()) return result; Rectangle bounds = event.getBounds(); if (event.doit) { if ((style & SWT.SMOOTH) != 0) { - int xInPixels = DPIUtil.pointToPixel(bounds.x, getZoom()); - int yInPixels = DPIUtil.pointToPixel(bounds.y, getZoom()); + int xInPixels = DPIUtil.pointToPixel(bounds.x, getAutoscalingZoom()); + int yInPixels = DPIUtil.pointToPixel(bounds.y, getAutoscalingZoom()); setBoundsInPixels (xInPixels, yInPixels, widthInPixels, heightInPixels); // widget could be disposed at this point } @@ -370,7 +370,7 @@ LRESULT WM_MOUSEMOVE (long wParam, long lParam) { if (newX == lastX && newY == lastY) return result; drawBand (lastX, lastY, width, height); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); /* The event must be sent because doit flag is used */ Event event = new Event (); event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(newX, newY, width, height), zoom)); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java index 9ae76ae41a..eef0212dfc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java @@ -355,7 +355,7 @@ public int getSelection () { */ public Point getSize () { checkWidget(); - return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getAutoscalingZoom()); } Point getSizeInPixels () { @@ -412,7 +412,7 @@ public int getThumb () { */ public Rectangle getThumbBounds () { checkWidget(); - return Win32DPIUtils.pixelToPoint(getThumbBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getThumbBoundsInPixels(), getAutoscalingZoom()); } Rectangle getThumbBoundsInPixels () { @@ -458,7 +458,7 @@ Rectangle getThumbBoundsInPixels () { */ public Rectangle getThumbTrackBounds () { checkWidget(); - return Win32DPIUtils.pixelToPoint(getThumbTrackBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getThumbTrackBoundsInPixels(), getAutoscalingZoom()); } Rectangle getThumbTrackBoundsInPixels () { 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 6006f339b0..17ce730c52 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 @@ -120,7 +120,7 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) { */ public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Rectangle rectangle = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(new Rectangle(x, y, width, height), zoom); return Win32DPIUtils.pixelToPointWithSufficientlyLargeSize(computeTrimInPixels(rectangle.x, rectangle.y, rectangle.width, rectangle.height), zoom); } @@ -210,7 +210,7 @@ void destroyScrollBar (int type) { */ public Rectangle getClientArea () { checkWidget (); - return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), getAutoscalingZoom()); } Rectangle getClientAreaInPixels () { 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 f1005c7299..5f2427c651 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 @@ -1060,7 +1060,7 @@ public boolean getMaximized () { */ public Point getMaximumSize () { checkWidget (); - return Win32DPIUtils.pixelToPointAsSize(getMaximumSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getMaximumSizeInPixels(), getAutoscalingZoom()); } Point getMaximumSizeInPixels () { @@ -1101,7 +1101,7 @@ Point getMaximumSizeInPixels () { */ public Point getMinimumSize () { checkWidget (); - return Win32DPIUtils.pixelToPointAsSize(getMinimumSizeInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsSize(getMinimumSizeInPixels(), getAutoscalingZoom()); } Point getMinimumSizeInPixels () { @@ -1233,6 +1233,21 @@ public ToolBar getToolBar() { return null; } +/** + * Returns the zoom of the shell. + *+ * Hint: The returned value is the zoom of the shell as originally considered by + * the OS and not an adjusted zoom value as considered by SWT autoscaling capabilities. + *
+ * + * @return the zoom for this shell + * + * @since 3.133 + */ +public int getZoom() { + return DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(handle)); +} + @Override Composite findDeferredControl () { return layoutCount > 0 ? this : null; @@ -1631,8 +1646,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, DPIUtil.pointToPixel(rect.width, getZoom()), - DPIUtil.pointToPixel(rect.height, getZoom())); + setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, DPIUtil.pointToPixel(rect.width, getAutoscalingZoom()), + DPIUtil.pointToPixel(rect.height, getAutoscalingZoom())); } @Override @@ -1807,7 +1822,7 @@ public void setImeInputMode (int mode) { */ public void setMaximumSize (int width, int height) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); setMaximumSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } @@ -1836,7 +1851,7 @@ public void setMaximumSize (int width, int height) { public void setMaximumSize (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - size = Win32DPIUtils.pointToPixelAsSize(size, getZoom()); + size = Win32DPIUtils.pointToPixelAsSize(size, getAutoscalingZoom()); setMaximumSizeInPixels(size.x, size.y); } @@ -1882,7 +1897,7 @@ void setMaximumSizeInPixels (int width, int height) { */ public void setMinimumSize (int width, int height) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); setMinimumSizeInPixels(DPIUtil.pointToPixel(width, zoom), DPIUtil.pointToPixel(height, zoom)); } @@ -1931,7 +1946,7 @@ void setMinimumSizeInPixels (int width, int height) { public void setMinimumSize (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - size = Win32DPIUtils.pointToPixelAsSize(size, getZoom()); + size = Win32DPIUtils.pointToPixelAsSize(size, getAutoscalingZoom()); setMinimumSizeInPixels(size.x, size.y); } @@ -2811,12 +2826,12 @@ LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) { @Override int computeBoundsZoom() { - return getZoom(); + return getAutoscalingZoom(); } @Override int computeGetBoundsZoom() { - return getZoom(); + return getAutoscalingZoom(); } } 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 7a4b7b5357..7fdb28106c 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 @@ -33,9 +33,9 @@ private int getZoomLevelForMapping(Control from, Control to) { display.error(SWT.ERROR_INVALID_ARGUMENT); } if (to != null) { - return to.getZoom(); + return to.getAutoscalingZoom(); } - return from.getZoom(); + return from.getAutoscalingZoom(); } @Override 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 7e5f0c90b8..fee2a38eff 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 @@ -456,9 +456,9 @@ int imageIndex (Image image) { if (image == null) return -1; if (imageList == null) { Rectangle boundsInPoints = image.getBounds(); - imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getZoom()); + imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); int index = imageList.add (image); - long hImageList = imageList.getHandle(getZoom()); + long hImageList = imageList.getHandle(getAutoscalingZoom()); OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList); return index; } @@ -838,8 +838,8 @@ void updateOrientation () { if (imageList != null) { Point sizeInPoints = imageList.getImageSize(); display.releaseImageList (imageList); - imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, this.getZoom()); - long hImageList = imageList.getHandle(getZoom()); + imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, this.getAutoscalingZoom()); + long hImageList = imageList.getHandle(getAutoscalingZoom()); OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList); TCITEM tcItem = new TCITEM (); tcItem.mask = OS.TCIF_IMAGE; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java index 7153b569a2..b4901f8bc3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java @@ -191,7 +191,7 @@ public Control getControl () { */ public Rectangle getBounds () { checkWidget(); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom()); } Rectangle getBoundsInPixels() { 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 2047bc492b..9c6a4b6d29 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 @@ -2338,7 +2338,7 @@ public int getGridLineWidth () { } int getGridLineWidthInPixels () { - return DPIUtil.pointToPixel(GRID_WIDTH, getZoom()); + return DPIUtil.pointToPixel(GRID_WIDTH, getAutoscalingZoom()); } /** @@ -2395,7 +2395,7 @@ private int getHeaderForegroundPixel() { */ public int getHeaderHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getHeaderHeightInPixels (), getZoom()); + return DPIUtil.pixelToPoint(getHeaderHeightInPixels (), getAutoscalingZoom()); } int getHeaderHeightInPixels () { @@ -2476,7 +2476,7 @@ public TableItem getItem (int index) { public TableItem getItem (Point point) { checkWidget (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - return getItemInPixels (Win32DPIUtils.pointToPixelAsLocation(point, getZoom())); + return getItemInPixels (Win32DPIUtils.pointToPixelAsLocation(point, getAutoscalingZoom())); } TableItem getItemInPixels (Point point) { @@ -2576,7 +2576,7 @@ public int getItemCount () { */ public int getItemHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getItemHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getItemHeightInPixels(), getAutoscalingZoom()); } int getItemHeightInPixels () { @@ -2832,7 +2832,7 @@ boolean hitTestSelection (int index, int x, int y) { long hFont = item.fontHandle (0); if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); Event event = sendMeasureItemEvent (item, index, 0, hDC); - if (Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()).contains (x, y)) result = true; + if (Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()).contains (x, y)) result = true; if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); if (newFont != 0) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); @@ -2850,10 +2850,10 @@ int imageIndex (Image image, int column) { } if (imageList == null) { Rectangle boundsInPoints = image.getBounds(); - imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getZoom()); + imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); int index = imageList.indexOf (image); if (index == -1) index = imageList.add (image); - long hImageList = imageList.getHandle(getZoom()); + long hImageList = imageList.getHandle(getAutoscalingZoom()); /* * Bug in Windows. Making any change to an item that * changes the item height of a table while the table @@ -2870,7 +2870,7 @@ int imageIndex (Image image, int column) { } OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList); if (headerImageList != null) { - long hHeaderImageList = headerImageList.getHandle(getZoom()); + long hHeaderImageList = headerImageList.getHandle(getAutoscalingZoom()); OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hHeaderImageList); } fixCheckboxImageList (false); @@ -2890,10 +2890,10 @@ int imageIndexHeader (Image image) { if (image == null) return OS.I_IMAGENONE; if (headerImageList == null) { Rectangle boundsInPoints = image.getBounds(); - headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getZoom()); + headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); int index = headerImageList.indexOf (image); if (index == -1) index = headerImageList.add (image); - long hImageList = headerImageList.getHandle(getZoom()); + long hImageList = headerImageList.getHandle(getAutoscalingZoom()); OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hImageList); return index; } @@ -3484,7 +3484,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long lParam, Event if (drawHot) event.detail |= SWT.HOT; if (drawSelected) event.detail |= SWT.SELECTED; if (drawBackground) event.detail |= SWT.BACKGROUND; - Rectangle bounds = Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getZoom()); + Rectangle bounds = Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getAutoscalingZoom()); event.setBounds (bounds); gc.setClipping (bounds); sendEvent (SWT.EraseItem, event); @@ -3530,7 +3530,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long lParam, Event RECT textRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, false, fullText, false, hDC); if ((style & SWT.FULL_SELECTION) == 0) { if (measureEvent != null) { - Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(measureEvent.getBounds(), getZoom()); + Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(measureEvent.getBounds(), getAutoscalingZoom()); textRect.right = Math.min (cellRect.right, boundsInPixels.x + boundsInPixels.width); } if (!ignoreDrawFocus) { @@ -3545,7 +3545,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long lParam, Event boolean backgroundWanted = !ignoreDrawHot || drawDrophilited || (!ignoreDrawSelection && clrSelectionBk != -1); if (backgroundWanted) { - int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, getZoom()); + int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, getAutoscalingZoom()); RECT pClipRect = new RECT (); OS.SetRect (pClipRect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); RECT rect = new RECT (); @@ -3567,7 +3567,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long lParam, Event rect.right += explorerExtraInPixels; pClipRect.right += explorerExtraInPixels; } - long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getZoom()); + long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getAutoscalingZoom()); int iStateId = selected ? OS.LISS_SELECTED : OS.LISS_HOT; if (OS.GetFocus () != handle && selected && !drawHot) iStateId = OS.LISS_SELECTEDNOTFOCUS; if (drawDrophilited) iStateId = OS.LISS_SELECTED; @@ -3606,7 +3606,7 @@ Event sendEraseItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT event.index = column; event.gc = gc; event.detail |= SWT.FOREGROUND; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getAutoscalingZoom())); //gc.setClipping (event.x, event.y, event.width, event.height); sendEvent (SWT.EraseItem, event); event.gc = null; @@ -3627,7 +3627,7 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long hDC) { event.item = item; event.gc = gc; event.index = column; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getAutoscalingZoom())); boolean drawSelected = false; if (OS.IsWindowEnabled (handle)) { LVITEM lvItem = new LVITEM (); @@ -3650,7 +3650,7 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long hDC) { gc.dispose (); OS.RestoreDC (hDC, nSavedDC); if (!isDisposed () && !item.isDisposed ()) { - Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()); + Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()); if (columnCount == 0) { int width = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0); if (boundsInPixels.x + boundsInPixels.width > width) setScrollWidth (boundsInPixels.x + boundsInPixels.width); @@ -3927,11 +3927,11 @@ void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) { if (drawHot) event.detail |= SWT.HOT; if (drawSelected) event.detail |= SWT.SELECTED; if (drawBackground) event.detail |= SWT.BACKGROUND; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getAutoscalingZoom())); RECT cellRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC); int cellWidth = cellRect.right - cellRect.left; int cellHeight = cellRect.bottom - cellRect.top; - gc.setClipping (Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellWidth, cellHeight), getZoom())); + gc.setClipping (Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellWidth, cellHeight), getAutoscalingZoom())); sendEvent (SWT.PaintItem, event); if (data.focusDrawn) focusRect = null; event.gc = null; @@ -3955,7 +3955,7 @@ Event sendPaintItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT event.index = column; event.gc = gc; event.detail |= SWT.FOREGROUND; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getAutoscalingZoom())); //gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight); sendEvent (SWT.PaintItem, event); event.gc = null; @@ -4881,7 +4881,7 @@ boolean setScrollWidth (TableItem item, boolean force) { */ newWidth++; } - newWidth += INSET * 2 + DPIUtil.pointToPixel(VISTA_EXTRA, getZoom()); + newWidth += INSET * 2 + DPIUtil.pointToPixel(VISTA_EXTRA, getAutoscalingZoom()); int oldWidth = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0); if (newWidth > oldWidth) { setScrollWidth (newWidth); @@ -5127,7 +5127,7 @@ void setTableEmpty () { OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList); OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0); if (headerImageList != null) { - long hHeaderImageList = headerImageList.getHandle(getZoom()); + long hHeaderImageList = headerImageList.getHandle(getAutoscalingZoom()); long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hHeaderImageList); } @@ -5541,7 +5541,7 @@ void updateMenuLocation (Event event) { y = Math.min (y, clientArea.y + clientArea.height); } Point pt = toDisplayInPixels (x, y); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(pt.x, zoom), DPIUtil.pixelToPoint(pt.y, zoom)); } @@ -5579,7 +5579,7 @@ void updateOrientation () { if (imageList != null) { Point sizeInPoints = imageList.getImageSize(); display.releaseImageList (imageList); - imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); + imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0); for (int i = 0; i < count; i++) { TableItem item = _getItem (i, false); @@ -5591,14 +5591,14 @@ void updateOrientation () { } } } - long hImageList = imageList.getHandle(getZoom()); + long hImageList = imageList.getHandle(getAutoscalingZoom()); OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList); } if (hwndHeader != 0) { if (headerImageList != null) { Point sizeInPoints = headerImageList.getImageSize(); display.releaseImageList (headerImageList); - headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); + headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); if (columns != null) { for (int i = 0; i < columns.length; i++) { TableColumn column = columns [i]; @@ -5619,7 +5619,7 @@ void updateOrientation () { } } } - long hHeaderImageList = headerImageList.getHandle(getZoom()); + long hHeaderImageList = headerImageList.getHandle(getAutoscalingZoom()); OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hHeaderImageList); } } @@ -5746,7 +5746,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 = DPIUtil.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); + int dragImageSizeInPixel = DPIUtil.pointToPixel(DRAG_IMAGE_SIZE, getAutoscalingZoom()); if ((style & SWT.FULL_SELECTION) != 0) { int width = dragImageSizeInPixel; rect.left = Math.max (clientRect.left, mousePos.x - width / 2); @@ -6968,10 +6968,10 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) { GCData data = new GCData(); data.device = display; GC gc = createNewGC(nmcd.hdc, data); - int y = Math.max (0, (nmcd.bottom - Win32DPIUtils.pointToPixel(columns[i].image.getBounds(), getZoom()).height) / 2); - int zoom = getZoom(); + int y = Math.max (0, (nmcd.bottom - Win32DPIUtils.pointToPixel(columns[i].image.getBounds(), getAutoscalingZoom()).height) / 2); + int zoom = getAutoscalingZoom(); gc.drawImage (columns[i].image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom)); - x += Win32DPIUtils.pointToPixel(columns[i].image.getBounds(), getZoom()).width + 12; + x += Win32DPIUtils.pointToPixel(columns[i].image.getBounds(), getAutoscalingZoom()).width + 12; gc.dispose (); } @@ -7234,7 +7234,7 @@ private LRESULT positionTooltip(NMHDR hdr, long lParam) { private RECT getItemBounds(LVHITTESTINFO pinfo, TableItem item, long hDC) { Event event = sendMeasureItemEvent(item, pinfo.iItem, pinfo.iSubItem, hDC); RECT itemRect = new RECT(); - Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()); + Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()); OS.SetRect(itemRect, boundsInPixels.x, boundsInPixels.y, boundsInPixels.x + boundsInPixels.width, boundsInPixels.y + boundsInPixels.height); return itemRect; @@ -7297,11 +7297,11 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) { if (pinfo.iSubItem != 0) x -= gridWidth; Image image = item.getImage (pinfo.iSubItem); if (image != null) { - Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); RECT imageRect = item.getBounds (pinfo.iItem, pinfo.iSubItem, false, true, false, false, hDC); - Point size = imageList == null ? new Point (rect.width, rect.height) : Win32DPIUtils.pointToPixelAsSize(imageList.getImageSize(), getZoom()); + Point size = imageList == null ? new Point (rect.width, rect.height) : Win32DPIUtils.pointToPixelAsSize(imageList.getImageSize(), getAutoscalingZoom()); int y = imageRect.top + Math.max (0, (imageRect.bottom - imageRect.top - size.y) / 2); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); gc.drawImage (image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom)); x += size.x + INSET + (pinfo.iSubItem == 0 ? -2 : 4); } else { 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 55637aa9cb..f173046ab1 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 @@ -305,7 +305,7 @@ public String getToolTipText () { */ public int getWidth () { checkWidget (); - return DPIUtil.pixelToPoint(getWidthInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getWidthInPixels(), getAutoscalingZoom()); } int getWidthInPixels () { @@ -401,12 +401,12 @@ public void pack () { long hwnd = parent.handle; int oldWidth = (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0); TCHAR buffer = new TCHAR (parent.getCodePage (), text, true); - int headerWidth = (int) (OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Win32DPIUtils.pointToPixel(Table.HEADER_MARGIN, getZoom())); - if (OS.IsAppThemed ()) headerWidth += Win32DPIUtils.pointToPixel(Table.HEADER_EXTRA, getZoom()); + int headerWidth = (int) (OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Win32DPIUtils.pointToPixel(Table.HEADER_MARGIN, getAutoscalingZoom())); + if (OS.IsAppThemed ()) headerWidth += Win32DPIUtils.pointToPixel(Table.HEADER_EXTRA, getAutoscalingZoom()); boolean hasHeaderImage = false; if (image != null) { hasHeaderImage = true; - Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); headerWidth += bounds.width; long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0); int margin = (int)OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0); @@ -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, DPIUtil.pointToPixel(bounds.x + bounds.width, getZoom()) - headerRect.left); + columnWidth = Math.max (columnWidth, DPIUtil.pointToPixel(bounds.x + bounds.width, getAutoscalingZoom()) - 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(DPIUtil.pointToPixel(width, getZoom())); + setWidthInPixels(DPIUtil.pointToPixel(width, getAutoscalingZoom())); } 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 89167efe54..bac7e17b94 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 @@ -214,7 +214,7 @@ public Color getBackground (int index) { */ public Rectangle getBounds () { checkWidget(); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom()); } Rectangle getBoundsInPixels () { @@ -240,7 +240,7 @@ Rectangle getBoundsInPixels () { */ public Rectangle getBounds (int index) { checkWidget(); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(index), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(index), getAutoscalingZoom()); } Rectangle getBoundsInPixels (int index) { @@ -586,7 +586,7 @@ public Image getImage (int index) { */ public Rectangle getImageBounds (int index) { checkWidget(); - return Win32DPIUtils.pixelToPoint(getImageBoundsInPixels(index), getZoom()); + return Win32DPIUtils.pixelToPoint(getImageBoundsInPixels(index), getAutoscalingZoom()); } Rectangle getImageBoundsInPixels (int index) { @@ -687,7 +687,7 @@ public String getText (int index) { */ public Rectangle getTextBounds (int index) { checkWidget(); - return Win32DPIUtils.pixelToPoint(getTextBoundsInPixels(index), getZoom()); + return Win32DPIUtils.pixelToPoint(getTextBoundsInPixels(index), getAutoscalingZoom()); } Rectangle getTextBoundsInPixels (int index) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java index c450f0bc06..2f212b1fe1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java @@ -473,11 +473,11 @@ void updateImage () { long hIcon = 0; switch (overlayImage.type) { case SWT.BITMAP: - image2 = Display.createIcon (overlayImage, getZoom()); - hIcon = Image.win32_getHandle(image2, getZoom()); + image2 = Display.createIcon (overlayImage, getAutoscalingZoom()); + hIcon = Image.win32_getHandle(image2, getAutoscalingZoom()); break; case SWT.ICON: - hIcon = Image.win32_getHandle(overlayImage, getZoom()); + hIcon = Image.win32_getHandle(overlayImage, getAutoscalingZoom()); break; } parent.mTaskbarList3.SetOverlayIcon(shell.handle, hIcon, 0); 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 d2399d764d..ba5ae2b23a 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 @@ -986,7 +986,7 @@ public int getCaretLineNumber () { */ public Point getCaretLocation () { checkWidget (); - return Win32DPIUtils.pixelToPointAsLocation(getCaretLocationInPixels(), getZoom()); + return Win32DPIUtils.pixelToPointAsLocation(getCaretLocationInPixels(), getAutoscalingZoom()); } Point getCaretLocationInPixels () { @@ -1211,7 +1211,7 @@ public String getLineDelimiter () { */ public int getLineHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getLineHeightInPixels (), getZoom()); + return DPIUtil.pixelToPoint(getLineHeightInPixels (), getAutoscalingZoom()); } int getLineHeightInPixels () { @@ -1554,7 +1554,7 @@ public int getTopIndex () { */ public int getTopPixel () { checkWidget (); - return DPIUtil.pixelToPoint(getTopPixelInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getTopPixelInPixels(), getAutoscalingZoom()); } int getTopPixelInPixels () { @@ -2493,7 +2493,7 @@ int untranslateOffset (int offset) { @Override void updateMenuLocation (Event event) { Point pointInPixels = display.mapInPixels (this, null, getCaretLocationInPixels ()); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(pointInPixels.x, zoom), DPIUtil.pixelToPoint(pointInPixels.y + getLineHeightInPixels (), zoom)); } 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 076bc0272f..9cdb484cff 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 @@ -571,7 +571,7 @@ public ToolItem getItem (int index) { public ToolItem getItem (Point point) { checkWidget (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - return getItemInPixels(Win32DPIUtils.pointToPixelAsLocation(point, getZoom())); + return getItemInPixels(Win32DPIUtils.pointToPixelAsLocation(point, getAutoscalingZoom())); } ToolItem getItemInPixels (Point point) { @@ -1052,7 +1052,7 @@ void setDisabledImageList (ImageList imageList) { long hImageList = 0; if ((disabledImageList = imageList) != null) { hImageList = OS.SendMessage(handle, OS.TB_GETDISABLEDIMAGELIST, 0, 0); - long newImageList = disabledImageList.getHandle(getZoom()); + long newImageList = disabledImageList.getHandle(getAutoscalingZoom()); if (hImageList == newImageList) return; hImageList = newImageList; } @@ -1091,7 +1091,7 @@ void setHotImageList (ImageList imageList) { long hImageList = 0; if ((hotImageList = imageList) != null) { hImageList = OS.SendMessage(handle, OS.TB_GETHOTIMAGELIST, 0, 0); - long newImageList = hotImageList.getHandle(getZoom()); + long newImageList = hotImageList.getHandle(getAutoscalingZoom()); if (hImageList == newImageList) return; hImageList = newImageList; } @@ -1104,7 +1104,7 @@ void setImageList (ImageList imageList) { long hImageList = 0; if ((this.imageList = imageList) != null) { hImageList = OS.SendMessage(handle, OS.TB_GETIMAGELIST, 0, 0); - long newImageList = imageList.getHandle(getZoom()); + long newImageList = imageList.getHandle(getAutoscalingZoom()); if (hImageList == newImageList) return; hImageList = newImageList; } @@ -1274,9 +1274,9 @@ void updateOrientation () { super.updateOrientation (); if (imageList != null) { Point sizeInPoints = imageList.getImageSize(); - ImageList newImageList = display.getImageListToolBar (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); - ImageList newHotImageList = display.getImageListToolBarHot (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); - ImageList newDisabledImageList = display.getImageListToolBarDisabled (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); + ImageList newImageList = display.getImageListToolBar (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); + ImageList newHotImageList = display.getImageListToolBarHot (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); + ImageList newDisabledImageList = display.getImageListToolBarDisabled (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); TBBUTTONINFO info = new TBBUTTONINFO (); info.cbSize = TBBUTTONINFO.sizeof; info.dwMask = OS.TBIF_IMAGE; @@ -1302,9 +1302,9 @@ void updateOrientation () { display.releaseToolImageList (imageList); display.releaseToolHotImageList (hotImageList); display.releaseToolDisabledImageList (disabledImageList); - OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, newImageList.getHandle(getZoom())); - OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, newHotImageList.getHandle(getZoom())); - OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, newDisabledImageList.getHandle(getZoom())); + OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, newImageList.getHandle(getAutoscalingZoom())); + OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, newHotImageList.getHandle(getAutoscalingZoom())); + OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, newDisabledImageList.getHandle(getAutoscalingZoom())); imageList = newImageList; hotImageList = newHotImageList; disabledImageList = newDisabledImageList; @@ -1651,7 +1651,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) { int index = (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmtb.iItem, 0); RECT rect = new RECT (); OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(rect.left, zoom), DPIUtil.pixelToPoint(rect.bottom, zoom)); child.sendSelectionEvent (SWT.Selection, event, false); } 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 59fa20c511..34cf05e720 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 @@ -235,7 +235,7 @@ void destroyWidget () { */ public Rectangle getBounds () { checkWidget(); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom()); } Rectangle getBoundsInPixels () { @@ -448,7 +448,7 @@ public String getToolTipText () { */ public int getWidth () { checkWidget(); - return DPIUtil.pixelToPoint(getWidthInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getWidthInPixels(), getAutoscalingZoom()); } int getWidthInPixels () { @@ -1076,7 +1076,7 @@ public void setToolTipText (String string) { */ public void setWidth (int width) { checkWidget(); - setWidthInPixels(DPIUtil.pointToPixel(width, getZoom())); + setWidthInPixels(DPIUtil.pointToPixel(width, getAutoscalingZoom())); } void setWidthInPixels (int width) { @@ -1106,13 +1106,13 @@ void updateImages (boolean enabled) { Rectangle boundsInPoints = image.getBounds(); int listStyle = parent.style & SWT.RIGHT_TO_LEFT; if (imageList == null) { - imageList = display.getImageListToolBar (listStyle, boundsInPoints.width, boundsInPoints.height, getZoom()); + imageList = display.getImageListToolBar (listStyle, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); } if (disabledImageList == null) { - disabledImageList = display.getImageListToolBarDisabled (listStyle, boundsInPoints.width, boundsInPoints.height, getZoom()); + disabledImageList = display.getImageListToolBarDisabled (listStyle, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); } if (hotImageList == null) { - hotImageList = display.getImageListToolBarHot (listStyle, boundsInPoints.width, boundsInPoints.height, getZoom()); + hotImageList = display.getImageListToolBarHot (listStyle, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); } Image disabled = disabledImage; if (disabledImage == null) { 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 1de01308bb..9555b97868 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 @@ -357,7 +357,7 @@ public void setAutoHide (boolean autoHide) { */ public void setLocation (int x, int y) { checkWidget (); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); setLocationInPixels(DPIUtil.pointToPixel(x, zoom), DPIUtil.pointToPixel(y, zoom)); } @@ -393,7 +393,7 @@ void setLocationInPixels (int x, int y) { public void setLocation (Point location) { checkWidget (); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); - location = Win32DPIUtils.pointToPixelAsLocation(location, getZoom()); + location = Win32DPIUtils.pointToPixelAsLocation(location, getAutoscalingZoom()); setLocationInPixels(location.x, location.y); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java index 975b426f0a..9554b24c8f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java @@ -405,7 +405,7 @@ void drawRectangles (Rectangle [] rects, boolean stippled) { checkWidget(); Rectangle [] result = getRectanglesInPixels(); for (int i = 0; i < result.length; i++) { - result[i] = Win32DPIUtils.pixelToPoint(result[i], getZoom()); + result[i] = Win32DPIUtils.pixelToPoint(result[i], getAutoscalingZoom()); } return result; } @@ -847,7 +847,7 @@ public void setRectangles (Rectangle [] rectangles) { Rectangle [] rectanglesInPixels = new Rectangle [rectangles.length]; for (int i = 0; i < rectangles.length; i++) { if (parent != null) { - rectanglesInPixels [i] = Win32DPIUtils.pointToPixel (rectangles [i], getZoom()); + rectanglesInPixels [i] = Win32DPIUtils.pointToPixel (rectangles [i], getAutoscalingZoom()); } else { rectanglesInPixels [i] = display.translateToDisplayCoordinates(rectangles[i]); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java index 1e21372106..0498981c9a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java @@ -457,11 +457,11 @@ public void setImage (Image image) { if (icon != null) { switch (icon.type) { case SWT.BITMAP: - image2 = Display.createIcon (image, getZoom()); - hIcon = Image.win32_getHandle(image2, getZoom()); + image2 = Display.createIcon (image, getAutoscalingZoom()); + hIcon = Image.win32_getHandle(image2, getAutoscalingZoom()); break; case SWT.ICON: - hIcon = Image.win32_getHandle(icon, getZoom()); + hIcon = Image.win32_getHandle(icon, getAutoscalingZoom()); break; } } 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 788de297fe..85d09cdb9c 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 @@ -416,7 +416,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { if ((style & SWT.FULL_SELECTION) != 0 || findImageControl () != null || ignoreDrawSelection || explorerTheme) { OS.SetBkMode (hDC, OS.TRANSPARENT); } - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); boolean selected = isItemSelected (nmcd); boolean hot = explorerTheme && (nmcd.uItemState & OS.CDIS_HOT) != 0; if (OS.IsWindowEnabled (handle)) { @@ -496,7 +496,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } } draw = false; - long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getZoom()); + long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getAutoscalingZoom()); int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect); @@ -644,7 +644,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } } } - Rectangle bounds = Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getZoom()); + Rectangle bounds = Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getAutoscalingZoom()); event.setBounds (bounds); gc.setClipping (bounds); sendEvent (SWT.EraseItem, event); @@ -708,7 +708,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { backgroundRect = selectionRect; } } - long hTheme = OS.OpenThemeData(handle, Display.TREEVIEW, getZoom()); + long hTheme = OS.OpenThemeData(handle, Display.TREEVIEW, getAutoscalingZoom()); int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, backgroundRect); @@ -861,7 +861,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } } } - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getAutoscalingZoom())); RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC); int cellWidth = cellRect.right - cellRect.left; int cellHeight = cellRect.bottom - cellRect.top; @@ -1028,7 +1028,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { Rectangle boundsInPixels = null; if (hooks (SWT.MeasureItem)) { measureEvent = sendMeasureItemEvent (item, index, hDC, selected ? SWT.SELECTED : 0); - boundsInPixels = Win32DPIUtils.pointToPixel(measureEvent.getBounds(), getZoom()); + boundsInPixels = Win32DPIUtils.pointToPixel(measureEvent.getBounds(), getAutoscalingZoom()); if (isDisposed () || item.isDisposed ()) return null; } selectionForeground = -1; @@ -1082,7 +1082,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } } } - Rectangle bounds = Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getZoom()); + Rectangle bounds = Win32DPIUtils.pixelToPoint(new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getAutoscalingZoom()); event.setBounds (bounds); gc.setClipping (bounds); sendEvent (SWT.EraseItem, event); @@ -1126,7 +1126,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { selectionForeground = clrText = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT); } if (explorerTheme) { - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); 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); @@ -1139,7 +1139,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } pRect.left -= explorerExtraInPixels; pClipRect.left -= explorerExtraInPixels; - long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getZoom()); + long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getAutoscalingZoom()); int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect); @@ -1207,7 +1207,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { OS.SaveDC (hDC); OS.SelectClipRgn (hDC, 0); if (explorerTheme) { - int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, getZoom()); + int explorerExtraInPixels = DPIUtil.pointToPixel(EXPLORER_EXTRA, getAutoscalingZoom()); itemRect.left -= explorerExtraInPixels; itemRect.right += explorerExtraInPixels; } @@ -2806,7 +2806,7 @@ boolean findCell (int x, int y, TreeItem [] item, int [] index, RECT [] cellRect int detail = (state & OS.TVIS_SELECTED) != 0 ? SWT.SELECTED : 0; Event event = sendMeasureItemEvent (item [0], order [index [0]], hDC, detail); if (isDisposed () || item [0].isDisposed ()) break; - Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()); + Rectangle boundsInPixels = Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()); itemRect [0] = new RECT (); itemRect [0].left = boundsInPixels.x; itemRect [0].right = boundsInPixels.x + boundsInPixels.width; @@ -2966,7 +2966,7 @@ public int getGridLineWidth () { } int getGridLineWidthInPixels () { - return DPIUtil.pointToPixel(GRID_WIDTH, getZoom()); + return DPIUtil.pointToPixel(GRID_WIDTH, getAutoscalingZoom()); } /** @@ -3023,7 +3023,7 @@ private int getHeaderForegroundPixel() { */ public int getHeaderHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getHeaderHeightInPixels (), getZoom()); + return DPIUtil.pixelToPoint(getHeaderHeightInPixels (), getAutoscalingZoom()); } int getHeaderHeightInPixels () { @@ -3060,7 +3060,7 @@ public boolean getHeaderVisible () { } Point getImageSize () { - if (imageList != null) return Win32DPIUtils.pointToPixelAsSize(imageList.getImageSize(), getZoom()); + if (imageList != null) return Win32DPIUtils.pointToPixelAsSize(imageList.getImageSize(), getAutoscalingZoom()); return new Point (0, getItemHeightInPixels ()); } @@ -3289,7 +3289,7 @@ TreeItem getItem (NMTVCUSTOMDRAW nmcd) { public TreeItem getItem (Point point) { checkWidget (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - return getItemInPixels(Win32DPIUtils.pointToPixelAsLocation(point, getZoom())); + return getItemInPixels(Win32DPIUtils.pointToPixelAsLocation(point, getAutoscalingZoom())); } TreeItem getItemInPixels (Point point) { @@ -3363,7 +3363,7 @@ int getItemCount (long hItem) { */ public int getItemHeight () { checkWidget (); - return DPIUtil.pixelToPoint(getItemHeightInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getItemHeightInPixels(), getAutoscalingZoom()); } int getItemHeightInPixels () { @@ -3732,7 +3732,7 @@ boolean hitTestSelection (long hItem, int x, int y) { int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED); int detail = (state & OS.TVIS_SELECTED) != 0 ? SWT.SELECTED : 0; Event event = sendMeasureItemEvent (item, order [index [0]], hDC, detail); - if (Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()).contains (x, y)) result = true; + if (Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()).contains (x, y)) result = true; if (newFont != 0) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); // if (isDisposed () || item.isDisposed ()) return false; @@ -3743,7 +3743,7 @@ int imageIndex (Image image, int index) { if (image == null) return OS.I_IMAGENONE; if (imageList == null) { Rectangle boundsInPoints = image.getBounds(); - imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getZoom()); + imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); } int imageIndex = imageList.indexOf (image); if (imageIndex == -1) imageIndex = imageList.add (image); @@ -3753,7 +3753,7 @@ int imageIndex (Image image, int index) { * times, Windows does work making this operation slow. The fix * is to test for the same image list before setting the new one. */ - long hImageList = imageList.getHandle(getZoom()); + long hImageList = imageList.getHandle(getAutoscalingZoom()); long hOldImageList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0); if (hOldImageList != hImageList) { OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList); @@ -3767,10 +3767,10 @@ int imageIndexHeader (Image image) { if (image == null) return OS.I_IMAGENONE; if (headerImageList == null) { Rectangle boundsInPoints = image.getBounds(); - headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getZoom()); + headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, boundsInPoints.width, boundsInPoints.height, getAutoscalingZoom()); int index = headerImageList.indexOf (image); if (index == -1) index = headerImageList.add (image); - long hImageList = headerImageList.getHandle(getZoom()); + long hImageList = headerImageList.getHandle(getAutoscalingZoom()); if (hwndHeader != 0) { OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hImageList); } @@ -4532,7 +4532,7 @@ Event sendEraseItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT c event.index = column; event.gc = gc; event.detail |= SWT.FOREGROUND; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top), getAutoscalingZoom())); //gc.setClipping (event.x, event.y, event.width, event.height); sendEvent (SWT.EraseItem, event); event.gc = null; @@ -4553,14 +4553,14 @@ Event sendMeasureItemEvent (TreeItem item, int index, long hDC, int detail) { event.item = item; event.gc = gc; event.index = index; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getAutoscalingZoom())); event.detail = detail; sendEvent (SWT.MeasureItem, event); event.gc = null; gc.dispose (); OS.RestoreDC (hDC, nSavedDC); if (isDisposed () || item.isDisposed ()) return null; - Rectangle rect = Win32DPIUtils.pointToPixel(event.getBounds(), getZoom()); + Rectangle rect = Win32DPIUtils.pointToPixel(event.getBounds(), getAutoscalingZoom()); if (hwndHeader != 0) { if (columnCount == 0) { if (rect.x + rect.width > scrollWidth) { @@ -4588,7 +4588,7 @@ Event sendPaintItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT i event.index = column; event.gc = gc; event.detail |= SWT.FOREGROUND; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top), getAutoscalingZoom())); //gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight); sendEvent (SWT.PaintItem, event); event.gc = null; @@ -5037,7 +5037,7 @@ void setScrollWidth (int width) { } } if (horizontalBar != null) { - horizontalBar.setIncrement (DPIUtil.pointToPixel(INCREMENT, getZoom())); + horizontalBar.setIncrement (DPIUtil.pointToPixel(INCREMENT, getAutoscalingZoom())); horizontalBar.setPageIncrement (info.nPage); } OS.GetClientRect (hwndParent, rect); @@ -5731,7 +5731,7 @@ void updateImageList () { * times, Windows does work making this operation slow. The fix * is to test for the same image list before setting the new one. */ - long hImageList = i == items.length ? 0 : imageList.getHandle(getZoom()); + long hImageList = i == items.length ? 0 : imageList.getHandle(getAutoscalingZoom()); long hOldImageList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0); if (hImageList != hOldImageList) { OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList); @@ -5754,7 +5754,7 @@ void updateMenuLocation (Event event) { y = Math.min (y, clientArea.y + clientArea.height); } Point pt = toDisplayInPixels (x, y); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(pt.x, zoom), DPIUtil.pixelToPoint(pt.y, zoom)); } @@ -5795,7 +5795,7 @@ void updateOrientation () { if (imageList != null) { Point sizeInPoints = imageList.getImageSize(); display.releaseImageList (imageList); - imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); + imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); for (TreeItem item : items) { if (item != null) { Image image = item.image; @@ -5805,14 +5805,14 @@ void updateOrientation () { } } } - long hImageList = imageList.getHandle(getZoom()); + long hImageList = imageList.getHandle(getAutoscalingZoom()); OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList); } if (hwndHeader != 0) { if (headerImageList != null) { Point sizeInPoints = headerImageList.getImageSize(); display.releaseImageList (headerImageList); - headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getZoom()); + headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, sizeInPoints.x, sizeInPoints.y, getAutoscalingZoom()); if (columns != null) { for (int i = 0; i < columns.length; i++) { TreeColumn column = columns[i]; @@ -5833,7 +5833,7 @@ void updateOrientation () { } } } - long hImageListHeader = headerImageList.getHandle(getZoom()); + long hImageListHeader = headerImageList.getHandle(getAutoscalingZoom()); OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hImageListHeader); } } @@ -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 = DPIUtil.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); + int dragImageSizeInPixels = DPIUtil.pointToPixel(DRAG_IMAGE_SIZE, getAutoscalingZoom()); if ((style & SWT.FULL_SELECTION) != 0) { int width = dragImageSizeInPixels; rect.left = Math.max (clientRect.left, mousePos.x - width / 2); @@ -7155,7 +7155,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { if (hooksPaint) { Event event = new Event (); event.gc = gc; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(ps.left, ps.top, ps.right - ps.left, ps.bottom - ps.top), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(ps.left, ps.top, ps.right - ps.left, ps.bottom - ps.top), getAutoscalingZoom())); sendEvent (SWT.Paint, event); // widget could be disposed at this point event.gc = null; @@ -7933,7 +7933,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) { GCData data = new GCData(); data.device = display; GC gc = createNewGC(nmcd.hdc, data); - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); Rectangle imageBounds = Win32DPIUtils.scaleBounds(columns[i].image.getBounds(), zoom, 100); int y = Math.max (0, (nmcd.bottom - imageBounds.height) / 2); gc.drawImage (columns[i].image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom)); @@ -8254,7 +8254,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) { RECT imageRect = item [0].getBounds (index [0], false, true, false, false, false, hDC); if (imageList == null) size.x = imageRect.right - imageRect.left; if (image != null) { - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); gc.drawImage (image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(imageRect.top, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom)); x += INSET + (index [0] == 0 ? 1 : 0); } 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 f3c1ba6afa..ada40a1745 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 @@ -307,7 +307,7 @@ public String getToolTipText () { */ public int getWidth () { checkWidget (); - return DPIUtil.pixelToPoint(getWidthInPixels(), getZoom()); + return DPIUtil.pixelToPoint(getWidthInPixels(), getAutoscalingZoom()); } int getWidthInPixels () { @@ -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 = DPIUtil.pointToPixel(bounds.x + bounds.width, getZoom()); + itemRight = DPIUtil.pointToPixel(bounds.x + bounds.width, getAutoscalingZoom()); } else { long hFont = item.fontHandle (index); if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); @@ -371,10 +371,10 @@ 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 + DPIUtil.pointToPixel(Tree.HEADER_MARGIN, getZoom()); - if (OS.IsAppThemed ()) headerWidth += DPIUtil.pointToPixel(Tree.HEADER_EXTRA, getZoom()); + int headerWidth = rect.right - rect.left + DPIUtil.pointToPixel(Tree.HEADER_MARGIN, getAutoscalingZoom()); + if (OS.IsAppThemed ()) headerWidth += DPIUtil.pointToPixel(Tree.HEADER_EXTRA, getAutoscalingZoom()); if (image != null) { - Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom()); + Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); headerWidth += bounds.width; int margin = 0; if (hwndHeader != 0) { @@ -524,7 +524,7 @@ void setImage (Image image, boolean sort, boolean right) { hdItem.mask &= ~OS.HDI_IMAGE; hdItem.fmt &= ~OS.HDF_IMAGE; hdItem.fmt |= OS.HDF_BITMAP; - hdItem.hbm = Image.win32_getHandle(image, getZoom()); + hdItem.hbm = Image.win32_getHandle(image, getAutoscalingZoom()); } else { hdItem.mask &= ~OS.HDI_BITMAP; hdItem.fmt &= ~OS.HDF_BITMAP; @@ -705,7 +705,7 @@ public void setToolTipText (String string) { */ public void setWidth (int width) { checkWidget (); - setWidthInPixels(DPIUtil.pointToPixel(width, getZoom())); + setWidthInPixels(DPIUtil.pointToPixel(width, getAutoscalingZoom())); } 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 e4b1dc8a62..97153a39c1 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 @@ -371,7 +371,7 @@ public Color getBackground (int index) { */ public Rectangle getBounds () { checkWidget (); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom()); } Rectangle getBoundsInPixels () { @@ -397,7 +397,7 @@ Rectangle getBoundsInPixels () { */ public Rectangle getBounds (int index) { checkWidget(); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(index), getZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(index), getAutoscalingZoom()); } Rectangle getBoundsInPixels (int index) { @@ -813,7 +813,7 @@ public Image getImage (int index) { */ public Rectangle getImageBounds (int index) { checkWidget(); - return Win32DPIUtils.pixelToPoint(getImageBoundsInPixels(index), getZoom()); + return Win32DPIUtils.pixelToPoint(getImageBoundsInPixels(index), getAutoscalingZoom()); } Rectangle getImageBoundsInPixels (int index) { @@ -908,7 +908,7 @@ public String getText (int index) { */ public Rectangle getTextBounds (int index) { checkWidget(); - return Win32DPIUtils.pixelToPoint(getTextBoundsInPixels(index), getZoom()); + return Win32DPIUtils.pixelToPoint(getTextBoundsInPixels(index), getAutoscalingZoom()); } Rectangle getTextBoundsInPixels (int index) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index d0476e512f..a98af94eb2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -1192,7 +1192,7 @@ void reskinWidget() { boolean sendDragEvent (int button, int x, int y) { Event event = new Event (); event.button = button; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom)); setInputState (event, SWT.DragDetect); postEvent (SWT.DragDetect, event); @@ -1203,7 +1203,7 @@ boolean sendDragEvent (int button, int x, int y) { boolean sendDragEvent (int button, int stateMask, int x, int y) { Event event = new Event (); event.button = button; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom)); event.stateMask = stateMask; postEvent (SWT.DragDetect, event); @@ -1280,7 +1280,7 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen event.button = button; event.detail = detail; event.count = count; - int zoom = getZoom(); + int zoom = getAutoscalingZoom(); event.setLocation(DPIUtil.pixelToPoint(OS.GET_X_LPARAM (lParam), zoom), DPIUtil.pixelToPoint(OS.GET_Y_LPARAM (lParam), zoom)); setInputState (event, type); mapEvent (hwnd, event); @@ -1707,7 +1707,7 @@ boolean showMenu (int x, int y, int detail) { if (!event.doit) return true; Menu menu = getMenu (); if (menu != null && !menu.isDisposed ()) { - Point locInPixels = Win32DPIUtils.pointToPixelAsLocation(event.getLocation(), getZoom()); // In Pixels + Point locInPixels = Win32DPIUtils.pointToPixelAsLocation(event.getLocation(), getAutoscalingZoom()); // In Pixels if (x != locInPixels.x || y != locInPixels.y) { menu.setLocation (event.getLocation()); } @@ -2361,7 +2361,7 @@ LRESULT wmPaint (long hwnd, long wParam, long lParam) { OS.SetMetaRgn (hDC); Event event = new Event (); event.gc = gc; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, width, height), getZoom())); + event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, width, height), getAutoscalingZoom())); sendEvent (SWT.Paint, event); // widget could be disposed at this point event.gc = null; @@ -2699,7 +2699,7 @@ GC createNewGC(long hDC, GCData data) { return GC.win32_new(hDC, data); } -int getZoom() { +int getAutoscalingZoom() { return DPIUtil.getZoomForAutoscaleProperty(nativeZoom); }