[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 2 18:22:36 UTC 2020
include/vcl/weld.hxx | 10 ++++++++++
vcl/inc/salvtables.hxx | 2 ++
vcl/source/app/salvtables.cxx | 8 ++++++++
vcl/unx/gtk3/gtk3gtkinst.cxx | 20 ++++++++++++++++++++
4 files changed, 40 insertions(+)
New commits:
commit 4582ac7de8291a81c867492aad770206fbaca224
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Jul 2 15:54:18 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jul 2 20:21:46 2020 +0200
add ability to set Entry font color
reluctantly, but the SvNumberformat color feature exists and it's expected to
be possible to use that color in the currency fields
Change-Id: I31834e5667fcad42021532957dee4f79621f58a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97774
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index db13a45a7731..8f2008598b80 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1496,6 +1496,16 @@ public:
// font size is in points, not pixels, e.g. see Window::[G]etPointFont
virtual void set_font(const vcl::Font& rFont) = 0;
+ /*
+ If you want to set a warning or error state, see set_message_type
+ instead where, if the toolkit supports it, a specific warning/error
+ indicator is shown.
+
+ This explicit text color method exists to support rendering the
+ SvNumberformat color feature.
+ */
+ virtual void set_font_color(const Color& rColor) = 0;
+
void connect_changed(const Link<Entry&, void>& rLink) { m_aChangeHdl = rLink; }
void connect_insert_text(const Link<OUString&, bool>& rLink) { m_aInsertTextHdl = rLink; }
// callback returns true to indicated no further processing of activate wanted
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index fb60a583e538..d76729b876c4 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -592,6 +592,8 @@ public:
virtual void set_font(const vcl::Font& rFont) override;
+ virtual void set_font_color(const Color& rColor) override;
+
virtual void connect_cursor_position(const Link<Entry&, void>& rLink) override;
virtual void set_placeholder_text(const OUString& rText) override;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 67f26faf9e59..656e82a43ea1 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3138,6 +3138,14 @@ void SalInstanceEntry::set_font(const vcl::Font& rFont)
m_xEntry->Invalidate();
}
+void SalInstanceEntry::set_font_color(const Color& rColor)
+{
+ if (rColor == COL_AUTO)
+ m_xEntry->SetControlForeground();
+ else
+ m_xEntry->SetControlForeground(rColor);
+}
+
void SalInstanceEntry::connect_cursor_position(const Link<Entry&, void>& rLink)
{
assert(!m_aCursorPositionHdl.IsSet());
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 1aa1af96882a..0959bb53421e 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8638,6 +8638,11 @@ namespace
gtk_entry_set_icon_from_icon_name(pEntry, GTK_ENTRY_ICON_SECONDARY, nullptr);
}
+ gboolean filter_pango_attrs(PangoAttribute *attr, gpointer /*data*/)
+ {
+ return attr->klass->type == PANGO_ATTR_FOREGROUND;
+ }
+
class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry
{
private:
@@ -8835,6 +8840,21 @@ public:
return GtkInstanceWidget::get_font();
}
+ void set_font_color(const Color& rColor) override
+ {
+ PangoAttrList* pOrigList = gtk_entry_get_attributes(m_pEntry);
+ if (rColor == COL_AUTO && !pOrigList) // nothing to do
+ return;
+
+ PangoAttrList* pAttrList = pOrigList ? pango_attr_list_filter(pOrigList, filter_pango_attrs, nullptr) : pango_attr_list_new();
+
+ if (rColor != COL_AUTO)
+ pango_attr_list_insert(pAttrList, pango_attr_foreground_new(rColor.GetRed()/255.0, rColor.GetGreen()/255.0, rColor.GetBlue()/255.0));
+
+ gtk_entry_set_attributes(m_pEntry, pAttrList);
+ pango_attr_list_unref(pAttrList);
+ }
+
void fire_signal_changed()
{
signal_changed();
More information about the Libreoffice-commits
mailing list