summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-07-25 15:56:35 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-07-26 11:09:08 +0200
commit1b6c01bdf769582508c852b24ab9d2a04fc0956f (patch)
treea87d5f3a50e64acd28b337cc98ebbdd805d0f6b6 /vcl
parent90e3af16c12f94f487ff7516048a239db1d2ff7d (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>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/salvtables.hxx9
-rw-r--r--vcl/source/app/salvtables.cxx20
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx7
3 files changed, 27 insertions, 9 deletions
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);