[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 7 19:31:21 UTC 2020


 include/vcl/weld.hxx          |    3 +++
 vcl/source/app/salvtables.cxx |   17 +++++++++++++++++
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   15 +++++++++++++++
 3 files changed, 35 insertions(+)

New commits:
commit ec8961c08dda313a22acf85638b0db3071e22db7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Apr 7 17:17:45 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Apr 7 21:30:44 2020 +0200

    allow setting combobox font
    
    so it can be made italic for the font name combobox
    
    Change-Id: I35e819b1401d2ebbaa1e9ce8e2ce9e031662c999
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91840
    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 3f3689fccc61..7dbe6643491e 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -677,6 +677,9 @@ public:
     virtual void set_entry_completion(bool bEnable, bool bCaseSensitive = false) = 0;
     virtual void set_entry_placeholder_text(const OUString& rText) = 0;
 
+    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
+    virtual void set_entry_font(const vcl::Font& rFont) = 0;
+
     virtual bool get_popup_shown() const = 0;
 
     void connect_entry_insert_text(const Link<OUString&, bool>& rLink)
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 706a874229e6..febffea547fc 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5946,6 +5946,8 @@ public:
 
     virtual void set_entry_placeholder_text(const OUString&) override { assert(false); }
 
+    virtual void set_entry_font(const vcl::Font&) override { assert(false); }
+
     virtual ~SalInstanceComboBoxWithoutEdit() override
     {
         m_xComboBox->SetSelectHdl(Link<ListBox&, void>());
@@ -6061,6 +6063,14 @@ public:
         return rSelection.Len();
     }
 
+    virtual void set_entry_font(const vcl::Font& rFont) override
+    {
+        Edit* pEdit = m_xComboBox->GetSubEdit();
+        assert(pEdit);
+        pEdit->SetPointFont(*pEdit, rFont);
+        pEdit->Invalidate();
+    }
+
     virtual ~SalInstanceComboBoxWithEdit() override
     {
         m_xComboBox->SetTextFilter(nullptr);
@@ -6132,6 +6142,13 @@ public:
         rEntry.SetAutocompleteHdl(Link<Edit&, void>());
     }
 
+    virtual void set_entry_font(const vcl::Font& rFont) override
+    {
+        Edit& rEntry = m_pEntry->getEntry();
+        rEntry.SetPointFont(rEntry, rFont);
+        rEntry.Invalidate();
+    }
+
     virtual void set_entry_placeholder_text(const OUString& rText) override
     {
         Edit& rEntry = m_pEntry->getEntry();
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 8b644d22d1c5..29d1ad3b0b9f 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -13403,6 +13403,16 @@ public:
         gtk_entry_set_placeholder_text(pEntry, rText.toUtf8().getStr());
     }
 
+    virtual void set_entry_font(const vcl::Font& rFont) override
+    {
+        PangoAttrList* pAttrList = create_attr_list(rFont);
+        GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox));
+        assert(pChild && GTK_IS_ENTRY(pChild));
+        GtkEntry* pEntry = GTK_ENTRY(pChild);
+        gtk_entry_set_attributes(pEntry, pAttrList);
+        pango_attr_list_unref(pAttrList);
+    }
+
     virtual void disable_notify_events() override
     {
         if (GtkEntry* pEntry = get_entry())
@@ -13701,6 +13711,11 @@ public:
         m_xEntry->set_placeholder_text(rText);
     }
 
+    virtual void set_entry_font(const vcl::Font& rFont) override
+    {
+        m_xEntry->set_font(rFont);
+    }
+
     virtual void grab_focus() override { m_xEntry->grab_focus(); }
 
     virtual void connect_focus_in(const Link<Widget&, void>& rLink) override


More information about the Libreoffice-commits mailing list