From 7274167512353f0e440b6ac5769abbebf0862fb5 Mon Sep 17 00:00:00 2001 From: Amartya Parijat Date: Wed, 10 Dec 2025 16:00:48 +0100 Subject: [PATCH] Use OS#Polygon in GC#drawRectangleInPixels This commit replaces OS#Rectangle with OS#Polygon in drawRectangleInPixels since, the behaviour of Rectangle doesn't comply with the documentation in https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-rectangle for win32 --- .../win32/org/eclipse/swt/graphics/GC.java | 31 +------------------ 1 file changed, 1 insertion(+), 30 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 e9fd4140349..1d03488e5ed 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 @@ -2309,36 +2309,7 @@ void apply() { } private void drawRectangleInPixels (int x, int y, int width, int height) { - checkGC(DRAW); - long gdipGraphics = data.gdipGraphics; - if (gdipGraphics != 0) { - if (width < 0) { - x = x + width; - width = -width; - } - if (height < 0) { - y = y + height; - height = -height; - } - Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); - Gdip.Graphics_DrawRectangle(gdipGraphics, data.gdipPen, x, y, width, height); - Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); - return; - } - if ((data.style & SWT.MIRRORED) != 0) { - /* - * Note that Rectangle() subtracts one pixel in MIRRORED mode when - * the pen was created with CreatePen() and its width is 0 or 1. - */ - if (data.lineWidth > 1) { - if ((data.lineWidth % 2) == 1) x++; - } else { - if (data.hPen != 0 && OS.GetObject(data.hPen, 0, 0) != OS.LOGPEN_sizeof()) { - x++; - } - } - } - OS.Rectangle (handle, x, y, x + width + 1, y + height + 1); + drawPolygonInPixels(new int[] {x, y, x + width + 1, y, x + width + 1, y + height + 1, x, y + height + 1}); } /**