Skip to content

Commit f7fb840

Browse files
amartya4256akoch-yatta
authored andcommitted
Added API Shell#getZoom()
This commit adds an API Shell#getZoom() which returns the native zoom of the shell.
1 parent 95bd299 commit f7fb840

File tree

3 files changed

+46
-0
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT

3 files changed

+46
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.eclipse.swt.*;
1919
import org.eclipse.swt.events.*;
2020
import org.eclipse.swt.graphics.*;
21+
import org.eclipse.swt.internal.*;
2122
import org.eclipse.swt.internal.cocoa.*;
2223

2324
/**
@@ -1992,6 +1993,21 @@ public void setModified (boolean modified) {
19921993
window.setDocumentEdited (modified);
19931994
}
19941995

1996+
/**
1997+
* Returns the zoom of the shell.
1998+
* <p>
1999+
* Hint: The returned value is the zoom of the shell as originally considered by
2000+
* the OS and not an adjusted zoom value as considered by SWT autoscaling capabilities.
2001+
* </p>
2002+
*
2003+
* @return the zoom for this shell
2004+
*
2005+
* @since 3.133
2006+
*/
2007+
public int getZoom() {
2008+
return DPIUtil.getNativeDeviceZoom();
2009+
}
2010+
19952011
/**
19962012
* Sets the shape of the shell to the region specified
19972013
* by the argument. When the argument is null, the

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,6 +2786,21 @@ public void setModified (boolean modified) {
27862786
this.modified = modified;
27872787
}
27882788

2789+
/**
2790+
* Returns the zoom of the shell.
2791+
* <p>
2792+
* Hint: The returned value is the zoom of the shell as originally considered by
2793+
* the OS and not an adjusted zoom value as considered by SWT autoscaling capabilities.
2794+
* </p>
2795+
*
2796+
* @return the zoom for this shell
2797+
*
2798+
* @since 3.133
2799+
*/
2800+
public int getZoom() {
2801+
return DPIUtil.getNativeDeviceZoom();
2802+
}
2803+
27892804
/**
27902805
* Sets the shape of the shell to the region specified
27912806
* by the argument. When the argument is null, the

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,21 @@ public ToolBar getToolBar() {
12331233
return null;
12341234
}
12351235

1236+
/**
1237+
* Returns the zoom of the shell.
1238+
* <p>
1239+
* Hint: The returned value is the zoom of the shell as originally considered by
1240+
* the OS and not an adjusted zoom value as considered by SWT autoscaling capabilities.
1241+
* </p>
1242+
*
1243+
* @return the zoom for this shell
1244+
*
1245+
* @since 3.133
1246+
*/
1247+
public int getZoom() {
1248+
return DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(handle));
1249+
}
1250+
12361251
@Override
12371252
Composite findDeferredControl () {
12381253
return layoutCount > 0 ? this : null;

0 commit comments

Comments
 (0)