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.weghorn@posteo.de>
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 5312449..75bc1fd 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -2603,6 +2603,10 @@ 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();
@@ -2610,11 +2614,11 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout)
{
tools::Rectangle aParentRect( Point( 0, 0 ), pWin->GetSizePixel() );
pWin->GetOutDev()->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 e463b2f..ce3cbba 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -771,17 +771,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/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index 6fc1be3..f55b45a 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -1005,9 +1005,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,
@@ -1882,13 +1881,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: