diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-07-25 15:56:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-07-26 11:09:08 +0200 |
commit | 1b6c01bdf769582508c852b24ab9d2a04fc0956f (patch) | |
tree | a87d5f3a50e64acd28b337cc98ebbdd805d0f6b6 | |
parent | 90e3af16c12f94f487ff7516048a239db1d2ff7d (diff) |
Related: tdf#156137 allow GtkLinkButton to wrap
Change-Id: I00ca5a9056b64389f1d55aa8ca6a9d5fd8a16372
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154899
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | include/vcl/weld.hxx | 1 | ||||
-rw-r--r-- | svx/uiconfig/ui/accessibilitycheckentry.ui | 22 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx | 10 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 9 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 20 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 7 |
6 files changed, 48 insertions, 21 deletions
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index c03f78d6c0e1..707d93099ef4 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1673,6 +1673,7 @@ protected: public: virtual void set_label(const OUString& rText) = 0; virtual OUString get_label() const = 0; + virtual void set_label_wrap(bool wrap) = 0; virtual void set_uri(const OUString& rUri) = 0; virtual OUString get_uri() const = 0; diff --git a/svx/uiconfig/ui/accessibilitycheckentry.ui b/svx/uiconfig/ui/accessibilitycheckentry.ui index ea4b63c5fe88..3bf122c0b70f 100644 --- a/svx/uiconfig/ui/accessibilitycheckentry.ui +++ b/svx/uiconfig/ui/accessibilitycheckentry.ui @@ -2,13 +2,14 @@ <!-- Generated with glade 3.40.0 --> <interface domain="svx"> <requires lib="gtk+" version="3.20"/> - <object class="GtkBox" id="accessibilityCheckEntryBox"> + <!-- n-columns=3 n-rows=1 --> + <object class="GtkGrid" id="accessibilityCheckEntryBox"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="margin-top">1</property> <property name="margin-bottom">1</property> <property name="hexpand">True</property> - <property name="spacing">6</property> + <property name="column-spacing">6</property> <child> <object class="GtkLabel" id="accessibilityCheckEntryLabel"> <property name="visible">True</property> @@ -25,9 +26,8 @@ </child> </object> <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> </packing> </child> <child> @@ -35,14 +35,13 @@ <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">True</property> - <property name="halign">start</property> <property name="hexpand">True</property> <property name="relief">none</property> + <property name="xalign">0</property> </object> <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left-attach">1</property> + <property name="top-attach">0</property> </packing> </child> <child> @@ -55,9 +54,8 @@ <property name="valign">center</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> + <property name="left-attach">2</property> + <property name="top-attach">0</property> </packing> </child> </object> diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx index 162724a1035c..338b0f1f7cac 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx @@ -43,6 +43,16 @@ AccessibilityCheckEntry::AccessibilityCheckEntry( if (m_pAccessibilityIssue->canGotoIssue()) { m_xGotoButton->set_label(m_pAccessibilityIssue->m_aIssueText); + + // int nPrefWidth(m_xGotoButton->get_preferred_size().Width()); + int nMaxWidth = m_xGotoButton->get_approximate_digit_width() * 10; + // if (nPrefWidth > nMaxWidth) + { + // tdf#156137 allow LinkButton label to wrap + m_xGotoButton->set_label_wrap(true); + m_xGotoButton->set_size_request(nMaxWidth, -1); + } + m_xGotoButton->connect_activate_link( LINK(this, AccessibilityCheckEntry, GotoButtonClicked)); m_xLabel->set_visible(false); diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 4264de0cea6d..e0c61a5c15ef 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1080,9 +1080,6 @@ private: DECL_LINK(ClickHdl, ::Button*, void); -protected: - void set_label_wrap(bool bWrap); - public: SalInstanceButton(::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership); @@ -1242,6 +1239,8 @@ public: virtual OUString get_uri() const override { return m_xButton->GetURL(); } + virtual void set_label_wrap(bool wrap) override; + virtual ~SalInstanceLinkButton() override { m_xButton->SetClickHdl(m_aOrigClickHdl); } }; @@ -1267,7 +1266,7 @@ public: virtual OUString get_label() const override { return SalInstanceButton::get_label(); } - virtual void set_label_wrap(bool wrap) override { SalInstanceButton::set_label_wrap(wrap); } + virtual void set_label_wrap(bool wrap) override; virtual ~SalInstanceCheckButton() override; }; @@ -2013,7 +2012,7 @@ public: virtual OUString get_label() const override { return SalInstanceButton::get_label(); } - virtual void set_label_wrap(bool wrap) override { SalInstanceButton::set_label_wrap(wrap); } + virtual void set_label_wrap(bool wrap) override; virtual ~SalInstanceRadioButton() override; }; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 3ed96cd8ef58..2716a219fb81 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -2890,14 +2890,14 @@ void SalInstanceButton::set_from_icon_name(const OUString& rIconName) m_xButton->SetModeImage(Image(StockImage::Yes, rIconName)); } -void SalInstanceButton::set_label_wrap(bool wrap) +static void set_label_wrap(Control& rWidget, bool wrap) { - WinBits nBits = m_xButton->GetStyle(); + WinBits nBits = rWidget.GetStyle(); nBits &= ~WB_WORDBREAK; if (wrap) nBits |= WB_WORDBREAK; - m_xButton->SetStyle(nBits); - m_xButton->queue_resize(); + rWidget.SetStyle(nBits); + rWidget.queue_resize(); } void SalInstanceButton::set_font(const vcl::Font& rFont) @@ -3109,6 +3109,8 @@ IMPL_LINK(SalInstanceLinkButton, ClickHdl, FixedHyperlink&, rButton, void) m_aOrigClickHdl.Call(rButton); } +void SalInstanceLinkButton::set_label_wrap(bool bWrap) { ::set_label_wrap(*m_xButton, bWrap); } + SalInstanceRadioButton::SalInstanceRadioButton(::RadioButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceButton(pButton, pBuilder, bTakeOwnership) @@ -3153,6 +3155,11 @@ void SalInstanceRadioButton::set_inconsistent(bool /*inconsistent*/) bool SalInstanceRadioButton::get_inconsistent() const { return false; } +void SalInstanceRadioButton::set_label_wrap(bool bWrap) +{ + ::set_label_wrap(*m_xRadioButton, bWrap); +} + SalInstanceRadioButton::~SalInstanceRadioButton() { m_xRadioButton->SetToggleHdl(Link<::RadioButton&, void>()); @@ -3204,6 +3211,11 @@ bool SalInstanceCheckButton::get_inconsistent() const return m_xCheckButton->GetState() == TRISTATE_INDET; } +void SalInstanceCheckButton::set_label_wrap(bool bWrap) +{ + ::set_label_wrap(*m_xCheckButton, bWrap); +} + SalInstanceCheckButton::~SalInstanceCheckButton() { m_xCheckButton->SetToggleHdl(Link<CheckBox&, void>()); diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 19aebdcc18fe..a864141de1d1 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -12583,6 +12583,13 @@ public: gtk_link_button_set_uri(m_pButton, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr()); } + virtual void set_label_wrap(bool bWrap) override + { + GtkLabel* pChild = ::get_label_widget(GTK_WIDGET(m_pButton)); + ::set_label_wrap(pChild, bWrap); + gtk_label_set_max_width_chars(pChild, 1); + } + virtual OUString get_uri() const override { const gchar* pStr = gtk_link_button_get_uri(m_pButton); |