Skip to content

Commit 95bd299

Browse files
amartya4256akoch-yatta
authored andcommitted
Renamed Widget#getZoom to getAutoscalingZoom
This commit renames the method Widget#getZoom to getAutoscalingZoom since this methods return the value of the zoom based on the autoscaling technique, i.e. quarter, half, etc and whether autoscaling is enabled or disabled.
1 parent 9a91cae commit 95bd299

38 files changed

+258
-258
lines changed

bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/WidgetWin32Tests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public void testWidgetZoomShouldChangeOnZoomLevelChange() {
4040
button.setText("Widget Test");
4141
button.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_CYAN));
4242
shell.open();
43-
assertEquals("The initial zoom is wrong", zoom, button.getZoom()); // pre-condition
43+
assertEquals("The initial zoom is wrong", zoom, button.getAutoscalingZoom()); // pre-condition
4444
DPITestUtil.changeDPIZoom(shell, scaledZoom);
4545
assertEquals("The Zoom Level should be updated for button on zoom change event on its shell", scaledZoom,
46-
button.getZoom());
46+
button.getAutoscalingZoom());
4747
}
4848

4949
@Test

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void _setImage (Image image) {
138138
if (imageList != null) imageList.dispose ();
139139
imageList = null;
140140
if (image != null) {
141-
imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getZoom());
141+
imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getAutoscalingZoom());
142142
if (OS.IsWindowEnabled (handle)) {
143143
imageList.add (image);
144144
} else {
@@ -147,7 +147,7 @@ void _setImage (Image image) {
147147
imageList.add (disabledImage);
148148
}
149149
BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
150-
buttonImageList.himl = imageList.getHandle(getZoom());
150+
buttonImageList.himl = imageList.getHandle(getAutoscalingZoom());
151151
int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits;
152152
newBits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT);
153153
if ((style & SWT.LEFT) != 0) newBits |= OS.BS_LEFT;
@@ -188,7 +188,7 @@ void _setText (String text) {
188188
if ((style & SWT.RIGHT) != 0) newBits |= OS.BS_RIGHT;
189189
if (imageList != null) {
190190
BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
191-
buttonImageList.himl = imageList.getHandle(getZoom());
191+
buttonImageList.himl = imageList.getHandle(getAutoscalingZoom());
192192
if (text.length () == 0) {
193193
if ((style & SWT.LEFT) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
194194
if ((style & SWT.CENTER) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER;
@@ -295,7 +295,7 @@ int computeLeftMargin () {
295295
if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) return MARGIN;
296296
int margin = 0;
297297
if (image != null && text.length () != 0) {
298-
Rectangle bounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100);
298+
Rectangle bounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100);
299299
margin += bounds.width + MARGIN * 2;
300300
long oldFont = 0;
301301
long hDC = OS.GetDC (handle);
@@ -359,13 +359,13 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) {
359359
boolean hasImage = image != null, hasText = true;
360360
if (hasImage) {
361361
if (image != null) {
362-
Rectangle rect = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100);
362+
Rectangle rect = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100);
363363
width = rect.width;
364364
if (hasText && text.length () != 0) {
365-
width += DPIUtil.pointToPixel(MARGIN * 2, getZoom());;
365+
width += DPIUtil.pointToPixel(MARGIN * 2, getAutoscalingZoom());;
366366
}
367367
height = rect.height;
368-
extra = DPIUtil.pointToPixel(MARGIN * 2, getZoom());;
368+
extra = DPIUtil.pointToPixel(MARGIN * 2, getAutoscalingZoom());;
369369
}
370370
}
371371
if (hasText) {
@@ -379,7 +379,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) {
379379
if (length == 0) {
380380
height = Math.max (height, lptm.tmHeight);
381381
} else {
382-
extra = Math.max (DPIUtil.pointToPixel(MARGIN * 2, getZoom()), lptm.tmAveCharWidth);
382+
extra = Math.max (DPIUtil.pointToPixel(MARGIN * 2, getAutoscalingZoom()), lptm.tmAveCharWidth);
383383
char [] buffer = text.toCharArray ();
384384
RECT rect = new RECT ();
385385
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
@@ -780,7 +780,7 @@ public void setAlignment (int alignment) {
780780
if ((style & SWT.RIGHT) != 0) newBits |= OS.BS_RIGHT;
781781
if (imageList != null) {
782782
BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
783-
buttonImageList.himl = imageList.getHandle(getZoom());
783+
buttonImageList.himl = imageList.getHandle(getAutoscalingZoom());
784784
if (text.length () == 0) {
785785
if ((style & SWT.LEFT) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
786786
if ((style & SWT.CENTER) != 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER;
@@ -1035,15 +1035,15 @@ void updateImageList () {
10351035
BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
10361036
OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, buttonImageList);
10371037
if (imageList != null) imageList.dispose ();
1038-
imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getZoom());
1038+
imageList = new ImageList (style & SWT.RIGHT_TO_LEFT, getAutoscalingZoom());
10391039
if (OS.IsWindowEnabled (handle)) {
10401040
imageList.add (image);
10411041
} else {
10421042
if (disabledImage != null) disabledImage.dispose ();
10431043
disabledImage = new Image (display, image, SWT.IMAGE_DISABLE);
10441044
imageList.add (disabledImage);
10451045
}
1046-
buttonImageList.himl = imageList.getHandle(getZoom());
1046+
buttonImageList.himl = imageList.getHandle(getAutoscalingZoom());
10471047
OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList);
10481048
/*
10491049
* Bug in Windows. Under certain cirumstances yet to be
@@ -1392,13 +1392,13 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
13921392
GC gc = createNewGC(nmcd.hdc, data);
13931393

13941394
int margin = computeLeftMargin();
1395-
Rectangle imageBounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getZoom(), 100);
1395+
Rectangle imageBounds = Win32DPIUtils.scaleBounds(image.getBounds(), this.getAutoscalingZoom(), 100);
13961396
int imageWidth = imageBounds.width;
13971397
left += (imageWidth + (isRadioOrCheck() ? 2 * MARGIN : MARGIN)); // for SWT.RIGHT_TO_LEFT right and left are inverted
13981398

13991399
int x = margin + (isRadioOrCheck() ? radioOrCheckTextPadding : 3);
14001400
int y = Math.max (0, (nmcd.bottom - imageBounds.height) / 2);
1401-
int zoom = getZoom();
1401+
int zoom = getAutoscalingZoom();
14021402
gc.drawImage (image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom));
14031403
gc.dispose ();
14041404
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Canvas (Composite parent, int style) {
103103
* @since 3.2
104104
*/
105105
public void drawBackground (GC gc, int x, int y, int width, int height) {
106-
int zoom = getZoom();
106+
int zoom = getAutoscalingZoom();
107107
Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom);
108108
drawBackgroundInPixels(gc, rectangle.x, rectangle.y, rectangle.width, rectangle.height, 0, 0);
109109
}
@@ -197,7 +197,7 @@ void reskinChildren (int flags) {
197197
*/
198198
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
199199
checkWidget ();
200-
int zoom = getZoom();
200+
int zoom = getAutoscalingZoom();
201201
destX = DPIUtil.pointToPixel(destX, zoom);
202202
destY = DPIUtil.pointToPixel(destY, zoom);
203203
Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ long defaultFont () {
119119
*/
120120
public Rectangle getBounds () {
121121
checkWidget();
122-
return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getZoom());
122+
return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getAutoscalingZoom());
123123
}
124124

125125
Rectangle getBoundsInPixels () {
126126
if (image != null) {
127-
Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom());
127+
Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom());
128128
return new Rectangle (getXInPixels(), getYInPixels(), rect.width, rect.height);
129129
}
130130
if (width == 0) {
@@ -223,12 +223,12 @@ public Canvas getParent () {
223223
*/
224224
public Point getSize () {
225225
checkWidget();
226-
return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getZoom());
226+
return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels(), getAutoscalingZoom());
227227
}
228228

229229
Point getSizeInPixels () {
230230
if (image != null) {
231-
Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getZoom());
231+
Rectangle rect = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom());
232232
return new Point (rect.width, rect.height);
233233
}
234234
if (width == 0) {
@@ -241,19 +241,19 @@ Point getSizeInPixels () {
241241
}
242242

243243
private int getWidthInPixels() {
244-
return DPIUtil.pointToPixel(width, getZoom());
244+
return DPIUtil.pointToPixel(width, getAutoscalingZoom());
245245
}
246246

247247
private int getHeightInPixels() {
248-
return DPIUtil.pointToPixel(height, getZoom());
248+
return DPIUtil.pointToPixel(height, getAutoscalingZoom());
249249
}
250250

251251
private int getXInPixels() {
252-
return DPIUtil.pointToPixel(x, getZoom());
252+
return DPIUtil.pointToPixel(x, getAutoscalingZoom());
253253
}
254254

255255
private int getYInPixels() {
256-
return DPIUtil.pointToPixel(y, getZoom());
256+
return DPIUtil.pointToPixel(y, getAutoscalingZoom());
257257
}
258258

259259
/**
@@ -373,7 +373,7 @@ void resize () {
373373
resized = false;
374374
long hwnd = parent.handle;
375375
OS.DestroyCaret ();
376-
long hBitmap = image != null ? Image.win32_getHandle(image, getZoom()) : 0;
376+
long hBitmap = image != null ? Image.win32_getHandle(image, getAutoscalingZoom()) : 0;
377377
int widthInPixels = this.getWidthInPixels();
378378
if (image == null && widthInPixels == 0) {
379379
OptionalInt systemCaretWidthInPixelsForCurrentMonitor = getSystemCaretWidthInPixelsForCurrentMonitor();
@@ -452,7 +452,7 @@ public void setBounds (Rectangle rect) {
452452
void setFocus () {
453453
long hwnd = parent.handle;
454454
long hBitmap = 0;
455-
if (image != null) hBitmap = Image.win32_getHandle(image, getZoom());
455+
if (image != null) hBitmap = Image.win32_getHandle(image, getAutoscalingZoom());
456456
int widthInPixels = this.getWidthInPixels();
457457
if (image == null && widthInPixels == 0) {
458458
OptionalInt systemCaretWidthInPixelsForCurrentMonitor = getSystemCaretWidthInPixelsForCurrentMonitor();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ boolean dragDetect (long hwnd, int x, int y, boolean filter, boolean [] detect,
911911
*/
912912
public Point getCaretLocation () {
913913
checkWidget ();
914-
return Win32DPIUtils.pixelToPointAsLocation(getCaretLocationInPixels(), getZoom());
914+
return Win32DPIUtils.pixelToPointAsLocation(getCaretLocationInPixels(), getAutoscalingZoom());
915915
}
916916

917917
Point getCaretLocationInPixels () {
@@ -1079,7 +1079,7 @@ public int getItemCount () {
10791079
*/
10801080
public int getItemHeight () {
10811081
checkWidget ();
1082-
return DPIUtil.pixelToPoint(getItemHeightInPixels(), getZoom());
1082+
return DPIUtil.pixelToPoint(getItemHeightInPixels(), getAutoscalingZoom());
10831083
}
10841084

10851085
int getItemHeightInPixels () {
@@ -1345,7 +1345,7 @@ public String getText () {
13451345
*/
13461346
public int getTextHeight () {
13471347
checkWidget ();
1348-
return DPIUtil.pixelToPoint(getTextHeightInPixels(), getZoom());
1348+
return DPIUtil.pixelToPoint(getTextHeightInPixels(), getAutoscalingZoom());
13491349
}
13501350

13511351
int getTextHeightInPixels () {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) {
229229
* Since computeTrim can be overridden by subclasses, we cannot
230230
* call computeTrimInPixels directly.
231231
*/
232-
Rectangle trim = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(computeTrim (0, 0, sizeInPoints.x, sizeInPoints.y), getZoom());
232+
Rectangle trim = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(computeTrim (0, 0, sizeInPoints.x, sizeInPoints.y), getAutoscalingZoom());
233233
return new Point (trim.width, trim.height);
234234
}
235235

@@ -349,7 +349,7 @@ int applyThemeBackground () {
349349
*/
350350
public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
351351
checkWidget ();
352-
int zoom = getZoom();
352+
int zoom = getAutoscalingZoom();
353353
Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom);
354354
offsetX = DPIUtil.pointToPixel(offsetX, zoom);
355355
offsetY = DPIUtil.pointToPixel(offsetY, zoom);
@@ -1532,7 +1532,7 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15321532

15331533
Event event = new Event ();
15341534
event.gc = gc;
1535-
event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle.OfFloat(ps.left, ps.top, width, height), getZoom()));
1535+
event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle.OfFloat(ps.left, ps.top, width, height), getAutoscalingZoom()));
15361536
sendEvent (SWT.Paint, event);
15371537
if (data.focusDrawn && !isDisposed ()) updateUIState ();
15381538
gc.dispose ();
@@ -1603,7 +1603,7 @@ LRESULT WM_PAINT (long wParam, long lParam) {
16031603
Event event = new Event ();
16041604
event.gc = gc;
16051605
RECT rect = null;
1606-
int zoom = getZoom();
1606+
int zoom = getAutoscalingZoom();
16071607
if ((style & SWT.NO_MERGE_PAINTS) != 0 && OS.GetRgnBox (sysRgn, rect = new RECT ()) == OS.COMPLEXREGION) {
16081608
int nBytes = OS.GetRegionData (sysRgn, 0, null);
16091609
int [] lpRgnData = new int [nBytes / 4];
@@ -1700,7 +1700,7 @@ LRESULT WM_PRINTCLIENT (long wParam, long lParam) {
17001700
GC gc = createNewGC(wParam, data);
17011701
Event event = new Event ();
17021702
event.gc = gc;
1703-
event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getZoom()));
1703+
event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getAutoscalingZoom()));
17041704
sendEvent (SWT.Paint, event);
17051705
event.gc = null;
17061706
gc.dispose ();

0 commit comments

Comments
 (0)