diff options
author | Niraj Modi | 2016-03-12 07:14:49 +0000 |
---|---|---|
committer | Niraj Modi | 2016-03-12 07:14:49 +0000 |
commit | e02d49aefe42ac4c77b81048299ab069ddb5c2ba (patch) | |
tree | ee78920992cfda51890cca0bf5fb394c876add83 /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop | |
parent | f50994fe9b815dddd13700087e2289575a82e8b7 (diff) | |
download | eclipse.platform.swt-e02d49aefe42ac4c77b81048299ab069ddb5c2ba.tar.gz eclipse.platform.swt-e02d49aefe42ac4c77b81048299ab069ddb5c2ba.tar.xz eclipse.platform.swt-e02d49aefe42ac4c77b81048299ab069ddb5c2ba.zip |
Bug 479614 - [Graphics] HiDPI support for eclipse platform
- Windows changes
Change-Id: I9cd0004d57a2a3a2a956a71de91b10af560c08a7
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop')
8 files changed, 31 insertions, 18 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java index db76bb35c0..7dbb5dfc6b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,7 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.widgets.*; @@ -152,7 +153,7 @@ public class TableDropTargetEffect extends DropTargetEffect { } else { if (index != -1 && scrollIndex == index && scrollBeginTime != 0) { if (System.currentTimeMillis() >= scrollBeginTime) { - if (coordinates.y < table.getItemHeight()) { + if (coordinates.y < DPIUtil.autoScaleUp(table.getItemHeight())) { OS.gtk_tree_path_prev(path[0]); } else { OS.gtk_tree_path_next(path[0]); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java index 1dd5c660f0..162c67fa9e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java @@ -13,10 +13,10 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.ole.win32.*; import org.eclipse.swt.internal.win32.*; +import org.eclipse.swt.widgets.*; /** * @@ -334,7 +334,7 @@ private void drag(Event dragEvent) { int offsetX = event.offsetX; hwndDrag = topControl.handle; if ((topControl.getStyle() & SWT.RIGHT_TO_LEFT) != 0) { - offsetX = image.getBounds().width - offsetX; + offsetX = image.getBoundsInPixels().width - offsetX; RECT rect = new RECT (); OS.GetClientRect (topControl.handle, rect); hwndDrag = OS.CreateWindowEx ( @@ -366,8 +366,8 @@ private void drag(Event dragEvent) { OS.RedrawWindow (topControl.handle, null, 0, flags); } POINT pt = new POINT (); - pt.x = dragEvent.x; - pt.y = dragEvent.y; + pt.x = DPIUtil.autoScaleUp(dragEvent.x);// To Pixels + pt.y = DPIUtil.autoScaleUp(dragEvent.y);// To Pixels OS.MapWindowPoints (control.handle, 0, pt, 1); RECT rect = new RECT (); OS.GetWindowRect (hwndDrag, rect); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java index 9c4ce9ba2c..be567ca1a4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java @@ -11,10 +11,10 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.ole.win32.*; import org.eclipse.swt.internal.win32.*; +import org.eclipse.swt.widgets.*; /** * @@ -286,6 +286,8 @@ int DragEnter_64(long /*int*/ pDataObject, int grfKeyState, long pt, long /*int* } int DragEnter(long /*int*/ pDataObject, int grfKeyState, int pt_x, int pt_y, long /*int*/ pdwEffect) { + pt_x = DPIUtil.autoScaleDown(pt_x);// To Points + pt_y = DPIUtil.autoScaleDown(pt_y);// To Points selectedDataType = null; selectedOperation = DND.DROP_NONE; if (iDataObject != null) iDataObject.Release(); @@ -351,6 +353,8 @@ int DragOver_64(int grfKeyState, long pt, long /*int*/ pdwEffect) { } int DragOver(int grfKeyState, int pt_x, int pt_y, long /*int*/ pdwEffect) { + pt_x = DPIUtil.autoScaleDown(pt_x);// To Points + pt_y = DPIUtil.autoScaleDown(pt_y);// To Points if (iDataObject == null) return COM.S_FALSE; int oldKeyOperation = keyOperation; @@ -403,6 +407,8 @@ int Drop_64(long /*int*/ pDataObject, int grfKeyState, long pt, long /*int*/ pdw } int Drop(long /*int*/ pDataObject, int grfKeyState, int pt_x, int pt_y, long /*int*/ pdwEffect) { + pt_x = DPIUtil.autoScaleDown(pt_x);// To Points + pt_y = DPIUtil.autoScaleDown(pt_y);// To Points DNDEvent event = new DNDEvent(); event.widget = this; event.time = OS.GetMessageTime(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java index d841910c8f..4a4e735fcc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ImageTransfer.java @@ -181,7 +181,7 @@ public Object nativeToJava(TransferData transferData) { } } Image image = Image.win32_new(null, SWT.BITMAP, memDib); - ImageData data = image.getImageData(); + ImageData data = image.getImageDataAtCurrentZoom(); OS.DeleteObject(memDib); image.dispose(); return data; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java index 686c8f8c74..5eb5319d21 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragSourceEffect.java @@ -12,6 +12,8 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.DPIUtil.*; import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.widgets.*; @@ -142,7 +144,7 @@ public class TableDragSourceEffect extends DragSourceEffect { } else { data.transparentPixel = shdi.crColorKey << 8; } - dragSourceImage = new Image(control.getDisplay(), data); + dragSourceImage = new Image(control.getDisplay(), new AutoScaleImageDataProvider(data, DPIUtil.getDeviceZoom())); OS.SelectObject (memHdc, oldMemBitmap); OS.DeleteDC (memHdc); OS.DeleteObject (memDib); @@ -163,9 +165,9 @@ public class TableDragSourceEffect extends DragSourceEffect { long /*int*/ tableImageList = OS.SendMessage (table.handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0); if (tableImageList != 0) { int count = Math.min(selection.length, 10); - Rectangle bounds = selection[0].getBounds(0); + Rectangle bounds = DPIUtil.autoScaleUp(selection[0].getBounds(0)); for (int i = 1; i < count; i++) { - bounds = bounds.union(selection[i].getBounds(0)); + bounds = bounds.union(DPIUtil.autoScaleUp(selection[i].getBounds(0))); } long /*int*/ hDC = OS.GetDC(0); long /*int*/ hDC1 = OS.CreateCompatibleDC(hDC); @@ -183,7 +185,7 @@ public class TableDragSourceEffect extends DragSourceEffect { OS.FillRect(hDC1, rect, hBrush); for (int i = 0; i < count; i++) { TableItem selected = selection[i]; - Rectangle cell = selected.getBounds(0); + Rectangle cell = DPIUtil.autoScaleUp(selected.getBounds(0)); POINT pt = new POINT(); long /*int*/ imageList = OS.SendMessage (table.handle, OS.LVM_CREATEDRAGIMAGE, table.indexOf(selected), pt); OS.ImageList_Draw(imageList, 0, hDC1, cell.x - bounds.x, cell.y - bounds.y, OS.ILD_SELECTED); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java index 6eb6b288ad..e9291a2df0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java @@ -11,6 +11,7 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.widgets.*; @@ -151,7 +152,7 @@ public class TableDropTargetEffect extends DropTargetEffect { int effect = checkEffect(event.feedback); long /*int*/ handle = table.handle; Point coordinates = new Point(event.x, event.y); - coordinates = table.toControl(coordinates); + coordinates = DPIUtil.autoScaleUp(table.toControl(coordinates)); // To Pixels LVHITTESTINFO pinfo = new LVHITTESTINFO(); pinfo.x = coordinates.x; pinfo.y = coordinates.y; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java index e6781bef49..a0e6e99d0e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragSourceEffect.java @@ -12,6 +12,8 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.DPIUtil.*; import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.widgets.*; @@ -141,7 +143,7 @@ public class TreeDragSourceEffect extends DragSourceEffect { } else { data.transparentPixel = shdi.crColorKey << 8; } - dragSourceImage = new Image (control.getDisplay (), data); + dragSourceImage = new Image (control.getDisplay (), new AutoScaleImageDataProvider(data, DPIUtil.getDeviceZoom())); OS.SelectObject (memHdc, oldMemBitmap); OS.DeleteDC (memHdc); OS.DeleteObject (memDib); @@ -163,9 +165,9 @@ public class TreeDragSourceEffect extends DragSourceEffect { long /*int*/ treeImageList = OS.SendMessage (tree.handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0); if (treeImageList != 0) { int count = Math.min(selection.length, 10); - Rectangle bounds = selection[0].getBounds(0); + Rectangle bounds = DPIUtil.autoScaleUp(selection[0].getBounds(0)); for (int i = 1; i < count; i++) { - bounds = bounds.union(selection[i].getBounds(0)); + bounds = bounds.union(DPIUtil.autoScaleUp(selection[i].getBounds(0))); } long /*int*/ hDC = OS.GetDC(tree.handle); long /*int*/ hDC1 = OS.CreateCompatibleDC(hDC); @@ -178,7 +180,7 @@ public class TreeDragSourceEffect extends DragSourceEffect { OS.FillRect(hDC1, rect, hBrush); for (int i = 0; i < count; i++) { TreeItem selected = selection[i]; - Rectangle cell = selected.getBounds(0); + Rectangle cell = DPIUtil.autoScaleUp(selected.getBounds(0)); long /*int*/ imageList = OS.SendMessage(tree.handle, OS.TVM_CREATEDRAGIMAGE, 0, selected.handle); OS.ImageList_Draw(imageList, 0, hDC1, cell.x - bounds.x, cell.y - bounds.y, OS.ILD_SELECTED); OS.ImageList_Destroy(imageList); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java index 16897d918f..98d28437c7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java @@ -12,6 +12,7 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.widgets.*; @@ -162,7 +163,7 @@ public class TreeDropTargetEffect extends DropTargetEffect { int effect = checkEffect(event.feedback); long /*int*/ handle = tree.handle; Point coordinates = new Point(event.x, event.y); - coordinates = tree.toControl(coordinates); + coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); // To Pixels TVHITTESTINFO lpht = new TVHITTESTINFO (); lpht.x = coordinates.x; lpht.y = coordinates.y; |