Skip to content

Commit 807b159

Browse files
ShahzaibIbrahimfedejeanne
authored andcommitted
Replace usages of new Image(device, width, height) for Composite
1 parent 28fdeb6 commit 807b159

File tree

1 file changed

+18
-9
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+18
-9
lines changed

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,8 +1554,6 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15541554
data.ps = ps;
15551555
data.hwnd = handle;
15561556
GC gc = GC.win32_new (this, data);
1557-
1558-
/* Get the system region for the paint HDC */
15591557
long sysRgn = 0;
15601558
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0 || (style & SWT.NO_MERGE_PAINTS) != 0) {
15611559
sysRgn = OS.CreateRectRgn (0, 0, 0, 0);
@@ -1581,14 +1579,25 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15811579
GC paintGC = null;
15821580
Image image = null;
15831581
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0) {
1584-
image = new Image (display, width, height);
15851582
paintGC = gc;
1586-
gc = new GC (image, paintGC.getStyle() & SWT.RIGHT_TO_LEFT);
1587-
GCData gcData = gc.getGCData ();
1588-
gcData.uiState = data.uiState;
1589-
gc.setForeground (getForeground ());
1590-
gc.setBackground (getBackground ());
1591-
gc.setFont (getFont ());
1583+
int originalStyle = gc.getStyle();
1584+
ImageGcDrawer drawer = new ImageGcDrawer() {
1585+
@Override
1586+
public void drawOn(GC gc, int iWidth, int iHeight) {
1587+
GCData gcData = gc.getGCData ();
1588+
gcData.uiState = data.uiState;
1589+
gc.setForeground (getForeground ());
1590+
gc.setBackground (getBackground ());
1591+
gc.setFont (getFont ());
1592+
1593+
}
1594+
1595+
@Override
1596+
public int getGcStyle() {
1597+
return originalStyle & SWT.RIGHT_TO_LEFT;
1598+
}
1599+
};
1600+
image = new Image (display, drawer, width, height);
15921601
if ((style & SWT.TRANSPARENT) != 0) {
15931602
OS.BitBlt (gc.handle, 0, 0, width, height, paintGC.handle, ps.left, ps.top, OS.SRCCOPY);
15941603
}

0 commit comments

Comments
 (0)