@@ -78,11 +78,14 @@ public abstract class Control extends Widget implements Drawable {
7878 Region region ;
7979 Font font ;
8080 int drawCount , foreground , background , backgroundAlpha = 255 ;
81+ boolean autoScaleDisabled = false ;
8182
8283 /** Cache for currently processed DPI change event to be able to cancel it if a new one is triggered */
8384 Event currentDpiChangeEvent ;
8485
8586 private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM" ;
87+
88+ private static final String DATA_AUTOSCALE_DISABLED = "AUTOSCALE_DISABLED" ;
8689/**
8790 * Prevents uninitialized instances from being created outside the package.
8891 */
@@ -122,6 +125,7 @@ public abstract class Control extends Widget implements Drawable {
122125public Control (Composite parent , int style ) {
123126 super (parent , style );
124127 this .parent = parent ;
128+ this .autoScaleDisabled = parent .autoScaleDisabled ;
125129 createWidget ();
126130}
127131
@@ -1283,6 +1287,19 @@ public Object getData(String key) {
12831287 return super .getData (key );
12841288}
12851289
1290+ @ Override
1291+ public void setData (String key , Object value ) {
1292+ super .setData (key , value );
1293+ if (DATA_AUTOSCALE_DISABLED .equals (key )) {
1294+ autoScaleDisabled = Boolean .parseBoolean (value .toString ());
1295+ if (autoScaleDisabled ) {
1296+ this .nativeZoom = 100 ;
1297+ } else {
1298+ this .nativeZoom = (int ) getData (DATA_SHELL_ZOOM );
1299+ }
1300+ }
1301+ }
1302+
12861303/**
12871304 * Returns <code>true</code> if the receiver is detecting
12881305 * drag gestures, and <code>false</code> otherwise.
@@ -3547,7 +3564,7 @@ public void setLayoutData (Object layoutData) {
35473564 */
35483565public void setLocation (int x , int y ) {
35493566 checkWidget ();
3550- int zoom = getZoom ();
3567+ int zoom = autoScaleDisabled ? parent . getZoom () : getZoom ();
35513568 x = DPIUtil .pointToPixel (x , zoom );
35523569 y = DPIUtil .pointToPixel (y , zoom );
35533570 setLocationInPixels (x , y );
@@ -3804,7 +3821,7 @@ public void setRegion (Region region) {
38043821 */
38053822public void setSize (int width , int height ) {
38063823 checkWidget ();
3807- int zoom = getZoom ();
3824+ int zoom = autoScaleDisabled ? parent . getZoom () : getZoom ();
38083825 width = DPIUtil .pointToPixel (width , zoom );
38093826 height = DPIUtil .pointToPixel (height , zoom );
38103827 setSizeInPixels (width , height );
@@ -4798,6 +4815,23 @@ public boolean setParent (Composite parent) {
47984815 return true ;
47994816}
48004817
4818+ @ Override
4819+ GC createNewGC (long hDC , GCData data ) {
4820+ data .nativeZoom = getNativeZoom ();
4821+ if (autoScaleDisabled && data .font != null ) {
4822+ data .font = SWTFontProvider .getFont (display , data .font .getFontData ()[0 ], 100 );
4823+ }
4824+ return GC .win32_new (hDC , data );
4825+ }
4826+
4827+ @ Override
4828+ int getZoom () {
4829+ if (autoScaleDisabled ) {
4830+ return 100 ;
4831+ }
4832+ return super .getZoom ();
4833+ }
4834+
48014835abstract TCHAR windowClass ();
48024836
48034837abstract long windowProc ();
@@ -5972,6 +6006,9 @@ void sendZoomChangedEvent(Event event, Shell shell) {
59726006@ Override
59736007void handleDPIChange (Event event , float scalingFactor ) {
59746008 super .handleDPIChange (event , scalingFactor );
6009+ if (this .autoScaleDisabled ) {
6010+ this .nativeZoom = 100 ;
6011+ }
59756012 resizeFont (this , getNativeZoom ());
59766013
59776014 Image image = backgroundImage ;
0 commit comments