diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-10 14:59:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-11 16:34:44 +0100 |
commit | 4bb482cc2e65a10fd4f38cddfab405169cf192e4 (patch) | |
tree | cb4859d2ece07f9163f7b79f39fdb3f613c9eee0 /vcl | |
parent | cac7541e1b2a1bbd0fca08853fd8323bb0078247 (diff) |
weld SvBaseLinksDlg
Change-Id: I40afcb99ae0e8fd27387077aea688906f037d6f4
Reviewed-on: https://gerrit.libreoffice.org/67676
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 73 | ||||
-rw-r--r-- | vcl/source/treelist/svtabbx.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 90 |
3 files changed, 150 insertions, 15 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 4f54a0e18e86..230875e737f9 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -40,6 +40,7 @@ #include <vcl/lstbox.hxx> #include <vcl/dialog.hxx> #include <vcl/fixed.hxx> +#include <vcl/fixedhyper.hxx> #include <vcl/fmtfield.hxx> #include <vcl/headbar.hxx> #include <vcl/layout.hxx> @@ -358,6 +359,11 @@ public: return Size(m_xWidget->GetTextWidth(rText), m_xWidget->GetTextHeight()); } + virtual vcl::Font get_font() override + { + return m_xWidget->GetPointFont(*m_xWidget); + } + virtual OString get_buildable_name() const override { return m_xWidget->get_id().toUtf8(); @@ -1491,6 +1497,51 @@ IMPL_LINK_NOARG(SalInstanceMenuButton, ActivateHdl, ::MenuButton*, void) signal_toggled(); } +class SalInstanceLinkButton : public SalInstanceContainer, public virtual weld::LinkButton +{ +private: + VclPtr<FixedHyperlink> m_xButton; + + DECL_LINK(ClickHdl, FixedHyperlink&, void); +public: + SalInstanceLinkButton(FixedHyperlink* pButton, bool bTakeOwnership) + : SalInstanceContainer(pButton, bTakeOwnership) + , m_xButton(pButton) + { + m_xButton->SetClickHdl(LINK(this, SalInstanceLinkButton, ClickHdl)); + } + + virtual void set_label(const OUString& rText) override + { + m_xButton->SetText(rText); + } + + virtual OUString get_label() const override + { + return m_xButton->GetText(); + } + + virtual void set_uri(const OUString& rUri) override + { + m_xButton->SetURL(rUri); + } + + virtual OUString get_uri() const override + { + return m_xButton->GetURL(); + } + + virtual ~SalInstanceLinkButton() override + { + m_xButton->SetClickHdl(Link<FixedHyperlink&,void>()); + } +}; + +IMPL_LINK_NOARG(SalInstanceLinkButton, ClickHdl, FixedHyperlink&, void) +{ + signal_clicked(); +} + class SalInstanceRadioButton : public SalInstanceButton, public virtual weld::RadioButton { private: @@ -1868,14 +1919,9 @@ public: } } - virtual vcl::Font get_font() override - { - return m_xEntry->GetFont(); - } - virtual void set_font(const vcl::Font& rFont) override { - m_xEntry->SetFont(rFont); + m_xEntry->SetPointFont(*m_xEntry, rFont); m_xEntry->Invalidate(); } @@ -1990,6 +2036,15 @@ public: m_xTreeView->Resize(); } + virtual int get_column_width(int nColumn) const override + { + // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox. + // So the first text column's width is Tab(2)-Tab(1). + auto nWidthPixel = m_xTreeView->GetLogicTab(nColumn + 2) - m_xTreeView->GetLogicTab(nColumn + 1); + nWidthPixel -= SV_TAB_BORDER; + return nWidthPixel; + } + virtual OUString get_column_title(int nColumn) const override { SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()); @@ -3688,6 +3743,12 @@ public: return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, bTakeOwnership) : nullptr; } + virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OString &id, bool bTakeOwnership) override + { + FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id); + return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, bTakeOwnership) : nullptr; + } + virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString &id, bool bTakeOwnership) override { PushButton* pToggleButton = m_xBuilder->get<PushButton>(id); diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx index 5b026ffbf195..e89ac8ad723a 100644 --- a/vcl/source/treelist/svtabbx.cxx +++ b/vcl/source/treelist/svtabbx.cxx @@ -98,8 +98,6 @@ SvTabListBox::SvTabListBox( vcl::Window* pParent, WinBits nBits ) SetHighlightRange(); // select full width } -VCL_BUILDER_FACTORY_CONSTRUCTOR(SvTabListBox, WB_TABSTOP) - SvTabListBox::~SvTabListBox() { disposeOnce(); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 76132642c21a..35fe3d03a0f7 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1402,6 +1402,13 @@ public: return Size(nWidth, nHeight); } + virtual vcl::Font get_font() override + { + PangoContext* pContext = gtk_widget_get_pango_context(m_pWidget); + return pango_to_vcl(pango_context_get_font_description(pContext), + Application::GetSettings().GetUILanguageTag().getLocale()); + } + virtual void set_grid_left_attach(int nAttach) override { GtkContainer* pParent = GTK_CONTAINER(gtk_widget_get_parent(m_pWidget)); @@ -4411,6 +4418,66 @@ public: } }; +class GtkInstanceLinkButton : public GtkInstanceContainer, public virtual weld::LinkButton +{ +private: + GtkLinkButton* m_pButton; + gulong m_nSignalId; + + static void signalClicked(GtkButton*, gpointer widget) + { + GtkInstanceLinkButton* pThis = static_cast<GtkInstanceLinkButton*>(widget); + SolarMutexGuard aGuard; + pThis->signal_clicked(); + } + +public: + GtkInstanceLinkButton(GtkLinkButton* pButton, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pButton), bTakeOwnership) + , m_pButton(pButton) + , m_nSignalId(g_signal_connect(pButton, "clicked", G_CALLBACK(signalClicked), this)) + { + } + + virtual void set_label(const OUString& rText) override + { + ::set_label(GTK_BUTTON(m_pButton), rText); + } + + virtual OUString get_label() const override + { + return ::get_label(GTK_BUTTON(m_pButton)); + } + + virtual void set_uri(const OUString& rText) override + { + gtk_link_button_set_uri(m_pButton, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr()); + } + + virtual OUString get_uri() const override + { + const gchar* pStr = gtk_link_button_get_uri(m_pButton); + return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + } + + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pButton, m_nSignalId); + GtkInstanceContainer::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceContainer::enable_notify_events(); + g_signal_handler_unblock(m_pButton, m_nSignalId); + } + + virtual ~GtkInstanceLinkButton() override + { + g_signal_handler_disconnect(m_pButton, m_nSignalId); + } +}; + class GtkInstanceRadioButton : public GtkInstanceToggleButton, public virtual weld::RadioButton { public: @@ -4698,13 +4765,6 @@ public: g_signal_handler_unblock(m_pEntry, m_nActivateSignalId); } - virtual vcl::Font get_font() override - { - PangoContext* pContext = gtk_widget_get_pango_context(m_pWidget); - return pango_to_vcl(pango_context_get_font_description(pContext), - Application::GetSettings().GetUILanguageTag().getLocale()); - } - virtual void set_font(const vcl::Font& rFont) override { PangoAttrList* pAttrList = pango_attr_list_new(); @@ -5256,6 +5316,13 @@ public: } } + virtual int get_column_width(int nColumn) const override + { + GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, nColumn)); + assert(pColumn && "wrong count"); + return gtk_tree_view_column_get_fixed_width(pColumn) - gtk_tree_view_column_get_spacing(pColumn); + } + virtual OUString get_column_title(int nColumn) const override { GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, nColumn)); @@ -8072,6 +8139,15 @@ public: return std::make_unique<GtkInstanceMenuButton>(pButton, bTakeOwnership); } + virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OString &id, bool bTakeOwnership) override + { + GtkLinkButton* pButton = GTK_LINK_BUTTON(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pButton) + return nullptr; + auto_add_parentless_widgets_to_container(GTK_WIDGET(pButton)); + return std::make_unique<GtkInstanceLinkButton>(pButton, bTakeOwnership); + } + virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString &id, bool bTakeOwnership) override { GtkToggleButton* pToggleButton = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_pBuilder, id.getStr())); |