vcl/source/control/imp_listbox.cxx | 9 +++++++-- vcl/source/control/listbox.cxx | 14 +++----------- vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 20 +++++++++++++++----- 3 files changed, 25 insertions(+), 18 deletions(-)
New commits: commit 3a2b58b03d07308a902cc42c53be6afb7d8dbbfc Author: Ilhan Yesil <ilhanye...@gmx.de> AuthorDate: Mon Mar 21 13:27:52 2022 +0100 Commit: Ilhan Yesil <ilhanye...@gmx.de> CommitDate: Wed Jan 4 09:10:53 2023 +0000 tdf#148109 Paint background color in listbox The combobox described in 148109 is indeed a listbox. If drop down list is not open and only the selected item is shown without having the focus, the background color will be paint either it's defined as native control or not. Change-Id: I210916fbe07f74aaa5835bf2c88e764b010c6d61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131904 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> (cherry picked from commit ff7e00e12ff80bd708f31a1d886d000907ceb31a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144991 Tested-by: Ilhan Yesil <ilhanye...@gmx.de> Reviewed-by: Ilhan Yesil <ilhanye...@gmx.de> diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index dee65a2c2a80..fdfe0647bbe9 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -2699,18 +2699,23 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) if( bMouseOver ) nState |= ControlState::ROLLOVER; + Color aBackgroundColor = COL_AUTO; + if (IsControlBackground()) + aBackgroundColor = GetControlBackground(); + // if parent has no border, then nobody has drawn the background // since no border window exists. so draw it here. WinBits nParentStyle = pWin->GetStyle(); if( ! (nParentStyle & WB_BORDER) || (nParentStyle & WB_NOBORDER) ) { tools::Rectangle aParentRect( Point( 0, 0 ), pWin->GetSizePixel() ); + pWin->DrawNativeControl( ControlType::Listbox, ControlPart::Entire, aParentRect, - nState, aControlValue, OUString() ); + nState, aControlValue, OUString(), aBackgroundColor); } bNativeOK = rRenderContext.DrawNativeControl(ControlType::Listbox, ControlPart::Entire, aCtrlRegion, - nState, aControlValue, OUString()); + nState, aControlValue, OUString(), aBackgroundColor); } if (bIsEnabled) diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index 2de9f387011a..541727541abe 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -780,17 +780,9 @@ void ListBox::StateChanged( StateChangedType nType ) mpImplLB->SetControlBackground( GetControlBackground() ); if ( mpImplWin ) { - if ( mpImplWin->IsNativeControlSupported(ControlType::Listbox, ControlPart::Entire) ) - { - // Transparent background - mpImplWin->SetBackground(); - mpImplWin->SetControlBackground(); - } - else - { - mpImplWin->SetBackground( mpImplLB->GetMainWindow()->GetControlBackground() ); - mpImplWin->SetControlBackground( mpImplLB->GetMainWindow()->GetControlBackground() ); - } + + mpImplWin->SetBackground( GetControlBackground() ); + mpImplWin->SetControlBackground( GetControlBackground() ); mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() ); mpImplWin->Invalidate(); } diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 8ab9f5cc4617..85c7133d3eaf 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -1332,9 +1332,8 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, else { render_common(mpListboxStyle, cr, aRect, flags); - render_common(mpListboxBoxStyle, cr, aRect, flags); - render_common(mpListboxButtonStyle, cr, aRect, flags); + render_common(mpListboxBoxStyle, cr, aRect, flags); gtk_render_arrow(mpListboxButtonArrowStyle, cr, G_PI, @@ -2631,13 +2630,24 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co case RenderType::Combobox: if (pBgCssProvider) { - gtk_style_context_add_provider(mpComboboxEntryStyle, GTK_STYLE_PROVIDER(pBgCssProvider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + if (nType == ControlType::Combobox) + { + gtk_style_context_add_provider(mpComboboxEntryStyle, GTK_STYLE_PROVIDER(pBgCssProvider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } + else if (nType == ControlType::Listbox) + { + gtk_style_context_add_provider(mpListboxBoxStyle, GTK_STYLE_PROVIDER(pBgCssProvider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } } PaintCombobox(flags, cr, rControlRegion, nType, nPart); if (pBgCssProvider) { - gtk_style_context_remove_provider(mpComboboxEntryStyle, GTK_STYLE_PROVIDER(pBgCssProvider)); + if (nType == ControlType::Combobox) + gtk_style_context_remove_provider(mpComboboxEntryStyle, GTK_STYLE_PROVIDER(pBgCssProvider)); + else if (nType == ControlType::Listbox) + gtk_style_context_remove_provider(mpListboxBoxStyle, GTK_STYLE_PROVIDER(pBgCssProvider)); } break; case RenderType::Icon: