diff options
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/salnativewidgets-luna.cxx | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx index 0dd5b2dd7442..c5a368c8c52c 100644 --- a/vcl/win/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/gdi/salnativewidgets-luna.cxx @@ -190,6 +190,7 @@ bool WinSalGraphics::isNativeControlSupported( ControlType nType, ControlPart nP } break; case ControlType::Progress: + case ControlType::LevelBar: if( nPart == ControlPart::Entire ) hTheme = getThemeHandle(mhWnd, L"Progress", mWinSalGraphicsImplBase); break; @@ -1003,12 +1004,19 @@ static bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, } } - if( nType == ControlType::Progress ) + if( nType == ControlType::Progress || nType == ControlType::LevelBar ) { if( nPart != ControlPart::Entire ) return false; - if( ! ImplDrawTheme( hTheme, hDC, PP_BAR, iState, rc, aCaption) ) + int nPartIdBackground = PP_BAR; + if( nType == ControlType::LevelBar ) + { + nPartIdBackground = PP_TRANSPARENTBAR; + iState = PBBS_PARTIAL; + } + + if( ! ImplDrawTheme( hTheme, hDC, nPartIdBackground, iState, rc, aCaption) ) return false; RECT aProgressRect = rc; if( GetThemeBackgroundContentRect( hTheme, hDC, PP_BAR, iState, &rc, &aProgressRect) != S_OK ) @@ -1022,6 +1030,26 @@ static bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, else aProgressRect.right = aProgressRect.left + nProgressWidth; + if (nType == ControlType::LevelBar) + { + const auto nPercentage + = aValue.getNumericVal() * 100 / std::max(LONG{ 1 }, (rc.right - rc.left)); + + COLORREF aBrushColor{}; + if (nPercentage < 25) + aBrushColor = RGB(255, 0, 0); + else if (nPercentage < 50) + aBrushColor = RGB(255, 255, 0); + else if (nPercentage < 75) + aBrushColor = RGB(0, 0, 255); + else + aBrushColor = RGB(0, 255, 0); + + ScopedHBRUSH hBrush(CreateSolidBrush(aBrushColor)); + FillRect(hDC, &aProgressRect, hBrush.get()); + return true; + } + return ImplDrawTheme( hTheme, hDC, PP_CHUNK, iState, aProgressRect, aCaption ); } @@ -1272,6 +1300,7 @@ bool WinSalGraphics::drawNativeControl( ControlType nType, } break; case ControlType::Progress: + case ControlType::LevelBar: if( nPart == ControlPart::Entire ) hTheme = getThemeHandle(mhWnd, L"Progress", mWinSalGraphicsImplBase); break; |