Support NULL column in wxDataViewCtrl::GetItemRect() in wxOSX

Emulate support for non-specified column by using the first and, if
necessary, last columns in this case.
This commit is contained in:
Vadim Zeitlin
2018-11-04 18:35:07 +01:00
parent fad50e74b7
commit bf97715972
2 changed files with 19 additions and 7 deletions

View File

@@ -1462,9 +1462,7 @@ public:
intersection of the item with the specified column. If @NULL, the intersection of the item with the specified column. If @NULL, the
rectangle spans all the columns. rectangle spans all the columns.
@note This method is currently not implemented at all in wxGTK and only @note This method is currently not implemented in wxGTK.
implemented for non-@NULL @a col argument in wxOSX. It is fully
implemented in the generic version of the control.
*/ */
virtual wxRect GetItemRect(const wxDataViewItem& item, virtual wxRect GetItemRect(const wxDataViewItem& item,
const wxDataViewColumn* col = NULL) const; const wxDataViewColumn* col = NULL) const;

View File

@@ -547,10 +547,24 @@ wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const
{ {
if (item.IsOk() && (columnPtr != NULL)) if ( !item.IsOk() )
return GetDataViewPeer()->GetRectangle(item,columnPtr);
else
return wxRect(); return wxRect();
wxRect rect = GetDataViewPeer()->GetRectangle(item, columnPtr ? columnPtr : GetColumn(0));
if ( !columnPtr )
{
const unsigned columnCount = GetColumnCount();
if ( columnCount != 1 )
{
// Extend the rectangle to the rightmost part of the last column.
const wxRect rectLastCol = GetDataViewPeer()->GetRectangle(item, GetColumn(columnCount - 1));
rect.SetRight(rectLastCol.GetRight());
}
//else: We already have the rectangle we need.
}
return rect;
} }
int wxDataViewCtrl::GetSelectedItemsCount() const int wxDataViewCtrl::GetSelectedItemsCount() const