Skip to content

Commit e41f12b

Browse files
ShahzaibIbrahimfedejeanne
authored andcommitted
Replace usages of new Image(device, width, height) for Composite
1 parent 6517c9e commit e41f12b

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
@@ -1553,8 +1553,6 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15531553
data.ps = ps;
15541554
data.hwnd = handle;
15551555
GC gc = GC.win32_new (this, data);
1556-
1557-
/* Get the system region for the paint HDC */
15581556
long sysRgn = 0;
15591557
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0 || (style & SWT.NO_MERGE_PAINTS) != 0) {
15601558
sysRgn = OS.CreateRectRgn (0, 0, 0, 0);
@@ -1580,14 +1578,25 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15801578
GC paintGC = null;
15811579
Image image = null;
15821580
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0) {
1583-
image = new Image (display, width, height);
15841581
paintGC = gc;
1585-
gc = new GC (image, paintGC.getStyle() & SWT.RIGHT_TO_LEFT);
1586-
GCData gcData = gc.getGCData ();
1587-
gcData.uiState = data.uiState;
1588-
gc.setForeground (getForeground ());
1589-
gc.setBackground (getBackground ());
1590-
gc.setFont (getFont ());
1582+
int originalStyle = gc.getStyle();
1583+
ImageGcDrawer drawer = new ImageGcDrawer() {
1584+
@Override
1585+
public void drawOn(GC gc, int iWidth, int iHeight) {
1586+
GCData gcData = gc.getGCData ();
1587+
gcData.uiState = data.uiState;
1588+
gc.setForeground (getForeground ());
1589+
gc.setBackground (getBackground ());
1590+
gc.setFont (getFont ());
1591+
1592+
}
1593+
1594+
@Override
1595+
public int getGcStyle() {
1596+
return originalStyle & SWT.RIGHT_TO_LEFT;
1597+
}
1598+
};
1599+
image = new Image (display, drawer, width, height);
15911600
if ((style & SWT.TRANSPARENT) != 0) {
15921601
OS.BitBlt (gc.handle, 0, 0, width, height, paintGC.handle, ps.left, ps.top, OS.SRCCOPY);
15931602
}

0 commit comments

Comments
 (0)