diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-04-19 14:00:55 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-04-19 16:51:47 +1000 |
commit | 9ad131f3c9980a7135653f187170f9ffb0fb59d8 (patch) | |
tree | 7166bb2a034ba0fec018cfbdbcc7abc450a16e30 | |
parent | 1c0f94abb59296ec9e686dd3ea6b2cd963923631 (diff) |
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
-rw-r--r-- | include/vcl/outdev.hxx | 4 | ||||
-rw-r--r-- | include/vcl/window.hxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 20 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 33 |
4 files changed, 38 insertions, 21 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 0af54185ee11..d0bd887ada50 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 f71ae689c1a7..25063dc957d6 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 f00f2bfeae27..e8210f449404 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 0ef7a057b83d..eccb70e1720d 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: */ |