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
This commit is contained in:
Umberto Carletti
2018-10-22 10:13:34 +02:00
committed by Vadim Zeitlin
parent 12f8ab20f9
commit 94a2595f5b

View File

@@ -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)