diff options
Diffstat (limited to 'bundles/org.eclipse.swt')
12 files changed, 111 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java index 1137b5bf8b..ee9193a53b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java @@ -609,7 +609,7 @@ void dropDown (boolean drop) { * Fix is to reduce height of list and shell in that case, bug 388126. */ ScrollBar hBar = list.getHorizontalBar(); - int emptyHBarSpace = hBar.isVisible () ? 0 : hBar.getSize ().y; + int emptyHBarSpace = hBar.isVisible () ? 0 : hBar.getSizeInPixels ().y; list.setSizeInPixels (listRect.width, listRect.height - emptyHBarSpace); popup.setBoundsInPixel (x, y, width, height - emptyHBarSpace); popup.setVisible (true); @@ -1813,7 +1813,7 @@ void textEvent (Event event) { e.x = event.x; e.y = event.y; if (event.detail == SWT.MENU_KEYBOARD) { - Point pt = getDisplay().mapInPixels(text, null, text.getCaretLocation()); + Point pt = getDisplay().mapInPixels(text, null, text.getCaretLocationInPixels()); e.x = pt.x; e.y = pt.y; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java index b5b9c7baf4..7e27fa0c27 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java @@ -265,7 +265,7 @@ private Point getTotalSize(Image image, String text) { size.y = Math.max(size.y, e.y); if (image != null) size.x += GAP; } else { - size.y = DPIUtil.autoScaleDown(gc.getFontMetrics().getHeight()); + size.y = gc.getFontMetrics().getHeight(); } gc.dispose(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java index 0b6e52ada0..f12ef09c6b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java @@ -341,7 +341,7 @@ boolean needHScroll(Rectangle contentRect, boolean vVisible) { int border = getBorderWidthInPixels(); hostRect.width -= 2*border; ScrollBar vBar = getVerticalBar(); - if (vVisible && vBar != null) hostRect.width -= vBar.getSize().x; + if (vVisible && vBar != null) hostRect.width -= vBar.getSizeInPixels().x; if (!expandHorizontal && contentRect.width > hostRect.width) return true; if (expandHorizontal && minWidth > hostRect.width) return true; @@ -356,7 +356,7 @@ boolean needVScroll(Rectangle contentRect, boolean hVisible) { int border = getBorderWidthInPixels(); hostRect.height -= 2*border; ScrollBar hBar = getHorizontalBar(); - if (hVisible && hBar != null) hostRect.height -= hBar.getSize().y; + if (hVisible && hBar != null) hostRect.height -= hBar.getSizeInPixels().y; if (!expandVertical && contentRect.height > hostRect.height) return true; if (expandVertical && minHeight > hostRect.height) return true; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java index 199ef22481..7ec1a9b62b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java @@ -55,12 +55,12 @@ protected void layout(Composite composite, boolean flushCache) { ScrollBar hBar = sc.getHorizontalBar(); ScrollBar vBar = sc.getVerticalBar(); if (hBar != null) { - if (hBar.getSize().y >= sc.getSizeInPixels().y) { + if (hBar.getSizeInPixels().y >= sc.getSizeInPixels().y) { return; } } if (vBar != null) { - if (vBar.getSize().x >= sc.getSizeInPixels().x) { + if (vBar.getSizeInPixels().x >= sc.getSizeInPixels().x) { return; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java index 8346d2b5c3..86e796a938 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java @@ -1609,6 +1609,7 @@ public int getAscent () { /** * @noreference This method is not intended to be referenced by clients. */ + public int getAscentInPixels () { checkLayout(); return ascent; @@ -1626,7 +1627,7 @@ public int getAscentInPixels () { * </ul> * * @see #setWidth(int) - * @see #getLineBoundsInPixels(int) + * @see #getLineBounds(int) */ public Rectangle getBounds () { return DPIUtil.autoScaleDown(getBoundsInPixels()); @@ -3382,6 +3383,13 @@ public void setTextDirection (int textDirection) { * @see #setAlignment(int) */ public void setWidth (int width) { + setWidthInPixels(width != SWT.DEFAULT ? DPIUtil.autoScaleUp(width) : width); +} + +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setWidthInPixels (int width) { checkLayout(); if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (this.wrapWidth == width) return; @@ -3404,6 +3412,13 @@ public void setWidth (int width) { * @since 3.6 */ public void setWrapIndent (int wrapIndent) { + setWrapIndentInPixels(DPIUtil.autoScaleUp(wrapIndent)); +} + +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setWrapIndentInPixels (int wrapIndent) { checkLayout(); if (wrapIndent < 0) return; if (this.wrapIndent == wrapIndent) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java index 50d2300eb7..dd5476ebac 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java @@ -209,17 +209,17 @@ public Point computeSizeInPixels (int wHint, int hHint, boolean changed) { int layoutWidth = layout.getWidthInPixels (); //TEMPORARY CODE if (wHint == 0) { - layout.setWidth (1); + layout.setWidthInPixels (1); Rectangle rect = layout.getBoundsInPixels (); width = 0; height = rect.height; } else { - layout.setWidth (wHint); + layout.setWidthInPixels (wHint); Rectangle rect = layout.getBoundsInPixels (); width = rect.width; height = rect.height; } - layout.setWidth (layoutWidth); + layout.setWidthInPixels (layoutWidth); } if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; @@ -1093,7 +1093,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) { if (OS.COMCTL32_MAJOR < 6) { RECT rect = new RECT (); OS.GetClientRect (handle, rect); - layout.setWidth (rect.right > 0 ? rect.right : -1); + layout.setWidthInPixels (rect.right > 0 ? rect.right : -1); redraw (); } return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java index dbbe6e85b3..676847f5ee 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java @@ -1226,7 +1226,7 @@ public void setToolTipText (String toolTip) { void showTooltip (int x, int y) { if (itemToolTip == null) return; - itemToolTip.setLocation (x, y); + itemToolTip.setLocationInPixels (x, y); itemToolTip.setVisible (true); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java index ab68be0aef..1882531a83 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java @@ -11,10 +11,10 @@ package org.eclipse.swt.widgets; -import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.win32.*; /** * Instances of this class are selectable user interface @@ -365,6 +365,12 @@ public int getSelection () { * </ul> */ public Point getSize () { + return DPIUtil.autoScaleDown(getSizeInPixels()); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Point getSizeInPixels () { checkWidget(); parent.forceResize (); RECT rect = new RECT (); @@ -418,6 +424,12 @@ public int getThumb () { * @since 3.6 */ public Rectangle getThumbBounds () { + return DPIUtil.autoScaleDown(getThumbBoundsInPixels()); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Rectangle getThumbBoundsInPixels () { checkWidget(); parent.forceResize (); SCROLLBARINFO info = new SCROLLBARINFO(); @@ -460,6 +472,12 @@ public Rectangle getThumbBounds () { * @since 3.6 */ public Rectangle getThumbTrackBounds () { + return DPIUtil.autoScaleDown(getThumbTrackBoundsInPixels()); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Rectangle getThumbTrackBoundsInPixels () { checkWidget(); parent.forceResize (); SCROLLBARINFO info = new SCROLLBARINFO(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java index 8b7f1c8847..297b3e63d8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java @@ -1065,6 +1065,13 @@ public boolean getMaximized () { * @since 3.1 */ public Point getMinimumSize () { + return DPIUtil.autoScaleDown(getMinimumSizeInPixels()); +} + +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Point getMinimumSizeInPixels () { checkWidget (); int width = Math.max (0, minWidth); int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX; @@ -1731,6 +1738,12 @@ public void setImeInputMode (int mode) { * @since 3.1 */ public void setMinimumSize (int width, int height) { + setMinimumSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height)); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setMinimumSizeInPixels (int width, int height) { checkWidget (); int widthLimit = 0, heightLimit = 0; int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX; @@ -1774,9 +1787,15 @@ public void setMinimumSize (int width, int height) { * @since 3.1 */ public void setMinimumSize (Point size) { + setMinimumSizeInPixels(DPIUtil.autoScaleUp(size)); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setMinimumSizeInPixels (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - setMinimumSize (size.x, size.y); + setMinimumSizeInPixels (size.x, size.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 582f39e972..82f9cd545d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -940,6 +940,12 @@ public int getCaretLineNumber () { * </ul> */ public Point getCaretLocation () { + return DPIUtil.autoScaleDown(getCaretLocationInPixels()); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Point getCaretLocationInPixels () { checkWidget (); /* * Bug in Windows. For some reason, Windows is unable @@ -2499,7 +2505,7 @@ int untranslateOffset (int offset) { @Override void updateMenuLocation (Event event) { - Point point = display.mapInPixels (this, null, getCaretLocation ()); + Point point = display.mapInPixels (this, null, getCaretLocationInPixels ()); event.x = point.x; event.y = point.y + getLineHeightInPixels (); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java index e1f449040b..20f8448ad3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java @@ -366,6 +366,12 @@ public void setAutoHide (boolean autoHide) { * </ul> */ public void setLocation (int x, int y) { + setLocationInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y)); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setLocationInPixels (int x, int y) { checkWidget (); this.x = x; this.y = y; @@ -396,9 +402,15 @@ public void setLocation (int x, int y) { * </ul> */ public void setLocation (Point location) { + setLocationInPixels(DPIUtil.autoScaleUp(location)); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setLocationInPixels (Point location) { checkWidget (); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); - setLocation (location.x, location.y); + setLocationInPixels (location.x, location.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java index d491e60749..e12492b129 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java @@ -11,11 +11,11 @@ package org.eclipse.swt.widgets; -import org.eclipse.swt.internal.*; -import org.eclipse.swt.internal.win32.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.*; import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.win32.*; /** * Instances of this class implement rubber banding rectangles that are @@ -410,6 +410,17 @@ void drawRectangles (Rectangle [] rects, boolean stippled) { * </ul> */ public Rectangle [] getRectangles () { + Rectangle [] result = getRectanglesInPixels(); + for (int i = 0; i < result.length; i++) { + result[i] = DPIUtil.autoScaleDown(result[i]); + } + return result; +} + +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Rectangle [] getRectanglesInPixels () { checkWidget(); Rectangle [] result = new Rectangle [rectangles.length]; for (int i = 0; i < rectangles.length; i++) { @@ -848,6 +859,15 @@ public void setCursor(Cursor newCursor) { * </ul> */ public void setRectangles (Rectangle [] rectangles) { + for (int i = 0; i < rectangles.length; i++) { + rectangles [i] = DPIUtil.autoScaleUp (rectangles [i]); + } + setRectanglesInPixels (rectangles); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setRectanglesInPixels (Rectangle [] rectangles) { checkWidget (); if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT); this.rectangles = new Rectangle [rectangles.length]; |