From 2966d57bdfdd40a55e31408f7da75b415e809d8e Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Wed, 17 Feb 2016 21:42:37 +0000 Subject: tdf#95618 - opengl - mend control regions and caching for tab headers. Some tab headers in some themes unhelpfully enlarge the control region in some states - so query the region size in advance. Sadly the control region querying is something of a train-wreck too - so only use that for CTRL_TAB_ITEMs for now. Also fix Rectangle constructor ordering. Change-Id: I5e66ec541193f5b66a656dd45d5fba67a771e132 --- vcl/win/gdi/salnativewidgets-luna.cxx | 36 ++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'vcl/win/gdi') diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx index 1fa4d589f233..f789f17e1972 100644 --- a/vcl/win/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/gdi/salnativewidgets-luna.cxx @@ -1162,20 +1162,35 @@ bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, * aCaption: A caption or title string (like button text etc) */ bool WinSalGraphics::drawNativeControl( ControlType nType, - ControlPart nPart, - const Rectangle& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - const OUString& aCaption ) + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const OUString& aCaption ) { bool bOk = false; HTHEME hTheme = NULL; Rectangle buttonRect = rControlRegion; + Rectangle cacheRect = rControlRegion; + Size keySize = cacheRect.GetSize(); WinOpenGLSalGraphicsImpl* pImpl = dynamic_cast(mpImpl.get()); - ControlCacheKey aControlCacheKey(nType, nPart, nState, buttonRect.GetSize()); + // tdf#95618 - A few controls render outside the region they're given. + if (pImpl && nType == CTRL_TAB_ITEM) + { + Rectangle rNativeBoundingRegion; + Rectangle rNativeContentRegion; + if (getNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, aCaption, + rNativeBoundingRegion, rNativeContentRegion)) + { + cacheRect = rNativeBoundingRegion; + keySize = rNativeBoundingRegion.GetSize(); + } + } + + ControlCacheKey aControlCacheKey(nType, nPart, nState, keySize); if (pImpl != NULL && pImpl->TryRenderCachedNativeControl(aControlCacheKey, buttonRect.Left(), buttonRect.Top())) { return true; @@ -1288,18 +1303,18 @@ bool WinSalGraphics::drawNativeControl( ControlType nType, else { // We can do OpenGL - OpenGLCompatibleDC aBlackDC(*this, buttonRect.Left(), buttonRect.Top(), buttonRect.GetWidth(), buttonRect.GetHeight()); + OpenGLCompatibleDC aBlackDC(*this, cacheRect.Left(), cacheRect.Top(), cacheRect.GetWidth()+1, cacheRect.GetHeight()+1); SetTextAlign(aBlackDC.getCompatibleHDC(), TA_LEFT|TA_TOP|TA_NOUPDATECP); aBlackDC.fill(MAKE_SALCOLOR(0, 0, 0)); - OpenGLCompatibleDC aWhiteDC(*this, buttonRect.Left(), buttonRect.Top(), buttonRect.GetWidth(), buttonRect.GetHeight()); + OpenGLCompatibleDC aWhiteDC(*this, cacheRect.Left(), cacheRect.Top(), cacheRect.GetWidth()+1, cacheRect.GetHeight()+1); SetTextAlign(aWhiteDC.getCompatibleHDC(), TA_LEFT|TA_TOP|TA_NOUPDATECP); aWhiteDC.fill(MAKE_SALCOLOR(0xff, 0xff, 0xff)); if (ImplDrawNativeControl(aBlackDC.getCompatibleHDC(), hTheme, rc, nType, nPart, nState, aValue, aCaptionStr) && ImplDrawNativeControl(aWhiteDC.getCompatibleHDC(), hTheme, rc, nType, nPart, nState, aValue, aCaptionStr)) { - bOk = pImpl->RenderAndCacheNativeControl(aWhiteDC, aBlackDC, buttonRect.Left(), buttonRect.Top(), aControlCacheKey); + bOk = pImpl->RenderAndCacheNativeControl(aWhiteDC, aBlackDC, cacheRect.Left(), cacheRect.Top(), aControlCacheKey); } } @@ -1330,6 +1345,9 @@ bool WinSalGraphics::getNativeControlRegion( ControlType nType, { bool bRet = FALSE; + // FIXME: rNativeBoundingRegion has a different origin + // depending on which part is used; horrors. + HDC hDC = GetDC( mhWnd ); if( nType == CTRL_TOOLBAR ) { -- cgit