diff options
-rw-r--r-- | include/vcl/treelistbox.hxx | 2 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 8 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 19 | ||||
-rw-r--r-- | vcl/source/treelist/treelistbox.cxx | 9 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 22 |
5 files changed, 58 insertions, 2 deletions
diff --git a/include/vcl/treelistbox.hxx b/include/vcl/treelistbox.hxx index cb4945a96717..ba088cee8c6f 100644 --- a/include/vcl/treelistbox.hxx +++ b/include/vcl/treelistbox.hxx @@ -200,6 +200,7 @@ class VCL_DLLPUBLIC SvTreeListBox Link<SvTreeListBox*,void> aSelectHdl; Link<SvTreeListBox*,void> aDeselectHdl; Link<const CommandEvent&, bool> aPopupMenuHdl; + Link<const HelpEvent&, void> aTooltipHdl; Image aPrevInsertedExpBmp; Image aPrevInsertedColBmp; @@ -433,6 +434,7 @@ public: void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;} void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;} void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; } + void SetTooltipHdl(const Link<const HelpEvent&, void>& rLink) { aTooltipHdl = rLink; } virtual void ExpandedHdl(); virtual bool ExpandingHdl(); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index e68d46c420d6..54a72e80c32d 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -730,7 +730,15 @@ protected: return m_aEditingDoneHdl.Call(rIterText); } + Link<const TreeIter&, OUString> m_aQueryTooltipHdl; + OUString signal_query_tooltip(const TreeIter& rIter) { return m_aQueryTooltipHdl.Call(rIter); } + public: + void connect_query_tooltip(const Link<const TreeIter&, OUString>& rLink) + { + m_aQueryTooltipHdl = rLink; + } + virtual void insert(const TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface, const OUString* pExpanderName, bool bChildrenOnDemand, TreeIter* pRet) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 844281cb806e..e26a6a3713fe 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3469,6 +3469,7 @@ private: DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void); DECL_LINK(CompareHdl, const SvSortData&, sal_Int32); DECL_LINK(PopupMenuHdl, const CommandEvent&, bool); + DECL_LINK(TooltipHdl, const HelpEvent&, void); bool IsDummyEntry(SvTreeListEntry* pEntry) const { @@ -3490,6 +3491,7 @@ public: m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl)); m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, ExpandingHdl)); m_xTreeView->SetPopupMenuHdl(LINK(this, SalInstanceTreeView, PopupMenuHdl)); + m_xTreeView->SetTooltipHdl(LINK(this, SalInstanceTreeView, TooltipHdl)); const long aTabPositions[] = { 0 }; m_xTreeView->SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions); LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); @@ -4625,9 +4627,26 @@ public: m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>()); m_xTreeView->SetDeselectHdl(Link<SvTreeListBox*, void>()); m_xTreeView->SetScrolledHdl(Link<SvTreeListBox*, void>()); + m_xTreeView->SetTooltipHdl(Link<const HelpEvent&, void>()); } }; +IMPL_LINK(SalInstanceTreeView, TooltipHdl, const HelpEvent&, rHEvt, void) +{ + if (notify_events_disabled()) + return; + Point aPos(m_xTreeView->ScreenToOutputPixel(rHEvt.GetMousePosPixel())); + SvTreeListEntry* pEntry = m_xTreeView->GetEntry(aPos); + if (pEntry) + { + SalInstanceTreeIter aIter(pEntry); + OUString aTooltip = signal_query_tooltip(aIter); + Size aSize(m_xTreeView->GetOutputSizePixel().Width(), m_xTreeView->GetEntryHeight()); + tools::Rectangle aScreenRect(m_xTreeView->OutputToScreenPixel(m_xTreeView->GetEntryPosition(pEntry)), aSize); + Help::ShowQuickHelp(m_xTreeView, aScreenRect, aTooltip); + } +} + IMPL_LINK(SalInstanceTreeView, CompareHdl, const SvSortData&, rSortData, sal_Int32) { const SvTreeListEntry* pLHS = rSortData.pLeft; diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index fc73a389bfb2..a192fa7ddb03 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -3322,8 +3322,13 @@ void SvTreeListBox::GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ) void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt ) { - if( !pImpl->RequestHelp( rHEvt ) ) - Control::RequestHelp( rHEvt ); + if (aTooltipHdl.IsSet()) + aTooltipHdl.Call(rHEvt); + else + { + if( !pImpl->RequestHelp( rHEvt ) ) + Control::RequestHelp( rHEvt ); + } } sal_Int32 SvTreeListBox::DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText) diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 5c7b8ae9ac5c..504355c09189 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8037,6 +8037,7 @@ private: gulong m_nDragDataDeleteignalId; gulong m_nDragGetSignalId; gulong m_nKeyPressSignalId; + gulong m_nQueryTooltipSignalId; ImplSVEvent* m_pChangeEvent; DECL_LINK(async_signal_changed, void*, void); @@ -8521,6 +8522,24 @@ private: return pThis->signal_key_press(pEvent); } + static gboolean signalQueryTooltip(GtkWidget* /*pGtkWidget*/, gint x, gint y, + gboolean keyboard_tip, GtkTooltip *tooltip, + gpointer widget) + { + GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget); + GtkTreeIter iter; + GtkTreeView *pTreeView = pThis->m_pTreeView; + GtkTreeModel *pModel = gtk_tree_view_get_model(pTreeView); + GtkTreePath *pPath = nullptr; + if (!gtk_tree_view_get_tooltip_context(pTreeView, &x, &y, keyboard_tip, &pModel, &pPath, &iter)) + return false; + OUString aTooltip = pThis->signal_query_tooltip(GtkInstanceTreeIter(iter)); + gtk_tooltip_set_text(tooltip, OUStringToOString(aTooltip, RTL_TEXTENCODING_UTF8).getStr()); + gtk_tree_view_set_tooltip_row(pTreeView, tooltip, pPath); + gtk_tree_path_free(pPath); + return true; + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) @@ -8543,6 +8562,7 @@ public: , m_nDragDataDeleteignalId(0) , m_nDragGetSignalId(0) , m_nKeyPressSignalId(g_signal_connect(pTreeView, "key-press-event", G_CALLBACK(signalKeyPress), this)) + , m_nQueryTooltipSignalId(g_signal_connect(pTreeView, "query-tooltip", G_CALLBACK(signalQueryTooltip), this)) , m_pChangeEvent(nullptr) { m_pColumns = gtk_tree_view_get_columns(m_pTreeView); @@ -10007,6 +10027,8 @@ public: m_aColumnSignalIds.pop_back(); } g_list_free(m_pColumns); + + g_signal_handler_disconnect(m_pTreeView, m_nQueryTooltipSignalId); } }; |