@@ -1553,8 +1553,6 @@ LRESULT WM_PAINT (long wParam, long lParam) {
1553
1553
data .ps = ps ;
1554
1554
data .hwnd = handle ;
1555
1555
GC gc = GC .win32_new (this , data );
1556
-
1557
- /* Get the system region for the paint HDC */
1558
1556
long sysRgn = 0 ;
1559
1557
if ((style & (SWT .DOUBLE_BUFFERED | SWT .TRANSPARENT )) != 0 || (style & SWT .NO_MERGE_PAINTS ) != 0 ) {
1560
1558
sysRgn = OS .CreateRectRgn (0 , 0 , 0 , 0 );
@@ -1577,17 +1575,26 @@ LRESULT WM_PAINT (long wParam, long lParam) {
1577
1575
int width = ps .right - ps .left ;
1578
1576
int height = ps .bottom - ps .top ;
1579
1577
if (width != 0 && height != 0 ) {
1580
- GC paintGC = null ;
1578
+ GC paintGC = gc ;
1581
1579
Image image = null ;
1582
1580
if ((style & (SWT .DOUBLE_BUFFERED | SWT .TRANSPARENT )) != 0 ) {
1583
- image = new Image (display , width , height );
1584
- 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 ());
1581
+ ImageGcDrawer drawer = new ImageGcDrawer () {
1582
+ @ Override
1583
+ public void drawOn (GC gc , int iWidth , int iHeight ) {
1584
+ GCData gcData = gc .getGCData ();
1585
+ gcData .uiState = data .uiState ;
1586
+ gc .setForeground (getForeground ());
1587
+ gc .setBackground (getBackground ());
1588
+ gc .setFont (getFont ());
1589
+
1590
+ }
1591
+
1592
+ @ Override
1593
+ public int getGcStyle () {
1594
+ return paintGC .getStyle () & SWT .RIGHT_TO_LEFT ;
1595
+ }
1596
+ };
1597
+ image = new Image (display , drawer , width , height );
1591
1598
if ((style & SWT .TRANSPARENT ) != 0 ) {
1592
1599
OS .BitBlt (gc .handle , 0 , 0 , width , height , paintGC .handle , ps .left , ps .top , OS .SRCCOPY );
1593
1600
}
0 commit comments