From 3f94cf15f9bbb58bb1f4e5ca4cfa10e354c659e3 Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Sun, 9 Oct 2016 16:35:57 +0000 Subject: Fix focus and rollover for vcl::ListBox Change-Id: I4fffd086a38b54c673a199ea0603d25ca54aacd1 --- vcl/source/control/imp_listbox.cxx | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index a09bdb98c9e8..2dd277a91ad3 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -2618,6 +2618,8 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) if (!bLayout) { bool bNativeOK = false; + bool bHasFocus = HasFocus(); + bool bIsEnabled = IsEnabled(); ControlState nState = ControlState::ENABLED; if (rRenderContext.IsNativeControlSupported(ControlType::Listbox, ControlPart::Entire) @@ -2629,9 +2631,11 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) vcl::Window *pWin = GetParent(); ImplControlValue aControlValue; - if ( !pWin->IsEnabled() ) + bIsEnabled &= pWin->IsEnabled(); + if ( !bIsEnabled ) nState &= ~ControlState::ENABLED; - if ( pWin->HasFocus() ) + bHasFocus |= pWin->HasFocus(); + if ( bHasFocus ) nState |= ControlState::FOCUSED; // The listbox is painted over the entire control including the @@ -2667,12 +2671,23 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) nState, aControlValue, OUString()); } - if (IsEnabled()) + if (bIsEnabled) { - if (HasFocus() && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea) + if (bHasFocus && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea) { - rRenderContext.SetTextColor( rStyleSettings.GetHighlightTextColor() ); - rRenderContext.SetFillColor( rStyleSettings.GetHighlightColor() ); + if ( !ImplGetSVData()->maNWFData.mbNoFocusRects ) + rRenderContext.SetFillColor( rStyleSettings.GetHighlightColor() ); + else + { + rRenderContext.SetLineColor(); + rRenderContext.SetFillColor(); + } + Color aColor; + if( bNativeOK && (nState & ControlState::ROLLOVER) ) + aColor = rStyleSettings.GetFieldRolloverTextColor(); + else + aColor = rStyleSettings.GetHighlightTextColor(); + rRenderContext.SetTextColor( aColor ); rRenderContext.DrawRect( maFocusRect ); } else -- cgit v1.2.3