From 9efab24f38bb5e4b150c842cda51cfd76d694022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 15 Apr 2022 14:44:54 +0100 Subject: [PATCH] use the same colors for warning/error for gen ComboBox as Entry does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0fb24c0d60c66348052334c9a86e6a5425dccb46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133070 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/source/app/salvtables.cxx | 43 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index fad841f45787..263c29ff5eea 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3316,31 +3316,39 @@ void SalInstanceEntry::set_overwrite_mode(bool bOn) { m_xEntry->SetInsertMode(!b bool SalInstanceEntry::get_overwrite_mode() const { return !m_xEntry->IsInsertMode(); } -void SalInstanceEntry::set_message_type(weld::EntryMessageType eType) +namespace +{ +void set_message_type(Edit* pEntry, weld::EntryMessageType eType) { switch (eType) { case weld::EntryMessageType::Normal: - m_xEntry->SetForceControlBackground(false); - m_xEntry->SetControlForeground(); - m_xEntry->SetControlBackground(); + pEntry->SetForceControlBackground(false); + pEntry->SetControlForeground(); + pEntry->SetControlBackground(); break; case weld::EntryMessageType::Warning: // tdf#114603: enable setting the background to a different color; // relevant for GTK; see also #i75179# - m_xEntry->SetForceControlBackground(true); - m_xEntry->SetControlForeground(COL_BLACK); - m_xEntry->SetControlBackground(COL_YELLOW); + pEntry->SetForceControlBackground(true); + pEntry->SetControlForeground(COL_BLACK); + pEntry->SetControlBackground(COL_YELLOW); break; case weld::EntryMessageType::Error: // tdf#114603: enable setting the background to a different color; // relevant for GTK; see also #i75179# - m_xEntry->SetForceControlBackground(true); - m_xEntry->SetControlForeground(COL_WHITE); - m_xEntry->SetControlBackground(0xff6563); + pEntry->SetForceControlBackground(true); + pEntry->SetControlForeground(COL_WHITE); + pEntry->SetControlBackground(0xff6563); break; } } +} + +void SalInstanceEntry::set_message_type(weld::EntryMessageType eType) +{ + ::set_message_type(m_xEntry, eType); +} void SalInstanceEntry::set_font(const vcl::Font& rFont) { @@ -6355,18 +6363,9 @@ bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const void SalInstanceComboBoxWithEdit::set_entry_message_type(weld::EntryMessageType eType) { - switch (eType) - { - case weld::EntryMessageType::Normal: - m_xComboBox->SetControlForeground(); - break; - case weld::EntryMessageType::Warning: - m_xComboBox->SetControlForeground(COL_YELLOW); - break; - case weld::EntryMessageType::Error: - m_xComboBox->SetControlForeground(Color(0xf0, 0, 0)); - break; - } + Edit* pEdit = m_xComboBox->GetSubEdit(); + assert(pEdit); + ::set_message_type(pEdit, eType); } OUString SalInstanceComboBoxWithEdit::get_active_text() const { return m_xComboBox->GetText(); }