Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2016-03-12 07:14:49 +0000
committerNiraj Modi2016-03-12 07:14:49 +0000
commite02d49aefe42ac4c77b81048299ab069ddb5c2ba (patch)
treeee78920992cfda51890cca0bf5fb394c876add83
parentf50994fe9b815dddd13700087e2289575a82e8b7 (diff)
downloadeclipse.platform.swt-e02d49aefe42ac4c77b81048299ab069ddb5c2ba.tar.gz
eclipse.platform.swt-e02d49aefe42ac4c77b81048299ab069ddb5c2ba.tar.xz
eclipse.platform.swt-e02d49aefe42ac4c77b81048299ab069ddb5c2ba.zip
Bug 479614 - [Graphics] HiDPI support for eclipse platform
- Windows changes Change-Id: I9cd0004d57a2a3a2a956a71de91b10af560c08a7 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c686
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/DrawData.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebUIDelegate.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java73
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/GlyphMetrics.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java313
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Monitor.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java316
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java149
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java97
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Pattern.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java59
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java145
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java45
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java159
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java43
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java82
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java35
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java25
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java39
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java96
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java33
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java138
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java27
82 files changed, 2756 insertions, 862 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
index 66c684d799..35cc62c76b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java
@@ -18,6 +18,7 @@ import java.lang.reflect.*;
/* SWT Imports */
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
@@ -303,7 +304,7 @@ public static Frame new_Frame (final Composite parent) {
@Override
public void run () {
if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea()); // To Pixels
EventQueue.invokeLater(new Runnable () {
@Override
public void run () {
@@ -353,7 +354,7 @@ public static Shell new_Shell (final Display display, final Canvas parent) {
public void run () {
if (shell.isDisposed()) return;
Dimension dim = parent.getSize ();
- shell.setSize (dim.width, dim.height);
+ shell.setSize(DPIUtil.autoScaleDown(new Point(dim.width, dim.height))); // To Points
}
});
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
index 02d12bf500..ce4ca4c4e3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
@@ -1898,7 +1898,7 @@ void handleDOMEvent (OleEvent e) {
int screenY = pVarResult.getInt();
pVarResult.dispose();
- Point position = new Point(screenX, screenY);
+ Point position = DPIUtil.autoScaleDown(new Point(screenX, screenY)); // To Points
position = browser.getDisplay().map(null, browser, position);
newEvent.x = position.x; newEvent.y = position.y;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java
index 63c33e8c5b..f1527106c5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java
@@ -322,6 +322,8 @@ int ShowContextMenu(int dwID, long /*int*/ ppt, long /*int*/ pcmdtReserved, long
Event event = new Event();
POINT pt = new POINT();
OS.MoveMemory(pt, ppt, POINT.sizeof);
+ pt.x = DPIUtil.autoScaleDown(pt.x); // To Points
+ pt.y = DPIUtil.autoScaleDown(pt.y); // To Points
event.x = pt.x;
event.y = pt.y;
browser.notifyListeners(SWT.MenuDetect, event);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index d64e2edbf7..ac8b24788a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -14,6 +14,8 @@ import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.DPIUtil.*;
import org.eclipse.swt.widgets.*;
/**
@@ -719,10 +721,10 @@ Image createButtonImage(Display display, int button) {
renderer.draw(button, SWT.NONE, new Rectangle(trim.x, trim.y, size.x, size.y), gc);
gc.dispose ();
transColor.dispose();
- ImageData imageData = image.getImageData();
+ final ImageData imageData = image.getImageDataAtCurrentZoom();
imageData.transparentPixel = imageData.palette.getPixel(transparent);
image.dispose();
- image = new Image(display, imageData);
+ image = new Image(display, new AutoScaleImageDataProvider(imageData, DPIUtil.getDeviceZoom()));
return image;
}
void createItem (CTabItem item, int index) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java
index 09e72e7217..c9cfa43987 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.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
@@ -935,9 +935,9 @@ public class CTabFolderRenderer {
gc.drawLine(x+1,y, x+3,y+2);
gc.drawLine(x+3,y+2, x+1,y+4);
gc.drawLine(x+4,y, x+6,y+2);
- gc.drawLine(x+6,y+2, x+5,y+4);
+ gc.drawLine(x+6,y+2, x+4,y+4);
gc.drawLine(x+5,y, x+7,y+2);
- gc.drawLine(x+7,y+2, x+4,y+4);
+ gc.drawLine(x+7,y+2, x+5,y+4);
gc.drawString(chevronString, x+7, y+3, true);
break;
}
@@ -952,9 +952,9 @@ public class CTabFolderRenderer {
gc.drawLine(x+1,y, x+3,y+2);
gc.drawLine(x+3,y+2, x+1,y+4);
gc.drawLine(x+4,y, x+6,y+2);
- gc.drawLine(x+6,y+2, x+5,y+4);
+ gc.drawLine(x+6,y+2, x+4,y+4);
gc.drawLine(x+5,y, x+7,y+2);
- gc.drawLine(x+7,y+2, x+4,y+4);
+ gc.drawLine(x+7,y+2, x+5,y+4);
gc.drawString(chevronString, x+7, y+3, true);
break;
}
@@ -969,9 +969,9 @@ public class CTabFolderRenderer {
gc.drawLine(x+2,y+1, x+4,y+3);
gc.drawLine(x+4,y+3, x+2,y+5);
gc.drawLine(x+5,y+1, x+7,y+3);
- gc.drawLine(x+7,y+3, x+6,y+5);
+ gc.drawLine(x+7,y+3, x+5,y+5);
gc.drawLine(x+6,y+1, x+8,y+3);
- gc.drawLine(x+8,y+3, x+5,y+5);
+ gc.drawLine(x+8,y+3, x+6,y+5);
gc.drawString(chevronString, x+8, y+4, true);
break;
}
@@ -1129,14 +1129,14 @@ public class CTabFolderRenderer {
if (!parent.getMaximized()) {
gc.fillRectangle(x, y, 9, 9);
gc.drawRectangle(x, y, 9, 9);
- gc.drawLine(x+1, y+2, x+8, y+2);
+ gc.drawLine(x, y+2, x+9, y+2);
} else {
gc.fillRectangle(x, y+3, 5, 4);
gc.fillRectangle(x+2, y, 5, 4);
gc.drawRectangle(x, y+3, 5, 4);
gc.drawRectangle(x+2, y, 5, 4);
- gc.drawLine(x+3, y+1, x+6, y+1);
- gc.drawLine(x+1, y+4, x+4, y+4);
+ gc.drawLine(x+2, y+1, x+7, y+1);
+ gc.drawLine(x, y+4, x+5, y+4);
}
break;
}
@@ -1146,14 +1146,14 @@ public class CTabFolderRenderer {
if (!parent.getMaximized()) {
gc.fillRectangle(x, y, 9, 9);
gc.drawRectangle(x, y, 9, 9);
- gc.drawLine(x+1, y+2, x+8, y+2);
+ gc.drawLine(x, y+2, x+9, y+2);
} else {
gc.fillRectangle(x, y+3, 5, 4);
gc.fillRectangle(x+2, y, 5, 4);
gc.drawRectangle(x, y+3, 5, 4);
gc.drawRectangle(x+2, y, 5, 4);
- gc.drawLine(x+3, y+1, x+6, y+1);
- gc.drawLine(x+1, y+4, x+4, y+4);
+ gc.drawLine(x+2, y+1, x+7, y+1);
+ gc.drawLine(x, y+4, x+5, y+4);
}
break;
}
@@ -1163,14 +1163,14 @@ public class CTabFolderRenderer {
if (!parent.getMaximized()) {
gc.fillRectangle(x+1, y+1, 9, 9);
gc.drawRectangle(x+1, y+1, 9, 9);
- gc.drawLine(x+2, y+3, x+9, y+3);
+ gc.drawLine(x+1, y+3, x+10, y+3);
} else {
gc.fillRectangle(x+1, y+4, 5, 4);
gc.fillRectangle(x+3, y+1, 5, 4);
gc.drawRectangle(x+1, y+4, 5, 4);
gc.drawRectangle(x+3, y+1, 5, 4);
- gc.drawLine(x+4, y+2, x+7, y+2);
- gc.drawLine(x+2, y+5, x+5, y+5);
+ gc.drawLine(x+3, y+2, x+8, y+2);
+ gc.drawLine(x+1, y+5, x+6, y+5);
}
break;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
index 177bcaa6dc..d0d1b4667b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.custom;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
/**
* A TableCursor provides a way for the user to navigate around a Table
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java
index db76bb35c0..7dbb5dfc6b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.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
@@ -11,6 +11,7 @@
package org.eclipse.swt.dnd;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.widgets.*;
@@ -152,7 +153,7 @@ public class TableDropTargetEffect extends DropTargetEffect {
} else {
if (index != -1 && scrollIndex == index && scrollBeginTime != 0) {
if (System.currentTimeMillis() >= scrollBeginTime) {
- if (coordinates.y < table.getItemHeight()) {
+ if (coordinates.y < DPIUtil.autoScaleUp(table.getItemHeight())) {
OS.gtk_tree_path_prev(path[0]);
} else {
OS.gtk_tree_path_next(path[0]);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
index 1dd5c660f0..162c67fa9e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
@@ -13,10 +13,10 @@ package org.eclipse.swt.dnd;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.widgets.*;
/**
*
@@ -334,7 +334,7 @@ private void drag(Event dragEvent) {
int offsetX = event.offsetX;
hwndDrag = topControl.handle;
if ((topControl.getStyle() & SWT.RIGHT_TO_LEFT) != 0) {
- offsetX = image.getBounds().width - offsetX;
+ offsetX = image.getBoundsInPixels().width - offsetX;
RECT rect = new RECT ();
OS.GetClientRect (topControl.handle, rect);
hwndDrag = OS.CreateWindowEx (
@@ -366,8 +366,8 @@ private void drag(Event dragEvent) {
OS.RedrawWindow (topControl.handle, null, 0, flags);
}
POINT pt = new POINT ();
- pt.x = dragEvent.x;
- pt.y = dragEvent.y;
+ pt.x = DPIUtil.autoScaleUp(dragEvent.x);// To Pixels
+ pt.y = DPIUtil.autoScaleUp(dragEvent.y);// To Pixels
OS.MapWindowPoints (control.handle, 0, pt, 1);
RECT rect = new RECT ();
OS.GetWindowRect (hwndDrag, rect);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
index 9c4ce9ba2c..be567ca1a4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.dnd;
import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.widgets.*;
/**
*
@@ -286,6 +286,8 @@ int DragEnter_64(long /*int*/ pDataObject, int grfKeyState, long pt, long /*int*
}
int DragEnter(long /*int*/ pDataObject, int grfKeyState, int pt_x, int pt_y, long /*int*/ pdwEffect) {
+ pt_x = DPIUtil.autoScaleDown(pt_x);// To Points
+ pt_y = DPIUtil.autoScaleDown(pt_y);// To Points
selectedDataType = null;
selectedOperation = DND.DROP_NONE;
if (iDataObject != null) iDataObject.Release();
@@ -351,6 +353,8 @@ int DragOver_64(int grfKeyState, long pt, long /*int*/ pdwEffect) {
}
int DragOver(int grfKeyState, int pt_x, int pt_y, long /*int*/ pdwEffect) {
+ pt_x = DPIUtil.autoScaleDown(pt_x);// To Points
+ pt_y = DPIUtil.autoScaleDown(pt_y);// To Points
if (iDataObject == null) return COM.S_FALSE;
int oldKeyOperation = keyOperation;
@@ -403,6 +407,8 @@ int Drop_64(long /*int*/ pDataObject, int grfKeyState, long pt, long /*int*/ pdw
}
int Drop(long /*int*/ pDataObject, int grfKeyState, int pt_x, int pt_y, long /*int*/ pdwEffect) {
+ pt_x = DPIUtil.autoScaleDown(pt_x);// To Points
+ pt_y = DPIUtil.autoScaleDown(pt_y);// To Points
DNDEvent event = new DNDEvent();
event.widget = this;
event.time = OS.GetMessageTime();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java
index d841910c8f..4a4e735fcc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java
@@ -181,7 +181,7 @@ public Object nativeToJava(TransferData transferData) {
}
}
Image image = Image.win32_new(null, SWT.BITMAP, memDib);
- ImageData data = image.getImageData();
+ ImageData data = image.getImageDataAtCurrentZoom();
OS.DeleteObject(memDib);
image.dispose();
return data;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java
index 686c8f8c74..5eb5319d21 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java
@@ -12,6 +12,8 @@ package org.eclipse.swt.dnd;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.DPIUtil.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
@@ -142,7 +144,7 @@ public class TableDragSourceEffect extends DragSourceEffect {
} else {
data.transparentPixel = shdi.crColorKey << 8;
}
- dragSourceImage = new Image(control.getDisplay(), data);
+ dragSourceImage = new Image(control.getDisplay(), new AutoScaleImageDataProvider(data, DPIUtil.getDeviceZoom()));
OS.SelectObject (memHdc, oldMemBitmap);
OS.DeleteDC (memHdc);
OS.DeleteObject (memDib);
@@ -163,9 +165,9 @@ public class TableDragSourceEffect extends DragSourceEffect {
long /*int*/ tableImageList = OS.SendMessage (table.handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
if (tableImageList != 0) {
int count = Math.min(selection.length, 10);
- Rectangle bounds = selection[0].getBounds(0);
+ Rectangle bounds = DPIUtil.autoScaleUp(selection[0].getBounds(0));
for (int i = 1; i < count; i++) {
- bounds = bounds.union(selection[i].getBounds(0));
+ bounds = bounds.union(DPIUtil.autoScaleUp(selection[i].getBounds(0)));
}
long /*int*/ hDC = OS.GetDC(0);
long /*int*/ hDC1 = OS.CreateCompatibleDC(hDC);
@@ -183,7 +185,7 @@ public class TableDragSourceEffect extends DragSourceEffect {
OS.FillRect(hDC1, rect, hBrush);
for (int i = 0; i < count; i++) {
TableItem selected = selection[i];
- Rectangle cell = selected.getBounds(0);
+ Rectangle cell = DPIUtil.autoScaleUp(selected.getBounds(0));
POINT pt = new POINT();
long /*int*/ imageList = OS.SendMessage (table.handle, OS.LVM_CREATEDRAGIMAGE, table.indexOf(selected), pt);
OS.ImageList_Draw(imageList, 0, hDC1, cell.x - bounds.x, cell.y - bounds.y, OS.ILD_SELECTED);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java
index 6eb6b288ad..e9291a2df0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.dnd;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
@@ -151,7 +152,7 @@ public class TableDropTargetEffect extends DropTargetEffect {
int effect = checkEffect(event.feedback);
long /*int*/ handle = table.handle;
Point coordinates = new Point(event.x, event.y);
- coordinates = table.toControl(coordinates);
+ coordinates = DPIUtil.autoScaleUp(table.toControl(coordinates)); // To Pixels
LVHITTESTINFO pinfo = new LVHITTESTINFO();
pinfo.x = coordinates.x;
pinfo.y = coordinates.y;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java
index e6781bef49..a0e6e99d0e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java
@@ -12,6 +12,8 @@ package org.eclipse.swt.dnd;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.DPIUtil.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
@@ -141,7 +143,7 @@ public class TreeDragSourceEffect extends DragSourceEffect {
} else {
data.transparentPixel = shdi.crColorKey << 8;
}
- dragSourceImage = new Image (control.getDisplay (), data);
+ dragSourceImage = new Image (control.getDisplay (), new AutoScaleImageDataProvider(data, DPIUtil.getDeviceZoom()));
OS.SelectObject (memHdc, oldMemBitmap);
OS.DeleteDC (memHdc);
OS.DeleteObject (memDib);
@@ -163,9 +165,9 @@ public class TreeDragSourceEffect extends DragSourceEffect {
long /*int*/ treeImageList = OS.SendMessage (tree.handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
if (treeImageList != 0) {
int count = Math.min(selection.length, 10);
- Rectangle bounds = selection[0].getBounds(0);
+ Rectangle bounds = DPIUtil.autoScaleUp(selection[0].getBounds(0));
for (int i = 1; i < count; i++) {
- bounds = bounds.union(selection[i].getBounds(0));
+ bounds = bounds.union(DPIUtil.autoScaleUp(selection[i].getBounds(0)));
}
long /*int*/ hDC = OS.GetDC(tree.handle);
long /*int*/ hDC1 = OS.CreateCompatibleDC(hDC);
@@ -178,7 +180,7 @@ public class TreeDragSourceEffect extends DragSourceEffect {
OS.FillRect(hDC1, rect, hBrush);
for (int i = 0; i < count; i++) {
TreeItem selected = selection[i];
- Rectangle cell = selected.getBounds(0);
+ Rectangle cell = DPIUtil.autoScaleUp(selected.getBounds(0));
long /*int*/ imageList = OS.SendMessage(tree.handle, OS.TVM_CREATEDRAGIMAGE, 0, selected.handle);
OS.ImageList_Draw(imageList, 0, hDC1, cell.x - bounds.x, cell.y - bounds.y, OS.ILD_SELECTED);
OS.ImageList_Destroy(imageList);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java
index 16897d918f..98d28437c7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.dnd;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
@@ -162,7 +163,7 @@ public class TreeDropTargetEffect extends DropTargetEffect {
int effect = checkEffect(event.feedback);
long /*int*/ handle = tree.handle;
Point coordinates = new Point(event.x, event.y);
- coordinates = tree.toControl(coordinates);
+ coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); // To Pixels
TVHITTESTINFO lpht = new TVHITTESTINFO ();
lpht.x = coordinates.x;
lpht.y = coordinates.y;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
index 674aec2964..82940c6607 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
@@ -4704,6 +4704,8 @@ int OnShowContextMenu (int aContextFlags, long /*int*/ aEvent, long /*int*/ aNod
domMouseEvent.Release ();
Event event = new Event ();
+ aScreenX[0] = DPIUtil.autoScaleDown(aScreenX[0]); // To Points
+ aScreenY[0] = DPIUtil.autoScaleDown(aScreenY[0]); // To Points
event.x = aScreenX[0];
event.y = aScreenY[0];
browser.notifyListeners (SWT.MenuDetect, event);
@@ -5154,7 +5156,7 @@ int HandleEvent (long /*int*/ event) {
if (rc != XPCOM.NS_OK) error (rc);
rc = domMouseEvent.GetScreenY (aScreenY);
if (rc != XPCOM.NS_OK) error (rc);
- Point position = new Point (aScreenX[0], aScreenY[0]);
+ Point position = DPIUtil.autoScaleDown(new Point (aScreenX[0], aScreenY[0]));// To Points
position = browser.getDisplay ().map (null, browser, position);
int[] aDetail = new int[1]; /* PRInt32 */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
index 242b3bf76e..cf4e1d1918 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
@@ -10,17 +10,14 @@
*******************************************************************************/
package org.eclipse.swt.ole.win32;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
+import java.io.*;
+
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.C;
-import org.eclipse.swt.internal.Compatibility;
-import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.widgets.*;
/**
* OleClientSite provides a site to manage an embedded OLE Document within a container.
*
@@ -829,7 +826,7 @@ protected int GetWindow(long /*int*/ phwnd) {
return COM.S_OK;
}
RECT getRect() {
- Rectangle area = getClientArea();
+ Rectangle area = DPIUtil.autoScaleUp(getClientArea()); // To Pixels
RECT rect = new RECT();
rect.left = area.x;
rect.top = area.y;
@@ -1006,14 +1003,14 @@ private int OnInPlaceDeactivate() {
return COM.S_OK;
}
private int OnPosRectChange(long /*int*/ lprcPosRect) {
- Point size = getSize();
+ Point size = DPIUtil.autoScaleUp(getSize()); // To Pixels
setExtent(size.x, size.y);
return COM.S_OK;
}
private void onPaint(Event e) {
if (state == STATE_RUNNING || state == STATE_INPLACEACTIVE) {
SIZE size = getExtent();
- Rectangle area = getClientArea();
+ Rectangle area = DPIUtil.autoScaleUp(getClientArea()); // To Pixels
RECT rect = new RECT();
if (getProgramID().startsWith("Excel.Sheet")) { //$NON-NLS-1$
rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy);
@@ -1403,11 +1400,11 @@ void setBorderSpace(RECT newBorderwidth) {
setBounds();
}
void setBounds() {
- Rectangle area = frame.getClientArea();
- setBounds(borderWidths.left,
- borderWidths.top,
- area.width - borderWidths.left - borderWidths.right,
- area.height - borderWidths.top - borderWidths.bottom);
+ Rectangle area = DPIUtil.autoScaleUp(frame.getClientArea()); // To Pixels
+ setBounds(DPIUtil.autoScaleDown(borderWidths.left),
+ DPIUtil.autoScaleDown(borderWidths.top),
+ DPIUtil.autoScaleDown(area.width - borderWidths.left - borderWidths.right),
+ DPIUtil.autoScaleDown(area.height - borderWidths.top - borderWidths.bottom));
setObjectRects();
}
private void setExtent(int width, int height){
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
index 6c7c7b4c29..932aa25263 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
@@ -1364,10 +1364,24 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CreateBitmap)
jbyte *lparg4=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, CreateBitmap_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)CreateBitmap(arg0, arg1, arg2, arg3, (CONST VOID *)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, CreateBitmap_FUNC);
return rc;
}
@@ -1417,12 +1431,28 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CreateCursor)
jbyte *lparg6=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, CreateCursor_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg5) if ((lparg5 = (*env)->GetPrimitiveArrayCritical(env, arg5, NULL)) == NULL) goto fail;
if (arg6) if ((lparg6 = (*env)->GetPrimitiveArrayCritical(env, arg6, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+ if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)CreateCursor((HINSTANCE)arg0, arg1, arg2, arg3, arg4, (CONST VOID *)lparg5, (CONST VOID *)lparg6);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg6 && lparg6) (*env)->ReleasePrimitiveArrayCritical(env, arg6, lparg6, JNI_ABORT);
if (arg5 && lparg5) (*env)->ReleasePrimitiveArrayCritical(env, arg5, lparg5, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, JNI_ABORT);
+ if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, CreateCursor_FUNC);
return rc;
}
@@ -1480,10 +1510,24 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CreateDIBSection__JJI_3JJI)(JNIEnv *env, jc
#else
OS_NATIVE_ENTER(env, that, CreateDIBSection__JJI_3JJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)CreateDIBSection((HDC)arg0, (BITMAPINFO *)arg1, arg2, (VOID **)lparg3, (HANDLE)arg4, arg5);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, CreateDIBSection__III_3III_FUNC);
#else
@@ -1508,12 +1552,28 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CreateDIBSection__J_3BI_3JJI)(JNIEnv *env,
#else
OS_NATIVE_ENTER(env, that, CreateDIBSection__J_3BI_3JJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)CreateDIBSection((HDC)arg0, (BITMAPINFO *)lparg1, arg2, (VOID **)lparg3, (HANDLE)arg4, arg5);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, CreateDIBSection__I_3BI_3III_FUNC);
#else
@@ -1677,10 +1737,24 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CreatePalette)
jbyte *lparg0=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, CreatePalette_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)CreatePalette((LOGPALETTE *)lparg0);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, CreatePalette_FUNC);
return rc;
}
@@ -2446,10 +2520,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(DrawTextA)
jint rc = 0;
OS_NATIVE_ENTER(env, that, DrawTextA_FUNC);
if (arg3) if ((lparg3 = getRECTFields(env, arg3, &_arg3)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jint)DrawTextA((HDC)arg0, (LPSTR)lparg1, arg2, lparg3, arg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg3 && lparg3) setRECTFields(env, arg3, lparg3);
OS_NATIVE_EXIT(env, that, DrawTextA_FUNC);
return rc;
@@ -2465,10 +2553,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(DrawTextW)
jint rc = 0;
OS_NATIVE_ENTER(env, that, DrawTextW_FUNC);
if (arg3) if ((lparg3 = getRECTFields(env, arg3, &_arg3)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jint)DrawTextW((HDC)arg0, (LPWSTR)lparg1, arg2, lparg3, arg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg3 && lparg3) setRECTFields(env, arg3, lparg3);
OS_NATIVE_EXIT(env, that, DrawTextW_FUNC);
return rc;
@@ -3197,12 +3299,28 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(ExtTextOutA)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, ExtTextOutA_FUNC);
if (arg4) if ((lparg4 = getRECTFields(env, arg4, &_arg4)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg5) if ((lparg5 = (*env)->GetPrimitiveArrayCritical(env, arg5, NULL)) == NULL) goto fail;
if (arg7) if ((lparg7 = (*env)->GetPrimitiveArrayCritical(env, arg7, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+ if (arg7) if ((lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)ExtTextOutA((HDC)arg0, arg1, arg2, arg3, lparg4, (LPSTR)lparg5, arg6, (CONST INT *)lparg7);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg7 && lparg7) (*env)->ReleasePrimitiveArrayCritical(env, arg7, lparg7, JNI_ABORT);
if (arg5 && lparg5) (*env)->ReleasePrimitiveArrayCritical(env, arg5, lparg5, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg7 && lparg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, JNI_ABORT);
+ if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, ExtTextOutA_FUNC);
return rc;
}
@@ -3218,12 +3336,28 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(ExtTextOutW)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, ExtTextOutW_FUNC);
if (arg4) if ((lparg4 = getRECTFields(env, arg4, &_arg4)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg5) if ((lparg5 = (*env)->GetPrimitiveArrayCritical(env, arg5, NULL)) == NULL) goto fail;
if (arg7) if ((lparg7 = (*env)->GetPrimitiveArrayCritical(env, arg7, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg5) if ((lparg5 = (*env)->GetCharArrayElements(env, arg5, NULL)) == NULL) goto fail;
+ if (arg7) if ((lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)ExtTextOutW((HDC)arg0, arg1, arg2, arg3, lparg4, (LPWSTR)lparg5, arg6, (CONST INT *)lparg7);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg7 && lparg7) (*env)->ReleasePrimitiveArrayCritical(env, arg7, lparg7, JNI_ABORT);
if (arg5 && lparg5) (*env)->ReleasePrimitiveArrayCritical(env, arg5, lparg5, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg7 && lparg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, JNI_ABORT);
+ if (arg5 && lparg5) (*env)->ReleaseCharArrayElements(env, arg5, lparg5, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, ExtTextOutW_FUNC);
return rc;
}
@@ -3640,10 +3774,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharABCWidthsA)
jint *lparg3=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, GetCharABCWidthsA_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)GetCharABCWidthsA((HDC)arg0, arg1, arg2, (LPABC)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetCharABCWidthsA_FUNC);
return rc;
}
@@ -3656,10 +3804,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharABCWidthsW)
jint *lparg3=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, GetCharABCWidthsW_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)GetCharABCWidthsW((HDC)arg0, arg1, arg2, (LPABC)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetCharABCWidthsW_FUNC);
return rc;
}
@@ -3672,10 +3834,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharWidthA)
jint *lparg3=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, GetCharWidthA_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)GetCharWidthA((HDC)arg0, arg1, arg2, (LPINT)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetCharWidthA_FUNC);
return rc;
}
@@ -3688,10 +3864,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharWidthW)
jint *lparg3=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, GetCharWidthW_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)GetCharWidthW((HDC)arg0, arg1, arg2, (LPINT)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetCharWidthW_FUNC);
return rc;
}
@@ -3706,10 +3896,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetCharacterPlacementA)
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetCharacterPlacementA_FUNC);
if (arg4) if ((lparg4 = getGCP_RESULTSFields(env, arg4, &_arg4)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetCharacterPlacementA((HDC)arg0, (LPSTR)lparg1, arg2, arg3, lparg4, arg5);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg4 && lparg4) setGCP_RESULTSFields(env, arg4, lparg4);
OS_NATIVE_EXIT(env, that, GetCharacterPlacementA_FUNC);
return rc;
@@ -3725,10 +3929,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetCharacterPlacementW)
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetCharacterPlacementW_FUNC);
if (arg4) if ((lparg4 = getGCP_RESULTSFields(env, arg4, &_arg4)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetCharacterPlacementW((HDC)arg0, (LPWSTR)lparg1, arg2, arg3, (LPGCP_RESULTSW)lparg4, arg5);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg4 && lparg4) setGCP_RESULTSFields(env, arg4, lparg4);
OS_NATIVE_EXIT(env, that, GetCharacterPlacementW_FUNC);
return rc;
@@ -4048,10 +4266,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetDIBColorTable)
jbyte *lparg3=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetDIBColorTable_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetDIBColorTable_FUNC);
return rc;
}
@@ -4065,12 +4297,28 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetDIBits)
jbyte *lparg5=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetDIBits_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
if (arg5) if ((lparg5 = (*env)->GetPrimitiveArrayCritical(env, arg5, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetDIBits((HDC)arg0, (HBITMAP)arg1, arg2, arg3, (LPVOID)lparg4, (LPBITMAPINFO)lparg5, arg6);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg5 && lparg5) (*env)->ReleasePrimitiveArrayCritical(env, arg5, lparg5, 0);
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
+ } else
+#endif
+ {
+ if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+ if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ }
OS_NATIVE_EXIT(env, that, GetDIBits_FUNC);
return rc;
}
@@ -5274,10 +5522,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetPaletteEntries)
jbyte *lparg3=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetPaletteEntries_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetPaletteEntries((HPALETTE)arg0, arg1, arg2, (LPPALETTEENTRY)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetPaletteEntries_FUNC);
return rc;
}
@@ -5487,10 +5749,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetRegionData)
jint *lparg2=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetRegionData_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetRegionData((HRGN)arg0, arg1, (RGNDATA *)lparg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ }
OS_NATIVE_EXIT(env, that, GetRegionData_FUNC);
return rc;
}
@@ -5691,10 +5967,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetSystemPaletteEntries)
jbyte *lparg3=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetSystemPaletteEntries_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jint)GetSystemPaletteEntries((HDC)arg0, (UINT)arg1, (UINT)arg2, (LPPALETTEENTRY)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ }
OS_NATIVE_EXIT(env, that, GetSystemPaletteEntries_FUNC);
return rc;
}
@@ -5733,10 +6023,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextExtentPoint32A)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, GetTextExtentPoint32A_FUNC);
if (arg3) if ((lparg3 = &_arg3) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)GetTextExtentPoint32A((HDC)arg0, (LPSTR)lparg1, arg2, lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg3 && lparg3) setSIZEFields(env, arg3, lparg3);
OS_NATIVE_EXIT(env, that, GetTextExtentPoint32A_FUNC);
return rc;
@@ -5752,10 +6056,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextExtentPoint32W)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, GetTextExtentPoint32W_FUNC);
if (arg3) if ((lparg3 = &_arg3) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)GetTextExtentPoint32W((HDC)arg0, (LPWSTR)lparg1, arg2, lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg3 && lparg3) setSIZEFields(env, arg3, lparg3);
OS_NATIVE_EXIT(env, that, GetTextExtentPoint32W_FUNC);
return rc;
@@ -9365,10 +9683,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3BI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3BI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3BI_FUNC);
#else
@@ -9390,10 +9722,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3CI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3CI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3CI_FUNC);
#else
@@ -9415,10 +9761,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3DI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3DI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3DI_FUNC);
#else
@@ -9440,10 +9800,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3FI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3FI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3FI_FUNC);
#else
@@ -9465,10 +9839,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3II)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3II_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3II_FUNC);
#else
@@ -9490,10 +9878,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3JI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3JI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetLongArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseLongArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3JI_FUNC);
#else
@@ -9515,10 +9917,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__J_3SI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory__J_3SI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory__I_3SI_FUNC);
#else
@@ -9560,10 +9976,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_BIT
jbyte *lparg1=NULL;
OS_NATIVE_ENTER(env, that, MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI_FUNC);
if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg0 && lparg0) setBITMAPINFOHEADERFields(env, arg0, lparg0);
OS_NATIVE_EXIT(env, that, MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI_FUNC);
}
@@ -10658,10 +11088,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_POI
jlong *lparg1=NULL;
OS_NATIVE_ENTER(env, that, MoveMemory__Lorg_eclipse_swt_internal_win32_POINT_2_3JI_FUNC);
if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetLongArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseLongArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
if (arg0 && lparg0) setPOINTFields(env, arg0, lparg0);
OS_NATIVE_EXIT(env, that, MoveMemory__Lorg_eclipse_swt_internal_win32_POINT_2_3JI_FUNC);
}
@@ -10983,10 +11427,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BJI)(JNIEnv *env, jclass that, jb
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3BJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3BII_FUNC);
#else
@@ -11003,10 +11461,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BLorg_eclipse_swt_internal_win32_
ACCEL _arg1, *lparg1=NULL;
OS_NATIVE_ENTER(env, that, MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I_FUNC);
if (arg1) if ((lparg1 = getACCELFields(env, arg1, &_arg1)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ }
OS_NATIVE_EXIT(env, that, MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I_FUNC);
}
#endif
@@ -11019,10 +11491,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BLorg_eclipse_swt_internal_win32_
BITMAPINFOHEADER _arg1, *lparg1=NULL;
OS_NATIVE_ENTER(env, that, MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I_FUNC);
if (arg1) if ((lparg1 = getBITMAPINFOHEADERFields(env, arg1, &_arg1)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ }
OS_NATIVE_EXIT(env, that, MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I_FUNC);
}
#endif
@@ -11040,10 +11526,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3CJI)(JNIEnv *env, jclass that, jc
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3CJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3CII_FUNC);
#else
@@ -11065,10 +11565,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3DJI)(JNIEnv *env, jclass that, jd
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3DJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3DII_FUNC);
#else
@@ -11090,10 +11604,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3FJI)(JNIEnv *env, jclass that, jf
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3FJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetFloatArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseFloatArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3FII_FUNC);
#else
@@ -11115,10 +11643,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3IJI)(JNIEnv *env, jclass that, ji
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3IJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3III_FUNC);
#else
@@ -11140,10 +11682,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3JJI)(JNIEnv *env, jclass that, jl
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3JJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetLongArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseLongArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3JII_FUNC);
#else
@@ -11165,10 +11721,24 @@ JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3SJI)(JNIEnv *env, jclass that, js
#else
OS_NATIVE_ENTER(env, that, MoveMemory___3SJI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MoveMemory___3SII_FUNC);
#else
@@ -11215,10 +11785,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(MultiByteToWideChar__IIJI_3CI)(JNIEnv *env, jcl
#else
OS_NATIVE_ENTER(env, that, MultiByteToWideChar__IIJI_3CI_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg4) if ((lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jint)MultiByteToWideChar(arg0, arg1, (LPCSTR)arg2, arg3, (LPWSTR)lparg4, arg5);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, MultiByteToWideChar__IIII_3CI_FUNC);
#else
@@ -11236,12 +11820,28 @@ JNIEXPORT jint JNICALL OS_NATIVE(MultiByteToWideChar__II_3BI_3CI)
jchar *lparg4=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, MultiByteToWideChar__II_3BI_3CI_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jint)MultiByteToWideChar(arg0, arg1, (LPCSTR)lparg2, arg3, (LPWSTR)lparg4, arg5);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, MultiByteToWideChar__II_3BI_3CI_FUNC);
return rc;
}
@@ -12021,10 +12621,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(Polygon)
jint *lparg1=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, Polygon_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)Polygon((HDC)arg0, (CONST POINT *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, Polygon_FUNC);
return rc;
}
@@ -12037,10 +12651,24 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(Polyline)
jint *lparg1=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, Polyline_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
rc = (jboolean)Polyline((HDC)arg0, (CONST POINT *)lparg1, arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, Polyline_FUNC);
return rc;
}
@@ -15885,10 +16513,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable)
jbyte *lparg3=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, SetDIBColorTable_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, SetDIBColorTable_FUNC);
return rc;
}
@@ -16173,10 +16815,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(SetPaletteEntries)
jbyte *lparg3=NULL;
jint rc = 0;
OS_NATIVE_ENTER(env, that, SetPaletteEntries_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
rc = (jint)SetPaletteEntries((HPALETTE)arg0, arg1, arg2, (PALETTEENTRY *)lparg3);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, SetPaletteEntries_FUNC);
return rc;
}
@@ -18654,10 +19310,24 @@ JNIEXPORT jint JNICALL OS_NATIVE(WideCharToMultiByte__II_3CIJI_3B_3Z)(JNIEnv *en
#endif
if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
if (arg7) if ((lparg7 = (*env)->GetBooleanArrayElements(env, arg7, NULL)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
rc = (jint)WideCharToMultiByte(arg0, arg1, (LPCWSTR)lparg2, arg3, (LPSTR)arg4, arg5, (LPCSTR)lparg6, (LPBOOL)lparg7);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
if (arg7 && lparg7) (*env)->ReleaseBooleanArrayElements(env, arg7, lparg7, 0);
if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
#ifndef JNI64
@@ -18681,12 +19351,28 @@ JNIEXPORT jint JNICALL OS_NATIVE(WideCharToMultiByte__II_3CI_3BI_3B_3Z)
OS_NATIVE_ENTER(env, that, WideCharToMultiByte__II_3CI_3BI_3B_3Z_FUNC);
if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
if (arg7) if ((lparg7 = (*env)->GetBooleanArrayElements(env, arg7, NULL)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jint)WideCharToMultiByte(arg0, arg1, (LPCWSTR)lparg2, arg3, (LPSTR)lparg4, arg5, (LPCSTR)lparg6, (LPBOOL)lparg7);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ if (arg2 && lparg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
if (arg7 && lparg7) (*env)->ReleaseBooleanArrayElements(env, arg7, lparg7, 0);
if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
OS_NATIVE_EXIT(env, that, WideCharToMultiByte__II_3CI_3BI_3B_3Z_FUNC);
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 5c15870a41..bdb2a8707a 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
@@ -13,6 +13,7 @@ package org.eclipse.swt.printing;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -482,6 +483,11 @@ public Point getDPI() {
*/
@Override
public Rectangle getBounds() {
+ checkDevice ();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels() {
checkDevice();
int width = OS.GetDeviceCaps(handle, OS.PHYSICALWIDTH);
int height = OS.GetDeviceCaps(handle, OS.PHYSICALHEIGHT);
@@ -506,7 +512,11 @@ public Rectangle getBounds() {
* @see #computeTrim
*/
@Override
-public Rectangle getClientArea() {
+public Rectangle getClientArea () {
+ checkDevice ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+Rectangle getClientAreaInPixels() {
checkDevice();
int width = OS.GetDeviceCaps(handle, OS.HORZRES);
int height = OS.GetDeviceCaps(handle, OS.VERTRES);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
index b879a47525..f48a06d51e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -375,7 +375,7 @@ public ImageData getImageData () {
OS.SHGetFileInfo (pszPath, OS.FILE_ATTRIBUTE_NORMAL, shfi, SHFILEINFO.sizeof, flags);
if (shfi.hIcon != 0) {
Image image = Image.win32_new (null, SWT.ICON, shfi.hIcon);
- ImageData imageData = image.getImageData ();
+ ImageData imageData = image.getImageDataAtCurrentZoom ();
image.dispose ();
return imageData;
}
@@ -402,7 +402,7 @@ public ImageData getImageData () {
OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
if (phiconSmall [0] == 0) return null;
Image image = Image.win32_new (null, SWT.ICON, phiconSmall [0]);
- ImageData imageData = image.getImageData ();
+ ImageData imageData = image.getImageDataAtCurrentZoom ();
image.dispose ();
return imageData;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/DrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/DrawData.java
index f5bfd7fc27..2abf6a11e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/DrawData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/DrawData.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.internal.theme;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
public class DrawData {
@@ -102,8 +103,9 @@ void drawImage(Theme theme, Image image, GC gc, Rectangle bounds) {
// OS.DrawThemeIcon(hTheme, gc.handle, part[0], part[1], rect, imageList.getHandle(), imageIndex);
// imageList.dispose();
// OS.CloseThemeData(hTheme);
- Rectangle rect = image.getBounds();
- gc.drawImage(image, 0, 0, rect.width, rect.height, bounds.x, bounds.y, bounds.width, bounds.height);
+ Rectangle rect = image.getBounds ();
+ bounds = DPIUtil.autoScaleDown (bounds);
+ gc.drawImage (image, 0, 0, rect.width, rect.height, bounds.x, bounds.y, bounds.width, bounds.height);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java
index aa6a5a1dc2..b748a7d330 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.internal.theme;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
public class ScaleDrawData extends RangeDrawData {
@@ -72,13 +73,13 @@ void draw(Theme theme, GC gc, Rectangle bounds) {
rect.bottom = rect.top + 1;
//TODO - why tics are ot drawn
OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TICSVERT, 1, rect, null);
- gc.drawLine(rect.left, rect.top, rect.right, rect.top);
+ gc.drawLine(DPIUtil.autoScaleDown(rect.left), DPIUtil.autoScaleDown(rect.top), DPIUtil.autoScaleDown(rect.right), DPIUtil.autoScaleDown(rect.top));
rect.left = bounds.x + TICS_MARGIN + thumbWidth + 1;
rect.right = rect.left + ticWidth;
if (sel != minimum && sel != maximum) rect.right--;
//TODO - why tics are ot drawn
OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TICSVERT, 1, rect, null);
- gc.drawLine(rect.left, rect.top, rect.right, rect.top);
+ gc.drawLine (DPIUtil.autoScaleDown(rect.left), DPIUtil.autoScaleDown(rect.top), DPIUtil.autoScaleDown(rect.right), DPIUtil.autoScaleDown(rect.top));
}
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java
index bf2dcb1ffc..f098d8e460 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebKit.java
@@ -658,7 +658,7 @@ public void create (Composite parent, int style) {
break;
}
case SWT.Resize: {
- Rectangle bounds = browser.getClientArea ();
+ Rectangle bounds = DPIUtil.autoScaleUp(browser.getClientArea ()); // To Pixels
OS.SetWindowPos (webViewWindowHandle, 0, bounds.x, bounds.y, bounds.width, bounds.height, OS.SWP_DRAWFRAME);
break;
}
@@ -950,7 +950,7 @@ boolean handleEvent (Object[] arguments) {
* coordinates relative to themselves rather than relative to their top-
* level page. Convert screen-relative coordinates to be browser-relative.
*/
- Point position = new Point (((Double)arguments[1]).intValue (), ((Double)arguments[2]).intValue ());
+ Point position = new Point (((Double)arguments[1]).intValue (), ((Double)arguments[2]).intValue ());// Points or Pixles ?
position = browser.getDisplay ().map (null, browser, position);
Event mouseEvent = new Event ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebUIDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebUIDelegate.java
index 913398e0c4..0c5869b9ae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebUIDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebUIDelegate.java
@@ -456,7 +456,7 @@ int setFrame (long /*int*/ sender, long /*int*/ frame) {
RECT rect = new RECT ();
COM.MoveMemory (rect, frame, RECT.sizeof);
/* convert to SWT system coordinates */
- location = browser.getDisplay ().map (browser, null, rect.left, rect.top);
+ location = DPIUtil.autoScaleUp(browser.getDisplay ().map (browser, null, DPIUtil.autoScaleDown(new Point(rect.left, rect.top)))); // To Pixels
int x = rect.right - rect.left;
int y = rect.bottom - rect.top;
if (y < 0 || x < 0 || (x == 0 && y == 0)) return COM.S_OK;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
deleted file mode 100644
index 016e1a01a0..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-import org.eclipse.swt.*;
-
-/**
- * This class hold common constants and utility functions w.r.t. to SWT high DPI
- * functionality.
- *
- * @since 3.104
- */
-class DPIUtil {
-
- /* DPI Constants */
- static final int DPI_ZOOM_200 = 192;
- static final int DPI_ZOOM_150 = 144;
-
- /**
- * Compute the zoom value based on the DPI value.
- *
- * @return zoom
- */
- static int mapDPIToZoom (int dpi) {
- int zoom;
- if (dpi >= DPI_ZOOM_200) {
- zoom = 200;
- } else if (dpi >= DPI_ZOOM_150) {
- zoom = 150;
- } else {
- zoom = 100;
- }
- return zoom;
- }
-
- /**
- * Gets Image file path at specified zoom level, if image is missing then
- * fall-back to 100% image. If provider or fall-back image is not available,
- * throw error.
- */
- static String validateAndGetImagePathAtZoom (ImageFileNameProvider provider, int zoom, boolean[] found) {
- if (provider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- String filename = provider.getImagePath (zoom);
- found [0] = (filename != null);
- /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
- if (zoom != 100 && !found [0]) filename = provider.getImagePath (100);
- if (filename == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return filename;
- }
-
- /**
- * Gets Image data at specified zoom level, if image is missing then
- * fall-back to 100% image. If provider or fall-back image is not available,
- * throw error.
- */
- static ImageData validateAndGetImageDataAtZoom (ImageDataProvider provider, int zoom, boolean[] found) {
- if (provider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- ImageData data = provider.getImageData (zoom);
- found [0] = (data != null);
- /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
- if (zoom != 100 && !found [0]) data = provider.getImageData (100);
- if (data == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return data;
- }
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/GlyphMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/GlyphMetrics.java
index 50d5a4d76b..4e6582b2c8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/GlyphMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/GlyphMetrics.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 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
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
/**
* Instances of this class represent glyph metrics.
@@ -70,6 +71,18 @@ public GlyphMetrics(int ascent, int descent, int width) {
this.width = width;
}
+int getAscentInPixels() {
+ return DPIUtil.autoScaleUp(ascent);
+}
+
+int getDescentInPixels() {
+ return DPIUtil.autoScaleUp(descent);
+}
+
+int getWidthInPixels() {
+ return DPIUtil.autoScaleUp(width);
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
index a2fc32eaf2..10775dab34 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 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
@@ -14,6 +14,7 @@ package org.eclipse.swt.graphics;
import java.io.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
/**
* Instances of this class are device-independent descriptions
@@ -3654,20 +3655,26 @@ static void fillGradientRectangle(GC gc, Device device,
fromRGB, toRGB, redBits, greenBits, blueBits);
Image image = new Image(device, band);
if ((band.width == 1) || (band.height == 1)) {
- gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);
- } else {
+ gc.drawImage(image, 0, 0, DPIUtil.autoScaleDown(band.width), DPIUtil.autoScaleDown(band.height),
+ DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y), DPIUtil.autoScaleDown(width),
+ DPIUtil.autoScaleDown(height));
+ } else {
if (vertical) {
for (int dx = 0; dx < width; dx += band.width) {
int blitWidth = width - dx;
if (blitWidth > band.width) blitWidth = band.width;
- gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);
- }
+ gc.drawImage(image, 0, 0, DPIUtil.autoScaleDown(blitWidth), DPIUtil.autoScaleDown(band.height),
+ DPIUtil.autoScaleDown(dx + x), DPIUtil.autoScaleDown(y), DPIUtil.autoScaleDown(blitWidth),
+ DPIUtil.autoScaleDown(band.height));
+ }
} else {
for (int dy = 0; dy < height; dy += band.height) {
int blitHeight = height - dy;
if (blitHeight > band.height) blitHeight = band.height;
- gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);
- }
+ gc.drawImage(image, 0, 0, DPIUtil.autoScaleDown(band.width), DPIUtil.autoScaleDown(blitHeight),
+ DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(dy + y), DPIUtil.autoScaleDown(band.width),
+ DPIUtil.autoScaleDown(blitHeight));
+ }
}
}
image.dispose();
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
new file mode 100644
index 0000000000..f54865d1de
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
@@ -0,0 +1,313 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This class hold common constants and utility functions w.r.t. to SWT high DPI
+ * functionality.
+ * <p>
+ * The {@code autoScaleUp(..)} methods convert from API coordinates (in
+ * SWT points) to internal high DPI coordinates (in pixels) that interface with
+ * native widgets.
+ * </p>
+ * <p>
+ * The {@code autoScaleDown(..)} convert from high DPI pixels to API coordinates
+ * (in SWT points).
+ * </p>
+ *
+ * @since 3.105
+ */
+public class DPIUtil {
+
+ /* DPI Constants */
+ static final int DPI_ZOOM_200 = 192;
+ static final int DPI_ZOOM_150 = 144;
+ static final int DPI_ZOOM_100 = 96;
+
+ private static boolean autoScaleEnable = true;
+ private static int deviceZoom = 100;
+
+ /*
+ * The AutoScale functionality is enabled by default on HighDPI monitors &
+ * can be disabled by setting below system property to "false"(Ignore case).
+ */
+ static final String SWT_ENABLE_AUTOSCALE = "swt.enable.autoScale";
+ static {
+ String value = System.getProperty (SWT_ENABLE_AUTOSCALE);
+ if (value != null && "false".equalsIgnoreCase (value))
+ autoScaleEnable = false;
+ }
+
+/**
+ * Auto-scale down ImageData
+ */
+public static ImageData autoScaleDown (ImageData imageData) {
+ if (!isAutoScaleEnable () || imageData == null) return imageData;
+ float scaleFactor = getScalingFactor ();
+ return scaleFactor == 1 ? imageData
+ : imageData.scaledTo (Math.round ((float)imageData.width / scaleFactor), Math.round ((float)imageData.height / scaleFactor));
+}
+
+public static int[] autoScaleDown(int[] pointArray) {
+ if (!isAutoScaleEnable () || pointArray == null) return pointArray;
+ float scaleFactor = getScalingFactor ();
+ int [] returnArray = new int[pointArray.length];
+ for (int i = 0; i < pointArray.length; i++) {
+ returnArray [i] = Math.round (pointArray [i] / scaleFactor);
+ }
+ return returnArray;
+}
+
+/**
+ * Auto-scale up float array dimensions.
+ */
+public static float[] autoScaleDown (float size[]) {
+ if (!isAutoScaleEnable () || size == null) return size;
+ float scaleFactor = getScalingFactor ();
+ float scaledSize[] = new float[size.length];
+ for (int i = 0; i < scaledSize.length; i++) {
+ scaledSize[i] = size[i] / scaleFactor;
+ }
+ return scaledSize;
+}
+/**
+ * Auto-scale down int dimensions.
+ */
+public static int autoScaleDown (int size) {
+ if (!isAutoScaleEnable ()||size == SWT.DEFAULT) return size;
+ float scaleFactor = getScalingFactor ();
+ return Math.round (size / scaleFactor);
+}
+/**
+ * Auto-scale down float dimensions.
+ */
+public static float autoScaleDown (float size) {
+ if (!isAutoScaleEnable ()||size == SWT.DEFAULT) return size;
+ float scaleFactor = getScalingFactor ();
+ return (size / scaleFactor);
+}
+
+/**
+ * Returns a new scaled down Point.
+ */
+public static Point autoScaleDown (Point point) {
+ if (!isAutoScaleEnable () || point == null) return point;
+ float scaleFactor = getScalingFactor ();
+ if (scaleFactor == 1) return point;
+ Point scaledPoint = new Point (0,0);
+ scaledPoint.x = Math.round (point.x / scaleFactor);
+ scaledPoint.y = Math.round (point.y / scaleFactor);
+ return scaledPoint;
+}
+
+/**
+ * Returns a new scaled down Rectangle.
+ */
+public static Rectangle autoScaleDown (Rectangle rect) {
+ if (!isAutoScaleEnable () || rect == null) return rect;
+ float scaleFactor = getScalingFactor ();
+ if (scaleFactor == 1) return rect;
+ Rectangle scaledRect = new Rectangle (0,0,0,0);
+ scaledRect.x = Math.round (rect.x / scaleFactor);
+ scaledRect.y = Math.round (rect.y / scaleFactor);
+ scaledRect.width = Math.round (rect.width / scaleFactor);
+ scaledRect.height = Math.round (rect.height / scaleFactor);
+ return scaledRect;
+}
+
+/**
+ * Auto-scale image with ImageData
+ */
+public static ImageData autoScaleImageData (ImageData imageData, int targetZoom, int currentZoom) {
+ if (!isAutoScaleEnable () || imageData == null || targetZoom == currentZoom) return imageData;
+ float scaleFactor = ((float) targetZoom)/((float) currentZoom);
+ return imageData.scaledTo (Math.round ((float)imageData.width * scaleFactor), Math.round ((float)imageData.height * scaleFactor));
+}
+
+/**
+ * Returns a new rectangle as per the scaleFactor.
+ */
+public static Rectangle autoScaleBounds (Rectangle rect, int targetZoom, int currentZoom) {
+ if (rect == null || targetZoom == currentZoom) return rect;
+ float scaleFactor = ((float)targetZoom) / (float)currentZoom;
+ Rectangle returnRect = new Rectangle (0,0,0,0);
+ returnRect.x = Math.round (rect.x * scaleFactor);
+ returnRect.y = Math.round (rect.y * scaleFactor);
+ returnRect.width = Math.round (rect.width * scaleFactor);
+ returnRect.height = Math.round (rect.height * scaleFactor);
+ return returnRect;
+}
+
+/**
+ * Auto-scale up ImageData
+ */
+public static ImageData autoScaleUp (ImageData imageData) {
+ if (!isAutoScaleEnable () || imageData == null) return imageData;
+ float scaleFactor = getScalingFactor ();
+ return scaleFactor == 1 ? imageData
+ : imageData.scaledTo (Math.round ((float)imageData.width * scaleFactor), Math.round ((float)imageData.height * scaleFactor));
+}
+
+public static int[] autoScaleUp(int[] pointArray) {
+ if (!isAutoScaleEnable () || pointArray == null) return pointArray;
+ float scaleFactor = getScalingFactor ();
+ int [] returnArray = new int[pointArray.length];
+ for (int i = 0; i < pointArray.length; i++) {
+ returnArray [i] = Math.round (pointArray [i] * scaleFactor);
+ }
+ return returnArray;
+}
+
+/**
+ * Auto-scale up int dimensions.
+ */
+public static int autoScaleUp (int size) {
+ if (!isAutoScaleEnable ()||size == SWT.DEFAULT) return size;
+ float scaleFactor = getScalingFactor ();
+ return Math.round (size * scaleFactor);
+}
+
+public static float autoScaleUp(float size) {
+ if (!isAutoScaleEnable ()||size == SWT.DEFAULT) return size;
+ float scaleFactor = getScalingFactor ();
+ return (size * scaleFactor);
+}
+
+/**
+ * Returns a new scaled up Point.
+ */
+public static Point autoScaleUp (Point point) {
+ if (!isAutoScaleEnable () || point == null) return point;
+ float scaleFactor = getScalingFactor ();
+ if (scaleFactor == 1) return point;
+ Point scaledPoint = new Point (0,0);
+ scaledPoint.x = Math.round (point.x * scaleFactor);
+ scaledPoint.y = Math.round (point.y * scaleFactor);
+ return scaledPoint;
+}
+
+/**
+ * Returns a new scaled up Rectangle.
+ */
+public static Rectangle autoScaleUp (Rectangle rect) {
+ if (!isAutoScaleEnable () || rect == null) return rect;
+ float scaleFactor = getScalingFactor ();
+ if (scaleFactor == 1) return rect;
+ Rectangle scaledRect = new Rectangle (0,0,0,0);
+ scaledRect.x = Math.round (rect.x * scaleFactor);
+ scaledRect.y = Math.round (rect.y * scaleFactor);
+ scaledRect.width = Math.round (rect.width * scaleFactor);
+ scaledRect.height = Math.round (rect.height * scaleFactor);
+ return scaledRect;
+}
+public static boolean isAutoScaleEnable () {
+ return autoScaleEnable;
+}
+
+/**
+ * Returns Scaling factor from the display
+ * @return float scaling factor
+ */
+private static float getScalingFactor () {
+ float scalingFactor = 1;
+ if (isAutoScaleEnable ()) {
+ scalingFactor = getDeviceZoom ()/100f;
+ }
+ return scalingFactor;
+}
+
+/**
+ * Compute the zoom value based on the scaleFactor value.
+ *
+ * @return zoom
+ */
+public static int mapSFToZoom (float scaleFactor) {
+ return mapDPIToZoom ((int) (scaleFactor * DPI_ZOOM_100));
+}
+/**
+ * Compute the zoom value based on the DPI value.
+ *
+ * @return zoom
+ */
+public static int mapDPIToZoom (int dpi) {
+ int zoom;
+ if (dpi >= DPI_ZOOM_200) {
+ zoom = 200;
+ } else if (dpi >= DPI_ZOOM_150) {
+ zoom = 150;
+ } else {
+ zoom = 100;
+ }
+ return zoom;
+}
+/**
+ * Gets Image data at specified zoom level, if image is missing then
+ * fall-back to 100% image. If provider or fall-back image is not available,
+ * throw error.
+ */
+public static ImageData validateAndGetImageDataAtZoom (ImageDataProvider provider, int zoom, boolean[] found) {
+ if (provider == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ ImageData data = provider.getImageData (zoom);
+ found [0] = (data != null);
+ /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
+ if (zoom != 100 && !found [0]) data = provider.getImageData (100);
+ if (data == null) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return data;
+}
+
+/**
+ * Gets Image file path at specified zoom level, if image is missing then
+ * fall-back to 100% image. If provider or fall-back image is not available,
+ * throw error.
+ */
+public static String validateAndGetImagePathAtZoom (ImageFileNameProvider provider, int zoom, boolean[] found) {
+ if (provider == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ String filename = provider.getImagePath (zoom);
+ found [0] = (filename != null);
+ /* If image is null when (zoom != 100%), fall-back to image at 100% zoom */
+ if (zoom != 100 && !found [0]) filename = provider.getImagePath (100);
+ if (filename == null) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return filename;
+}
+
+/**
+ * @return the deviceZoom
+ */
+public static int getDeviceZoom() {
+ return isAutoScaleEnable () ? deviceZoom : 100;
+}
+
+/**
+ * @param deviceZoom the deviceZoom to set
+ */
+public static void setDeviceZoom(int deviceZoom) {
+ DPIUtil.deviceZoom = deviceZoom;
+}
+
+/**
+ * AutoScale ImageDataProvider.
+ */
+public static final class AutoScaleImageDataProvider implements ImageDataProvider {
+ ImageData imageData;
+ int currentZoom;
+ public AutoScaleImageDataProvider(ImageData data, int zoom){
+ this.imageData = data;
+ this.currentZoom = zoom;
+ }
+ @Override
+ public ImageData getImageData(int zoom) {
+ return DPIUtil.autoScaleImageData(imageData, zoom, currentZoom);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java
index f5b2206208..0e213a64b9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
/**
* Instances of this class provide a description of a particular
@@ -265,7 +266,6 @@ public class Event {
*/
public double rotation;
-
/**
* Gets the bounds.
*
@@ -274,6 +274,17 @@ public class Event {
public Rectangle getBounds () {
return new Rectangle (x, y, width, height);
}
+Rectangle getBoundsInPixels () {
+ return DPIUtil.autoScaleUp(getBounds());
+}
+
+Point getLocation () {
+ return new Point (x, y);
+}
+
+Point getLocationInPixels () {
+ return DPIUtil.autoScaleUp(new Point(x, y));
+}
/**
* Sets the bounds.
@@ -287,6 +298,15 @@ public void setBounds (Rectangle rect) {
this.height = rect.height;
}
+void setBoundsInPixels (Rectangle rect) {
+ setBounds(DPIUtil.autoScaleDown(rect));
+}
+
+void setLocationInPixels (int x, int y) {
+ this.x = DPIUtil.autoScaleDown(x);
+ this.y = DPIUtil.autoScaleDown(y);
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Monitor.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Monitor.java
index 787e0d4b07..b797fd8193 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Monitor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Monitor.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
@@ -71,6 +71,20 @@ public Rectangle getClientArea () {
return new Rectangle (clientX, clientY, clientWidth, clientHeight);
}
+void setBounds (Rectangle rect) {
+ x = rect.x;
+ y = rect.y;
+ width = rect.width;
+ height = rect.height;
+}
+
+void setClientArea (Rectangle rect) {
+ clientX = rect.x;
+ clientY = rect.y;
+ clientWidth = rect.width;
+ clientHeight = rect.height;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects that return <code>true</code> when passed to
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
index 5eedc6da83..c97d3a1320 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
@@ -68,6 +68,9 @@ public abstract class Device implements Drawable {
boolean disposed;
+ /* Auto-Scaling*/
+ boolean enableAutoScaling = true;
+
/*
* TEMPORARY CODE. When a graphics object is
* created and the device parameter is null,
@@ -363,8 +366,12 @@ long /*int*/ EnumFontFamProc (long /*int*/ lpelfe, long /*int*/ lpntme, long /*i
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getBounds () {
+public Rectangle getBounds() {
checkDevice ();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+private Rectangle getBoundsInPixels () {
long /*int*/ hDC = internal_new_GC (null);
int width = OS.GetDeviceCaps (hDC, OS.HORZRES);
int height = OS.GetDeviceCaps (hDC, OS.VERTRES);
@@ -427,7 +434,12 @@ public DeviceData getDeviceData () {
* @see #getBounds
*/
public Rectangle getClientArea () {
- return getBounds ();
+ checkDevice ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+
+private Rectangle getClientAreaInPixels () {
+ return getBoundsInPixels ();
}
/**
@@ -695,6 +707,7 @@ public boolean getWarnings () {
* @see #create
*/
protected void init () {
+ DPIUtil.setDeviceZoom (getDeviceZoom ());
if (debug) {
if (!OS.IsWinCE) OS.GdiSetBatchLimit(1);
}
@@ -991,4 +1004,16 @@ public void setWarnings (boolean warnings) {
checkDevice ();
}
+boolean getEnableAutoScaling() {
+ return enableAutoScaling;
+}
+
+void setEnableAutoScaling(boolean value) {
+ enableAutoScaling = value;
+}
+
+private int getDeviceZoom () {
+ return DPIUtil.mapDPIToZoom ( _getDPIx ());
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java
index 773e042bc6..f76b4e0913 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -91,7 +92,7 @@ public boolean equals (Object object) {
* @return the ascent of the font
*/
public int getAscent() {
- return handle.tmAscent - handle.tmInternalLeading;
+ return DPIUtil.autoScaleDown(handle.tmAscent - handle.tmInternalLeading);
}
/**
@@ -101,7 +102,7 @@ public int getAscent() {
* @return the average character width of the font
*/
public int getAverageCharWidth() {
- return handle.tmAveCharWidth;
+ return DPIUtil.autoScaleDown(handle.tmAveCharWidth);
}
/**
@@ -113,7 +114,7 @@ public int getAverageCharWidth() {
* @return the descent of the font
*/
public int getDescent() {
- return handle.tmDescent;
+ return DPIUtil.autoScaleDown(handle.tmDescent);
}
/**
@@ -128,7 +129,7 @@ public int getDescent() {
* @see #getLeading
*/
public int getHeight() {
- return handle.tmHeight;
+ return DPIUtil.autoScaleDown(handle.tmHeight);
}
/**
@@ -139,7 +140,7 @@ public int getHeight() {
* @return the leading space of the font
*/
public int getLeading() {
- return handle.tmInternalLeading;
+ return DPIUtil.autoScaleDown(handle.tmInternalLeading);
}
/**
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 0c014229ed..f99800b050 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
@@ -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
@@ -12,6 +12,7 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -444,13 +445,18 @@ void checkGC(int mask) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(Image image, int x, int y) {
+public void copyArea (Image image, int x, int y) {
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ copyAreaInPixels(image, x, y);
+}
+
+void copyAreaInPixels(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);
-
/* Copy the bitmap area */
- Rectangle rect = image.getBounds();
+ Rectangle rect = image.getBoundsInPixels();
long /*int*/ memHdc = OS.CreateCompatibleDC(handle);
long /*int*/ hOldBitmap = OS.SelectObject(memHdc, image.handle);
OS.BitBlt(memHdc, 0, 0, rect.width, rect.height, handle, x, y, OS.SRCCOPY);
@@ -473,8 +479,8 @@ public void copyArea(Image image, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
- copyArea(srcX, srcY, width, height, destX, destY, true);
+public void copyArea (int srcX, int srcY, int width, int height, int destX, int destY) {
+ copyArea (srcX, srcY, width, height, destX, destY, true);
}
/**
@@ -495,9 +501,18 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d
*
* @since 3.1
*/
-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);
+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);
+ copyAreaInPixels(srcX, srcY, width, height, destX, destY, paint);
+}
+void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
/*
* Feature in WinCE. The function WindowFromDC is not part of the
* WinCE SDK. The fix is to remember the HWND.
@@ -728,6 +743,14 @@ 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);
+ drawArcInPixels(x, y, width, height, startAngle, arcAngle);
+}
+
+void drawArcInPixels (int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
if (width < 0) {
@@ -826,6 +849,14 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int ar
* @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);
+ drawFocusInPixels(x, y, width, height);
+}
+
+void drawFocusInPixels (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if ((data.uiState & OS.UISF_HIDEFOCUS) != 0) return;
data.focusDrawn = true;
@@ -895,7 +926,13 @@ public void drawFocus (int x, int y, int width, int height) {
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
* </ul>
*/
-public void drawImage(Image image, int x, int y) {
+public void drawImage (Image image, int x, int y) {
+ x = (x != SWT.DEFAULT ? DPIUtil.autoScaleUp(x) : x);
+ y = (y != SWT.DEFAULT ? DPIUtil.autoScaleUp(y) : y);
+ drawImageInPixels(image, x, y);
+}
+
+void drawImageInPixels(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);
@@ -934,7 +971,19 @@ public void drawImage(Image image, int x, int y) {
* <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
* </ul>
*/
-public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+public void drawImage (Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ srcX = (srcX != SWT.DEFAULT ? DPIUtil.autoScaleUp(srcX) : srcX);
+ srcY = (srcY != SWT.DEFAULT ? DPIUtil.autoScaleUp(srcY) : srcY);
+ srcWidth = (srcWidth != SWT.DEFAULT ? DPIUtil.autoScaleUp(srcWidth) : srcWidth);
+ srcHeight = (srcHeight != SWT.DEFAULT ? DPIUtil.autoScaleUp(srcHeight) : srcHeight);
+ destX = (destX != SWT.DEFAULT ? DPIUtil.autoScaleUp(destX) : destX);
+ destY = (destY != SWT.DEFAULT ? DPIUtil.autoScaleUp(destY) : destY);
+ destWidth = (destWidth != SWT.DEFAULT ? DPIUtil.autoScaleUp(destWidth) : destWidth);
+ destHeight = (destHeight != SWT.DEFAULT ? DPIUtil.autoScaleUp(destHeight) : destHeight);
+ drawImageInPixels(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight);
+}
+
+void drawImageInPixels(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
@@ -1164,7 +1213,18 @@ void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight,
srcHeight = destHeight = imgHeight;
} else {
if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * This is a HACK ! Due to auto-scale of dimensions at high DPI
+ * display(specifically 150% zoom), rounding error of 1 pixel
+ * gets introduced in srcX . Below check detects this particular
+ * scenario and adjusts the dimension for 1 pixel grace value.
+ */
+ if (DPIUtil.isAutoScaleEnable() && DPIUtil.getDeviceZoom() > 100 && ((srcX + srcWidth - imgWidth) == 1)) {
+ srcX--;
+ }
+ else {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
}
simple = srcX == 0 && srcY == 0 &&
srcWidth == destWidth && destWidth == imgWidth &&
@@ -1266,7 +1326,7 @@ void drawBitmapAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHe
}
/* Check clipping */
- Rectangle rect = getClipping();
+ Rectangle rect = getClippingInPixels();
rect = rect.intersection(new Rectangle(destX, destY, destWidth, destHeight));
if (rect.isEmpty()) return;
@@ -1677,6 +1737,14 @@ 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);
+ drawLineInPixels(x1, y1, x2, y2);
+}
+
+void drawLineInPixels (int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
long /*int*/ gdipGraphics = data.gdipGraphics;
@@ -1726,6 +1794,14 @@ public void drawLine (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);
+ drawOvalInPixels(x, y, width, height);
+}
+
+void drawOvalInPixels (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
long /*int*/ gdipGraphics = data.gdipGraphics;
@@ -1794,6 +1870,12 @@ public void drawPath (Path path) {
* @since 3.0
*/
public void drawPoint (int x, int y) {
+ x = DPIUtil.autoScaleUp (x);
+ y = DPIUtil.autoScaleUp (y);
+ drawPointInPixels(x, y);
+}
+
+void drawPointInPixels (int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (data.gdipGraphics != 0) {
checkGC(DRAW);
@@ -1820,9 +1902,13 @@ public void drawPoint (int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public void drawPolygon (int[] pointArray) {
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawPolygonInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+
+void drawPolygonInPixels(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
long /*int*/ gdipGraphics = data.gdipGraphics;
if (gdipGraphics != 0) {
@@ -1865,7 +1951,11 @@ public void drawPolygon(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolyline(int[] pointArray) {
+public void drawPolyline (int[] pointArray) {
+ drawPolylineInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+
+void drawPolylineInPixels(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
checkGC(DRAW);
@@ -1915,6 +2005,14 @@ public void drawPolyline(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);
+ drawRectangleInPixels(x, y, width, height);
+}
+
+void drawRectangleInPixels (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
long /*int*/ gdipGraphics = data.gdipGraphics;
@@ -1966,7 +2064,8 @@ public void drawRectangle (int x, int y, int width, int height) {
*/
public void drawRectangle (Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangle (rect.x, rect.y, rect.width, rect.height);
+ rect = DPIUtil.autoScaleUp(rect);
+ drawRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -1991,6 +2090,16 @@ 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);
+ drawRoundRectangleInPixels(x, y, width, height, arcWidth, arcHeight);
+}
+
+void drawRoundRectangleInPixels (int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(DRAW);
if (data.gdipGraphics != 0) {
@@ -2008,7 +2117,7 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
*/
if (width == 0 || height == 0) return;
if (arcWidth == 0 || arcHeight == 0) {
- drawRectangle(x, y, width, height);
+ drawRectangleInPixels(x, y, width, height);
return;
}
if (width < 0) {
@@ -2025,18 +2134,18 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
if (arcHeight > height) arcHeight = height;
if (arcWidth < width) {
- drawLine(x+arcWidth/2, y, x+width-arcWidth/2, y);
- drawLine(x+arcWidth/2, y+height, x+width-arcWidth/2, y+height);
+ drawLineInPixels(x+arcWidth/2, y, x+width-arcWidth/2, y);
+ drawLineInPixels(x+arcWidth/2, y+height, x+width-arcWidth/2, y+height);
}
if (arcHeight < height) {
- drawLine(x, y+arcHeight/2, x, y+height-arcHeight/2);
- drawLine(x+width, y+arcHeight/2, x+width, y+height-arcHeight/2);
+ drawLineInPixels(x, y+arcHeight/2, x, y+height-arcHeight/2);
+ drawLineInPixels(x+width, y+arcHeight/2, x+width, y+height-arcHeight/2);
}
if (arcWidth != 0 && arcHeight != 0) {
- drawArc(x, y, arcWidth, arcHeight, 90, 90);
- drawArc(x+width-arcWidth, y, arcWidth, arcHeight, 0, 90);
- drawArc(x+width-arcWidth, y+height-arcHeight, arcWidth, arcHeight, 0, -90);
- drawArc(x, y+height-arcHeight, arcWidth, arcHeight, 180, 90);
+ drawArcInPixels(x, y, arcWidth, arcHeight, 90, 90);
+ drawArcInPixels(x+width-arcWidth, y, arcWidth, arcHeight, 0, 90);
+ drawArcInPixels(x+width-arcWidth, y+height-arcHeight, arcWidth, arcHeight, 0, -90);
+ drawArcInPixels(x, y+height-arcHeight, arcWidth, arcHeight, 180, 90);
}
} else {
OS.RoundRect(handle, x,y,x+width+1,y+height+1, arcWidth, arcHeight);
@@ -2114,7 +2223,9 @@ void drawRoundRectangleGdip (long /*int*/ gdipGraphics, long /*int*/ pen, int x,
* </ul>
*/
public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawStringInPixels(string, x, y, false);
}
/**
@@ -2138,6 +2249,12 @@ 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);
+ drawStringInPixels(string, x, y, isTransparent);
+}
+
+void drawStringInPixels (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);
// TCHAR buffer = new TCHAR (getCodePage(), string, false);
@@ -2228,7 +2345,13 @@ public void drawString (String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText (String string, int x, int y) {
- drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawTextInPixels(string, x, y);
+}
+
+void drawTextInPixels (String string, int x, int y) {
+ drawTextInPixels(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
@@ -2252,9 +2375,15 @@ public void drawText (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);
+ drawTextInPixels(string, x, y, isTransparent);
+}
+
+void drawTextInPixels (String string, int x, int y, boolean isTransparent) {
int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
+ drawTextInPixels(string, x, y, flags);
}
/**
@@ -2292,6 +2421,12 @@ public void drawText (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);
+ drawTextInPixels(string, x, y, flags);
+}
+
+void drawTextInPixels (String string, int x, int y, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (string.length() == 0) return;
@@ -2687,6 +2822,14 @@ 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);
+ fillArcInPixels(x, y, width, height, startAngle, arcAngle);
+}
+
+void fillArcInPixels (int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (width < 0) {
@@ -2785,9 +2928,17 @@ public void fillArc (int x, int y, int width, int height, int startAngle, int ar
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #drawRectangle(int, int, int, int)
+ * @see #drawRectangleInPixels(int, int, int, int)
*/
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
+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);
+ fillGradientRectangleInPixels(x, y, width, height, vertical);
+}
+
+void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean vertical) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width == 0 || height == 0) return;
@@ -2813,7 +2964,7 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
toRGB = foregroundRGB;
}
if (fromRGB.equals(toRGB)) {
- fillRectangle(x, y, width, height);
+ fillRectangleInPixels(x, y, width, height);
return;
}
if (data.gdipGraphics != 0) {
@@ -2914,6 +3065,14 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
* @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);
+ fillOvalInPixels(x, y, width, height);
+}
+
+void fillOvalInPixels (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (data.gdipGraphics != 0) {
@@ -2977,9 +3136,13 @@ public void fillPath (Path path) {
*
* @see #drawPolygon
*/
-public void fillPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public void fillPolygon (int[] pointArray) {
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ fillPolygonInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+
+void fillPolygonInPixels (int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (data.gdipGraphics != 0) {
int mode = OS.GetPolyFillMode(handle) == OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate;
@@ -3015,6 +3178,14 @@ public void fillPolygon(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);
+ fillRectangleInPixels(x, y, width, height);
+}
+
+void fillRectangleInPixels (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (data.gdipGraphics != 0) {
@@ -3057,7 +3228,8 @@ public void fillRectangle (int x, int y, int width, int height) {
*/
public void fillRectangle (Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- fillRectangle (rect.x, rect.y, rect.width, rect.height);
+ rect = DPIUtil.autoScaleUp(rect);
+ fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -3078,6 +3250,16 @@ 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);
+ fillRoundRectangleInPixels(x, y, width, height, arcWidth, arcHeight);
+}
+
+void fillRoundRectangleInPixels (int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FILL);
if (data.gdipGraphics != 0) {
@@ -3348,7 +3530,11 @@ public int getCharWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getClipping() {
+public Rectangle getClipping () {
+ return DPIUtil.autoScaleDown(getClippingInPixels());
+}
+
+Rectangle getClippingInPixels() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
long /*int*/ gdipGraphics = data.gdipGraphics;
if (gdipGraphics != 0) {
@@ -3618,7 +3804,13 @@ public int getInterpolation() {
*
* @since 3.3
*/
-public LineAttributes getLineAttributes() {
+public LineAttributes getLineAttributes () {
+ LineAttributes attributes = getLineAttributesInPixels();
+ attributes.width = DPIUtil.autoScaleDown(attributes.width);
+ return attributes;
+}
+
+LineAttributes getLineAttributesInPixels () {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
float[] dashes = null;
if (data.lineDashes != null) {
@@ -3715,7 +3907,11 @@ public int getLineStyle() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineWidth() {
+public int getLineWidth () {
+ return DPIUtil.autoScaleDown(getLineWidthInPixels());
+}
+
+int getLineWidthInPixels() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return (int)data.lineWidth;
}
@@ -4276,6 +4472,14 @@ 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);
+ setClippingInPixels(x, y, width, height);
+}
+
+void setClippingInPixels (int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
long /*int*/ hRgn = OS.CreateRectRgn(x, y, x + width, y + height);
setClipping(hRgn);
@@ -4337,8 +4541,10 @@ public void setClipping (Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) {
setClipping(0);
- } else {
- setClipping(rect.x, rect.y, rect.width, rect.height);
+ }
+ else {
+ rect = DPIUtil.autoScaleUp(rect);
+ setClippingInPixels(rect.x, rect.y, rect.width, rect.height);
}
}
@@ -4538,9 +4744,14 @@ public void setInterpolation(int interpolation) {
*
* @since 3.3
*/
-public void setLineAttributes(LineAttributes attributes) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public void setLineAttributes (LineAttributes attributes) {
if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ attributes.width = DPIUtil.autoScaleUp(attributes.width);
+ setLineAttributesInPixels(attributes);
+}
+
+void setLineAttributesInPixels (LineAttributes attributes) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int mask = 0;
float lineWidth = attributes.width;
if (lineWidth != data.lineWidth) {
@@ -4788,6 +4999,11 @@ public void setLineStyle(int lineStyle) {
* </ul>
*/
public void setLineWidth(int lineWidth) {
+ lineWidth = DPIUtil.autoScaleUp (lineWidth);
+ setLineWidthInPixels(lineWidth);
+}
+
+void setLineWidthInPixels(int lineWidth) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (data.lineWidth == lineWidth) return;
data.lineWidth = lineWidth;
@@ -4935,9 +5151,13 @@ public void setTransform(Transform transform) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point stringExtent(String string) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public Point stringExtent (String string) {
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return DPIUtil.autoScaleDown(stringExtentInPixels(string));
+}
+
+Point stringExtentInPixels (String string) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
checkGC(FONT);
int length = string.length();
long /*int*/ gdipGraphics = data.gdipGraphics;
@@ -4979,8 +5199,8 @@ public Point stringExtent(String string) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+public Point textExtent (String string) {
+ return DPIUtil.autoScaleDown(textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB));
}
/**
@@ -5014,7 +5234,11 @@ public Point textExtent(String string) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point textExtent(String string, int flags) {
+public Point textExtent (String string, int flags) {
+ return DPIUtil.autoScaleDown(textExtentInPixels(string, flags));
+}
+
+Point textExtentInPixels(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
checkGC(FONT);
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 64bac082e4..f4ad003cd1 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
@@ -14,6 +14,7 @@ package org.eclipse.swt.graphics;
import java.io.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -126,17 +127,17 @@ public final class Image extends Resource implements Drawable {
/**
* ImageFileNameProvider to provide file names at various Zoom levels
*/
- ImageFileNameProvider imageFileNameProvider;
+ private ImageFileNameProvider imageFileNameProvider;
/**
* ImageDataProvider to provide ImageData at various Zoom levels
*/
- ImageDataProvider imageDataProvider;
+ private ImageDataProvider imageDataProvider;
/**
* Attribute to cache current device zoom level
*/
- int currentDeviceZoom = 100;
+ private int currentDeviceZoom = 100;
/**
* width of the image
@@ -158,6 +159,7 @@ public final class Image extends Resource implements Drawable {
*/
Image (Device device) {
super(device);
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
}
/**
@@ -197,6 +199,9 @@ Image (Device device) {
*/
public Image(Device device, int width, int height) {
super(device);
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ width = DPIUtil.autoScaleUp (width);
+ height = DPIUtil.autoScaleUp (height);
init(width, height);
init();
}
@@ -242,7 +247,7 @@ public Image(Device device, Image srcImage, int flag) {
device = this.device;
if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- Rectangle rect = srcImage.getBounds();
+ Rectangle rect = srcImage.getBoundsInPixels();
this.type = srcImage.type;
switch (flag) {
case SWT.IMAGE_COPY: {
@@ -290,7 +295,7 @@ public Image(Device device, Image srcImage, int flag) {
break;
}
case SWT.IMAGE_DISABLE: {
- ImageData data = srcImage.getImageData();
+ ImageData data = srcImage.getImageDataAtCurrentZoom();
PaletteData palette = data.palette;
RGB[] rgbs = new RGB[3];
rgbs[0] = device.getSystemColor(SWT.COLOR_BLACK).getRGB();
@@ -349,7 +354,7 @@ public Image(Device device, Image srcImage, int flag) {
break;
}
case SWT.IMAGE_GRAY: {
- ImageData data = srcImage.getImageData();
+ ImageData data = srcImage.getImageDataAtCurrentZoom();
PaletteData palette = data.palette;
ImageData newData = data;
if (!palette.isDirect) {
@@ -456,6 +461,8 @@ public Image(Device device, Image srcImage, int flag) {
public Image(Device device, Rectangle bounds) {
super(device);
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ bounds = DPIUtil.autoScaleUp (bounds);
init(bounds.width, bounds.height);
init();
}
@@ -485,6 +492,9 @@ public Image(Device device, Rectangle bounds) {
*/
public Image(Device device, ImageData data) {
super(device);
+ if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ data = DPIUtil.autoScaleUp (data);
init(data);
init();
}
@@ -526,6 +536,9 @@ public Image(Device device, ImageData source, ImageData mask) {
if (source.width != mask.width || source.height != mask.height) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ source = DPIUtil.autoScaleUp(source);
+ mask = DPIUtil.autoScaleUp(mask);
mask = ImageData.convertMask(mask);
init(this.device, this, source, mask);
init();
@@ -586,7 +599,9 @@ public Image(Device device, ImageData source, ImageData mask) {
*/
public Image (Device device, InputStream stream) {
super(device);
- init(new ImageData(stream));
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ ImageData data = DPIUtil.autoScaleUp(new ImageData(stream));
+ init(data);
init();
}
@@ -625,8 +640,9 @@ public Image (Device device, InputStream stream) {
public Image (Device device, String filename) {
super(device);
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- initNative(filename);
- if (this.handle == 0) init(new ImageData(filename));
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ ImageData data = DPIUtil.autoScaleUp(new ImageData(filename));
+ init(data);
init();
}
@@ -662,10 +678,16 @@ public Image (Device device, String filename) {
public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
super(device);
this.imageFileNameProvider = imageFileNameProvider;
- currentDeviceZoom = getDeviceZoom ();
- String fileName = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, currentDeviceZoom, new boolean[1]);
- initNative (fileName);
- if (this.handle == 0) init(new ImageData (fileName));
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ boolean[] found = new boolean[1];
+ String fileName = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, currentDeviceZoom, found);
+ if (found[0]) {
+ initNative (fileName);
+ if (this.handle == 0) init(new ImageData (fileName));
+ } else {
+ ImageData resizedData = DPIUtil.autoScaleUp (new ImageData (fileName));
+ init(resizedData);
+ }
init();
}
@@ -701,16 +723,18 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
public Image(Device device, ImageDataProvider imageDataProvider) {
super(device);
this.imageDataProvider = imageDataProvider;
- currentDeviceZoom = getDeviceZoom ();
- ImageData data = DPIUtil.validateAndGetImageDataAtZoom(imageDataProvider, currentDeviceZoom, new boolean[1]);
- init(data);
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
+ boolean[] found = new boolean[1];
+ ImageData data = DPIUtil.validateAndGetImageDataAtZoom(imageDataProvider, currentDeviceZoom, found);
+ if (found[0]) {
+ init(data);
+ } else {
+ ImageData resizedData = DPIUtil.autoScaleUp(data);
+ init (resizedData);
+ }
init();
}
-int getDeviceZoom () {
- return DPIUtil.mapDPIToZoom (device._getDPIx ());
-}
-
/**
* Refresh the Image based on the zoom level, if required.
*
@@ -718,8 +742,8 @@ int getDeviceZoom () {
*/
boolean refreshImageForZoom () {
boolean refreshed = false;
+ int deviceZoomLevel = DPIUtil.getDeviceZoom();
if (imageFileNameProvider != null) {
- int deviceZoomLevel = getDeviceZoom();
if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, deviceZoomLevel, found);
@@ -732,10 +756,17 @@ boolean refreshImageForZoom () {
init();
refreshed = true;
}
+ if (!found[0]) {
+ /* Release current native resources */
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleUp (new ImageData (filename));
+ init(resizedData);
+ init ();
+ refreshed = true;
+ }
currentDeviceZoom = deviceZoomLevel;
}
} else if (imageDataProvider != null) {
- int deviceZoomLevel = getDeviceZoom();
if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
ImageData data = DPIUtil.validateAndGetImageDataAtZoom (imageDataProvider, deviceZoomLevel, found);
@@ -747,6 +778,24 @@ boolean refreshImageForZoom () {
init();
refreshed = true;
}
+ if (!found[0]) {
+ /* Release current native resources */
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleUp (data);
+ init(resizedData);
+ init();
+ refreshed = true;
+ }
+ currentDeviceZoom = deviceZoomLevel;
+ }
+ } else {
+ if (deviceZoomLevel != currentDeviceZoom) {
+ ImageData data = getImageDataAtCurrentZoom();
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleImageData(data, deviceZoomLevel, currentDeviceZoom);
+ init(resizedData);
+ init();
+ refreshed = true;
currentDeviceZoom = deviceZoomLevel;
}
}
@@ -1335,7 +1384,7 @@ public Color getBackground() {
* have x and y values of 0, and the width and height of the
* image.
*
- * @return a rectangle specifying the image's bounds
+ * @return a rectangle specifying the image's bounds at 100% zoom.
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
@@ -1344,6 +1393,32 @@ public Color getBackground() {
*/
public Rectangle getBounds() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return getBounds (100);
+}
+
+Rectangle getBounds(int zoom) {
+ Rectangle bounds = getBoundsInPixels();
+ if (bounds != null && zoom != currentDeviceZoom) {
+ bounds = DPIUtil.autoScaleBounds(bounds, zoom, currentDeviceZoom);
+ }
+ return bounds;
+}
+
+/**
+ * Returns the bounds of the receiver. The rectangle will always
+ * have x and y values of 0, and the width and height of the
+ * image in Pixels.
+ *
+ * @return a rectangle specifying the image's bounds in pixels.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ * @since 3.105
+ */
+public Rectangle getBoundsInPixels() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width != -1 && height != -1) {
return new Rectangle(0, 0, width, height);
}
@@ -1378,7 +1453,8 @@ public Rectangle getBounds() {
* Modifications made to this <code>ImageData</code> will not
* affect the Image.
*
- * @return an <code>ImageData</code> containing the image's data and attributes
+ * @return an <code>ImageData</code> containing the image's data and
+ * attributes at 100% zoom level.
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
@@ -1389,6 +1465,31 @@ public Rectangle getBounds() {
*/
public ImageData getImageData() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return getImageData(100);
+}
+
+ImageData getImageData (int zoom) {
+ return DPIUtil.autoScaleImageData(this.getImageDataAtCurrentZoom(), zoom, currentDeviceZoom);
+}
+
+/**
+ * Returns an <code>ImageData</code> based on the receiver
+ * Modifications made to this <code>ImageData</code> will not
+ * affect the Image.
+ *
+ * @return an <code>ImageData</code> containing the image's data
+ * and attributes at the current zoom level.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ * @since 3.105
+ */
+public ImageData getImageDataAtCurrentZoom() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
BITMAP bm;
int depth, width, height;
switch (type) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
index 5684d1ce3e..7b845f2fda 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -194,7 +195,15 @@ public Path (Device device, PathData data) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
+public void addArc (float x, float y, float width, float height, float startAngle, float arcAngle) {
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ addArcInPixels(x, y, width, height, startAngle, arcAngle);
+}
+
+void addArcInPixels(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0) {
x = x + width;
@@ -256,7 +265,15 @@ public void addPath(Path path) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void addRectangle(float x, float y, float width, float height) {
+public void addRectangle (float x, float y, float width, float height) {
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ addRectangleInPixels(x, y, width, height);
+}
+
+void addRectangleInPixels(float x, float y, float width, float height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
RectF rect = new RectF();
rect.X = x;
@@ -285,7 +302,13 @@ public void addRectangle(float x, float y, float width, float height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void addString(String string, float x, float y, Font font) {
+public void addString (String string, float x, float y, Font font) {
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ addStringInPixels(string, x, y, font);
+}
+
+void addStringInPixels(String string, float x, float y, Font font) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -353,7 +376,13 @@ public void close() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains(float x, float y, GC gc, boolean outline) {
+public boolean contains (float x, float y, GC gc, boolean outline) {
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ return containsInPixels(x, y, gc, outline);
+}
+
+boolean containsInPixels(float x, float y, GC gc, boolean outline) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -383,7 +412,17 @@ public boolean contains(float x, float y, GC gc, boolean outline) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
+public void cubicTo (float cx1, float cy1, float cx2, float cy2, float x, float y) {
+ cx1 = DPIUtil.autoScaleUp(cx1);
+ cy1 = DPIUtil.autoScaleUp(cy1);
+ cx2 = DPIUtil.autoScaleUp(cx2);
+ cy2 = DPIUtil.autoScaleUp(cy2);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
+}
+
+void cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
Gdip.GraphicsPath_AddBezier(handle, currentPoint.X, currentPoint.Y, cx1, cy1, cx2, cy2, x, y);
Gdip.GraphicsPath_GetLastPoint(handle, currentPoint);
@@ -410,9 +449,14 @@ void destroy() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void getBounds(float[] bounds) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public void getBounds (float[] bounds) {
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ getBoundsInPixels(bounds);
+ bounds = DPIUtil.autoScaleDown(bounds);
+}
+
+void getBoundsInPixels(float[] bounds) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (bounds.length < 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
RectF rect = new RectF();
Gdip.GraphicsPath_GetBounds(handle, rect, 0, 0);
@@ -436,9 +480,14 @@ public void getBounds(float[] bounds) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void getCurrentPoint(float[] point) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+public void getCurrentPoint (float[] point) {
if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ getCurrentPointInPixels(point);
+ point = DPIUtil.autoScaleDown(point);
+}
+
+void getCurrentPointInPixels(float[] point) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (point.length < 2) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
point[0] = currentPoint.X;
point[1] = currentPoint.Y;
@@ -512,7 +561,11 @@ public PathData getPathData() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void lineTo(float x, float y) {
+public void lineTo (float x, float y) {
+ lineToInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void lineToInPixels(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
Gdip.GraphicsPath_AddLine(handle, currentPoint.X, currentPoint.Y, x, y);
Gdip.GraphicsPath_GetLastPoint(handle, currentPoint);
@@ -524,16 +577,16 @@ void init(PathData data) {
for (int i = 0, j = 0; i < types.length; i++) {
switch (types[i]) {
case SWT.PATH_MOVE_TO:
- moveTo(points[j++], points[j++]);
+ moveToInPixels(points[j++], points[j++]);
break;
case SWT.PATH_LINE_TO:
- lineTo(points[j++], points[j++]);
+ lineToInPixels(points[j++], points[j++]);
break;
case SWT.PATH_CUBIC_TO:
- cubicTo(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
+ cubicToInPixels(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
break;
case SWT.PATH_QUAD_TO:
- quadTo(points[j++], points[j++], points[j++], points[j++]);
+ quadToInPixels(points[j++], points[j++], points[j++], points[j++]);
break;
case SWT.PATH_CLOSE:
close();
@@ -572,7 +625,11 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void moveTo(float x, float y) {
+public void moveTo (float x, float y) {
+ moveToInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void moveToInPixels(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
Gdip.GraphicsPath_StartFigure(handle);
currentPoint.X = startPoint.X = x;
@@ -591,7 +648,15 @@ public void moveTo(float x, float y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void quadTo(float cx, float cy, float x, float y) {
+public void quadTo (float cx, float cy, float x, float y) {
+ cx = DPIUtil.autoScaleUp(cx);
+ cy = DPIUtil.autoScaleUp(cy);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ quadToInPixels(cx, cy, x, y);
+}
+
+void quadToInPixels(float cx, float cy, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
float cx1 = currentPoint.X + 2 * (cx - currentPoint.X) / 3;
float cy1 = currentPoint.Y + 2 * (cy - currentPoint.Y) / 3;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Pattern.java
index c5a5d8c125..01c8929115 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Pattern.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Pattern.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 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
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -176,6 +177,10 @@ public Pattern(Device device, float x1, float y1, float x2, float y2, Color colo
*/
public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
super(device);
+ x1 = DPIUtil.autoScaleUp(x1);
+ y1 = DPIUtil.autoScaleUp(y1);
+ x2 = DPIUtil.autoScaleUp(x2);
+ y2 = DPIUtil.autoScaleUp(y2);
if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
index 97b51d1aa6..d7cfba8ee3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -110,11 +111,15 @@ Region(Device device, int handle) {
* </ul>
*
* @since 3.0
-*
+ *
*/
public void add (int[] pointArray) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ addInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+
+void addInPixels (int[] pointArray) {
if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
long /*int*/ polyRgn = OS.CreatePolygonRgn(pointArray, pointArray.length / 2, OS.ALTERNATE);
OS.CombineRgn (handle, handle, polyRgn, OS.RGN_OR);
@@ -138,7 +143,8 @@ public void add (int[] pointArray) {
public void add (Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- add (rect.x, rect.y, rect.width, rect.height);
+ rect = DPIUtil.autoScaleUp(rect);
+ addInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -161,6 +167,10 @@ public void add (Rectangle rect) {
*/
public void add (int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ addInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void addInPixels (int x, int y, int width, int height) {
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
long /*int*/ rectRgn = OS.CreateRectRgn (x, y, x + width, y + height);
OS.CombineRgn (handle, handle, rectRgn, OS.RGN_OR);
@@ -204,6 +214,10 @@ public void add (Region region) {
*/
public boolean contains (int x, int y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return containsInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+boolean containsInPixels (int x, int y) {
return OS.PtInRegion (handle, x, y);
}
@@ -225,7 +239,8 @@ public boolean contains (int x, int y) {
public boolean contains (Point pt) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
+ pt = DPIUtil.autoScaleUp(pt);
+ return containsInPixels(pt.x, pt.y);
}
@Override
@@ -265,8 +280,12 @@ public boolean equals (Object object) {
*
* @see Rectangle#union
*/
-public Rectangle getBounds() {
+public Rectangle getBounds () {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels() {
RECT rect = new RECT();
OS.GetRgnBox(handle, rect);
return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
@@ -306,7 +325,8 @@ public int hashCode () {
public void intersect (Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- intersect (rect.x, rect.y, rect.width, rect.height);
+ rect = DPIUtil.autoScaleUp(rect);
+ intersectInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -329,6 +349,10 @@ public void intersect (Rectangle rect) {
*/
public void intersect (int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ intersectInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void intersectInPixels (int x, int y, int width, int height) {
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
long /*int*/ rectRgn = OS.CreateRectRgn (x, y, x + width, y + height);
OS.CombineRgn (handle, handle, rectRgn, OS.RGN_AND);
@@ -378,6 +402,10 @@ public void intersect (Region region) {
*/
public boolean intersects (int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return intersectsInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+boolean intersectsInPixels (int x, int y, int width, int height) {
RECT r = new RECT ();
OS.SetRect (r, x, y, x + width, y + height);
return OS.RectInRegion (handle, r);
@@ -403,7 +431,8 @@ public boolean intersects (int x, int y, int width, int height) {
public boolean intersects (Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return intersects(rect.x, rect.y, rect.width, rect.height);
+ rect = DPIUtil.autoScaleUp(rect);
+ return intersectsInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -458,6 +487,10 @@ public boolean isEmpty () {
public void subtract (int[] pointArray) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ subtractInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+
+void subtractInPixels (int[] pointArray) {
if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
long /*int*/ polyRgn = OS.CreatePolygonRgn(pointArray, pointArray.length / 2, OS.ALTERNATE);
OS.CombineRgn (handle, handle, polyRgn, OS.RGN_DIFF);
@@ -483,7 +516,8 @@ public void subtract (int[] pointArray) {
public void subtract (Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- subtract (rect.x, rect.y, rect.width, rect.height);
+ rect = DPIUtil.autoScaleUp(rect);
+ subtractInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -506,6 +540,10 @@ public void subtract (Rectangle rect) {
*/
public void subtract (int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ subtractInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void subtractInPixels (int x, int y, int width, int height) {
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
long /*int*/ rectRgn = OS.CreateRectRgn (x, y, x + width, y + height);
OS.CombineRgn (handle, handle, rectRgn, OS.RGN_DIFF);
@@ -551,6 +589,10 @@ public void subtract (Region region) {
*/
public void translate (int x, int y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ translateInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void translateInPixels (int x, int y) {
OS.OffsetRgn (handle, x, y);
}
@@ -572,7 +614,8 @@ public void translate (int x, int y) {
public void translate (Point pt) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- translate (pt.x, pt.y);
+ pt = DPIUtil.autoScaleUp(pt);
+ translateInPixels(pt.x, pt.y);
}
/**
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 b191dc2e6a..a1556d0319 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
@@ -567,7 +567,12 @@ long /*int*/ createGdipBrush(Color color, int alpha) {
* </ul>
*/
public void draw (GC gc, int x, int y) {
- draw(gc, x, y, -1, -1, null, null);
+ checkLayout();
+ drawInPixels(gc, DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void drawInPixels (GC gc, int x, int y) {
+ drawInPixels(gc, x, y, -1, -1, null, null);
}
/**
@@ -590,7 +595,12 @@ public void draw (GC gc, int x, int y) {
* </ul>
*/
public void draw (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
- draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
+ checkLayout();
+ drawInPixels(gc, DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), selectionStart, selectionEnd, selectionForeground, selectionBackground);
+}
+
+void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
}
/**
@@ -622,6 +632,10 @@ public void draw (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();
+ drawInPixels(gc, DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), selectionStart, selectionEnd, selectionForeground, selectionBackground, flags);
+}
+
+void drawInPixels (GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
computeRuns(gc);
if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -630,7 +644,7 @@ public void draw (GC gc, int x, int y, int selectionStart, int selectionEnd, Col
int length = text.length();
if (length == 0 && flags == 0) return;
long /*int*/ hdc = gc.handle;
- Rectangle clip = gc.getClipping();
+ Rectangle clip = gc.getClippingInPixels();
GCData data = gc.data;
long /*int*/ gdipGraphics = data.gdipGraphics;
int foreground = data.foreground;
@@ -1580,20 +1594,24 @@ public int getAlignment () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #getDescent()
- * @see #setDescent(int)
- * @see #setAscent(int)
+ * @see #getDescentInPixels()
+ * @see #setDescentInPixels(int)
+ * @see #setAscentInPixels(int)
* @see #getLineMetrics(int)
*/
public int getAscent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getAscentInPixels());
+}
+
+int getAscentInPixels () {
return ascent;
}
/**
* Returns the bounds of the receiver. The width returned is either the
* width of the longest line or the width set using {@link TextLayout#setWidth(int)}.
- * To obtain the text bounds of a line use {@link TextLayout#getLineBounds(int)}.
+ * To obtain the text bounds of a line use {@link TextLayout#getLineBoundsInPixels(int)}.
*
* @return the bounds of the receiver
*
@@ -1606,6 +1624,10 @@ public int getAscent () {
*/
public Rectangle getBounds () {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
computeRuns(null);
int width = 0;
if (wrapWidth != -1) {
@@ -1634,6 +1656,10 @@ public Rectangle getBounds () {
*/
public Rectangle getBounds (int start, int end) {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels(start, end));
+}
+
+Rectangle getBoundsInPixels (int start, int end) {
computeRuns(null);
int length = text.length();
if (length == 0) return new Rectangle(0, 0, 0, 0);
@@ -1676,7 +1702,7 @@ public Rectangle getBounds (int start, int end) {
int cx = 0;
if (run.style != null && run.style.metrics != null) {
GlyphMetrics metrics = run.style.metrics;
- cx = metrics.width * (start - run.start);
+ cx = metrics.getWidthInPixels() * (start - run.start);
} else if (!run.tab) {
int[] piX = new int[1];
long /*int*/ advances = run.justify != 0 ? run.justify : run.advances;
@@ -1693,7 +1719,7 @@ public Rectangle getBounds (int start, int end) {
int cx = run.width;
if (run.style != null && run.style.metrics != null) {
GlyphMetrics metrics = run.style.metrics;
- cx = metrics.width * (end - run.start + 1);
+ cx = metrics.getWidthInPixels() * (end - run.start + 1);
} else if (!run.tab) {
int[] piX = new int[1];
long /*int*/ advances = run.justify != 0 ? run.justify : run.advances;
@@ -1727,13 +1753,17 @@ public Rectangle getBounds (int start, int end) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #getAscent()
- * @see #setAscent(int)
- * @see #setDescent(int)
+ * @see #getAscentInPixels()
+ * @see #setAscentInPixels(int)
+ * @see #setDescentInPixels(int)
* @see #getLineMetrics(int)
*/
public int getDescent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getDescentInPixels());
+}
+
+int getDescentInPixels () {
return descent;
}
@@ -1765,6 +1795,10 @@ public Font getFont () {
*/
public int getIndent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getIndentInPixels());
+}
+
+int getIndentInPixels () {
return indent;
}
@@ -1836,8 +1870,12 @@ public int getLevel (int offset) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getLineBounds(int lineIndex) {
+public Rectangle getLineBounds (int lineIndex) {
checkLayout();
+ return DPIUtil.autoScaleDown(getLineBoundsInPixels(lineIndex));
+}
+
+Rectangle getLineBoundsInPixels(int lineIndex) {
computeRuns(null);
if (!(0 <= lineIndex && lineIndex < runs.length)) SWT.error(SWT.ERROR_INVALID_RANGE);
int x = getLineIndent(lineIndex);
@@ -2002,11 +2040,15 @@ public int[] getLineOffsets () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #getOffset(Point, int[])
- * @see #getOffset(int, int, int[])
+ * @see #getOffsetInPixels(Point, int[])
+ * @see #getOffsetInPixels(int, int, int[])
*/
public Point getLocation (int offset, boolean trailing) {
checkLayout();
+ return DPIUtil.autoScaleDown(getLocationInPixels(offset, trailing));
+}
+
+Point getLocationInPixels (int offset, boolean trailing) {
computeRuns(null);
int length = text.length();
if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
@@ -2054,7 +2096,7 @@ public Point getLocation (int offset, boolean trailing) {
int width;
if (run.style != null && run.style.metrics != null) {
GlyphMetrics metrics = run.style.metrics;
- width = metrics.width * (offset - run.start + (trailing ? 1 : 0));
+ width = metrics.getWidthInPixels() * (offset - run.start + (trailing ? 1 : 0));
} else if (run.tab) {
width = (trailing || (offset == length)) ? run.width : 0;
} else {
@@ -2195,12 +2237,15 @@ int _getOffset(int offset, int movement, boolean forward) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #getLocation(int, boolean)
+ * @see #getLocationInPixels(int, boolean)
*/
public int getOffset (Point point, int[] trailing) {
checkLayout();
- if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return getOffset (point.x, point.y, trailing) ;
+ if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); return getOffsetInPixels(DPIUtil.autoScaleUp(point), trailing);
+}
+
+int getOffsetInPixels (Point point, int[] trailing) {
+ return getOffsetInPixels (point.x, point.y, trailing) ;
}
/**
@@ -2228,6 +2273,10 @@ public int getOffset (Point point, int[] trailing) {
*/
public int getOffset (int x, int y, int[] trailing) {
checkLayout();
+ return getOffsetInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), trailing);
+}
+
+int getOffsetInPixels (int x, int y, int[] trailing) {
computeRuns(null);
if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int line;
@@ -2254,11 +2303,11 @@ public int getOffset (int x, int y, int[] trailing) {
int xRun = x - run.x;
if (run.style != null && run.style.metrics != null) {
GlyphMetrics metrics = run.style.metrics;
- if (metrics.width > 0) {
+ if (metrics.getWidthInPixels() > 0) {
if (trailing != null) {
- trailing[0] = (xRun % metrics.width < metrics.width / 2) ? 0 : 1;
+ trailing[0] = (xRun % metrics.getWidthInPixels() < metrics.getWidthInPixels() / 2) ? 0 : 1;
}
- return untranslateOffset(run.start + xRun / metrics.width);
+ return untranslateOffset(run.start + xRun / metrics.getWidthInPixels());
}
}
if (run.tab) {
@@ -2467,6 +2516,10 @@ String getSegmentsText() {
*/
public int getSpacing () {
checkLayout();
+ return DPIUtil.autoScaleDown(getSpacingInPixels());
+}
+
+int getSpacingInPixels () {
return lineSpacing;
}
@@ -2580,6 +2633,10 @@ public int getTextDirection () {
*/
public int getWidth () {
checkLayout();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
return wrapWidth;
}
@@ -2596,6 +2653,10 @@ public int getWidth () {
*/
public int getWrapIndent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getWrapIndentInPixels());
+}
+
+int getWrapIndentInPixels () {
return wrapIndent;
}
@@ -2852,11 +2913,15 @@ public void setAlignment (int alignment) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #setDescent(int)
+ * @see #setDescentInPixels(int)
* @see #getLineMetrics(int)
*/
-public void setAscent(int ascent) {
+public void setAscent (int ascent) {
checkLayout();
+ setAscentInPixels(DPIUtil.autoScaleUp(ascent));
+}
+
+void setAscentInPixels(int ascent) {
if (ascent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (this.ascent == ascent) return;
freeRuns();
@@ -2878,11 +2943,15 @@ public void setAscent(int ascent) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #setAscent(int)
+ * @see #setAscentInPixels(int)
* @see #getLineMetrics(int)
*/
-public void setDescent(int descent) {
+public void setDescent (int descent) {
checkLayout();
+ setDescentInPixels(DPIUtil.autoScaleUp(descent));
+}
+
+void setDescentInPixels(int descent) {
if (descent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (this.descent == descent) return;
freeRuns();
@@ -2931,6 +3000,10 @@ public void setFont (Font font) {
*/
public void setIndent (int indent) {
checkLayout();
+ setIndentInPixels(DPIUtil.autoScaleUp(indent));
+}
+
+void setIndentInPixels (int indent) {
if (indent < 0) return;
if (this.indent == indent) return;
freeRuns();
@@ -3066,6 +3139,10 @@ public void setSegmentsChars(char[] segmentsChars) {
public void setSpacing (int spacing) {
checkLayout();
if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+}
+
+void setSpacingInPixels (int spacing) {
if (this.lineSpacing == spacing) return;
freeRuns();
this.lineSpacing = spacing;
@@ -3269,6 +3346,10 @@ public void setTextDirection (int textDirection) {
*/
public void setWidth (int width) {
checkLayout();
+ setWidthInPixels(width != SWT.DEFAULT ? DPIUtil.autoScaleUp(width) : width);
+}
+
+void setWidthInPixels (int width) {
if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (this.wrapWidth == width) return;
freeRuns();
@@ -3285,12 +3366,16 @@ public void setWidth (int width) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
- * @see #setIndent(int)
+ * @see #setIndentInPixels(int)
*
* @since 3.6
*/
public void setWrapIndent (int wrapIndent) {
checkLayout();
+ setWrapIndentInPixels(DPIUtil.autoScaleUp(wrapIndent));
+}
+
+void setWrapIndentInPixels (int wrapIndent) {
if (wrapIndent < 0) return;
if (this.wrapIndent == wrapIndent) return;
freeRuns();
@@ -3535,9 +3620,9 @@ void shape (final long /*int*/ hdc, final StyleItem run) {
* equals zero for FFFC (possibly other unicode code points), the fix
* is to make sure the glyph is at least one pixel wide.
*/
- run.width = metrics.width * Math.max (1, run.glyphCount);
- run.ascent = metrics.ascent;
- run.descent = metrics.descent;
+ run.width = metrics.getWidthInPixels() * Math.max (1, run.glyphCount);
+ run.ascent = metrics.getAscentInPixels();
+ run.descent = metrics.getDescentInPixels();
run.leading = 0;
} else {
TEXTMETRIC lptm = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
index c7f96b0a77..2a26a1b066 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Transform.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
/**
@@ -143,7 +144,7 @@ public Transform(Device device, float[] elements) {
public Transform (Device device, float m11, float m12, float m21, float m22, float dx, float dy) {
super(device);
this.device.checkGDIP();
- handle = Gdip.Matrix_new(m11, m12, m21, m22, dx, dy);
+ handle = Gdip.Matrix_new(m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
init();
}
@@ -179,6 +180,8 @@ public void getElements(float[] elements) {
if (elements == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (elements.length < 6) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
Gdip.Matrix_GetElements(handle, elements);
+ elements[4] = DPIUtil.autoScaleDown(elements[4]);
+ elements[5] = DPIUtil.autoScaleDown(elements[5]);
}
/**
@@ -309,7 +312,7 @@ public void scale(float scaleX, float scaleY) {
*/
public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Gdip.Matrix_SetElements(handle, m11, m12, m21, m22, dx, dy);
+ Gdip.Matrix_SetElements(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
}
/**
@@ -347,7 +350,14 @@ public void shear(float shearX, float shearY) {
public void transform(float[] pointArray) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- Gdip.Matrix_TransformPoints(handle, pointArray, pointArray.length / 2);
+ int length = pointArray.length;
+ for (int i = 0; i < length; i++) {
+ pointArray[i] = DPIUtil.autoScaleUp(pointArray[i]);
+ }
+ Gdip.Matrix_TransformPoints(handle, pointArray, length / 2);
+ for (int i = 0; i < length; i++) {
+ pointArray[i] = DPIUtil.autoScaleDown(pointArray[i]);
+ }
}
/**
@@ -363,7 +373,7 @@ public void transform(float[] pointArray) {
*/
public void translate(float offsetX, float offsetY) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Gdip.Matrix_Translate(handle, offsetX, offsetY, Gdip.MatrixOrderPrepend);
+ Gdip.Matrix_Translate(handle, DPIUtil.autoScaleUp(offsetX), DPIUtil.autoScaleUp(offsetY), Gdip.MatrixOrderPrepend);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
index 3941a177fc..d2c4b54152 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
@@ -11,9 +11,9 @@
package org.eclipse.swt.internal;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
public class ImageList {
long /*int*/ handle;
@@ -64,7 +64,7 @@ public int add (Image image) {
index++;
}
if (count == 0) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
OS.ImageList_SetIconSize (handle, rect.width, rect.height);
}
set (index, image, count);
@@ -402,7 +402,7 @@ void set (int index, Image image, int count) {
* Note that the image size has to match the image list icon size.
*/
long /*int*/ hBitmap = 0, hMask = 0;
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageDataAtCurrentZoom ();
switch (data.getTransparencyType ()) {
case SWT.TRANSPARENCY_ALPHA:
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 839ba189f3..aba6517576 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a selectable user interface object that
@@ -213,7 +213,7 @@ void _setImage (Image image) {
*/
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
long /*int*/ hDC = OS.GetDC (handle);
long /*int*/ dstHdc = OS.CreateCompatibleDC (hDC);
long /*int*/ hBitmap = OS.CreateCompatibleBitmap (hDC, rect.width, rect.height);
@@ -378,7 +378,7 @@ int computeLeftMargin () {
if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) return MARGIN;
int margin = 0;
if (image != null && text.length () != 0) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
margin += bounds.width + MARGIN * 2;
long /*int*/ oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
@@ -397,10 +397,9 @@ int computeLeftMargin () {
return margin;
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- int width = 0, height = 0, border = getBorderWidth ();
+ int width = 0, height = 0, border = getBorderWidthInPixels ();
if ((style & SWT.ARROW) != 0) {
if ((style & (SWT.UP | SWT.DOWN)) != 0) {
width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
@@ -440,7 +439,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
if (hasImage) {
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
width = rect.width;
if (hasText && text.length () != 0) {
width += MARGIN * 2;
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 1c17b19910..c283f29f40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide a surface for drawing
@@ -110,7 +111,11 @@ void clearArea (int x, int y, int width, int height) {
* @since 3.2
*/
public void drawBackground (GC gc, int x, int y, int width, int height) {
- drawBackground(gc, x, y, width, height, 0, 0);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ drawBackgroundInPixels(gc, x, y, width, height, 0, 0);
}
/**
@@ -197,6 +202,16 @@ void reskinChildren (int flags) {
*/
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
checkWidget ();
+ destX = DPIUtil.autoScaleUp(destX);
+ destY = DPIUtil.autoScaleUp(destY);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ scrollInPixels(destX, destY, x, y, width, height, all);
+}
+
+void scrollInPixels (int destX, int destY, int x, int y, int width, int height, boolean all) {
forceResize ();
boolean isFocus = caret != null && caret.isFocusCaret ();
if (isFocus) caret.killFocus ();
@@ -252,10 +267,10 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
- Rectangle rect = child.getBounds ();
+ Rectangle rect = child.getBoundsInPixels ();
if (Math.min (x + width, rect.x + rect.width) >= Math.max (x, rect.x) &&
Math.min (y + height, rect.y + rect.height) >= Math.max (y, rect.y)) {
- child.setLocation (rect.x + deltaX, rect.y + deltaY);
+ child.setLocationInPixels (rect.x + deltaX, rect.y + deltaY);
}
}
}
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 0aa61670c9..0023de9111 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
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide an i-beam that is typically used
@@ -110,8 +111,12 @@ long /*int*/ defaultFont () {
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
return new Rectangle (x, y, rect.width, rect.height);
} else {
if (!OS.IsWinCE && width == 0) {
@@ -171,6 +176,10 @@ public Image getImage () {
*/
public Point getLocation () {
checkWidget();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
return new Point (x, y);
}
@@ -201,8 +210,12 @@ public Canvas getParent () {
*/
public Point getSize () {
checkWidget();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels () {
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
return new Point (rect.width, rect.height);
} else {
if (!OS.IsWinCE && width == 0) {
@@ -283,7 +296,7 @@ void resizeIME () {
long /*int*/ hIMC = OS.ImmGetContext (hwnd);
IME ime = parent.getIME ();
if (ime != null && ime.isInlineEnabled ()) {
- Point size = getSize ();
+ Point size = getSizeInPixels ();
CANDIDATEFORM lpCandidate = new CANDIDATEFORM ();
lpCandidate.dwStyle = OS.CFS_EXCLUDE;
lpCandidate.ptCurrentPos = ptCurrentPos;
@@ -367,6 +380,10 @@ void restoreIMEFont () {
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
+ setBoundsInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void setBoundsInPixels (int x, int y, int width, int height) {
boolean samePosition = this.x == x && this.y == y;
boolean sameExtent = this.width == width && this.height == height;
if (samePosition && sameExtent) return;
@@ -398,7 +415,11 @@ public void setBounds (int x, int y, int width, int height) {
*/
public void setBounds (Rectangle rect) {
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
+ setBoundsInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+void setBoundsInPixels (Rectangle rect) {
+ setBoundsInPixels (rect.x, rect.y, rect.width, rect.height);
}
void setFocus () {
@@ -501,6 +522,10 @@ void setIMEFont () {
*/
public void setLocation (int x, int y) {
checkWidget();
+ setLocationInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void setLocationInPixels (int x, int y) {
if (this.x == x && this.y == y) return;
this.x = x; this.y = y;
moved = true;
@@ -522,7 +547,8 @@ public void setLocation (int x, int y) {
public void setLocation (Point location) {
checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ location = DPIUtil.autoScaleUp(location);
+ setLocationInPixels(location.x, location.y);
}
/**
@@ -538,6 +564,10 @@ public void setLocation (Point location) {
*/
public void setSize (int width, int height) {
checkWidget();
+ setSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void setSizeInPixels (int width, int height) {
if (this.width == width && this.height == height) return;
this.width = width; this.height = height;
resized = true;
@@ -560,7 +590,8 @@ public void setSize (int width, int height) {
public void setSize (Point size) {
checkWidget();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
+ size = DPIUtil.autoScaleUp(size);
+ setSizeInPixels(size.x, size.y);
}
/**
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 e3abaa93fb..19b311f332 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -12,11 +12,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are controls that allow the user
@@ -622,8 +622,7 @@ public void clearSelection () {
OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, -1);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
if (wHint == SWT.DEFAULT) {
@@ -948,6 +947,10 @@ boolean dragDetect (long /*int*/ hwnd, int x, int y, boolean filter, boolean []
*/
public Point getCaretLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getCaretLocationInPixels());
+}
+
+Point getCaretLocationInPixels () {
/*
* Bug in Windows. For some reason, Windows is unable
* to return the pixel coordinates of the last character
@@ -1118,6 +1121,10 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getItemHeightInPixels());
+}
+
+int getItemHeightInPixels () {
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
if (result == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
return result;
@@ -1384,6 +1391,10 @@ public String getText () {
*/
public int getTextHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getTextHeightInPixels());
+}
+
+int getTextHeightInPixels () {
COMBOBOXINFO pcbi = new COMBOBOXINFO ();
pcbi.cbSize = COMBOBOXINFO.sizeof;
if (((style & SWT.SIMPLE) == 0) && !OS.IsWinCE && OS.GetComboBoxInfo (handle, pcbi)) {
@@ -1978,7 +1989,7 @@ void setBackgroundPixel (int pixel) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags) {
/*
* Feature in Windows. If the combo box has the CBS_DROPDOWN
* or CBS_DROPDOWNLIST style, Windows uses the height that the
@@ -1998,7 +2009,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
*/
if ((style & SWT.DROP_DOWN) != 0) {
int visibleCount = getItemCount() == 0 ? VISIBLE_COUNT : this.visibleCount;
- height = getTextHeight () + (getItemHeight () * visibleCount) + 2;
+ height = getTextHeightInPixels () + (getItemHeightInPixels () * visibleCount) + 2;
/*
* Feature in Windows. When a drop down combo box is resized,
* the combo box resizes the height of the text field and uses
@@ -2022,7 +2033,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
}
SetWindowPos (handle, 0, x, y, width, height, flags);
} else {
- super.setBounds (x, y, width, height, flags);
+ super.setBoundsInPixels (x, y, width, height, flags);
}
}
@@ -2484,7 +2495,7 @@ void updateDropDownHeight () {
RECT rect = new RECT ();
OS.SendMessage (handle, OS.CB_GETDROPPEDCONTROLRECT, 0, rect);
int visibleCount = getItemCount() == 0 ? VISIBLE_COUNT : this.visibleCount;
- int height = getTextHeight () + (getItemHeight () * visibleCount) + 2;
+ int height = getTextHeightInPixels () + (getItemHeightInPixels () * visibleCount) + 2;
if (height != (rect.bottom - rect.top)) {
forceResize ();
OS.GetWindowRect (handle, rect);
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 09b3f7a046..4ddebda353 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
@@ -227,16 +227,14 @@ Widget [] computeTabList () {
return result;
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
display.runSkin ();
Point size;
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
changed |= (state & LAYOUT_CHANGED) != 0;
state &= ~LAYOUT_CHANGED;
- size = layout.computeSize (this, wHint, hHint, changed);
+ size = DPIUtil.autoScaleUp(layout.computeSize (this, DPIUtil.autoScaleDown(wHint), DPIUtil.autoScaleDown(hHint), changed));
} else {
size = new Point (wHint, hHint);
}
@@ -247,7 +245,11 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
if (wHint != SWT.DEFAULT) size.x = wHint;
if (hHint != SWT.DEFAULT) size.y = hHint;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ /*
+ * Since computeTrim is overridden by Custom classes like CTabFolder
+ * etc... hence we cannot call computeTrimInPixels directly.
+ */
+ Rectangle trim = DPIUtil.autoScaleUp(computeTrim (0, 0, DPIUtil.autoScaleDown(size.x), DPIUtil.autoScaleDown(size.y)));
return new Point (trim.width, trim.height);
}
@@ -365,8 +367,18 @@ int applyThemeBackground () {
*
* @since 3.6
*/
-public void drawBackground(GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
+public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ offsetX = DPIUtil.autoScaleUp(offsetX);
+ offsetY = DPIUtil.autoScaleUp(offsetY);
+ drawBackgroundInPixels(gc, x, y, width, height, offsetX, offsetY);
+}
+
+void drawBackgroundInPixels(GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
RECT rect = new RECT ();
@@ -882,10 +894,10 @@ void markLayout (boolean changed, boolean all) {
Point minimumSize (int wHint, int hHint, boolean changed) {
Control [] children = _getChildren ();
- Rectangle clientArea = getClientArea ();
+ Rectangle clientArea = getClientAreaInPixels ();
int width = 0, height = 0;
for (int i=0; i<children.length; i++) {
- Rectangle rect = children [i].getBounds ();
+ Rectangle rect = children [i].getBoundsInPixels ();
width = Math.max (width, rect.x - clientArea.x + rect.width);
height = Math.max (height, rect.y - clientArea.y + rect.height);
}
@@ -1071,7 +1083,7 @@ public void setBackgroundMode (int mode) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) {
if (display.resizeCount > Display.RESIZE_LIMIT) {
defer = false;
}
@@ -1079,7 +1091,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
state &= ~(RESIZE_OCCURRED | MOVE_OCCURRED);
state |= RESIZE_DEFERRED | MOVE_DEFERRED;
}
- super.setBounds (x, y, width, height, flags, defer);
+ super.setBoundsInPixels (x, y, width, height, flags, defer);
if (!defer && (state & CANVAS) != 0) {
boolean wasMoved = (state & MOVE_OCCURRED) != 0;
boolean wasResized = (state & RESIZE_OCCURRED) != 0;
@@ -1569,10 +1581,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
GC gc = GC.win32_new (phdc [0], data);
Event event = new Event ();
event.gc = gc;
- event.x = ps.left;
- event.y = ps.top;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(ps.left, ps.top, width, height));
sendEvent (SWT.Paint, event);
if (data.focusDrawn && !isDisposed ()) updateUIState ();
gc.dispose ();
@@ -1657,10 +1666,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if ((style & (SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.TRANSPARENT)) == 0) {
drawBackground (gc.handle, rect);
}
- event.x = rect.left;
- event.y = rect.top;
- event.width = rect.right - rect.left;
- event.height = rect.bottom - rect.top;
+ event.setBoundsInPixels(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
event.count = count - 1 - i;
sendEvent (SWT.Paint, event);
}
@@ -1670,10 +1676,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
drawBackground (gc.handle, rect);
}
- event.x = ps.left;
- event.y = ps.top;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(ps.left, ps.top, width, height));
sendEvent (SWT.Paint, event);
}
// widget could be disposed at this point
@@ -1684,7 +1687,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (gcData.focusDrawn && !isDisposed ()) updateUIState ();
}
gc.dispose();
- if (!isDisposed ()) paintGC.drawImage (image, ps.left, ps.top);
+ if (!isDisposed ()) paintGC.drawImage (image, DPIUtil.autoScaleDown(ps.left), DPIUtil.autoScaleDown(ps.top));
image.dispose ();
gc = paintGC;
}
@@ -1746,10 +1749,7 @@ LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
GC gc = GC.win32_new (wParam, data);
Event event = new Event ();
event.gc = gc;
- event.x = rect.left;
- event.y = rect.top;
- event.width = rect.right - rect.left;
- event.height = rect.bottom - rect.top;
+ event.setBoundsInPixels(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
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 0f692f7c0e..6ed15ef215 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
@@ -16,6 +16,7 @@ import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
@@ -568,7 +569,7 @@ void checkBackground () {
}
void checkBorder () {
- if (getBorderWidth () == 0) style &= ~SWT.BORDER;
+ if (getBorderWidthInPixels () == 0) style &= ~SWT.BORDER;
}
void checkBuffered () {
@@ -618,7 +619,10 @@ void checkMirrored () {
* @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint) {
- return computeSize (wHint, hHint, true);
+ checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint) : hHint);
+ return DPIUtil.autoScaleDown(computeSizeInPixels(wHint, hHint, true));
}
/**
@@ -655,13 +659,19 @@ public Point computeSize (int wHint, int hHint) {
* @see #pack(boolean)
* @see "computeTrim, getClientArea for controls that implement them"
*/
-public Point computeSize (int wHint, int hHint, boolean changed) {
+public Point computeSize (int wHint, int hHint, boolean changed){
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint) : hHint);
+ return DPIUtil.autoScaleDown(computeSizeInPixels(wHint, hHint, changed));
+}
+
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
int width = DEFAULT_WIDTH;
int height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2;
height += border * 2;
return new Point (width, height);
@@ -828,7 +838,8 @@ void destroyWidget () {
public boolean dragDetect (Event event) {
checkWidget ();
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
+ Point loc = event.getLocationInPixels();
+ return dragDetect (event.button, event.count, event.stateMask, loc.x, loc.y);
}
/**
@@ -870,7 +881,7 @@ public boolean dragDetect (Event event) {
public boolean dragDetect (MouseEvent event) {
checkWidget ();
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
+ return dragDetect (event.button, event.count, event.stateMask, DPIUtil.autoScaleUp(event.x), DPIUtil.autoScaleUp(event.y)); // To Pixels
}
boolean dragDetect (int button, int count, int stateMask, int x, int y) {
@@ -1221,6 +1232,10 @@ int getBackgroundPixel () {
*/
public int getBorderWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getBorderWidthInPixels ());
+}
+
+int getBorderWidthInPixels () {
long /*int*/ borderHandle = borderHandle ();
int bits1 = OS.GetWindowLong (borderHandle, OS.GWL_EXSTYLE);
if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXEDGE);
@@ -1243,8 +1258,12 @@ public int getBorderWidth () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
+public Rectangle getBounds (){
checkWidget ();
+ return DPIUtil.autoScaleDown(getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
forceResize ();
RECT rect = new RECT ();
OS.GetWindowRect (topHandle (), rect);
@@ -1419,6 +1438,10 @@ public Object getLayoutData () {
*/
public Point getLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
forceResize ();
RECT rect = new RECT ();
OS.GetWindowRect (topHandle (), rect);
@@ -1471,14 +1494,12 @@ public Monitor getMonitor () {
OS.GetMonitorInfo (hmonitor, lpmi);
Monitor monitor = new Monitor ();
monitor.handle = hmonitor;
- monitor.x = lpmi.rcMonitor_left;
- monitor.y = lpmi.rcMonitor_top;
- monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left;
- monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top;
- monitor.clientX = lpmi.rcWork_left;
- monitor.clientY = lpmi.rcWork_top;
- monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left;
- monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top;
+ Rectangle bounds = new Rectangle (lpmi.rcMonitor_left, lpmi.rcMonitor_top, lpmi.rcMonitor_right - lpmi.rcMonitor_left, lpmi.rcMonitor_bottom - lpmi.rcMonitor_top);
+ bounds = DPIUtil.autoScaleDown (bounds);
+ monitor.setBounds (bounds);
+ Rectangle clientArea = new Rectangle (lpmi.rcWork_left, lpmi.rcWork_top, lpmi.rcWork_right - lpmi.rcWork_left, lpmi.rcWork_bottom - lpmi.rcWork_top);
+ clientArea = DPIUtil.autoScaleDown (clientArea);
+ monitor.setClientArea (clientArea);
return monitor;
}
@@ -1585,8 +1606,12 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSize () {
+public Point getSize (){
checkWidget ();
+ return DPIUtil.autoScaleDown(getSizeInPixels ());
+}
+
+Point getSizeInPixels () {
forceResize ();
RECT rect = new RECT ();
OS.GetWindowRect (topHandle (), rect);
@@ -1899,7 +1924,7 @@ boolean isShowing () {
if (!isVisible ()) return false;
Control control = this;
while (control != null) {
- Point size = control.getSize ();
+ Point size = control.getSizeInPixels ();
if (size.x == 0 || size.y == 0) {
return false;
}
@@ -1969,11 +1994,11 @@ public boolean isVisible () {
void mapEvent (long /*int*/ hwnd, Event event) {
if (hwnd != handle) {
POINT point = new POINT ();
- point.x = event.x;
- point.y = event.y;
+ Point loc = event.getLocationInPixels();
+ point.x = loc.x;
+ point.y = loc.y;
OS.MapWindowPoints (hwnd, handle, point, 1);
- event.x = point.x;
- event.y = point.y;
+ event.setLocationInPixels(point.x, point.y);
}
}
@@ -2146,6 +2171,10 @@ public void pack () {
*/
public void pack (boolean changed) {
checkWidget ();
+ /*
+ * Since computeSize is overridden by Custom classes like CCombo
+ * etc... hence we cannot call computeSizeInPixels directly.
+ */
setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
}
@@ -2429,6 +2458,14 @@ void redraw (boolean all) {
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ redrawInPixels(x, y, width, height, all);
+}
+
+void redrawInPixels (int x, int y, int width, int height, boolean all) {
if (width <= 0 || height <= 0) return;
if (!OS.IsWindowVisible (handle)) return;
RECT rect = new RECT ();
@@ -2924,9 +2961,8 @@ boolean sendGestureEvent (GESTUREINFO gi) {
Event event = new Event ();
int type = 0;
Point globalPt = new Point(gi.x, gi.y);
- Point point = toControl(globalPt);
- event.x = point.x;
- event.y = point.y;
+ Point point = toControlInPixels(globalPt.x, globalPt.y);
+ event.setLocationInPixels(point.x, point.y);
switch (gi.dwID) {
case OS.GID_ZOOM:
type = SWT.Gesture;
@@ -3006,8 +3042,7 @@ void sendTouchEvent (TOUCHINPUT touchInput []) {
POINT pt = new POINT ();
OS.GetCursorPos (pt);
OS.ScreenToClient (handle, pt);
- event.x = pt.x;
- event.y = pt.y;
+ event.setLocationInPixels(pt.x, pt.y);
Touch [] touches = new Touch [touchInput.length];
Monitor monitor = getMonitor ();
for (int i = 0; i < touchInput.length; i++) {
@@ -3157,17 +3192,25 @@ void setBackgroundPixel (int pixel) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setBounds (int x, int y, int width, int height) {
+public void setBounds(int x, int y, int width, int height) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ setBoundsInPixels(x, y, width, height);
+}
+
+void setBoundsInPixels (int x, int y, int width, int height) {
int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
- setBounds (x, y, Math.max (0, width), Math.max (0, height), flags);
+ setBoundsInPixels (x, y, Math.max (0, width), Math.max (0, height), flags);
}
-void setBounds (int x, int y, int width, int height, int flags) {
- setBounds (x, y, width, height, flags, true);
+void setBoundsInPixels (int x, int y, int width, int height, int flags) {
+ setBoundsInPixels (x, y, width, height, flags, true);
}
-void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) {
if (findImageControl () != null) {
if (backgroundImage == null) flags |= OS.SWP_NOCOPYBITS;
} else {
@@ -3227,7 +3270,11 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
+ setBoundsInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+void setBoundsInPixels (Rectangle rect) {
+ setBoundsInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -3477,6 +3524,12 @@ public void setLayoutData (Object layoutData) {
*/
public void setLocation (int x, int y) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ setLocationInPixels(x, y);
+}
+
+void setLocationInPixels (int x, int y) {
int flags = OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
/*
* Feature in WinCE. The SWP_DRAWFRAME flag for SetWindowPos()
@@ -3485,7 +3538,7 @@ public void setLocation (int x, int y) {
* not running on WinCE.
*/
if (!OS.IsWinCE) flags |= OS.SWP_DRAWFRAME;
- setBounds (x, y, 0, 0, flags);
+ setBoundsInPixels (x, y, 0, 0, flags);
}
/**
@@ -3505,7 +3558,8 @@ public void setLocation (int x, int y) {
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ location = DPIUtil.autoScaleUp(location);
+ setLocationInPixels(location.x, location.y);
}
/**
@@ -3700,8 +3754,14 @@ boolean setSavedFocus () {
*/
public void setSize (int width, int height) {
checkWidget ();
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ setSizeInPixels(width, height);
+}
+
+void setSizeInPixels (int width, int height) {
int flags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
- setBounds (0, 0, Math.max (0, width), Math.max (0, height), flags);
+ setBoundsInPixels (0, 0, Math.max (0, width), Math.max (0, height), flags);
}
/**
@@ -3725,7 +3785,8 @@ public void setSize (int width, int height) {
public void setSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
+ size = DPIUtil.autoScaleUp(size);
+ setSizeInPixels(size.x, size.y);
}
@Override
@@ -3915,7 +3976,7 @@ void subclass () {
* to coordinates relative to the receiver.
* <p>
* NOTE: To properly map a rectangle or a corner of a rectangle on a right-to-left platform, use
- * {@link Display#map(Control, Control, Rectangle)}.
+ * {@link Display#mapInPixels(Control, Control, Rectangle)}.
* </p>
*
* @param x the x coordinate to be translated
@@ -3931,6 +3992,10 @@ void subclass () {
*/
public Point toControl (int x, int y) {
checkWidget ();
+ return DPIUtil.autoScaleDown(toControlInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y)));
+}
+
+Point toControlInPixels (int x, int y) {
POINT pt = new POINT ();
pt.x = x; pt.y = y;
OS.ScreenToClient (handle, pt);
@@ -3943,7 +4008,7 @@ public Point toControl (int x, int y) {
* to coordinates relative to the receiver.
* <p>
* NOTE: To properly map a rectangle or a corner of a rectangle on a right-to-left platform, use
- * {@link Display#map(Control, Control, Rectangle)}.
+ * {@link Display#mapInPixels(Control, Control, Rectangle)}.
* </p>
*
* @param point the point to be translated (must not be null)
@@ -3960,7 +4025,8 @@ public Point toControl (int x, int y) {
public Point toControl (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toControl (point.x, point.y);
+ point = DPIUtil.autoScaleUp(point);
+ return DPIUtil.autoScaleDown(toControlInPixels(point.x, point.y));
}
/**
@@ -3969,7 +4035,7 @@ public Point toControl (Point point) {
* the receiver, to display relative coordinates.
* <p>
* NOTE: To properly map a rectangle or a corner of a rectangle on a right-to-left platform, use
- * {@link Display#map(Control, Control, Rectangle)}.
+ * {@link Display#mapInPixels(Control, Control, Rectangle)}.
* </p>
*
* @param x the x coordinate to be translated
@@ -3985,6 +4051,10 @@ public Point toControl (Point point) {
*/
public Point toDisplay (int x, int y) {
checkWidget ();
+ return DPIUtil.autoScaleDown(toDisplayInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y)));
+}
+
+Point toDisplayInPixels (int x, int y) {
POINT pt = new POINT ();
pt.x = x; pt.y = y;
OS.ClientToScreen (handle, pt);
@@ -3997,7 +4067,7 @@ public Point toDisplay (int x, int y) {
* the receiver, to display relative coordinates.
* <p>
* NOTE: To properly map a rectangle or a corner of a rectangle on a right-to-left platform, use
- * {@link Display#map(Control, Control, Rectangle)}.
+ * {@link Display#mapInPixels(Control, Control, Rectangle)}.
* </p>
*
* @param point the point to be translated (must not be null)
@@ -4014,7 +4084,8 @@ public Point toDisplay (int x, int y) {
public Point toDisplay (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toDisplay (point.x, point.y);
+ point = DPIUtil.autoScaleUp(point);
+ return DPIUtil.autoScaleDown(toDisplayInPixels(point.x, point.y));
}
long /*int*/ topHandle () {
@@ -5544,9 +5615,7 @@ LRESULT WM_TABLET_FLICK (long /*int*/ wParam, long /*int*/ lParam) {
event.yDirection = 1;
break;
}
-
- event.x = fPoint.x;
- event.y = fPoint.y;
+ event.setLocationInPixels(fPoint.x, fPoint.y);
event.type = SWT.Gesture;
event.detail = SWT.GESTURE_SWIPE;
setInputState (event, SWT.Gesture);
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 d68f57dc1d..71f50c22d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide an area for dynamically
@@ -140,11 +141,9 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
int width = 0, height = 0;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
@@ -561,6 +560,16 @@ public CoolItem [] getItems () {
*/
public Point [] getItemSizes () {
checkWidget ();
+ Point [] sizes = getItemSizesInPixels();
+ if (sizes != null) {
+ for (int i = 0; i < sizes.length; i++) {
+ sizes[i] = DPIUtil.autoScaleDown(sizes[i]);
+ }
+ }
+ return sizes;
+}
+
+Point [] getItemSizesInPixels () {
int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
Point [] sizes = new Point [count];
REBARBANDINFO rbBand = new REBARBANDINFO ();
@@ -820,6 +829,15 @@ void setItemColors (int foreColor, int backColor) {
*/
public void setItemLayout (int [] itemOrder, int [] wrapIndices, Point [] sizes) {
checkWidget ();
+ if (sizes == null) error (SWT.ERROR_NULL_ARGUMENT);
+ Point [] sizesInPoints = new Point [sizes.length];
+ for (int i = 0; i < sizes.length; i++) {
+ sizesInPoints[i] = DPIUtil.autoScaleUp(sizes[i]);
+ }
+ setItemLayoutInPixels (itemOrder, wrapIndices, sizesInPoints);
+}
+
+void setItemLayoutInPixels (int [] itemOrder, int [] wrapIndices, Point [] sizes) {
setRedraw (false);
setItemOrder (itemOrder);
setWrapIndices (wrapIndices);
@@ -912,7 +930,7 @@ void setItemSizes (Point [] sizes) {
rbBand.fMask = OS.RBBIM_ID;
for (int i=0; i<count; i++) {
OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
- items [rbBand.wID].setSize (sizes [i].x, sizes [i].y);
+ items [rbBand.wID].setSizeInPixels (sizes [i].x, sizes [i].y);
}
}
@@ -1107,11 +1125,11 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
* proc.
*/
if (OS.COMCTL32_MAJOR >= 6) return LRESULT.ZERO;
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
long /*int*/ code = callWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
- if (!rect.equals (getBounds ())) {
- parent.redraw (rect.x, rect.y, rect.width, rect.height, true);
+ if (!rect.equals (getBoundsInPixels ())) {
+ parent.redrawInPixels (rect.x, rect.y, rect.width, rect.height, true);
}
return new LRESULT (code);
}
@@ -1162,20 +1180,20 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (control != null) {
int width = lprbcs.rcChild_right - lprbcs.rcChild_left;
int height = lprbcs.rcChild_bottom - lprbcs.rcChild_top;
- control.setBounds (lprbcs.rcChild_left, lprbcs.rcChild_top, width, height);
+ control.setBoundsInPixels (lprbcs.rcChild_left, lprbcs.rcChild_top, width, height);
}
}
break;
}
case OS.RBN_HEIGHTCHANGE: {
if (!ignoreResize) {
- Point size = getSize ();
- int border = getBorderWidth ();
+ Point size = getSizeInPixels ();
+ int border = getBorderWidthInPixels ();
int barHeight = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
if ((style & SWT.VERTICAL) != 0) {
- setSize (barHeight + 2 * border, size.y);
+ setSizeInPixels (barHeight + 2 * border, size.y);
} else {
- setSize (size.x, barHeight + 2 * border);
+ setSizeInPixels (size.x, barHeight + 2 * border);
}
}
break;
@@ -1188,11 +1206,9 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
Event event = new Event();
event.detail = SWT.ARROW;
if ((style & SWT.VERTICAL) != 0) {
- event.x = lpnm.right;
- event.y = lpnm.top;
+ event.setLocationInPixels(lpnm.right, lpnm.top);
} else {
- event.x = lpnm.left;
- event.y = lpnm.bottom;
+ event.setLocationInPixels(lpnm.left, lpnm.bottom);
}
item.sendSelectionEvent(SWT.Selection, event, false);
}
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 9742ca56d6..1931910066 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -11,10 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are selectable user interface
@@ -185,6 +186,11 @@ protected void checkSubclass () {
*/
public Point computeSize (int wHint, int hHint) {
checkWidget ();
+ wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint) : wHint);
+ hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint) : hHint);
+ return DPIUtil.autoScaleDown(computeSizeInPixels(wHint, hHint));
+}
+Point computeSizeInPixels (int wHint, int hHint) {
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
int width = wHint, height = hHint;
@@ -217,6 +223,10 @@ void destroyWidget () {
*/
public Rectangle getBounds () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
int index = parent.indexOf (this);
if (index == -1) return new Rectangle (0, 0, 0, 0);
long /*int*/ hwnd = parent.handle;
@@ -375,6 +385,10 @@ public void setControl (Control control) {
*/
public Point getPreferredSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getPreferredSizeInPixels());
+}
+
+Point getPreferredSizeInPixels () {
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
long /*int*/ hwnd = parent.handle;
@@ -402,6 +416,10 @@ public Point getPreferredSize () {
*/
public void setPreferredSize (int width, int height) {
checkWidget ();
+ setPreferredSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void setPreferredSizeInPixels (int width, int height) {
int index = parent.indexOf (this);
if (index == -1) return;
width = Math.max (0, width);
@@ -447,7 +465,8 @@ public void setPreferredSize (int width, int height) {
public void setPreferredSize (Point size) {
checkWidget ();
if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
- setPreferredSize (size.x, size.y);
+ size = DPIUtil.autoScaleUp(size);
+ setPreferredSizeInPixels(size.x, size.y);
}
/**
@@ -463,8 +482,12 @@ public void setPreferredSize (Point size) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSize() {
+public Point getSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels() {
int index = parent.indexOf (this);
if (index == -1) new Point (0, 0);
long /*int*/ hwnd = parent.handle;
@@ -505,6 +528,10 @@ public Point getSize() {
*/
public void setSize (int width, int height) {
checkWidget ();
+ setSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void setSizeInPixels (int width, int height) {
int index = parent.indexOf (this);
if (index == -1) return;
width = Math.max (0, width);
@@ -567,8 +594,10 @@ public void setSize (int width, int height) {
* </ul>
*/
public void setSize (Point size) {
+ checkWidget ();
if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
+ size = DPIUtil.autoScaleUp(size);
+ setSizeInPixels(size.x, size.y);
}
/**
@@ -586,6 +615,10 @@ public void setSize (Point size) {
*/
public Point getMinimumSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getMinimumSizeInPixels());
+}
+
+Point getMinimumSizeInPixels () {
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
long /*int*/ hwnd = parent.handle;
@@ -615,6 +648,10 @@ public Point getMinimumSize () {
*/
public void setMinimumSize (int width, int height) {
checkWidget ();
+ setMinimumSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void setMinimumSizeInPixels (int width, int height) {
int index = parent.indexOf (this);
if (index == -1) return;
width = Math.max (0, width);
@@ -661,7 +698,8 @@ public void setMinimumSize (int width, int height) {
public void setMinimumSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setMinimumSize (size.x, size.y);
+ size = DPIUtil.autoScaleUp(size);
+ setMinimumSizeInPixels(size.x, size.y);
}
boolean getWrap() {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
index 828e7ab0a4..e30d1a8e79 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
@@ -247,8 +247,7 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -317,7 +316,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2;
height += border * 2;
return new Point (width, height);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index bf7af0a31f..6f42df63d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -348,8 +348,7 @@ Control computeTabRoot () {
return this;
}
-@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
/* Get the size of the trimmings */
@@ -491,8 +490,7 @@ void fixDecorations (Decorations newDecorations, Control control, Menu [] menus)
}
}
-@Override
-public Rectangle getBounds () {
+@Override Rectangle getBoundsInPixels () {
checkWidget ();
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
@@ -509,11 +507,10 @@ public Rectangle getBounds () {
return new Rectangle (lpwndpl.left, lpwndpl.top, width, height);
}
}
- return super.getBounds ();
+ return super.getBoundsInPixels ();
}
-@Override
-public Rectangle getClientArea () {
+@Override Rectangle getClientAreaInPixels () {
checkWidget ();
/*
* Note: The CommandBar is part of the client area,
@@ -521,7 +518,7 @@ public Rectangle getClientArea () {
* subtract the height of the CommandBar.
*/
if (OS.IsHPC) {
- Rectangle rect = super.getClientArea ();
+ Rectangle rect = super.getClientAreaInPixels ();
if (menuBar != null) {
long /*int*/ hwndCB = menuBar.hwndCB;
int height = OS.CommandBar_Height (hwndCB);
@@ -563,7 +560,7 @@ public Rectangle getClientArea () {
return new Rectangle (0, 0, width, height);
}
}
- return super.getClientArea ();
+ return super.getClientAreaInPixels ();
}
/**
@@ -646,8 +643,7 @@ public Image [] getImages () {
return result;
}
-@Override
-public Point getLocation () {
+@Override Point getLocationInPixels () {
checkWidget ();
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
@@ -660,7 +656,7 @@ public Point getLocation () {
return new Point (lpwndpl.left, lpwndpl.top);
}
}
- return super.getLocation ();
+ return super.getLocationInPixels ();
}
/**
@@ -726,8 +722,7 @@ String getNameText () {
return getText ();
}
-@Override
-public Point getSize () {
+@Override Point getSizeInPixels () {
checkWidget ();
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
@@ -744,7 +739,7 @@ public Point getSize () {
return new Point (width, height);
}
}
- return super.getSize ();
+ return super.getSizeInPixels ();
}
/**
@@ -871,7 +866,7 @@ void saveFocus () {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) {
swFlags = OS.SW_SHOWNOACTIVATE;
if (OS.IsWinCE) {
swFlags = OS.SW_RESTORE;
@@ -902,7 +897,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
return;
}
}
- super.setBounds (x, y, width, height, flags, defer);
+ super.setBoundsInPixels (x, y, width, height, flags, defer);
}
/**
@@ -1014,7 +1009,7 @@ void setImages (Image image, Image [] images) {
System.arraycopy (images, 0, bestImages, 0, images.length);
datas = new ImageData [images.length];
for (int i=0; i<datas.length; i++) {
- datas [i] = images [i].getImageData ();
+ datas [i] = images [i].getImageDataAtCurrentZoom ();
}
images = bestImages;
sort (images, datas, OS.GetSystemMetrics (OS.SM_CXSMICON), OS.GetSystemMetrics (OS.SM_CYSMICON), depth);
@@ -1290,7 +1285,7 @@ void setPlacement (int x, int y, int width, int height, int flags) {
if (OS.IsIconic (handle)) {
if (sameOrigin) {
moved = true;
- Point location = getLocation ();
+ Point location = getLocationInPixels ();
oldX = location.x;
oldY = location.y;
sendEvent (SWT.Move);
@@ -1298,7 +1293,7 @@ void setPlacement (int x, int y, int width, int height, int flags) {
}
if (sameExtent) {
resized = true;
- Rectangle rect = getClientArea ();
+ Rectangle rect = getClientAreaInPixels ();
oldWidth = rect.width;
oldHeight = rect.height;
sendEvent (SWT.Resize);
@@ -1437,13 +1432,13 @@ public void setVisible (boolean visible) {
opened = true;
if (!moved) {
moved = true;
- Point location = getLocation ();
+ Point location = getLocationInPixels ();
oldX = location.x;
oldY = location.y;
}
if (!resized) {
resized = true;
- Rectangle rect = getClientArea ();
+ Rectangle rect = getClientAreaInPixels ();
oldWidth = rect.width;
oldHeight = rect.height;
}
@@ -1771,7 +1766,7 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
@Override
LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
if (moved) {
- Point location = getLocation ();
+ Point location = getLocationInPixels ();
if (location.x == oldX && location.y == oldY) {
return null;
}
@@ -1839,7 +1834,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
newHeight = OS.HIWORD (lParam);
break;
case OS.SIZE_MINIMIZED:
- Rectangle rect = getClientArea ();
+ Rectangle rect = getClientAreaInPixels ();
newWidth = rect.width;
newHeight = rect.height;
break;
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 629009edde..b4d98a318a 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
@@ -858,7 +858,7 @@ static long /*int*/ create32bitDIB (Image image) {
hMask = info.hbmMask;
break;
case SWT.BITMAP:
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageDataAtCurrentZoom ();
hBitmap = image.handle;
alpha = data.alpha;
alphaData = data.alphaData;
@@ -1087,7 +1087,7 @@ static long /*int*/ create32bitDIB (long /*int*/ hBitmap, int alpha, byte [] alp
static Image createIcon (Image image) {
Device device = image.getDevice ();
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageDataAtCurrentZoom ();
if (data.alpha == -1 && data.alphaData == null) {
ImageData mask = data.getTransparencyMask ();
return new Image (device, data, mask);
@@ -1512,7 +1512,12 @@ public Menu getMenuBar () {
* </ul>
*/
@Override
-public Rectangle getBounds () {
+public Rectangle getBounds() {
+ checkDevice ();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
checkDevice ();
if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
@@ -1582,6 +1587,11 @@ int getClickCount (int type, int button, long /*int*/ hwnd, long /*int*/ lParam)
@Override
public Rectangle getClientArea () {
checkDevice ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+
+Rectangle getClientAreaInPixels () {
+ checkDevice ();
if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
RECT rect = new RECT ();
OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
@@ -1661,6 +1671,10 @@ public Control getCursorControl () {
*/
public Point getCursorLocation () {
checkDevice ();
+ return DPIUtil.autoScaleDown(getCursorLocationInPixels());
+}
+
+Point getCursorLocationInPixels () {
POINT pt = new POINT ();
OS.GetCursorPos (pt);
return new Point (pt.x, pt.y);
@@ -2187,14 +2201,14 @@ public Monitor getPrimaryMonitor () {
Monitor monitor = new Monitor();
int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
- monitor.width = width;
- monitor.height = height;
+ Rectangle bounds = new Rectangle (0, 0, width, height);
+ bounds = DPIUtil.autoScaleDown (bounds);
+ monitor.setBounds (bounds);
RECT rect = new RECT ();
OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
- monitor.clientX = rect.left;
- monitor.clientY = rect.top;
- monitor.clientWidth = rect.right - rect.left;
- monitor.clientHeight = rect.bottom - rect.top;
+ Rectangle clientArea = new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ clientArea = DPIUtil.autoScaleDown (clientArea);
+ monitor.setClientArea( clientArea);
return monitor;
}
monitors = new Monitor [4];
@@ -2210,6 +2224,11 @@ public Monitor getPrimaryMonitor () {
Monitor monitor = monitors [i];
OS.GetMonitorInfo (monitors [i].handle, lpmi);
if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) != 0) {
+ // Convert Monitor's bounds/client-area to Points.
+ Rectangle bounds = DPIUtil.autoScaleDown (monitor.getBounds ());
+ monitor.setBounds (bounds);
+ Rectangle clientArea = DPIUtil.autoScaleDown (monitor.getClientArea ());
+ monitor.setClientArea (clientArea);
result = monitor;
break;
}
@@ -2949,7 +2968,12 @@ boolean isValidThread () {
public Point map (Control from, Control to, Point point) {
checkDevice ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, point.x, point.y);
+ point = DPIUtil.autoScaleUp(point);
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, point));
+}
+
+Point mapInPixels (Control from, Control to, Point point) {
+ return mapInPixels (from, to, point.x, point.y);
}
/**
@@ -2990,6 +3014,12 @@ public Point map (Control from, Control to, Point point) {
*/
public Point map (Control from, Control to, int x, int y) {
checkDevice ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, x, y));
+}
+
+Point mapInPixels (Control from, Control to, int x, int y) {
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (from == to) return new Point (x, y);
@@ -3041,7 +3071,12 @@ public Point map (Control from, Control to, int x, int y) {
public Rectangle map (Control from, Control to, Rectangle rectangle) {
checkDevice ();
if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+ rectangle = DPIUtil.autoScaleUp(rectangle);
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, rectangle));
+}
+
+Rectangle mapInPixels (Control from, Control to, Rectangle rectangle) {
+ return mapInPixels (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
/**
@@ -3084,6 +3119,14 @@ public Rectangle map (Control from, Control to, Rectangle rectangle) {
*/
public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
checkDevice ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, x, y, width, height));
+}
+
+Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int height) {
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (from == to) return new Rectangle (x, y, width, height);
@@ -3450,14 +3493,10 @@ long /*int*/ monitorEnumProc (long /*int*/ hmonitor, long /*int*/ hdc, long /*in
OS.GetMonitorInfo (hmonitor, lpmi);
Monitor monitor = new Monitor ();
monitor.handle = hmonitor;
- monitor.x = lpmi.rcMonitor_left;
- monitor.y = lpmi.rcMonitor_top;
- monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left;
- monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top;
- monitor.clientX = lpmi.rcWork_left;
- monitor.clientY = lpmi.rcWork_top;
- monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left;
- monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top;
+ Rectangle boundsInPixels = new Rectangle (lpmi.rcMonitor_left, lpmi.rcMonitor_top, lpmi.rcMonitor_right - lpmi.rcMonitor_left,lpmi.rcMonitor_bottom - lpmi.rcMonitor_top);
+ monitor.setBounds (boundsInPixels);
+ Rectangle clientAreaInPixels = new Rectangle (lpmi.rcWork_left, lpmi.rcWork_top, lpmi.rcWork_right - lpmi.rcWork_left, lpmi.rcWork_bottom - lpmi.rcWork_top);
+ monitor.setClientArea (clientAreaInPixels);
monitors [monitorCount++] = monitor;
return 1;
}
@@ -3667,8 +3706,9 @@ public boolean post (Event event) {
width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
}
- inputs.dx = ((event.x - x) * 65535 + width - 2) / (width - 1);
- inputs.dy = ((event.y - y) * 65535 + height - 2) / (height - 1);
+ Point loc = event.getLocationInPixels();
+ inputs.dx = ((loc.x - x) * 65535 + width - 2) / (width - 1);
+ inputs.dy = ((loc.y - y) * 65535 + height - 2) / (height - 1);
} else {
if (type == SWT.MouseWheel) {
if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false;
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 ddfcb84def..789ff0f822 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
@@ -10,10 +10,11 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class support the layout of selectable
@@ -127,9 +128,7 @@ static int checkStyle (int style) {
return style | SWT.NO_BACKGROUND;
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
int height = 0, width = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
if (itemCount > 0) {
@@ -159,7 +158,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
height += spacing;
for (int i = 0; i < itemCount; i++) {
ExpandItem item = items [i];
- height += item.getHeaderHeight ();
+ height += item.getHeaderHeightInPixels ();
if (item.expanded) height += item.height;
height += spacing;
width = Math.max (width, item.getPreferredWidth (hTheme, hDC));
@@ -175,7 +174,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- Rectangle trim = computeTrim (0, 0, width, height);
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
return new Point (trim.width, trim.height);
}
@@ -395,6 +394,10 @@ public ExpandItem [] getItems () {
*/
public int getSpacing () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getSpacingInPixels ());
+}
+
+int getSpacingInPixels () {
return spacing;
}
@@ -438,13 +441,13 @@ void layoutItems (int index, boolean setScrollbar) {
for (int i = 0; i < index; i++) {
ExpandItem item = items [i];
if (item.expanded) y += item.height;
- y += item.getHeaderHeight () + spacing;
+ y += item.getHeaderHeightInPixels () + spacing;
}
for (int i = index; i < itemCount; i++) {
ExpandItem item = items [i];
- item.setBounds (spacing, y, 0, 0, true, false);
+ item.setBoundsInPixels (spacing, y, 0, 0, true, false);
if (item.expanded) y += item.height;
- y += item.getHeaderHeight () + spacing;
+ y += item.getHeaderHeightInPixels () + spacing;
}
}
if (setScrollbar) setScrollbar ();
@@ -567,6 +570,10 @@ void setScrollbar () {
*/
public void setSpacing (int spacing) {
checkWidget ();
+ setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+}
+
+void setSpacingInPixels (int spacing) {
if (spacing < 0) return;
if (spacing == this.spacing) return;
this.spacing = spacing;
@@ -575,7 +582,7 @@ public void setSpacing (int spacing) {
int width = Math.max (0, (rect.right - rect.left) - spacing * 2);
for (int i = 0; i < itemCount; i++) {
ExpandItem item = items[i];
- if (item.width != width) item.setBounds (0, 0, width, item.height, false, true);
+ if (item.width != width) item.setBoundsInPixels (0, 0, width, item.height, false, true);
}
layoutItems (0, true);
OS.InvalidateRect (handle, null, true);
@@ -791,10 +798,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (hooks (SWT.Paint) || filters (SWT.Paint)) {
Event event = new Event ();
event.gc = gc;
- event.x = rect.left;
- event.y = rect.top;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(rect.left, rect.top, width, height));
sendEvent (SWT.Paint, event);
event.gc = null;
}
@@ -851,7 +855,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
int width = Math.max (0, (rect.right - rect.left) - spacing * 2);
for (int i = 0; i < itemCount; i++) {
ExpandItem item = items[i];
- if (item.width != width) item.setBounds (0, 0, width, item.height, false, true);
+ if (item.width != width) item.setBoundsInPixels (0, 0, width, item.height, false, true);
}
setScrollbar ();
OS.InvalidateRect (handle, null, true);
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 a088e06dc0..c2778a88d0 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
@@ -10,9 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
/**
* Instances of this class represent a selectable user interface object
@@ -189,9 +190,9 @@ void drawItem (GC gc, long /*int*/ hTheme, RECT clipRect, boolean drawFocus) {
if (image != null) {
rect.left += ExpandItem.TEXT_INSET;
if (imageHeight > headerHeight) {
- gc.drawImage (image, rect.left, rect.top + headerHeight - imageHeight);
+ gc.drawImage (image, DPIUtil.autoScaleDown(rect.left), DPIUtil.autoScaleDown(rect.top + headerHeight - imageHeight));
} else {
- gc.drawImage (image, rect.left, rect.top + (headerHeight - imageHeight) / 2);
+ gc.drawImage (image, DPIUtil.autoScaleDown(rect.left), DPIUtil.autoScaleDown(rect.top + (headerHeight - imageHeight) / 2));
}
rect.left += imageWidth;
}
@@ -297,6 +298,10 @@ public boolean getExpanded () {
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeaderHeightInPixels());
+}
+
+int getHeaderHeightInPixels () {
return Math.max (parent.getBandHeight (), imageHeight);
}
@@ -312,6 +317,10 @@ public int getHeaderHeight () {
*/
public int getHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeightInPixels());
+}
+
+int getHeightInPixels () {
return height;
}
@@ -382,7 +391,7 @@ void releaseWidget () {
control = null;
}
-void setBounds (int x, int y, int width, int height, boolean move, boolean size) {
+void setBoundsInPixels (int x, int y, int width, int height, boolean move, boolean size) {
redraw (true);
int headerHeight = parent.getBandHeight ();
if (move) {
@@ -404,9 +413,9 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean size)
width = Math.max (0, width - BORDER * 2);
height = Math.max (0, height - BORDER);
}
- if (move && size) control.setBounds (x, y + headerHeight, width, height);
- if (move && !size) control.setLocation (x, y + headerHeight);
- if (!move && size) control.setSize (width, height);
+ if (move && size) control.setBoundsInPixels (x, y + headerHeight, width, height);
+ if (move && !size) control.setLocationInPixels (x, y + headerHeight);
+ if (!move && size) control.setSizeInPixels (width, height);
}
}
@@ -437,9 +446,9 @@ public void setControl (Control control) {
if (!parent.isAppThemed ()) {
int width = Math.max (0, this.width - BORDER * 2);
int height = Math.max (0, this.height - BORDER);
- control.setBounds (x + BORDER, y + headerHeight, width, height);
+ control.setBoundsInPixels (x + BORDER, y + headerHeight, width, height);
} else {
- control.setBounds (x, y + headerHeight, width, height);
+ control.setBoundsInPixels (x, y + headerHeight, width, height);
}
}
}
@@ -473,8 +482,12 @@ public void setExpanded (boolean expanded) {
*/
public void setHeight (int height) {
checkWidget ();
+ setHeightInPixels(DPIUtil.autoScaleUp(height));
+}
+
+void setHeightInPixels (int height) {
if (height < 0) return;
- setBounds (0, 0, width, height, false, true);
+ setBoundsInPixels (0, 0, width, height, false, true);
if (expanded) parent.layoutItems (parent.indexOf (this) + 1, true);
}
@@ -483,7 +496,7 @@ public void setImage (Image image) {
super.setImage (image);
int oldImageHeight = imageHeight;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageHeight = bounds.height;
imageWidth = bounds.width;
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index 8436df5f03..19fc56e3b8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.BidiUtil;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide an etched border
@@ -151,10 +151,9 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- Point size = super.computeSize (wHint, hHint, changed);
+ Point size = super.computeSizeInPixels (wHint, hHint, changed);
int length = text.length ();
if (length != 0) {
String string = fixText (false);
@@ -179,10 +178,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return size;
}
-@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
@@ -251,8 +249,7 @@ String fixText (boolean enabled) {
return null;
}
-@Override
-public Rectangle getClientArea () {
+@Override Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
@@ -345,10 +342,10 @@ void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
OS.SendMessage (hwnd, OS.WM_PRINT, hdc, flags);
int nSavedDC = OS.SaveDC (hdc);
Control [] children = _getChildren ();
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
OS.IntersectClipRect (hdc, 0, 0, rect.width, rect.height);
for (int i=children.length - 1; i>=0; --i) {
- Point location = children [i].getLocation ();
+ Point location = children [i].getLocationInPixels ();
int graphicsMode = OS.GetGraphicsMode(hdc);
if (graphicsMode == OS.GM_ADVANCED) {
float [] lpXform = {1, 0, 0, 1, location.x, location.y};
@@ -384,9 +381,9 @@ int resolveTextDirection () {
@Override
public void setFont (Font font) {
checkWidget ();
- Rectangle oldRect = getClientArea ();
+ Rectangle oldRect = getClientAreaInPixels ();
super.setFont (font);
- Rectangle newRect = getClientArea ();
+ Rectangle newRect = getClientAreaInPixels ();
if (!oldRect.equals (newRect)) sendResize ();
}
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 7819623586..764143ac59 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
@@ -11,9 +11,9 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent input method editors.
@@ -578,8 +578,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (TCHAR)null, 0) > 0) {
Event event = new Event ();
event.detail = SWT.COMPOSITION_OFFSET;
- event.x = OS.GET_X_LPARAM (lParam);
- event.y = OS.GET_Y_LPARAM (lParam);
+ event.setLocationInPixels(OS.GET_X_LPARAM (lParam), OS.GET_Y_LPARAM (lParam));
sendEvent (SWT.ImeComposition, event);
int offset = event.index;
int length = text.length();
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 7133858dcd..fa1826b167 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -13,7 +13,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -128,10 +128,9 @@ static int checkStyle (int style) {
return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- int width = 0, height = 0, border = getBorderWidth ();
+ int width = 0, height = 0, border = getBorderWidthInPixels ();
if ((style & SWT.SEPARATOR) != 0) {
int lineWidth = OS.GetSystemMetrics (OS.SM_CXBORDER);
if ((style & SWT.HORIZONTAL) != 0) {
@@ -149,7 +148,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
boolean drawImage = (bits & OS.SS_OWNERDRAW) == OS.SS_OWNERDRAW;
if (drawImage) {
if (image != null) {
- Rectangle rect = image.getBounds();
+ Rectangle rect = image.getBoundsInPixels();
width += rect.width;
height += rect.height;
if (IMAGE_AND_TEXT) {
@@ -611,7 +610,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
result = LRESULT.ONE;
}
if (drawImage) {
- Rectangle imageBounds = image.getBounds ();
+ Rectangle imageBounds = image.getBoundsInPixels ();
int x = 0;
if ((style & SWT.CENTER) != 0) {
x = Math.max (0, (clientRect.right - imageBounds.width) / 2);
@@ -620,7 +619,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
x = Math.max (0, (clientRect.right - imageBounds.width));
}
}
- gc.drawImage (image, x, Math.max (0, (clientRect.bottom - imageBounds.height) / 2));
+ gc.drawImage (image, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(Math.max (0, (clientRect.bottom - imageBounds.height) / 2)));
result = LRESULT.ONE;
}
int width = ps.right - ps.left;
@@ -628,10 +627,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (width != 0 && height != 0) {
Event event = new Event ();
event.gc = gc;
- event.x = ps.left;
- event.y = ps.top;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(ps.left, ps.top, width, height));
sendEvent (SWT.Paint, event);
// widget could be disposed at this point
event.gc = null;
@@ -672,7 +668,7 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
int margin = drawText && drawImage ? MARGIN : 0;
int imageWidth = 0, imageHeight = 0;
if (drawImage) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
imageWidth = rect.width;
imageHeight = rect.height;
}
@@ -707,7 +703,7 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
data.device = display;
GC gc = GC.win32_new (struct.hDC, data);
Image image = getEnabled () ? this.image : new Image (display, this.image, SWT.IMAGE_DISABLE);
- gc.drawImage (image, x, Math.max (0, (height - imageHeight) / 2));
+ gc.drawImage (image, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(Math.max (0, (height - imageHeight) / 2)));
if (image != this.image) image.dispose ();
gc.dispose ();
x += imageWidth + margin;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index e672bd8f2f..261e1c20ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -178,8 +178,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -211,13 +210,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
int layoutWidth = layout.getWidth ();
//TEMPORARY CODE
if (wHint == 0) {
- layout.setWidth (1);
- Rectangle rect = layout.getBounds ();
+ layout.setWidth (DPIUtil.autoScaleDown(1));
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
width = 0;
height = rect.height;
} else {
- layout.setWidth (wHint);
- Rectangle rect = layout.getBounds ();
+ layout.setWidth (DPIUtil.autoScaleDown(wHint));
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
width = rect.width;
height = rect.height;
}
@@ -225,7 +224,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2;
height += border * 2;
return new Point (width, height);
@@ -267,19 +266,16 @@ void drawWidget (GC gc, RECT rect) {
if (!OS.IsWindowEnabled (handle)) gc.setForeground (disabledColor);
layout.draw (gc, 0, 0, selStart, selEnd, null, null);
if (hasFocus () && focusIndex != -1) {
- Rectangle [] rects = getRectangles (focusIndex);
+ Rectangle [] rects = getRectanglesInPixels (focusIndex);
for (int i = 0; i < rects.length; i++) {
- Rectangle rectangle = rects [i];
+ Rectangle rectangle = DPIUtil.autoScaleDown(rects [i]);
gc.drawFocus (rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
}
if (hooks (SWT.Paint) || filters (SWT.Paint)) {
Event event = new Event ();
event.gc = gc;
- event.x = rect.left;
- event.y = rect.top;
- event.width = rect.right - rect.left;
- event.height = rect.bottom - rect.top;
+ event.setBoundsInPixels(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
sendEvent (SWT.Paint, event);
event.gc = null;
}
@@ -325,7 +321,7 @@ void initAccessible () {
@Override
public void getLocation (AccessibleControlEvent e) {
- Rectangle rect = display.map (getParent (), null, getBounds ());
+ Rectangle rect = display.mapInPixels (getParent (), null, getBoundsInPixels ());
e.x = rect.x;
e.y = rect.y;
e.width = rect.width;
@@ -396,7 +392,7 @@ String getNameText () {
return getText ();
}
-Rectangle [] getRectangles (int linkIndex) {
+Rectangle [] getRectanglesInPixels (int linkIndex) {
int lineCount = layout.getLineCount ();
Rectangle [] rects = new Rectangle [lineCount];
int [] lineOffsets = layout.getLineOffsets ();
@@ -407,13 +403,13 @@ Rectangle [] getRectangles (int linkIndex) {
while (point.y > lineOffsets [lineEnd]) lineEnd++;
int index = 0;
if (lineStart == lineEnd) {
- rects [index++] = layout.getBounds (point.x, point.y);
+ rects [index++] = DPIUtil.autoScaleUp(layout.getBounds (point.x, point.y));
} else {
- rects [index++] = layout.getBounds (point.x, lineOffsets [lineStart]-1);
- rects [index++] = layout.getBounds (lineOffsets [lineEnd-1], point.y);
+ rects [index++] = DPIUtil.autoScaleUp(layout.getBounds (point.x, lineOffsets [lineStart]-1));
+ rects [index++] = DPIUtil.autoScaleUp(layout.getBounds (lineOffsets [lineEnd-1], point.y));
if (lineEnd - lineStart > 1) {
for (int i = lineStart; i < lineEnd - 1; i++) {
- rects [index++] = layout.getLineBounds (i);
+ rects [index++] = DPIUtil.autoScaleUp(layout.getLineBounds (i));
}
}
}
@@ -988,7 +984,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (focusIndex != -1) setFocus ();
int x = OS.GET_X_LPARAM (lParam);
int y = OS.GET_Y_LPARAM (lParam);
- int offset = layout.getOffset (x, y, null);
+ int offset = layout.getOffset (DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y), null);
int oldSelectionX = selection.x;
int oldSelectionY = selection.y;
selection.x = offset;
@@ -999,11 +995,11 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
oldSelectionX = oldSelectionY;
oldSelectionY = temp;
}
- Rectangle rect = layout.getBounds (oldSelectionX, oldSelectionY);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds (oldSelectionX, oldSelectionY)); // To Pixels
+ redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
}
for (int j = 0; j < offsets.length; j++) {
- Rectangle [] rects = getRectangles (j);
+ Rectangle [] rects = getRectanglesInPixels (j);
for (int i = 0; i < rects.length; i++) {
Rectangle rect = rects [i];
if (rect.contains (x, y)) {
@@ -1027,7 +1023,7 @@ LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
if (mouseDownIndex == -1) return result;
int x = OS.GET_X_LPARAM (lParam);
int y = OS.GET_Y_LPARAM (lParam);
- Rectangle [] rects = getRectangles (mouseDownIndex);
+ Rectangle [] rects = getRectanglesInPixels (mouseDownIndex);
for (int i = 0; i < rects.length; i++) {
Rectangle rect = rects [i];
if (rect.contains (x, y)) {
@@ -1063,7 +1059,7 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
int y = OS.GET_Y_LPARAM (lParam);
if (OS.GetKeyState (OS.VK_LBUTTON) < 0) {
int oldSelection = selection.y;
- selection.y = layout.getOffset (x, y, null);
+ selection.y = layout.getOffset (DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y), null);
if (selection.y != oldSelection) {
int newSelection = selection.y;
if (oldSelection > newSelection) {
@@ -1071,12 +1067,12 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
oldSelection = newSelection;
newSelection = temp;
}
- Rectangle rect = layout.getBounds (oldSelection, newSelection);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds (oldSelection, newSelection));// To Pixels
+ redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
}
} else {
for (int j = 0; j < offsets.length; j++) {
- Rectangle [] rects = getRectangles (j);
+ Rectangle [] rects = getRectanglesInPixels (j);
for (int i = 0; i < rects.length; i++) {
Rectangle rect = rects [i];
if (rect.contains (x, y)) {
@@ -1151,7 +1147,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- layout.setWidth (rect.right > 0 ? rect.right : -1);
+ layout.setWidth (DPIUtil.autoScaleDown(rect.right > 0 ? rect.right : -1));
if (!useCommonControl()) {
redraw ();
}
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 ce40298299..19856dd38c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -14,7 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -215,8 +215,7 @@ static int checkStyle (int style) {
return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
if (wHint == SWT.DEFAULT) {
@@ -259,7 +258,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2 + INSET;
height += border * 2;
if ((style & SWT.V_SCROLL) != 0) {
@@ -477,6 +476,10 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getItemHeightInPixels());
+}
+
+int getItemHeightInPixels () {
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
return result;
@@ -1525,7 +1528,7 @@ public void showSelection () {
@Override
void updateMenuLocation (Event event) {
- Rectangle clientArea = getClientArea ();
+ Rectangle clientArea = getClientAreaInPixels ();
int x = clientArea.x, y = clientArea.y;
int focusIndex = getFocusIndex();
if (focusIndex != -1) {
@@ -1556,9 +1559,8 @@ void updateMenuLocation (Event event) {
y = Math.max (y, rect.bottom);
y = Math.min (y, clientArea.y + clientArea.height);
}
- Point pt = toDisplay (x, y);
- event.x = pt.x;
- event.y = pt.y;
+ Point pt = toDisplayInPixels (x, y);
+ event.setLocationInPixels(pt.x, pt.y);
}
@Override
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 5aefe29bad..a08c092caf 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
@@ -1063,7 +1063,7 @@ void hideCurrentToolTip () {
int imageIndex (Image image) {
if (hwndCB == 0 || image == null) return OS.I_IMAGENONE;
if (imageList == null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = imageList.add (image);
long /*int*/ hImageList = imageList.getHandle ();
@@ -1446,6 +1446,10 @@ public void setEnabled (boolean enabled) {
*/
public void setLocation (int x, int y) {
checkWidget ();
+ setLocationInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void setLocationInPixels (int x, int y) {
if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
this.x = x;
this.y = y;
@@ -1479,7 +1483,8 @@ public void setLocation (int x, int y) {
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ location = DPIUtil.autoScaleUp(location);
+ setLocationInPixels(location.x, location.y);
}
/**
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 a85c6e7ec0..fc7eb8f7ab 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
@@ -14,6 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -1226,7 +1227,7 @@ public void setToolTipText (String toolTip) {
void showTooltip (int x, int y) {
if (itemToolTip == null) return;
- itemToolTip.setLocation (x, y);
+ itemToolTip.setLocationInPixels (x, y);
itemToolTip.setVisible (true);
}
@@ -1278,7 +1279,7 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
*/
int x = (parent.style & SWT.BAR) != 0 ? MARGIN_WIDTH * 2 : struct.left;
Image image = getEnabled () ? this.image : new Image (display, this.image, SWT.IMAGE_DISABLE);
- gc.drawImage (image, x, struct.top + MARGIN_HEIGHT);
+ gc.drawImage (image, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(struct.top + MARGIN_HEIGHT));
if (this.image != image) image.dispose ();
gc.dispose ();
}
@@ -1291,7 +1292,7 @@ LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
int width = 0, height = 0;
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
width = rect.width;
height = rect.height;
} else {
@@ -1315,7 +1316,7 @@ LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
for (int i=0; i<items.length; i++) {
MenuItem item = items [i];
if (item.image != null) {
- Rectangle rect = item.image.getBounds ();
+ Rectangle rect = item.image.getBoundsInPixels ();
width = Math.max (width, rect.width);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
index 0245cba131..e3f76f49a0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
@@ -122,10 +122,9 @@ static int checkStyle (int style) {
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
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 efae7ca241..659b2e0e01 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of the receiver represent a selectable user interface object
@@ -126,10 +126,9 @@ static int checkStyle (int style) {
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
width += DEFAULT_WIDTH; height += 3;
@@ -245,15 +244,12 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
OS.SetCursorPos (cursorPt.x, cursorPt.y);
Event event = new Event ();
- event.x = newX;
- event.y = newY;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(newX, newY, width, height));
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return LRESULT.ZERO;
if (event.doit) {
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (event.getBoundsInPixels());
}
}
return result;
@@ -288,10 +284,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
/* The event must be sent because doit flag is used */
Event event = new Event ();
- event.x = lastX;
- event.y = lastY;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(lastX, lastY, width, height));
if ((style & SWT.SMOOTH) == 0) {
event.detail = SWT.DRAG;
}
@@ -299,10 +292,11 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (isDisposed ()) return LRESULT.ZERO;
/* Draw the banding rectangle */
+ Rectangle bounds = event.getBoundsInPixels();
if (event.doit) {
dragging = true;
- lastX = event.x;
- lastY = event.y;
+ lastX = bounds.x;
+ lastY = bounds.y;
menuShell ().bringToTop ();
if (isDisposed ()) return LRESULT.ZERO;
if (OS.IsWinCE) {
@@ -311,9 +305,9 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
OS.RedrawWindow (hwndTrack, null, 0, flags);
}
- drawBand (event.x, event.y, width, height);
+ drawBand (bounds.x, bounds.y, width, height);
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (bounds.x, bounds.y, width, height);
// widget could be disposed at this point
}
}
@@ -335,16 +329,14 @@ LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
/* The event must be sent because doit flag is used */
Event event = new Event ();
- event.x = lastX;
- event.y = lastY;
- event.width = width;
- event.height = height;
- drawBand (event.x, event.y, width, height);
+ event.setBoundsInPixels(new Rectangle(lastX, lastY, width, height));
+ drawBand (lastX, lastY, width, height);
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return result;
+ Rectangle bounds = event.getBoundsInPixels();
if (event.doit) {
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (bounds.x, bounds.y, width, height);
// widget could be disposed at this point
}
}
@@ -380,18 +372,16 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
/* The event must be sent because doit flag is used */
Event event = new Event ();
- event.x = newX;
- event.y = newY;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(newX, newY, width, height));
if ((style & SWT.SMOOTH) == 0) {
event.detail = SWT.DRAG;
}
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return LRESULT.ZERO;
if (event.doit) {
- lastX = event.x;
- lastY = event.y;
+ Rectangle boundsInPixels = event.getBoundsInPixels();
+ lastX = boundsInPixels.x;
+ lastY = boundsInPixels.y;
}
if (OS.IsWinCE) {
OS.UpdateWindow (hwndTrack);
@@ -401,7 +391,7 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
drawBand (lastX, lastY, width, height);
if ((style & SWT.SMOOTH) != 0) {
- setBounds (lastX, lastY, width, height);
+ setBoundsInPixels (lastX, lastY, width, height);
// widget could be disposed at this point
}
return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
index 3c423e42ae..e2e716a2d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of the receiver represent a selectable user
@@ -151,10 +151,9 @@ static int checkStyle (int style) {
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
RECT rect = new RECT ();
OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, rect);
@@ -320,7 +319,7 @@ void setBackgroundPixel (int pixel) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) {
/*
* Bug in Windows. If SetWindowPos() is called on a
* track bar with either SWP_DRAWFRAME, a new size,
@@ -344,7 +343,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
* mouse down.
*/
flags &= ~OS.SWP_DRAWFRAME;
- super.setBounds (x, y, width, height, flags, true);
+ super.setBoundsInPixels (x, y, width, height, flags, true);
}
/**
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 ab68be0aef..df731bd999 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
@@ -11,10 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are selectable user interface
@@ -366,6 +367,10 @@ public int getSelection () {
*/
public Point getSize () {
checkWidget();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels () {
parent.forceResize ();
RECT rect = new RECT ();
OS.GetClientRect (parent.scrolledHandle (), rect);
@@ -419,6 +424,10 @@ public int getThumb () {
*/
public Rectangle getThumbBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getThumbBoundsInPixels());
+}
+
+Rectangle getThumbBoundsInPixels () {
parent.forceResize ();
SCROLLBARINFO info = new SCROLLBARINFO();
info.cbSize = SCROLLBARINFO.sizeof;
@@ -461,6 +470,10 @@ public Rectangle getThumbBounds () {
*/
public Rectangle getThumbTrackBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getThumbTrackBoundsInPixels());
+}
+
+Rectangle getThumbTrackBoundsInPixels () {
parent.forceResize ();
SCROLLBARINFO info = new SCROLLBARINFO();
info.cbSize = SCROLLBARINFO.sizeof;
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 a71d67677e..239711b876 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* This class is the abstract superclass of all classes which
@@ -116,6 +117,14 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
*/
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ return DPIUtil.autoScaleDown(computeTrimInPixels(x, y, width, height));
+}
+
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
long /*int*/ scrolledHandle = scrolledHandle ();
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
@@ -194,6 +203,10 @@ void destroyScrollBar (int type) {
*/
public Rectangle getClientArea () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+
+Rectangle getClientAreaInPixels () {
forceResize ();
RECT rect = new RECT ();
long /*int*/ scrolledHandle = scrolledHandle ();
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 fe671331f0..3ae942117a 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
@@ -14,6 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -504,8 +505,8 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
void center () {
if (parent == null) return;
- Rectangle rect = getBounds ();
- Rectangle parentRect = display.map (parent, null, parent.getClientArea());
+ Rectangle rect = getBoundsInPixels ();
+ Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels());
int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
Rectangle monitorRect = parent.getMonitor ().getClientArea();
@@ -519,7 +520,7 @@ void center () {
} else {
y = Math.max (y, monitorRect.y);
}
- setLocation (x, y);
+ setLocationInPixels (x, y);
}
/**
@@ -930,11 +931,9 @@ public int getAlpha () {
return 0xFF;
}
-@Override
-public Rectangle getBounds () {
- checkWidget ();
+@Override Rectangle getBoundsInPixels () {
if (!OS.IsWinCE) {
- if (OS.IsIconic (handle)) return super.getBounds ();
+ if (OS.IsIconic (handle)) return super.getBoundsInPixels ();
}
RECT rect = new RECT ();
OS.GetWindowRect (handle, rect);
@@ -1030,12 +1029,10 @@ public int getImeInputMode () {
return result | SWT.ALPHA;
}
-@Override
-public Point getLocation () {
- checkWidget ();
+@Override Point getLocationInPixels () {
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
- return super.getLocation ();
+ return super.getLocationInPixels ();
}
}
RECT rect = new RECT ();
@@ -1066,6 +1063,10 @@ public boolean getMaximized () {
*/
public Point getMinimumSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getMinimumSizeInPixels());
+}
+
+Point getMinimumSizeInPixels () {
int width = Math.max (0, minWidth);
int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
@@ -1130,11 +1131,9 @@ public Shell getShell () {
return this;
}
-@Override
-public Point getSize () {
- checkWidget ();
+@Override Point getSizeInPixels () {
if (!OS.IsWinCE) {
- if (OS.IsIconic (handle)) return super.getSize ();
+ if (OS.IsIconic (handle)) return super.getSizeInPixels ();
}
RECT rect = new RECT ();
OS.GetWindowRect (handle, rect);
@@ -1576,7 +1575,7 @@ public void setAlpha (int alpha) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) {
if (fullScreen) setFullScreen (false);
/*
* Bug in Windows. When a window has alpha and
@@ -1590,7 +1589,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
if ((bits & OS.WS_EX_LAYERED) != 0) {
flags &= ~OS.SWP_DRAWFRAME;
}
- super.setBounds (x, y, width, height, flags, false);
+ super.setBoundsInPixels (x, y, width, height, flags, false);
}
@Override
@@ -1732,6 +1731,10 @@ public void setImeInputMode (int mode) {
*/
public void setMinimumSize (int width, int height) {
checkWidget ();
+ setMinimumSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+void setMinimumSizeInPixels (int width, int height) {
int widthLimit = 0, heightLimit = 0;
int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
@@ -1748,12 +1751,12 @@ public void setMinimumSize (int width, int height) {
}
minWidth = Math.max (widthLimit, width);
minHeight = Math.max (heightLimit, height);
- Point size = getSize ();
+ Point size = getSizeInPixels ();
int newWidth = Math.max (size.x, minWidth);
int newHeight = Math.max (size.y, minHeight);
if (minWidth <= widthLimit) minWidth = SWT.DEFAULT;
if (minHeight <= heightLimit) minHeight = SWT.DEFAULT;
- if (newWidth != size.x || newHeight != size.y) setSize (newWidth, newHeight);
+ if (newWidth != size.x || newHeight != size.y) setSizeInPixels (newWidth, newHeight);
}
/**
@@ -1776,7 +1779,8 @@ public void setMinimumSize (int width, int height) {
public void setMinimumSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setMinimumSize (size.x, size.y);
+ size = DPIUtil.autoScaleUp(size);
+ setMinimumSizeInPixels(size.x, size.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
index ed5a219711..324fd8826b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
@@ -175,10 +175,9 @@ static int checkStyle (int style) {
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
@@ -378,8 +377,8 @@ public void removeSelectionListener (SelectionListener listener) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags) {
- super.setBounds (x, y, width, height, flags);
+void setBoundsInPixels (int x, int y, int width, int height, int flags) {
+ super.setBoundsInPixels (x, y, width, height, flags);
/*
* Bug in Windows. If the scroll bar is resized when it has focus,
* the flashing cursor that is used to show that the scroll bar has
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
index 9a57b4466b..963fb7e51e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
@@ -289,8 +289,7 @@ long /*int*/ borderHandle () {
return hwndText;
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -327,9 +326,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- Rectangle trim = computeTrim (0, 0, width, height);
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
if (hHint == SWT.DEFAULT) {
- int upDownHeight = OS.GetSystemMetrics (OS.SM_CYVSCROLL) + 2 * getBorderWidth ();
+ int upDownHeight = OS.GetSystemMetrics (OS.SM_CYVSCROLL) + 2 * getBorderWidthInPixels ();
if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
upDownHeight += (style & SWT.BORDER) != 0 ? 1 : 3;
}
@@ -338,8 +337,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point (trim.width, trim.height);
}
-@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
/* Get the trim of the text control */
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 901aaf7b64..28e9358833 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class implement the notebook user interface
@@ -193,10 +193,9 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- Point size = super.computeSize (wHint, hHint, changed);
+ Point size = super.computeSizeInPixels (wHint, hHint, changed);
RECT insetRect = new RECT (), itemRect = new RECT ();
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect);
int width = insetRect.left - insetRect.right;
@@ -208,20 +207,19 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
RECT rect = new RECT ();
OS.SetRect (rect, 0, 0, width, size.y);
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect);
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
rect.left -= border; rect.right += border;
width = rect.right - rect.left;
size.x = Math.max (width, size.x);
return size;
}
-@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect);
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
rect.left -= border; rect.right += border;
rect.top -= border; rect.bottom += border;
int newWidth = rect.right - rect.left;
@@ -329,8 +327,7 @@ Control findThemeControl () {
return this;
}
-@Override
-public Rectangle getClientArea () {
+@Override Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
@@ -473,7 +470,7 @@ public int getSelectionIndex () {
int imageIndex (Image image) {
if (image == null) return OS.I_IMAGENONE;
if (imageList == null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = imageList.add (image);
long /*int*/ hImageList = imageList.getHandle ();
@@ -529,11 +526,11 @@ Point minimumSize (int wHint, int hHint, boolean flushCache) {
index++;
}
if (index == count) {
- Rectangle rect = child.getBounds ();
+ Rectangle rect = child.getBoundsInPixels ();
width = Math.max (width, rect.x + rect.width);
height = Math.max (height, rect.y + rect.height);
} else {
- Point size = child.computeSize (wHint, hHint, flushCache);
+ Point size = child.computeSizeInPixels (wHint, hHint, flushCache);
width = Math.max (width, size.x);
height = Math.max (height, size.y);
}
@@ -699,9 +696,9 @@ public void setSelection (TabItem [] items) {
@Override
public void setFont (Font font) {
checkWidget ();
- Rectangle oldRect = getClientArea ();
+ Rectangle oldRect = getClientAreaInPixels ();
super.setFont (font);
- Rectangle newRect = getClientArea ();
+ Rectangle newRect = getClientAreaInPixels ();
if (!oldRect.equals (newRect)) {
sendResize ();
int index = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
@@ -709,7 +706,7 @@ public void setFont (Font font) {
TabItem item = items [index];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
}
}
}
@@ -751,7 +748,7 @@ void setSelection (int index, boolean notify) {
TabItem item = items [newIndex];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
control.setVisible (true);
}
if (notify) {
@@ -1066,7 +1063,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
TabItem item = items [index];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
}
}
return result;
@@ -1135,7 +1132,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
Control control = item.control;
if (control != null && !control.isDisposed ()) {
if (code == OS.TCN_SELCHANGE) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
}
control.setVisible (code == OS.TCN_SELCHANGE);
}
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 744e05c87d..f1f98344df 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
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a selectable user interface object
@@ -185,8 +186,12 @@ public Control getControl () {
*
* @since 3.4
*/
-public Rectangle getBounds() {
+public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels() {
int index = parent.indexOf(this);
if (index == -1) return new Rectangle (0, 0, 0, 0);
RECT itemRect = new RECT ();
@@ -284,7 +289,7 @@ public void setControl (Control control) {
}
}
if (newControl != null) {
- newControl.setBounds (parent.getClientArea ());
+ newControl.setBounds (parent.getClientAreaInPixels ());
newControl.setVisible (true);
}
if (oldControl != null && newControl != null && oldControl != newControl)
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 fabcfc8c2b..1301d64fd9 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
@@ -1463,9 +1463,7 @@ public void clearAll () {
}
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
if (fixScrollWidth) setScrollWidth (null, true);
//This code is intentionally commented
// if (itemHeight == -1 && hooks (SWT.MeasureItem)) {
@@ -1514,7 +1512,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2; height += border * 2;
if ((style & SWT.V_SCROLL) != 0) {
width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
@@ -2461,6 +2459,10 @@ int getFocusIndex () {
*/
public int getGridLineWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getGridLineWidthInPixels());
+}
+
+int getGridLineWidthInPixels () {
return GRID_WIDTH;
}
@@ -2478,6 +2480,10 @@ public int getGridLineWidth () {
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
if (hwndHeader == 0) return 0;
RECT rect = new RECT ();
@@ -2556,6 +2562,10 @@ public TableItem getItem (int index) {
public TableItem getItem (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return getItemInPixels (DPIUtil.autoScaleUp(point));
+}
+
+TableItem getItemInPixels (Point point) {
int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0) return null;
LVHITTESTINFO pinfo = new LVHITTESTINFO ();
@@ -2653,6 +2663,10 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getItemHeightInPixels());
+}
+
+int getItemHeightInPixels () {
if (!painted && hooks (SWT.MeasureItem)) hitTestSelection (0, 0, 0);
long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
@@ -2908,7 +2922,7 @@ boolean hitTestSelection (int index, int x, int y) {
long /*int*/ hFont = item.fontHandle (0);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
Event event = sendMeasureItemEvent (item, index, 0, hDC);
- if (event.getBounds ().contains (x, y)) result = true;
+ if (event.getBoundsInPixels ().contains (x, y)) result = true;
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
@@ -2925,7 +2939,7 @@ int imageIndex (Image image, int column) {
setSubImagesVisible (true);
}
if (imageList == null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = imageList.indexOf (image);
if (index == -1) index = imageList.add (image);
@@ -2966,7 +2980,7 @@ int imageIndex (Image image, int column) {
int imageIndexHeader (Image image) {
if (image == null) return OS.I_IMAGENONE;
if (headerImageList == null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = headerImageList.indexOf (image);
if (index == -1) index = headerImageList.add (image);
@@ -3636,11 +3650,9 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
if (drawHot) event.detail |= SWT.HOT;
if (drawSelected) event.detail |= SWT.SELECTED;
if (drawBackground) event.detail |= SWT.BACKGROUND;
- event.x = cellRect.left;
- event.y = cellRect.top;
- event.width = cellRect.right - cellRect.left;
- event.height = cellRect.bottom - cellRect.top;
- gc.setClipping (event.x, event.y, event.width, event.height);
+ Rectangle boundsInPixels = new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top);
+ event.setBoundsInPixels (boundsInPixels);
+ gc.setClipping (DPIUtil.autoScaleDown(boundsInPixels));
sendEvent (SWT.EraseItem, event);
event.gc = null;
int clrSelectionText = data.foreground;
@@ -3685,7 +3697,8 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
RECT textRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, false, fullText, false, hDC);
if ((style & SWT.FULL_SELECTION) == 0) {
if (measureEvent != null) {
- textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width);
+ Rectangle boundInPixels = measureEvent.getBoundsInPixels();
+ textRect.right = Math.min (cellRect.right, boundInPixels.x + boundInPixels.width);
}
if (!ignoreDrawFocus) {
nmcd.uItemState &= ~OS.CDIS_FOCUS;
@@ -3755,10 +3768,7 @@ Event sendEraseItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT
event.index = column;
event.gc = gc;
event.detail |= SWT.FOREGROUND;
- event.x = cellRect.left;
- event.y = cellRect.top;
- event.width = cellRect.right - cellRect.left;
- event.height = cellRect.bottom - cellRect.top;
+ event.setBoundsInPixels(new Rectangle(cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top));
//gc.setClipping (event.x, event.y, event.width, event.height);
sendEvent (SWT.EraseItem, event);
event.gc = null;
@@ -3779,10 +3789,7 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hD
event.item = item;
event.gc = gc;
event.index = column;
- event.x = itemRect.left;
- event.y = itemRect.top;
- event.width = itemRect.right - itemRect.left;
- event.height = itemRect.bottom - itemRect.top;
+ event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
boolean drawSelected = false;
if (OS.IsWindowEnabled (handle)) {
LVITEM lvItem = new LVITEM ();
@@ -3805,9 +3812,10 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hD
gc.dispose ();
OS.RestoreDC (hDC, nSavedDC);
if (!isDisposed () && !item.isDisposed ()) {
+ Rectangle boundsInPixels = event.getBoundsInPixels();
if (columnCount == 0) {
int width = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
- if (event.x + event.width > width) setScrollWidth (event.x + event.width);
+ if (boundsInPixels.x + boundsInPixels.width > width) setScrollWidth (boundsInPixels.x + boundsInPixels.width);
}
long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
@@ -3817,9 +3825,9 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hD
* SWT.MeasureItem event processing with a non-zero table-row
* selection. Refer bug 400174 and 458786
*/
- if (!settingItemHeight && event.height > itemHeight) {
+ if (!settingItemHeight && boundsInPixels.height > itemHeight) {
settingItemHeight = true;
- setItemHeight (event.height);
+ setItemHeight (boundsInPixels.height);
settingItemHeight = false;
}
}
@@ -4089,14 +4097,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.x = itemRect.left;
- event.y = itemRect.top;
- event.width = itemRect.right - itemRect.left;
- event.height = itemRect.bottom - itemRect.top;
+ event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
RECT cellRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC);
int cellWidth = cellRect.right - cellRect.left;
int cellHeight = cellRect.bottom - cellRect.top;
- gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
+ gc.setClipping (DPIUtil.autoScaleDown(new Rectangle (cellRect.left, cellRect.top, cellWidth, cellHeight)));
sendEvent (SWT.PaintItem, event);
if (data.focusDrawn) focusRect = null;
event.gc = null;
@@ -4120,10 +4125,7 @@ Event sendPaintItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT
event.index = column;
event.gc = gc;
event.detail |= SWT.FOREGROUND;
- event.x = itemRect.left;
- event.y = itemRect.top;
- event.width = itemRect.right - itemRect.left;
- event.height = itemRect.bottom - itemRect.top;
+ event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
//gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
sendEvent (SWT.PaintItem, event);
event.gc = null;
@@ -4250,7 +4252,7 @@ void setBackgroundTransparent (boolean transparent) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) {
/*
* Bug in Windows. If the table column widths are adjusted
* in WM_SIZE or WM_POSITIONCHANGED using LVM_SETCOLUMNWIDTH
@@ -4267,7 +4269,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
* time.
*/
setDeferResize (true);
- super.setBounds (x, y, width, height, flags, false);
+ super.setBoundsInPixels (x, y, width, height, flags, false);
setDeferResize (false);
}
@@ -5701,23 +5703,22 @@ void updateImages () {
@Override
void updateMenuLocation (Event event) {
- Rectangle clientArea = getClientArea ();
+ Rectangle clientArea = getClientAreaInPixels ();
int x = clientArea.x, y = clientArea.y;
int focusIndex = getFocusIndex ();
if (focusIndex != -1) {
TableItem focusItem = getItem (focusIndex);
- Rectangle bounds = focusItem.getBounds (0);
+ Rectangle bounds = focusItem.getBoundsInPixels (0);
if (focusItem.text != null && focusItem.text.length () != 0) {
- bounds = focusItem.getBounds ();
+ bounds = focusItem.getBoundsInPixels ();
}
x = Math.max (x, bounds.x + bounds.width / 2);
x = Math.min (x, clientArea.x + clientArea.width);
y = Math.max (y, bounds.y + bounds.height);
y = Math.min (y, clientArea.y + clientArea.height);
}
- Point pt = toDisplay (x, y);
- event.x = pt.x;
- event.y = pt.y;
+ Point pt = toDisplayInPixels (x, y);
+ event.setLocationInPixels(pt.x, pt.y);
}
void updateMoveable () {
@@ -6350,10 +6351,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (hooksPaint) {
Event event = new Event ();
event.gc = gc;
- event.x = ps.left;
- event.y = ps.top;
- event.width = ps.right - ps.left;
- event.height = ps.bottom - ps.top;
+ event.setBoundsInPixels(new Rectangle(ps.left, ps.top, ps.right - ps.left, ps.bottom - ps.top));
sendEvent (SWT.Paint, event);
// widget could be disposed at this point
event.gc = null;
@@ -7387,7 +7385,8 @@ LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
Event event = sendMeasureItemEvent (item, pinfo.iItem, pinfo.iSubItem, hDC);
if (!isDisposed () && !item.isDisposed ()) {
RECT itemRect = new RECT ();
- OS.SetRect (itemRect, event.x, event.y, event.x + event.width, event.y + event.height);
+ Rectangle boundsInPixels = event.getBoundsInPixels();
+ OS.SetRect (itemRect, boundsInPixels.x, boundsInPixels.y, boundsInPixels.x + boundsInPixels.width, boundsInPixels.y + boundsInPixels.height);
if (hdr.code == OS.TTN_SHOW) {
RECT toolRect = toolTipRect (itemRect);
OS.MapWindowPoints (handle, 0, toolRect, 2);
@@ -7511,14 +7510,15 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
if (pinfo.iSubItem != 0) x -= gridWidth;
Image image = item.getImage (pinfo.iSubItem);
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
RECT imageRect = item.getBounds (pinfo.iItem, pinfo.iSubItem, false, true, false, false, hDC);
Point size = imageList == null ? new Point (rect.width, rect.height) : imageList.getImageSize ();
int y = imageRect.top;
if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
y = y + Math.max (0, (imageRect.bottom - imageRect.top - size.y) / 2);
}
- gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, x, y, size.x, size.y);
+ rect = DPIUtil.autoScaleDown(rect);
+ gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y), DPIUtil.autoScaleDown(size.x), DPIUtil.autoScaleDown(size.y));
x += size.x + INSET + (pinfo.iSubItem == 0 ? -2 : 4);
} else {
x += INSET + 2;
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 1c079bdfa4..ebb755ae40 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
@@ -11,10 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a column in a table widget.
@@ -309,6 +310,10 @@ public String getToolTipText () {
*/
public int getWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
int index = parent.indexOf (this);
if (index == -1) return 0;
long /*int*/ hwnd = parent.handle;
@@ -349,7 +354,7 @@ public void pack () {
headerImage = image;
}
if (headerImage != null) {
- Rectangle bounds = headerImage.getBounds ();
+ Rectangle bounds = headerImage.getBoundsInPixels ();
headerWidth += bounds.width;
}
int margin = 0;
@@ -380,7 +385,8 @@ public void pack () {
Event event = parent.sendMeasureItemEvent (item, i, index, hDC);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
if (isDisposed () || parent.isDisposed ()) break;
- columnWidth = Math.max (columnWidth, event.x + event.width - headerRect.left);
+ Rectangle bounds = event.getBoundsInPixels();
+ columnWidth = Math.max (columnWidth, bounds.x + bounds.width - headerRect.left);
}
}
if (newFont != 0) OS.SelectObject (hDC, oldFont);
@@ -869,6 +875,10 @@ public void setToolTipText (String string) {
*/
public void setWidth (int width) {
checkWidget ();
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
if (width < 0) return;
int index = parent.indexOf (this);
if (index == -1) return;
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 8e11b2f05e..83a2c14c81 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
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a selectable user interface object
@@ -210,6 +211,10 @@ public Color getBackground (int index) {
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
@@ -232,6 +237,10 @@ public Rectangle getBounds () {
*/
public Rectangle getBounds (int index) {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels(index));
+}
+
+Rectangle getBoundsInPixels (int index) {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
@@ -574,6 +583,10 @@ public Image getImage (int index) {
*/
public Rectangle getImageBounds (int index) {
checkWidget();
+ return DPIUtil.autoScaleDown(getImageBoundsInPixels(index));
+}
+
+Rectangle getImageBoundsInPixels (int index) {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
@@ -671,6 +684,10 @@ public String getText (int index) {
*/
public Rectangle getTextBounds (int index) {
checkWidget();
+ return DPIUtil.autoScaleDown(getTextBoundsInPixels(index));
+}
+
+Rectangle getTextBoundsInPixels (int index) {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
index e314e24b15..754336413b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
@@ -195,9 +195,9 @@ long /*int*/ createShellLink (MenuItem item, String directory) {
ImageData data;
if (item.hBitmap != 0) {
Image image2 = Image.win32_new (display, SWT.BITMAP, item.hBitmap);
- data = image2.getImageData ();
+ data = image2.getImageDataAtCurrentZoom ();
} else {
- data = image.getImageData ();
+ data = image.getImageDataAtCurrentZoom ();
}
ImageLoader loader = new ImageLoader ();
loader.data = new ImageData [] {data};
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 35d889e8be..9f9eb48e68 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -14,7 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -664,8 +664,7 @@ public void clearSelection () {
}
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int height = 0, width = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
@@ -709,14 +708,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- Rectangle trim = computeTrim (0, 0, width, height);
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
return new Point (trim.width, trim.height);
}
-@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
- Rectangle rect = super.computeTrim (x, y, width, height);
+ Rectangle rect = super.computeTrimInPixels (x, y, width, height);
/*
* The preferred height of a single-line text widget
* has been hand-crafted to be the same height as
@@ -895,8 +893,7 @@ void fixAlignment () {
OS.SetWindowLong (handle, OS.GWL_STYLE, bits2);
}
-@Override
-public int getBorderWidth () {
+@Override int getBorderWidthInPixels () {
checkWidget ();
/*
* Feature in Windows 2000 and XP. Despite the fact that WS_BORDER
@@ -907,7 +904,7 @@ public int getBorderWidth () {
// if ((style & SWT.BORDER) != 0 && (style & SWT.FLAT) != 0) {
// return OS.GetSystemMetrics (OS.SM_CXBORDER);
// }
- return super.getBorderWidth ();
+ return super.getBorderWidthInPixels ();
}
/**
@@ -941,6 +938,10 @@ public int getCaretLineNumber () {
*/
public Point getCaretLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getCaretLocationInPixels());
+}
+
+Point getCaretLocationInPixels () {
/*
* Bug in Windows. For some reason, Windows is unable
* to return the pixel coordinates of the last character
@@ -1169,6 +1170,10 @@ public String getLineDelimiter () {
*/
public int getLineHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getLineHeightInPixels ());
+}
+
+int getLineHeightInPixels () {
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
@@ -1515,6 +1520,10 @@ public int getTopIndex () {
*/
public int getTopPixel () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getTopPixelInPixels());
+}
+
+int getTopPixelInPixels () {
/*
* Note, EM_GETSCROLLPOS is implemented in Rich Edit 3.0
* and greater. The plain text widget and previous versions
@@ -1523,7 +1532,7 @@ public int getTopPixel () {
int [] buffer = new int [2];
long /*int*/ code = OS.SendMessage (handle, OS.EM_GETSCROLLPOS, 0, buffer);
if (code == 1) return buffer [1];
- return getTopIndex () * getLineHeight ();
+ return getTopIndex () * getLineHeightInPixels ();
}
/**
@@ -1891,7 +1900,7 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
}
@Override
-void setBounds (int x, int y, int width, int height, int flags) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags) {
/*
* Feature in Windows. When the caret is moved,
* the text widget scrolls to show the new location.
@@ -1923,7 +1932,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
}
}
}
- super.setBounds (x, y, width, height, flags);
+ super.setBoundsInPixels (x, y, width, height, flags);
/*
* Bug in Windows. If the client area height is smaller than
@@ -2486,9 +2495,8 @@ int untranslateOffset (int offset) {
@Override
void updateMenuLocation (Event event) {
- Point point = display.map (this, null, getCaretLocation ());
- event.x = point.x;
- event.y = point.y + getLineHeight ();
+ Point point = display.mapInPixels (this, null, getCaretLocationInPixels ());
+ event.setLocationInPixels(point.x, point.y + getLineHeightInPixels ());
}
@Override
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 a43e4f92b6..bd3327f5fb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class support the layout of selectable
@@ -188,9 +188,7 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
int width = 0, height = 0;
if ((style & SWT.VERTICAL) != 0) {
RECT rect = new RECT ();
@@ -215,7 +213,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
OS.GetWindowRect (handle, oldRect);
int oldWidth = oldRect.right - oldRect.left;
int oldHeight = oldRect.bottom - oldRect.top;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + border * 2;
int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + border * 2;
boolean redraw = getDrawing () && OS.IsWindowVisible (handle);
@@ -246,15 +244,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- Rectangle trim = computeTrim (0, 0, width, height);
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
width = trim.width; height = trim.height;
return new Point (width, height);
}
-@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget ();
- Rectangle trim = super.computeTrim (x, y, width, height);
+@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.CCS_NODIVIDER) == 0) trim.height += 2;
return trim;
@@ -550,9 +546,13 @@ public ToolItem getItem (int index) {
public ToolItem getItem (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+ToolItem getItemInPixels (Point point) {
ToolItem [] items = getItems ();
for (int i=0; i<items.length; i++) {
- Rectangle rect = items [i].getBounds ();
+ Rectangle rect = items [i].getBoundsInPixels ();
if (rect.contains (point)) return items [i];
}
return null;
@@ -918,7 +918,7 @@ void setBackgroundTransparent (boolean transparent) {
}
@Override
-void setBounds (int x, int y, int width, int height, int flags) {
+void setBoundsInPixels (int x, int y, int width, int height, int flags) {
/*
* Feature in Windows. For some reason, when a tool bar is
* repositioned more than once using DeferWindowPos () into
@@ -934,7 +934,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
parent.setResizeChildren (true);
}
}
- super.setBounds (x, y, width, height, flags);
+ super.setBoundsInPixels (x, y, width, height, flags);
}
@Override
@@ -1502,7 +1502,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
if ((style & SWT.BORDER) != 0 && (style & SWT.WRAP) != 0) {
RECT windowRect = new RECT ();
OS.GetWindowRect (handle, windowRect);
- int index = 0, border = getBorderWidth () * 2;
+ int index = 0, border = getBorderWidthInPixels () * 2;
RECT rect = new RECT ();
int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
while (index < count) {
@@ -1586,8 +1586,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
int index = (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmtb.iItem, 0);
RECT rect = new RECT ();
OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
- event.x = rect.left;
- event.y = rect.bottom;
+ event.setLocationInPixels(rect.left, rect.bottom);
child.sendSelectionEvent (SWT.Selection, event, false);
}
break;
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 83e2c593e2..e1742c77c3 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
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a selectable user interface object
@@ -235,6 +235,10 @@ void destroyWidget () {
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
long /*int*/ hwnd = parent.handle;
int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
RECT rect = new RECT ();
@@ -390,6 +394,10 @@ public String getToolTipText () {
*/
public int getWidth () {
checkWidget();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
long /*int*/ hwnd = parent.handle;
int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
RECT rect = new RECT ();
@@ -510,12 +518,12 @@ void resizeControl () {
* case can occur when the control is a
* combo box.
*/
- Rectangle itemRect = getBounds ();
- control.setSize (itemRect.width, itemRect.height);
- Rectangle rect = control.getBounds ();
+ Rectangle itemRect = getBoundsInPixels ();
+ control.setSizeInPixels (itemRect.width, itemRect.height);
+ Rectangle rect = control.getBoundsInPixels ();
rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
- control.setLocation (rect.x, rect.y);
+ control.setLocationInPixels (rect.x, rect.y);
}
}
@@ -921,6 +929,10 @@ public void setToolTipText (String string) {
*/
public void setWidth (int width) {
checkWidget();
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
if ((style & SWT.SEPARATOR) == 0) return;
if (width < 0) return;
long /*int*/ hwnd = parent.handle;
@@ -944,7 +956,7 @@ void updateImages (boolean enabled) {
ImageList hotImageList = parent.getHotImageList ();
ImageList disabledImageList = parent.getDisabledImageList();
if (info.iImage == OS.I_IMAGENONE) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
int listStyle = parent.style & SWT.RIGHT_TO_LEFT;
if (imageList == null) {
imageList = display.getImageListToolBar (listStyle, bounds.width, bounds.height);
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 e1f449040b..15ddacff82 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
@@ -14,6 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -367,6 +368,10 @@ public void setAutoHide (boolean autoHide) {
*/
public void setLocation (int x, int y) {
checkWidget ();
+ setLocationInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y));
+}
+
+void setLocationInPixels (int x, int y) {
this.x = x;
this.y = y;
hasLocation = true;
@@ -398,7 +403,8 @@ public void setLocation (int x, int y) {
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ location = DPIUtil.autoScaleUp(location);
+ 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 06baecf925..44e2a01bd5 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
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class implement rubber banding rectangles that are
@@ -411,6 +411,14 @@ void drawRectangles (Rectangle [] rects, boolean stippled) {
*/
public Rectangle [] getRectangles () {
checkWidget();
+ Rectangle [] result = getRectanglesInPixels();
+ for (int i = 0; i < result.length; i++) {
+ result[i] = DPIUtil.autoScaleDown(result[i]);
+ }
+ return result;
+}
+
+Rectangle [] getRectanglesInPixels () {
Rectangle [] result = new Rectangle [rectangles.length];
for (int i = 0; i < rectangles.length; i++) {
Rectangle current = rectangles [i];
@@ -488,7 +496,7 @@ public boolean open () {
* second window is used for drawing the rectangles.
*/
if (IsVista && parent == null) {
- Rectangle bounds = display.getBounds();
+ Rectangle bounds = display.getBoundsInPixels();
hwndTransparent = OS.CreateWindowEx (
OS.WS_EX_LAYERED | OS.WS_EX_NOACTIVATE | OS.WS_EX_TOOLWINDOW,
display.windowClass,
@@ -531,7 +539,7 @@ public boolean open () {
* outside of our visible windows (ie.- over the desktop).
*/
if (!mouseDown) {
- Rectangle bounds = display.getBounds();
+ Rectangle bounds = display.getBoundsInPixels();
hwndTransparent = OS.CreateWindowEx (
OS.WS_EX_TRANSPARENT,
display.windowClass,
@@ -850,6 +858,14 @@ public void setCursor(Cursor newCursor) {
public void setRectangles (Rectangle [] rectangles) {
checkWidget ();
if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ Rectangle [] rectanglesInPixels = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ rectanglesInPixels [i] = DPIUtil.autoScaleUp (rectangles [i]);
+ }
+ setRectanglesInPixels (rectanglesInPixels);
+}
+
+void setRectanglesInPixels (Rectangle [] rectangles) {
this.rectangles = new Rectangle [rectangles.length];
for (int i = 0; i < rectangles.length; i++) {
Rectangle current = rectangles [i];
@@ -999,8 +1015,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
}
Event event = new Event ();
- event.x = oldX + xChange;
- event.y = oldY + yChange;
+ event.setLocationInPixels(oldX + xChange, oldY + yChange);
Point cursorPos;
if ((style & SWT.RESIZE) != 0) {
resizeRectangles (xChange, yChange);
@@ -1120,8 +1135,7 @@ LRESULT wmMouse (int message, long /*int*/ wParam, long /*int*/ lParam) {
rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
}
Event event = new Event ();
- event.x = newX;
- event.y = newY;
+ event.setLocationInPixels(newX, newY);
if ((style & SWT.RESIZE) != 0) {
if (isMirrored) {
resizeRectangles (oldX - newX, newY - oldY);
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 1e0de9fd44..7b527129ab 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class provide a selectable user interface object
@@ -525,15 +525,15 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (images != null) image = images [index];
}
if (image != null) {
- Rectangle bounds = image.getBounds ();
- if (size == null) size = getImageSize ();
+ Rectangle bounds = image.getBounds (); // Points
+ if (size == null) size = DPIUtil.autoScaleDown (getImageSize ()); // To Points
if (!ignoreDrawForeground) {
GCData data = new GCData();
data.device = display;
GC gc = GC.win32_new (hDC, data);
- RECT iconRect = item.getBounds (index, false, true, false, false, true, hDC);
- gc.setClipping (iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top);
- gc.drawImage (image, 0, 0, bounds.width, bounds.height, iconRect.left, iconRect.top, size.x, size.y);
+ RECT iconRect = item.getBounds (index, false, true, false, false, true, hDC); // Pixels
+ gc.setClipping (DPIUtil.autoScaleDown(new Rectangle(iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top)));
+ gc.drawImage (image, 0, 0, bounds.width, bounds.height, DPIUtil.autoScaleDown(iconRect.left), DPIUtil.autoScaleDown(iconRect.top), size.x, size.y);
OS.SelectClipRgn (hDC, 0);
gc.dispose ();
}
@@ -648,11 +648,9 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
}
}
}
- event.x = cellRect.left;
- event.y = cellRect.top;
- event.width = cellRect.right - cellRect.left;
- event.height = cellRect.bottom - cellRect.top;
- gc.setClipping (event.x, event.y, event.width, event.height);
+ Rectangle boundsInPixels = new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top);
+ event.setBoundsInPixels (boundsInPixels);
+ gc.setClipping (DPIUtil.autoScaleDown (boundsInPixels));
sendEvent (SWT.EraseItem, event);
event.gc = null;
int newTextClr = data.foreground;
@@ -765,8 +763,8 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
int inset = i != 0 ? INSET : 0;
int offset = i != 0 ? INSET : INSET + 2;
if (image != null) {
- Rectangle bounds = image.getBounds ();
- if (size == null) size = getImageSize ();
+ Rectangle bounds = image.getBounds (); // Points
+ if (size == null) size = DPIUtil.autoScaleDown (getImageSize ()); // To Points
if (!ignoreDrawForeground) {
//int y1 = rect.top + (index == 0 ? (getItemHeight () - size.y) / 2 : 0);
int y1 = rect.top;
@@ -774,8 +772,8 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
GCData data = new GCData();
data.device = display;
GC gc = GC.win32_new (hDC, data);
- gc.setClipping (x1, rect.top, rect.right - x1, rect.bottom - rect.top);
- gc.drawImage (image, 0, 0, bounds.width, bounds.height, x1, y1, size.x, size.y);
+ gc.setClipping (DPIUtil.autoScaleDown(new Rectangle(x1, rect.top, rect.right - x1, rect.bottom - rect.top)));
+ gc.drawImage (image, 0, 0, bounds.width, bounds.height, DPIUtil.autoScaleDown(x1), DPIUtil.autoScaleDown(y1), size.x, size.y);
OS.SelectClipRgn (hDC, 0);
gc.dispose ();
}
@@ -865,14 +863,11 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
}
}
}
- event.x = itemRect.left;
- event.y = itemRect.top;
- event.width = itemRect.right - itemRect.left;
- event.height = itemRect.bottom - itemRect.top;
+ event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC);
int cellWidth = cellRect.right - cellRect.left;
int cellHeight = cellRect.bottom - cellRect.top;
- gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
+ gc.setClipping (DPIUtil.autoScaleDown(new Rectangle(cellRect.left, cellRect.top, cellWidth, cellHeight)));
sendEvent (SWT.PaintItem, event);
if (data.focusDrawn) focusRect = null;
event.gc = null;
@@ -1000,8 +995,10 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
}
//TODO - BUG - measure and erase sent when first column is clipped
Event measureEvent = null;
+ Rectangle boundsInPixels = null;
if (hooks (SWT.MeasureItem)) {
measureEvent = sendMeasureItemEvent (item, index, hDC, selected ? SWT.SELECTED : 0);
+ boundsInPixels = measureEvent.getBoundsInPixels ();
if (isDisposed () || item.isDisposed ()) return null;
}
selectionForeground = -1;
@@ -1055,11 +1052,9 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
}
}
}
- event.x = cellRect.left;
- event.y = cellRect.top;
- event.width = cellRect.right - cellRect.left;
- event.height = cellRect.bottom - cellRect.top;
- gc.setClipping (event.x, event.y, event.width, event.height);
+ Rectangle boundsInPixels2 = new Rectangle (cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top);
+ event.setBoundsInPixels (boundsInPixels2);
+ gc.setClipping (DPIUtil.autoScaleDown (boundsInPixels2));
sendEvent (SWT.EraseItem, event);
event.gc = null;
int newTextClr = data.foreground;
@@ -1086,7 +1081,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
} else {
RECT textRect = item.getBounds (index, true, false, false, false, true, hDC);
if (measureEvent != null) {
- textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width);
+ textRect.right = Math.min (cellRect.right, boundsInPixels.x + boundsInPixels.width);
}
fillBackground (hDC, clrTextBk, textRect);
}
@@ -1105,7 +1100,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
RECT pRect = item.getBounds (index, true, true, false, false, false, hDC);
RECT pClipRect = item.getBounds (index, true, true, true, false, true, hDC);
if (measureEvent != null) {
- pRect.right = Math.min (pClipRect.right, measureEvent.x + measureEvent.width);
+ pRect.right = Math.min (pClipRect.right, boundsInPixels.x + boundsInPixels.width);
} else {
pRect.right += EXPLORER_EXTRA;
pClipRect.right += EXPLORER_EXTRA;
@@ -1135,7 +1130,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
} else {
RECT textRect = item.getBounds (index, true, false, false, false, true, hDC);
if (measureEvent != null) {
- textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width);
+ textRect.right = Math.min (cellRect.right, boundsInPixels.x + boundsInPixels.width);
}
fillBackground (hDC, OS.GetBkColor (hDC), textRect);
}
@@ -1166,7 +1161,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
if (focused && !ignoreDrawFocus && (style & SWT.FULL_SELECTION) == 0) {
RECT textRect = item.getBounds (index, true, explorerTheme, false, false, true, hDC);
if (measureEvent != null) {
- textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width);
+ textRect.right = Math.min (cellRect.right, boundsInPixels.x + boundsInPixels.width);
}
nmcd.uItemState &= ~OS.CDIS_FOCUS;
OS.MoveMemory (lParam, nmcd, NMTVCUSTOMDRAW.sizeof);
@@ -1811,9 +1806,7 @@ long /*int*/ CompareFunc (long /*int*/ lParam1, long /*int*/ lParam2, long /*int
return sortDirection == SWT.UP ? text1.compareTo (text2) : text2.compareTo (text1);
}
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
+@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
int width = 0, height = 0;
if (hwndHeader != 0) {
HDITEM hdItem = new HDITEM ();
@@ -1848,7 +1841,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2;
height += border * 2;
if ((style & SWT.V_SCROLL) != 0) {
@@ -2775,11 +2768,12 @@ 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 = event.getBoundsInPixels();
itemRect [0] = new RECT ();
- itemRect [0].left = event.x;
- itemRect [0].right = event.x + event.width;
- itemRect [0].top = event.y;
- itemRect [0].bottom = event.y + event.height;
+ itemRect [0].left = boundsInPixels.x;
+ itemRect [0].right = boundsInPixels.x + boundsInPixels.width;
+ itemRect [0].top = boundsInPixels.y;
+ itemRect [0].bottom = boundsInPixels.y + boundsInPixels.height;
} else {
itemRect [0] = item [0].getBounds (order [index [0]], true, false, false, false, false, hDC);
}
@@ -2930,6 +2924,10 @@ TreeItem getFocusItem () {
*/
public int getGridLineWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getGridLineWidthInPixels ());
+}
+
+int getGridLineWidthInPixels () {
return GRID_WIDTH;
}
@@ -2947,6 +2945,10 @@ public int getGridLineWidth () {
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
if (hwndHeader == 0) return 0;
RECT rect = new RECT ();
OS.GetWindowRect (hwndHeader, rect);
@@ -2981,7 +2983,7 @@ public boolean getHeaderVisible () {
Point getImageSize () {
if (imageList != null) return imageList.getImageSize ();
- return new Point (0, getItemHeight ());
+ return new Point (0, getItemHeightInPixels ());
}
long /*int*/ getBottomItem () {
@@ -3200,6 +3202,10 @@ TreeItem getItem (NMTVCUSTOMDRAW nmcd) {
public TreeItem getItem (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+TreeItem getItemInPixels (Point point) {
TVHITTESTINFO lpht = new TVHITTESTINFO ();
lpht.x = point.x;
lpht.y = point.y;
@@ -3270,6 +3276,10 @@ int getItemCount (long /*int*/ hItem) {
*/
public int getItemHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getItemHeightInPixels());
+}
+
+int getItemHeightInPixels () {
return (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
}
@@ -3689,7 +3699,7 @@ boolean hitTestSelection (long /*int*/ hItem, int x, int y) {
int state = (int)/*64*/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 (event.getBounds ().contains (x, y)) result = true;
+ if (event.getBoundsInPixels ().contains (x, y)) result = true;
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
// if (isDisposed () || item.isDisposed ()) return false;
@@ -3699,7 +3709,7 @@ boolean hitTestSelection (long /*int*/ hItem, int x, int y) {
int imageIndex (Image image, int index) {
if (image == null) return OS.I_IMAGENONE;
if (imageList == null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
}
int imageIndex = imageList.indexOf (image);
@@ -3723,7 +3733,7 @@ int imageIndex (Image image, int index) {
int imageIndexHeader (Image image) {
if (image == null) return OS.I_IMAGENONE;
if (headerImageList == null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = headerImageList.indexOf (image);
if (index == -1) index = headerImageList.add (image);
@@ -4433,10 +4443,7 @@ Event sendEraseItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT c
event.index = column;
event.gc = gc;
event.detail |= SWT.FOREGROUND;
- event.x = cellRect.left;
- event.y = cellRect.top;
- event.width = cellRect.right - cellRect.left;
- event.height = cellRect.bottom - cellRect.top;
+ event.setBoundsInPixels(new Rectangle(cellRect.left, cellRect.top, cellRect.right - cellRect.left, cellRect.bottom - cellRect.top));
//gc.setClipping (event.x, event.y, event.width, event.height);
sendEvent (SWT.EraseItem, event);
event.gc = null;
@@ -4457,24 +4464,22 @@ Event sendMeasureItemEvent (TreeItem item, int index, long /*int*/ hDC, int deta
event.item = item;
event.gc = gc;
event.index = index;
- event.x = itemRect.left;
- event.y = itemRect.top;
- event.width = itemRect.right - itemRect.left;
- event.height = itemRect.bottom - itemRect.top;
+ event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
event.detail = detail;
sendEvent (SWT.MeasureItem, event);
event.gc = null;
gc.dispose ();
OS.RestoreDC (hDC, nSavedDC);
if (isDisposed () || item.isDisposed ()) return null;
+ Rectangle rect = event.getBoundsInPixels ();
if (hwndHeader != 0) {
if (columnCount == 0) {
- if (event.x + event.width > scrollWidth) {
- setScrollWidth (scrollWidth = event.x + event.width);
+ if (rect.x + rect.width > scrollWidth) {
+ setScrollWidth (scrollWidth = rect.x + rect.width);
}
}
}
- if (event.height > getItemHeight ()) setItemHeight (event.height);
+ if (rect.height > getItemHeightInPixels ()) setItemHeight (rect.height);
return event;
}
@@ -4494,10 +4499,7 @@ Event sendPaintItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT i
event.index = column;
event.gc = gc;
event.detail |= SWT.FOREGROUND;
- event.x = itemRect.left;
- event.y = itemRect.top;
- event.width = itemRect.right - itemRect.left;
- event.height = itemRect.bottom - itemRect.top;
+ event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
//gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight);
sendEvent (SWT.PaintItem, event);
event.gc = null;
@@ -5634,22 +5636,21 @@ void updateImages () {
@Override
void updateMenuLocation (Event event) {
- Rectangle clientArea = getClientArea ();
+ Rectangle clientArea = getClientAreaInPixels ();
int x = clientArea.x, y = clientArea.y;
TreeItem focusItem = getFocusItem ();
if (focusItem != null) {
- Rectangle bounds = focusItem.getBounds (0);
+ Rectangle bounds = focusItem.getBoundsInPixels (0);
if (focusItem.text != null && focusItem.text.length () != 0) {
- bounds = focusItem.getBounds ();
+ bounds = focusItem.getBoundsInPixels ();
}
x = Math.max (x, bounds.x + bounds.width / 2);
x = Math.min (x, clientArea.x + clientArea.width);
y = Math.max (y, bounds.y + bounds.height);
y = Math.min (y, clientArea.y + clientArea.height);
}
- Point pt = toDisplay (x, y);
- event.x = pt.x;
- event.y = pt.y;
+ Point pt = toDisplayInPixels (x, y);
+ event.setLocationInPixels(pt.x, pt.y);
}
@Override
@@ -7093,10 +7094,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (hooksPaint) {
Event event = new Event ();
event.gc = gc;
- event.x = ps.left;
- event.y = ps.top;
- event.width = ps.right - ps.left;
- event.height = ps.bottom - ps.top;
+ event.setBoundsInPixels(new Rectangle(ps.left, ps.top, ps.right - ps.left, ps.bottom - ps.top));
sendEvent (SWT.Paint, event);
// widget could be disposed at this point
event.gc = null;
@@ -8112,8 +8110,8 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ 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) {
- Rectangle rect = image.getBounds ();
- gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, x, imageRect.top, size.x, size.y);
+ Rectangle rect = image.getBounds (); // Points
+ gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(imageRect.top), DPIUtil.autoScaleDown(size.x), DPIUtil.autoScaleDown(size.y));
x += INSET + (index [0] == 0 ? 1 : 0);
}
x += size.x;
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 d8706826da..2c07d2d220 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
@@ -11,10 +11,11 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a column in a tree widget.
@@ -311,6 +312,10 @@ public String getToolTipText () {
*/
public int getWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
int index = parent.indexOf (this);
if (index == -1) return 0;
long /*int*/ hwndHeader = parent.hwndHeader;
@@ -355,7 +360,8 @@ public void pack () {
int detail = (tvItem.state & OS.TVIS_SELECTED) != 0 ? SWT.SELECTED : 0;
Event event = parent.sendMeasureItemEvent (item, index, hDC, detail);
if (isDisposed () || parent.isDisposed ()) break;
- itemRight = event.x + event.width;
+ Rectangle bounds = event.getBoundsInPixels();
+ itemRight = bounds.x + bounds.width;
} else {
long /*int*/ hFont = item.fontHandle (index);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
@@ -385,7 +391,7 @@ public void pack () {
headerImage = image;
}
if (headerImage != null) {
- Rectangle bounds = headerImage.getBounds ();
+ Rectangle bounds = headerImage.getBoundsInPixels ();
headerWidth += bounds.width;
}
int margin = 0;
@@ -399,7 +405,7 @@ public void pack () {
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (hwnd, hDC);
int gridWidth = parent.linesVisible ? Tree.GRID_WIDTH : 0;
- setWidth (Math.max (headerWidth, columnWidth + gridWidth));
+ setWidthInPixels (Math.max (headerWidth, columnWidth + gridWidth));
}
@Override
@@ -726,6 +732,10 @@ public void setToolTipText (String string) {
*/
public void setWidth (int width) {
checkWidget ();
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
if (width < 0) return;
int index = parent.indexOf (this);
if (index == -1) return;
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 5e9f9f6279..9e98f80edb 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
@@ -11,9 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a selectable user interface object
@@ -394,6 +395,10 @@ public Color getBackground (int index) {
*/
public Rectangle getBounds () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
RECT rect = getBounds (0, true, false, false);
int width = rect.right - rect.left, height = rect.bottom - rect.top;
@@ -416,6 +421,10 @@ public Rectangle getBounds () {
*/
public Rectangle getBounds (int index) {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels(index));
+}
+
+Rectangle getBoundsInPixels (int index) {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
RECT rect = getBounds (index, true, true, true);
int width = rect.right - rect.left, height = rect.bottom - rect.top;
@@ -839,6 +848,10 @@ public Image getImage (int index) {
*/
public Rectangle getImageBounds (int index) {
checkWidget();
+ return DPIUtil.autoScaleDown(getImageBoundsInPixels(index));
+}
+
+Rectangle getImageBoundsInPixels (int index) {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
RECT rect = getBounds (index, false, true, false);
int width = rect.right - rect.left, height = rect.bottom - rect.top;
@@ -930,6 +943,10 @@ public String getText (int index) {
*/
public Rectangle getTextBounds (int index) {
checkWidget();
+ return DPIUtil.autoScaleDown(getTextBoundsInPixels(index));
+}
+
+Rectangle getTextBoundsInPixels (int index) {
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
RECT rect = getBounds (index, true, false, true);
if (index == 0) rect.left += Tree.INSET - 1;
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 e97e92e1ed..9bea44347d 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
@@ -1056,8 +1056,7 @@ void reskinWidget() {
boolean sendDragEvent (int button, int x, int y) {
Event event = new Event ();
event.button = button;
- event.x = x;
- event.y = y;
+ event.setLocationInPixels(x, y); // In Pixels
setInputState (event, SWT.DragDetect);
postEvent (SWT.DragDetect, event);
if (isDisposed ()) return false;
@@ -1067,8 +1066,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;
- event.x = x;
- event.y = y;
+ event.setLocationInPixels(x, y);
event.stateMask = stateMask;
postEvent (SWT.DragDetect, event);
if (isDisposed ()) return false;
@@ -1144,8 +1142,7 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
event.button = button;
event.detail = detail;
event.count = count;
- event.x = OS.GET_X_LPARAM (lParam);
- event.y = OS.GET_Y_LPARAM (lParam);
+ event.setLocationInPixels(OS.GET_X_LPARAM (lParam), OS.GET_Y_LPARAM (lParam));
setInputState (event, type);
mapEvent (hwnd, event);
if (send) {
@@ -1491,8 +1488,7 @@ boolean showMenu (int x, int y) {
boolean showMenu (int x, int y, int detail) {
Event event = new Event ();
- event.x = x;
- event.y = y;
+ event.setLocationInPixels(x, y);
event.detail = detail;
if (event.detail == SWT.MENU_KEYBOARD) {
updateMenuLocation (event);
@@ -1503,8 +1499,9 @@ boolean showMenu (int x, int y, int detail) {
if (!event.doit) return true;
Menu menu = getMenu ();
if (menu != null && !menu.isDisposed ()) {
- if (x != event.x || y != event.y) {
- menu.setLocation (event.x, event.y);
+ Point loc = event.getLocationInPixels(); // In Pixels
+ if (x != loc.x || y != loc.y) {
+ menu.setLocation (event.getLocation());
}
menu.setVisible (true);
return true;
@@ -2300,10 +2297,7 @@ LRESULT wmPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
if (width != 0 && height != 0) {
Event event = new Event ();
event.gc = gc;
- event.x = ps.left;
- event.y = ps.top;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(ps.left, ps.top, width, height));
sendEvent (SWT.Paint, event);
// widget could be disposed at this point
event.gc = null;
@@ -2329,10 +2323,7 @@ LRESULT wmPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
OS.SetMetaRgn (hDC);
Event event = new Event ();
event.gc = gc;
- event.x = rect.left;
- event.y = rect.top;
- event.width = width;
- event.height = height;
+ event.setBoundsInPixels(new Rectangle(rect.left, rect.top, width, height));
sendEvent (SWT.Paint, event);
// widget could be disposed at this point
event.gc = null;

Back to the top