@@ -1581,14 +1581,25 @@ LRESULT WM_PAINT (long wParam, long lParam) {
1581
1581
GC paintGC = null ;
1582
1582
Image image = null ;
1583
1583
if ((style & (SWT .DOUBLE_BUFFERED | SWT .TRANSPARENT )) != 0 ) {
1584
- image = new Image (display , width , height );
1585
1584
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 ());
1585
+ int originalStyle = gc .getStyle ();
1586
+ ImageGcDrawer drawer = new ImageGcDrawer () {
1587
+ @ Override
1588
+ public void drawOn (GC gc , int iWidth , int iHeight ) {
1589
+ GCData gcData = gc .getGCData ();
1590
+ gcData .uiState = data .uiState ;
1591
+ gc .setForeground (getForeground ());
1592
+ gc .setBackground (getBackground ());
1593
+ gc .setFont (getFont ());
1594
+ }
1595
+
1596
+ @ Override
1597
+ public int getGcStyle () {
1598
+ return originalStyle & SWT .RIGHT_TO_LEFT ;
1599
+ }
1600
+ };
1601
+ image = new Image (display , drawer , width , height );
1602
+ gc = new GC (image , originalStyle & SWT .RIGHT_TO_LEFT );
1592
1603
if ((style & SWT .TRANSPARENT ) != 0 ) {
1593
1604
OS .BitBlt (gc .handle , 0 , 0 , width , height , paintGC .handle , ps .left , ps .top , OS .SRCCOPY );
1594
1605
}
@@ -1598,6 +1609,16 @@ LRESULT WM_PAINT (long wParam, long lParam) {
1598
1609
OS .SetMetaRgn (gc .handle );
1599
1610
OS .SetWindowOrgEx (gc .handle , ps .left , ps .top , null );
1600
1611
OS .SetBrushOrgEx (gc .handle , ps .left , ps .top , null );
1612
+
1613
+ if ((style & (SWT .NO_BACKGROUND | SWT .TRANSPARENT )) != 0 ) {
1614
+ /* This code is intentionally commented because it may be slow to copy bits from the screen */
1615
+ //newPaintGC.copyArea (image, ps.left, ps.top);
1616
+ } else {
1617
+ RECT rect = new RECT ();
1618
+ OS .SetRect (rect , ps .left , ps .top , ps .right , ps .bottom );
1619
+ drawBackground (gc .handle , rect );
1620
+ }
1621
+
1601
1622
if ((style & (SWT .NO_BACKGROUND | SWT .TRANSPARENT )) != 0 ) {
1602
1623
/* This code is intentionally commented because it may be slow to copy bits from the screen */
1603
1624
//paintGC.copyArea (image, ps.left, ps.top);
@@ -1642,10 +1663,10 @@ LRESULT WM_PAINT (long wParam, long lParam) {
1642
1663
GCData gcData = gc .getGCData ();
1643
1664
if (gcData .focusDrawn && !isDisposed ()) updateUIState ();
1644
1665
}
1645
- gc .dispose ();
1646
1666
if (!isDisposed ()) {
1647
1667
paintGC .drawImage (image , DPIUtil .scaleDown (ps .left , zoom ), DPIUtil .scaleDown (ps .top , zoom ));
1648
1668
}
1669
+ gc .dispose ();
1649
1670
image .dispose ();
1650
1671
gc = paintGC ;
1651
1672
}
0 commit comments