diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-05-13 21:23:18 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-05-13 21:30:47 +1000 |
commit | 82fa84e983fd5c8266e3b9ac820035a1d78a2ab4 (patch) | |
tree | 905e1f59a88cce4f974cfa621a7f01a96b6c9b27 /vcl | |
parent | aa23a83999acf1f0cd8631cf6b314e83d1bde9fb (diff) |
vcl: clipping functions moved from window.cxx to clipping.cxx
Change-Id: Iaaabbe2002b14540bdf4a51269909b44bf5d8880
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/clipping.cxx | 227 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 225 |
2 files changed, 227 insertions, 225 deletions
diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx index e6ffb04ffab2..94b510d1228f 100644 --- a/vcl/source/window/clipping.cxx +++ b/vcl/source/window/clipping.cxx @@ -141,6 +141,94 @@ void Window::InitClipRegion() mbInitClipRegion = false; } +void Window::SetParentClipMode( sal_uInt16 nMode ) +{ + + if ( mpWindowImpl->mpBorderWindow ) + mpWindowImpl->mpBorderWindow->SetParentClipMode( nMode ); + else + { + if ( !ImplIsOverlapWindow() ) + { + mpWindowImpl->mnParentClipMode = nMode; + if ( nMode & PARENTCLIPMODE_CLIP ) + mpWindowImpl->mpParent->mpWindowImpl->mbClipChildren = true; + } + } +} + +sal_uInt16 Window::GetParentClipMode() const +{ + + if ( mpWindowImpl->mpBorderWindow ) + return mpWindowImpl->mpBorderWindow->GetParentClipMode(); + else + return mpWindowImpl->mnParentClipMode; +} + +void Window::ExpandPaintClipRegion( const Region& rRegion ) +{ + if( mpWindowImpl->mpPaintRegion ) + { + Region aPixRegion = LogicToPixel( rRegion ); + Region aDevPixRegion = ImplPixelToDevicePixel( aPixRegion ); + + Region aWinChildRegion = *ImplGetWinChildClipRegion(); + // --- RTL -- only this region is in frame coordinates, so re-mirror it + if( ImplIsAntiparallel() ) + { + const OutputDevice *pOutDev = GetOutDev(); + pOutDev->ReMirror( aWinChildRegion ); + } + + aDevPixRegion.Intersect( aWinChildRegion ); + if( ! aDevPixRegion.IsEmpty() ) + { + mpWindowImpl->mpPaintRegion->Union( aDevPixRegion ); + mbInitClipRegion = true; + } + } +} + + +Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const +{ + + Region aWinClipRegion; + + if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN ) + { + if ( mpWindowImpl->mbInitWinClipRegion ) + ((Window*)this)->ImplInitWinClipRegion(); + aWinClipRegion = mpWindowImpl->maWinClipRegion; + } + else + { + Region* pWinChildClipRegion = ((Window*)this)->ImplGetWinChildClipRegion(); + aWinClipRegion = *pWinChildClipRegion; + // --- RTL --- remirror clip region before passing it to somebody + if( ImplIsAntiparallel() ) + { + const OutputDevice *pOutDev = GetOutDev(); + pOutDev->ReMirror( aWinClipRegion ); + } + } + + if ( nFlags & WINDOW_GETCLIPREGION_NULL ) + { + Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); + Region aWinRegion( aWinRect ); + + if ( aWinRegion == aWinClipRegion ) + aWinClipRegion.SetNull(); + } + + aWinClipRegion.Move( -mnOutOffX, -mnOutOffY ); + + return aWinClipRegion; +} + + Region Window::GetActiveClipRegion() const { Region aRegion(true); @@ -174,6 +262,145 @@ void Window::EnableClipSiblings( bool bClipSiblings ) mpWindowImpl->mbClipSiblings = bClipSiblings; } +void Window::ImplClipBoundaries( Region& rRegion, bool bThis, bool bOverlaps ) +{ + if ( bThis ) + ImplIntersectWindowClipRegion( rRegion ); + else if ( ImplIsOverlapWindow() ) + { + // clip to frame if required + if ( !mpWindowImpl->mbFrame ) + rRegion.Intersect( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) ); + + if ( bOverlaps && !rRegion.IsEmpty() ) + { + // Clip Overlap Siblings + Window* pStartOverlapWindow = this; + while ( !pStartOverlapWindow->mpWindowImpl->mbFrame ) + { + Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; + while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) ) + { + pOverlapWindow->ImplExcludeOverlapWindows2( rRegion ); + pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; + } + pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow; + } + + // Clip Child Overlap Windows + ImplExcludeOverlapWindows( rRegion ); + } + } + else + ImplGetParent()->ImplIntersectWindowClipRegion( rRegion ); +} + +bool Window::ImplClipChildren( Region& rRegion ) +{ + bool bOtherClip = false; + Window* pWindow = mpWindowImpl->mpFirstChild; + while ( pWindow ) + { + if ( pWindow->mpWindowImpl->mbReallyVisible ) + { + // read-out ParentClipMode-Flags + sal_uInt16 nClipMode = pWindow->GetParentClipMode(); + if ( !(nClipMode & PARENTCLIPMODE_NOCLIP) && + ((nClipMode & PARENTCLIPMODE_CLIP) || (GetStyle() & WB_CLIPCHILDREN)) ) + pWindow->ImplExcludeWindowRegion( rRegion ); + else + bOtherClip = true; + } + + pWindow = pWindow->mpWindowImpl->mpNext; + } + + return bOtherClip; +} + +void Window::ImplClipAllChildren( Region& rRegion ) +{ + Window* pWindow = mpWindowImpl->mpFirstChild; + while ( pWindow ) + { + if ( pWindow->mpWindowImpl->mbReallyVisible ) + pWindow->ImplExcludeWindowRegion( rRegion ); + pWindow = pWindow->mpWindowImpl->mpNext; + } +} + +void Window::ImplClipSiblings( Region& rRegion ) +{ + Window* pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild; + while ( pWindow ) + { + if ( pWindow == this ) + break; + + if ( pWindow->mpWindowImpl->mbReallyVisible ) + pWindow->ImplExcludeWindowRegion( rRegion ); + + pWindow = pWindow->mpWindowImpl->mpNext; + } +} + +void Window::ImplInitWinClipRegion() +{ + // Build Window Region + mpWindowImpl->maWinClipRegion = Rectangle( Point( mnOutOffX, mnOutOffY ), + Size( mnOutWidth, mnOutHeight ) ); + if ( mpWindowImpl->mbWinRegion ) + mpWindowImpl->maWinClipRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); + + // ClipSiblings + if ( mpWindowImpl->mbClipSiblings && !ImplIsOverlapWindow() ) + ImplClipSiblings( mpWindowImpl->maWinClipRegion ); + + // Clip Parent Boundaries + ImplClipBoundaries( mpWindowImpl->maWinClipRegion, false, true ); + + // Clip Children + if ( (GetStyle() & WB_CLIPCHILDREN) || mpWindowImpl->mbClipChildren ) + mpWindowImpl->mbInitChildRegion = true; + + mpWindowImpl->mbInitWinClipRegion = false; +} + +void Window::ImplInitWinChildClipRegion() +{ + if ( !mpWindowImpl->mpFirstChild ) + { + if ( mpWindowImpl->mpChildClipRegion ) + { + delete mpWindowImpl->mpChildClipRegion; + mpWindowImpl->mpChildClipRegion = NULL; + } + } + else + { + if ( !mpWindowImpl->mpChildClipRegion ) + mpWindowImpl->mpChildClipRegion = new Region( mpWindowImpl->maWinClipRegion ); + else + *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion; + + ImplClipChildren( *mpWindowImpl->mpChildClipRegion ); + } + + mpWindowImpl->mbInitChildRegion = false; +} + +Region* Window::ImplGetWinChildClipRegion() +{ + if ( mpWindowImpl->mbInitWinClipRegion ) + ImplInitWinClipRegion(); + if ( mpWindowImpl->mbInitChildRegion ) + ImplInitWinChildClipRegion(); + if ( mpWindowImpl->mpChildClipRegion ) + return mpWindowImpl->mpChildClipRegion; + else + return &mpWindowImpl->maWinClipRegion; +} + bool Window::ImplSysObjClip( const Region* pOldRegion ) { diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index dd8a6c413f11..d958287654b1 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1789,145 +1789,6 @@ void Window::ImplExcludeOverlapWindows2( Region& rRegion ) ImplExcludeOverlapWindows( rRegion ); } -void Window::ImplClipBoundaries( Region& rRegion, bool bThis, bool bOverlaps ) -{ - if ( bThis ) - ImplIntersectWindowClipRegion( rRegion ); - else if ( ImplIsOverlapWindow() ) - { - // clip to frame if required - if ( !mpWindowImpl->mbFrame ) - rRegion.Intersect( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) ); - - if ( bOverlaps && !rRegion.IsEmpty() ) - { - // Clip Overlap Siblings - Window* pStartOverlapWindow = this; - while ( !pStartOverlapWindow->mpWindowImpl->mbFrame ) - { - Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; - while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) ) - { - pOverlapWindow->ImplExcludeOverlapWindows2( rRegion ); - pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; - } - pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow; - } - - // Clip Child Overlap Windows - ImplExcludeOverlapWindows( rRegion ); - } - } - else - ImplGetParent()->ImplIntersectWindowClipRegion( rRegion ); -} - -bool Window::ImplClipChildren( Region& rRegion ) -{ - bool bOtherClip = false; - Window* pWindow = mpWindowImpl->mpFirstChild; - while ( pWindow ) - { - if ( pWindow->mpWindowImpl->mbReallyVisible ) - { - // read-out ParentClipMode-Flags - sal_uInt16 nClipMode = pWindow->GetParentClipMode(); - if ( !(nClipMode & PARENTCLIPMODE_NOCLIP) && - ((nClipMode & PARENTCLIPMODE_CLIP) || (GetStyle() & WB_CLIPCHILDREN)) ) - pWindow->ImplExcludeWindowRegion( rRegion ); - else - bOtherClip = true; - } - - pWindow = pWindow->mpWindowImpl->mpNext; - } - - return bOtherClip; -} - -void Window::ImplClipAllChildren( Region& rRegion ) -{ - Window* pWindow = mpWindowImpl->mpFirstChild; - while ( pWindow ) - { - if ( pWindow->mpWindowImpl->mbReallyVisible ) - pWindow->ImplExcludeWindowRegion( rRegion ); - pWindow = pWindow->mpWindowImpl->mpNext; - } -} - -void Window::ImplClipSiblings( Region& rRegion ) -{ - Window* pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild; - while ( pWindow ) - { - if ( pWindow == this ) - break; - - if ( pWindow->mpWindowImpl->mbReallyVisible ) - pWindow->ImplExcludeWindowRegion( rRegion ); - - pWindow = pWindow->mpWindowImpl->mpNext; - } -} - -void Window::ImplInitWinClipRegion() -{ - // Build Window Region - mpWindowImpl->maWinClipRegion = Rectangle( Point( mnOutOffX, mnOutOffY ), - Size( mnOutWidth, mnOutHeight ) ); - if ( mpWindowImpl->mbWinRegion ) - mpWindowImpl->maWinClipRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); - - // ClipSiblings - if ( mpWindowImpl->mbClipSiblings && !ImplIsOverlapWindow() ) - ImplClipSiblings( mpWindowImpl->maWinClipRegion ); - - // Clip Parent Boundaries - ImplClipBoundaries( mpWindowImpl->maWinClipRegion, false, true ); - - // Clip Children - if ( (GetStyle() & WB_CLIPCHILDREN) || mpWindowImpl->mbClipChildren ) - mpWindowImpl->mbInitChildRegion = true; - - mpWindowImpl->mbInitWinClipRegion = false; -} - -void Window::ImplInitWinChildClipRegion() -{ - if ( !mpWindowImpl->mpFirstChild ) - { - if ( mpWindowImpl->mpChildClipRegion ) - { - delete mpWindowImpl->mpChildClipRegion; - mpWindowImpl->mpChildClipRegion = NULL; - } - } - else - { - if ( !mpWindowImpl->mpChildClipRegion ) - mpWindowImpl->mpChildClipRegion = new Region( mpWindowImpl->maWinClipRegion ); - else - *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion; - - ImplClipChildren( *mpWindowImpl->mpChildClipRegion ); - } - - mpWindowImpl->mbInitChildRegion = false; -} - -Region* Window::ImplGetWinChildClipRegion() -{ - if ( mpWindowImpl->mbInitWinClipRegion ) - ImplInitWinClipRegion(); - if ( mpWindowImpl->mbInitChildRegion ) - ImplInitWinChildClipRegion(); - if ( mpWindowImpl->mpChildClipRegion ) - return mpWindowImpl->mpChildClipRegion; - else - return &mpWindowImpl->maWinClipRegion; -} - void Window::ImplIntersectAndUnionOverlapWindows( const Region& rInterRegion, Region& rRegion ) { Window* pWindow = mpWindowImpl->mpFirstOverlap; @@ -4992,31 +4853,6 @@ Font Window::GetPointFont() const return aFont; } -void Window::SetParentClipMode( sal_uInt16 nMode ) -{ - - if ( mpWindowImpl->mpBorderWindow ) - mpWindowImpl->mpBorderWindow->SetParentClipMode( nMode ); - else - { - if ( !ImplIsOverlapWindow() ) - { - mpWindowImpl->mnParentClipMode = nMode; - if ( nMode & PARENTCLIPMODE_CLIP ) - mpWindowImpl->mpParent->mpWindowImpl->mbClipChildren = true; - } - } -} - -sal_uInt16 Window::GetParentClipMode() const -{ - - if ( mpWindowImpl->mpBorderWindow ) - return mpWindowImpl->mpBorderWindow->GetParentClipMode(); - else - return mpWindowImpl->mnParentClipMode; -} - void Window::SetWindowRegionPixel() { @@ -5155,43 +4991,6 @@ bool Window::IsWindowRegionPixel() const return mpWindowImpl->mbWinRegion; } -Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const -{ - - Region aWinClipRegion; - - if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN ) - { - if ( mpWindowImpl->mbInitWinClipRegion ) - ((Window*)this)->ImplInitWinClipRegion(); - aWinClipRegion = mpWindowImpl->maWinClipRegion; - } - else - { - Region* pWinChildClipRegion = ((Window*)this)->ImplGetWinChildClipRegion(); - aWinClipRegion = *pWinChildClipRegion; - // --- RTL --- remirror clip region before passing it to somebody - if( ImplIsAntiparallel() ) - { - const OutputDevice *pOutDev = GetOutDev(); - pOutDev->ReMirror( aWinClipRegion ); - } - } - - if ( nFlags & WINDOW_GETCLIPREGION_NULL ) - { - Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); - Region aWinRegion( aWinRect ); - - if ( aWinRegion == aWinClipRegion ) - aWinClipRegion.SetNull(); - } - - aWinClipRegion.Move( -mnOutOffX, -mnOutOffY ); - - return aWinClipRegion; -} - Region Window::GetPaintRegion() const { @@ -5208,30 +5007,6 @@ Region Window::GetPaintRegion() const } } -void Window::ExpandPaintClipRegion( const Region& rRegion ) -{ - if( mpWindowImpl->mpPaintRegion ) - { - Region aPixRegion = LogicToPixel( rRegion ); - Region aDevPixRegion = ImplPixelToDevicePixel( aPixRegion ); - - Region aWinChildRegion = *ImplGetWinChildClipRegion(); - // --- RTL -- only this region is in frame coordinates, so re-mirror it - if( ImplIsAntiparallel() ) - { - const OutputDevice *pOutDev = GetOutDev(); - pOutDev->ReMirror( aWinChildRegion ); - } - - aDevPixRegion.Intersect( aWinChildRegion ); - if( ! aDevPixRegion.IsEmpty() ) - { - mpWindowImpl->mpPaintRegion->Union( aDevPixRegion ); - mbInitClipRegion = true; - } - } -} - static SystemWindow *ImplGetLastSystemWindow( Window *pWin ) { // get the most top-level system window, the one that contains the taskpanelist |