[Libreoffice-commits] core.git: include/vcl vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Fri Apr 18 23:52:42 PDT 2014


 include/vcl/outdev.hxx       |    4 ++--
 include/vcl/window.hxx       |    2 ++
 vcl/source/outdev/outdev.cxx |   20 +-------------------
 vcl/source/window/window.cxx |   33 +++++++++++++++++++++++++++++++++
 4 files changed, 38 insertions(+), 21 deletions(-)

New commits:
commit 9ad131f3c9980a7135653f187170f9ffb0fb59d8
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sat Apr 19 14:00:55 2014 +1000

    fdo#74702 Allow Window & OutputDevice to handle erasure
    
    Window handles erasure of backgrounds for controls. Probably this
    needs to be moved to a more specific class in the future, but for
    now it should go into Windows.
    
    I also removed an unnecessary temporary variable, and removed the
    need to case the pointer to this from OutputDevice to Window. In
    other words, this code has been vastly simplified :-)
    
    Change-Id: I44b91cf68f29424ffbc1679b66fbeaeb024880e9

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 0af54185e..d0bd887 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1436,8 +1436,8 @@ public:
     Size                        GetOutputSize() const
                                     { return PixelToLogic( GetOutputSizePixel() ); }
 
-    void                        Erase();
-    void                        Erase( const Rectangle& rRect ) { DrawWallpaper( rRect, GetBackground() ); }
+    virtual void                Erase();
+    virtual void                Erase( const Rectangle& rRect ) { DrawWallpaper( rRect, GetBackground() ); }
 
     bool                        AddTempDevFont( const OUString& rFileURL, const OUString& rFontName );
     int                         GetDevFontCount() const;
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index f71ae68..25063dc 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -606,6 +606,8 @@ public:
     virtual void        KeyUp( const KeyEvent& rKEvt );
     virtual void        PrePaint();
     virtual void        Paint( const Rectangle& rRect );
+    virtual void        Erase() SAL_OVERRIDE;
+    virtual void        Erase( const Rectangle& rRect ) SAL_OVERRIDE { OutputDevice::Erase( rRect ); }
 
     virtual void        PostPaint();
     virtual void        Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index f00f2bf..e8210f4 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -1581,25 +1581,7 @@ void OutputDevice::Erase()
     if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
         return;
 
-    bool bNativeOK = false;
-
-    if( meOutDevType == OUTDEV_WINDOW )
-    {
-        Window* pWindow = static_cast<Window*>(this);
-        ControlPart aCtrlPart = pWindow->ImplGetWindowImpl()->mnNativeBackground;
-        if( aCtrlPart != 0 && ! pWindow->IsControlBackground() )
-        {
-            ImplControlValue    aControlValue;
-            Rectangle           aCtrlRegion( Point(), GetOutputSizePixel() );
-            ControlState        nState = 0;
-
-            if( pWindow->IsEnabled() )              nState |= CTRL_STATE_ENABLED;
-            bNativeOK = pWindow->DrawNativeControl( CTRL_WINDOW_BACKGROUND, aCtrlPart, aCtrlRegion,
-                                                    nState, aControlValue, OUString() );
-        }
-    }
-
-    if ( mbBackground && ! bNativeOK )
+    if ( mbBackground )
     {
         RasterOp eRasterOp = GetRasterOp();
         if ( eRasterOp != ROP_OVERPAINT )
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 0ef7a05..eccb70e 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -9417,5 +9417,38 @@ void Window::DrawGradientWallpaper( long nX, long nY,
     mpMetaFile = pOldMetaFile;
 }
 
+void Window::Erase()
+{
+    if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
+        return;
+
+    bool bNativeOK = false;
+
+    ControlPart aCtrlPart = ImplGetWindowImpl()->mnNativeBackground;
+    if( aCtrlPart != 0 && ! IsControlBackground() )
+    {
+        Rectangle           aCtrlRegion( Point(), GetOutputSizePixel() );
+        ControlState        nState = 0;
+
+        if( IsEnabled() )
+            nState |= CTRL_STATE_ENABLED;
+
+        bNativeOK = DrawNativeControl( CTRL_WINDOW_BACKGROUND, aCtrlPart, aCtrlRegion,
+                                       nState, ImplControlValue(), OUString() );
+    }
+
+    if ( mbBackground && ! bNativeOK )
+    {
+        RasterOp eRasterOp = GetRasterOp();
+        if ( eRasterOp != ROP_OVERPAINT )
+            SetRasterOp( ROP_OVERPAINT );
+        ImplDrawWallpaper( 0, 0, mnOutWidth, mnOutHeight, maBackground );
+        if ( eRasterOp != ROP_OVERPAINT )
+            SetRasterOp( eRasterOp );
+    }
+
+    if( mpAlphaVDev )
+        mpAlphaVDev->Erase();
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list