Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
amartya4256 committed Aug 12, 2024
1 parent 8aec5fc commit 01cd52e
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static Frame new_Frame (final Composite parent) {

parent.getDisplay().asyncExec(() -> {
if (parent.isDisposed()) return;
final Rectangle clientArea = DPIUtil.scaleUp(parent.getClientArea(), DPIUtil.getZoomForAutoscaleProperty(parent.nativeZoom)); // To Pixels
final Rectangle clientArea = DPIUtil.scaleUp(parent.getClientArea(), parent.nativeZoom); // To Pixels
EventQueue.invokeLater(() -> {
frame.setSize (clientArea.width, clientArea.height);
frame.validate ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ private void drag(Event dragEvent) {
hwndDrag = 0;
topControl = null;
if (image != null) {
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
int zoom = nativeZoom;
imagelist = new ImageList(SWT.NONE, zoom);
imagelist.add(image);
topControl = control.getShell();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int DragEnter_64(long pDataObject, int grfKeyState, long pt, long pdwEffect) {
}

int DragEnter(long pDataObject, int grfKeyState, int pt_x, int pt_y, long pdwEffect) {
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
int zoom = nativeZoom;
pt_x = DPIUtil.scaleDown(pt_x, zoom);// To Points
pt_y = DPIUtil.scaleDown(pt_y, zoom);// To Points
selectedDataType = null;
Expand Down Expand Up @@ -349,7 +349,7 @@ int DragOver_64(int grfKeyState, long pt, long pdwEffect) {
}

int DragOver(int grfKeyState, int pt_x, int pt_y, long pdwEffect) {
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
int zoom = nativeZoom;
pt_x = DPIUtil.scaleDown(pt_x, zoom);// To Points
pt_y = DPIUtil.scaleDown(pt_y, zoom);// To Points
if (iDataObject == null) return COM.S_FALSE;
Expand Down Expand Up @@ -405,7 +405,7 @@ int Drop_64(long pDataObject, int grfKeyState, long pt, long pdwEffect) {

int Drop(long pDataObject, int grfKeyState, int pt_x, int pt_y, long pdwEffect) {
try {
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
int zoom = nativeZoom;
pt_x = DPIUtil.scaleDown(pt_x, zoom);// To Points
pt_y = DPIUtil.scaleDown(pt_y, zoom);// To Points
DNDEvent event = new DNDEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

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.*;
Expand Down Expand Up @@ -147,7 +146,7 @@ Image getDragSourceImage(DragSourceEvent event) {
data.transparentPixel = shdi.crColorKey << 8;
}
Display display = control.getDisplay();
dragSourceImage = new Image(display, new AutoScaleImageDataProvider(display, data, DPIUtil.getZoomForAutoscaleProperty(control.nativeZoom)));
dragSourceImage = new Image(display, new AutoScaleImageDataProvider(display, data, control.nativeZoom));
OS.SelectObject (memHdc, oldMemBitmap);
OS.DeleteDC (memHdc);
OS.DeleteObject (memDib);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void dragOver(DropTargetEvent event) {
int effect = checkEffect(event.feedback);
long handle = table.handle;
Point coordinates = new Point(event.x, event.y);
coordinates = DPIUtil.scaleUp(table.toControl(coordinates), DPIUtil.getZoomForAutoscaleProperty(table.nativeZoom)); // To Pixels
coordinates = DPIUtil.scaleUp(table.toControl(coordinates), table.nativeZoom); // To Pixels
LVHITTESTINFO pinfo = new LVHITTESTINFO();
pinfo.x = coordinates.x;
pinfo.y = coordinates.y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

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.*;
Expand Down Expand Up @@ -146,7 +145,7 @@ Image getDragSourceImage(DragSourceEvent event) {
data.transparentPixel = shdi.crColorKey << 8;
}
Display display = control.getDisplay ();
dragSourceImage = new Image (display, new AutoScaleImageDataProvider(display, data, DPIUtil.getZoomForAutoscaleProperty(control.nativeZoom)));
dragSourceImage = new Image (display, new AutoScaleImageDataProvider(display, data, control.nativeZoom));
OS.SelectObject (memHdc, oldMemBitmap);
OS.DeleteDC (memHdc);
OS.DeleteObject (memDib);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void dragOver(DropTargetEvent event) {
int effect = checkEffect(event.feedback);
long handle = tree.handle;
Point coordinates = new Point(event.x, event.y);
coordinates = DPIUtil.scaleUp(tree.toControl(coordinates), DPIUtil.getZoomForAutoscaleProperty(tree.nativeZoom)); // To Pixels
coordinates = DPIUtil.scaleUp(tree.toControl(coordinates), tree.nativeZoom); // To Pixels
TVHITTESTINFO lpht = new TVHITTESTINFO ();
lpht.x = coordinates.x;
lpht.y = coordinates.y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ protected int GetWindow(long phwnd) {
return COM.S_OK;
}
RECT getRect() {
Rectangle area = DPIUtil.scaleUp(getClientArea(), DPIUtil.getZoomForAutoscaleProperty(nativeZoom)); // To Pixels
Rectangle area = DPIUtil.scaleUp(getClientArea(), nativeZoom); // To Pixels
RECT rect = new RECT();
rect.left = area.x;
rect.top = area.y;
Expand Down Expand Up @@ -987,14 +987,14 @@ private int OnInPlaceDeactivate() {
return COM.S_OK;
}
private int OnPosRectChange(long lprcPosRect) {
Point size = DPIUtil.scaleUp(getSize(), DPIUtil.getZoomForAutoscaleProperty(nativeZoom)); // To Pixels
Point size = DPIUtil.scaleUp(getSize(), nativeZoom); // 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 = DPIUtil.scaleUp(getClientArea(), DPIUtil.getZoomForAutoscaleProperty(nativeZoom)); // To Pixels
Rectangle area = DPIUtil.scaleUp(getClientArea(), nativeZoom); // 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);
Expand Down Expand Up @@ -1369,7 +1369,7 @@ void setBorderSpace(RECT newBorderwidth) {
setBounds();
}
void setBounds() {
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
int zoom = nativeZoom;
Rectangle area = DPIUtil.scaleDown(frame.getClientArea(), zoom); // To Pixels
setBounds(DPIUtil.scaleDown(borderWidths.left, zoom),
DPIUtil.scaleDown(borderWidths.top, zoom),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void tearDownTest() {

protected void changeDPIZoom (int nativeZoom) {
DPIUtil.setDeviceZoom(nativeZoom);
float scalingFactor = 1f * DPIUtil.getZoomForAutoscaleProperty(nativeZoom) / DPIUtil.getZoomForAutoscaleProperty(shell.nativeZoom);
float scalingFactor = 1f * nativeZoom / shell.nativeZoom;
DPIZoomChangeRegistry.applyChange(shell, nativeZoom, scalingFactor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public int getLeading() {
}

private int getZoom() {
return DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
return nativeZoom;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3932,7 +3932,7 @@ void init(Drawable drawable, GCData data, long hDC) {
}
Image image = data.image;
if (image != null) {
data.hNullBitmap = OS.SelectObject(hDC, Image.win32_getHandle(image, DPIUtil.getZoomForAutoscaleProperty(data.nativeZoom)));
data.hNullBitmap = OS.SelectObject(hDC, Image.win32_getHandle(image, data.nativeZoom));
image.memGC = this;
}
int layout = data.layout;
Expand Down Expand Up @@ -5160,7 +5160,7 @@ private static int sin(int angle, int length) {
}

private int getZoom() {
return DPIUtil.getZoomForAutoscaleProperty(data.nativeZoom);
return data.nativeZoom;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,7 @@ public void setBackground(Color color) {
}

private int getZoom() {
return DPIUtil.getZoomForAutoscaleProperty(initialNativeZoom);
return initialNativeZoom;
}
/**
* Returns a string containing a concise, human-readable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,11 @@ private int getNativeZoom(GC gc) {
}

private int getZoom(GC gc){
return DPIUtil.getZoomForAutoscaleProperty(getNativeZoom(gc));
return getNativeZoom(gc);
}

private int getZoom() {
return DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
return nativeZoom;
}

void drawInPixels (GC gc, int x, int y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4905,7 +4905,7 @@ LRESULT WM_DPICHANGED (long wParam, long lParam) {
if (newNativeZoom != oldNativeZoom) {
DPIUtil.setDeviceZoom (newNativeZoom);

float scalingFactor = 1f * DPIUtil.getZoomForAutoscaleProperty(newNativeZoom) / DPIUtil.getZoomForAutoscaleProperty(oldNativeZoom);
float scalingFactor = 1f * newNativeZoom / oldNativeZoom;
DPIZoomChangeRegistry.applyChange(this, newNativeZoom, scalingFactor);

RECT rect = new RECT ();
Expand All @@ -4914,14 +4914,14 @@ LRESULT WM_DPICHANGED (long wParam, long lParam) {
return LRESULT.ZERO;
}
} else {
int newZoom = DPIUtil.getZoomForAutoscaleProperty (newNativeZoom);
int oldZoom = DPIUtil.getZoomForAutoscaleProperty (nativeZoom);
int newZoom = newNativeZoom;
int oldZoom = nativeZoom;
if (newZoom != oldZoom) {
// Throw the DPI change event if zoom value changes
Event event = new Event();
event.type = SWT.ZoomChanged;
event.widget = this;
event.detail = DPIUtil.getZoomForAutoscaleProperty(newNativeZoom);
event.detail = newNativeZoom;
event.doit = true;
notifyListeners(SWT.ZoomChanged, event);
return LRESULT.ZERO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,7 @@ GC createNewGC(long hDC, GCData data) {
}

int getZoom() {
return DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
return nativeZoom;
}

private static void handleDPIChange(Widget widget, int newZoom, float scalingFactor) {
Expand Down

0 comments on commit 01cd52e

Please sign in to comment.