diff options
author | Niraj Modi | 2016-02-12 06:22:40 +0000 |
---|---|---|
committer | Niraj Modi | 2016-02-12 06:22:40 +0000 |
commit | ca815cd21572e20f1fadfa8c1a5fa668f2e3bd12 (patch) | |
tree | e0f8a83bb995659d1acbce31d1b74faeeeb1ce1b | |
parent | 6a22d0ead2a518bbc3ead013d57fbea0d965a6f3 (diff) | |
download | eclipse.platform.swt-ca815cd21572e20f1fadfa8c1a5fa668f2e3bd12.tar.gz eclipse.platform.swt-ca815cd21572e20f1fadfa8c1a5fa668f2e3bd12.tar.xz eclipse.platform.swt-ca815cd21572e20f1fadfa8c1a5fa668f2e3bd12.zip |
Win32 (Part 3): Changing API's coordinate system from Pixels to Points.
- Updated GC class & it's usage across SWT code-base.
Change-Id: I37269f14381e056342b5ed21b5408126b445d28f
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
24 files changed, 395 insertions, 263 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java index 68c41102a6..2331770ac7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java @@ -126,19 +126,19 @@ public Point computeSizeInPixels(int wHint, int hHint, boolean changed) { } private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(topleft); - gc.drawLine(x, y, x+w-1, y); - gc.drawLine(x, y, x, y+h-1); + gc.drawLineInPixels(x, y, x+w-1, y); + gc.drawLineInPixels(x, y, x, y+h-1); gc.setForeground(bottomright); - gc.drawLine(x+w, y, x+w, y+h); - gc.drawLine(x, y+h, x+w, y+h); + gc.drawLineInPixels(x+w, y, x+w, y+h); + gc.drawLineInPixels(x, y+h, x+w, y+h); } void paint(PaintEvent event) { GC gc = event.gc; Display disp= getDisplay(); Rectangle rect= getClientAreaInPixels(); - gc.fillRectangle(rect); + gc.fillRectangleInPixels(rect); if (showBorder) { drawBevelRect(gc, rect.x, rect.y, rect.width-1, rect.height-1, disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), @@ -155,11 +155,11 @@ void paintStripes(GC gc) { // Subtracted border painted by paint. rect = new Rectangle(rect.x+2, rect.y+2, rect.width-4, rect.height-4); - gc.setLineWidth(2); - gc.setClipping(rect); + gc.setLineWidthInPixels(2); + gc.setClippingInPixels(rect); Color color = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); gc.setBackground(color); - gc.fillRectangle(rect); + gc.fillRectangleInPixels(rect); gc.setForeground(this.getBackground()); int step = 12; int foregroundValue = value == 0 ? step - 2 : value - 2; @@ -169,7 +169,7 @@ void paintStripes(GC gc) { int h = rect.height + 2; for (int i= 0; i < w; i+= step) { int x = i + foregroundValue; - gc.drawLine(x, y, x, h); + gc.drawLineInPixels(x, y, x, h); } } else { int x = rect.x - 1; @@ -178,7 +178,7 @@ void paintStripes(GC gc) { for (int i= 0; i < h; i+= step) { int y = i + foregroundValue; - gc.drawLine(x, y, w, y); + gc.drawLineInPixels(x, y, w, y); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CBanner.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CBanner.java index 5a52134752..a2337e2ce0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CBanner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CBanner.java @@ -312,7 +312,7 @@ void onPaint(GC gc) { if (bottom != null) { int y = bottom.getBoundsInPixels().y - BORDER_STRIPE - 1; gc.setForeground(border1); - gc.drawLine(0, y, size.x, y); + gc.drawLineInPixels(0, y, size.x, y); } if (left == null || right == null) return; int[] line1 = new int[curve.length+6]; @@ -360,12 +360,12 @@ void onPaint(GC gc) { int x1 = Math.max(0, curveStart - CURVE_TAIL); gc.setForeground(background); gc.setBackground(border1); - gc.fillGradientRectangle(x1, size.y - BORDER_STRIPE, curveStart-x1+1, 1, false); + gc.fillGradientRectangleInPixels(x1, size.y - BORDER_STRIPE, curveStart-x1+1, 1, false); } else { // draw solid tail int x1 = Math.max(0, curveStart - CURVE_TAIL); gc.setForeground(border1); - gc.drawLine(x1, size.y - BORDER_STRIPE, curveStart+1, size.y - BORDER_STRIPE); + gc.drawLineInPixels(x1, size.y - BORDER_STRIPE, curveStart+1, size.y - BORDER_STRIPE); } // draw border 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 ecf50aa937..fb11f223ce 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 @@ -1268,7 +1268,7 @@ void popupEvent(Event event) { Rectangle listRect = list.getBoundsInPixels(); Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); event.gc.setForeground(black); - event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); + event.gc.drawRectangleInPixels(0, 0, listRect.width + 1, listRect.height + 1); break; case SWT.Close: event.doit = false; 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 897e6741bb..3693aee7d9 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 @@ -170,12 +170,12 @@ public Point computeSizeInPixels(int wHint, int hHint, boolean changed) { */ private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(bottomright); - gc.drawLine(x+w, y, x+w, y+h); - gc.drawLine(x, y+h, x+w, y+h); + gc.drawLineInPixels(x+w, y, x+w, y+h); + gc.drawLineInPixels(x, y+h, x+w, y+h); gc.setForeground(topleft); - gc.drawLine(x, y, x+w-1, y); - gc.drawLine(x, y, x, y+h-1); + gc.drawLineInPixels(x, y, x+w-1, y); + gc.drawLineInPixels(x, y, x, y+h-1); } /* * Return the lowercase of the first non-'&' character following @@ -455,7 +455,7 @@ void onPaint(PaintEvent event) { Rectangle imageRect = backgroundImage.getBoundsInPixels(); // tile image to fill space gc.setBackground(getBackground()); - gc.fillRectangle(rect); + gc.fillRectangleInPixels(rect); int xPos = 0; while (xPos < rect.width) { int yPos = 0; @@ -470,7 +470,7 @@ void onPaint(PaintEvent event) { final Color oldBackground = gc.getBackground(); if (gradientColors.length == 1) { if (gradientColors[0] != null) gc.setBackground(gradientColors[0]); - gc.fillRectangle(0, 0, rect.width, rect.height); + gc.fillRectangleInPixels(0, 0, rect.width, rect.height); } else { final Color oldForeground = gc.getForeground(); Color lastColor = gradientColors[0]; @@ -483,21 +483,21 @@ void onPaint(PaintEvent event) { gc.setBackground(lastColor); if (gradientVertical) { final int gradientHeight = (gradientPercents[i] * rect.height / 100) - pos; - gc.fillGradientRectangle(0, pos, rect.width, gradientHeight, true); + gc.fillGradientRectangleInPixels(0, pos, rect.width, gradientHeight, true); pos += gradientHeight; } else { final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos; - gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false); + gc.fillGradientRectangleInPixels(pos, 0, gradientWidth, rect.height, false); pos += gradientWidth; } } if (gradientVertical && pos < rect.height) { gc.setBackground(getBackground()); - gc.fillRectangle(0, pos, rect.width, rect.height - pos); + gc.fillRectangleInPixels(0, pos, rect.width, rect.height - pos); } if (!gradientVertical && pos < rect.width) { gc.setBackground(getBackground()); - gc.fillRectangle(pos, 0, rect.width - pos, rect.height); + gc.fillRectangleInPixels(pos, 0, rect.width - pos, rect.height); } gc.setForeground(oldForeground); } @@ -505,13 +505,13 @@ void onPaint(PaintEvent event) { } else { if ((background != null || (getStyle() & SWT.DOUBLE_BUFFERED) == 0) && background.getAlpha() > 0) { gc.setBackground(getBackground()); - gc.fillRectangle(rect); + gc.fillRectangleInPixels(rect); } } } catch (SWTException e) { if ((getStyle() & SWT.DOUBLE_BUFFERED) == 0) { gc.setBackground(getBackground()); - gc.fillRectangle(rect); + gc.fillRectangleInPixels(rect); } } @@ -600,7 +600,7 @@ private void paintBorder(GC gc, Rectangle r) { } if (c1 != null && c2 != null) { - gc.setLineWidth(1); + gc.setLineWidthInPixels(1); drawBevelRect(gc, r.x, r.y, r.width-1, r.height-1, c1, c2); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java index fbf7509504..cf64692e3f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java @@ -714,7 +714,7 @@ Image createButtonImage(Display display, int button) { } Color transColor = new Color(display, transparent); gc.setBackground(transColor); - gc.fillRectangle(image.getBoundsInPixels()); + gc.fillRectangleInPixels(image.getBoundsInPixels()); renderer.draw(button, SWT.NONE, new Rectangle(trim.x, trim.y, size.x, size.y), gc); gc.dispose (); transColor.dispose(); @@ -2073,11 +2073,11 @@ void onPaint(Event event) { x = hoverRect.x; int y = hoverRect.y; gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE)); - gc.fillRectangle(x + hoverRect.width - 6, y, 5, 5); - gc.drawRectangle(x + hoverRect.width - 6, y, 5, 5); - gc.drawLine(x + hoverRect.width - 6, y+2, x + hoverRect.width - 6 + 5, y + 2); - gc.fillRectangle(x, y, 5 , 2); - gc.drawRectangle(x, y, 5 , 2); + gc.fillRectangleInPixels(x + hoverRect.width - 6, y, 5, 5); + gc.drawRectangleInPixels(x + hoverRect.width - 6, y, 5, 5); + gc.drawLineInPixels(x + hoverRect.width - 6, y+2, x + hoverRect.width - 6 + 5, y + 2); + gc.fillRectangleInPixels(x, y, 5 , 2); + gc.drawRectangleInPixels(x, y, 5 , 2); } gc.setFont(gcFont); gc.setForeground(gcForeground); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java index fe03314a5e..4bfe12cfa8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java @@ -663,7 +663,7 @@ public class CTabFolderRenderer { if (image != null) { // draw the background image in shape gc.setBackground(defaultBackground); - gc.fillRectangle(x, y, width, height); + gc.fillRectangleInPixels(x, y, width, height); Rectangle imageRect = image.getBoundsInPixels(); gc.drawImage(image, imageRect.x, imageRect.y, imageRect.width, imageRect.height, x, y, width, height); } else if (colors != null) { @@ -671,7 +671,7 @@ public class CTabFolderRenderer { if (colors.length == 1) { Color background = colors[0] != null ? colors[0] : defaultBackground; gc.setBackground(background); - gc.fillRectangle(x, y, width, height); + gc.fillRectangleInPixels(x, y, width, height); } else { if (vertical) { if (parent.onBottom) { @@ -679,7 +679,7 @@ public class CTabFolderRenderer { if (percents[percents.length - 1] < 100) { pos = (100 - percents[percents.length - 1]) * height / 100; gc.setBackground(defaultBackground); - gc.fillRectangle(x, y, width, pos); + gc.fillRectangleInPixels(x, y, width, pos); } Color lastColor = colors[colors.length-1]; if (lastColor == null) lastColor = defaultBackground; @@ -690,7 +690,7 @@ public class CTabFolderRenderer { gc.setBackground(lastColor); int percentage = i > 0 ? percents[i] - percents[i-1] : percents[i]; int gradientHeight = percentage * height / 100; - gc.fillGradientRectangle(x, y+pos, width, gradientHeight, true); + gc.fillGradientRectangleInPixels(x, y+pos, width, gradientHeight, true); pos += gradientHeight; } } else { @@ -704,12 +704,12 @@ public class CTabFolderRenderer { gc.setBackground(lastColor); int percentage = i > 0 ? percents[i] - percents[i-1] : percents[i]; int gradientHeight = percentage * height / 100; - gc.fillGradientRectangle(x, y+pos, width, gradientHeight, true); + gc.fillGradientRectangleInPixels(x, y+pos, width, gradientHeight, true); pos += gradientHeight; } if (pos < height) { gc.setBackground(defaultBackground); - gc.fillRectangle(x, pos, width, height-pos+1); + gc.fillRectangleInPixels(x, pos, width, height-pos+1); } } } else { //horizontal gradient @@ -724,12 +724,12 @@ public class CTabFolderRenderer { if (lastColor == null) lastColor = defaultBackground; gc.setBackground(lastColor); int gradientWidth = (percents[i] * width / 100) - pos; - gc.fillGradientRectangle(x+pos, y, gradientWidth, height, false); + gc.fillGradientRectangleInPixels(x+pos, y, gradientWidth, height, false); pos += gradientWidth; } if (pos < width) { gc.setBackground(defaultBackground); - gc.fillRectangle(x+pos, y, width-pos, height); + gc.fillRectangleInPixels(x+pos, y, width-pos, height); } } } @@ -737,7 +737,7 @@ public class CTabFolderRenderer { // draw a solid background using default background in shape if ((parent.getStyle() & SWT.NO_BACKGROUND) != 0 || !defaultBackground.equals(parent.getBackground())) { gc.setBackground(defaultBackground); - gc.fillRectangle(x, y, width, height); + gc.fillRectangleInPixels(x, y, width, height); } } if (shape != null) { @@ -818,14 +818,14 @@ public class CTabFolderRenderer { } else { yClient = borderTop + tabHeight + highlight_header + marginHeight; } - gc.fillRectangle(xClient - marginWidth, yClient - marginHeight, width, height); + gc.fillRectangleInPixels(xClient - marginWidth, yClient - marginHeight, width, height); } } else { if ((parent.getStyle() & SWT.NO_BACKGROUND) != 0) { int height = borderTop + tabHeight + highlight_header + borderBottom; if (size.y > height) { gc.setBackground(parent.getParent().getBackground()); - gc.fillRectangle(0, height, size.x, size.y - height); + gc.fillRectangleInPixels(0, height, size.x, size.y - height); } } } @@ -837,12 +837,12 @@ public class CTabFolderRenderer { int x2 = size.x - borderRight; int y1 = parent.onBottom ? borderTop - 1 : borderTop + tabHeight; int y2 = parent.onBottom ? size.y - tabHeight - borderBottom - 1 : size.y - borderBottom; - gc.drawLine(x1, y1, x1, y2); // left - gc.drawLine(x2, y1, x2, y2); // right + gc.drawLineInPixels(x1, y1, x1, y2); // left + gc.drawLineInPixels(x2, y1, x2, y2); // right if (parent.onBottom) { - gc.drawLine(x1, y1, x2, y1); // top + gc.drawLineInPixels(x1, y1, x2, y1); // top } else { - gc.drawLine(x1, y2, x2, y2); // bottom + gc.drawLineInPixels(x1, y2, x2, y2); // bottom } } } @@ -930,14 +930,14 @@ public class CTabFolderRenderer { Color chevronBorder = parent.single ? parent.getSelectionForeground() : parent.getForeground(); gc.setForeground(chevronBorder); gc.setFont(f); - gc.drawLine(x,y, x+2,y+2); - gc.drawLine(x+2,y+2, x,y+4); - gc.drawLine(x+1,y, x+3,y+2); - gc.drawLine(x+3,y+2, x+1,y+4); - gc.drawLine(x+4,y, x+6,y+2); - gc.drawLine(x+6,y+2, x+5,y+4); - gc.drawLine(x+5,y, x+7,y+2); - gc.drawLine(x+7,y+2, x+4,y+4); + gc.drawLineInPixels(x,y, x+2,y+2); + gc.drawLineInPixels(x+2,y+2, x,y+4); + gc.drawLineInPixels(x+1,y, x+3,y+2); + gc.drawLineInPixels(x+3,y+2, x+1,y+4); + gc.drawLineInPixels(x+4,y, x+6,y+2); + gc.drawLineInPixels(x+6,y+2, x+5,y+4); + gc.drawLineInPixels(x+5,y, x+7,y+2); + gc.drawLineInPixels(x+7,y+2, x+4,y+4); gc.drawString(chevronString, x+7, y+3, true); break; } @@ -945,16 +945,16 @@ public class CTabFolderRenderer { gc.setForeground(display.getSystemColor(BUTTON_BORDER)); gc.setBackground(display.getSystemColor(BUTTON_FILL)); gc.setFont(f); - gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6); - gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6); - gc.drawLine(x,y, x+2,y+2); - gc.drawLine(x+2,y+2, x,y+4); - gc.drawLine(x+1,y, x+3,y+2); - gc.drawLine(x+3,y+2, x+1,y+4); - gc.drawLine(x+4,y, x+6,y+2); - gc.drawLine(x+6,y+2, x+5,y+4); - gc.drawLine(x+5,y, x+7,y+2); - gc.drawLine(x+7,y+2, x+4,y+4); + gc.fillRoundRectangleInPixels(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6); + gc.drawRoundRectangleInPixels(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6); + gc.drawLineInPixels(x,y, x+2,y+2); + gc.drawLineInPixels(x+2,y+2, x,y+4); + gc.drawLineInPixels(x+1,y, x+3,y+2); + gc.drawLineInPixels(x+3,y+2, x+1,y+4); + gc.drawLineInPixels(x+4,y, x+6,y+2); + gc.drawLineInPixels(x+6,y+2, x+5,y+4); + gc.drawLineInPixels(x+5,y, x+7,y+2); + gc.drawLineInPixels(x+7,y+2, x+4,y+4); gc.drawString(chevronString, x+7, y+3, true); break; } @@ -962,16 +962,16 @@ public class CTabFolderRenderer { gc.setForeground(display.getSystemColor(BUTTON_BORDER)); gc.setBackground(display.getSystemColor(BUTTON_FILL)); gc.setFont(f); - gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6); - gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6); - gc.drawLine(x+1,y+1, x+3,y+3); - gc.drawLine(x+3,y+3, x+1,y+5); - gc.drawLine(x+2,y+1, x+4,y+3); - gc.drawLine(x+4,y+3, x+2,y+5); - gc.drawLine(x+5,y+1, x+7,y+3); - gc.drawLine(x+7,y+3, x+6,y+5); - gc.drawLine(x+6,y+1, x+8,y+3); - gc.drawLine(x+8,y+3, x+5,y+5); + gc.fillRoundRectangleInPixels(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6); + gc.drawRoundRectangleInPixels(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6); + gc.drawLineInPixels(x+1,y+1, x+3,y+3); + gc.drawLineInPixels(x+3,y+3, x+1,y+5); + gc.drawLineInPixels(x+2,y+1, x+4,y+3); + gc.drawLineInPixels(x+4,y+3, x+2,y+5); + gc.drawLineInPixels(x+5,y+1, x+7,y+3); + gc.drawLineInPixels(x+7,y+3, x+6,y+5); + gc.drawLineInPixels(x+6,y+1, x+8,y+3); + gc.drawLineInPixels(x+8,y+3, x+5,y+5); gc.drawString(chevronString, x+8, y+4, true); break; } @@ -1005,7 +1005,7 @@ public class CTabFolderRenderer { gc.setForeground(gradients[0]); //draw top horizontal line - gc.drawLine( + gc.drawLineInPixels( TOP_LEFT_CORNER_HILITE[0] + x + 1, //rely on fact that first pair is top/right of curve 1 + y, rightEdge - curveIndent, @@ -1027,12 +1027,12 @@ public class CTabFolderRenderer { lastY = rawY + y; lastColorIndex = rawY - 1; gc.setForeground(gradients[lastColorIndex]); - gc.drawPoint(lastX, lastY); + gc.drawPointInPixels(lastX, lastY); } //draw left vertical line highlight for(int i = lastColorIndex; i < gradientsSize; i++) { gc.setForeground(gradients[i]); - gc.drawPoint(lastX, 1 + lastY++); + gc.drawPointInPixels(lastX, 1 + lastY++); } int rightEdgeOffset = rightEdge - curveIndent; @@ -1047,14 +1047,14 @@ public class CTabFolderRenderer { if(lastColorIndex >= gradientsSize) break; //can happen if tabs are unusually short and cut off the curve gc.setForeground(gradients[lastColorIndex]); - gc.drawPoint(lastX, lastY); + gc.drawPointInPixels(lastX, lastY); } //draw right diagonal line highlight for(int i = lastColorIndex; i < lastColorIndex + d; i++) { if(i >= gradientsSize) break; //can happen if tabs are unusually short and cut off the curve gc.setForeground(gradients[i]); - gc.drawPoint(1 + lastX++, 1 + lastY++); + gc.drawPointInPixels(1 + lastX++, 1 + lastY++); } //draw right swoop highlight from diagonal portion to end @@ -1067,7 +1067,7 @@ public class CTabFolderRenderer { if(lastColorIndex >= gradientsSize) break; //can happen if tabs are unusually short and cut off the curve gc.setForeground(gradients[lastColorIndex]); - gc.drawPoint(lastX, lastY); + gc.drawPointInPixels(lastX, lastY); } } @@ -1127,50 +1127,50 @@ public class CTabFolderRenderer { switch (maxImageState & (SWT.HOT | SWT.SELECTED)) { case SWT.NONE: { if (!parent.getMaximized()) { - gc.fillRectangle(x, y, 9, 9); - gc.drawRectangle(x, y, 9, 9); - gc.drawLine(x+1, y+2, x+8, y+2); + gc.fillRectangleInPixels(x, y, 9, 9); + gc.drawRectangleInPixels(x, y, 9, 9); + gc.drawLineInPixels(x+1, y+2, x+8, y+2); } else { - gc.fillRectangle(x, y+3, 5, 4); - gc.fillRectangle(x+2, y, 5, 4); - gc.drawRectangle(x, y+3, 5, 4); - gc.drawRectangle(x+2, y, 5, 4); - gc.drawLine(x+3, y+1, x+6, y+1); - gc.drawLine(x+1, y+4, x+4, y+4); + gc.fillRectangleInPixels(x, y+3, 5, 4); + gc.fillRectangleInPixels(x+2, y, 5, 4); + gc.drawRectangleInPixels(x, y+3, 5, 4); + gc.drawRectangleInPixels(x+2, y, 5, 4); + gc.drawLineInPixels(x+3, y+1, x+6, y+1); + gc.drawLineInPixels(x+1, y+4, x+4, y+4); } break; } case SWT.HOT: { - gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6); - gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6); + gc.fillRoundRectangleInPixels(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6); + gc.drawRoundRectangleInPixels(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6); if (!parent.getMaximized()) { - gc.fillRectangle(x, y, 9, 9); - gc.drawRectangle(x, y, 9, 9); - gc.drawLine(x+1, y+2, x+8, y+2); + gc.fillRectangleInPixels(x, y, 9, 9); + gc.drawRectangleInPixels(x, y, 9, 9); + gc.drawLineInPixels(x+1, y+2, x+8, y+2); } else { - gc.fillRectangle(x, y+3, 5, 4); - gc.fillRectangle(x+2, y, 5, 4); - gc.drawRectangle(x, y+3, 5, 4); - gc.drawRectangle(x+2, y, 5, 4); - gc.drawLine(x+3, y+1, x+6, y+1); - gc.drawLine(x+1, y+4, x+4, y+4); + gc.fillRectangleInPixels(x, y+3, 5, 4); + gc.fillRectangleInPixels(x+2, y, 5, 4); + gc.drawRectangleInPixels(x, y+3, 5, 4); + gc.drawRectangleInPixels(x+2, y, 5, 4); + gc.drawLineInPixels(x+3, y+1, x+6, y+1); + gc.drawLineInPixels(x+1, y+4, x+4, y+4); } break; } case SWT.SELECTED: { - gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6); - gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6); + gc.fillRoundRectangleInPixels(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6); + gc.drawRoundRectangleInPixels(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6); if (!parent.getMaximized()) { - gc.fillRectangle(x+1, y+1, 9, 9); - gc.drawRectangle(x+1, y+1, 9, 9); - gc.drawLine(x+2, y+3, x+9, y+3); + gc.fillRectangleInPixels(x+1, y+1, 9, 9); + gc.drawRectangleInPixels(x+1, y+1, 9, 9); + gc.drawLineInPixels(x+2, y+3, x+9, y+3); } else { - gc.fillRectangle(x+1, y+4, 5, 4); - gc.fillRectangle(x+3, y+1, 5, 4); - gc.drawRectangle(x+1, y+4, 5, 4); - gc.drawRectangle(x+3, y+1, 5, 4); - gc.drawLine(x+4, y+2, x+7, y+2); - gc.drawLine(x+2, y+5, x+5, y+5); + gc.fillRectangleInPixels(x+1, y+4, 5, 4); + gc.fillRectangleInPixels(x+3, y+1, 5, 4); + gc.drawRectangleInPixels(x+1, y+4, 5, 4); + gc.drawRectangleInPixels(x+3, y+1, 5, 4); + gc.drawLineInPixels(x+4, y+2, x+7, y+2); + gc.drawLineInPixels(x+2, y+5, x+5, y+5); } break; } @@ -1189,47 +1189,47 @@ public class CTabFolderRenderer { switch (minImageState & (SWT.HOT | SWT.SELECTED)) { case SWT.NONE: { if (!parent.getMinimized()) { - gc.fillRectangle(x, y, 9, 3); - gc.drawRectangle(x, y, 9, 3); + gc.fillRectangleInPixels(x, y, 9, 3); + gc.drawRectangleInPixels(x, y, 9, 3); } else { - gc.fillRectangle(x, y+3, 5, 4); - gc.fillRectangle(x+2, y, 5, 4); - gc.drawRectangle(x, y+3, 5, 4); - gc.drawRectangle(x+2, y, 5, 4); - gc.drawLine(x+3, y+1, x+6, y+1); - gc.drawLine(x+1, y+4, x+4, y+4); + gc.fillRectangleInPixels(x, y+3, 5, 4); + gc.fillRectangleInPixels(x+2, y, 5, 4); + gc.drawRectangleInPixels(x, y+3, 5, 4); + gc.drawRectangleInPixels(x+2, y, 5, 4); + gc.drawLineInPixels(x+3, y+1, x+6, y+1); + gc.drawLineInPixels(x+1, y+4, x+4, y+4); } break; } case SWT.HOT: { - gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6); - gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6); + gc.fillRoundRectangleInPixels(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6); + gc.drawRoundRectangleInPixels(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6); if (!parent.getMinimized()) { - gc.fillRectangle(x, y, 9, 3); - gc.drawRectangle(x, y, 9, 3); + gc.fillRectangleInPixels(x, y, 9, 3); + gc.drawRectangleInPixels(x, y, 9, 3); } else { - gc.fillRectangle(x, y+3, 5, 4); - gc.fillRectangle(x+2, y, 5, 4); - gc.drawRectangle(x, y+3, 5, 4); - gc.drawRectangle(x+2, y, 5, 4); - gc.drawLine(x+3, y+1, x+6, y+1); - gc.drawLine(x+1, y+4, x+4, y+4); + gc.fillRectangleInPixels(x, y+3, 5, 4); + gc.fillRectangleInPixels(x+2, y, 5, 4); + gc.drawRectangleInPixels(x, y+3, 5, 4); + gc.drawRectangleInPixels(x+2, y, 5, 4); + gc.drawLineInPixels(x+3, y+1, x+6, y+1); + gc.drawLineInPixels(x+1, y+4, x+4, y+4); } break; } case SWT.SELECTED: { - gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6); - gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6); + gc.fillRoundRectangleInPixels(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6); + gc.drawRoundRectangleInPixels(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6); if (!parent.getMinimized()) { - gc.fillRectangle(x+1, y+1, 9, 3); - gc.drawRectangle(x+1, y+1, 9, 3); + gc.fillRectangleInPixels(x+1, y+1, 9, 3); + gc.drawRectangleInPixels(x+1, y+1, 9, 3); } else { - gc.fillRectangle(x+1, y+4, 5, 4); - gc.fillRectangle(x+3, y+1, 5, 4); - gc.drawRectangle(x+1, y+4, 5, 4); - gc.drawRectangle(x+3, y+1, 5, 4); - gc.drawLine(x+4, y+2, x+7, y+2); - gc.drawLine(x+2, y+5, x+5, y+5); + gc.fillRectangleInPixels(x+1, y+4, 5, 4); + gc.fillRectangleInPixels(x+3, y+1, 5, 4); + gc.drawRectangleInPixels(x+1, y+4, 5, 4); + gc.drawRectangleInPixels(x+3, y+1, 5, 4); + gc.drawLineInPixels(x+4, y+2, x+7, y+2); + gc.drawLineInPixels(x+2, y+5, x+5, y+5); } break; } @@ -1314,7 +1314,7 @@ public class CTabFolderRenderer { drawBackground(gc, shape, true); } else { gc.setBackground(parent.selectionBackground); - gc.fillRectangle(xx, yy, ww, hh); + gc.fillRectangleInPixels(xx, yy, ww, hh); } if (parent.single) { @@ -1327,7 +1327,7 @@ public class CTabFolderRenderer { int y1 = (parent.onBottom) ? y - 1 : y + height; int x2 = size.x - borderRight; gc.setForeground(parent.getDisplay().getSystemColor(BORDER1_COLOR)); - gc.drawLine(x1, y1, x2, y1); + gc.drawLineInPixels(x1, y1, x2, y1); return; } @@ -1383,7 +1383,7 @@ public class CTabFolderRenderer { shape[index++] = y + height + 1; } - Rectangle clipping = gc.getClipping(); + Rectangle clipping = gc.getClippingInPixels(); Rectangle clipBounds = item.getBounds(); clipBounds.height += 1; if (parent.onBottom) clipBounds.y -= 1; @@ -1477,10 +1477,10 @@ public class CTabFolderRenderer { if (parent.simple || parent.single) { gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - gc.drawFocus(xDraw-1, textY-1, extent.x+2, extent.y+2); + gc.drawFocusInPixels(xDraw-1, textY-1, extent.x+2, extent.y+2); } else { gc.setForeground(display.getSystemColor(BUTTON_BORDER)); - gc.drawLine(xDraw, textY+extent.y+1, xDraw+extent.x+1, textY+extent.y+1); + gc.drawLineInPixels(xDraw, textY+extent.y+1, xDraw+extent.x+1, textY+extent.y+1); } } } @@ -1604,7 +1604,7 @@ public class CTabFolderRenderer { int y1 = (parent.onBottom) ? size.y - borderBottom - tabHeight - 1 : borderTop + tabHeight; int x2 = size.x - borderRight; gc.setForeground(borderColor); - gc.drawLine(x1, y1, x2, y1); + gc.drawLineInPixels(x1, y1, x2, y1); } // Draw border line @@ -1626,7 +1626,7 @@ public class CTabFolderRenderer { // Do not draw partial items if (!item.showing) return; - Rectangle clipping = gc.getClipping(); + Rectangle clipping = gc.getClippingInPixels(); if (!clipping.intersects(bounds)) return; if ((state & SWT.BACKGROUND) != 0) { @@ -1691,7 +1691,7 @@ public class CTabFolderRenderer { gc.getClipping(clipping); region.intersect(clipping); gc.setClipping(region); - gc.fillRectangle(region.getBounds()); + gc.fillRectangleInPixels(region.getBounds()); gc.setClipping(clipping); clipping.dispose(); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java index d573de8d0f..3543fb75a7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java @@ -517,9 +517,9 @@ public class StyledText extends Canvas { } else { //draw paragraph top in the current page and paragraph bottom in the next int height = paragraphBottom - paintY; - gc.setClipping(clientArea.x, paintY, clientArea.width, height); + gc.setClippingInPixels(clientArea.x, paintY, clientArea.width, height); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); - gc.setClipping((Rectangle)null); + gc.setClippingInPixels((Rectangle)null); printDecoration(page, false, printLayout); printer.endPage(); page++; @@ -528,9 +528,9 @@ public class StyledText extends Canvas { printDecoration(page, true, printLayout); paintY = clientArea.y - height; int layoutHeight = layout.getBounds().height; - gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height); + gc.setClippingInPixels(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); - gc.setClipping((Rectangle)null); + gc.setClippingInPixels((Rectangle)null); paintY += layoutHeight; } } @@ -611,7 +611,7 @@ public class StyledText extends Canvas { if (background != null) { Rectangle rect = layout.getBounds(); gc.setBackground(background); - gc.fillRectangle(x, y, rect.width, rect.height); + gc.fillRectangleInPixels(x, y, rect.width, rect.height); // int lineCount = layout.getLineCount(); // for (int i = 0; i < lineCount; i++) { @@ -2084,11 +2084,11 @@ void createCaretBitmaps() { leftCaretBitmap = new Image(display, caretWidth, lineHeight); GC gc = new GC (leftCaretBitmap); gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); - gc.fillRectangle(0, 0, caretWidth, lineHeight); + gc.fillRectangleInPixels(0, 0, caretWidth, lineHeight); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - gc.drawLine(0,0,0,lineHeight); - gc.drawLine(0,0,caretWidth-1,0); - gc.drawLine(0,1,1,1); + gc.drawLineInPixels(0,0,0,lineHeight); + gc.drawLineInPixels(0,0,caretWidth-1,0); + gc.drawLineInPixels(0,1,1,1); gc.dispose(); if (rightCaretBitmap != null) { @@ -2100,11 +2100,11 @@ void createCaretBitmaps() { rightCaretBitmap = new Image(display, caretWidth, lineHeight); gc = new GC (rightCaretBitmap); gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); - gc.fillRectangle(0, 0, caretWidth, lineHeight); + gc.fillRectangleInPixels(0, 0, caretWidth, lineHeight); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - gc.drawLine(caretWidth-1,0,caretWidth-1,lineHeight); - gc.drawLine(0,0,caretWidth-1,0); - gc.drawLine(caretWidth-1,1,1,1); + gc.drawLineInPixels(caretWidth-1,0,caretWidth-1,lineHeight); + gc.drawLineInPixels(0,0,caretWidth-1,0); + gc.drawLineInPixels(caretWidth-1,1,1,1); gc.dispose(); } /** @@ -6156,11 +6156,11 @@ void handlePaint(Event event) { if (blockSelection && blockXLocation != -1) { gc.setBackground(getSelectionBackground()); Rectangle rect = getBlockSelectionRectangle(); - gc.drawRectangle(rect.x, rect.y, Math.max(1, rect.width - 1), Math.max(1, rect.height - 1)); + gc.drawRectangleInPixels(rect.x, rect.y, Math.max(1, rect.width - 1), Math.max(1, rect.height - 1)); gc.setAdvanced(true); if (gc.getAdvanced()) { gc.setAlpha(100); - gc.fillRectangle(rect); + gc.fillRectangleInPixels(rect); gc.setAdvanced(false); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java index 1532119c7d..03868ac0bb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java @@ -71,7 +71,7 @@ public class StyledTextDropTargetEffect extends DropTargetEffect { Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); - event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); + event.gc.fillRectangleInPixels(position.x, position.y, CARET_WIDTH, height); } } }; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java index 1e155230c8..e56e73910b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java @@ -371,7 +371,7 @@ int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackgroun int height = layout.getBounds().height; if (lineBackground != null) { gc.setBackground(lineBackground); - gc.fillRectangle(client.x, paintY, client.width, height); + gc.fillRectangleInPixels(client.x, paintY, client.width, height); } else { gc.setBackground(widgetBackground); styledText.drawBackground(gc, client.x, paintY, client.width, height); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java index 80f9bd75cb..2b44a82f68 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java @@ -319,7 +319,7 @@ void paint(Event event) { GC gc = event.gc; gc.setBackground(getBackground()); gc.setForeground(getForeground()); - gc.fillRectangle(event.x, event.y, event.width, event.height); + gc.fillRectangleInPixels(event.x, event.y, event.width, event.height); int x = 0; Point size = getSizeInPixels(); Image image = row.getImage(columnIndex); @@ -377,7 +377,7 @@ void paint(Event event) { Display display = getDisplay(); gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - gc.drawFocus(0, 0, size.x, size.y); + gc.drawFocusInPixels(0, 0, size.x, size.y); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java index 353149b812..9a6b05b91d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java @@ -396,12 +396,12 @@ void createImages () { plusImage = new Image(getDisplay(), imageData); GC gc = new GC(plusImage); gc.setBackground(background); - gc.fillRectangle(0, 0, itemHeight, itemHeight); + gc.fillRectangleInPixels(0, 0, itemHeight, itemHeight); gc.setForeground(plusMinus); - gc.drawRectangle(indent, indent, size, size); + gc.drawRectangleInPixels(indent, indent, size, size); gc.setForeground(foreground); - gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2); - gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint); + gc.drawLineInPixels(midpoint, indent + 2, midpoint, indent + size - 2); + gc.drawLineInPixels(indent + 2, midpoint, indent + size - 2, midpoint); gc.dispose(); /* Minus image */ @@ -411,11 +411,11 @@ void createImages () { minusImage = new Image(getDisplay(), imageData); gc = new GC(minusImage); gc.setBackground(background); - gc.fillRectangle(0, 0, itemHeight, itemHeight); + gc.fillRectangleInPixels(0, 0, itemHeight, itemHeight); gc.setForeground(plusMinus); - gc.drawRectangle(indent, indent, size, size); + gc.drawRectangleInPixels(indent, indent, size, size); gc.setForeground(foreground); - gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint); + gc.drawLineInPixels(indent + 2, midpoint, indent + size - 2, midpoint); gc.dispose(); } @@ -719,7 +719,7 @@ public void setBackground (Color color) { GC gc = new GC (sizeImage); gc.setBackground(getBackground()); Rectangle size = sizeImage.getBoundsInPixels(); - gc.fillRectangle(size); + gc.fillRectangleInPixels(size); gc.dispose(); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java index b3e7cb331a..807f244009 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java @@ -192,7 +192,7 @@ TableTreeItem(TableTree parent, TableTreeItem parentItem, int style, int index) parent.sizeImage = new Image(parent.getDisplay(), itemHeight, itemHeight); GC gc = new GC (parent.sizeImage); gc.setBackground(parent.getBackground()); - gc.fillRectangle(0, 0, itemHeight, itemHeight); + gc.fillRectangleInPixels(0, 0, itemHeight, itemHeight); gc.dispose(); tableItem.setImage(0, parent.sizeImage); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeCursor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeCursor.java index 6384e93a7f..02c47af6ea 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeCursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeCursor.java @@ -622,7 +622,7 @@ void paint(Event event) { GC gc = event.gc; gc.setBackground(getBackground()); gc.setForeground(getForeground()); - gc.fillRectangle(event.x, event.y, event.width, event.height); + gc.fillRectangleInPixels(event.x, event.y, event.width, event.height); Image image = row.getImage(columnIndex); int x = 0; // Temporary code - need a better way to determine trim @@ -690,7 +690,7 @@ void paint(Event event) { Display display = getDisplay(); gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - gc.drawFocus(0, 0, size.x, size.y); + gc.drawFocusInPixels(0, 0, size.x, size.y); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java index bee0aec488..cdb647dd02 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java @@ -264,7 +264,7 @@ void onPaint(GC gc) { Color border = getDisplay().getSystemColor(BORDER1_COLOR); if (showBorder) { gc.setForeground(border); - gc.drawRectangle(0, 0, size.x - 1, size.y - 1); + gc.drawRectangleInPixels(0, 0, size.x - 1, size.y - 1); if (highlight > 0) { int x1 = 1; int y1 = 1; @@ -280,7 +280,7 @@ void onPaint(GC gc) { } if (separator > -1) { gc.setForeground(border); - gc.drawLine(borderLeft + highlight, separator, size.x - borderLeft - borderRight - highlight, separator); + gc.drawLineInPixels(borderLeft + highlight, separator, size.x - borderLeft - borderRight - highlight, separator); } gc.setForeground(gcForeground); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java index aa6a5a1dc2..3606d99cb6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/ScaleDrawData.java @@ -72,13 +72,13 @@ void draw(Theme theme, GC gc, Rectangle bounds) { rect.bottom = rect.top + 1; //TODO - why tics are ot drawn OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TICSVERT, 1, rect, null); - gc.drawLine(rect.left, rect.top, rect.right, rect.top); + gc.drawLineInPixels(rect.left, rect.top, rect.right, rect.top); rect.left = bounds.x + TICS_MARGIN + thumbWidth + 1; rect.right = rect.left + ticWidth; if (sel != minimum && sel != maximum) rect.right--; //TODO - why tics are ot drawn OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TICSVERT, 1, rect, null); - gc.drawLine(rect.left, rect.top, rect.right, rect.top); + gc.drawLineInPixels(rect.left, rect.top, rect.right, rect.top); } } else { diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/Theme.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/Theme.java index 10a0a9ccc6..44537af9d6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/Theme.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/win32/org/eclipse/swt/internal/theme/Theme.java @@ -52,7 +52,7 @@ public void drawFocus(GC gc, Rectangle bounds, DrawData data) { if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height); + gc.drawFocusInPixels(bounds.x, bounds.y, bounds.width, bounds.height); } public void drawImage(GC gc, Rectangle bounds, DrawData data, Image image, int flags) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java index 7c1fa12517..19e6d41678 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/DPIUtil.java @@ -102,6 +102,19 @@ public static int autoScaleUp (int size, Device device) { } /** + * Auto-scale up int array dimensions. + */ +public static int[] autoScaleUp (int size[], Device device) { + if (!getAutoScale () || device == null) return size; + float scaleFactor = getScalingFactor (device); + int scaledSize[] = new int[size.length]; + for (int i = 0; i < scaledSize.length; i++) { + scaledSize[i] = Math.round (size[i] * scaleFactor); + } + return scaledSize; +} + +/** * Returns a new scaled up Point. */ public static Point autoScaleUp (Point point, Device device) { 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 6d5a641154..24c3d5e4f3 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 @@ -444,12 +444,18 @@ void checkGC(int mask) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void copyArea(Image image, int x, int y) { +public void copyArea (Image image, int x, int y) { + x = DPIUtil.autoScaleUp(x, device); + y = DPIUtil.autoScaleUp(y, device); + copyAreaInPixels(image, x, y); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void copyAreaInPixels(Image image, int x, int y) { 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); - x = DPIUtil.autoScaleUp(x, device); - y = DPIUtil.autoScaleUp(y, device); /* Copy the bitmap area */ Rectangle rect = image.getBoundsInPixels(); long /*int*/ memHdc = OS.CreateCompatibleDC(handle); @@ -474,8 +480,14 @@ public void copyArea(Image image, int x, int y) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) { - copyArea(srcX, srcY, width, height, destX, destY, true); +public void copyArea (int srcX, int srcY, int width, int height, int destX, int destY) { + copyAreaInPixels (srcX, srcY, width, height, destX, destY); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY) { + copyAreaInPixels(srcX, srcY, width, height, destX, destY, true); } /** @@ -496,14 +508,20 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d * * @since 3.1 */ -public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); +public void copyArea (int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { srcX = DPIUtil.autoScaleUp(srcX, device); srcY = DPIUtil.autoScaleUp(srcY, device); width = DPIUtil.autoScaleUp(width, device); height = DPIUtil.autoScaleUp(height, device); destX = DPIUtil.autoScaleUp(destX, device); destY = DPIUtil.autoScaleUp(destY, device); + copyAreaInPixels(srcX, srcY, width, height, destX, destY, paint); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); /* * Feature in WinCE. The function WindowFromDC is not part of the * WinCE SDK. The fix is to remember the HWND. @@ -734,10 +752,18 @@ void disposeGdip() { * </ul> */ public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - checkGC(DRAW); + x = DPIUtil.autoScaleUp(x, device); + y = DPIUtil.autoScaleUp(y, device); width = DPIUtil.autoScaleUp(width, device); height = DPIUtil.autoScaleUp(height, device); + drawArcInPixels(x, y, width, height, startAngle, arcAngle); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawArcInPixels (int x, int y, int width, int height, int startAngle, int arcAngle) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + checkGC(DRAW); if (width < 0) { x = x + width; width = -width; @@ -831,15 +857,20 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int ar * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * - * @see #drawRectangle(int, int, int, int) + * @see #drawRectangleInPixels(int, int, int, int) */ public void drawFocus (int x, int y, int width, int height) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); - + drawFocusInPixels(x, y, width, height); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawFocusInPixels (int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if ((data.uiState & OS.UISF_HIDEFOCUS) != 0) return; data.focusDrawn = true; long /*int*/ hdc = handle; @@ -1279,7 +1310,7 @@ void drawBitmapAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHe } /* Check clipping */ - Rectangle rect = getClipping(); + Rectangle rect = getClippingInPixels(); rect = rect.intersection(new Rectangle(destX, destY, destWidth, destHeight)); if (rect.isEmpty()) return; @@ -1690,12 +1721,17 @@ void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, * </ul> */ public void drawLine (int x1, int y1, int x2, int y2) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x1 = DPIUtil.autoScaleUp (x1, device); x2 = DPIUtil.autoScaleUp (x2, device); y1 = DPIUtil.autoScaleUp (y1, device); y2 = DPIUtil.autoScaleUp (y2, device); - + drawLineInPixels(x1, y1, x2, y2); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawLineInPixels (int x1, int y1, int x2, int y2) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(DRAW); long /*int*/ gdipGraphics = data.gdipGraphics; if (gdipGraphics != 0) { @@ -1744,12 +1780,17 @@ public void drawLine (int x1, int y1, int x2, int y2) { * </ul> */ public void drawOval (int x, int y, int width, int height) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); - + drawOvalInPixels(x, y, width, height); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawOvalInPixels (int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(DRAW); long /*int*/ gdipGraphics = data.gdipGraphics; if (gdipGraphics != 0) { @@ -1817,10 +1858,15 @@ public void drawPath (Path path) { * @since 3.0 */ public void drawPoint (int x, int y) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); - + drawPointInPixels(x, y); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawPointInPixels (int x, int y) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (data.gdipGraphics != 0) { checkGC(DRAW); Gdip.Graphics_FillRectangle(data.gdipGraphics, getFgBrush(), x, y, 1, 1); @@ -1941,11 +1987,17 @@ public void drawPolyline(int[] pointArray) { * </ul> */ public void drawRectangle (int x, int y, int width, int height) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); + drawRectangleInPixels(x, y, width, height); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawRectangleInPixels (int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(DRAW); long /*int*/ gdipGraphics = data.gdipGraphics; if (gdipGraphics != 0) { @@ -2021,14 +2073,19 @@ public void drawRectangle (Rectangle rect) { * </ul> */ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); arcWidth = DPIUtil.autoScaleUp (arcWidth, device); arcHeight = DPIUtil.autoScaleUp (arcHeight, device); - + drawRoundRectangleInPixels(x, y, width, height, arcWidth, arcHeight); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void drawRoundRectangleInPixels (int x, int y, int width, int height, int arcWidth, int arcHeight) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(DRAW); if (data.gdipGraphics != 0) { drawRoundRectangleGdip(data.gdipGraphics, data.gdipPen, x, y, width, height, arcWidth, arcHeight); @@ -2045,7 +2102,7 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt */ if (width == 0 || height == 0) return; if (arcWidth == 0 || arcHeight == 0) { - drawRectangle(x, y, width, height); + drawRectangleInPixels(x, y, width, height); return; } if (width < 0) { @@ -2062,18 +2119,18 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt if (arcHeight > height) arcHeight = height; if (arcWidth < width) { - drawLine(x+arcWidth/2, y, x+width-arcWidth/2, y); - drawLine(x+arcWidth/2, y+height, x+width-arcWidth/2, y+height); + drawLineInPixels(x+arcWidth/2, y, x+width-arcWidth/2, y); + drawLineInPixels(x+arcWidth/2, y+height, x+width-arcWidth/2, y+height); } if (arcHeight < height) { - drawLine(x, y+arcHeight/2, x, y+height-arcHeight/2); - drawLine(x+width, y+arcHeight/2, x+width, y+height-arcHeight/2); + drawLineInPixels(x, y+arcHeight/2, x, y+height-arcHeight/2); + drawLineInPixels(x+width, y+arcHeight/2, x+width, y+height-arcHeight/2); } if (arcWidth != 0 && arcHeight != 0) { - drawArc(x, y, arcWidth, arcHeight, 90, 90); - drawArc(x+width-arcWidth, y, arcWidth, arcHeight, 0, 90); - drawArc(x+width-arcWidth, y+height-arcHeight, arcWidth, arcHeight, 0, -90); - drawArc(x, y+height-arcHeight, arcWidth, arcHeight, 180, 90); + drawArcInPixels(x, y, arcWidth, arcHeight, 90, 90); + drawArcInPixels(x+width-arcWidth, y, arcWidth, arcHeight, 0, 90); + drawArcInPixels(x+width-arcWidth, y+height-arcHeight, arcWidth, arcHeight, 0, -90); + drawArcInPixels(x, y+height-arcHeight, arcWidth, arcHeight, 180, 90); } } else { OS.RoundRect(handle, x,y,x+width+1,y+height+1, arcWidth, arcHeight); @@ -2724,12 +2781,17 @@ public boolean equals (Object object) { * @see #drawArc */ public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); - + fillArcInPixels(x, y, width, height, startAngle, arcAngle); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void fillArcInPixels (int x, int y, int width, int height, int startAngle, int arcAngle) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(FILL); if (width < 0) { x = x + width; @@ -2827,15 +2889,20 @@ public void fillArc (int x, int y, int width, int height, int startAngle, int ar * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * - * @see #drawRectangle(int, int, int, int) + * @see #drawRectangleInPixels(int, int, int, int) */ -public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); +public void fillGradientRectangle (int x, int y, int width, int height, boolean vertical) { x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); - + fillGradientRectangleInPixels(x, y, width, height, vertical); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean vertical) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width == 0 || height == 0) return; RGB backgroundRGB, foregroundRGB; @@ -2860,7 +2927,7 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v toRGB = foregroundRGB; } if (fromRGB.equals(toRGB)) { - fillRectangle(x, y, width, height); + fillRectangleInPixels(x, y, width, height); return; } if (data.gdipGraphics != 0) { @@ -2961,12 +3028,17 @@ 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) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); - + fillOvalInPixels(x, y, width, height); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void fillOvalInPixels (int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(FILL); if (data.gdipGraphics != 0) { Gdip.Graphics_FillEllipse(data.gdipGraphics, data.gdipBrush, x, y, width, height); @@ -3029,7 +3101,7 @@ public void fillPath (Path path) { * * @see #drawPolygon */ -public void fillPolygon(int[] pointArray) { +public void fillPolygon (int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); checkGC(FILL); @@ -3064,14 +3136,20 @@ public void fillPolygon(int[] pointArray) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * - * @see #drawRectangle(int, int, int, int) + * @see #drawRectangleInPixels(int, int, int, int) */ public void fillRectangle (int x, int y, int width, int height) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); + fillRectangleInPixels(x, y, width, height); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void fillRectangleInPixels (int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(FILL); if (data.gdipGraphics != 0) { if (width < 0) { @@ -3109,11 +3187,18 @@ public void fillRectangle (int x, int y, int width, int height) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * - * @see #drawRectangle(int, int, int, int) + * @see #drawRectangleInPixels(int, int, int, int) */ public void fillRectangle (Rectangle rect) { + rect = DPIUtil.autoScaleUp(rect, getDevice()); + fillRectangleInPixels(rect); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void fillRectangleInPixels (Rectangle rect) { if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - fillRectangle (rect.x, rect.y, rect.width, rect.height); + fillRectangleInPixels (rect.x, rect.y, rect.width, rect.height); } /** @@ -3134,14 +3219,19 @@ public void fillRectangle (Rectangle rect) { * @see #drawRoundRectangle */ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp (x, device); y = DPIUtil.autoScaleUp (y, device); width = DPIUtil.autoScaleUp (width, device); height = DPIUtil.autoScaleUp (height, device); arcWidth = DPIUtil.autoScaleUp (arcWidth, device); arcHeight = DPIUtil.autoScaleUp (arcHeight, device); - + fillRoundRectangleInPixels(x, y, width, height, arcWidth, arcHeight); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void fillRoundRectangleInPixels (int x, int y, int width, int height, int arcWidth, int arcHeight) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); checkGC(FILL); if (data.gdipGraphics != 0) { fillRoundRectangleGdip(data.gdipGraphics, data.gdipBrush, x, y, width, height, arcWidth, arcHeight); @@ -3235,7 +3325,7 @@ public int getAdvanceWidth(char ch) { if (OS.IsWinCE) { SIZE size = new SIZE(); OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size); - return DPIUtil.autoScaleDown(size.cx, getDevice ()); + return size.cx; } int tch = ch; if (ch > 0x7F) { @@ -3244,7 +3334,7 @@ public int getAdvanceWidth(char ch) { } int[] width = new int[1]; OS.GetCharWidth(handle, tch, tch, width); - return DPIUtil.autoScaleDown(width[0], getDevice ()); + return width[0]; } /** @@ -3387,7 +3477,7 @@ public int getCharWidth(char ch) { } int[] width = new int[3]; if (OS.GetCharABCWidths(handle, tch, tch, width)) { - return DPIUtil.autoScaleDown(width[1], getDevice ()); + return width[1]; } } @@ -3396,7 +3486,7 @@ public int getCharWidth(char ch) { OS.GetTextMetrics(handle, lptm); SIZE size = new SIZE(); OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size); - return DPIUtil.autoScaleDown(size.cx - lptm.tmOverhang, getDevice ()); + return size.cx - lptm.tmOverhang; } /** @@ -3411,7 +3501,13 @@ public int getCharWidth(char ch) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public Rectangle getClipping() { +public Rectangle getClippingInP () { + return DPIUtil.autoScaleDown(getClippingInPixels(), getDevice()); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public Rectangle getClippingInPixels() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); long /*int*/ gdipGraphics = data.gdipGraphics; if (gdipGraphics != 0) { @@ -3419,11 +3515,11 @@ public Rectangle getClipping() { Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone); Gdip.Graphics_GetVisibleClipBounds(gdipGraphics, rect); Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); - return DPIUtil.autoScaleDown(new Rectangle(rect.X, rect.Y, rect.Width, rect.Height), getDevice ()); + return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height); } RECT rect = new RECT(); OS.GetClipBox(handle, rect); - return DPIUtil.autoScaleDown(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), getDevice ()); + return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } /** @@ -3778,9 +3874,15 @@ public int getLineStyle() { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public int getLineWidth() { +public int getLineWidth () { + return DPIUtil.autoScaleDown(getLineWidthInPixels(), getDevice()); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public int getLineWidthInPixels() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown((int)data.lineWidth, device); + return (int)data.lineWidth; } /** @@ -4339,11 +4441,17 @@ void setClipping(long /*int*/ clipRgn) { * </ul> */ public void setClipping (int x, int y, int width, int height) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); x = DPIUtil.autoScaleUp(x, getDevice ()); y = DPIUtil.autoScaleUp(y, getDevice ()); width = DPIUtil.autoScaleUp(width, getDevice ()); height = DPIUtil.autoScaleUp(height, getDevice ()); + setClippingInPixels(x, y, width, height); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setClippingInPixels (int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); long /*int*/ hRgn = OS.CreateRectRgn(x, y, x + width, y + height); setClipping(hRgn); OS.DeleteObject(hRgn); @@ -4401,12 +4509,18 @@ public void setClipping (Path path) { * </ul> */ public void setClipping (Rectangle rect) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); rect = DPIUtil.autoScaleUp(rect, getDevice ()); + setClippingInPixels(rect); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setClippingInPixels (Rectangle rect) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) { setClipping(0); } else { - setClipping(rect.x, rect.y, rect.width, rect.height); + setClippingInPixels(rect.x, rect.y, rect.width, rect.height); } } @@ -4856,9 +4970,14 @@ public void setLineStyle(int lineStyle) { * </ul> */ public void setLineWidth(int lineWidth) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); lineWidth = DPIUtil.autoScaleUp (lineWidth, device); - + setLineWidthInPixels(lineWidth); +} +/** +* @noreference This method is not intended to be referenced by clients. +*/ +public void setLineWidthInPixels(int lineWidth) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (data.lineWidth == lineWidth) return; data.lineWidth = lineWidth; data.state &= ~(LINE_WIDTH | DRAW_OFFSET); @@ -5014,19 +5133,19 @@ public Point stringExtent(String string) { if (gdipGraphics != 0) { Point size = new Point(0, 0); drawText(gdipGraphics, string, 0, 0, 0, size); - return DPIUtil.autoScaleDown(size, getDevice ()); + return size; } SIZE size = new SIZE(); if (length == 0) { // OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size); OS.GetTextExtentPoint32W(handle, new char[]{' '}, 1, size); - return DPIUtil.autoScaleDown(new Point(0, size.cy), getDevice ()); + return new Point(0, size.cy); } else { // TCHAR buffer = new TCHAR (getCodePage(), string, false); char[] buffer = new char [length]; string.getChars(0, length, buffer, 0); OS.GetTextExtentPoint32W(handle, buffer, length, size); - return DPIUtil.autoScaleDown(new Point(size.cx, size.cy), getDevice ()); + return new Point(size.cx, size.cy); } } @@ -5092,13 +5211,13 @@ public Point textExtent(String string, int flags) { if (gdipGraphics != 0) { Point size = new Point(0, 0); drawText(gdipGraphics, string, 0, 0, flags, size); - return DPIUtil.autoScaleDown(size, getDevice ()); + return size; } if (string.length () == 0) { SIZE size = new SIZE(); // OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size); OS.GetTextExtentPoint32W(handle, new char [] {' '}, 1, size); - return DPIUtil.autoScaleDown(new Point(0, size.cy), getDevice ()); + return new Point(0, size.cy); } RECT rect = new RECT(); TCHAR buffer = new TCHAR(getCodePage(), string, false); @@ -5107,7 +5226,7 @@ public Point textExtent(String string, int flags) { if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS; if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX; OS.DrawText(handle, buffer, buffer.length(), rect, uFormat); - return DPIUtil.autoScaleDown(new Point(rect.right, rect.bottom), getDevice ()); + return new Point(rect.right, rect.bottom); } /** 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 b191dc2e6a..881eb8133b 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 @@ -630,7 +630,7 @@ public void draw (GC gc, int x, int y, int selectionStart, int selectionEnd, Col int length = text.length(); if (length == 0 && flags == 0) return; long /*int*/ hdc = gc.handle; - Rectangle clip = gc.getClipping(); + Rectangle clip = gc.getClippingInPixels(); GCData data = gc.data; long /*int*/ gdipGraphics = data.gdipGraphics; int foreground = data.foreground; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index e0ab2fc8c3..2936e7ef11 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -184,7 +184,7 @@ void _setImage (Image image) { image2 = new Image (display, rect.width, rect.height); GC gc = new GC (image2); gc.setBackground (getBackground ()); - gc.fillRectangle (rect); + gc.fillRectangleInPixels (rect); gc.drawImage (image, 0, 0); gc.dispose (); hImage = image2.handle; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 5ee2ee6339..932f778ef0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -2277,7 +2277,7 @@ Image getSortImage (int direction) { upArrow = new Image (this, imageData); GC gc = new GC (upArrow); gc.setBackground (c3); - gc.fillRectangle (0, 0, 8, 8); + gc.fillRectangleInPixels (0, 0, 8, 8); gc.setForeground (c1); int [] line1 = new int [] {0,6, 1,6, 1,4, 2,4, 2,2, 3,2, 3,1}; gc.drawPolyline (line1); @@ -2298,7 +2298,7 @@ Image getSortImage (int direction) { downArrow = new Image (this, imageData); GC gc = new GC (downArrow); gc.setBackground (c3); - gc.fillRectangle (0, 0, 8, 8); + gc.fillRectangleInPixels (0, 0, 8, 8); gc.setForeground (c1); int [] line1 = new int [] {7,0, 0,0, 0,1, 1,1, 1,3, 2,3, 2,5, 3,5, 3,6}; gc.drawPolyline (line1); 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 aa689ff62c..8ba8edc05f 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 @@ -277,7 +277,7 @@ void drawWidget (GC gc, RECT rect) { Rectangle [] rects = getRectangles (focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rectangle = rects [i]; - gc.drawFocus (rectangle.x, rectangle.y, rectangle.width, rectangle.height); + gc.drawFocusInPixels (rectangle.x, rectangle.y, rectangle.width, rectangle.height); } } if (hooks (SWT.Paint) || filters (SWT.Paint)) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index dd20a3cdc0..88a027c0da 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -3647,7 +3647,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara event.y = cellRect.top; event.width = cellRect.right - cellRect.left; event.height = cellRect.bottom - cellRect.top; - gc.setClipping (event.x, event.y, event.width, event.height); + gc.setClippingInPixels (event.x, event.y, event.width, event.height); sendEvent (SWT.EraseItem, event); event.gc = null; int clrSelectionText = data.foreground; @@ -4103,7 +4103,7 @@ void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) { RECT cellRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC); int cellWidth = cellRect.right - cellRect.left; int cellHeight = cellRect.bottom - cellRect.top; - gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight); + gc.setClippingInPixels (cellRect.left, cellRect.top, cellWidth, cellHeight); sendEvent (SWT.PaintItem, event); if (data.focusDrawn) focusRect = null; event.gc = null; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index e137ea0883..fe27de3ec2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -532,7 +532,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int data.device = display; GC gc = GC.win32_new (hDC, data); RECT iconRect = item.getBounds (index, false, true, false, false, true, hDC); - gc.setClipping (iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top); + gc.setClippingInPixels (iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top); gc.drawImage (image, 0, 0, bounds.width, bounds.height, iconRect.left, iconRect.top, size.x, size.y); OS.SelectClipRgn (hDC, 0); gc.dispose (); @@ -652,7 +652,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int event.y = cellRect.top; event.width = cellRect.right - cellRect.left; event.height = cellRect.bottom - cellRect.top; - gc.setClipping (event.x, event.y, event.width, event.height); + gc.setClippingInPixels (event.x, event.y, event.width, event.height); sendEvent (SWT.EraseItem, event); event.gc = null; int newTextClr = data.foreground; @@ -774,7 +774,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int GCData data = new GCData(); data.device = display; GC gc = GC.win32_new (hDC, data); - gc.setClipping (x1, rect.top, rect.right - x1, rect.bottom - rect.top); + gc.setClippingInPixels (x1, rect.top, rect.right - x1, rect.bottom - rect.top); gc.drawImage (image, 0, 0, bounds.width, bounds.height, x1, y1, size.x, size.y); OS.SelectClipRgn (hDC, 0); gc.dispose (); @@ -872,7 +872,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC); int cellWidth = cellRect.right - cellRect.left; int cellHeight = cellRect.bottom - cellRect.top; - gc.setClipping (cellRect.left, cellRect.top, cellWidth, cellHeight); + gc.setClippingInPixels (cellRect.left, cellRect.top, cellWidth, cellHeight); sendEvent (SWT.PaintItem, event); if (data.focusDrawn) focusRect = null; event.gc = null; @@ -1059,7 +1059,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int* event.y = cellRect.top; event.width = cellRect.right - cellRect.left; event.height = cellRect.bottom - cellRect.top; - gc.setClipping (event.x, event.y, event.width, event.height); + gc.setClippingInPixels (event.x, event.y, event.width, event.height); sendEvent (SWT.EraseItem, event); event.gc = null; int newTextClr = data.foreground; |