Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ public abstract class Control extends Widget implements Drawable {
Font font;
int drawCount, foreground, background, backgroundAlpha = 255;
boolean autoScaleDisabled = false;
boolean propagateAutoScaleDisabled = true;

private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM";

private static final String DATA_AUTOSCALE_DISABLED = "AUTOSCALE_DISABLED";

private static final String PROPOGATE_AUTOSCALE_DISABLED = "PROPOGATE_AUTOSCALE_DISABLED";
/**
* Prevents uninitialized instances from being created outside the package.
*/
Expand Down Expand Up @@ -121,7 +124,12 @@ public abstract class Control extends Widget implements Drawable {
public Control (Composite parent, int style) {
super (parent, style);
this.parent = parent;
this.autoScaleDisabled = parent.autoScaleDisabled;
if (parent != null && parent.propagateAutoScaleDisabled) {
this.autoScaleDisabled = parent.autoScaleDisabled;
}
if (!autoScaleDisabled) {
this.nativeZoom = getShellZoom();
}
createWidget ();
}

Expand Down Expand Up @@ -1207,7 +1215,7 @@ int getBorderWidthInPixels () {
*/
public Rectangle getBounds (){
checkWidget ();
return Win32DPIUtils.pixelToPoint(getBoundsInPixels (), getZoom());
return Win32DPIUtils.pixelToPoint(getBoundsInPixels (), computeBoundsZoom());
}

Rectangle getBoundsInPixels () {
Expand Down Expand Up @@ -1286,6 +1294,9 @@ public void setData(String key, Object value) {
this.nativeZoom = getShellZoom();
}
}
if (PROPOGATE_AUTOSCALE_DISABLED.equals(key)) {
this.propagateAutoScaleDisabled = Boolean.parseBoolean(value.toString());
}
}

/**
Expand Down Expand Up @@ -1403,7 +1414,7 @@ public Object getLayoutData () {
public Point getLocation () {
checkWidget ();
//For a location the closest point values is okay
return Win32DPIUtils.pixelToPointAsLocation(getLocationInPixels(), getZoom());
return Win32DPIUtils.pixelToPointAsLocation(getLocationInPixels(), computeBoundsZoom());
}

Point getLocationInPixels () {
Expand Down Expand Up @@ -1559,7 +1570,7 @@ public Shell getShell () {
*/
public Point getSize (){
checkWidget ();
return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels (), getZoom());
return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels (), computeBoundsZoom());
}

Point getSizeInPixels () {
Expand Down Expand Up @@ -3294,7 +3305,7 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
int zoom = autoScaleDisabled && parent != null ? parent.getZoom() : getZoom();
int zoom = computeBoundsZoom();
setBoundsInPixels(Win32DPIUtils.pointToPixel(rect, zoom));
}

Expand Down Expand Up @@ -3552,7 +3563,7 @@ public void setLayoutData (Object layoutData) {
*/
public void setLocation (int x, int y) {
checkWidget ();
int zoom = autoScaleDisabled && parent != null ? parent.getZoom() : getZoom();
int zoom = computeBoundsZoom();
x = DPIUtil.pointToPixel(x, zoom);
y = DPIUtil.pointToPixel(y, zoom);
setLocationInPixels(x, y);
Expand Down Expand Up @@ -3809,7 +3820,7 @@ public void setRegion (Region region) {
*/
public void setSize (int width, int height) {
checkWidget ();
int zoom = autoScaleDisabled && parent != null ? parent.getZoom() : getZoom();
int zoom = computeBoundsZoom();
width = DPIUtil.pointToPixel(width, zoom);
height = DPIUtil.pointToPixel(height, zoom);
setSizeInPixels(width, height);
Expand Down Expand Up @@ -4824,6 +4835,13 @@ int getShellZoom() {
return nativeZoom;
}

private int computeBoundsZoom() {
if (parent != null) {
return parent.getZoom();
}
return getZoom();
}

abstract TCHAR windowClass ();

abstract long windowProc ();
Expand Down
Loading