From 94a2595f5b53cca321c28447c8857308a965d165 Mon Sep 17 00:00:00 2001 From: Umberto Carletti Date: Mon, 22 Oct 2018 10:13:34 +0200 Subject: [PATCH] Add GTK implementation of wxDataViewCtrl::GetItemRect() This function returns a wxRect of the given wxDataViewItem. If no column is provided, the width will be the sum of all the visible columns widths. See https://github.com/wxWidgets/wxWidgets/pull/990 --- src/gtk/dataview.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 8e1a6503a3..c5662aa26e 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -5289,10 +5289,36 @@ void wxDataViewCtrl::HitTest(const wxPoint& point, } wxRect -wxDataViewCtrl::GetItemRect(const wxDataViewItem& WXUNUSED(item), - const wxDataViewColumn *WXUNUSED(column)) const +wxDataViewCtrl::GetItemRect(const wxDataViewItem& item, + const wxDataViewColumn *column) const { - return wxRect(); + if ( !item ) + return wxRect(); + + GtkTreeViewColumn *gcolumn = NULL ; + if (column) + gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()); + + GtkTreeIter iter; + iter.user_data = item.GetID(); + wxGtkTreePath path(m_internal->get_path( &iter )); + + GdkRectangle item_rect; + gtk_tree_view_get_background_area(GTK_TREE_VIEW(m_treeview), path, gcolumn, &item_rect); + // If column is NULL we compute the combined width of all the columns + if ( !column ) + { + unsigned int cols = GetColumnCount(); + int width = 0; + for (unsigned int i = 0; i < cols; ++i) + { + wxDataViewColumn * col = GetColumn(i); + if ( !col->IsHidden() ) + width += col->GetWidth(); + } + item_rect.width = width; + } + return wxRectFromGDKRect(&item_rect); } bool wxDataViewCtrl::SetRowHeight(int rowHeight)