diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-19 12:11:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-19 16:28:48 +0200 |
commit | 55053394c1253cb55109af354e417288486bf81e (patch) | |
tree | c701a3c37b8a815bad5cf4b3be2da755a6548798 | |
parent | 62ae240e9e9405b04488ade5ef113b42a3d583fa (diff) |
use switch statement
Change-Id: I64a61a2d08196b86e0dcb789c06a2b90f62a8097
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100992
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/app/salvtables.cxx | 78 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 36 |
2 files changed, 69 insertions, 45 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 906cd00cffe3..9e6fb8e54904 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3153,27 +3153,27 @@ bool SalInstanceEntry::get_overwrite_mode() const void SalInstanceEntry::set_message_type(weld::EntryMessageType eType) { - if (eType == 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); - } - else if (eType == 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(); - m_xEntry->SetControlBackground(COL_YELLOW); - } - else + switch (eType) { - m_xEntry->SetForceControlBackground(false); - m_xEntry->SetControlForeground(); - m_xEntry->SetControlBackground(); + case weld::EntryMessageType::Normal: + m_xEntry->SetForceControlBackground(false); + m_xEntry->SetControlForeground(); + m_xEntry->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(); + m_xEntry->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); + break; } } @@ -5488,13 +5488,19 @@ void SalInstanceLabel::set_mnemonic_widget(Widget* pTarget) void SalInstanceLabel::set_message_type(weld::EntryMessageType eType) { - if (eType == weld::EntryMessageType::Error) - m_xLabel->SetControlBackground( - m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor()); - else if (eType == weld::EntryMessageType::Warning) - m_xLabel->SetControlBackground(COL_YELLOW); - else - m_xLabel->SetControlBackground(); + switch (eType) + { + case weld::EntryMessageType::Normal: + m_xLabel->SetControlBackground(); + break; + case weld::EntryMessageType::Warning: + m_xLabel->SetControlBackground(COL_YELLOW); + break; + case weld::EntryMessageType::Error: + m_xLabel->SetControlBackground( + m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor()); + break; + } } void SalInstanceLabel::set_font(const vcl::Font& rFont) @@ -6050,12 +6056,18 @@ bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const void SalInstanceComboBoxWithEdit::set_entry_message_type(weld::EntryMessageType eType) { - if (eType == weld::EntryMessageType::Error) - m_xComboBox->SetControlForeground(Color(0xf0, 0, 0)); - else if (eType == weld::EntryMessageType::Warning) - m_xComboBox->SetControlForeground(COL_YELLOW); - else - m_xComboBox->SetControlForeground(); + 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; + } } OUString SalInstanceComboBoxWithEdit::get_active_text() const { return m_xComboBox->GetText(); } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index bfd3c32eca6c..a1f57e0e14dd 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8694,12 +8694,18 @@ namespace { void set_entry_message_type(GtkEntry* pEntry, weld::EntryMessageType eType) { - if (eType == weld::EntryMessageType::Error) - gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-error"); - else if (eType == weld::EntryMessageType::Warning) - gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning"); - else - gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr); + switch (eType) + { + case weld::EntryMessageType::Normal: + gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr); + break; + case weld::EntryMessageType::Warning: + gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning"); + break; + case weld::EntryMessageType::Error: + gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, "dialog-error"); + break; + } } gboolean filter_pango_attrs(PangoAttribute *attr, gpointer /*data*/) @@ -12556,12 +12562,18 @@ public: virtual void set_message_type(weld::EntryMessageType eType) override { - if (eType == weld::EntryMessageType::Error) - set_text_color(Application::GetSettings().GetStyleSettings().GetHighlightColor()); - else if (eType == weld::EntryMessageType::Warning) - set_text_color(COL_YELLOW); - else - gtk_label_set_attributes(m_pLabel, nullptr); + switch (eType) + { + case weld::EntryMessageType::Normal: + gtk_label_set_attributes(m_pLabel, nullptr); + break; + case weld::EntryMessageType::Warning: + set_text_color(COL_YELLOW); + break; + case weld::EntryMessageType::Error: + set_text_color(Application::GetSettings().GetStyleSettings().GetHighlightColor()); + break; + } } virtual void set_font(const vcl::Font& rFont) override |