Merge branch 'master' into slakkimsetti/HighDPIChangesforNeon
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
index 9852f99..b3b0d42 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
@@ -19,6 +19,7 @@
/* SWT Imports */
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
@@ -249,7 +250,7 @@
});
break;
case SWT.Resize:
- final Rectangle clientArea = parent.getClientArea();
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
EventQueue.invokeLater(new Runnable () {
@Override
public void run () {
@@ -267,7 +268,7 @@
@Override
public void run () {
if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
EventQueue.invokeLater(new Runnable () {
@Override
public void run () {
@@ -317,7 +318,7 @@
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)));
}
});
}
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 66c684d..35cc62c 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 @@
/* 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 @@
@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 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 02d12bf..ce4ca4c 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 @@
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 63c33e8..f152710 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 @@
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 d64e2ed..ac8b247 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.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 @@
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 09e72e7..c9cfa43 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 177bcaa..d0d1b46 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/common/org/eclipse/swt/dnd/DragSourceEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java
index 618200e..813a8a4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
-import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
index aa3c1f6..04cf42c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.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
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
-import org.eclipse.swt.SWT;
+import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
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 db76bb3..7dbb5df 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 @@
} 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 1dd5c66..162c67f 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 @@
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 @@
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 @@
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 9c4ce9b..be567ca 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(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(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(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 d841910..4a4e735 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 @@
}
}
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 686c8f8..5eb5319 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 @@
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 @@
} 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 @@
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 @@
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 6eb6b28..e9291a2 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 @@
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 e6781be..a0e6e99 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 @@
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 @@
} 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 @@
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 @@
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 16897d9..98d2843 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 @@
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 @@
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 674aec2..82940c6 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 @@
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 @@
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 Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
index 7f5bd1b..1e06d0f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
@@ -361,6 +361,8 @@
}
void setSize (long /*int*/ embedHandle, int width, int height) {
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
OS.gtk_widget_set_size_request (embedHandle, width, height);
}
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 242b3bf..cf4e1d1 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 @@
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 @@
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 @@
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 OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java
index acf9111..247aa7f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java
@@ -12,6 +12,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.opengl.glx.*;
import org.eclipse.swt.widgets.*;
@@ -161,7 +162,7 @@
GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]);
break;
case SWT.Resize:
- Rectangle clientArea = getClientArea();
+ Rectangle clientArea = DPIUtil.autoScaleUp(getClientArea());
OS.gdk_window_move (glWindow, clientArea.x, clientArea.y);
OS.gdk_window_resize (glWindow, clientArea.width, clientArea.height);
break;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c
index 67018e9..7aeca2a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c
@@ -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
@@ -101,10 +101,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3BJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3BI_FUNC);
#else
@@ -126,10 +140,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3CJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3CI_FUNC);
#else
@@ -151,10 +179,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3DJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3DI_FUNC);
#else
@@ -176,10 +218,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3FJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3FI_FUNC);
#else
@@ -201,10 +257,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3IJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3II_FUNC);
#else
@@ -226,10 +296,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3JJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3JI_FUNC);
#else
@@ -251,10 +335,24 @@
#else
C_NATIVE_ENTER(env, that, memmove__J_3SJ_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;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove__I_3SI_FUNC);
#else
@@ -276,10 +374,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3BJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3BII_FUNC);
#else
@@ -302,12 +414,28 @@
#else
C_NATIVE_ENTER(env, that, memmove___3B_3CJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3B_3CI_FUNC);
#else
@@ -329,10 +457,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3CJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3CII_FUNC);
#else
@@ -354,10 +496,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3DJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3DII_FUNC);
#else
@@ -379,10 +535,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3FJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3FII_FUNC);
#else
@@ -404,10 +574,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3IJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3III_FUNC);
#else
@@ -431,10 +615,24 @@
C_NATIVE_ENTER(env, that, memmove___3I_3BJ_FUNC);
#endif
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == 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)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)lparg1, (size_t)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);
+ }
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3I_3BI_FUNC);
@@ -457,10 +655,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3JJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3JII_FUNC);
#else
@@ -482,10 +694,24 @@
#else
C_NATIVE_ENTER(env, that, memmove___3SJJ_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;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)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
C_NATIVE_EXIT(env, that, memmove___3SII_FUNC);
#else
@@ -506,6 +732,25 @@
}
#endif
+#ifndef NO_setenv
+JNIEXPORT jint JNICALL C_NATIVE(setenv)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc = 0;
+ C_NATIVE_ENTER(env, that, setenv_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ rc = (jint)setenv((const char *)lparg0, (const char *)lparg1, arg2);
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ C_NATIVE_EXIT(env, that, setenv_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_strlen
JNIEXPORT jint JNICALL C_NATIVE(strlen)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c
index 932c91c..d763ed6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c
@@ -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
@@ -105,6 +105,7 @@
"memmove___3SJJ",
#endif
"memset",
+ "setenv",
"strlen",
};
#define NATIVE_FUNCTION_COUNT sizeof(C_nativeFunctionNames) / sizeof(char*)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h
index cc34b1c..e0da109 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h
@@ -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
@@ -115,5 +115,6 @@
memmove___3SJJ_FUNC,
#endif
memset_FUNC,
+ setenv_FUNC,
strlen_FUNC,
} C_FUNCS;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java
index dcafafe..c511494 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.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
@@ -22,6 +22,11 @@
public static final native void free (long /*int*/ ptr);
/** @param env cast=(const char *) */
public static final native long /*int*/ getenv (byte[] env);
+/**
+ * @param env cast=(const char *)
+ * @param value cast=(const char *)
+ */
+public static final native int setenv (byte[] env, byte[] value, int overwrite);
public static final native long /*int*/ malloc (long /*int*/ size);
/**
* @param dest cast=(void *)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 02dbadd..c367399 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -3861,6 +3861,129 @@
}
#endif
+#ifndef NO__1g_1settings_1get
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1settings_1get)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jintArray arg4)
+{
+ jbyte *lparg1=NULL;
+ jbyte *lparg2=NULL;
+ jbyte *lparg3=NULL;
+ jint *lparg4=NULL;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1get_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+/*
+ g_settings_get((GSettings *)arg0, (const gchar *)lparg1, lparg2, lparg3, lparg4);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_get)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GSettings *, const gchar *, jbyte *, jbyte *, jint *))fp)((GSettings *)arg0, (const gchar *)lparg1, lparg2, lparg3, lparg4);
+ }
+ }
+fail:
+ if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1get_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1settings_1get_1value
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1get_1value)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1get_1value_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_settings_get_value((GSettings *)arg0, (const gchar *)lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_get_value)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GSettings *, const gchar *))fp)((GSettings *)arg0, (const gchar *)lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1get_1value_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1settings_1new
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1new)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1new_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_settings_new((const gchar *)lparg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const gchar *))fp)((const gchar *)lparg0);
+ }
+ }
+fail:
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1settings_1schema_1source_1get_1default
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1schema_1source_1get_1default)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1schema_1source_1get_1default_FUNC);
+/*
+ rc = (jintLong)g_settings_schema_source_get_default();
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_schema_source_get_default)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1schema_1source_1get_1default_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1settings_1schema_1source_1lookup
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1schema_1source_1lookup)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jboolean arg2)
+{
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1schema_1source_1lookup_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_settings_schema_source_lookup((GSettingsSchemaSource *)arg0, (const gchar *)lparg1, (gboolean)arg2);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_schema_source_lookup)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GSettingsSchemaSource *, const gchar *, gboolean))fp)((GSettingsSchemaSource *)arg0, (const gchar *)lparg1, (gboolean)arg2);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1schema_1source_1lookup_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1g_1signal_1add_1emission_1hook
JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1signal_1add_1emission_1hook)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jintLong arg2, jintLong arg3, jintLong arg4)
@@ -4476,16 +4599,36 @@
jintLong *lparg4=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1g_1utf16_1to_1utf8_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntLongArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)g_utf16_to_utf8((const gunichar2 *)lparg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseIntLongArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0);
+ if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1g_1utf16_1to_1utf8_FUNC);
return rc;
}
@@ -4543,14 +4686,32 @@
#else
OS_NATIVE_ENTER(env, that, _1g_1utf8_1to_1utf16__JJ_3J_3J_3J_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntLongArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)g_utf8_to_utf16((const gchar *)arg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseIntLongArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, _1g_1utf8_1to_1utf16__II_3I_3I_3I_FUNC);
#else
@@ -4577,16 +4738,36 @@
#else
OS_NATIVE_ENTER(env, that, _1g_1utf8_1to_1utf16___3BJ_3J_3J_3J_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntLongArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)g_utf8_to_utf16((const gchar *)lparg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseIntLongArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, _1g_1utf8_1to_1utf16___3BI_3I_3I_3I_FUNC);
#else
@@ -4608,6 +4789,30 @@
}
#endif
+#ifndef NO__1g_1variant_1dict_1lookup_1value
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1dict_1lookup_1value)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2)
+{
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1dict_1lookup_1value_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_variant_dict_lookup_value((GVariant *)arg0, (const gchar *)lparg1, (const GVariantType *)arg2);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_dict_lookup_value)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GVariant *, const gchar *, const GVariantType *))fp)((GVariant *)arg0, (const gchar *)lparg1, (const GVariantType *)arg2);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1dict_1lookup_1value_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1g_1variant_1get_1boolean
JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1variant_1get_1boolean)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -4776,6 +4981,108 @@
}
#endif
+#ifndef NO__1g_1variant_1iter_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1variant_1iter_1free)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1free_FUNC);
+/*
+ g_variant_iter_free((GVariantIter *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_free)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GVariantIter *))fp)((GVariantIter *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1init
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1variant_1iter_1init)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1init_FUNC);
+/*
+ rc = (jint)g_variant_iter_init((GVariantIter *)arg0, (GVariant *)arg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_init)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GVariantIter *, GVariant *))fp)((GVariantIter *)arg0, (GVariant *)arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1init_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1new
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1iter_1new)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1new_FUNC);
+/*
+ rc = (jintLong)g_variant_iter_new((GVariant *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GVariant *))fp)((GVariant *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1next
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1variant_1iter_1next)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2, jintLong arg3)
+{
+ jbyte *lparg1=NULL;
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1next_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jboolean)g_variant_iter_next((const GVariantIter *)arg0, lparg1, (gchar *)arg2, arg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_next)
+ if (fp) {
+ rc = (jboolean)((jboolean (CALLING_CONVENTION*)(const GVariantIter *, jbyte *, gchar *, jintLong))fp)((const GVariantIter *)arg0, lparg1, (gchar *)arg2, arg3);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1next_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1next_1value
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1iter_1next_1value)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1next_1value_FUNC);
+/*
+ rc = (jintLong)g_variant_iter_next_value((const GVariantIter *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_next_value)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const GVariantIter *))fp)((const GVariantIter *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1next_1value_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1g_1variant_1n_1children
JNIEXPORT jlong JNICALL OS_NATIVE(_1g_1variant_1n_1children)
(JNIEnv *env, jclass that, jlong arg0)
@@ -4968,6 +5275,44 @@
}
#endif
+#ifndef NO__1g_1variant_1print
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1print)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1print_FUNC);
+/*
+ rc = (jintLong)g_variant_print((const GVariant *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_print)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const GVariant *))fp)((const GVariant *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1print_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1variant_1unref)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1unref_FUNC);
+/*
+ g_variant_unref((GVariant *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_unref)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GVariant *))fp)((GVariant *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1unref_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1atom_1intern
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1atom_1intern)
(JNIEnv *env, jclass that, jbyteArray arg0, jboolean arg1)
@@ -4975,10 +5320,24 @@
jbyte *lparg0=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1gdk_1atom_1intern_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)gdk_atom_intern((const gchar *)lparg0, arg1);
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, _1gdk_1atom_1intern_FUNC);
return rc;
}
@@ -5013,7 +5372,14 @@
jbyte *lparg1=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1gdk_1bitmap_1create_1from_1data_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)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
/*
rc = (jintLong)gdk_bitmap_create_from_data((GdkWindow *)arg0, (const gchar *)lparg1, (gint)arg2, (gint)arg3);
*/
@@ -5024,7 +5390,14 @@
}
}
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);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1bitmap_1create_1from_1data_FUNC);
return rc;
}
@@ -5773,7 +6146,14 @@
{
jint *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1draw_1lines_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;
+ }
/*
gdk_draw_lines(arg0, arg1, (GdkPoint *)lparg2, (gint)arg3);
*/
@@ -5784,7 +6164,14 @@
}
}
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)->ReleaseIntArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1draw_1lines_FUNC);
}
#endif
@@ -5831,7 +6218,14 @@
{
jint *lparg3=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1draw_1polygon_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;
+ }
/*
gdk_draw_polygon(arg0, arg1, arg2, lparg3, arg4);
*/
@@ -5842,7 +6236,14 @@
}
}
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)->ReleaseIntArrayElements(env, arg3, lparg3, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1draw_1polygon_FUNC);
}
#endif
@@ -5912,8 +6313,16 @@
jint *lparg1=NULL;
jint *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1size_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_drawable_get_size(arg0, (gint *)lparg1, (gint *)lparg2);
*/
@@ -5924,8 +6333,16 @@
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1size_FUNC);
}
#endif
@@ -6257,7 +6674,14 @@
{
jbyte *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1dashes_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)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_gc_set_dashes(arg0, (gint)arg1, (gint8 *)lparg2, (gint)arg3);
*/
@@ -6268,7 +6692,14 @@
}
}
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)->ReleaseByteArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1dashes_FUNC);
}
#endif
@@ -6876,8 +7307,16 @@
jint *lparg1=NULL;
jint *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1pixmap_1get_1size_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_pixmap_get_size(arg0, (gint *)lparg1, (gint *)lparg2);
*/
@@ -6888,8 +7327,16 @@
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1pixmap_1get_1size_FUNC);
}
#endif
@@ -20303,10 +20750,24 @@
jbyte *lparg0=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1from_1string_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)pango_font_description_from_string((const char *)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, _1pango_1font_1description_1from_1string_FUNC);
return rc;
}
@@ -20402,10 +20863,24 @@
{
jbyte *lparg1=NULL;
OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1family_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)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
pango_font_description_set_family((PangoFontDescription *)arg0, (const char *)lparg1);
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);
+ }
OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1family_FUNC);
}
#endif
@@ -21113,10 +21588,24 @@
{
jbyte *lparg1=NULL;
OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1text_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)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
pango_layout_set_text((PangoLayout *)arg0, (const char *)lparg1, (int)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);
+ }
OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1text_FUNC);
}
#endif
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 8e5844b..13d853e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+* Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -500,6 +500,19 @@
#define g_icon_to_string_LIB LIB_GIO
#define g_icon_new_for_string_LIB LIB_GIO
#define g_file_query_info_LIB LIB_GIO
+#define g_settings_get_LIB LIB_GIO
+#define g_settings_new_LIB LIB_GIO
+#define g_settings_get_value_LIB LIB_GIO
+#define g_variant_dict_lookup_value_LIB LIB_GIO
+#define g_variant_iter_next_LIB LIB_GIO
+#define g_variant_iter_next_value_LIB LIB_GIO
+#define g_variant_iter_init_LIB LIB_GIO
+#define g_variant_iter_free_LIB LIB_GIO
+#define g_variant_iter_new_LIB LIB_GIO
+#define g_variant_unref_LIB LIB_GIO
+#define g_variant_print_LIB LIB_GIO
+#define g_settings_schema_source_get_default_LIB LIB_GIO
+#define g_settings_schema_source_lookup_LIB LIB_GIO
// GTK3 only
#define gtk_widget_draw_LIB LIB_GTK
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 670adf8..14313df 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -331,6 +331,11 @@
"_1g_1object_1unref",
"_1g_1quark_1from_1string",
"_1g_1set_1prgname",
+ "_1g_1settings_1get",
+ "_1g_1settings_1get_1value",
+ "_1g_1settings_1new",
+ "_1g_1settings_1schema_1source_1get_1default",
+ "_1g_1settings_1schema_1source_1lookup",
"_1g_1signal_1add_1emission_1hook",
"_1g_1signal_1connect",
"_1g_1signal_1connect_1closure",
@@ -409,6 +414,7 @@
"_1g_1utf8_1to_1utf16___3BJ_3J_3J_3J",
#endif
"_1g_1value_1peek_1pointer",
+ "_1g_1variant_1dict_1lookup_1value",
"_1g_1variant_1get_1boolean",
"_1g_1variant_1get_1child_1value",
"_1g_1variant_1get_1double",
@@ -417,6 +423,11 @@
"_1g_1variant_1get_1type_1string",
"_1g_1variant_1get_1uint64",
"_1g_1variant_1is_1of_1type",
+ "_1g_1variant_1iter_1free",
+ "_1g_1variant_1iter_1init",
+ "_1g_1variant_1iter_1new",
+ "_1g_1variant_1iter_1next",
+ "_1g_1variant_1iter_1next_1value",
"_1g_1variant_1n_1children",
"_1g_1variant_1new_1boolean",
"_1g_1variant_1new_1byte",
@@ -426,6 +437,8 @@
"_1g_1variant_1new_1string",
"_1g_1variant_1new_1tuple",
"_1g_1variant_1new_1uint64",
+ "_1g_1variant_1print",
+ "_1g_1variant_1unref",
"_1gdk_1atom_1intern",
"_1gdk_1atom_1name",
"_1gdk_1beep",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 11fdfe4..cbf1649 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -341,6 +341,11 @@
_1g_1object_1unref_FUNC,
_1g_1quark_1from_1string_FUNC,
_1g_1set_1prgname_FUNC,
+ _1g_1settings_1get_FUNC,
+ _1g_1settings_1get_1value_FUNC,
+ _1g_1settings_1new_FUNC,
+ _1g_1settings_1schema_1source_1get_1default_FUNC,
+ _1g_1settings_1schema_1source_1lookup_FUNC,
_1g_1signal_1add_1emission_1hook_FUNC,
_1g_1signal_1connect_FUNC,
_1g_1signal_1connect_1closure_FUNC,
@@ -419,6 +424,7 @@
_1g_1utf8_1to_1utf16___3BJ_3J_3J_3J_FUNC,
#endif
_1g_1value_1peek_1pointer_FUNC,
+ _1g_1variant_1dict_1lookup_1value_FUNC,
_1g_1variant_1get_1boolean_FUNC,
_1g_1variant_1get_1child_1value_FUNC,
_1g_1variant_1get_1double_FUNC,
@@ -427,6 +433,11 @@
_1g_1variant_1get_1type_1string_FUNC,
_1g_1variant_1get_1uint64_FUNC,
_1g_1variant_1is_1of_1type_FUNC,
+ _1g_1variant_1iter_1free_FUNC,
+ _1g_1variant_1iter_1init_FUNC,
+ _1g_1variant_1iter_1new_FUNC,
+ _1g_1variant_1iter_1next_FUNC,
+ _1g_1variant_1iter_1next_1value_FUNC,
_1g_1variant_1n_1children_FUNC,
_1g_1variant_1new_1boolean_FUNC,
_1g_1variant_1new_1byte_FUNC,
@@ -436,6 +447,8 @@
_1g_1variant_1new_1string_FUNC,
_1g_1variant_1new_1tuple_FUNC,
_1g_1variant_1new_1uint64_FUNC,
+ _1g_1variant_1print_FUNC,
+ _1g_1variant_1unref_FUNC,
_1gdk_1atom_1intern_FUNC,
_1gdk_1atom_1name_FUNC,
_1gdk_1beep_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 353d4b7..9a0230d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -20,6 +20,8 @@
public class OS extends C {
static {
+ String scalingProperty = "GDK_SCALE";
+ OS.setenv(ascii(scalingProperty), ascii("1"), 1);
String propertyName = "SWT_GTK3";
String gtk3 = getEnvironmentalVariable (propertyName);
if (gtk3 != null && gtk3.equals("0")) {
@@ -17073,4 +17075,189 @@
g_object_notify(gtk_settings_get_default(),
gtk_application_prefer_dark_theme);
}
+
+/**
+ * @method flags=dynamic
+ * @param schema_id cast=(const gchar *)
+ */
+public static final native long /*int*/ _g_settings_new (byte[] schema_id);
+public static final long /*int*/ g_settings_new (byte[] schema_id) {
+ lock.lock();
+ try {
+ return _g_settings_new (schema_id);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param settings cast=(GSettings *)
+ * @param key cast=(const gchar *)
+ * @param format = (const gchar *)
+ * @param monitorId = (const gchar *)
+ * @param scalingfactor = (gint *)
+ */
+public static final native void _g_settings_get (long /*int*/ settings, byte[] key, byte[] format, byte[] monitorId, int[] scalingfactor);
+public static final void g_settings_get (long /*int*/ settings, byte[] key, byte[] format, byte[] monitorId, int[] scalingfactor) {
+ lock.lock();
+ try {
+ _g_settings_get (settings, key, format, monitorId, scalingfactor);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param settings cast=(GSettings *)
+ * @param key cast=(const gchar *)
+ */
+public static final native long /*int*/ _g_settings_get_value (long /*int*/ settings, byte[] key);
+public static final long /*int*/ g_settings_get_value (long /*int*/ settings, byte[] key) {
+ lock.lock();
+ try {
+ return _g_settings_get_value (settings, key);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariant *)
+ * @param key cast=(const gchar *)
+ * @param expectedType cast=(const GVariantType *)
+ */
+public static final native long /*int*/ _g_variant_dict_lookup_value (long /*int*/ variant, byte[] key, long /*int*/ expectedType);
+public static final long /*int*/ g_variant_dict_lookup_value (long /*int*/ variant, byte[] key, long /*int*/ expectedType) {
+ lock.lock();
+ try {
+ return _g_variant_dict_lookup_value (variant, key, expectedType);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariant *)
+ */
+public static final native long /*int*/ _g_variant_iter_new (long /*int*/ variant);
+public static final long /*int*/ g_variant_iter_new (long /*int*/ variant) {
+ lock.lock();
+ try {
+ return _g_variant_iter_new (variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariantIter *)
+ */
+public static final native void _g_variant_iter_free (long /*int*/ variant);
+public static final void g_variant_iter_free (long /*int*/ variant) {
+ lock.lock();
+ try {
+ _g_variant_iter_free (variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param iter cast=(GVariantIter *)
+ * @param variant cast=(GVariant *)
+ */
+public static final native int _g_variant_iter_init (long /*int*/ iter, long /*int*/ variant);
+public static final int g_variant_iter_init (long /*int*/ iter, long /*int*/ variant) {
+ lock.lock();
+ try {
+ return _g_variant_iter_init (iter, variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param iter cast=(const GVariantIter *)
+ * @param key cast = (gchar *)
+ * @param format = (const gchar *)
+ * @param value = (GVariant *)
+ */
+public static final native boolean _g_variant_iter_next (long /*int*/ iter, byte[] format, long /*int*/ key, long /*int*/ value);
+public static final boolean g_variant_iter_next (long /*int*/ iter, byte[] format, long /*int*/ key, long /*int*/ value) {
+ lock.lock();
+ try {
+ return _g_variant_iter_next (iter, format, key, value);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param iter cast=(const GVariantIter *)
+ */
+public static final native long /*int*/ _g_variant_iter_next_value (long /*int*/ iter);
+public static final long /*int*/ g_variant_iter_next_value (long /*int*/ iter) {
+ lock.lock();
+ try {
+ return _g_variant_iter_next_value (iter);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param value cast=(const GVariant *)
+ */
+public static final native long /*int*/ _g_variant_print (long /*int*/ value);
+public static final long /*int*/ g_variant_print (long /*int*/ value) {
+ lock.lock();
+ try {
+ return _g_variant_print (value);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariant *)
+ */
+public static final native void _g_variant_unref (long /*int*/ variant);
+public static final void g_variant_unref (long /*int*/ variant) {
+ lock.lock();
+ try {
+ _g_variant_unref (variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ */
+public static final native long /*int*/ _g_settings_schema_source_get_default ();
+public static final long /*int*/ g_settings_schema_source_get_default () {
+ lock.lock();
+ try {
+ return _g_settings_schema_source_get_default ();
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param schemaSource cast = (GSettingsSchemaSource *)
+ * @param schema_id cast = (const gchar *)
+ * @param recursive cast = (gboolean)
+ */
+public static final native long /*int*/ _g_settings_schema_source_lookup (long /*int*/ schemaSource, byte[] schema_id, boolean recursive);
+public static final long /*int*/ g_settings_schema_source_lookup (long /*int*/ schemaSource, byte[] schema_id, boolean recursive) {
+ lock.lock();
+ try {
+ return _g_settings_schema_source_lookup (schemaSource, schema_id, recursive);
+ } finally {
+ lock.unlock();
+ }
+}
+
+
+
}
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 6c7c7b4..932aa25 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 @@
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 @@
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 @@
#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 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
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 @@
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 @@
#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 @@
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 @@
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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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 @@
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 5c15870..bdb2a87 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 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -482,6 +483,11 @@
*/
@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 @@
* @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 b879a47..f48a06d 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 @@
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 @@
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 f5bfd7f..2abf6a1 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 @@
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 @@
// 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 aa6a5a1..b748a7d 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 @@
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 @@
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/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index af64cf0..d65638e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -1554,7 +1554,7 @@
}
void onResize (Event e) {
- Rectangle rect = browser.getClientArea ();
+ Rectangle rect = DPIUtil.autoScaleUp(browser.getClientArea ());
if (WEBKIT2){
OS.gtk_widget_set_size_request (webView, rect.width, rect.height);
} 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 bf2dcb1..f098d8e 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 @@
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 @@
* 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 913398e..0c5869b 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 @@
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/cairo/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
index 63ee440..0855bbf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.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.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
/**
@@ -215,6 +216,14 @@
*/
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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) {
moved = true;
if (width == height) {
float angle = -startAngle * (float)Math.PI / 180;
@@ -280,6 +289,14 @@
*/
public void addRectangle(float x, float y, float width, float height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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) {
moved = false;
Cairo.cairo_rectangle(handle, x, y, width, height);
closed = true;
@@ -306,6 +323,11 @@
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);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ addStringInPixels(string, x, y, font);
+}
+void addStringInPixels(String string, float x, float y, Font font) {
moved = false;
GC.addCairoString(handle, string, x, y, font);
closed = true;
@@ -354,6 +376,11 @@
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);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ return containsInPixels(x, y, gc, outline);
+}
+boolean containsInPixels(float x, float y, GC gc, boolean outline) {
//TODO - see Windows
gc.initCairo();
gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH);
@@ -388,6 +415,13 @@
*/
public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ cx1 = DPIUtil.autoScaleUp(cx1);
+ cy1 = DPIUtil.autoScaleUp(cy1);
+ cx2 = DPIUtil.autoScaleUp(cx2);
+ cy2 = DPIUtil.autoScaleUp(cy2);
+ cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
+}
+void cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (!moved) {
double[] currentX = new double[1], currentY = new double[1];
Cairo.cairo_get_current_point(handle, currentX, currentY);
@@ -417,6 +451,12 @@
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (bounds.length < 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ getBoundsInPixels(bounds);
+ for (int i = 0; i < bounds.length; i++) {
+ bounds [i] = DPIUtil.autoScaleDown(bounds[i]);
+ }
+}
+void getBoundsInPixels(float[] bounds) {
long /*int*/ copy = Cairo.cairo_copy_path(handle);
if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
cairo_path_t path = new cairo_path_t();
@@ -489,6 +529,13 @@
*/
public void getCurrentPoint(float[] point) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ getCurrentPointInPixels(point);
+ for (int i = 0; i < point.length; i++) {
+ point [i] = DPIUtil.autoScaleDown(point[i]);
+ }
+}
+
+void getCurrentPointInPixels(float[] point) {
if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (point.length < 2) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
double[] x = new double[1], y = new double[1];
@@ -584,6 +631,11 @@
*/
public void lineTo(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ lineToInPixels(x, y);
+}
+void lineToInPixels(float x, float y) {
if (!moved) {
double[] currentX = new double[1], currentY = new double[1];
Cairo.cairo_get_current_point(handle, currentX, currentY);
@@ -608,6 +660,11 @@
*/
public void moveTo(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ moveToInPixels(x, y);
+}
+void moveToInPixels(float x, float y) {
/*
* Bug in Cairo. If cairo_move_to() is not called at the
* begining of a subpath, the first cairo_line_to() or
@@ -634,6 +691,13 @@
*/
public void quadTo(float cx, float cy, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ cx = DPIUtil.autoScaleUp(cx);
+ cy = DPIUtil.autoScaleUp(cy);
+ quadToInPixels(cx, cy, x, y);
+}
+void quadToInPixels(float cx, float cy, float x, float y) {
double[] currentX = new double[1], currentY = new double[1];
Cairo.cairo_get_current_point(handle, currentX, currentY);
if (!moved) {
@@ -662,16 +726,16 @@
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();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
index 1791886..82ee23b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
/**
@@ -170,6 +171,10 @@
*/
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/cairo/org/eclipse/swt/graphics/Transform.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java
index fc9f40d..5c29a8d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/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.cairo.*;
/**
@@ -144,7 +145,7 @@
this.device.checkCairo();
handle = new double[6];
if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES);
- Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+ Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
init();
}
@@ -181,8 +182,8 @@
elements[1] = (float)handle[1];
elements[2] = (float)handle[2];
elements[3] = (float)handle[3];
- elements[4] = (float)handle[4];
- elements[5] = (float)handle[5];
+ elements[4] = DPIUtil.autoScaleDown((float)handle[4]);
+ elements[5] = DPIUtil.autoScaleDown((float)handle[5]);
}
/**
@@ -317,7 +318,7 @@
*/
public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+ Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
}
/**
@@ -359,11 +360,11 @@
double[] dx = new double[1], dy = new double[1];
int length = pointArray.length / 2;
for (int i = 0, j = 0; i < length; i++, j += 2) {
- dx[0] = pointArray[j];
- dy[0] = pointArray[j + 1];
+ dx[0] = DPIUtil.autoScaleUp(pointArray[j]);
+ dy[0] = DPIUtil.autoScaleUp(pointArray[j + 1]);
Cairo.cairo_matrix_transform_point(handle, dx, dy);
- pointArray[j] = (float)dx[0];
- pointArray[j + 1] = (float)dy[0];
+ pointArray[j] = DPIUtil.autoScaleDown((float)dx[0]);
+ pointArray[j + 1] = DPIUtil.autoScaleDown((float)dy[0]);
}
}
@@ -380,7 +381,7 @@
*/
public void translate(float offsetX, float offsetY) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Cairo.cairo_matrix_translate(handle, offsetX, offsetY);
+ Cairo.cairo_matrix_translate(handle, DPIUtil.autoScaleUp(offsetX), DPIUtil.autoScaleUp(offsetY));
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
index 62b2dfd..9b6bc2d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
@@ -11,10 +11,11 @@
package org.eclipse.swt.graphics;
-import org.eclipse.swt.internal.cocoa.*;
-import org.eclipse.swt.*;
import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.cocoa.*;
+
/**
* Instances of this class are graphics which have been prepared
* for display on a specific device. That is, they are ready
@@ -834,6 +835,90 @@
}
/**
+ * 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.
+ *
+ * @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() {
+ Rectangle bounds = getBounds();
+ int scaleFactor = (int) NSScreen.mainScreen().backingScaleFactor();
+ bounds.width *= scaleFactor;
+ bounds.height *= scaleFactor;
+ return bounds;
+}
+
+ImageData _getImageData(NSBitmapImageRep imageRep) {
+ long /*int*/ width = imageRep.pixelsWide();
+ long /*int*/ height = imageRep.pixelsHigh();
+ long /*int*/ bpr = imageRep.bytesPerRow();
+ long /*int*/ bpp = imageRep.bitsPerPixel();
+ long /*int*/ bitmapData = imageRep.bitmapData();
+ long /*int*/ bitmapFormat = imageRep.bitmapFormat();
+ long /*int*/ dataSize = height * bpr;
+ byte[] srcData = new byte[(int)/*64*/dataSize];
+ OS.memmove(srcData, bitmapData, dataSize);
+
+ PaletteData palette;
+ if (bpp == 32 && (bitmapFormat & OS.NSAlphaFirstBitmapFormat) == 0) {
+ palette = new PaletteData(0xFF000000, 0xFF0000, 0xFF00);
+ } else {
+ palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
+ }
+ ImageData data = new ImageData((int)/*64*/width, (int)/*64*/height, (int)/*64*/bpp, palette, 1, srcData);
+ data.bytesPerLine = (int)/*64*/bpr;
+ if (imageRep.hasAlpha() && transparentPixel == -1 && alpha == -1 && alphaData == null) {
+ byte[] alphaData = new byte[(int)/*64*/(width * height)];
+ int offset = (bitmapFormat & OS.NSAlphaFirstBitmapFormat) != 0 ? 0 : 3, a = 0;
+ for (int i = offset; i < srcData.length; i+= 4) {
+ alphaData[a++] = srcData[i];
+ }
+ data.alphaData = alphaData;
+ } else {
+ data.transparentPixel = transparentPixel;
+ if (transparentPixel == -1 && type == SWT.ICON) {
+ /* Get the icon mask data */
+ int maskPad = 2;
+ long /*int*/ maskBpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
+ byte[] maskData = new byte[(int)/*64*/(height * maskBpl)];
+ int offset = 0, maskOffset = 0;
+ for (int y = 0; y<height; y++) {
+ for (int x = 0; x<width; x++) {
+ if (srcData[offset] != 0) {
+ maskData[maskOffset + (x >> 3)] |= (1 << (7 - (x & 0x7)));
+ } else {
+ maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
+ }
+ offset += 4;
+ }
+ maskOffset += maskBpl;
+ }
+ data.maskData = maskData;
+ data.maskPad = maskPad;
+ }
+ data.alpha = alpha;
+ if (alpha == -1 && alphaData != null) {
+ data.alphaData = new byte[alphaData.length];
+ System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
+ }
+ }
+ if (bpp == 32) {
+ int offset = (bitmapFormat & OS.NSAlphaFirstBitmapFormat) != 0 ? 0 : 3;
+ for (int i = offset; i < srcData.length; i+= 4) {
+ srcData[i] = 0;
+ }
+ }
+ return data;
+}
+
+/**
* Returns an <code>ImageData</code> based on the receiver
* Modifications made to this <code>ImageData</code> will not
* affect the Image.
@@ -852,67 +937,36 @@
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
- NSBitmapImageRep imageRep = getRepresentation();
- long /*int*/ width = imageRep.pixelsWide();
- long /*int*/ height = imageRep.pixelsHigh();
- long /*int*/ bpr = imageRep.bytesPerRow();
- long /*int*/ bpp = imageRep.bitsPerPixel();
- long /*int*/ bitmapData = imageRep.bitmapData();
- long /*int*/ bitmapFormat = imageRep.bitmapFormat();
- long /*int*/ dataSize = height * bpr;
- byte[] srcData = new byte[(int)/*64*/dataSize];
- OS.memmove(srcData, bitmapData, dataSize);
+ NSBitmapImageRep imageRep = getActualRepresentation();
+ return _getImageData(imageRep);
+ } finally {
+ if (pool != null) pool.release();
+ }
+}
- PaletteData palette;
- if (bpp == 32 && (bitmapFormat & OS.NSAlphaFirstBitmapFormat) == 0) {
- palette = new PaletteData(0xFF000000, 0xFF0000, 0xFF00);
- } else {
- palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
- }
- ImageData data = new ImageData((int)/*64*/width, (int)/*64*/height, (int)/*64*/bpp, palette, 1, srcData);
- data.bytesPerLine = (int)/*64*/bpr;
- if (imageRep.hasAlpha() && transparentPixel == -1 && alpha == -1 && alphaData == null) {
- byte[] alphaData = new byte[(int)/*64*/(width * height)];
- int offset = (bitmapFormat & OS.NSAlphaFirstBitmapFormat) != 0 ? 0 : 3, a = 0;
- for (int i = offset; i < srcData.length; i+= 4) {
- alphaData[a++] = srcData[i];
- }
- data.alphaData = alphaData;
- } else {
- data.transparentPixel = transparentPixel;
- if (transparentPixel == -1 && type == SWT.ICON) {
- /* Get the icon mask data */
- int maskPad = 2;
- long /*int*/ maskBpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
- byte[] maskData = new byte[(int)/*64*/(height * maskBpl)];
- int offset = 0, maskOffset = 0;
- for (int y = 0; y<height; y++) {
- for (int x = 0; x<width; x++) {
- if (srcData[offset] != 0) {
- maskData[maskOffset + (x >> 3)] |= (1 << (7 - (x & 0x7)));
- } else {
- maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
- }
- offset += 4;
- }
- maskOffset += maskBpl;
- }
- data.maskData = maskData;
- data.maskPad = maskPad;
- }
- data.alpha = alpha;
- if (alpha == -1 && alphaData != null) {
- data.alphaData = new byte[alphaData.length];
- System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
- }
- }
- if (bpp == 32) {
- int offset = (bitmapFormat & OS.NSAlphaFirstBitmapFormat) != 0 ? 0 : 3;
- for (int i = offset; i < srcData.length; i+= 4) {
- srcData[i] = 0;
- }
- }
- return data;
+/**
+ * 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);
+ NSAutoreleasePool pool = null;
+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+ try {
+ NSBitmapImageRep imageRep = getRepresentation();
+ return _getImageData(imageRep);
} finally {
if (pool != null) pool.release();
}
@@ -941,6 +995,21 @@
return image;
}
+// Method to get the Image representation for the actual image without any scaling.
+NSBitmapImageRep getActualRepresentation () {
+ NSArray reps = handle.representations();
+ NSSize size = handle.size();
+ long /*int*/ count = reps.count();
+ NSBitmapImageRep bestRep = null;
+ for (int i = 0; i < count; i++) {
+ NSBitmapImageRep rep = new NSBitmapImageRep(reps.objectAtIndex(i));
+ if (bestRep == null || ((int)size.width == rep.pixelsWide() && (int)size.height == rep.pixelsHigh())) {
+ bestRep = rep;
+ }
+ }
+ return bestRep;
+}
+
NSBitmapImageRep getRepresentation () {
NSBitmapImageRep rep = new NSBitmapImageRep(handle.bestRepresentationForDevice(null));
if (rep.isKindOfClass(OS.class_NSBitmapImageRep)) {
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 016e1a0..0000000
--- 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 50d5a4d..4e6582b 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 @@
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 a2fc32e..10775da 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 @@
import java.io.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
/**
* Instances of this class are device-independent descriptions
@@ -3654,20 +3655,26 @@
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 0000000..f54865d
--- /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 f5b2206..0e213a6 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 @@
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 double rotation;
-
/**
* Gets the bounds.
*
@@ -274,6 +274,17 @@
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 @@
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 787e0d4..b797fd8 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 @@
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/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index eb29d04..e129711 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -25,6 +25,17 @@
*/
public abstract class Device implements Drawable {
/**
+ * @noreference This field is not intended to be referenced by clients.
+ * @since 3.105
+ */
+ protected static final int CHANGE_SCALEFACTOR = 1;
+ /* Settings callbacks */
+ long /*int*/ gsettingsProc;
+ Callback gsettingsCallback;
+ boolean isConnected = false;
+ long /*int*/ displaySettings; //gsettings Dictionary
+
+ /**
* the handle to the X Display
* (Warning: This field is platform dependent)
* <p>
@@ -82,6 +93,13 @@
/* Device dpi */
Point dpi;
+ /*Device Scale Factor in percentage*/
+ /**
+ * @noreference This field is not intended to be referenced by clients.
+ * @since 3.105
+ */
+ protected int scaleFactor;
+
long /*int*/ emptyTab;
boolean useXRender;
@@ -316,6 +334,10 @@
*/
public Rectangle getBounds () {
checkDevice ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+private Rectangle getBoundsInPixels () {
return new Rectangle(0, 0, 0, 0);
}
@@ -375,7 +397,11 @@
*/
public Rectangle getClientArea () {
checkDevice ();
- return getBounds ();
+ return DPIUtil.autoScaleDown (getClientAreaInPixels ());
+}
+
+private Rectangle getClientAreaInPixels () {
+ return getBoundsInPixels ();
}
/**
@@ -579,6 +605,8 @@
*/
protected void init () {
this.dpi = getDPI();
+ this.scaleFactor = getDeviceZoom ();
+ DPIUtil.setDeviceZoom (scaleFactor);
if (xDisplay != 0 && !OS.USE_CAIRO) {
int[] event_basep = new int[1], error_basep = new int [1];
@@ -910,6 +938,11 @@
handler_ids = null; log_domains = null;
logProc = 0;
}
+ /* Dispose the settings callback */
+ gsettingsCallback.dispose(); gsettingsCallback = null;
+ gsettingsProc = 0;
+
+
}
/**
@@ -991,13 +1024,80 @@
* @return the horizontal DPI
*/
int _getDPIx () {
+ return scaleFactor * 96/100;
+}
+/**
+ * Gets the scaling factor from the device and calculates the zoom level.
+ * @return zoom in percentage
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ * @since 3.105
+ */
+protected int getDeviceZoom() {
long /*int*/ screen = OS.gdk_screen_get_default();
int monitor = OS.gdk_screen_get_monitor_at_point(screen, 0, 0);
- GdkRectangle dest = new GdkRectangle ();
- OS.gdk_screen_get_monitor_geometry(screen, monitor, dest);
- int widthMM = OS.gdk_screen_get_monitor_width_mm(screen, monitor);
- return Compatibility.round (254 * dest.width, widthMM * 10);
+ final String schemaId = "com.ubuntu.user-interface";
+ final String key = "scale-factor";
+ int fontHeight = 0;
+ byte[] schema_id = Converter.wcsToMbcs (null, schemaId, true);
+ long /*int*/ schemaSource = OS.g_settings_schema_source_get_default ();
+ if (OS.g_settings_schema_source_lookup(schemaSource, schema_id, false) != 0) {
+ displaySettings = OS.g_settings_new (schema_id);
+ byte[] keyString = Converter.wcsToMbcs (null, key, true);
+ long /*int*/ settingsDict = OS.g_settings_get_value (displaySettings, keyString);
+ long /*int*/ keyArray = 0;
+ if (!isConnected) {
+ gsettingsCallback = new Callback (this, "gsettingsProc", 3); //$NON-NLS-1$
+ gsettingsProc = gsettingsCallback.getAddress ();
+ if (gsettingsProc == 0) {
+ SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ }
+ int retVal = OS.g_signal_connect (displaySettings, OS.changed, gsettingsProc, CHANGE_SCALEFACTOR);
+ if (retVal > 0) {
+ isConnected = true;
+ }
+ }
+
+
+ long /*int*/ iter = OS.g_variant_iter_new (settingsDict);
+ int size = OS.g_variant_iter_init(iter, settingsDict);
+ for (int i =0; i<size; i++) {
+ long /*int*/ iterValue = OS.g_variant_iter_next_value(iter);
+ keyArray = OS.g_variant_print(iterValue);
+ int len = OS.strlen(keyArray);
+ byte[] buffer = new byte [len];
+ OS.memmove (buffer, keyArray, len);
+ String type = new String(Converter.mbcsToWcs(null, buffer));
+ int index = type.indexOf(",");
+ String height = type.substring((index + 1), (type.length() - 1));
+ fontHeight = Math.max(fontHeight, Integer.valueOf(height.trim()));
+ OS.g_free(keyArray);
+ OS.g_variant_unref(iterValue);
+ }
+
+ OS.g_variant_iter_free(iter);
+ return DPIUtil.mapSFToZoom(fontHeight/ 8f);
+ } else {
+ GdkRectangle dest = new GdkRectangle ();
+ OS.gdk_screen_get_monitor_geometry(screen, monitor, dest);
+ int widthMM = OS.gdk_screen_get_monitor_width_mm(screen, monitor);
+ return (DPIUtil.mapDPIToZoom(Compatibility.round (254 * dest.width, widthMM * 10)));
+ }
+}
+/**
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ * @since 3.105
+ */
+protected long /*int*/ gsettingsProc (long /*int*/ gobject, long /*int*/ arg1, long /*int*/ user_data) {
+ switch((int)/*64*/user_data) {
+ case CHANGE_SCALEFACTOR:
+ this.scaleFactor = getDeviceZoom ();
+ DPIUtil.setDeviceZoom (scaleFactor);
+ }
+ return 0;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
index 555eebc..c5426d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
+import org.eclipse.swt.internal.*;
/**
* Instances of this class provide measurement information
@@ -56,7 +57,7 @@
* @return the ascent of the font
*/
public int getAscent() {
- return ascent;
+ return DPIUtil.autoScaleDown(ascent);
}
/**
@@ -66,7 +67,7 @@
* @return the average character width of the font
*/
public int getAverageCharWidth() {
- return averageCharWidth;
+ return DPIUtil.autoScaleDown(averageCharWidth);
}
/**
@@ -78,7 +79,7 @@
* @return the descent of the font
*/
public int getDescent() {
- return descent;
+ return DPIUtil.autoScaleDown(descent);
}
/**
@@ -93,7 +94,7 @@
* @see #getLeading
*/
public int getHeight() {
- return height;
+ return DPIUtil.autoScaleDown(height);
}
/**
@@ -104,7 +105,7 @@
* @return the leading space of the font
*/
public int getLeading() {
- return leading;
+ return DPIUtil.autoScaleDown(leading);
}
public static FontMetrics gtk_new(int ascent, int descent, int averageCharWidth, int leading, int height) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index de06b27..c7ae51f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -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
@@ -15,6 +15,7 @@
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
/**
* Class <code>GC</code> is where all of the drawing capabilities that are
@@ -297,7 +298,7 @@
Cairo.cairo_set_line_join(cairo, join_style);
}
if ((state & LINE_WIDTH) != 0) {
- Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? 1 : data.lineWidth);
+ Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? DPIUtil.autoScaleUp(1) : data.lineWidth);
switch (data.lineStyle) {
case SWT.LINE_DOT:
case SWT.LINE_DASH:
@@ -477,6 +478,10 @@
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ copyAreaInPixels(image, loc.x, loc.y);
+}
+void copyAreaInPixels(Image image, int x, int y) {
if (OS.USE_CAIRO) {
long /*int*/ cairo = Cairo.cairo_create(image.surface);
if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
@@ -508,7 +513,7 @@
Cairo.cairo_destroy(cairo);
return;
}
- Rectangle rect = image.getBounds();
+ Rectangle rect = image.getBoundsInPixels();
long /*int*/ gdkGC = OS.gdk_gc_new(image.pixmap);
if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.gdk_gc_set_subwindow(gdkGC, OS.GDK_INCLUDE_INFERIORS);
@@ -532,7 +537,14 @@
* </ul>
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
- copyArea(srcX, srcY, width, height, destX, destY, true);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle src = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, width, height));
+ Point dest = DPIUtil.autoScaleUp(new Point(destX, destY));
+ copyAreaInPixels(src.x, src.y, src.width, src.height, dest.x, dest.y);
+}
+
+void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY) {
+ copyAreaInPixels(srcX, srcY, width, height, destX, destY, true);
}
/**
* Copies a rectangular area of the receiver at the source
@@ -554,6 +566,11 @@
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle srcLoc = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, width, height));
+ Point destLoc = DPIUtil.autoScaleUp(new Point(destX, destY));
+ copyAreaInPixels(srcLoc.x, srcLoc.y, srcLoc.width, srcLoc.height, destLoc.x, destLoc.y, paint);
+}
+void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
if (width <= 0 || height <= 0) return;
int deltaX = destX - srcX, deltaY = destY - srcY;
if (deltaX == 0 && deltaY == 0) return;
@@ -722,6 +739,10 @@
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle loc = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ drawArcInPixels(loc.x, loc.y, loc.width, loc.height, startAngle, arcAngle);
+}
+void drawArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) {
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -777,6 +798,10 @@
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle loc = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ drawFocusInPixels(loc.x, loc.y, loc.width, loc.height);
+}
+void drawFocusInPixels(int x, int y, int width, int height) {
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
checkGC(FOREGROUND);
@@ -831,6 +856,10 @@
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ drawImageInPixels(image, loc.x, loc.y);
+}
+void drawImageInPixels(Image image, int x, int y) {
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
@@ -846,12 +875,12 @@
* @param image the source image
* @param srcX the x coordinate in the source image to copy from
* @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
+ * @param srcWidth the width in points to copy from the source
+ * @param srcHeight the height in points to copy from the source
* @param destX the x coordinate in the destination to copy to
* @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
+ * @param destWidth the width in points of the destination rectangle
+ * @param destHeight the height in points of the destination rectangle
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
@@ -874,9 +903,10 @@
}
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+ Rectangle srcRect = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, srcWidth, srcHeight));
+ Rectangle destRect = DPIUtil.autoScaleUp(new Rectangle(destX, destY, destWidth, destHeight));
+ drawImage(image, srcRect.x, srcRect.y, srcRect.width, srcRect.height, destRect.x, destRect.y, destRect.width, destRect.height, false);
}
-
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
/* Refresh Image as per zoom level, if required. */
srcImage.refreshImageForZoom ();
@@ -903,7 +933,7 @@
simple = srcX == 0 && srcY == 0 &&
srcWidth == destWidth && destWidth == imgWidth &&
srcHeight == destHeight && destHeight == imgHeight;
- if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
+ if (srcX + srcWidth > imgWidth + 1 || srcY + srcHeight > imgHeight + 1) { //rounding error correction for hidpi
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
}
@@ -1256,6 +1286,11 @@
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Point loc1 = DPIUtil.autoScaleUp(new Point(x1, y1));
+ Point loc2 = DPIUtil.autoScaleUp(new Point(x2, y2));
+ drawLineInPixels(loc1.x, loc1.y, loc2.x, loc2.y);
+}
+void drawLineInPixels(int x1, int y1, int x2, int y2) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1291,6 +1326,10 @@
*/
public void drawOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ drawOvalInPixels(rect.x, rect.y, rect.width, rect.height);
+}
+void drawOvalInPixels(int x, int y, int width, int height) {
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -1378,6 +1417,10 @@
*/
public void drawPoint (int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ drawPointInPixels(loc.x, loc.y);
+}
+void drawPointInPixels (int x, int y) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1408,6 +1451,10 @@
public void drawPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ drawPolygonInPixels(scaledPointArray);
+}
+void drawPolygonInPixels(int[] pointArray) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1438,6 +1485,10 @@
public void drawPolyline(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ drawPolylineInPixels(scaledPointArray);
+}
+void drawPolylineInPixels(int[] pointArray) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1476,6 +1527,9 @@
*/
public void drawRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ drawRectangle(new Rectangle(x, y, width, height));
+}
+void drawRectangleInPixels(int x, int y, int width, int height) {
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -1513,7 +1567,10 @@
*/
public void drawRectangle(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangle (rect.x, rect.y, rect.width, rect.height);
+ drawRectangleInPixels(DPIUtil.autoScaleUp(rect));
+}
+void drawRectangleInPixels(Rectangle rect) {
+ drawRectangleInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
* Draws the outline of the round-cornered rectangle specified by
@@ -1538,6 +1595,11 @@
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Point arcSize = DPIUtil.autoScaleUp(new Point(arcWidth, arcHeight));
+ drawRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y);
+}
+void drawRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) {
checkGC(DRAW);
int nx = x;
int ny = y;
@@ -1629,7 +1691,13 @@
* </ul>
*/
public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawString (string, x, y, false);
+}
+
+void drawStringInPixels (String string, int x, int y) {
+ drawStringInPixels(string, x, y, false);
}
/**
* Draws the given string, using the receiver's current font and
@@ -1652,7 +1720,14 @@
* </ul>
*/
public void drawString(String string, int x, int y, boolean isTransparent) {
- drawText(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ drawStringInPixels(string, loc.x, loc.y, isTransparent);
+}
+
+void drawStringInPixels(String string, int x, int y, boolean isTransparent) {
+ drawTextInPixels(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
}
/**
@@ -1676,6 +1751,9 @@
public void drawText(String string, int x, int y) {
drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
+void drawTextInPixels(String string, int x, int y) {
+ drawTextInPixels(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
/**
* Draws the given string, using the receiver's current font and
@@ -1698,9 +1776,13 @@
* </ul>
*/
public void drawText(String string, int x, int y, boolean isTransparent) {
+ Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ drawTextInPixels(string, loc.x, loc.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);
}
/**
@@ -1738,6 +1820,10 @@
* </ul>
*/
public void drawText (String string, int x, int y, int flags) {
+ Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ drawTextInPixels(string, loc.x, loc.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;
@@ -1846,6 +1932,10 @@
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ fillArcInPixels(rect.x, rect.y, rect.width, rect.height, startAngle, arcAngle);
+}
+void fillArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) {
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -1905,6 +1995,11 @@
*/
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ fillGradientRectangleInPixels(rect.x, rect.y, rect.width, rect.height, vertical);
+}
+
+void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean vertical) {
if ((width == 0) || (height == 0)) return;
/* Rewrite this to use GdkPixbuf */
@@ -1930,7 +2025,7 @@
toRGB = foregroundRGB;
}
if (fromRGB.equals(toRGB)) {
- fillRectangle(x, y, width, height);
+ fillRectangleInPixels(x, y, width, height);
return;
}
long /*int*/ cairo = data.cairo;
@@ -1954,8 +2049,9 @@
return;
}
ImageData.fillGradientRectangle(this, data.device,
- x, y, width, height, vertical, fromRGB, toRGB,
- 8, 8, 8);
+ DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y),
+ DPIUtil.autoScaleDown(width), DPIUtil.autoScaleDown(height),
+ vertical, fromRGB, toRGB, 8, 8, 8);
}
/**
@@ -1976,6 +2072,10 @@
*/
public void fillOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ fillOvalInPixels(rect.x, rect.y, rect.width, rect.height);
+}
+void fillOvalInPixels(int x, int y, int width, int height) {
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -2061,6 +2161,10 @@
public void fillPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ fillPolygonInPixels(scaledPointArray);
+}
+void fillPolygonInPixels(int[] pointArray) {
checkGC(FILL);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -2088,6 +2192,9 @@
*/
public void fillRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ fillRectangle(new Rectangle(x, y, width, height));
+}
+void fillRectangleInPixels(int x, int y, int width, int height) {
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -2124,7 +2231,10 @@
public void fillRectangle(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- fillRectangle(rect.x, rect.y, rect.width, rect.height);
+ fillRectangleInPixels(DPIUtil.autoScaleUp(rect));
+}
+void fillRectangleInPixels(Rectangle rect) {
+ fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -2146,6 +2256,11 @@
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Point arcSize = DPIUtil.autoScaleUp(new Point(arcWidth, arcHeight));
+ fillRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y);
+}
+void fillRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) {
checkGC(FILL);
int nx = x;
int ny = y;
@@ -2247,7 +2362,7 @@
public int getAdvanceWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
- return stringExtent(new String(new char[]{ch})).x;
+ return stringExtentInPixels(new String(new char[]{ch})).x;
}
/**
@@ -2378,7 +2493,7 @@
public int getCharWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
- return stringExtent(new String(new char[]{ch})).x;
+ return stringExtentInPixels(new String(new char[]{ch})).x;
}
/**
@@ -2395,6 +2510,9 @@
*/
public Rectangle getClipping() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleDown(getClippingInPixels());
+}
+Rectangle getClippingInPixels() {
/* Calculate visible bounds in device space */
int x = 0, y = 0, width = 0, height = 0;
int[] w = new int[1], h = new int[1];
@@ -2651,6 +2769,11 @@
*/
public LineAttributes getLineAttributes() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ LineAttributes attributes = getLineAttributesInPixels();
+ attributes.width = DPIUtil.autoScaleDown(attributes.width);
+ return attributes;
+}
+LineAttributes getLineAttributesInPixels() {
float[] dashes = null;
if (data.lineDashes != null) {
dashes = new float[data.lineDashes.length];
@@ -2748,6 +2871,9 @@
*/
public int getLineWidth() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (int)DPIUtil.autoScaleDown(data.lineWidth);
+}
+int getLineWidthInPixels() {
return (int)data.lineWidth;
}
@@ -3330,6 +3456,9 @@
*/
public void setClipping(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ setClippingInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+void setClippingInPixels(int x, int y, int width, int height) {
if (width < 0) {
x = x + width;
width = -width;
@@ -3405,13 +3534,16 @@
*/
public void setClipping(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0)) {
- return;
+ setClippingInPixels(DPIUtil.autoScaleUp(rect));
+}
+void setClippingInPixels(Rectangle rect) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && (drawable instanceof Tree || drawable instanceof Table)) {
+ return; //FIXME: This is an atrocious hack for bug 446075
}
if (rect == null) {
setClipping(0);
} else {
- setClipping(rect.x, rect.y, rect.width, rect.height);
+ setClippingInPixels(rect.x, rect.y, rect.width, rect.height);
}
}
/**
@@ -3619,6 +3751,9 @@
public void setLineAttributes(LineAttributes attributes) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ attributes.width = DPIUtil.autoScaleUp(attributes.width);
+}
+void setLineAttributesInPixels(LineAttributes attributes) {
int mask = 0;
float lineWidth = attributes.width;
if (lineWidth != data.lineWidth) {
@@ -3867,6 +4002,9 @@
*/
public void setLineWidth(int lineWidth) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ setLineWidthInPixels(DPIUtil.autoScaleUp(lineWidth));
+}
+void setLineWidthInPixels(int lineWidth) {
if (data.lineWidth == lineWidth) return;
data.lineWidth = lineWidth;
data.state &= ~(LINE_WIDTH | DRAW_OFFSET);
@@ -4037,7 +4175,6 @@
}
data.xorMode = xor;
}
-
/**
* Returns the extent of the given string. No tab
* expansion or carriage return processing will be performed.
@@ -4058,7 +4195,10 @@
* </ul>
*/
public Point stringExtent(String string) {
- return textExtent(string, 0);
+ return DPIUtil.autoScaleDown(stringExtentInPixels(string));
+}
+Point stringExtentInPixels(String string) {
+ return textExtentInPixels(string, 0);
}
/**
@@ -4081,7 +4221,11 @@
* </ul>
*/
public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+ return DPIUtil.autoScaleDown(textExtentInPixels(string));
+}
+
+Point textExtentInPixels(String string) {
+ return textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
@@ -4118,6 +4262,9 @@
public Point textExtent(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return DPIUtil.autoScaleDown(textExtentInPixels(string, flags));
+}
+Point textExtentInPixels(String string, int flags) {
setString(string, flags);
checkGC(FONT);
if (data.stringWidth == -1) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index 7d2ca6b..c593caa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -164,20 +164,21 @@
/**
* 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;
Image(Device device) {
super(device);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
}
/**
@@ -217,7 +218,9 @@
*/
public Image(Device device, int width, int height) {
super(device);
- init(width, height);
+ Point size = DPIUtil.autoScaleUp(new Point(width, height));
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ init(size.x, size.y);
init();
}
@@ -383,6 +386,7 @@
}
}
init();
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
return;
}
@@ -502,6 +506,7 @@
OS.g_object_unref(gdkGC);
}
init();
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
}
/**
@@ -542,7 +547,9 @@
public Image(Device device, Rectangle bounds) {
super(device);
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(bounds.width, bounds.height);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ Rectangle bounds1 = DPIUtil.autoScaleUp (bounds);
+ init(bounds1.width, bounds1.height);
init();
}
@@ -571,6 +578,9 @@
*/
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();
}
@@ -612,6 +622,9 @@
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);
ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
image.maskPad = mask.scanlinePad;
@@ -675,7 +688,10 @@
*/
public Image(Device device, InputStream stream) {
super(device);
- init(new ImageData(stream));
+ ImageData data = new ImageData(stream);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ data = DPIUtil.autoScaleUp (data);
+ init(data);
init();
}
@@ -714,8 +730,11 @@
public Image(Device device, String filename) {
super(device);
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- initNative(filename);
- if (this.pixmap == 0 && this.surface == 0) init(new ImageData(filename));
+
+ ImageData data = new ImageData(filename);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ data = DPIUtil.autoScaleUp (data);
+ init(data);
init();
}
@@ -751,10 +770,20 @@
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.pixmap == 0 && this.surface == 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.pixmap == 0 && this.surface == 0) {
+ ImageData data = new ImageData(filename);
+ init(data);
+ }
+ } else {
+ ImageData imageData = new ImageData (filename);
+ ImageData resizedData = DPIUtil.autoScaleUp (imageData);
+ init(resizedData);
+ }
init ();
}
@@ -790,16 +819,18 @@
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.
*
@@ -807,8 +838,9 @@
*/
boolean refreshImageForZoom () {
boolean refreshed = false;
+ int deviceZoom = DPIUtil.getDeviceZoom();
if (imageFileNameProvider != null) {
- int deviceZoomLevel = getDeviceZoom();
+ int deviceZoomLevel = deviceZoom;
if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, deviceZoomLevel, found);
@@ -817,14 +849,26 @@
/* Release current native resources */
destroy ();
initNative(filename);
- if (this.pixmap == 0 && this.surface == 0) init(new ImageData(filename));
+ if (this.pixmap == 0 && this.surface == 0) {
+ ImageData data = new ImageData(filename);
+ init(data);
+ }
+ init ();
+ refreshed = true;
+ }
+ if (!found[0]) {
+ /* Release current native resources */
+ destroy ();
+ ImageData imageData = new ImageData (filename);
+ ImageData resizedData = DPIUtil.autoScaleUp (imageData);
+ init(resizedData);
init ();
refreshed = true;
}
currentDeviceZoom = deviceZoomLevel;
}
} else if (imageDataProvider != null) {
- int deviceZoomLevel = getDeviceZoom();
+ int deviceZoomLevel = deviceZoom;
if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
ImageData data = DPIUtil.validateAndGetImageDataAtZoom (imageDataProvider, deviceZoomLevel, found);
@@ -836,6 +880,25 @@
init();
refreshed = true;
}
+ if (!found[0]) {
+ /* Release current native resources */
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleImageData(data, deviceZoomLevel, 100);
+ init(resizedData);
+ init();
+ refreshed = true;
+ }
+ currentDeviceZoom = deviceZoomLevel;
+ }
+ } else {
+ int deviceZoomLevel = deviceZoom;
+ if (deviceZoomLevel != currentDeviceZoom) {
+ ImageData data = getImageDataAtCurrentZoom();
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleImageData(data, deviceZoomLevel, currentDeviceZoom);
+ init(resizedData);
+ init();
+ refreshed = true;
currentDeviceZoom = deviceZoomLevel;
}
}
@@ -1023,7 +1086,7 @@
return;
}
if (mask != 0) return;
- mask = createMask(getImageData(), false);
+ mask = createMask(getImageDataAtCurrentZoom(), false);
if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
}
@@ -1242,13 +1305,12 @@
//NOT DONE
return null;
}
-
/**
* 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.
*
- * @return a rectangle specifying the image's bounds
+ * @return a rectangle specifying the image's bounds in points
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
@@ -1257,6 +1319,24 @@
*/
public Rectangle getBounds() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleBounds(getBoundsInPixels(), 100, currentDeviceZoom);
+}
+
+/**
+ * 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);
}
@@ -1283,7 +1363,29 @@
*
* @see ImageData
*/
-public ImageData getImageData() {
+public ImageData getImageData () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return getImageData(100);
+
+}
+
+/**
+ * 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);
if (OS.USE_CAIRO) {
@@ -1396,6 +1498,32 @@
}
/**
+ * Returns an <code>ImageData</code> for specified zoom, based on the receiver
+ * Modifications made to this <code>ImageData</code> will not affect the
+ * Image.
+ *
+ * @param zoom
+ * The zoom level in % of the standard resolution (which is 1
+ * physical monitor pixel == 1 SWT logical pixel). Typically 100,
+ * 150, or 200.
+ * @return an <code>ImageData</code> containing the image's data and
+ * attributes at specified zoom if present else null is returned.
+ *
+ * @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
+ */
+ImageData getImageData (int zoom) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleImageData (getImageDataAtCurrentZoom (), zoom, currentDeviceZoom);
+}
+
+/**
* Invokes platform specific functionality to allocate a new image.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
index 096cd33..d629618 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.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,9 +11,10 @@
package org.eclipse.swt.graphics;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
/**
* Instances of this class represent areas of an x-y coordinate
@@ -160,6 +161,9 @@
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) {
/*
* Bug in GTK. If gdk_region_polygon() is called with one point,
* it segment faults. The fix is to make sure that it is called
@@ -188,7 +192,10 @@
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);
+ addInPixels(DPIUtil.autoScaleUp(rect));
+}
+void addInPixels(Rectangle rect) {
+ addInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -212,6 +219,9 @@
public void add(int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ add(new Rectangle(x, y, width, height));
+}
+void addInPixels(int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -257,6 +267,9 @@
*/
public boolean contains(int x, int y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return contains(new Point(x, y));
+}
+boolean containsInPixels(int x, int y) {
return OS.gdk_region_point_in(handle, x, y);
}
@@ -276,8 +289,12 @@
* </ul>
*/
public boolean contains(Point pt) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return containsInPixels(DPIUtil.autoScaleUp(pt));
+}
+boolean containsInPixels(Point pt) {
if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
+ return containsInPixels(pt.x, pt.y);
}
@Override
@@ -319,6 +336,9 @@
*/
public Rectangle getBounds() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+Rectangle getBoundsInPixels() {
GdkRectangle gdkRect = new GdkRectangle();
OS.gdk_region_get_clipbox(handle, gdkRect);
return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height);
@@ -378,7 +398,11 @@
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);
+ intersectInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+void intersectInPixels(Rectangle rect) {
+ intersectInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -402,6 +426,10 @@
public void intersect(int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ intersect(new Rectangle(x, y, width, height));
+}
+
+void intersectInPixels(int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -455,6 +483,10 @@
*/
public boolean intersects (int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return intersects(new Rectangle(x, y, width, height));
+}
+
+boolean intersectsInPixels (int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -481,7 +513,11 @@
*/
public boolean intersects(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return intersects(rect.x, rect.y, rect.width, rect.height);
+ return intersectsInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+boolean intersectsInPixels(Rectangle rect) {
+ return intersectsInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -533,6 +569,10 @@
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) {
/*
* Bug in GTK. If gdk_region_polygon() is called with one point,
* it segment faults. The fix is to make sure that it is called
@@ -543,7 +583,6 @@
OS.gdk_region_subtract(handle, polyRgn);
OS.gdk_region_destroy(polyRgn);
}
-
/**
* Subtracts the given rectangle from the collection of polygons
* the receiver maintains to describe its area.
@@ -563,7 +602,11 @@
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);
+ subtractInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+void subtractInPixels(Rectangle rect) {
+ subtractInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -587,6 +630,10 @@
public void subtract(int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ subtract(new Rectangle(x, y, width, height));
+}
+
+void subtractInPixels(int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -636,6 +683,10 @@
*/
public void translate (int x, int y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ translate(new Point(x, y));
+}
+
+void translateInPixels (int x, int y) {
OS.gdk_region_offset (handle, x, y);
}
@@ -657,7 +708,11 @@
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);
+ translate(DPIUtil.autoScaleUp(pt));
+}
+
+void translateInPixels (Point pt) {
+ translateInPixels (pt.x, pt.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
index 2c11cb8..52c8c6e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
@@ -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
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
+import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
/**
* <code>TextLayout</code> is a graphic object that represents
@@ -367,7 +367,13 @@
* </ul>
*/
public void draw(GC gc, int x, int y) {
- draw(gc, x, y, -1, -1, null, null);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawInPixels(gc, x, y);
+}
+
+void drawInPixels(GC gc, int x, int y) {
+ drawInPixels(gc, x, y, -1, -1, null, null);
}
/**
@@ -390,7 +396,13 @@
* </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 ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground);
+}
+void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
}
/**
@@ -422,6 +434,12 @@
*/
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
checkLayout ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, flags);
+}
+void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
+ checkLayout ();
computeRuns();
if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -776,6 +794,10 @@
*/
public Rectangle getBounds() {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+Rectangle getBoundsInPixels() {
+ checkLayout();
computeRuns();
int[] w = new int[1], h = new int[1];
OS.pango_layout_get_size(layout, w, h);
@@ -806,6 +828,11 @@
*/
public Rectangle getBounds(int start, int end) {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels(start, end));
+}
+
+Rectangle getBoundsInPixels(int start, int end) {
+ checkLayout();
computeRuns();
int length = text.length();
if (length == 0) return new Rectangle(0, 0, 0, 0);
@@ -910,6 +937,10 @@
*/
public int getIndent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getIndentInPixels());
+}
+
+int getIndentInPixels () {
return indent;
}
@@ -988,6 +1019,10 @@
*/
public Rectangle getLineBounds(int lineIndex) {
checkLayout();
+ return DPIUtil.autoScaleDown(getLineBoundsInPixels(lineIndex));
+}
+
+Rectangle getLineBoundsInPixels(int lineIndex) {
computeRuns();
int lineCount = OS.pango_layout_get_line_count(layout);
if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE);
@@ -1147,6 +1182,10 @@
*/
public Point getLocation(int offset, boolean trailing) {
checkLayout();
+ return DPIUtil.autoScaleDown(getLocationInPixels(offset, trailing));
+}
+
+Point getLocationInPixels(int offset, boolean trailing) {
computeRuns();
int length = text.length();
if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
@@ -1282,8 +1321,12 @@
*/
public int getOffset(Point point, int[] trailing) {
checkLayout();
+ return getOffsetInPixels(DPIUtil.autoScaleUp(point), trailing);
+}
+
+int getOffsetInPixels(Point point, int[] trailing) {
if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return getOffset(point.x, point.y, trailing);
+ return getOffsetInPixels(point.x, point.y, trailing);
}
/**
@@ -1311,6 +1354,10 @@
*/
public int getOffset(int x, int y, int[] trailing) {
checkLayout();
+ return getOffset(new Point(x, y), trailing);
+}
+
+int getOffsetInPixels(int x, int y, int[] trailing) {
computeRuns();
if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
x -= Math.min (indent, wrapIndent);
@@ -1500,6 +1547,10 @@
*/
public int getSpacing () {
checkLayout();
+ return DPIUtil.autoScaleDown(getSpacingInPixels());
+}
+
+int getSpacingInPixels () {
return OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout));
}
@@ -1613,6 +1664,10 @@
*/
public int getWidth () {
checkLayout ();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
return wrapWidth;
}
@@ -1629,6 +1684,9 @@
*/
public int getWrapIndent () {
checkLayout ();
+ return DPIUtil.autoScaleDown(getWrapIndentInPixels());
+}
+int getWrapIndentInPixels () {
return wrapIndent;
}
@@ -1780,6 +1838,11 @@
* @since 3.2
*/
public void setIndent (int indent) {
+ checkLayout ();
+ setIndentInPixels(DPIUtil.autoScaleUp(indent));
+}
+
+void setIndentInPixels (int indent) {
checkLayout();
if (indent < 0) return;
if (this.indent == indent) return;
@@ -1849,6 +1912,10 @@
public void setSpacing (int spacing) {
checkLayout();
if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+}
+
+void setSpacingInPixels (int spacing) {
OS.pango_layout_set_spacing(layout, spacing * OS.PANGO_SCALE);
}
@@ -2146,6 +2213,10 @@
public void setWidth (int width) {
checkLayout ();
if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
if (wrapWidth == width) return;
freeRuns();
wrapWidth = width;
@@ -2180,6 +2251,10 @@
public void setWrapIndent (int wrapIndent) {
checkLayout();
if (wrapIndent < 0) return;
+ setWrapIndentInPixels(DPIUtil.autoScaleUp(wrapIndent));
+}
+
+void setWrapIndentInPixels (int wrapIndent) {
if (this.wrapIndent == wrapIndent) return;
this.wrapIndent = wrapIndent;
OS.pango_layout_set_indent(layout, (indent - wrapIndent) * OS.PANGO_SCALE);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
index 60c30d1..1d919cd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.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,10 +11,10 @@
package org.eclipse.swt.internal;
-import org.eclipse.swt.SWT;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
public class ImageList {
long /*int*/ [] pixbufs;
@@ -30,7 +30,7 @@
long /*int*/ newSurface = image.surface;
int type = Cairo.cairo_surface_get_type(newSurface);
if (type != Cairo.CAIRO_SURFACE_TYPE_IMAGE) {
- Rectangle bounds = image.getBounds();
+ Rectangle bounds = image.getBoundsInPixels();
int format = Cairo.cairo_surface_get_content(newSurface) == Cairo.CAIRO_CONTENT_COLOR ? Cairo.CAIRO_FORMAT_RGB24 : Cairo.CAIRO_FORMAT_ARGB32;
newSurface = Cairo.cairo_image_surface_create(format, bounds.width, bounds.height);
if (newSurface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
@@ -136,7 +136,7 @@
}
OS.g_object_unref(maskPixbuf);
} else {
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageDataAtCurrentZoom ();
boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 44d4766..967550c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.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
@@ -166,7 +166,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index 8611902..dff797a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.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
@@ -13,6 +13,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
@@ -259,6 +260,12 @@
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
checkWidget();
if (width <= 0 || height <= 0) return;
+ Point destination = DPIUtil.autoScaleUp (new Point (destX, destY));
+ Rectangle srcRect = DPIUtil.autoScaleUp (new Rectangle (x, y, width, height));
+ scrollInPixels(destination.x, destination.y, srcRect.x, srcRect.y, srcRect.width, srcRect.height, all);
+}
+
+void scrollInPixels (int destX, int destY, int x, int y, int width, int height, boolean all) {
if ((style & SWT.MIRRORED) != 0) {
int clientWidth = getClientWidth ();
x = clientWidth - width - x;
@@ -357,10 +364,10 @@
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/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
index aca785f..9bc1beb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.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
@@ -12,9 +12,10 @@
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
/**
* Instances of this class provide an i-beam that is typically used
@@ -171,8 +172,13 @@
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
+ checkWidget();
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
return new Rectangle (x, y, rect.width, rect.height);
} else {
if (width == 0) {
@@ -226,6 +232,11 @@
*/
public Point getLocation () {
checkWidget();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
+ checkWidget();
return new Point (x, y);
}
@@ -256,8 +267,13 @@
*/
public Point getSize () {
checkWidget();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels () {
+ checkWidget();
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
return new Point (rect.width, rect.height);
} else {
if (width == 0) {
@@ -359,6 +375,11 @@
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
+ setBounds (new Rectangle (x, y, width, height));
+}
+
+void setBoundsInPixels (int x, int y, int width, int height) {
+ checkWidget();
if (this.x == x && this.y == y && this.width == width && this.height == height) return;
boolean isFocus = isFocusCaret ();
if (isFocus && isVisible) hideCaret ();
@@ -383,8 +404,14 @@
*/
public void setBounds (Rectangle rect) {
checkWidget();
+ rect = DPIUtil.autoScaleUp(rect);
+ setBoundsInPixels(rect);
+}
+
+void setBoundsInPixels (Rectangle rect) {
+ checkWidget();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
+ setBoundsInPixels (rect.x, rect.y, rect.width, rect.height);
}
void setFocus () {
@@ -457,7 +484,12 @@
*/
public void setLocation (int x, int y) {
checkWidget();
- setBounds (x, y, width, height);
+ setLocation (new Point (x, y));
+}
+
+void setLocationInPixels (int x, int y) {
+ checkWidget();
+ setBoundsInPixels (x, y, width, height);
}
/**
@@ -474,8 +506,13 @@
*/
public void setLocation (Point location) {
checkWidget();
+ setLocationInPixels (DPIUtil.autoScaleUp (location));
+}
+
+void setLocationInPixels (Point location) {
+ checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ setLocationInPixels (location.x, location.y);
}
/**
@@ -491,7 +528,12 @@
*/
public void setSize (int width, int height) {
checkWidget();
- setBounds (x, y, width, height);
+ setSize (new Point (width,height));
+}
+
+void setSizeInPixels (int width, int height) {
+ checkWidget();
+ setBoundsInPixels (x, y, width, height);
}
/**
@@ -509,8 +551,13 @@
*/
public void setSize (Point size) {
checkWidget();
+ setSizeInPixels(DPIUtil.autoScaleUp (size));
+}
+
+void setSizeInPixels (Point size) {
+ checkWidget();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
+ setSizeInPixels (size.x, size.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 6ad07a5..18643b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.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
@@ -394,7 +394,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if ((style & SWT.READ_ONLY) != 0 || OS.GTK3) {
return computeNativeSize (handle, wHint, hHint, changed);
@@ -850,6 +850,12 @@
*/
public Point getCaretLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getCaretLocationInPixels());
+}
+
+
+Point getCaretLocationInPixels () {
+ checkWidget ();
if ((style & SWT.READ_ONLY) != 0) {
return new Point (0, 0);
}
@@ -860,7 +866,7 @@
long /*int*/ layout = OS.gtk_entry_get_layout (entryHandle);
PangoRectangle pos = new PangoRectangle ();
OS.pango_layout_index_to_pos (layout, index, pos);
- int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth ();
+ int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidthInPixels ();
int y = offset_y [0] + OS.PANGO_PIXELS (pos.y);
return new Point (x, y);
}
@@ -1133,6 +1139,12 @@
*/
public int getTextHeight () {
checkWidget();
+ return DPIUtil.autoScaleDown(getTextHeightInPixels());
+}
+
+
+int getTextHeightInPixels () {
+ checkWidget();
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_size_request (handle, requisition);
if (OS.GTK3) {
@@ -1911,7 +1923,7 @@
@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int newHeight = height;
- if (resize) newHeight = Math.max (getTextHeight (), height);
+ if (resize) newHeight = Math.max (getTextHeightInPixels (), height);
return super.setBounds (x, y, width, newHeight, move, resize);
}
@@ -2142,6 +2154,11 @@
*/
public void setSelection (Point selection) {
checkWidget();
+ selection = DPIUtil.autoScaleUp(selection);
+}
+
+void setSelectionInPixels (Point selection) {
+ checkWidget();
if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.READ_ONLY) != 0) return;
if (entryHandle != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index 28c4d56..6d83315 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.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
@@ -13,6 +13,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
@@ -64,6 +65,7 @@
Layout layout;
Control[] tabList;
int layoutCount, backgroundMode;
+ GdkRGBA background;
static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
@@ -227,7 +229,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
display.runSkin();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
@@ -236,7 +238,7 @@
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
changed |= (state & LAYOUT_CHANGED) != 0;
- size = layout.computeSize (this, wHint, hHint, changed);
+ size = DPIUtil.autoScaleUp(layout.computeSize (this, DPIUtil.autoScaleDown(wHint), DPIUtil.autoScaleDown(hHint), changed));
state &= ~LAYOUT_CHANGED;
} else {
size = new Point (wHint, hHint);
@@ -248,7 +250,7 @@
}
if (wHint != SWT.DEFAULT) size.x = wHint;
if (hHint != SWT.DEFAULT) size.y = hHint;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = DPIUtil.autoScaleUp (computeTrim (0, 0, DPIUtil.autoScaleDown(size.x), DPIUtil.autoScaleDown(size.y)));
return new Point (trim.width, trim.height);
}
@@ -400,6 +402,14 @@
* @since 3.6
*/
public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
+ checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
+ offsetX = DPIUtil.autoScaleUp(offsetX);
+ offsetY = DPIUtil.autoScaleUp(offsetY);
+ drawBackgroundInPixels(gc, rect.x, rect.y, rect.width, rect.height, offsetX, offsetY);
+}
+
+void drawBackgroundInPixels (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
checkWidget ();
if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
@@ -410,7 +420,7 @@
if (cairo != 0) {
Cairo.cairo_save (cairo);
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
Cairo.cairo_translate (cairo, -pt.x - offsetX, -pt.y - offsetY);
x += pt.x + offsetX;
y += pt.y + offsetY;
@@ -454,7 +464,7 @@
GdkGCValues values = new GdkGCValues ();
OS.gdk_gc_get_values (gdkGC, values);
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
OS.gdk_gc_set_ts_origin (gdkGC, -pt.x - offsetX, -pt.y - offsetY);
OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap);
@@ -470,7 +480,8 @@
}
}
} else {
- gc.fillRectangle (x, y, width, height);
+ gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(x, y, width, height)));
+
}
}
@@ -649,7 +660,7 @@
}
@Override
-public Rectangle getClientArea () {
+Rectangle getClientAreaInPixels () {
checkWidget();
if ((state & CANVAS) != 0) {
if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) {
@@ -663,7 +674,24 @@
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
return new Rectangle (0, 0, width, height);
}
- return super.getClientArea();
+ return super.getClientAreaInPixels();
+}
+
+@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground();
+ }
}
/**
@@ -770,11 +798,8 @@
for (int i=0; i<n_rectangles[0]; i++) {
Event event = new Event ();
OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof);
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ event.setBounds (DPIUtil.autoScaleDown (new Rectangle(rect.x, rect.y, rect.width, rect.height)));
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.width - event.x;
long /*int*/ damageRgn = OS.gdk_region_new ();
OS.gdk_region_union_with_rect (damageRgn, rect);
GCData data = new GCData ();
@@ -1340,10 +1365,10 @@
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);
}
@@ -1359,23 +1384,24 @@
void printWidget (GC gc, long /*int*/ drawable, int depth, int x, int y) {
Region oldClip = new Region (gc.getDevice ());
Region newClip = new Region (gc.getDevice ());
+ Point loc = DPIUtil.autoScaleDown(new Point (x, y));
gc.getClipping (oldClip);
Rectangle rect = getBounds ();
newClip.add (oldClip);
- newClip.intersect (x, y, rect.width, rect.height);
+ newClip.intersect (loc.x, loc.y, rect.width, rect.height);
gc.setClipping (newClip);
super.printWidget (gc, drawable, depth, x, y);
- Rectangle clientRect = getClientArea ();
- Point pt = display.map (this, parent, clientRect.x, clientRect.y);
+ Rectangle clientRect = getClientAreaInPixels ();
+ Point pt = display.mapInPixels (this, parent, clientRect.x, clientRect.y);
clientRect.x = x + pt.x - rect.x;
clientRect.y = y + pt.y - rect.y;
- newClip.intersect (clientRect);
+ newClip.intersect (DPIUtil.autoScaleDown(clientRect));
gc.setClipping (newClip);
Control [] children = _getChildren ();
for (int i=children.length-1; i>=0; --i) {
Control child = children [i];
if (child.getVisible ()) {
- Point location = child.getLocation ();
+ Point location = child.getLocationInPixels ();
child.printWidget (gc, drawable, depth, x + location.x, y + location.y);
}
}
@@ -1483,6 +1509,18 @@
}
@Override
+void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ background = rgba;
+ String color = gtk_rgba_to_css_string(background);
+ String css = "SwtFixed {background-color: " + color + "}";
+ gtk_css_provider_load_from_css(context, css);
+ } else {
+ super.setBackgroundColor(context, handle, rgba);
+ }
+}
+
+@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if ((result & RESIZED) != 0 && layout != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 9fe8dbf..ed36380 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -130,7 +130,7 @@
Cairo.cairo_clip(cairo);
}
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
Cairo.cairo_translate (cairo, -pt.x, -pt.y);
x += pt.x;
y += pt.y;
@@ -156,7 +156,7 @@
long /*int*/ gdkGC = OS.gdk_gc_new (window);
if (region != 0) OS.gdk_gc_set_clip_region (gdkGC, region);
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y);
OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap);
@@ -561,7 +561,7 @@
}
/**
- * Returns the preferred size of the receiver.
+ * Returns the preferred size(in Points) of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
@@ -591,6 +591,10 @@
return computeSize (wHint, hHint, true);
}
+Point computeSizeInPixels (int wHint, int hHint) {
+ return computeSizeInPixels (wHint, hHint, true);
+}
+
Widget computeTabGroup () {
if (isTabGroup()) return this;
return parent.computeTabGroup ();
@@ -661,7 +665,7 @@
}
void checkBorder () {
- if (getBorderWidth () == 0) style &= ~SWT.BORDER;
+ if (getBorderWidthInPixels () == 0) style &= ~SWT.BORDER;
}
void checkMirrored () {
@@ -690,7 +694,7 @@
}
/**
- * Returns the preferred size of the receiver.
+ * Returns the preferred size (in points) of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
@@ -727,6 +731,15 @@
checkWidget();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+ wHint = DPIUtil.autoScaleUp(wHint);
+ hHint = DPIUtil.autoScaleUp(hHint);
+ return DPIUtil.autoScaleDown (computeSizeInPixels (wHint, hHint, changed));
+}
+
+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;
return computeNativeSize (handle, wHint, hHint, changed);
}
@@ -815,7 +828,7 @@
}
/**
- * Returns a rectangle describing the receiver's size and location
+ * Returns a rectangle describing the receiver's size and location in points
* relative to its parent (or its display if its parent is null),
* unless the receiver is a shell. In this case, the location is
* relative to the display.
@@ -829,6 +842,11 @@
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
+ checkWidget();
long /*int*/ topHandle = topHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
@@ -841,7 +859,7 @@
}
/**
- * Sets the receiver's size and location to the rectangular
+ * Sets the receiver's size and location in points to the rectangular
* area specified by the argument. The <code>x</code> and
* <code>y</code> fields of the rectangle are relative to
* the receiver's parent (or its display if its parent is null).
@@ -866,11 +884,18 @@
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ rect = DPIUtil.autoScaleUp(rect);
+ setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
+}
+
+void setBoundsInPixels (Rectangle rect) {
+ checkWidget ();
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
}
/**
- * Sets the receiver's size and location to the rectangular
+ * Sets the receiver's size and location in points to the rectangular
* area specified by the arguments. The <code>x</code> and
* <code>y</code> arguments are relative to the receiver's
* parent (or its display if its parent is null), unless
@@ -899,6 +924,12 @@
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
+ setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
+}
+
+void setBoundsInPixels (int x, int y, int width, int height) {
+ checkWidget();
setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true);
}
@@ -1075,7 +1106,7 @@
/**
* Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null), unless
+ * to its parent in points (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
@@ -1088,6 +1119,11 @@
*/
public Point getLocation () {
checkWidget();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
+ checkWidget();
long /*int*/ topHandle = topHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
@@ -1117,6 +1153,13 @@
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ location = DPIUtil.autoScaleUp(location);
+ setBounds (location.x, location.y, 0, 0, true, false);
+}
+
+void setLocationInPixels (Point location) {
+ checkWidget ();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (location.x, location.y, 0, 0, true, false);
}
@@ -1127,7 +1170,7 @@
* the receiver is a shell. In this case, the point is
* relative to the display.
*
- * @param x the new x coordinate for the receiver
+ * @param x the new x coordinate in for the receiver
* @param y the new y coordinate for the receiver
*
* @exception SWTException <ul>
@@ -1137,11 +1180,17 @@
*/
public void setLocation(int x, int y) {
checkWidget();
+ Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ setBounds (loc.x, loc.y, 0, 0, true, false);
+}
+
+void setLocationInPixels(int x, int y) {
+ checkWidget();
setBounds (x, y, 0, 0, true, false);
}
/**
- * Returns a point describing the receiver's size. The
+ * Returns a point describing the receiver's size in points. The
* x coordinate of the result is the width of the receiver.
* The y coordinate of the result is the height of the
* receiver.
@@ -1155,6 +1204,11 @@
*/
public Point getSize () {
checkWidget();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels () {
+ checkWidget();
long /*int*/ topHandle = topHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
@@ -1176,7 +1230,7 @@
* set to (2^14)-1 instead.
* </p>
*
- * @param size the new size for the receiver
+ * @param size the new size in points for the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
@@ -1185,10 +1239,18 @@
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
+ * @since 3.105
*/
public void setSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ size = DPIUtil.autoScaleUp(size);
+ setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
+}
+
+void setSizeInPixels (Point size) {
+ checkWidget ();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
}
@@ -1255,8 +1317,8 @@
* set to (2^14)-1 instead.
* </p>
*
- * @param width the new width for the receiver
- * @param height the new height for the receiver
+ * @param width the new width in points for the receiver
+ * @param height the new height in points for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1265,6 +1327,12 @@
*/
public void setSize (int width, int height) {
checkWidget();
+ Point size = DPIUtil.autoScaleUp(new Point (width, height));
+ setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
+}
+
+void setSizeInPixels (int width, int height) {
+ checkWidget();
setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true);
}
@@ -1414,8 +1482,8 @@
* {@link Display#map(Control, Control, Rectangle)}.
* </p>
*
- * @param x the x coordinate to be translated
- * @param y the y coordinate to be translated
+ * @param x the x coordinate in points to be translated
+ * @param y the y coordinate in points to be translated
* @return the translated coordinates
*
* @exception SWTException <ul>
@@ -1427,6 +1495,11 @@
*/
public Point toControl (int x, int y) {
checkWidget ();
+ return toControl (new Point (x, y));
+}
+
+Point toControlInPixels (int x, int y) {
+ checkWidget ();
long /*int*/ window = eventWindow ();
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
@@ -1459,7 +1532,14 @@
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));
+}
+
+Point toControlInPixels (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toControlInPixels (point.x, point.y);
}
/**
@@ -1484,6 +1564,11 @@
*/
public Point toDisplay (int x, int y) {
checkWidget();
+ return toDisplay (new Point (x, y));
+}
+
+Point toDisplayInPixels (int x, int y) {
+ checkWidget();
long /*int*/ window = eventWindow ();
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
@@ -1516,9 +1601,15 @@
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));
}
+Point toDisplayInPixels (Point point) {
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toDisplayInPixels (point.x, point.y);
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -2395,7 +2486,7 @@
Point startPos = null;
Point currPos = null;
if (OS.GTK3) {
- startPos = display.getCursorLocation();
+ startPos = display.getCursorLocationInPixels();
}
while (!quit) {
@@ -2413,7 +2504,7 @@
break;
} else {
if (OS.GTK3) { //428852
- currPos = display.getCursorLocation();
+ currPos = display.getCursorLocationInPixels();
dragging = OS.gtk_drag_check_threshold (handle,
startPos.x, startPos.y, currPos.x, currPos.y);
if (dragging) break;
@@ -2669,7 +2760,7 @@
}
/**
- * Returns the receiver's border width.
+ * Returns the receiver's border width in points.
*
* @return the border width
*
@@ -2679,6 +2770,10 @@
* </ul>
*/
public int getBorderWidth () {
+ return DPIUtil.autoScaleDown(getBorderWidthInPixels());
+}
+
+int getBorderWidthInPixels () {
checkWidget();
return 0;
}
@@ -3255,18 +3350,18 @@
OS.gdk_cairo_get_clip_rectangle (cairo, rect);
Event event = new Event ();
event.count = 1;
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ Rectangle eventRect = new Rectangle (rect.x, rect.y, rect.width, rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.width - event.x;
GCData data = new GCData ();
// data.damageRgn = gdkEvent.region;
if (OS.GTK_VERSION <= OS.VERSION (3, 9, 0)) {
data.cairo = cairo;
}
GC gc = event.gc = GC.gtk_new (this, data);
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping (rect2.x, rect2.y, rect2.width, rect2.height);
drawWidget (gc);
sendEvent (SWT.Paint, event);
gc.dispose ();
@@ -3282,11 +3377,9 @@
OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
Event event = new Event ();
event.count = gdkEvent.count;
- event.x = gdkEvent.area_x;
- event.y = gdkEvent.area_y;
- event.width = gdkEvent.area_width;
- event.height = gdkEvent.area_height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ Rectangle eventRect = new Rectangle (gdkEvent.area_x, gdkEvent.area_y, gdkEvent.area_width, gdkEvent.area_height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.width - event.x;
GCData data = new GCData ();
data.damageRgn = gdkEvent.region;
GC gc = event.gc = GC.gtk_new (this, data);
@@ -3633,7 +3726,7 @@
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;
}
@@ -3831,6 +3924,12 @@
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ redrawInPixels(rect.x, rect.y, rect.width, rect.height, all);
+}
+
+void redrawInPixels (int x, int y, int width, int height, boolean all) {
+ checkWidget();
if (!OS.gtk_widget_get_visible (topHandle ())) return;
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x;
redrawWidget (x, y, width, height, false, all, false);
@@ -3931,9 +4030,9 @@
boolean sendDragEvent (int button, int stateMask, int x, int y, boolean isStateMask) {
Event event = new Event ();
event.button = button;
- event.x = x;
- event.y = y;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
+ Rectangle eventRect = new Rectangle (x, y, 0, 0);
+ event.setBounds (eventRect);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown(getClientWidth ()) - event.x;
if (isStateMask) {
event.stateMask = stateMask;
} else {
@@ -4000,16 +4099,16 @@
event.detail = detail;
event.count = count;
if (is_hint) {
- event.x = (int)x;
- event.y = (int)y;
+ Rectangle eventRect = new Rectangle ((int)x, (int)y, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
} else {
long /*int*/ window = eventWindow ();
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
- event.x = (int)x - origin_x [0];
- event.y = (int)y - origin_y [0];
+ Rectangle eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
}
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.x;
setInputState (event, state);
if (send) {
sendEvent (type, event);
@@ -4873,7 +4972,7 @@
if (drawCount++ == 0) {
if (gtk_widget_get_realized (handle)) {
long /*int*/ window = paintWindow ();
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
GdkWindowAttr attributes = new GdkWindowAttr ();
attributes.width = rect.width;
attributes.height = rect.height;
@@ -5196,8 +5295,8 @@
boolean showMenu (int x, int y, int detail) {
Event event = new Event ();
- event.x = x;
- event.y = y;
+ Rectangle eventRect = new Rectangle (x, y, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = detail;
sendEvent (SWT.MenuDetect, event);
//widget could be disposed at this point
@@ -5206,8 +5305,9 @@
if (menu != null && !menu.isDisposed ()) {
boolean hooksKeys = hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
menu.createIMMenu (hooksKeys ? imHandle() : 0);
- if (event.x != x || event.y != y) {
- menu.setLocation (event.x, event.y);
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ if (rect.x != x || rect.y != y) {
+ menu.setLocationInPixels (rect.x, rect.y);
}
menu.setVisible (true);
return true;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
index 7e792c1..cfefd0e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
@@ -159,8 +159,8 @@
if (isDateWithDropDownButton ()) {
//Date w/ drop down button is in containers.
//first time round we set the bounds manually for correct Right_to_left behaviour
- Point size = computeSize (SWT.DEFAULT, SWT.DEFAULT);
- setBounds (0, 0, size.x, size.y);
+ Point size = computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT);
+ setBoundsInPixels (0, 0, size.x, size.y);
}
}
@@ -236,7 +236,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
@@ -254,9 +254,9 @@
height = size.y;
} else {
Point textSize = computeNativeSize (textEntryHandle, wHint, hHint, changed);
- Rectangle trim = computeTrim (0,0, textSize.x,textSize.y);
+ Rectangle trim = computeTrimInPixels (0,0, textSize.x,textSize.y);
if (isDateWithDropDownButton ()){
- Point buttonSize = down.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point buttonSize = down.computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, changed);
width = trim.width + buttonSize.x;
height = Math.max (trim.height, buttonSize.y);
} else if (isDate () || isTime ()) {
@@ -275,7 +275,7 @@
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int borderWidth = getBorderWidth ();
+ int borderWidth = getBorderWidthInPixels ();
if (prefferedSize == null && (isDateWithDropDownButton () && OS.GTK3)) {
prefferedSize = new Point (width + 2*borderWidth, height+ 2*borderWidth);
@@ -286,13 +286,13 @@
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
if (isCalendar ()) {
- return super.computeTrim (x, y, width, height);
+ return super.computeTrimInPixels (x, y, width, height);
}
checkWidget ();
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
int xborder = 0, yborder = 0;
if (OS.GTK3) {
GtkBorder tmp = new GtkBorder ();
@@ -559,11 +559,11 @@
}
//This is the x/y/width/height of the container of DateTime
- Point containerBounds = getSize ();
- Point calendarSize = popupCalendar.computeSize (SWT.DEFAULT, SWT.DEFAULT, false);
+ Point containerBounds = getSizeInPixels ();
+ Point calendarSize = popupCalendar.computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, false);
//Set the inner calendar pos/size. (not the popup shell pos/size)
- popupCalendar.setBounds (1, 1, Math.max (containerBounds.x - 2, calendarSize.x), calendarSize.y);
+ popupCalendar.setBoundsInPixels (1, 1, Math.max (containerBounds.x - 2, calendarSize.x), calendarSize.y);
//Set Date & focus current day
popupCalendar.setDate (savedYear, savedMonth, savedDay);
@@ -572,7 +572,7 @@
Display display = getDisplay ();
//To display popup calendar, we need to know where the parent is relative to the whole screen.
- Rectangle coordsRelativeToScreen = display.map (getParent (), null, getBounds ());
+ Rectangle coordsRelativeToScreen = display.mapInPixels (getParent (), null, getBoundsInPixels ());
Rectangle displayRect = getMonitor ().getClientArea ();
showPopupShell (containerBounds, calendarSize, coordsRelativeToScreen, displayRect);
@@ -587,7 +587,7 @@
int y = calculateCalendarYpos (containerBounds, coordsRelativeToScreen, height, displayRect);
int x = calculateCalendarXpos (calendarSize, coordsRelativeToScreen, displayRect, width);
- popupShell.setBounds (x, y, width, height);
+ popupShell.setBoundsInPixels (x, y, width, height);
popupShell.setVisible (true);
if (isFocusControl ()) {
popupCalendar.setFocus ();
@@ -1071,7 +1071,7 @@
@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;
@@ -1691,7 +1691,7 @@
}
@Override
-public void setBounds (int x, int y, int width, int height) {
+void setBoundsInPixels (int x, int y, int width, int height) {
//Date with Drop down is in container. Needs extra handling.
if (isDateWithDropDownButton () && OS.GTK3) {
@@ -1699,7 +1699,7 @@
OS.gtk_widget_get_preferred_size (textEntryHandle, null, requisition);
int oldHeight = requisition.height; //Entry should not expand vertically. It is single liner.
- int newWidth = width - (down.getSize ().x + getGtkBorderPadding ().right);
+ int newWidth = width - (down.getSizeInPixels ().x + getGtkBorderPadding ().right);
OS.gtk_widget_set_size_request (textEntryHandle, (newWidth >= 0) ? newWidth : 0, oldHeight);
}
@@ -1718,12 +1718,12 @@
*/
int fixedGtkVersion = OS.VERSION (3, 14, 2);
if (isCalendar () && OS.GTK3 && (OS.GTK_VERSION < fixedGtkVersion)) {
- int calendarPrefferedVerticalSize = computeSize (SWT.DEFAULT, SWT.DEFAULT, true).y;
+ int calendarPrefferedVerticalSize = computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, true).y;
if (height > calendarPrefferedVerticalSize) {
height = calendarPrefferedVerticalSize;
}
}
- super.setBounds (x, y, width, height);
+ super.setBoundsInPixels (x, y, width, height);
}
@@ -1731,10 +1731,10 @@
* Usually called when control is resized or first initialized.
*/
private void setDropDownButtonSize () {
- Rectangle rect = getClientArea ();
+ Rectangle rect = getClientAreaInPixels ();
int parentWidth = rect.width;
int parentHeight = rect.height;
- Point buttonSize = down.computeSize (SWT.DEFAULT, parentHeight);
+ Point buttonSize = down.computeSizeInPixels (SWT.DEFAULT, parentHeight);
//TAG_GTK3__NO_VERTICAL_FILL_ADJUSTMENT
int dateEntryHeight = computeNativeSize (textEntryHandle, SWT.DEFAULT, SWT.DEFAULT, false).y;
@@ -1744,7 +1744,7 @@
int newXpos = parentWidth - buttonSize.x;
int newYPos = parentHeight/2 - dateEntryHeight/2;
- down.setBounds (newXpos, newYPos, buttonSize.x, newHeight);
+ down.setBoundsInPixels (newXpos, newYPos, buttonSize.x, newHeight);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 7dee6d7..eff7dfe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -1402,20 +1402,14 @@
return activeShell;
}
-/**
- * Returns a rectangle describing the receiver's size and location. Note that
- * on multi-monitor systems the origin can be negative.
- *
- * @return the bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
@Override
public Rectangle getBounds () {
checkDevice ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
+ checkDevice ();
return new Rectangle (0, 0, OS.gdk_screen_width (), OS.gdk_screen_height ());
}
@@ -1579,6 +1573,10 @@
* </ul>
*/
public Point getCursorLocation () {
+ return DPIUtil.autoScaleDown(getCursorLocationInPixels());
+}
+
+Point getCursorLocationInPixels () {
checkDevice ();
int [] x = new int [1], y = new int [1];
gdk_window_get_device_position (0, x, y, null);
@@ -2025,7 +2023,7 @@
public Monitor [] getMonitors () {
checkDevice ();
Monitor [] monitors = null;
- Rectangle workArea = getWorkArea ();
+ Rectangle workArea = DPIUtil.autoScaleDown (getWorkArea ());
long /*int*/ screen = OS.gdk_screen_get_default ();
if (screen != 0) {
int monitorCount = OS.gdk_screen_get_n_monitors (screen);
@@ -2036,19 +2034,19 @@
OS.gdk_screen_get_monitor_geometry (screen, i, dest);
Monitor monitor = new Monitor ();
monitor.handle = i;
- monitor.x = dest.x;
- monitor.y = dest.y;
- monitor.width = dest.width;
- monitor.height = dest.height;
+ monitor.x = DPIUtil.autoScaleDown (dest.x);
+ monitor.y = DPIUtil.autoScaleDown (dest.y);
+ monitor.width = DPIUtil.autoScaleDown (dest.width);
+ monitor.height = DPIUtil.autoScaleDown (dest.height);
if (OS.GTK_VERSION >= OS.VERSION (3, 4, 0)) {
// workarea was defined in GTK 3.4. If present, it will return the best results
// since it takes into account per-monitor trim
OS.gdk_screen_get_monitor_workarea (screen, i, dest);
- monitor.clientX = dest.x;
- monitor.clientY = dest.y;
- monitor.clientWidth = dest.width;
- monitor.clientHeight = dest.height;
+ monitor.clientX = DPIUtil.autoScaleDown (dest.x);
+ monitor.clientY = DPIUtil.autoScaleDown (dest.y);
+ monitor.clientWidth = DPIUtil.autoScaleDown (dest.width);
+ monitor.clientHeight = DPIUtil.autoScaleDown (dest.height);
} else {
// If we're on an older version of gtk without the workarea function, see if we can use
// the getWorkArea function. In the case of multi-monitors, this will return something that
@@ -3144,9 +3142,14 @@
* @since 2.1.2
*/
public Point map (Control from, Control to, Point point) {
+ checkDevice();
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, DPIUtil.autoScaleUp(point)));
+}
+
+Point mapInPixels (Control from, Control to, Point point) {
checkDevice ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, point.x, point.y);
+ return mapInPixels (from, to, point.x, point.y);
}
/**
@@ -3186,6 +3189,11 @@
* @since 2.1.2
*/
public Point map (Control from, Control to, int x, int y) {
+ checkDevice();
+ return map(from, to, new Point(x, y));
+}
+
+Point mapInPixels (Control from, Control to, int x, int y) {
checkDevice ();
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
@@ -3244,8 +3252,13 @@
*/
public Rectangle map (Control from, Control to, Rectangle rectangle) {
checkDevice();
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, DPIUtil.autoScaleUp(rectangle)));
+}
+
+Rectangle mapInPixels (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);
+ return mapInPixels (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
static char mbcsToWcs (char ch) {
@@ -3311,6 +3324,11 @@
*/
public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
checkDevice();
+ return map(from, to, new Rectangle(x, y, width, height));
+}
+
+Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int height) {
+ checkDevice();
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
Rectangle rect = new Rectangle (x, y, width, height);
@@ -3445,7 +3463,8 @@
case SWT.MouseMove:
case SWT.MouseUp: {
if (type == SWT.MouseMove) {
- OS.XTestFakeMotionEvent (xDisplay, -1, event.x, event.y, 0);
+ Rectangle loc = DPIUtil.autoScaleUp(event.getBounds ());
+ OS.XTestFakeMotionEvent (xDisplay, -1, loc.x, loc.y, 0);
} else {
int button = event.button;
switch (button) {
@@ -4370,7 +4389,7 @@
widget.setFontDescription (preeditLabel, control.getFontDescription ());
if (pangoAttrs [0] != 0) OS.gtk_label_set_attributes (preeditLabel, pangoAttrs[0]);
OS.gtk_label_set_text (preeditLabel, preeditString [0]);
- Point point = control.toDisplay (control.getIMCaretPos ());
+ Point point = control.toDisplayInPixels (control.getIMCaretPos ());
OS.gtk_window_move (preeditWindow, point.x, point.y);
GtkRequisition requisition = new GtkRequisition ();
if (OS.GTK3) {
@@ -4892,4 +4911,23 @@
}
}
+/**
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+@Override
+protected long /*int*/ gsettingsProc (long /*int*/ gobject, long /*int*/ arg1, long /*int*/ user_data) {
+ switch((int)/*64*/user_data) {
+ case CHANGE_SCALEFACTOR:
+ this.scaleFactor = getDeviceZoom ();
+ DPIUtil.setDeviceZoom (scaleFactor);
+ Shell[] shells = getShells();
+ for (int i = 0; i < shells.length; i++) {
+ shells[i].layout(true, true);
+ }
+ }
+ return 0;
+}
+
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index 1d11275..33c693e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.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
@@ -13,6 +13,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -115,7 +116,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
Point size = computeNativeSize (handle, wHint, hHint, changed);
@@ -168,7 +169,7 @@
System.arraycopy (items, index, items, index + 1, itemCount - index);
items [index] = item;
itemCount++;
- item.width = Math.max (0, getClientArea ().width - spacing * 2);
+ item.width = Math.max (0, getClientAreaInPixels ().width - spacing * 2);
layoutItems (index, true);
}
@@ -302,6 +303,11 @@
*/
public int getSpacing () {
checkWidget ();
+ return DPIUtil.autoScaleDown(spacing);
+}
+
+int getSpacingInPixels () {
+ checkWidget ();
return spacing;
}
@@ -466,7 +472,7 @@
void setScrollbar () {
if (itemCount == 0) return;
if ((style & SWT.V_SCROLL) == 0) return;
- int height = getClientArea ().height;
+ int height = getClientAreaInPixels ().height;
ExpandItem item = items [itemCount - 1];
int maxHeight = item.y + getBandHeight () + spacing;
if (item.expanded) maxHeight += item.height;
@@ -518,6 +524,11 @@
*/
public void setSpacing (int spacing) {
checkWidget ();
+ setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+}
+
+void setSpacingInPixels (int spacing) {
+ checkWidget ();
if (spacing < 0) return;
if (spacing == this.spacing) return;
this.spacing = spacing;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
index e67abed..90fdeae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.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
@@ -200,8 +200,8 @@
px+3,py+2, px+4,py+2, px+4,py+1, px+5,py+1, px+5,py, px+6,py};
}
gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_FOREGROUND));
- gc.drawPolyline (polyline1);
- gc.drawPolyline (polyline2);
+ gc.drawPolyline (DPIUtil.autoScaleDown(polyline1));
+ gc.drawPolyline (DPIUtil.autoScaleDown(polyline2));
}
void drawItem (GC gc, boolean drawFocus) {
@@ -283,11 +283,15 @@
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
+ checkWidget ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (handle, allocation);
return allocation.height - (expanded ? height : 0);
}
-
/**
* Gets the height of the receiver.
*
@@ -300,6 +304,11 @@
*/
public int getHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeightInPixels());
+}
+
+int getHeightInPixels () {
+ checkWidget ();
return height;
}
@@ -472,8 +481,8 @@
redraw ();
}
if (control != null && !control.isDisposed ()) {
- if (move) control.setLocation (x + BORDER, y + headerHeight);
- if (size) control.setSize (Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
+ if (move) control.setLocationInPixels (x + BORDER, y + headerHeight);
+ if (size) control.setSizeInPixels (Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
}
}
@@ -574,6 +583,11 @@
*/
public void setHeight (int height) {
checkWidget ();
+ setHeightInPixels(DPIUtil.autoScaleUp(height));
+}
+
+void setHeightInPixels (int height) {
+ checkWidget ();
if (height < 0) return;
this.height = height;
OS.gtk_widget_set_size_request (clientHandle, -1, height);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 9eb6120..fb69dcd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.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
@@ -103,14 +103,14 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- Point size = super.computeSize(wHint, hHint, changed);
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
+ Point size = super.computeSizeInPixels(wHint, hHint, changed);
int width = computeNativeSize (handle, SWT.DEFAULT, SWT.DEFAULT, false).x;
size.x = Math.max (size.x, width);
return size;
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget();
forceResize ();
GtkAllocation allocation = new GtkAllocation();
@@ -125,8 +125,8 @@
}
@Override
-public Rectangle getClientArea () {
- Rectangle clientRectangle = super.getClientArea ();
+Rectangle getClientAreaInPixels () {
+ Rectangle clientRectangle = super.getClientAreaInPixels ();
/*
* Bug 453827 Child position fix.
* SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index e9dbbe8..88fe1b1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -114,7 +114,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -297,7 +297,7 @@
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
if (frameHandle != 0) {
return getThickness (frameHandle).x;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 5172fcf..d6c87c8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -15,6 +15,7 @@
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.gtk.*;
/**
@@ -115,7 +116,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -124,19 +125,19 @@
//TEMPORARY CODE
if (wHint == 0) {
layout.setWidth (1);
- Rectangle rect = layout.getBounds ();
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
width = 0;
height = rect.height;
} else {
layout.setWidth (wHint);
- Rectangle rect = layout.getBounds ();
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
width = rect.width;
height = rect.height;
}
layout.setWidth (layoutWidth);
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);
@@ -217,7 +218,7 @@
@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;
@@ -334,7 +335,7 @@
int x = (int) gdkEvent.x;
int y = (int) gdkEvent.y;
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
- int offset = layout.getOffset (x, y, null);
+ int offset = DPIUtil.autoScaleUp(layout.getOffset (x, y, null));
int oldSelectionX = selection.x;
int oldSelectionY = selection.y;
selection.x = offset;
@@ -345,8 +346,8 @@
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));
+ redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
}
for (int j = 0; j < offsets.length; j++) {
Rectangle [] rects = getRectangles (j);
@@ -458,7 +459,7 @@
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
if ((gdkEvent.state & OS.GDK_BUTTON1_MASK) != 0) {
int oldSelection = selection.y;
- selection.y = layout.getOffset (x, y, null);
+ selection.y = DPIUtil.autoScaleUp(layout.getOffset (x, y, null));
if (selection.y != oldSelection) {
int newSelection = selection.y;
if (oldSelection > newSelection) {
@@ -467,7 +468,7 @@
newSelection = temp;
}
Rectangle rect = layout.getBounds (oldSelection, newSelection);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
+ redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
}
} else {
for (int j = 0; j < offsets.length; j++) {
@@ -716,7 +717,7 @@
int setBounds(int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width,height, move, resize);
if ((result & RESIZED) != 0) {
- layout.setWidth (width > 0 ? width : -1);
+ layout.setWidth (DPIUtil.autoScaleDown((width > 0 ? width : -1)));
redraw ();
}
return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index b7d2fc6..ae75d62 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.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
@@ -252,7 +252,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -265,7 +265,7 @@
* based on the number of items in the table
*/
if (OS.GTK3 && size.y == 0 && hHint == SWT.DEFAULT) {
- size.y = getItemCount() * getItemHeight();
+ size.y = getItemCount() * getItemHeightInPixels();
}
/*
@@ -274,7 +274,7 @@
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
@@ -527,6 +527,11 @@
*/
public int getItemHeight () {
checkWidget();
+ return DPIUtil.autoScaleDown(getItemHeightInPixels());
+}
+
+int getItemHeightInPixels () {
+ checkWidget();
int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
if (itemCount == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 458c2e2..c1ac0aa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.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
@@ -1012,6 +1012,11 @@
* </ul>
*/
public void setLocation (int x, int y) {
+ checkWidget ();
+ setLocation (new Point (x, y));
+}
+
+void setLocationInPixels (int x, int y) {
checkWidget();
if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
this.x = x;
@@ -1044,9 +1049,14 @@
* @since 2.1
*/
public void setLocation (Point location) {
+ checkWidget ();
+ setLocationInPixels (DPIUtil.autoScaleUp (location));
+}
+
+void setLocationInPixels (Point location) {
checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ setLocationInPixels (location.x, location.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 58406f7..e3f7831 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.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
@@ -14,6 +14,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -120,11 +121,11 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
width += DEFAULT_WIDTH; height += 3;
@@ -192,25 +193,24 @@
lastY = y;
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = lastX;
- event.y = lastY;
- event.width = width;
- event.height = height;
+ Rectangle eventRect = new Rectangle (lastX, lastY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if ((style & SWT.SMOOTH) == 0) {
event.detail = SWT.DRAG;
}
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return 0;
if (event.doit) {
dragging = true;
- lastX = event.x;
- lastY = event.y;
- if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ lastX = rect.x;
+ lastY = rect.y;
+ if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
parent.update (true, (style & SWT.SMOOTH) == 0);
- drawBand (lastX, event.y, width, height);
+ drawBand (lastX, rect.y, width, height);
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (rect.x, rect.y, width, height);
// widget could be disposed at this point
}
}
@@ -233,17 +233,16 @@
int height = allocation.height;
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = lastX;
- event.y = lastY;
- event.width = width;
- event.height = height;
+ Rectangle eventRect = new Rectangle (lastX, lastY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
drawBand (lastX, lastY, width, height);
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return result;
if (event.doit) {
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ setBoundsInPixels (rect.x, rect.y, width, height);
// widget could be disposed at this point
}
}
@@ -326,30 +325,29 @@
/* The event must be sent because its doit flag is used. */
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = newX;
- event.y = newY;
- event.width = width;
- event.height = height;
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x;
+ Rectangle eventRect = new Rectangle (newX, newY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (ptrGrabResult == OS.GDK_GRAB_SUCCESS) gdk_pointer_ungrab (window, OS.GDK_CURRENT_TIME);
if (isDisposed ()) break;
if (event.doit) {
- lastX = event.x;
- lastY = event.y;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ lastX = rect.x;
+ lastY = rect.y;
if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (rect.x, rect.y, width, height);
if (isDisposed ()) break;
}
- int cursorX = event.x, cursorY = event.y;
+ int cursorX = rect.x, cursorY = rect.y;
if ((style & SWT.VERTICAL) != 0) {
cursorY += height / 2;
} else {
cursorX += width / 2;
}
- display.setCursorLocation (parent.toDisplay (cursorX, cursorY));
+ display.setCursorLocation (parent.toDisplayInPixels (cursorX, cursorY));
}
break;
}
@@ -400,25 +398,24 @@
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = newX;
- event.y = newY;
- event.width = width;
- event.height = height;
+ Rectangle eventRect = new Rectangle (newX, newY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if ((style & SWT.SMOOTH) == 0) {
event.detail = SWT.DRAG;
}
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth() - width - event.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return 0;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
if (event.doit) {
- lastX = event.x;
- lastY = event.y;
+ lastX = rect.x;
+ lastY = rect.y;
if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
}
parent.update (true, (style & SWT.SMOOTH) == 0);
drawBand (lastX, lastY, width, height);
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, lastY, width, height);
+ setBoundsInPixels (rect.x, lastY, width, height);
// widget could be disposed at this point
}
return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
index 464bb490..d1d7b88 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.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
@@ -109,7 +109,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index 015b969..3adbce1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -276,6 +277,7 @@
return (int) OS.gtk_adjustment_get_value (adjustmentHandle);
}
+
/**
* Returns a point describing the receiver's size. The
* x coordinate of the result is the width of the receiver.
@@ -291,6 +293,11 @@
*/
public Point getSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getSizeInPixels ());
+}
+
+Point getSizeInPixels () {
+ checkWidget ();
if (handle == 0) return new Point (0,0);
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_get_preferred_size (handle, requisition);
@@ -328,6 +335,11 @@
* @since 3.6
*/
public Rectangle getThumbBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getThumbBoundsInPixels());
+}
+
+Rectangle getThumbBoundsInPixels () {
checkWidget();
int [] slider_start = new int [1], slider_end = new int [1];
gtk_range_get_slider_range (handle, slider_start, slider_end);
@@ -373,6 +385,11 @@
* @since 3.6
*/
public Rectangle getThumbTrackBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getThumbTrackBoundsInPixels());
+}
+
+Rectangle getThumbTrackBoundsInPixels () {
checkWidget();
int x = 0, y = 0, width, height;
int[] has_stepper = new int[1];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index c336798..caca280 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.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
@@ -13,6 +13,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -107,6 +108,12 @@
*/
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
+ return DPIUtil.autoScaleDown(computeTrimInPixels(rect.x, rect.y, rect.width, rect.height));
+}
+
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
+ checkWidget();
int border = 0;
if (fixedHandle != 0) border += OS.gtk_container_get_border_width (fixedHandle);
if (scrolledHandle != 0) border += OS.gtk_container_get_border_width (scrolledHandle);
@@ -189,7 +196,7 @@
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
int border = 0;
if (fixedHandle != 0) border += OS.gtk_container_get_border_width (fixedHandle);
@@ -201,7 +208,6 @@
}
return border;
}
-
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data (that is,
@@ -218,6 +224,11 @@
*/
public Rectangle getClientArea () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+
+Rectangle getClientAreaInPixels () {
+ checkWidget ();
forceResize ();
long /*int*/ clientHandle = clientHandle ();
GtkAllocation allocation = new GtkAllocation ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 0a5f9fe..a8abd17 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -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
@@ -600,8 +600,8 @@
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();
@@ -615,7 +615,7 @@
} else {
y = Math.max (y, monitorRect.y);
}
- setLocation (x, y);
+ setLocationInPixels (x, y);
}
@Override
@@ -659,9 +659,9 @@
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+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);
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
border = OS.gtk_container_get_border_width (shellHandle);
@@ -1053,7 +1053,7 @@
}
@Override
-public Point getLocation () {
+Point getLocationInPixels () {
checkWidget ();
int [] x = new int [1], y = new int [1];
OS.gtk_window_get_position (shellHandle, x,y);
@@ -1079,10 +1079,15 @@
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
- * @since 3.1
+ * @since 3.105
*/
public Point getMinimumSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getMinimumSizeInPixels ());
+}
+
+Point getMinimumSizeInPixels () {
+ checkWidget ();
int width = Math.max (1, minWidth + trimWidth ());
int height = Math.max (1, minHeight + trimHeight ());
return new Point (width, height);
@@ -1134,7 +1139,7 @@
}
@Override
-public Point getSize () {
+Point getSizeInPixels () {
checkWidget ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (vboxHandle, allocation);
@@ -1869,7 +1874,7 @@
* anything different from the current bounds.
*/
if (getMaximized ()) {
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
boolean sameOrigin = !move || (rect.x == x && rect.y == y);
boolean sameExtent = !resize || (rect.width == width && rect.height == height);
if (sameOrigin && sameExtent) return 0;
@@ -1950,7 +1955,7 @@
long /*int*/ parentHandle = shellHandle;
OS.gtk_widget_realize (parentHandle);
long /*int*/ window = gtk_widget_get_window (parentHandle);
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
GdkWindowAttr attributes = new GdkWindowAttr ();
attributes.width = rect.width;
attributes.height = rect.height;
@@ -2138,6 +2143,11 @@
*/
public void setMinimumSize (int width, int height) {
checkWidget ();
+ setMinimumSize (new Point (width, height));
+}
+
+void setMinimumSizeInPixels (int width, int height) {
+ checkWidget ();
GdkGeometry geometry = new GdkGeometry ();
minWidth = geometry.min_width = Math.max (width, trimWidth ()) - trimWidth ();
minHeight = geometry.min_height = Math.max (height, trimHeight ()) - trimHeight ();
@@ -2163,8 +2173,13 @@
*/
public void setMinimumSize (Point size) {
checkWidget ();
+ setMinimumSizeInPixels (DPIUtil.autoScaleUp (size));
+}
+
+void setMinimumSizeInPixels (Point size) {
+ checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setMinimumSize (size.x, size.y);
+ setMinimumSizeInPixels (size.x, size.y);
}
/**
@@ -2254,7 +2269,7 @@
int [] nRects = new int [1];
long /*int*/ [] rects = new long /*int*/ [1];
gdk_region_get_rectangles (rgn, rects, nRects);
- Rectangle bounds = region.getBounds ();
+ Rectangle bounds = DPIUtil.autoScaleUp(region.getBounds ());
GdkRectangle rect = new GdkRectangle ();
for (int i = 0; i < nRects [0]; i++) {
OS.memmove (rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof);
@@ -2296,7 +2311,7 @@
checkWidget();
if (moved) { //fix shell location if it was moved.
- setLocation(oldX, oldY);
+ setLocationInPixels(oldX, oldY);
}
int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
if ((style & mask) != 0) {
@@ -2377,7 +2392,7 @@
opened = true;
if (!moved) {
moved = true;
- Point location = getLocation();
+ Point location = getLocationInPixels();
oldX = location.x;
oldY = location.y;
sendEvent (SWT.Move);
@@ -2385,7 +2400,7 @@
}
if (!resized) {
resized = true;
- Point size = getSize ();
+ Point size = getSizeInPixels ();
oldWidth = size.x - trimWidth ();
oldHeight = size.y - trimHeight ();
sendEvent (SWT.Resize);
@@ -2654,7 +2669,7 @@
}
@Override
-public Rectangle getBounds () {
+Rectangle getBoundsInPixels () {
checkWidget ();
int [] x = new int [1], y = new int [1];
OS.gtk_window_get_position (shellHandle, x, y);
@@ -2751,7 +2766,7 @@
* window trims etc. from the window manager. That's why getLocation ()
* is not safe to use for coordinate mappings after the shell has been made visible.
*/
- return getLocation ();
+ return getLocationInPixels ();
}
return super.getWindowOrigin( );
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
index 3089ecd..a3d8fd6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -264,7 +264,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget();
OS.gtk_widget_realize(handle);
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
index 6f3b161..4ad4a57 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -204,7 +204,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -247,15 +247,15 @@
width = wHint == SWT.DEFAULT ? w [0] : wHint;
height = hHint == SWT.DEFAULT ? h [0] : 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) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
int xborder = 0, yborder = 0;
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
if (OS.GTK3) {
GtkBorder tmp = new GtkBorder();
long /*int*/ context = OS.gtk_widget_get_style_context (handle);
@@ -420,7 +420,7 @@
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
if ((this.style & SWT.BORDER) != 0) {
return getThickness (handle).x;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index 00e157c..b30e9a6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.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
@@ -189,9 +189,9 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- Point size = super.computeSize (wHint, hHint, changed);
+ Point size = super.computeSizeInPixels (wHint, hHint, changed);
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
@@ -209,7 +209,7 @@
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget();
forceResize ();
long /*int*/ clientHandle = clientHandle ();
@@ -232,8 +232,8 @@
}
@Override
-public Rectangle getClientArea () {
- Rectangle clientRectangle = super.getClientArea ();
+Rectangle getClientAreaInPixels () {
+ Rectangle clientRectangle = super.getClientAreaInPixels ();
if (OS.GTK3) {
/*
@@ -352,7 +352,7 @@
if (newIndex != -1) {
Control control = items [newIndex].getControl ();
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea());
+ control.setBoundsInPixels (getClientAreaInPixels());
control.setVisible (true);
}
Event event = new Event ();
@@ -571,7 +571,7 @@
TabItem item = items [(int)/*64*/page_num];
Control control = item.getControl ();
if (control != null && !control.isDisposed ()) {
- control.setBounds(getClientArea());
+ control.setBoundsInPixels(getClientAreaInPixels());
control.setVisible (true);
}
Event event = new Event();
@@ -634,11 +634,11 @@
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);
}
@@ -747,7 +747,7 @@
TabItem item = items [index];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
}
}
}
@@ -824,7 +824,7 @@
TabItem item = items [newIndex];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
control.setVisible (true);
}
if (notify) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index 90e28ee..19feb36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.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
@@ -153,6 +153,11 @@
* @since 3.4
*/
public Rectangle getBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
checkWidget();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (handle, allocation);
@@ -306,7 +311,7 @@
}
}
if (newControl != null) {
- newControl.setBounds (parent.getClientArea ());
+ newControl.setBoundsInPixels (parent.getClientAreaInPixels ());
newControl.setVisible (true);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 991d930..3b6d869 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -486,7 +486,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -499,7 +499,7 @@
* the number of items in the table.
*/
if (OS.GTK3 && hHint == SWT.DEFAULT && size.y == getHeaderHeight()) {
- size.y = getItemCount() * getItemHeight() + getHeaderHeight();
+ size.y = getItemCount() * getItemHeightInPixels() + getHeaderHeight();
}
/*
@@ -508,7 +508,7 @@
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
@@ -1153,7 +1153,7 @@
}
@Override
-public Rectangle getClientArea () {
+Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
OS.gtk_widget_realize (handle);
@@ -1170,7 +1170,7 @@
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- rect.y += getHeaderHeight();
+ rect.y += getHeaderHeightInPixels();
}
return rect;
}
@@ -1386,6 +1386,11 @@
* </ul>
*/
public int getGridLineWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getGridLineWidthInPixels ());
+}
+
+int getGridLineWidthInPixels () {
checkWidget();
return 0;
}
@@ -1404,6 +1409,11 @@
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
+ checkWidget ();
if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
if (columnCount > 0) {
GtkRequisition requisition = new GtkRequisition ();
@@ -1495,12 +1505,17 @@
*/
public TableItem getItem (Point point) {
checkWidget();
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+TableItem getItemInPixels (Point point) {
+ checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_widget_realize (handle);
int y = point.y;
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- y -= getHeaderHeight();
+ y -= getHeaderHeightInPixels();
}
if (!OS.gtk_tree_view_get_path_at_pos (handle, point.x, y, path, null, null, null)) return null;
if (path [0] == 0) return null;
@@ -1542,6 +1557,11 @@
* </ul>
*/
public int getItemHeight () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getItemHeightInPixels ());
+}
+
+int getItemHeightInPixels () {
checkWidget();
if (itemCount == 0) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
@@ -2609,7 +2629,7 @@
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
contentWidth [0] += imageWidth;
@@ -2619,13 +2639,14 @@
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.width = contentWidth [0];
- event.height = contentHeight [0];
+ Rectangle eventRect = new Rectangle (0, 0, contentWidth [0], contentHeight [0]);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if (isSelected) event.detail = SWT.SELECTED;
sendEvent (SWT.MeasureItem, event);
gc.dispose ();
- contentWidth [0] = event.width - imageWidth;
- if (contentHeight [0] < event.height) contentHeight [0] = event.height;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ contentWidth [0] = rect.width - imageWidth;
+ if (contentHeight [0] < rect.height) contentHeight [0] = rect.height;
if (width != 0) OS.memmove (width, contentWidth, 4);
if (height != 0) OS.memmove (height, contentHeight, 4);
if (OS.GTK3) {
@@ -2772,22 +2793,26 @@
if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) {
GdkRectangle r = new GdkRectangle();
OS.gdk_cairo_get_clip_rectangle(cr, r);
- gc.setClipping(rect.x, r.y, r.width, r.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
+
if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
rect.width = r.width;
}
} else {
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
+
}
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
event.detail = drawState;
+ Rectangle eventRect = new Rectangle (rect.x, rect.y, rect.width, rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
sendEvent (SWT.EraseItem, event);
drawForeground = null;
drawState = event.doit ? event.detail : 0;
@@ -2823,7 +2848,7 @@
gc.setBackground (item.getBackground (columnIndex));
GdkRectangle rect = new GdkRectangle ();
OS.memmove (rect, background_area, GdkRectangle.sizeof);
- gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
+ gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)));
gc.dispose ();
}
if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
@@ -2861,7 +2886,7 @@
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
// On gtk >3.9 and <3.14.8 the clip rectangle does not have image area into clip rectangle
@@ -2896,15 +2921,17 @@
}
gc.setFont (item.getFont (columnIndex));
if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
+
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x + contentX [0];
- event.y = rect.y;
- event.width = contentWidth [0];
- event.height = rect.height;
+ Rectangle eventRect = new Rectangle (rect.x + contentX [0], rect.y, contentWidth [0], rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = drawState;
sendEvent (SWT.PaintItem, event);
gc.dispose();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index 47ab211..9c80d2c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.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
@@ -12,10 +12,10 @@
import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a column in a table widget.
@@ -320,6 +320,11 @@
* </ul>
*/
public int getWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
checkWidget();
if (!OS.gtk_tree_view_column_get_visible (handle)) {
return 0;
@@ -447,7 +452,7 @@
}
OS.g_free (iter);
}
- setWidth(width);
+ setWidthInPixels(width);
}
@Override
@@ -689,6 +694,11 @@
* </ul>
*/
public void setWidth (int width) {
+ checkWidget ();
+ setWidthInPixels (DPIUtil.autoScaleUp (width));
+}
+
+void setWidthInPixels (int width) {
checkWidget();
if (width < 0) return;
if (width == lastWidth) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index 192f0e7..51db5f9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.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
@@ -267,6 +267,23 @@
* @since 3.2
*/
public Rectangle getBounds () {
+ return DPIUtil.autoScaleDown (getBoundsinPixels ());
+}
+
+/**
+ * Returns a rectangle describing the size and location of the receiver's
+ * text relative to its parent.
+ *
+ * @return the bounding rectangle of the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.105
+ */
+Rectangle getBoundsinPixels () {
// TODO fully test on early and later versions of GTK
// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
checkWidget ();
@@ -316,7 +333,7 @@
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -353,6 +370,11 @@
* </ul>
*/
public Rectangle getBounds (int index) {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels (index));
+}
+
+Rectangle getBoundsInPixels (int index) {
checkWidget();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
long /*int*/ parentHandle = parent.handle;
@@ -379,7 +401,7 @@
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -542,6 +564,11 @@
*/
public Rectangle getImageBounds (int index) {
checkWidget ();
+ return DPIUtil.autoScaleDown (getImageBoundsInPixels (index));
+}
+
+Rectangle getImageBoundsInPixels (int index) {
+ checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
long /*int*/ parentHandle = parent.handle;
long /*int*/ column = 0;
@@ -676,6 +703,11 @@
*/
public Rectangle getTextBounds (int index) {
checkWidget ();
+ return DPIUtil.autoScaleDown (getTextBoundsInPixels (index));
+}
+
+Rectangle getTextBoundsInPixels (int index) {
+ checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return new Rectangle (0, 0, 0, 0);
@@ -731,7 +763,7 @@
Image image = _getImage(index);
int imageWidth = 0;
if (image != null) {
- imageWidth = image.getBounds ().width;
+ imageWidth = image.getBoundsInPixels ().width;
}
if (x [0] < imageWidth) {
rect.x += imageWidth;
@@ -1134,8 +1166,8 @@
OS.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
if (!parent.pixbufSizeSet) {
if (image != null) {
- int iWidth = image.getBounds ().width;
- int iHeight = image.getBounds ().height;
+ int iWidth = image.getBoundsInPixels ().width;
+ int iHeight = image.getBoundsInPixels ().height;
if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
OS.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
parent.pixbufSizeSet = true;
@@ -1167,7 +1199,7 @@
int [] w = new int [1];
long /*int*/ pixbufRenderer = parent.getPixbufRenderer(column);
OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
- if (w[0] < image.getBounds().width) {
+ if (w[0] < image.getBoundsInPixels().width) {
/*
* There is no direct way to clear the cell renderer width so we
* are relying on the fact that it is done as part of modifying
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index a2ee2e1..4a8f500 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.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
@@ -549,7 +549,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -582,14 +582,14 @@
if (height == 0) height = DEFAULT_HEIGHT;
width = wHint == SWT.DEFAULT ? width : wHint;
height = 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) {
+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);
int xborder = 0, yborder = 0;
if ((style & SWT.SINGLE) != 0) {
if (OS.GTK3) {
@@ -833,9 +833,9 @@
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
- if ((style & SWT.MULTI) != 0) return super.getBorderWidth ();
+ if ((style & SWT.MULTI) != 0) return super.getBorderWidthInPixels ();
if ((this.style & SWT.BORDER) != 0) {
return getThickness (handle).x;
}
@@ -877,6 +877,11 @@
*/
public Point getCaretLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getCaretLocationInPixels());
+}
+
+Point getCaretLocationInPixels () {
+ checkWidget ();
if ((style & SWT.SINGLE) != 0) {
int index = OS.gtk_editable_get_position (handle);
index = OS.gtk_entry_text_index_to_layout_index (handle, index);
@@ -885,7 +890,7 @@
long /*int*/ layout = OS.gtk_entry_get_layout (handle);
PangoRectangle pos = new PangoRectangle ();
OS.pango_layout_index_to_pos (layout, index, pos);
- int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth ();
+ int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidthInPixels ();
int y = offset_y [0] + OS.PANGO_PIXELS (pos.y);
return new Point (x, y);
}
@@ -1409,7 +1414,7 @@
* The top pixel does not include the widget trimming.
* </p>
*
- * @return the pixel position of the top line
+ * @return the point position of the top line
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1418,6 +1423,11 @@
*/
public int getTopPixel () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getTopPixelInPixels());
+}
+
+int getTopPixelInPixels () {
+ checkWidget ();
if ((style & SWT.SINGLE) != 0) return 0;
byte [] position = new byte [ITER_SIZEOF];
GdkRectangle rect = new GdkRectangle ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index fa5807b..12e223f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.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
@@ -162,7 +162,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -299,10 +299,15 @@
*/
public ToolItem getItem (Point point) {
checkWidget();
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+
+ToolItem getItemInPixels (Point point) {
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
ToolItem[] items = getItems();
for (int i=0; i<items.length; i++) {
- if (items[i].getBounds().contains(point)) return items[i];
+ if (items[i].getBoundsInPixels().contains(point)) return items[i];
}
return null;
}
@@ -475,9 +480,9 @@
event.detail = SWT.ARROW;
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (widget, allocation);
- event.x = allocation.x;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - allocation.width - event.x;
- event.y = allocation.y + allocation.height;
+ event.x = DPIUtil.autoScaleDown(allocation.x);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth () - allocation.width) - event.x;
+ event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
break;
case SWT.RADIO :
if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index 0c03576..d785bab 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -299,6 +299,11 @@
* </ul>
*/
public Rectangle getBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
checkWidget();
parent.forceResize ();
long /*int*/ topHandle = topHandle ();
@@ -453,6 +458,11 @@
* </ul>
*/
public int getWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getWidthInPixels ());
+}
+
+int getWidthInPixels () {
checkWidget();
parent.forceResize ();
long /*int*/ topHandle = topHandle ();
@@ -523,9 +533,9 @@
event.detail = SWT.ARROW;
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
- event.x = allocation.x;
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - allocation.width - event.x;
- event.y = allocation.y + allocation.height;
+ event.x = DPIUtil.autoScaleDown(allocation.x);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()- allocation.width) - event.x;
+ event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
}
break;
}
@@ -869,13 +879,13 @@
* case can occur when the control is a
* combo box.
*/
- Rectangle itemRect = getBounds ();
- control.setSize (itemRect.width, itemRect.height);
+ Rectangle itemRect = getBoundsInPixels ();
+ control.setSizeInPixels (itemRect.width, itemRect.height);
resizeHandle(itemRect.width, itemRect.height);
- Rectangle rect = control.getBounds ();
+ 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);
}
}
@@ -988,7 +998,7 @@
*/
int [] x = new int [1], y = new int [1];
gdk_window_get_device_position (parent.paintWindow (), x, y, null);
- if (getBounds ().contains (x [0], y [0])) {
+ if (getBoundsInPixels ().contains (x [0], y [0])) {
OS.gtk_widget_hide (handle);
OS.gtk_widget_show (handle);
}
@@ -1249,6 +1259,11 @@
* </ul>
*/
public void setWidth (int width) {
+ checkWidget ();
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
checkWidget();
if ((style & SWT.SEPARATOR) == 0) return;
if (width < 0) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 8ad085a..2b0f892 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.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
@@ -252,7 +252,7 @@
}
OS.gtk_widget_realize(handle);
Region region = new Region (display);
- region.add(polyline);
+ region.add(DPIUtil.autoScaleDown(polyline));
if (OS.GTK3) {
OS.gtk_widget_shape_combine_region (handle, region.handle);
} else {
@@ -711,13 +711,17 @@
*/
public void setLocation (int x, int y) {
checkWidget ();
+ setLocation (new Point (x, y));
+}
+
+void setLocationInPixels (int x, int y) {
+ checkWidget ();
this.x = x;
this.y = y;
if ((style & SWT.BALLOON) != 0) {
if (OS.gtk_widget_get_visible (handle)) configure ();
}
}
-
/**
* Sets the location of the receiver, which must be a tooltip,
* to the point specified by the argument which is relative
@@ -742,8 +746,13 @@
*/
public void setLocation (Point location) {
checkWidget ();
+ setLocationInPixels(DPIUtil.autoScaleUp(location));
+}
+
+void setLocationInPixels (Point location) {
+ checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ setLocationInPixels (location.x, location.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 1870a87..cfb0019 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.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
@@ -195,7 +195,7 @@
int newX = bounds.x + bounds.width / 2;
int newY = bounds.y;
- Point point = display.map (parent, null, newX, newY);
+ Point point = display.mapInPixels (parent, null, newX, newY);
display.setCursorLocation (point);
/*
@@ -228,7 +228,7 @@
newY = bounds.y + bounds.height / 2;
}
- Point point = display.map (parent, null, newX, newY);
+ Point point = display.mapInPixels (parent, null, newX, newY);
display.setCursorLocation (point);
/*
@@ -318,7 +318,7 @@
long /*int*/ region = OS.gdk_region_new ();
GdkRectangle rect = new GdkRectangle();
for (int i = 0; i < rects.length; i++) {
- Rectangle r = parent != null ? display.map(parent, null, rects[i]) : rects[i];
+ Rectangle r = parent != null ? display.mapInPixels(parent, null, rects[i]) : rects[i];
rect.x = r.x;
rect.y = r.y;
rect.width = r.width + 1;
@@ -376,6 +376,16 @@
Rectangle [] result = new Rectangle [rectangles.length];
for (int i = 0; i < rectangles.length; i++) {
Rectangle current = rectangles [i];
+ result [i] = DPIUtil.autoScaleDown (new Rectangle (current.x, current.y, current.width, current.height));
+ }
+ return result;
+}
+
+Rectangle [] getRectanglesInPixels () {
+ checkWidget();
+ Rectangle [] result = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ Rectangle current = rectangles [i];
result [i] = new Rectangle (current.x, current.y, current.width, current.height);
}
return result;
@@ -443,10 +453,10 @@
rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
}
Event event = new Event ();
- event.x = oldX + xChange;
- event.y = oldY + yChange;
+ Rectangle eventRect = new Rectangle (oldX + xChange, oldY + yChange, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if (parent != null && (parent.style & SWT.MIRRORED) != 0) {
- event.x = parent.getClientWidth () - event.width - event.x;
+ event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()) - event.width - event.x;
}
if ((style & SWT.RESIZE) != 0) {
resizeRectangles (xChange, yChange);
@@ -568,12 +578,12 @@
}
Event event = new Event ();
if (parent == null) {
- event.x = newX [0];
- event.y = newY [0];
+ Rectangle eventRect = new Rectangle (newX [0], newY [0], 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
} else {
- Point screenCoord = display.map (parent, null, newX [0], newY [0]);
- event.x = screenCoord.x;
- event.y = screenCoord.y;
+ Point screenCoord = display.mapInPixels (parent, null, newX [0], newY [0]);
+ Rectangle eventRect = new Rectangle (screenCoord.x, screenCoord.y, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
}
if ((style & SWT.RESIZE) != 0) {
resizeRectangles (newX [0] - oldX, newY [0] - oldY);
@@ -772,7 +782,7 @@
OS.gtk_widget_shape_combine_region (overlay, region);
OS.gtk_widget_input_shape_combine_region (overlay, region);
OS.gdk_region_destroy (region);
- Rectangle bounds = display.getBounds();
+ Rectangle bounds = display.getBoundsInPixels();
OS.gtk_window_move (overlay, bounds.x, bounds.y);
OS.gtk_window_resize (overlay, bounds.width, bounds.height);
OS.gtk_widget_show (overlay);
@@ -1050,6 +1060,16 @@
checkWidget();
if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
int length = rectangles.length;
+ for (int i = 0; i < length; i++) {
+ rectangles [i] = DPIUtil.autoScaleUp (rectangles [i]);
+ }
+ setRectanglesInPixels (rectangles);
+}
+
+void setRectanglesInPixels (Rectangle [] rectangles) {
+ checkWidget();
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int length = rectangles.length;
this.rectangles = new Rectangle [length];
for (int i = 0; i < length; i++) {
Rectangle current = rectangles [i];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index 6d8ede3..36b8edc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.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
@@ -293,7 +293,7 @@
OS.gtk_widget_get_allocation (widget, widgetAllocation);
int xoffset = (int) Math.floor (widgetAllocation.x + ((widgetAllocation.width -OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
int yoffset = (int) Math.floor (widgetAllocation.y + ((widgetAllocation.height - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
- Rectangle b = image.getBounds();
+ Rectangle b = image.getBoundsInPixels();
long /*int*/ gdkImagePtr = OS.gdk_drawable_get_image (image.mask, 0, 0, b.width, b.height);
if (gdkImagePtr == 0) error(SWT.ERROR_NO_HANDLES);
GdkImage gdkImage = new GdkImage();
@@ -308,7 +308,8 @@
int theByte = maskData [index] & 0xFF;
int mask = 1 << (x & 0x7);
if ((theByte & mask) != 0) {
- region.add (xoffset + x, yoffset + y, 1, 1);
+ Rectangle rect = DPIUtil.autoScaleDown(new Rectangle(xoffset + x, yoffset + y, 1, 1));
+ region.add(rect.x, rect.y, rect.width, rect.height);
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index c70aa25..bf9660d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.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
@@ -537,7 +537,7 @@
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+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;
@@ -551,7 +551,7 @@
* the number of items in the table.
*/
if (OS.GTK3 && hHint == SWT.DEFAULT && size.y == getHeaderHeight()) {
- size.y = getItemCount() * getItemHeight() + getHeaderHeight();
+ size.y = getItemCount() * getItemHeightInPixels() + getHeaderHeight();
}
/*
@@ -560,7 +560,7 @@
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
@@ -1146,7 +1146,7 @@
}
@Override
-public Rectangle getClientArea () {
+Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
OS.gtk_widget_realize (handle);
@@ -1163,7 +1163,7 @@
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- rect.y += getHeaderHeight();
+ rect.y += getHeaderHeightInPixels();
}
return rect;
}
@@ -1389,6 +1389,11 @@
* @since 3.1
*/
public int getGridLineWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getGridLineWidthInPixels ());
+}
+
+int getGridLineWidthInPixels () {
checkWidget();
return 0;
}
@@ -1407,6 +1412,11 @@
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
+ checkWidget ();
if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
if (columnCount > 0) {
GtkRequisition requisition = new GtkRequisition ();
@@ -1503,6 +1513,11 @@
* </ul>
*/
public TreeItem getItem (Point point) {
+ checkWidget();
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+TreeItem getItemInPixels (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
long /*int*/ [] path = new long /*int*/ [1];
@@ -1510,7 +1525,7 @@
int x = point.x;
int y = point.y;
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- y -= getHeaderHeight();
+ y -= getHeaderHeightInPixels();
}
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
long /*int*/ [] columnHandle = new long /*int*/ [1];
@@ -1569,6 +1584,11 @@
*/
public int getItemHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getItemHeightInPixels ());
+}
+
+int getItemHeightInPixels () {
+ checkWidget ();
int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
if (itemCount == 0) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
@@ -2626,7 +2646,7 @@
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
contentWidth [0] += imageWidth;
@@ -2636,8 +2656,8 @@
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.width = contentWidth [0];
- event.height = contentHeight [0];
+ Rectangle eventRect = new Rectangle (0, 0, contentWidth [0], contentHeight [0]);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
if (OS.gtk_tree_selection_path_is_selected (selection, path)) {
@@ -2646,8 +2666,9 @@
OS.gtk_tree_path_free (path);
sendEvent (SWT.MeasureItem, event);
gc.dispose ();
- contentWidth [0] = event.width - imageWidth;
- if (contentHeight [0] < event.height) contentHeight [0] = event.height;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ contentWidth [0] = rect.width - imageWidth;
+ if (contentHeight [0] < rect.height) contentHeight [0] = rect.height;
if (width != 0) OS.memmove (width, contentWidth, 4);
if (height != 0) OS.memmove (height, contentHeight, 4);
if (OS.GTK3) {
@@ -2786,21 +2807,23 @@
if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) {
GdkRectangle r = new GdkRectangle();
OS.gdk_cairo_get_clip_rectangle(cr, r);
- gc.setClipping(rect.x, r.y, r.width, r.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
rect.width = r.width;
}
} else {
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
}
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
+ Rectangle eventRect = new Rectangle (rect.x, rect.y, rect.width, rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = drawState;
sendEvent (SWT.EraseItem, event);
drawForeground = null;
@@ -2828,7 +2851,7 @@
gc.setBackground (item.getBackground (columnIndex));
GdkRectangle rect = new GdkRectangle ();
OS.memmove (rect, background_area, GdkRectangle.sizeof);
- gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
+ gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)));
gc.dispose ();
}
if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
@@ -2866,7 +2889,7 @@
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
// On gtk >3.9 and <3.14.8 the clip rectangle does not have image area into clip rectangle
@@ -2904,16 +2927,16 @@
rect.x = getClientWidth () - rect.width - rect.x;
}
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x + contentX [0];
- event.y = rect.y;
- event.width = contentWidth [0];
- event.height = rect.height;
+ Rectangle eventRect = new Rectangle (rect.x + contentX [0], rect.y, contentWidth [0], rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = drawState;
sendEvent(SWT.PaintItem, event);
gc.dispose();
@@ -2995,7 +3018,7 @@
}
if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (item.parent != this) return;
- Rectangle rect = item.getBounds();
+ Rectangle rect = item.getBoundsInPixels();
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_widget_realize (handle);
if (!OS.gtk_tree_view_get_path_at_pos(handle, rect.x, rect.y, path, null, null, null)) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index 4457e6b..ff689dd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.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
@@ -12,10 +12,10 @@
import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a column in a tree widget.
@@ -322,6 +322,11 @@
* </ul>
*/
public int getWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getWidthInPixels ());
+}
+
+int getWidthInPixels () {
checkWidget();
if (!OS.gtk_tree_view_column_get_visible (handle)) {
return 0;
@@ -449,7 +454,7 @@
}
OS.g_free (iter);
}
- setWidth(width);
+ setWidthInPixels(width);
}
@Override
@@ -689,6 +694,11 @@
* </ul>
*/
public void setWidth (int width) {
+ checkWidget ();
+ setWidthInPixels (DPIUtil.autoScaleUp (width));
+}
+
+void setWidthInPixels (int width) {
checkWidget();
if (width < 0) return;
if (width == lastWidth) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index 6bdf35a..c160728 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.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
@@ -422,6 +422,11 @@
* @since 3.1
*/
public Rectangle getBounds (int index) {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels (index));
+}
+
+Rectangle getBoundsInPixels (int index) {
// TODO fully test on early and later versions of GTK
checkWidget();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -450,7 +455,7 @@
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -467,6 +472,11 @@
* </ul>
*/
public Rectangle getBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
// TODO fully test on early and later versions of GTK
// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
checkWidget ();
@@ -512,7 +522,7 @@
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -701,6 +711,11 @@
* @since 3.1
*/
public Rectangle getImageBounds (int index) {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getImageBoundsInPixels(index));
+}
+
+Rectangle getImageBoundsInPixels (int index) {
// TODO fully test on early and later versions of GTK
checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -915,6 +930,11 @@
*/
public Rectangle getTextBounds (int index) {
checkWidget ();
+ return DPIUtil.autoScaleDown(getTextBoundsInPixels(index));
+}
+
+Rectangle getTextBoundsInPixels (int index) {
+ checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return new Rectangle (0, 0, 0, 0);
@@ -966,7 +986,7 @@
Image image = _getImage(index);
int imageWidth = 0;
if (image != null) {
- imageWidth = image.getBounds ().width;
+ imageWidth = image.getBoundsInPixels ().width;
}
if (x [0] < imageWidth) {
rect.x += imageWidth;
@@ -1502,8 +1522,8 @@
OS.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
if (!parent.pixbufSizeSet) {
if (image != null) {
- int iWidth = image.getBounds ().width;
- int iHeight = image.getBounds ().height;
+ int iWidth = image.getBoundsInPixels ().width;
+ int iHeight = image.getBoundsInPixels ().height;
if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
OS.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
parent.pixbufSizeSet = true;
@@ -1535,7 +1555,7 @@
int [] w = new int [1];
long /*int*/ pixbufRenderer = parent.getPixbufRenderer(column);
OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
- if (w[0] < image.getBounds().width) {
+ if (w[0] < image.getBoundsInPixels().width) {
/*
* There is no direct way to clear the cell renderer width so we
* are relying on the fact that it is done as part of modifying
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 76adec8..3ef6774 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.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
@@ -1352,7 +1352,9 @@
if (eventTable == null && !display.filters (eventType)) {
return;
}
- if (event == null) event = new Event ();
+ if (event == null) {
+ event = new Event();
+ }
event.type = eventType;
event.display = display;
event.widget = this;
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 5eedc6d..c97d3a1 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 @@
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 @@
* <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 @@
* @see #getBounds
*/
public Rectangle getClientArea () {
- return getBounds ();
+ checkDevice ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+
+private Rectangle getClientAreaInPixels () {
+ return getBoundsInPixels ();
}
/**
@@ -695,6 +707,7 @@
* @see #create
*/
protected void init () {
+ DPIUtil.setDeviceZoom (getDeviceZoom ());
if (debug) {
if (!OS.IsWinCE) OS.GdiSetBatchLimit(1);
}
@@ -991,4 +1004,16 @@
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 773e042..f76b4e0 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 @@
* @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 @@
* @return the average character width of the font
*/
public int getAverageCharWidth() {
- return handle.tmAveCharWidth;
+ return DPIUtil.autoScaleDown(handle.tmAveCharWidth);
}
/**
@@ -113,7 +114,7 @@
* @return the descent of the font
*/
public int getDescent() {
- return handle.tmDescent;
+ return DPIUtil.autoScaleDown(handle.tmDescent);
}
/**
@@ -128,7 +129,7 @@
* @see #getLeading
*/
public int getHeight() {
- return handle.tmHeight;
+ return DPIUtil.autoScaleDown(handle.tmHeight);
}
/**
@@ -139,7 +140,7 @@
* @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 0c01422..f99800b 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 @@
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 @@
* <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 @@
* <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 @@
*
* @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 @@
* </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 @@
* @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 @@
* <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 @@
* <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 @@
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 @@
}
/* 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 @@
* </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 @@
* </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 @@
* @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 @@
* <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 @@
* <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 @@
* </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 (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 @@
* </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 @@
*/
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 @@
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 @@
* </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 @@
* </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 @@
* </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 @@
* </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 @@
* </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 @@
* @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 @@
* <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 @@
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 @@
* @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 @@
*
* @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 @@
* @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 (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 @@
* @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 @@
* <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 @@
*
* @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 @@
* <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 @@
* </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 @@
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 @@
*
* @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 @@
* </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 @@
* <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 @@
* <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 @@
* <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 64bac08..f4ad003 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 @@
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 @@
/**
* 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 @@
*/
Image (Device device) {
super(device);
+ currentDeviceZoom = DPIUtil.getDeviceZoom ();
}
/**
@@ -197,6 +199,9 @@
*/
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 @@
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 @@
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 @@
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, 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, 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 @@
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, 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, 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, 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, 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 @@
*/
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 @@
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 @@
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 @@
* 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 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 @@
* 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 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 5684d1c..7b845f2 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 @@
* <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 @@
* <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 @@
* <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 @@
* <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 @@
* <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 @@
* <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 @@
* <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 @@
* <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 @@
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 @@
* <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 @@
* <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 c5a5d8c..01c8929 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 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 97b51d1..d7cfba8 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 @@
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -110,11 +111,15 @@
* </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 (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 (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 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 (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 @@
*
* @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 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 (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 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 (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 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 (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 (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 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 (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 b191dc2..a1556d0 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 @@
* </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 @@
* </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, 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 @@
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 @@
* <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 Rectangle getBounds () {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
computeRuns(null);
int width = 0;
if (wrapWidth != -1) {
@@ -1634,6 +1656,10 @@
*/
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 @@
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 @@
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 @@
* <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 int getIndent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getIndentInPixels());
+}
+
+int getIndentInPixels () {
return indent;
}
@@ -1836,8 +1870,12 @@
* <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 @@
* <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 @@
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 @@
* <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 (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 @@
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 @@
*/
public int getSpacing () {
checkLayout();
+ return DPIUtil.autoScaleDown(getSpacingInPixels());
+}
+
+int getSpacingInPixels () {
return lineSpacing;
}
@@ -2580,6 +2633,10 @@
*/
public int getWidth () {
checkLayout();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
return wrapWidth;
}
@@ -2596,6 +2653,10 @@
*/
public int getWrapIndent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getWrapIndentInPixels());
+}
+
+int getWrapIndentInPixels () {
return wrapIndent;
}
@@ -2852,11 +2913,15 @@
* <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 @@
* <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 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 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 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 @@
* <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 @@
* 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 c7f96b0..2a26a1b 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 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 @@
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 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 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 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 3941a17..d2c4b54 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 @@
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 @@
* 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 839ba18..aba6517 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a selectable user interface object that
@@ -213,7 +213,7 @@
*/
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 @@
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 @@
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 @@
}
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 1c17b19..c283f29 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 @@
* @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 @@
*/
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 @@
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 0aa6167..0023de9 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 @@
*/
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 Point getLocation () {
checkWidget();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
return new Point (x, y);
}
@@ -201,8 +210,12 @@
*/
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 @@
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 @@
*/
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 (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 @@
*/
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 (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 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 (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 e3abaa9..19b311f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -12,11 +12,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class are controls that allow the user
@@ -622,8 +622,7 @@
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 @@
*/
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 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 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 @@
}
@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 @@
*/
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 @@
}
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 @@
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 09b3f7a..4ddebda 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 @@
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 @@
}
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 @@
*
* @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 @@
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 @@
}
@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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 0f692f7..6ed15ef 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.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 checkBorder () {
- if (getBorderWidth () == 0) style &= ~SWT.BORDER;
+ if (getBorderWidthInPixels () == 0) style &= ~SWT.BORDER;
}
void checkBuffered () {
@@ -618,7 +619,10 @@
* @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 @@
* @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 @@
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 (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 @@
*/
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 @@
* <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 Point getLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
forceResize ();
RECT rect = new RECT ();
OS.GetWindowRect (topHandle (), rect);
@@ -1471,14 +1494,12 @@
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 @@
* <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 @@
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 @@
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 (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 @@
*/
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 @@
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 @@
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 @@
* <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 @@
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 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 @@
* 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 (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 @@
*/
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 (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 @@
* 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 @@
*/
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 @@
* 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 (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 @@
* 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 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 @@
* 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 (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 @@
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 d68f57d..71f50c2 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 @@
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 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 @@
*/
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 @@
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 @@
* 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 @@
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 @@
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 9742ca5..1931910 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 @@
*/
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 @@
*/
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 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 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 (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 @@
* <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 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 @@
* </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 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 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 (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 828e7ab..e30d1a8 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 @@
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 @@
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 bf7af0a..6f42df6 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 @@
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 @@
}
}
-@Override
-public Rectangle getBounds () {
+@Override Rectangle getBoundsInPixels () {
checkWidget ();
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
@@ -509,11 +507,10 @@
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 @@
* 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 @@
return new Rectangle (0, 0, width, height);
}
}
- return super.getClientArea ();
+ return super.getClientAreaInPixels ();
}
/**
@@ -646,8 +643,7 @@
return result;
}
-@Override
-public Point getLocation () {
+@Override Point getLocationInPixels () {
checkWidget ();
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
@@ -660,7 +656,7 @@
return new Point (lpwndpl.left, lpwndpl.top);
}
}
- return super.getLocation ();
+ return super.getLocationInPixels ();
}
/**
@@ -726,8 +722,7 @@
return getText ();
}
-@Override
-public Point getSize () {
+@Override Point getSizeInPixels () {
checkWidget ();
if (!OS.IsWinCE) {
if (OS.IsIconic (handle)) {
@@ -744,7 +739,7 @@
return new Point (width, height);
}
}
- return super.getSize ();
+ return super.getSizeInPixels ();
}
/**
@@ -871,7 +866,7 @@
}
@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 @@
return;
}
}
- super.setBounds (x, y, width, height, flags, defer);
+ super.setBoundsInPixels (x, y, width, height, flags, defer);
}
/**
@@ -1014,7 +1009,7 @@
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 @@
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 @@
}
if (sameExtent) {
resized = true;
- Rectangle rect = getClientArea ();
+ Rectangle rect = getClientAreaInPixels ();
oldWidth = rect.width;
oldHeight = rect.height;
sendEvent (SWT.Resize);
@@ -1437,13 +1432,13 @@
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 @@
@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 @@
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 629009e..b4d98a3 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 @@
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 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 @@
* </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 @@
@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 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 @@
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 @@
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 @@
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, 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 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, 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 @@
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 @@
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 ddfcb84..789ff0f 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 @@
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 @@
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 @@
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 int getSpacing () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getSpacingInPixels ());
+}
+
+int getSpacingInPixels () {
return spacing;
}
@@ -438,13 +441,13 @@
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 @@
*/
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 @@
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 @@
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 @@
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 a088e06..c2778a8 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.graphics.*;
-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
@@ -189,9 +190,9 @@
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 int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeaderHeightInPixels());
+}
+
+int getHeaderHeightInPixels () {
return Math.max (parent.getBandHeight (), imageHeight);
}
@@ -312,6 +317,10 @@
*/
public int getHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeightInPixels());
+}
+
+int getHeightInPixels () {
return height;
}
@@ -382,7 +391,7 @@
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 @@
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 @@
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 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 @@
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 8436df5..19fc56e 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 @@
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 @@
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 @@
return null;
}
-@Override
-public Rectangle getClientArea () {
+@Override Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
@@ -345,10 +342,10 @@
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 @@
@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 7819623..764143a 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 @@
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 7133858..fa1826b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -13,7 +13,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -128,10 +128,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 e672bd8..261e1c2 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 @@
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 @@
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 @@
}
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 @@
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 @@
@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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 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 ce40298..19856dd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -14,7 +14,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -215,8 +215,7 @@
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 @@
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 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 @@
@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 @@
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 5aefe29..a08c092 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 @@
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 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 (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 a85c6e7..fc7eb8f 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 @@
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 @@
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 @@
*/
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 @@
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 @@
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 0245cba..e3f76f4 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 @@
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 efae7ca..659b2e0 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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
}
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 3c423e4..e2e716a 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 @@
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 @@
}
@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 @@
* 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 ab68be0..df731bd 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 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 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 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 a71d676..239711b 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 @@
*/
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 @@
*/
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 fe67133..3ae9421 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 @@
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 @@
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 @@
} else {
y = Math.max (y, monitorRect.y);
}
- setLocation (x, y);
+ setLocationInPixels (x, y);
}
/**
@@ -930,11 +931,9 @@
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 @@
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 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 @@
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 @@
}
@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 @@
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 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 @@
}
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 (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 ed5a219..324fd88 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 @@
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 @@
}
@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 9a57b44..963fb7e 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 @@
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 @@
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 @@
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 901aaf7..28e9358 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class implement the notebook user interface
@@ -193,10 +193,9 @@
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 @@
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 @@
return this;
}
-@Override
-public Rectangle getClientArea () {
+@Override Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
@@ -473,7 +470,7 @@
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 @@
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 @@
@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 @@
TabItem item = items [index];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
}
}
}
@@ -751,7 +748,7 @@
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 @@
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 @@
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 744e05c..f1f9834 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 @@
*
* @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 @@
}
}
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 fabcfc8..1301d64 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 @@
}
}
-@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 @@
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 @@
*/
public int getGridLineWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getGridLineWidthInPixels());
+}
+
+int getGridLineWidthInPixels () {
return GRID_WIDTH;
}
@@ -2478,6 +2480,10 @@
*/
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 (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 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 @@
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 @@
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 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 @@
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 @@
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.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.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 @@
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 @@
* 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 @@
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.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 @@
}
@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 @@
* 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 @@
@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 @@
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 @@
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 @@
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 1c079bd..ebb755a 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 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 @@
headerImage = image;
}
if (headerImage != null) {
- Rectangle bounds = headerImage.getBounds ();
+ Rectangle bounds = headerImage.getBoundsInPixels ();
headerWidth += bounds.width;
}
int margin = 0;
@@ -380,7 +385,8 @@
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 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 8e11b2f..83a2c14 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 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 (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 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 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 e314e24..7543364 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 @@
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 35d889e..9f9eb48 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -14,7 +14,7 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.BidiUtil;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -664,8 +664,7 @@
}
}
-@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 @@
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 @@
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 @@
// 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 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 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 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 @@
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 @@
}
@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 @@
}
}
}
- 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 @@
@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 a43e4f9..bd3327f 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 @@
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 @@
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 @@
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 (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 @@
}
@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 @@
parent.setResizeChildren (true);
}
}
- super.setBounds (x, y, width, height, flags);
+ super.setBoundsInPixels (x, y, width, height, flags);
}
@Override
@@ -1502,7 +1502,7 @@
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 @@
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 83e2c59..e1742c7 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.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a selectable user interface object
@@ -235,6 +235,10 @@
*/
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 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 @@
* 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 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 @@
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 e1f4490..15ddacf 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 @@
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 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 (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 06baecf..44e2a01 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 @@
*/
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 @@
* 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 @@
* 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 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 @@
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 @@
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 1e0de9f..7b52712 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class provide a selectable user interface object
@@ -525,15 +525,15 @@
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 @@
}
}
}
- 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 @@
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 @@
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 @@
}
}
}
- 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 @@
}
//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 @@
}
}
}
- 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 @@
} 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 @@
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 @@
} 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 @@
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 @@
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 @@
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 @@
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 @@
*/
public int getGridLineWidth () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getGridLineWidthInPixels ());
+}
+
+int getGridLineWidthInPixels () {
return GRID_WIDTH;
}
@@ -2947,6 +2945,10 @@
*/
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 @@
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 @@
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 @@
*/
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 @@
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 @@
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 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.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.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.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 @@
@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 @@
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 @@
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 d870682..2c07d2d 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 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 @@
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 @@
headerImage = image;
}
if (headerImage != null) {
- Rectangle bounds = headerImage.getBounds ();
+ Rectangle bounds = headerImage.getBoundsInPixels ();
headerWidth += bounds.width;
}
int margin = 0;
@@ -399,7 +405,7 @@
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 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 5e9f9f6..9e98f80 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 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 (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 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 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 e97e92e..9bea443 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 @@
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 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 @@
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, 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 @@
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 @@
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 @@
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;
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
index 6e69e0b..6c6dbdf 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
@@ -139,11 +139,11 @@
PaletteData palette = imageData.palette;
int pixel = imageData.getPixel(destX + 4, destY);
assertEquals(":a:", whiteRGB, palette.getRGB(pixel));
- pixel = imageData.getPixel(destX + 5, destY);
+ pixel = imageData.getPixel(destX + 6 , destY);
assertEquals(":b:", blueRGB, palette.getRGB(pixel));
pixel = imageData.getPixel(destX + 10, destY);
assertEquals(":c:", blueRGB, palette.getRGB(pixel));
- pixel = imageData.getPixel(destX + 11, destY);
+ pixel = imageData.getPixel(destX + 12, destY);
assertEquals(":d:", whiteRGB, palette.getRGB(pixel));
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
index 32379e5..27f794d 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
@@ -733,6 +733,7 @@
assertEquals(":c:", bounds, bounds1);
}
+
@Test
public void test_getImageData() {
getImageData1();
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
index 0dc9fcb..078e945 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
@@ -382,11 +382,11 @@
@Test
public void test_intersectLorg_eclipse_swt_graphics_Rectangle() {
- Rectangle rect1 = new Rectangle(0,0,50,25);
- Rectangle rect2 = new Rectangle(0,0,50,25);
+ Rectangle rect1 = new Rectangle(0,0,48,24);
+ Rectangle rect2 = new Rectangle(0,0,48,24);
Rectangle rect3 = new Rectangle(10,10,10,10);
- Rectangle rect4 = new Rectangle(50,25,10,10);
- Rectangle rect5 = new Rectangle(25,20,25,10);
+ Rectangle rect4 = new Rectangle(48,24,10,10);
+ Rectangle rect5 = new Rectangle(24,20,24,10);
Region reg = new Region(display);
reg.dispose();
@@ -435,7 +435,7 @@
reg.add(rect4);
reg.intersect(rect5);
box = reg.getBounds();
- if (!box.equals(new Rectangle(25,20,25,5))) {
+ if (!box.equals(new Rectangle(24,20,24,4))) {
reg.dispose();
fail("intersect failed 5");
}
@@ -446,7 +446,7 @@
public void test_intersectLorg_eclipse_swt_graphics_Region() {
Region reg = new Region(display);
Region reg1 = new Region(display);
- reg1.add(new Rectangle(0,0,50,25));
+ reg1.add(new Rectangle(0,0,48,24));
reg.dispose();
try {
@@ -466,7 +466,7 @@
}
Region reg2 = new Region(display);
- reg2.add(new Rectangle(0,0,50,25));
+ reg2.add(new Rectangle(0,0,48,24));
reg.add(reg1);
reg.intersect(reg2);
@@ -493,7 +493,7 @@
reg3.dispose();
Region reg4 = new Region(display);
- reg4.add(new Rectangle(50,25,10,10));
+ reg4.add(new Rectangle(48,24,10,10));
reg.intersect(reg4);
if (!reg.isEmpty()) {
@@ -504,7 +504,7 @@
}
Region reg5 = new Region(display);
- reg5.add(new Rectangle(25,20,25,10));
+ reg5.add(new Rectangle(24,20,24,10));
reg.add(reg1.getBounds().union(reg4.getBounds()));
reg.intersect(reg5);
@@ -522,7 +522,7 @@
reg.add(reg4);
reg.intersect(reg5);
box = reg.getBounds();
- if (!box.equals(new Rectangle(25,20,25,5))) {
+ if (!box.equals(new Rectangle(24,20,24,4))) {
reg.dispose();
reg1.dispose();
reg4.dispose();
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
index ad6e9cd..73d2d12 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
@@ -520,7 +520,7 @@
result = display.map(button2, null, 0, 0);
assertEquals(new Point(shellOffset.x + 200,shellOffset.y + 100), result);
result = display.map(button2, null, -3, -6);
- assertEquals(new Point(shellOffset.x + 197,shellOffset.y + 94), result);
+ assertEquals(new Point(shellOffset.x + 197, shellOffset.y + 94), result);
result = display.map(button2, null, 9, 12);
assertEquals(new Point(shellOffset.x + 209,shellOffset.y + 112), result);