@@ -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 );
@@ -1577,17 +1575,26 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15771575 int width = ps .right - ps .left ;
15781576 int height = ps .bottom - ps .top ;
15791577 if (width != 0 && height != 0 ) {
1580- GC paintGC = null ;
1578+ GC paintGC = gc ;
15811579 Image image = null ;
15821580 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 );
15911598 if ((style & SWT .TRANSPARENT ) != 0 ) {
15921599 OS .BitBlt (gc .handle , 0 , 0 , width , height , paintGC .handle , ps .left , ps .top , OS .SRCCOPY );
15931600 }
0 commit comments