Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2016-09-20 06:51:53 +0000
committerNiraj Modi2016-11-14 08:57:24 +0000
commit06c84738708c839d8b8abd240d414db8a63273f7 (patch)
tree5e341941fbd6a6d859997f9a0c39a9370c984a9c
parentfb77215d07a8535413f6739b244a3692300b0921 (diff)
downloadeclipse.platform.swt-06c84738708c839d8b8abd240d414db8a63273f7.tar.gz
eclipse.platform.swt-06c84738708c839d8b8abd240d414db8a63273f7.tar.xz
eclipse.platform.swt-06c84738708c839d8b8abd240d414db8a63273f7.zip
Bug 498876 - [HiDPI][Printer] GC autoScales for Printer devices at
HighDPI Change-Id: I50d88fa0df93a1f421501bcd3306bc9388f34c1d Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/.settings/.api_filters13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java85
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java90
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java68
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java180
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java118
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java5
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_printing_Printer.java13
20 files changed, 408 insertions, 235 deletions
diff --git a/bundles/org.eclipse.swt/.settings/.api_filters b/bundles/org.eclipse.swt/.settings/.api_filters
index 96a64ecdf2..144f977ae3 100644
--- a/bundles/org.eclipse.swt/.settings/.api_filters
+++ b/bundles/org.eclipse.swt/.settings/.api_filters
@@ -1472,6 +1472,19 @@
</message_arguments>
</filter>
</resource>
+ <resource path="Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java" type="org.eclipse.swt.graphics.Drawable">
+ <filter id="403804204">
+ <message_arguments>
+ <message_argument value="org.eclipse.swt.graphics.Drawable"/>
+ <message_argument value="isAutoScalable()"/>
+ </message_arguments>
+ </filter>
+ <filter id="1211105284">
+ <message_arguments>
+ <message_argument value="isAutoScalable()"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java" type="org.eclipse.swt.graphics.ImageData">
<filter id="576725006">
<message_arguments>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java
index 0c04d16d4a..ac59d9f620 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -368,6 +368,11 @@ public void internal_dispose_GC(long /*int*/ hDC, GCData data) {
if (data != null) isGCCreated = false;
}
+@Override
+public boolean isAutoScalable() {
+ return false;
+}
+
/**
* Releases any internal state prior to destroying this printer.
* This method is called internally by the dispose
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
index ec9de7f483..84c383d2a6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -463,6 +463,11 @@ public void internal_dispose_GC(long /*int*/ hDC, GCData data) {
}
}
+@Override
+public boolean isAutoScalable() {
+ return false;
+}
+
/**
* Starts a print job and returns true if the job started successfully
* and false otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
index 906f70b8c6..2972e6e988 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
@@ -323,6 +323,11 @@ public void internal_dispose_GC(long /*int*/ hDC, GCData data) {
if (data != null) isGCCreated = false;
}
+@Override
+public boolean isAutoScalable() {
+ return false;
+}
+
/**
* Starts a print job and returns true if the job started successfully
* and false otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
index 7c6cbd6924..dc38d16b03 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
@@ -1441,6 +1441,11 @@ public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
}
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
/**
* Returns <code>true</code> if the image has been disposed,
* and <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index c5ceb26d1c..4a8c82591f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -2253,6 +2253,11 @@ void invalidateVisibleRegion () {
}
@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
+@Override
boolean isActive () {
if (getShell().getModalShell () != null) return false;
Dialog dialog = display.getModalDialog();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 4a93b4e4ef..8e755d212d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -3123,6 +3123,11 @@ public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
if (isDisposed()) error(SWT.ERROR_DEVICE_DISPOSED);
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
boolean isBundled () {
NSBundle mainBundle = NSBundle.mainBundle();
if (mainBundle != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java
index 988f071268..f8cece405c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -64,4 +64,14 @@ public long /*int*/ internal_new_GC (GCData data);
*/
public void internal_dispose_GC (long /*int*/ handle, GCData data);
+/**
+ * Returns <code>true</code> iff coordinates can be auto-scaled on this
+ * drawable and <code>false</code> if not. E.g. a {@link GC} method should not
+ * auto-scale the bounds of a figure drawn on a Printer device, but it may have
+ * to auto-scale when drawing on a high-DPI Display monitor.
+ *
+ * @return <code>true</code> if auto-scaling is enabled for this drawable
+ */
+public boolean isAutoScalable ();
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
index 90dca7fedf..05bcecc363 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
@@ -85,7 +85,7 @@ public class DPIUtil {
* Auto-scale down ImageData
*/
public static ImageData autoScaleDown (Device device, final ImageData imageData) {
- if (deviceZoom == 100 || imageData == null) return imageData;
+ if (deviceZoom == 100 || imageData == null || (device != null && !device.isAutoScalable())) return imageData;
float scaleFactor = 1.0f / getScalingFactor ();
return autoScaleImageData(device, imageData, scaleFactor);
}
@@ -100,6 +100,11 @@ public static int[] autoScaleDown(int[] pointArray) {
return returnArray;
}
+public static int[] autoScaleDown(Drawable drawable, int[] pointArray) {
+ if (drawable != null && !drawable.isAutoScalable ()) return pointArray;
+ return autoScaleDown (pointArray);
+}
+
/**
* Auto-scale up float array dimensions.
*/
@@ -112,6 +117,15 @@ public static float[] autoScaleDown (float size[]) {
}
return scaledSize;
}
+
+/**
+ * Auto-scale up float array dimensions if enabled for Drawable class.
+ */
+public static float[] autoScaleDown (Drawable drawable, float size[]) {
+ if (drawable != null && !drawable.isAutoScalable ()) return size;
+ return autoScaleDown (size);
+}
+
/**
* Auto-scale down int dimensions.
*/
@@ -121,6 +135,14 @@ public static int autoScaleDown (int size) {
return Math.round (size / scaleFactor);
}
/**
+ * Auto-scale down int dimensions if enabled for Drawable class.
+ */
+public static int autoScaleDown (Drawable drawable, int size) {
+ if (drawable != null && !drawable.isAutoScalable ()) return size;
+ return autoScaleDown (size);
+}
+
+/**
* Auto-scale down float dimensions.
*/
public static float autoScaleDown (float size) {
@@ -130,6 +152,14 @@ public static float autoScaleDown (float size) {
}
/**
+ * Auto-scale down float dimensions if enabled for Drawable class.
+ */
+public static float autoScaleDown (Drawable drawable, float size) {
+ if (drawable != null && !drawable.isAutoScalable ()) return size;
+ return autoScaleDown (size);
+}
+
+/**
* Returns a new scaled down Point.
*/
public static Point autoScaleDown (Point point) {
@@ -142,6 +172,14 @@ public static Point autoScaleDown (Point point) {
}
/**
+ * Returns a new scaled down Point if enabled for Drawable class.
+ */
+public static Point autoScaleDown (Drawable drawable, Point point) {
+ if (drawable != null && !drawable.isAutoScalable ()) return point;
+ return autoScaleDown (point);
+}
+
+/**
* Returns a new scaled down Rectangle.
*/
public static Rectangle autoScaleDown (Rectangle rect) {
@@ -156,12 +194,19 @@ public static Rectangle autoScaleDown (Rectangle rect) {
scaledRect.height = scaledBottomRight.y - scaledTopLeft.y;
return scaledRect;
}
+/**
+ * Returns a new scaled down Rectangle if enabled for Drawable class.
+ */
+public static Rectangle autoScaleDown (Drawable drawable, Rectangle rect) {
+ if (drawable != null && !drawable.isAutoScalable ()) return rect;
+ return autoScaleDown (rect);
+}
/**
* Auto-scale image with ImageData
*/
public static ImageData autoScaleImageData (Device device, final ImageData imageData, int targetZoom, int currentZoom) {
- if (deviceZoom == 100 || imageData == null || targetZoom == currentZoom) return imageData;
+ if (deviceZoom == 100 || imageData == null || targetZoom == currentZoom || (device != null && !device.isAutoScalable())) return imageData;
float scaleFactor = (float) targetZoom / (float) currentZoom;
return autoScaleImageData(device, imageData, scaleFactor);
}
@@ -227,7 +272,7 @@ public static Rectangle autoScaleBounds (Rectangle rect, int targetZoom, int cur
* Auto-scale up ImageData
*/
public static ImageData autoScaleUp (Device device, final ImageData imageData) {
- if (deviceZoom == 100 || imageData == null) return imageData;
+ if (deviceZoom == 100 || imageData == null || (device != null && !device.isAutoScalable())) return imageData;
float scaleFactor = getScalingFactor ();
return autoScaleImageData(device, imageData, scaleFactor);
}
@@ -242,6 +287,11 @@ public static int[] autoScaleUp(int[] pointArray) {
return returnArray;
}
+public static int[] autoScaleUp(Drawable drawable, int[] pointArray) {
+ if (drawable != null && !drawable.isAutoScalable ()) return pointArray;
+ return autoScaleUp (pointArray);
+}
+
/**
* Auto-scale up int dimensions.
*/
@@ -251,12 +301,25 @@ public static int autoScaleUp (int size) {
return Math.round (size * scaleFactor);
}
+/**
+ * Auto-scale up int dimensions if enabled for Drawable class.
+ */
+public static int autoScaleUp (Drawable drawable, int size) {
+ if (drawable != null && !drawable.isAutoScalable ()) return size;
+ return autoScaleUp (size);
+}
+
public static float autoScaleUp(float size) {
if (deviceZoom == 100 || size == SWT.DEFAULT) return size;
float scaleFactor = getScalingFactor ();
return (size * scaleFactor);
}
+public static float autoScaleUp(Drawable drawable, float size) {
+ if (drawable != null && !drawable.isAutoScalable ()) return size;
+ return autoScaleUp (size);
+}
+
/**
* Returns a new scaled up Point.
*/
@@ -270,6 +333,14 @@ public static Point autoScaleUp (Point point) {
}
/**
+ * Returns a new scaled up Point if enabled for Drawable class.
+ */
+public static Point autoScaleUp (Drawable drawable, Point point) {
+ if (drawable != null && !drawable.isAutoScalable ()) return point;
+ return autoScaleUp (point);
+}
+
+/**
* Returns a new scaled up Rectangle.
*/
public static Rectangle autoScaleUp (Rectangle rect) {
@@ -286,6 +357,14 @@ public static Rectangle autoScaleUp (Rectangle rect) {
}
/**
+ * Returns a new scaled up Rectangle if enabled for Drawable class.
+ */
+public static Rectangle autoScaleUp (Drawable drawable, Rectangle rect) {
+ if (drawable != null && !drawable.isAutoScalable ()) return rect;
+ return autoScaleUp (rect);
+}
+
+/**
* Returns Scaling factor from the display
* @return float scaling factor
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index d9324b263e..2e539099a0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -298,7 +298,7 @@ void checkGC (int mask) {
Cairo.cairo_set_line_join(cairo, join_style);
}
if ((state & LINE_WIDTH) != 0) {
- Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? DPIUtil.autoScaleUp(1) : data.lineWidth);
+ Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? DPIUtil.autoScaleUp(drawable, 1) : data.lineWidth);
switch (data.lineStyle) {
case SWT.LINE_DOT:
case SWT.LINE_DASH:
@@ -478,7 +478,7 @@ public void copyArea(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y));
copyAreaInPixels(image, loc.x, loc.y);
}
void copyAreaInPixels(Image image, int x, int y) {
@@ -538,8 +538,8 @@ void copyAreaInPixels(Image image, int x, int y) {
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle src = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, width, height));
- Point dest = DPIUtil.autoScaleUp(new Point(destX, destY));
+ Rectangle src = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, width, height));
+ Point dest = DPIUtil.autoScaleUp(drawable, new Point(destX, destY));
copyAreaInPixels(src.x, src.y, src.width, src.height, dest.x, dest.y);
}
@@ -566,8 +566,8 @@ void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle srcLoc = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, width, height));
- Point destLoc = DPIUtil.autoScaleUp(new Point(destX, destY));
+ Rectangle srcLoc = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, width, height));
+ Point destLoc = DPIUtil.autoScaleUp(drawable, new Point(destX, destY));
copyAreaInPixels(srcLoc.x, srcLoc.y, srcLoc.width, srcLoc.height, destLoc.x, destLoc.y, paint);
}
void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
@@ -739,7 +739,7 @@ void destroy() {
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle loc = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Rectangle loc = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
drawArcInPixels(loc.x, loc.y, loc.width, loc.height, startAngle, arcAngle);
}
void drawArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) {
@@ -798,7 +798,7 @@ void drawArcInPixels(int x, int y, int width, int height, int startAngle, int ar
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle loc = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Rectangle loc = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
drawFocusInPixels(loc.x, loc.y, loc.width, loc.height);
}
void drawFocusInPixels(int x, int y, int width, int height) {
@@ -856,7 +856,7 @@ public void drawImage(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y));
drawImageInPixels(image, loc.x, loc.y);
}
void drawImageInPixels(Image image, int x, int y) {
@@ -903,8 +903,8 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig
}
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- Rectangle srcRect = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, srcWidth, srcHeight));
- Rectangle destRect = DPIUtil.autoScaleUp(new Rectangle(destX, destY, destWidth, destHeight));
+ Rectangle srcRect = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, srcWidth, srcHeight));
+ Rectangle destRect = DPIUtil.autoScaleUp(drawable, new Rectangle(destX, destY, destWidth, destHeight));
drawImage(image, srcRect.x, srcRect.y, srcRect.width, srcRect.height, destRect.x, destRect.y, destRect.width, destRect.height, false);
}
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
@@ -1286,8 +1286,8 @@ long /*int*/ scale(long /*int*/ src, int srcX, int srcY, int srcWidth, int srcHe
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Point loc1 = DPIUtil.autoScaleUp(new Point(x1, y1));
- Point loc2 = DPIUtil.autoScaleUp(new Point(x2, y2));
+ Point loc1 = DPIUtil.autoScaleUp(drawable, new Point(x1, y1));
+ Point loc2 = DPIUtil.autoScaleUp(drawable, new Point(x2, y2));
drawLineInPixels(loc1.x, loc1.y, loc2.x, loc2.y);
}
void drawLineInPixels(int x1, int y1, int x2, int y2) {
@@ -1326,7 +1326,7 @@ void drawLineInPixels(int x1, int y1, int x2, int y2) {
*/
public void drawOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
drawOvalInPixels(rect.x, rect.y, rect.width, rect.height);
}
void drawOvalInPixels(int x, int y, int width, int height) {
@@ -1417,7 +1417,7 @@ public void drawPath(Path path) {
*/
public void drawPoint (int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y));
drawPointInPixels(loc.x, loc.y);
}
void drawPointInPixels (int x, int y) {
@@ -1451,7 +1451,7 @@ void drawPointInPixels (int x, int y) {
public void drawPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray);
drawPolygonInPixels(scaledPointArray);
}
void drawPolygonInPixels(int[] pointArray) {
@@ -1485,7 +1485,7 @@ void drawPolygonInPixels(int[] pointArray) {
public void drawPolyline(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray);
drawPolylineInPixels(scaledPointArray);
}
void drawPolylineInPixels(int[] pointArray) {
@@ -1567,7 +1567,7 @@ void drawRectangleInPixels(int x, int y, int width, int height) {
*/
public void drawRectangle(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangleInPixels(DPIUtil.autoScaleUp(rect));
+ drawRectangleInPixels(DPIUtil.autoScaleUp(drawable, rect));
}
void drawRectangleInPixels(Rectangle rect) {
drawRectangleInPixels (rect.x, rect.y, rect.width, rect.height);
@@ -1595,8 +1595,8 @@ void drawRectangleInPixels(Rectangle rect) {
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
- Point arcSize = DPIUtil.autoScaleUp(new Point(arcWidth, arcHeight));
+ Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
+ Point arcSize = DPIUtil.autoScaleUp(drawable, new Point(arcWidth, arcHeight));
drawRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y);
}
void drawRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) {
@@ -1722,7 +1722,7 @@ void drawStringInPixels (String string, int x, int y) {
public void drawString(String string, int x, int y, boolean isTransparent) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y));
drawStringInPixels(string, loc.x, loc.y, isTransparent);
}
@@ -1776,7 +1776,7 @@ void drawTextInPixels(String string, int x, int y) {
* </ul>
*/
public void drawText(String string, int x, int y, boolean isTransparent) {
- Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ Point loc = DPIUtil.autoScaleUp(drawable, new Point (x, y));
drawTextInPixels(string, loc.x, loc.y, isTransparent);
}
void drawTextInPixels(String string, int x, int y, boolean isTransparent) {
@@ -1820,7 +1820,7 @@ void drawTextInPixels(String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText (String string, int x, int y, int flags) {
- Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ Point loc = DPIUtil.autoScaleUp(drawable, new Point (x, y));
drawTextInPixels(string, loc.x, loc.y, flags);
}
void drawTextInPixels (String string, int x, int y, int flags) {
@@ -1932,7 +1932,7 @@ public boolean equals(Object object) {
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
fillArcInPixels(rect.x, rect.y, rect.width, rect.height, startAngle, arcAngle);
}
void fillArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) {
@@ -1995,7 +1995,7 @@ void fillArcInPixels(int x, int y, int width, int height, int startAngle, int ar
*/
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
fillGradientRectangleInPixels(rect.x, rect.y, rect.width, rect.height, vertical);
}
@@ -2049,8 +2049,8 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean
return;
}
ImageData.fillGradientRectangle(this, data.device,
- DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y),
- DPIUtil.autoScaleDown(width), DPIUtil.autoScaleDown(height),
+ DPIUtil.autoScaleDown(drawable, x), DPIUtil.autoScaleDown(drawable, y),
+ DPIUtil.autoScaleDown(drawable, width), DPIUtil.autoScaleDown(drawable, height),
vertical, fromRGB, toRGB, 8, 8, 8);
}
@@ -2072,7 +2072,7 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean
*/
public void fillOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
fillOvalInPixels(rect.x, rect.y, rect.width, rect.height);
}
void fillOvalInPixels(int x, int y, int width, int height) {
@@ -2161,7 +2161,7 @@ public void fillPath (Path path) {
public void fillPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray);
fillPolygonInPixels(scaledPointArray);
}
void fillPolygonInPixels(int[] pointArray) {
@@ -2231,7 +2231,7 @@ void fillRectangleInPixels(int x, int y, int width, int height) {
public void fillRectangle(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- fillRectangleInPixels(DPIUtil.autoScaleUp(rect));
+ fillRectangleInPixels(DPIUtil.autoScaleUp(drawable, rect));
}
void fillRectangleInPixels(Rectangle rect) {
fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
@@ -2256,8 +2256,8 @@ void fillRectangleInPixels(Rectangle rect) {
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
- Point arcSize = DPIUtil.autoScaleUp(new Point(arcWidth, arcHeight));
+ Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height));
+ Point arcSize = DPIUtil.autoScaleUp(drawable, new Point(arcWidth, arcHeight));
fillRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y);
}
void fillRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) {
@@ -2510,7 +2510,7 @@ public int getCharWidth(char ch) {
*/
public Rectangle getClipping() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return DPIUtil.autoScaleDown(getClippingInPixels());
+ return DPIUtil.autoScaleDown(drawable, getClippingInPixels());
}
Rectangle getClippingInPixels() {
/* Calculate visible bounds in device space */
@@ -2672,11 +2672,11 @@ public FontMetrics getFontMetrics() {
FontMetrics fm = new FontMetrics();
int ascent = OS.pango_font_metrics_get_ascent(metrics);
int descent = OS.pango_font_metrics_get_descent(metrics);
- int ascentInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(ascent));
+ int ascentInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(ascent));
fm.ascentInPoints = ascentInPoints;
- int heightInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(ascent + descent));
+ int heightInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(ascent + descent));
fm.descentInPoints = heightInPoints - ascentInPoints;
- fm.averageCharWidthInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics)));
+ fm.averageCharWidthInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics)));
OS.pango_font_metrics_unref(metrics);
return fm;
}
@@ -2773,7 +2773,7 @@ public int getInterpolation() {
public LineAttributes getLineAttributes() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
LineAttributes attributes = getLineAttributesInPixels();
- attributes.width = DPIUtil.autoScaleDown(attributes.width);
+ attributes.width = DPIUtil.autoScaleDown(drawable, attributes.width);
return attributes;
}
LineAttributes getLineAttributesInPixels() {
@@ -2874,7 +2874,7 @@ public int getLineStyle() {
*/
public int getLineWidth() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (int)DPIUtil.autoScaleDown(data.lineWidth);
+ return (int)DPIUtil.autoScaleDown(drawable, data.lineWidth);
}
int getLineWidthInPixels() {
return (int)data.lineWidth;
@@ -3459,7 +3459,7 @@ void setClipping(long /*int*/ clipRgn) {
*/
public void setClipping(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- setClippingInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+ setClippingInPixels(DPIUtil.autoScaleUp(drawable, x), DPIUtil.autoScaleUp(drawable, y), DPIUtil.autoScaleUp(drawable, width), DPIUtil.autoScaleUp(drawable, height));
}
void setClippingInPixels(int x, int y, int width, int height) {
if (width < 0) {
@@ -3537,7 +3537,7 @@ public void setClipping(Path path) {
*/
public void setClipping(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- setClippingInPixels(DPIUtil.autoScaleUp(rect));
+ setClippingInPixels(DPIUtil.autoScaleUp(drawable, rect));
}
void setClippingInPixels(Rectangle rect) {
if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && (drawable instanceof Tree || drawable instanceof Table)) {
@@ -3754,7 +3754,7 @@ public void setInterpolation(int interpolation) {
public void setLineAttributes(LineAttributes attributes) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- attributes.width = DPIUtil.autoScaleUp(attributes.width);
+ attributes.width = DPIUtil.autoScaleUp(drawable, attributes.width);
setLineAttributesInPixels(attributes);
}
void setLineAttributesInPixels(LineAttributes attributes) {
@@ -4006,7 +4006,7 @@ public void setLineStyle(int lineStyle) {
*/
public void setLineWidth(int lineWidth) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- setLineWidthInPixels(DPIUtil.autoScaleUp(lineWidth));
+ setLineWidthInPixels(DPIUtil.autoScaleUp(drawable, lineWidth));
}
void setLineWidthInPixels(int lineWidth) {
if (data.lineWidth == lineWidth) return;
@@ -4199,7 +4199,7 @@ public void setXORMode(boolean xor) {
* </ul>
*/
public Point stringExtent(String string) {
- return DPIUtil.autoScaleDown(stringExtentInPixels(string));
+ return DPIUtil.autoScaleDown(drawable, stringExtentInPixels(string));
}
Point stringExtentInPixels(String string) {
return textExtentInPixels(string, 0);
@@ -4225,7 +4225,7 @@ Point stringExtentInPixels(String string) {
* </ul>
*/
public Point textExtent(String string) {
- return DPIUtil.autoScaleDown(textExtentInPixels(string));
+ return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string));
}
Point textExtentInPixels(String string) {
@@ -4266,7 +4266,7 @@ Point textExtentInPixels(String string) {
public Point textExtent(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return DPIUtil.autoScaleDown(textExtentInPixels(string, flags));
+ return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string, flags));
}
Point textExtentInPixels(String string, int flags) {
setString(string, flags);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index 7ea44ae72e..8489f3ff08 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -1934,6 +1934,11 @@ public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
}
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
/**
* Returns <code>true</code> if the image has been disposed,
* and <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
index 7830a3f71a..4c1adfa31f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
@@ -118,8 +118,8 @@ void computeRuns () {
int[] lineOffsets = null;
if ((ascentInPoints != -1 || descentInPoints != -1) && segementsLength > 0) {
PangoRectangle rect = new PangoRectangle();
- if (ascentInPoints != -1) rect.y = -(DPIUtil.autoScaleUp(ascentInPoints) * OS.PANGO_SCALE);
- rect.height = DPIUtil.autoScaleUp((Math.max(0, ascentInPoints) + Math.max(0, descentInPoints))) * OS.PANGO_SCALE;
+ if (ascentInPoints != -1) rect.y = -(DPIUtil.autoScaleUp(getDevice(), ascentInPoints) * OS.PANGO_SCALE);
+ rect.height = DPIUtil.autoScaleUp(getDevice(), (Math.max(0, ascentInPoints) + Math.max(0, descentInPoints))) * OS.PANGO_SCALE;
int lineCount = OS.pango_layout_get_line_count(layout);
chars = new char[segementsLength + lineCount * 2];
lineOffsets = new int [lineCount];
@@ -291,9 +291,9 @@ void computeRuns () {
GlyphMetrics metrics = style.metrics;
if (metrics != null) {
PangoRectangle rect = new PangoRectangle();
- rect.y = -(DPIUtil.autoScaleUp(metrics.ascent) * OS.PANGO_SCALE);
- rect.height = DPIUtil.autoScaleUp((metrics.ascent + metrics.descent)) * OS.PANGO_SCALE;
- rect.width = DPIUtil.autoScaleUp(metrics.width) * OS.PANGO_SCALE;
+ rect.y = -(DPIUtil.autoScaleUp(getDevice(), metrics.ascent) * OS.PANGO_SCALE);
+ rect.height = DPIUtil.autoScaleUp(getDevice(), (metrics.ascent + metrics.descent)) * OS.PANGO_SCALE;
+ rect.width = DPIUtil.autoScaleUp(getDevice(), metrics.width) * OS.PANGO_SCALE;
long /*int*/ attr = OS.pango_attr_shape_new (rect, rect);
OS.memmove (attribute, attr, PangoAttribute.sizeof);
attribute.start_index = byteStart;
@@ -304,7 +304,7 @@ void computeRuns () {
}
int rise = style.rise;
if (rise != 0) {
- long /*int*/ attr = OS.pango_attr_rise_new (DPIUtil.autoScaleUp(rise) * OS.PANGO_SCALE);
+ long /*int*/ attr = OS.pango_attr_rise_new (DPIUtil.autoScaleUp(getDevice(), rise) * OS.PANGO_SCALE);
OS.memmove (attribute, attr, PangoAttribute.sizeof);
attribute.start_index = byteStart;
attribute.end_index = byteEnd;
@@ -369,8 +369,8 @@ void destroy() {
* </ul>
*/
public void draw(GC gc, int x, int y) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(getDevice(), x);
+ y = DPIUtil.autoScaleUp(getDevice(), y);
drawInPixels(gc, x, y);
}
@@ -399,8 +399,8 @@ void drawInPixels(GC gc, int x, int y) {
*/
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
checkLayout ();
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(getDevice(), x);
+ y = DPIUtil.autoScaleUp(getDevice(), y);
drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground);
}
void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
@@ -436,8 +436,8 @@ void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Col
*/
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
checkLayout ();
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(getDevice(), x);
+ y = DPIUtil.autoScaleUp(getDevice(), y);
drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, flags);
}
void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
@@ -498,7 +498,7 @@ void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Col
int lineY = y + OS.PANGO_PIXELS(rect.y);
int height = OS.PANGO_PIXELS(rect.height);
if (ascentInPoints != -1 && descentInPoints != -1) {
- height = Math.max (height, DPIUtil.autoScaleUp(ascentInPoints + descentInPoints));
+ height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints));
}
int width = (flags & SWT.FULL_SELECTION) != 0 ? 0x7fff : height / 3;
if (cairo != 0) {
@@ -796,7 +796,7 @@ public int getAscent () {
*/
public Rectangle getBounds() {
checkLayout();
- Rectangle bounds = DPIUtil.autoScaleDown(getBoundsInPixels());
+ Rectangle bounds = DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels());
int lineCount = OS.pango_layout_get_line_count(layout);
int totalLineheight = 0;
for (int i = 0; i < lineCount; i++) {
@@ -815,7 +815,7 @@ Rectangle getBoundsInPixels() {
int width = OS.PANGO_PIXELS(w[0]);
int height = OS.PANGO_PIXELS(h[0]);
if (ascentInPoints != -1 && descentInPoints != -1) {
- height = Math.max (height, DPIUtil.autoScaleUp(ascentInPoints + descentInPoints));
+ height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints));
}
height += OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout));
return new Rectangle(0, 0, width, height);
@@ -837,7 +837,7 @@ Rectangle getBoundsInPixels() {
*/
public Rectangle getBounds(int start, int end) {
checkLayout();
- return DPIUtil.autoScaleDown(getBoundsInPixels(start, end));
+ return DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels(start, end));
}
Rectangle getBoundsInPixels(int start, int end) {
@@ -946,7 +946,7 @@ public Font getFont () {
*/
public int getIndent () {
checkLayout();
- return DPIUtil.autoScaleDown(getIndentInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getIndentInPixels());
}
int getIndentInPixels () {
@@ -1028,7 +1028,7 @@ public int getLevel(int offset) {
*/
public Rectangle getLineBounds(int lineIndex) {
checkLayout();
- return DPIUtil.autoScaleDown(getLineBoundsInPixels(lineIndex));
+ return DPIUtil.autoScaleDown(getDevice(), getLineBoundsInPixels(lineIndex));
}
Rectangle getLineBoundsInPixels(int lineIndex) {
@@ -1046,7 +1046,7 @@ Rectangle getLineBoundsInPixels(int lineIndex) {
int width = OS.PANGO_PIXELS(rect.width);
int height = OS.PANGO_PIXELS(rect.height);
if (ascentInPoints != -1 && descentInPoints != -1) {
- height = Math.max (height, DPIUtil.autoScaleUp(ascentInPoints + descentInPoints));
+ height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints));
}
if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) {
x = width() - x - width;
@@ -1134,14 +1134,14 @@ public FontMetrics getLineMetrics (int lineIndex) {
long /*int*/ metrics = OS.pango_context_get_metrics(context, font, lang);
int ascent = OS.pango_font_metrics_get_ascent(metrics);
int descent = OS.pango_font_metrics_get_descent(metrics);
- ascentInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(ascent));
- heightInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(ascent + descent));
+ ascentInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(ascent));
+ heightInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(ascent + descent));
OS.pango_font_metrics_unref(metrics);
} else {
PangoRectangle rect = new PangoRectangle();
OS.pango_layout_line_get_extents(OS.pango_layout_get_line(layout, lineIndex), null, rect);
- ascentInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(-rect.y));
- heightInPoints = DPIUtil.autoScaleDown(OS.PANGO_PIXELS(rect.height));
+ ascentInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(-rect.y));
+ heightInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(rect.height));
}
heightInPoints = Math.max(this.ascentInPoints + this.descentInPoints, heightInPoints);
ascentInPoints = Math.max(this.ascentInPoints, ascentInPoints);
@@ -1195,7 +1195,7 @@ public int[] getLineOffsets() {
*/
public Point getLocation(int offset, boolean trailing) {
checkLayout();
- return DPIUtil.autoScaleDown(getLocationInPixels(offset, trailing));
+ return DPIUtil.autoScaleDown(getDevice(), getLocationInPixels(offset, trailing));
}
Point getLocationInPixels(int offset, boolean trailing) {
@@ -1334,7 +1334,7 @@ int _getOffset (int offset, int movement, boolean forward) {
*/
public int getOffset(Point point, int[] trailing) {
checkLayout();
- return getOffsetInPixels(DPIUtil.autoScaleUp(point), trailing);
+ return getOffsetInPixels(DPIUtil.autoScaleUp(getDevice(), point), trailing);
}
int getOffsetInPixels(Point point, int[] trailing) {
@@ -1560,7 +1560,7 @@ String getSegmentsText() {
*/
public int getSpacing () {
checkLayout();
- return DPIUtil.autoScaleDown(getSpacingInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getSpacingInPixels());
}
int getSpacingInPixels () {
@@ -1634,7 +1634,7 @@ public TextStyle[] getStyles () {
*/
public int[] getTabs() {
checkLayout();
- return DPIUtil.autoScaleDown (getTabsInPixels ());
+ return DPIUtil.autoScaleDown (getDevice(), getTabsInPixels ());
}
int[] getTabsInPixels () {
@@ -1681,7 +1681,7 @@ public int getTextDirection () {
*/
public int getWidth () {
checkLayout ();
- return DPIUtil.autoScaleDown(getWidthInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getWidthInPixels());
}
int getWidthInPixels () {
@@ -1701,7 +1701,7 @@ int getWidthInPixels () {
*/
public int getWrapIndent () {
checkLayout ();
- return DPIUtil.autoScaleDown(getWrapIndentInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getWrapIndentInPixels());
}
int getWrapIndentInPixels () {
return wrapIndent;
@@ -1856,7 +1856,7 @@ public void setFont (Font font) {
*/
public void setIndent (int indent) {
checkLayout ();
- setIndentInPixels(DPIUtil.autoScaleUp(indent));
+ setIndentInPixels(DPIUtil.autoScaleUp(getDevice(), indent));
}
void setIndentInPixels (int indent) {
@@ -1929,7 +1929,7 @@ public void setOrientation(int orientation) {
public void setSpacing (int spacing) {
checkLayout();
if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+ setSpacingInPixels(DPIUtil.autoScaleUp(getDevice(), spacing));
}
void setSpacingInPixels (int spacing) {
@@ -2131,7 +2131,7 @@ public void setStyle (TextStyle style, int start, int end) {
public void setTabs(int[] tabs) {
checkLayout();
if (this.tabs == null && tabs == null) return;
- setTabsInPixels (DPIUtil.autoScaleUp (tabs));
+ setTabsInPixels (DPIUtil.autoScaleUp (getDevice(), tabs));
}
void setTabsInPixels (int[] tabs) {
@@ -2227,7 +2227,7 @@ public void setTextDirection (int textDirection) {
public void setWidth (int width) {
checkLayout ();
if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- setWidthInPixels(DPIUtil.autoScaleUp(width));
+ setWidthInPixels(DPIUtil.autoScaleUp(getDevice(), width));
}
void setWidthInPixels (int width) {
@@ -2265,7 +2265,7 @@ void setWidth () {
public void setWrapIndent (int wrapIndent) {
checkLayout();
if (wrapIndent < 0) return;
- setWrapIndentInPixels(DPIUtil.autoScaleUp(wrapIndent));
+ setWrapIndentInPixels(DPIUtil.autoScaleUp(getDevice(), wrapIndent));
}
void setWrapIndentInPixels (int wrapIndent) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 91f8324939..58c04f5e5c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -1344,6 +1344,11 @@ boolean isActive () {
return getShell ().getModalShell () == null && display.getModalDialog () == null;
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
/*
* Answers a boolean indicating whether a Label that precedes the receiver in
* a layout should be read by screen readers as the recevier's label.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index a6f05319fc..b0e85a9593 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -2172,6 +2172,11 @@ public static Display getDefault () {
}
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
static boolean isValidClass (Class<?> clazz) {
String name = clazz.getName ();
int index = name.lastIndexOf ('.');
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index 2197d26de9..8d8ee8c794 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -446,8 +446,8 @@ void checkGC(int mask) {
* </ul>
*/
public void copyArea (Image image, int x, int y) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
copyAreaInPixels(image, x, y);
}
@@ -502,12 +502,12 @@ public void copyArea (int srcX, int srcY, int width, int height, int destX, int
* @since 3.1
*/
public void copyArea (int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
- srcX = DPIUtil.autoScaleUp(srcX);
- srcY = DPIUtil.autoScaleUp(srcY);
- width = DPIUtil.autoScaleUp(width);
- height = DPIUtil.autoScaleUp(height);
- destX = DPIUtil.autoScaleUp(destX);
- destY = DPIUtil.autoScaleUp(destY);
+ srcX = DPIUtil.autoScaleUp(drawable, srcX);
+ srcY = DPIUtil.autoScaleUp(drawable, srcY);
+ width = DPIUtil.autoScaleUp(drawable, width);
+ height = DPIUtil.autoScaleUp(drawable, height);
+ destX = DPIUtil.autoScaleUp(drawable, destX);
+ destY = DPIUtil.autoScaleUp(drawable, destY);
copyAreaInPixels(srcX, srcY, width, height, destX, destY, paint);
}
@@ -743,10 +743,10 @@ void disposeGdip() {
* </ul>
*/
public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
- width = DPIUtil.autoScaleUp(width);
- height = DPIUtil.autoScaleUp(height);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
+ width = DPIUtil.autoScaleUp(drawable, width);
+ height = DPIUtil.autoScaleUp(drawable, height);
drawArcInPixels(x, y, width, height, startAngle, arcAngle);
}
@@ -849,10 +849,10 @@ void drawArcInPixels (int x, int y, int width, int height, int startAngle, int a
* @see #drawRectangle(int, int, int, int)
*/
public void drawFocus (int x, int y, int width, int height) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
drawFocusInPixels(x, y, width, height);
}
@@ -927,8 +927,8 @@ void drawFocusInPixels (int x, int y, int width, int height) {
* </ul>
*/
public void drawImage (Image image, int x, int y) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
drawImageInPixels(image, x, y);
}
@@ -980,8 +980,8 @@ public void drawImage (Image image, int srcX, int srcY, int srcWidth, int srcHei
if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- Rectangle src = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, srcWidth, srcHeight));
- Rectangle dest = DPIUtil.autoScaleUp(new Rectangle(destX, destY, destWidth, destHeight));
+ Rectangle src = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, srcWidth, srcHeight));
+ Rectangle dest = DPIUtil.autoScaleUp(drawable, new Rectangle(destX, destY, destWidth, destHeight));
int deviceZoom = DPIUtil.getDeviceZoom();
if (deviceZoom != 100) {
/*
@@ -1735,10 +1735,10 @@ void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight,
* </ul>
*/
public void drawLine (int x1, int y1, int x2, int y2) {
- x1 = DPIUtil.autoScaleUp (x1);
- x2 = DPIUtil.autoScaleUp (x2);
- y1 = DPIUtil.autoScaleUp (y1);
- y2 = DPIUtil.autoScaleUp (y2);
+ x1 = DPIUtil.autoScaleUp (drawable, x1);
+ x2 = DPIUtil.autoScaleUp (drawable, x2);
+ y1 = DPIUtil.autoScaleUp (drawable, y1);
+ y2 = DPIUtil.autoScaleUp (drawable, y2);
drawLineInPixels(x1, y1, x2, y2);
}
@@ -1792,10 +1792,10 @@ void drawLineInPixels (int x1, int y1, int x2, int y2) {
* </ul>
*/
public void drawOval (int x, int y, int width, int height) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
drawOvalInPixels(x, y, width, height);
}
@@ -1868,8 +1868,8 @@ public void drawPath (Path path) {
* @since 3.0
*/
public void drawPoint (int x, int y) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
drawPointInPixels(x, y);
}
@@ -1902,7 +1902,7 @@ void drawPointInPixels (int x, int y) {
*/
public void drawPolygon (int[] pointArray) {
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawPolygonInPixels(DPIUtil.autoScaleUp(pointArray));
+ drawPolygonInPixels(DPIUtil.autoScaleUp(drawable, pointArray));
}
void drawPolygonInPixels(int[] pointArray) {
@@ -1950,7 +1950,7 @@ void drawPolygonInPixels(int[] pointArray) {
* </ul>
*/
public void drawPolyline (int[] pointArray) {
- drawPolylineInPixels(DPIUtil.autoScaleUp(pointArray));
+ drawPolylineInPixels(DPIUtil.autoScaleUp(drawable, pointArray));
}
void drawPolylineInPixels(int[] pointArray) {
@@ -2003,10 +2003,10 @@ void drawPolylineInPixels(int[] pointArray) {
* </ul>
*/
public void drawRectangle (int x, int y, int width, int height) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
drawRectangleInPixels(x, y, width, height);
}
@@ -2062,7 +2062,7 @@ void drawRectangleInPixels (int x, int y, int width, int height) {
*/
public void drawRectangle (Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- rect = DPIUtil.autoScaleUp(rect);
+ rect = DPIUtil.autoScaleUp(drawable, rect);
drawRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
}
@@ -2088,12 +2088,12 @@ public void drawRectangle (Rectangle rect) {
* </ul>
*/
public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
- arcWidth = DPIUtil.autoScaleUp (arcWidth);
- arcHeight = DPIUtil.autoScaleUp (arcHeight);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
+ arcWidth = DPIUtil.autoScaleUp (drawable, arcWidth);
+ arcHeight = DPIUtil.autoScaleUp (drawable, arcHeight);
drawRoundRectangleInPixels(x, y, width, height, arcWidth, arcHeight);
}
@@ -2221,8 +2221,8 @@ void drawRoundRectangleGdip (long /*int*/ gdipGraphics, long /*int*/ pen, int x,
* </ul>
*/
public void drawString (String string, int x, int y) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
drawStringInPixels(string, x, y, false);
}
@@ -2247,8 +2247,8 @@ public void drawString (String string, int x, int y) {
* </ul>
*/
public void drawString (String string, int x, int y, boolean isTransparent) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
drawStringInPixels(string, x, y, isTransparent);
}
@@ -2343,8 +2343,8 @@ void drawStringInPixels (String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText (String string, int x, int y) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
drawTextInPixels(string, x, y);
}
@@ -2373,8 +2373,8 @@ void drawTextInPixels (String string, int x, int y) {
* </ul>
*/
public void drawText (String string, int x, int y, boolean isTransparent) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
drawTextInPixels(string, x, y, isTransparent);
}
@@ -2419,8 +2419,8 @@ void drawTextInPixels (String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText (String string, int x, int y, int flags) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
drawTextInPixels(string, x, y, flags);
}
@@ -2820,10 +2820,10 @@ public boolean equals (Object object) {
* @see #drawArc
*/
public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
fillArcInPixels(x, y, width, height, startAngle, arcAngle);
}
@@ -2929,10 +2929,10 @@ void fillArcInPixels (int x, int y, int width, int height, int startAngle, int a
* @see #drawRectangle(int, int, int, int)
*/
public void fillGradientRectangle (int x, int y, int width, int height, boolean vertical) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
fillGradientRectangleInPixels(x, y, width, height, vertical);
}
@@ -3063,10 +3063,10 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean
* @see #drawOval
*/
public void fillOval (int x, int y, int width, int height) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
fillOvalInPixels(x, y, width, height);
}
@@ -3136,7 +3136,7 @@ public void fillPath (Path path) {
*/
public void fillPolygon (int[] pointArray) {
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- fillPolygonInPixels(DPIUtil.autoScaleUp(pointArray));
+ fillPolygonInPixels(DPIUtil.autoScaleUp(drawable, pointArray));
}
void fillPolygonInPixels (int[] pointArray) {
@@ -3176,10 +3176,10 @@ void fillPolygonInPixels (int[] pointArray) {
* @see #drawRectangle(int, int, int, int)
*/
public void fillRectangle (int x, int y, int width, int height) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
fillRectangleInPixels(x, y, width, height);
}
@@ -3226,7 +3226,7 @@ void fillRectangleInPixels (int x, int y, int width, int height) {
*/
public void fillRectangle (Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- rect = DPIUtil.autoScaleUp(rect);
+ rect = DPIUtil.autoScaleUp(drawable, rect);
fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
}
@@ -3248,12 +3248,12 @@ public void fillRectangle (Rectangle rect) {
* @see #drawRoundRectangle
*/
public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- x = DPIUtil.autoScaleUp (x);
- y = DPIUtil.autoScaleUp (y);
- width = DPIUtil.autoScaleUp (width);
- height = DPIUtil.autoScaleUp (height);
- arcWidth = DPIUtil.autoScaleUp (arcWidth);
- arcHeight = DPIUtil.autoScaleUp (arcHeight);
+ x = DPIUtil.autoScaleUp (drawable, x);
+ y = DPIUtil.autoScaleUp (drawable, y);
+ width = DPIUtil.autoScaleUp (drawable, width);
+ height = DPIUtil.autoScaleUp (drawable, height);
+ arcWidth = DPIUtil.autoScaleUp (drawable, arcWidth);
+ arcHeight = DPIUtil.autoScaleUp (drawable, arcHeight);
fillRoundRectangleInPixels(x, y, width, height, arcWidth, arcHeight);
}
@@ -3529,7 +3529,7 @@ public int getCharWidth(char ch) {
* </ul>
*/
public Rectangle getClipping () {
- return DPIUtil.autoScaleDown(getClippingInPixels());
+ return DPIUtil.autoScaleDown(drawable, getClippingInPixels());
}
Rectangle getClippingInPixels() {
@@ -3804,7 +3804,7 @@ public int getInterpolation() {
*/
public LineAttributes getLineAttributes () {
LineAttributes attributes = getLineAttributesInPixels();
- attributes.width = DPIUtil.autoScaleDown(attributes.width);
+ attributes.width = DPIUtil.autoScaleDown(drawable, attributes.width);
return attributes;
}
@@ -3906,7 +3906,7 @@ public int getLineStyle() {
* </ul>
*/
public int getLineWidth () {
- return DPIUtil.autoScaleDown(getLineWidthInPixels());
+ return DPIUtil.autoScaleDown(drawable, getLineWidthInPixels());
}
int getLineWidthInPixels() {
@@ -4470,10 +4470,10 @@ void setClipping(long /*int*/ clipRgn) {
* </ul>
*/
public void setClipping (int x, int y, int width, int height) {
- x = DPIUtil.autoScaleUp(x);
- y = DPIUtil.autoScaleUp(y);
- width = DPIUtil.autoScaleUp(width);
- height = DPIUtil.autoScaleUp(height);
+ x = DPIUtil.autoScaleUp(drawable, x);
+ y = DPIUtil.autoScaleUp(drawable, y);
+ width = DPIUtil.autoScaleUp(drawable, width);
+ height = DPIUtil.autoScaleUp(drawable, height);
setClippingInPixels(x, y, width, height);
}
@@ -4541,7 +4541,7 @@ public void setClipping (Rectangle rect) {
setClipping(0);
}
else {
- rect = DPIUtil.autoScaleUp(rect);
+ rect = DPIUtil.autoScaleUp(drawable, rect);
setClippingInPixels(rect.x, rect.y, rect.width, rect.height);
}
}
@@ -4744,7 +4744,7 @@ public void setInterpolation(int interpolation) {
*/
public void setLineAttributes (LineAttributes attributes) {
if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- attributes.width = DPIUtil.autoScaleUp(attributes.width);
+ attributes.width = DPIUtil.autoScaleUp(drawable, attributes.width);
setLineAttributesInPixels(attributes);
}
@@ -4997,7 +4997,7 @@ public void setLineStyle(int lineStyle) {
* </ul>
*/
public void setLineWidth(int lineWidth) {
- lineWidth = DPIUtil.autoScaleUp (lineWidth);
+ lineWidth = DPIUtil.autoScaleUp (drawable, lineWidth);
setLineWidthInPixels(lineWidth);
}
@@ -5151,7 +5151,7 @@ public void setTransform(Transform transform) {
*/
public Point stringExtent (String string) {
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return DPIUtil.autoScaleDown(stringExtentInPixels(string));
+ return DPIUtil.autoScaleDown(drawable, stringExtentInPixels(string));
}
Point stringExtentInPixels (String string) {
@@ -5198,7 +5198,7 @@ Point stringExtentInPixels (String string) {
* </ul>
*/
public Point textExtent (String string) {
- return DPIUtil.autoScaleDown(textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB));
+ return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB));
}
/**
@@ -5233,7 +5233,7 @@ public Point textExtent (String string) {
* </ul>
*/
public Point textExtent (String string, int flags) {
- return DPIUtil.autoScaleDown(textExtentInPixels(string, flags));
+ return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string, flags));
}
Point textExtentInPixels(String string, int flags) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
index 007270dcc3..50c910b9b8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -2302,6 +2302,11 @@ public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
OS.DeleteDC(hDC);
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
/**
* Returns <code>true</code> if the image has been disposed,
* and <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
index 35a95f139b..011b443883 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
@@ -394,8 +394,8 @@ void computeRuns (GC gc) {
lineY = new int[lineCount + 1];
this.lineWidth = new int[lineCount];
int lineRunCount = 0, line = 0;
- int ascentInPoints = Math.max(0, DPIUtil.autoScaleDown(this.ascentInPixels));
- int descentInPoints = Math.max(0, DPIUtil.autoScaleDown(this.descentInPixels));
+ int ascentInPoints = Math.max(0, DPIUtil.autoScaleDown(getDevice(), this.ascentInPixels));
+ int descentInPoints = Math.max(0, DPIUtil.autoScaleDown(getDevice(), this.descentInPixels));
StyleItem[] lineRuns = new StyleItem[allRuns.length];
for (int i=0; i<allRuns.length; i++) {
StyleItem run = allRuns[i];
@@ -409,8 +409,8 @@ void computeRuns (GC gc) {
TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
OS.SelectObject(srcHdc, getItemFont(run));
OS.GetTextMetrics(srcHdc, lptm);
- run.ascentInPoints = DPIUtil.autoScaleDown(lptm.tmAscent);
- run.descentInPoints = DPIUtil.autoScaleDown(lptm.tmDescent);
+ run.ascentInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmAscent);
+ run.descentInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmDescent);
ascentInPoints = Math.max(ascentInPoints, run.ascentInPoints);
descentInPoints = Math.max(descentInPoints, run.descentInPoints);
}
@@ -464,8 +464,8 @@ void computeRuns (GC gc) {
lineY[line] = lineY[line - 1] + ascentInPoints + descentInPoints + lineSpacingInPoints;
lineOffset[line] = lastOffset;
lineRunCount = lineWidth = 0;
- ascentInPoints = Math.max(0, DPIUtil.autoScaleDown(this.ascentInPixels));
- descentInPoints = Math.max(0, DPIUtil.autoScaleDown(this.descentInPixels));
+ ascentInPoints = Math.max(0, DPIUtil.autoScaleDown(getDevice(), this.ascentInPixels));
+ descentInPoints = Math.max(0, DPIUtil.autoScaleDown(getDevice(), this.descentInPixels));
}
}
if (srcHdc != 0) OS.DeleteDC(srcHdc);
@@ -570,7 +570,7 @@ long /*int*/ createGdipBrush(Color color, int alpha) {
*/
public void draw (GC gc, int x, int y) {
checkLayout();
- drawInPixels(gc, DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+ drawInPixels(gc, DPIUtil.autoScaleUp(getDevice(), x), DPIUtil.autoScaleUp(getDevice(), y));
}
void drawInPixels (GC gc, int x, int y) {
@@ -598,7 +598,7 @@ void drawInPixels (GC gc, int x, int y) {
*/
public void draw (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
checkLayout();
- drawInPixels(gc, DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), selectionStart, selectionEnd, selectionForeground, selectionBackground);
+ drawInPixels(gc, DPIUtil.autoScaleUp(getDevice(), x), DPIUtil.autoScaleUp(getDevice(), y), selectionStart, selectionEnd, selectionForeground, selectionBackground);
}
void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
@@ -634,7 +634,7 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
*/
public void draw (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
checkLayout();
- drawInPixels(gc, DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), selectionStart, selectionEnd, selectionForeground, selectionBackground, flags);
+ drawInPixels(gc, DPIUtil.autoScaleUp(getDevice(), x), DPIUtil.autoScaleUp(getDevice(), y), selectionStart, selectionEnd, selectionForeground, selectionBackground, flags);
}
void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
@@ -688,9 +688,9 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
OS.SetBkMode(hdc, OS.TRANSPARENT);
for (int line=0; line<runs.length; line++) {
int drawX = x + getLineIndent(line);
- int drawY = y + DPIUtil.autoScaleUp(lineY[line]);
+ int drawY = y + DPIUtil.autoScaleUp(getDevice(), lineY[line]);
StyleItem[] lineRuns = runs[line];
- int lineHeight = DPIUtil.autoScaleUp(lineY[line+1] - lineY[line] - lineSpacingInPoints);
+ int lineHeight = DPIUtil.autoScaleUp(getDevice(), lineY[line+1] - lineY[line] - lineSpacingInPoints);
//Draw last line selection
if ((flags & (SWT.FULL_SELECTION | SWT.DELIMITER_SELECTION)) != 0 && (hasSelection || (flags & SWT.LAST_LINE_SELECTION) != 0)) {
@@ -749,7 +749,7 @@ void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Co
int baselineInPixels = Math.max(0, this.ascentInPixels);
int lineUnderlinePos = 0;
for (int i = 0; i < lineRuns.length; i++) {
- baselineInPixels = Math.max(baselineInPixels, DPIUtil.autoScaleUp(lineRuns[i].ascentInPoints));
+ baselineInPixels = Math.max(baselineInPixels, DPIUtil.autoScaleUp(getDevice(), lineRuns[i].ascentInPoints));
lineUnderlinePos = Math.min(lineUnderlinePos, lineRuns[i].underlinePos);
}
RECT borderClip = null, underlineClip = null, strikeoutClip = null, pRect = null;
@@ -1029,7 +1029,7 @@ RECT drawRunText(long /*int*/ hdc, StyleItem run, RECT rect, int baselineInPixel
boolean partialSelection = hasSelection && !fullSelection && !(selectionStart > end || run.start > selectionEnd);
int offset = (orientation & SWT.RIGHT_TO_LEFT) != 0 ? -1 : 0;
int x = rect.left + offset;
- int y = rect.top + (baselineInPixels - DPIUtil.autoScaleUp(run.ascentInPoints));
+ int y = rect.top + (baselineInPixels - DPIUtil.autoScaleUp(getDevice(), run.ascentInPoints));
long /*int*/ hFont = getItemFont(run);
OS.SelectObject(hdc, hFont);
if (fullSelection) {
@@ -1055,7 +1055,7 @@ RECT drawRunTextGDIP(long /*int*/ graphics, StyleItem run, RECT rect, long /*int
boolean fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end;
boolean partialSelection = hasSelection && !fullSelection && !(selectionStart > end || run.start > selectionEnd);
int drawY = rect.top + baselineInPixels;
- if (run.style != null && run.style.rise != 0) drawY -= DPIUtil.autoScaleUp(run.style.rise);
+ if (run.style != null && run.style.rise != 0) drawY -= DPIUtil.autoScaleUp(getDevice(), run.style.rise);
int drawX = rect.left;
long /*int*/ brush = color;
if (fullSelection) {
@@ -1206,7 +1206,7 @@ RECT drawStrikeout(long /*int*/ hdc, int x, int baselineInPixels, StyleItem[] li
}
}
RECT rect = new RECT();
- int riseInPixels = DPIUtil.autoScaleUp(style.rise);
+ int riseInPixels = DPIUtil.autoScaleUp(getDevice(), style.rise);
OS.SetRect(rect, x + left, baselineInPixels - run.strikeoutPos - riseInPixels, x + run.x + run.width, baselineInPixels - run.strikeoutPos + run.strikeoutThickness - riseInPixels);
long /*int*/ brush = OS.CreateSolidBrush(color);
OS.FillRect(hdc, rect, brush);
@@ -1256,7 +1256,7 @@ RECT drawStrikeoutGDIP(long /*int*/ graphics, int x, int baselineInPixels, Style
}
}
}
- int riseInPixels = DPIUtil.autoScaleUp(style.rise);
+ int riseInPixels = DPIUtil.autoScaleUp(getDevice(), style.rise);
if (clipRect != null) {
int gstate = Gdip.Graphics_Save(graphics);
if (clipRect.left == -1) clipRect.left = 0;
@@ -1314,7 +1314,7 @@ RECT drawUnderline(long /*int*/ hdc, int x, int baselineInPixels, int lineUnderl
}
}
RECT rect = new RECT();
- int riseInPixels = DPIUtil.autoScaleUp(style.rise);
+ int riseInPixels = DPIUtil.autoScaleUp(getDevice(), style.rise);
OS.SetRect(rect, x + left, baselineInPixels - lineUnderlinePos - riseInPixels, x + run.x + run.width, baselineInPixels - lineUnderlinePos + run.underlineThickness - riseInPixels);
if (clipRect != null) {
if (clipRect.left == -1) clipRect.left = 0;
@@ -1390,7 +1390,7 @@ RECT drawUnderline(long /*int*/ hdc, int x, int baselineInPixels, int lineUnderl
int penStyle = style.underlineStyle == UNDERLINE_IME_DASH ? OS.PS_DASH : OS.PS_DOT;
long /*int*/ pen = OS.CreatePen(penStyle, 1, color);
long /*int*/ oldPen = OS.SelectObject(hdc, pen);
- int descentInPixels = DPIUtil.autoScaleUp(run.descentInPoints);
+ int descentInPixels = DPIUtil.autoScaleUp(getDevice(), run.descentInPoints);
OS.SetRect(rect, rect.left, baselineInPixels + descentInPixels, rect.right, baselineInPixels + descentInPixels + run.underlineThickness);
OS.MoveToEx(hdc, rect.left, rect.top, 0);
OS.LineTo(hdc, rect.right, rect.top);
@@ -1446,7 +1446,7 @@ RECT drawUnderlineGDIP (long /*int*/ graphics, int x, int baselineInPixels, int
}
}
RECT rect = new RECT();
- int riseInPixels = DPIUtil.autoScaleUp(style.rise);
+ int riseInPixels = DPIUtil.autoScaleUp(getDevice(), style.rise);
OS.SetRect(rect, x + left, baselineInPixels - lineUnderlinePos - riseInPixels, x + run.x + run.width, baselineInPixels - lineUnderlinePos + run.underlineThickness - riseInPixels);
Rect gdipRect = null;
if (clipRect != null) {
@@ -1542,7 +1542,7 @@ RECT drawUnderlineGDIP (long /*int*/ graphics, int x, int baselineInPixels, int
gstate = Gdip.Graphics_Save(graphics);
Gdip.Graphics_SetClip(graphics, gdipRect, Gdip.CombineModeExclude);
}
- int descentInPixels = DPIUtil.autoScaleUp(run.descentInPoints);
+ int descentInPixels = DPIUtil.autoScaleUp(getDevice(), run.descentInPoints);
Gdip.Graphics_DrawLine(graphics, pen, rect.left, baselineInPixels + descentInPixels, run.width - run.length, baselineInPixels + descentInPixels);
if (gdipRect != null) {
Gdip.Graphics_Restore(graphics, gstate);
@@ -1609,7 +1609,7 @@ public int getAlignment () {
*/
public int getAscent () {
checkLayout();
- return DPIUtil.autoScaleDown(ascentInPixels);
+ return DPIUtil.autoScaleDown(getDevice(), ascentInPixels);
}
/**
@@ -1637,7 +1637,7 @@ public Rectangle getBounds () {
width = Math.max(width, lineWidth[line] + getLineIndent(line));
}
}
- return new Rectangle (0, 0, DPIUtil.autoScaleDown(width), lineY[lineY.length - 1]);
+ return new Rectangle (0, 0, DPIUtil.autoScaleDown(getDevice(), width), lineY[lineY.length - 1]);
}
/**
@@ -1656,7 +1656,7 @@ public Rectangle getBounds () {
*/
public Rectangle getBounds (int start, int end) {
checkLayout();
- return DPIUtil.autoScaleDown(getBoundsInPixels(start, end));
+ return DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels(start, end));
}
Rectangle getBoundsInPixels (int start, int end) {
@@ -1738,8 +1738,8 @@ Rectangle getBoundsInPixels (int start, int end) {
}
left = Math.min(left, runLead);
right = Math.max(right, runTrail);
- top = Math.min(top, DPIUtil.autoScaleUp(lineY[lineIndex]));
- bottom = Math.max(bottom, DPIUtil.autoScaleUp(lineY[lineIndex + 1] - lineSpacingInPoints));
+ top = Math.min(top, DPIUtil.autoScaleUp(getDevice(), lineY[lineIndex]));
+ bottom = Math.max(bottom, DPIUtil.autoScaleUp(getDevice(), lineY[lineIndex + 1] - lineSpacingInPoints));
}
return new Rectangle(left, top, right - left, bottom - top);
}
@@ -1760,7 +1760,7 @@ Rectangle getBoundsInPixels (int start, int end) {
*/
public int getDescent () {
checkLayout();
- return DPIUtil.autoScaleDown(descentInPixels);
+ return DPIUtil.autoScaleDown(getDevice(), descentInPixels);
}
/**
@@ -1791,7 +1791,7 @@ public Font getFont () {
*/
public int getIndent () {
checkLayout();
- return DPIUtil.autoScaleDown(getIndentInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getIndentInPixels());
}
int getIndentInPixels () {
@@ -1868,16 +1868,16 @@ public int getLevel (int offset) {
*/
public Rectangle getLineBounds (int lineIndex) {
checkLayout();
- return DPIUtil.autoScaleDown(getLineBoundsInPixels(lineIndex));
+ return DPIUtil.autoScaleDown(getDevice(), getLineBoundsInPixels(lineIndex));
}
Rectangle getLineBoundsInPixels(int lineIndex) {
computeRuns(null);
if (!(0 <= lineIndex && lineIndex < runs.length)) SWT.error(SWT.ERROR_INVALID_RANGE);
int x = getLineIndent(lineIndex);
- int y = DPIUtil.autoScaleUp(lineY[lineIndex]);
+ int y = DPIUtil.autoScaleUp(getDevice(), lineY[lineIndex]);
int width = lineWidth[lineIndex];
- int height = DPIUtil.autoScaleUp(lineY[lineIndex + 1] - lineY[lineIndex] - lineSpacingInPoints);
+ int height = DPIUtil.autoScaleUp(getDevice(), lineY[lineIndex + 1] - lineY[lineIndex] - lineSpacingInPoints);
return new Rectangle (x, y, width, height);
}
@@ -1980,9 +1980,9 @@ public FontMetrics getLineMetrics (int lineIndex) {
OS.DeleteDC(srcHdc);
device.internal_dispose_GC(hDC, null);
- int ascentInPoints = DPIUtil.autoScaleDown(Math.max(lptm.tmAscent, this.ascentInPixels));
- int descentInPoints = DPIUtil.autoScaleDown(Math.max(lptm.tmDescent, this.descentInPixels));
- int leadingInPoints = DPIUtil.autoScaleDown(lptm.tmInternalLeading);
+ int ascentInPoints = DPIUtil.autoScaleDown(getDevice(), Math.max(lptm.tmAscent, this.ascentInPixels));
+ int descentInPoints = DPIUtil.autoScaleDown(getDevice(), Math.max(lptm.tmDescent, this.descentInPixels));
+ int leadingInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmInternalLeading);
if (text.length() != 0) {
StyleItem[] lineRuns = runs[lineIndex];
for (int i = 0; i<lineRuns.length; i++) {
@@ -1994,10 +1994,10 @@ public FontMetrics getLineMetrics (int lineIndex) {
descentInPoints = Math.max(descentInPoints, run.descentInPoints);
}
}
- lptm.tmAscent = DPIUtil.autoScaleUp(ascentInPoints);
- lptm.tmDescent = DPIUtil.autoScaleUp(descentInPoints);
- lptm.tmHeight = DPIUtil.autoScaleUp(ascentInPoints + descentInPoints);
- lptm.tmInternalLeading = DPIUtil.autoScaleUp(leadingInPoints);
+ lptm.tmAscent = DPIUtil.autoScaleUp(getDevice(), ascentInPoints);
+ lptm.tmDescent = DPIUtil.autoScaleUp(getDevice(), descentInPoints);
+ lptm.tmHeight = DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints);
+ lptm.tmInternalLeading = DPIUtil.autoScaleUp(getDevice(), leadingInPoints);
lptm.tmAveCharWidth = 0;
return FontMetrics.win32_new(lptm);
}
@@ -2041,7 +2041,7 @@ public int[] getLineOffsets () {
*/
public Point getLocation (int offset, boolean trailing) {
checkLayout();
- return DPIUtil.autoScaleDown(getLocationInPixels(offset, trailing));
+ return DPIUtil.autoScaleDown(getDevice(), getLocationInPixels(offset, trailing));
}
Point getLocationInPixels (int offset, boolean trailing) {
@@ -2056,7 +2056,7 @@ Point getLocationInPixels (int offset, boolean trailing) {
}
line = Math.min(line, runs.length - 1);
if (offset == length) {
- return new Point(getLineIndent(line) + lineWidth[line], DPIUtil.autoScaleUp(lineY[line]));
+ return new Point(getLineIndent(line) + lineWidth[line], DPIUtil.autoScaleUp(getDevice(), lineY[line]));
}
/* For trailing use the low surrogate and for lead use the high surrogate */
char ch = segmentsText.charAt(offset);
@@ -2104,7 +2104,7 @@ Point getLocationInPixels (int offset, boolean trailing) {
OS.ScriptCPtoX(runOffset, trailing, cChars, gGlyphs, run.clusters, run.visAttrs, advances, run.analysis, piX);
width = (orientation & SWT.RIGHT_TO_LEFT) != 0 ? run.width - piX[0] : piX[0];
}
- return new Point(run.x + width, DPIUtil.autoScaleUp(lineY[line]));
+ return new Point(run.x + width, DPIUtil.autoScaleUp(getDevice(), lineY[line]));
}
}
return new Point(0, 0);
@@ -2237,7 +2237,7 @@ int _getOffset(int offset, int movement, boolean forward) {
*/
public int getOffset (Point point, int[] trailing) {
checkLayout();
- if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); return getOffsetInPixels(DPIUtil.autoScaleUp(point), trailing);
+ if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); return getOffsetInPixels(DPIUtil.autoScaleUp(getDevice(), point), trailing);
}
int getOffsetInPixels (Point point, int[] trailing) {
@@ -2269,7 +2269,7 @@ int getOffsetInPixels (Point point, int[] trailing) {
*/
public int getOffset (int x, int y, int[] trailing) {
checkLayout();
- return getOffsetInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), trailing);
+ return getOffsetInPixels(DPIUtil.autoScaleUp(getDevice(), x), DPIUtil.autoScaleUp(getDevice(), y), trailing);
}
int getOffsetInPixels (int x, int y, int[] trailing) {
@@ -2278,7 +2278,7 @@ int getOffsetInPixels (int x, int y, int[] trailing) {
int line;
int lineCount = runs.length;
for (line=0; line<lineCount; line++) {
- if (DPIUtil.autoScaleUp(lineY[line + 1]) > y) break;
+ if (DPIUtil.autoScaleUp(getDevice(), lineY[line + 1]) > y) break;
}
line = Math.min(line, runs.length - 1);
StyleItem[] lineRuns = runs[line];
@@ -2581,7 +2581,7 @@ public TextStyle[] getStyles () {
*/
public int[] getTabs () {
checkLayout();
- return DPIUtil.autoScaleDown (getTabsInPixels ());
+ return DPIUtil.autoScaleDown (getDevice(), getTabsInPixels ());
}
int[] getTabsInPixels () {
@@ -2629,7 +2629,7 @@ public int getTextDirection () {
*/
public int getWidth () {
checkLayout();
- return DPIUtil.autoScaleDown(getWidthInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getWidthInPixels());
}
int getWidthInPixels () {
@@ -2649,7 +2649,7 @@ int getWidthInPixels () {
*/
public int getWrapIndent () {
checkLayout();
- return DPIUtil.autoScaleDown(getWrapIndentInPixels());
+ return DPIUtil.autoScaleDown(getDevice(), getWrapIndentInPixels());
}
int getWrapIndentInPixels () {
@@ -2915,7 +2915,7 @@ public void setAlignment (int alignment) {
public void setAscent (int ascent) {
checkLayout();
if (ascent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- ascent = DPIUtil.autoScaleUp(ascent);
+ ascent = DPIUtil.autoScaleUp(getDevice(), ascent);
if (this.ascentInPixels == ascent) return;
freeRuns();
this.ascentInPixels = ascent;
@@ -2942,7 +2942,7 @@ public void setAscent (int ascent) {
public void setDescent (int descent) {
checkLayout();
if (descent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- descent = DPIUtil.autoScaleUp(descent);
+ descent = DPIUtil.autoScaleUp(getDevice(), descent);
if (this.descentInPixels == descent) return;
freeRuns();
this.descentInPixels = descent;
@@ -2990,7 +2990,7 @@ public void setFont (Font font) {
*/
public void setIndent (int indent) {
checkLayout();
- setIndentInPixels(DPIUtil.autoScaleUp(indent));
+ setIndentInPixels(DPIUtil.autoScaleUp(getDevice(), indent));
}
void setIndentInPixels (int indent) {
@@ -3241,7 +3241,7 @@ public void setStyle (TextStyle style, int start, int end) {
public void setTabs (int[] tabs) {
checkLayout();
if (this.tabs == null && tabs == null) return;
- setTabsInPixels (DPIUtil.autoScaleUp (tabs));
+ setTabsInPixels (DPIUtil.autoScaleUp (getDevice(), tabs));
}
void setTabsInPixels (int[] tabs) {
@@ -3328,7 +3328,7 @@ public void setTextDirection (int textDirection) {
*/
public void setWidth (int width) {
checkLayout();
- setWidthInPixels(width != SWT.DEFAULT ? DPIUtil.autoScaleUp(width) : width);
+ setWidthInPixels(width != SWT.DEFAULT ? DPIUtil.autoScaleUp(getDevice(), width) : width);
}
void setWidthInPixels (int width) {
@@ -3354,7 +3354,7 @@ void setWidthInPixels (int width) {
*/
public void setWrapIndent (int wrapIndent) {
checkLayout();
- setWrapIndentInPixels(DPIUtil.autoScaleUp(wrapIndent));
+ setWrapIndentInPixels(DPIUtil.autoScaleUp(getDevice(), wrapIndent));
}
void setWrapIndentInPixels (int wrapIndent) {
@@ -3614,9 +3614,9 @@ void shape (final long /*int*/ hdc, final StyleItem run) {
lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
OS.GetTextMetrics(hdc, lptm);
}
- run.ascentInPoints = DPIUtil.autoScaleDown(lptm.tmAscent);
- run.descentInPoints = DPIUtil.autoScaleDown(lptm.tmDescent);
- run.leadingInPoints = DPIUtil.autoScaleDown(lptm.tmInternalLeading);
+ run.ascentInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmAscent);
+ run.descentInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmDescent);
+ run.leadingInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmInternalLeading);
}
if (lotm != null) {
run.underlinePos = lotm.otmsUnderscorePosition;
@@ -3626,7 +3626,7 @@ void shape (final long /*int*/ hdc, final StyleItem run) {
} else {
run.underlinePos = 1;
run.underlineThickness = 1;
- run.strikeoutPos = DPIUtil.autoScaleUp(run.ascentInPoints) / 2;
+ run.strikeoutPos = DPIUtil.autoScaleUp(getDevice(), run.ascentInPoints) / 2;
run.strikeoutThickness = 1;
}
run.ascentInPoints += style.rise;
@@ -3634,9 +3634,9 @@ void shape (final long /*int*/ hdc, final StyleItem run) {
} else {
TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
OS.GetTextMetrics(hdc, lptm);
- run.ascentInPoints = DPIUtil.autoScaleDown(lptm.tmAscent);
- run.descentInPoints = DPIUtil.autoScaleDown(lptm.tmDescent);
- run.leadingInPoints = DPIUtil.autoScaleDown(lptm.tmInternalLeading);
+ run.ascentInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmAscent);
+ run.descentInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmDescent);
+ run.leadingInPoints = DPIUtil.autoScaleDown(getDevice(), lptm.tmInternalLeading);
}
}
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 4fbbbcf82d..2d9623939b 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
@@ -1849,6 +1849,11 @@ boolean isActive () {
return shell.getEnabled ();
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
/**
* Returns <code>true</code> if the receiver is enabled and all
* ancestors up to and including the receiver's nearest ancestor
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index f9870e63c4..ab15c138a2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -1712,6 +1712,11 @@ public static Display getDefault () {
}
}
+@Override
+public boolean isAutoScalable() {
+ return true;
+}
+
static boolean isValidClass (Class clazz) {
String name = clazz.getName ();
int index = name.lastIndexOf ('.');
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_printing_Printer.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_printing_Printer.java
index bdc7e20bc2..31fac4bf0b 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_printing_Printer.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_printing_Printer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -174,4 +174,15 @@ public void test_getPrinterList() {
assertTrue("printer list is empty", list.length > 0);
}
}
+
+@Test
+public void test_isAutoScalable() {
+ PrinterData data = Printer.getDefaultPrinterData();
+ // if there aren't any printers, don't do this test
+ if (data == null) return;
+ Printer printer = new Printer(data);
+ boolean isAutoScalable = printer.isAutoScalable();
+ assertFalse("SWT doesnot auto-scale for Printer devices", isAutoScalable);
+ printer.dispose();
+}
}

Back to the top