diff options
author | Niraj Modi | 2016-01-22 12:34:14 +0000 |
---|---|---|
committer | Niraj Modi | 2016-01-22 12:34:14 +0000 |
commit | 22cefbb16c5b1798ddb6728509c710931e442a64 (patch) | |
tree | e350fe5b1473da21964005bd7c189cdd4cfcbdb5 | |
parent | 6f45f070654872959136998cb2143f6e2cde8deb (diff) | |
download | eclipse.platform.swt-22cefbb16c5b1798ddb6728509c710931e442a64.tar.gz eclipse.platform.swt-22cefbb16c5b1798ddb6728509c710931e442a64.tar.xz eclipse.platform.swt-22cefbb16c5b1798ddb6728509c710931e442a64.zip |
Bug 479614 - [Graphics] HiDPI support for eclipse platform
- Win32: Reverting new APIs related to autoZoom in GC class
Change-Id: Ie7921b2afb604c93782262221763f82318405a1d
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 395 |
1 files changed, 18 insertions, 377 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index 8d49ddfb91..20e7a5350e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -73,7 +73,7 @@ public final class GC extends Resource { Drawable drawable; GCData data; - boolean defaultAutoScale; + boolean autoScaleEnabled; static final int FOREGROUND = 1 << 0; static final int BACKGROUND = 1 << 1; @@ -170,7 +170,7 @@ public GC(Drawable drawable, int style) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.device = data.device = device; - this.defaultAutoScale = getEnableAutoScaling (); + this.autoScaleEnabled = getEnableAutoScaling (); init (drawable, data, hDC); init(); } @@ -447,33 +447,10 @@ void checkGC(int mask) { * </ul> */ public void copyArea(Image image, int x, int y) { - copyArea (image, x, y, defaultAutoScale); -} - -/** - * Copies a rectangular area of the receiver at the specified - * position into the image, which must be of type <code>SWT.BITMAP</code>. - * - * @param image the image to copy into - * @param x the x coordinate in the receiver of the area to be copied - * @param y the y coordinate in the receiver of the area to be copied - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the image is null</li> - * <li>ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void copyArea(Image image, int x, int y, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = ((float)this.getDeviceZoom()) / 100f; x = (int)(x * scaleFactor); y = (int)(y * scaleFactor); @@ -757,45 +734,9 @@ void disposeGdip() { * </ul> */ public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) { - drawArc(x, y, width, height, startAngle, arcAngle, defaultAutoScale); -} - -/** - * Draws the outline of a circular or elliptical arc - * within the specified rectangular area. - * <p> - * The resulting arc begins at <code>startAngle</code> and extends - * for <code>arcAngle</code> degrees, using the current color. - * Angles are interpreted such that 0 degrees is at the 3 o'clock - * position. A positive value indicates a counter-clockwise rotation - * while a negative value indicates a clockwise rotation. - * </p><p> - * The center of the arc is the center of the rectangle whose origin - * is (<code>x</code>, <code>y</code>) and whose size is specified by the - * <code>width</code> and <code>height</code> arguments. - * </p><p> - * The resulting arc covers an area <code>width + 1</code> pixels wide - * by <code>height + 1</code> pixels tall. - * </p> - * - * @param x the x coordinate of the upper-left corner of the arc to be drawn - * @param y the y coordinate of the upper-left corner of the arc to be drawn - * @param width the width of the arc to be drawn - * @param height the height of the arc to be drawn - * @param startAngle the beginning angle - * @param arcAngle the angular extent of the arc, relative to the start angle - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(DRAW); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = ((float)getDeviceZoom()) / 100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -898,32 +839,8 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int ar * @see #drawRectangle(int, int, int, int) */ public void drawFocus (int x, int y, int width, int height) { - drawFocus(x, y, width, height, defaultAutoScale); -} - -/** - * Draws a rectangle, based on the specified arguments, which has - * the appearance of the platform's <em>focus rectangle</em> if the - * platform supports such a notion, and otherwise draws a simple - * rectangle in the receiver's foreground color. - * - * @param x the x coordinate of the rectangle - * @param y the y coordinate of the rectangle - * @param width the width of the rectangle - * @param height the height of the rectangle - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawRectangle(int, int, int, int) - * - * @since 3.105 - */ -public void drawFocus (int x, int y, int width, int height, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -1780,28 +1697,8 @@ void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, * </ul> */ public void drawLine (int x1, int y1, int x2, int y2) { - drawLine(x1, y1, x2, y2, defaultAutoScale); -} - -/** - * Draws a line, using the foreground color, between the points - * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>). - * - * @param x1 the first point's x coordinate - * @param y1 the first point's y coordinate - * @param x2 the second point's x coordinate - * @param y2 the second point's y coordinate - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void drawLine (int x1, int y1, int x2, int y2, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x1 = (int) (x1 * scaleFactor); x2 = (int) (x2 * scaleFactor); @@ -1857,36 +1754,8 @@ public void drawLine (int x1, int y1, int x2, int y2, boolean autoScale) { * </ul> */ public void drawOval (int x, int y, int width, int height) { - drawOval(x, y, width, height, defaultAutoScale); -} - -/** - * Draws the outline of an oval, using the foreground color, - * within the specified rectangular area. - * <p> - * The result is a circle or ellipse that fits within the - * rectangle specified by the <code>x</code>, <code>y</code>, - * <code>width</code>, and <code>height</code> arguments. - * </p><p> - * The oval covers an area that is <code>width + 1</code> - * pixels wide and <code>height + 1</code> pixels tall. - * </p> - * - * @param x the x coordinate of the upper left corner of the oval to be drawn - * @param y the y coordinate of the upper left corner of the oval to be drawn - * @param width the width of the oval to be drawn - * @param height the height of the oval to be drawn - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void drawOval (int x, int y, int width, int height, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -1960,30 +1829,8 @@ public void drawPath (Path path) { * @since 3.0 */ public void drawPoint (int x, int y) { - drawPoint(x, y, defaultAutoScale); -} - -/** - * Draws a pixel, using the foreground color, at the specified - * point (<code>x</code>, <code>y</code>). - * <p> - * Note that the receiver's line attributes do not affect this - * operation. - * </p> - * - * @param x the point's x coordinate - * @param y the point's y coordinate - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void drawPoint (int x, int y, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -2108,30 +1955,8 @@ public void drawPolyline(int[] pointArray) { * </ul> */ public void drawRectangle (int x, int y, int width, int height) { - drawRectangle(x, y, width, height, defaultAutoScale); -} - -/** - * Draws the outline of the rectangle specified by the arguments, - * using the receiver's foreground color. The left and right edges - * of the rectangle are at <code>x</code> and <code>x + width</code>. - * The top and bottom edges are at <code>y</code> and <code>y + height</code>. - * - * @param x the x coordinate of the rectangle to be drawn - * @param y the y coordinate of the rectangle to be drawn - * @param width the width of the rectangle to be drawn - * @param height the height of the rectangle to be drawn - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void drawRectangle (int x, int y, int width, int height, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -2213,36 +2038,8 @@ public void drawRectangle (Rectangle rect) { * </ul> */ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { - drawRoundRectangle(x, y, width, height, arcWidth, arcHeight, defaultAutoScale); -} - -/** - * Draws the outline of the round-cornered rectangle specified by - * the arguments, using the receiver's foreground color. The left and - * right edges of the rectangle are at <code>x</code> and <code>x + width</code>. - * The top and bottom edges are at <code>y</code> and <code>y + height</code>. - * The <em>roundness</em> of the corners is specified by the - * <code>arcWidth</code> and <code>arcHeight</code> arguments, which - * are respectively the width and height of the ellipse used to draw - * the corners. - * - * @param x the x coordinate of the rectangle to be drawn - * @param y the y coordinate of the rectangle to be drawn - * @param width the width of the rectangle to be drawn - * @param height the height of the rectangle to be drawn - * @param arcWidth the width of the arc - * @param arcHeight the height of the arc - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @since 3.105 - */ -public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -2373,7 +2170,7 @@ void drawRoundRectangleGdip (long /*int*/ gdipGraphics, long /*int*/ pen, int x, * </ul> */ public void drawString (String string, int x, int y) { - drawString(string, x, y, defaultAutoScale); + drawString(string, x, y, false); } /** @@ -2946,47 +2743,8 @@ public boolean equals (Object object) { * @see #drawArc */ public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) { - fillArc(x, y, width, height, startAngle, arcAngle, defaultAutoScale); -} - -/** - * Fills the interior of a circular or elliptical arc within - * the specified rectangular area, with the receiver's background - * color. - * <p> - * The resulting arc begins at <code>startAngle</code> and extends - * for <code>arcAngle</code> degrees, using the current color. - * Angles are interpreted such that 0 degrees is at the 3 o'clock - * position. A positive value indicates a counter-clockwise rotation - * while a negative value indicates a clockwise rotation. - * </p><p> - * The center of the arc is the center of the rectangle whose origin - * is (<code>x</code>, <code>y</code>) and whose size is specified by the - * <code>width</code> and <code>height</code> arguments. - * </p><p> - * The resulting arc covers an area <code>width + 1</code> pixels wide - * by <code>height + 1</code> pixels tall. - * </p> - * - * @param x the x coordinate of the upper-left corner of the arc to be filled - * @param y the y coordinate of the upper-left corner of the arc to be filled - * @param width the width of the arc to be filled - * @param height the height of the arc to be filled - * @param startAngle the beginning angle - * @param arcAngle the angular extent of the arc, relative to the start angle - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawArc - * - * @since 3.105 - */ -public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -3093,35 +2851,8 @@ public void fillArc (int x, int y, int width, int height, int startAngle, int ar * @see #drawRectangle(int, int, int, int) */ public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) { - fillGradientRectangle(x, y, width, height, vertical, defaultAutoScale); -} - -/** - * Fills the interior of the specified rectangle with a gradient - * sweeping from left to right or top to bottom progressing - * from the receiver's foreground color to its background color. - * - * @param x the x coordinate of the rectangle to be filled - * @param y the y coordinate of the rectangle to be filled - * @param width the width of the rectangle to be filled, may be negative - * (inverts direction of gradient if horizontal) - * @param height the height of the rectangle to be filled, may be negative - * (inverts direction of gradient if vertical) - * @param vertical if true sweeps from top to bottom, else - * sweeps from left to right - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawRectangle(int, int, int, int) - * - * @since 3.105 - */ -public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -3253,30 +2984,8 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v * @see #drawOval */ public void fillOval (int x, int y, int width, int height) { - fillOval(x, y, width, height, defaultAutoScale); -} - -/** - * Fills the interior of an oval, within the specified - * rectangular area, with the receiver's background - * color. - * - * @param x the x coordinate of the upper left corner of the oval to be filled - * @param y the y coordinate of the upper left corner of the oval to be filled - * @param width the width of the oval to be filled - * @param height the height of the oval to be filled - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawOval - * - * @since 3.105 - */ -public void fillOval (int x, int y, int width, int height, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -3383,30 +3092,8 @@ public void fillPolygon(int[] pointArray) { * @see #drawRectangle(int, int, int, int) */ public void fillRectangle (int x, int y, int width, int height) { - fillRectangle(x, y, width, height, defaultAutoScale); -} - -/** - * Fills the interior of the rectangle specified by the arguments, - * using the receiver's background color. - * - * @param x the x coordinate of the rectangle to be filled - * @param y the y coordinate of the rectangle to be filled - * @param width the width of the rectangle to be filled - * @param height the height of the rectangle to be filled - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawRectangle(int, int, int, int) - * - * @since 3.105 - */ -public void fillRectangle (int x, int y, int width, int height, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = (float) getDeviceZoom()/100f; x = (int) (x * scaleFactor); y = (int) (y * scaleFactor); @@ -3456,28 +3143,6 @@ public void fillRectangle (Rectangle rect) { if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); fillRectangle (rect.x, rect.y, rect.width, rect.height); } -/** - * Fills the interior of the specified rectangle, using the receiver's - * background color. - * - * @param rect the rectangle to be filled - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawRectangle(int, int, int, int) - * - * @since 3.105 - */ -public void fillRectangle (Rectangle rect, boolean autoScale) { - if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - fillRectangle (rect.x, rect.y, rect.width, rect.height, autoScale); -} /** * Fills the interior of the round-cornered rectangle specified by @@ -3497,32 +3162,8 @@ public void fillRectangle (Rectangle rect, boolean autoScale) { * @see #drawRoundRectangle */ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { - fillRoundRectangle(x, y, width, height, arcWidth, arcHeight, defaultAutoScale); -} - -/** - * Fills the interior of the round-cornered rectangle specified by - * the arguments, using the receiver's background color. - * - * @param x the x coordinate of the rectangle to be filled - * @param y the y coordinate of the rectangle to be filled - * @param width the width of the rectangle to be filled - * @param height the height of the rectangle to be filled - * @param arcWidth the width of the arc - * @param arcHeight the height of the arc - * @param autoScale true if coordinates need to be adjusted for zoom - * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> - * - * @see #drawRoundRectangle - * - * @since 3.105 - */ -public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight, boolean autoScale) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (autoScale) { + if (autoScaleEnabled) { float scaleFactor = this.getDeviceZoom() / 100f; x = (int)(x * scaleFactor); y = (int)(y * scaleFactor); @@ -4170,7 +3811,7 @@ public int getLineStyle() { public int getLineWidth() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); int returnVal = (int)data.lineWidth; - if (defaultAutoScale) { + if (autoScaleEnabled) { float scaleFactor = ((float)this.getDeviceZoom()) / 100f; returnVal = (int)(returnVal / scaleFactor); } @@ -5246,7 +4887,7 @@ public void setLineStyle(int lineStyle) { */ public void setLineWidth(int lineWidth) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (defaultAutoScale) { + if (autoScaleEnabled) { float scaleFactor = ((float)this.getDeviceZoom()) / 100f; lineWidth = (int)(lineWidth * scaleFactor); } |