Fix generic wxDVC::EnsureVisible() to show full row

Generic wxDataViewCtrl's EnsureVisible() previously only ensured that at
least some part of the item (even if just 1px of it) was visible,
instead of being fully shown.
This commit is contained in:
Václav Slavík 2017-01-11 13:05:03 +01:00 committed by Václav Slavík
parent 195df9af7f
commit 1f56389e8b

View File

@ -756,6 +756,7 @@ public:
// the displaying number of the tree are changing along with the // the displaying number of the tree are changing along with the
// expanding/collapsing of the tree nodes // expanding/collapsing of the tree nodes
unsigned int GetLastVisibleRow(); unsigned int GetLastVisibleRow();
unsigned int GetLastFullyVisibleRow();
unsigned int GetRowCount() const; unsigned int GetRowCount() const;
const wxSelectionStore& GetSelections() const { return m_selection; } const wxSelectionStore& GetSelections() const { return m_selection; }
@ -2872,6 +2873,19 @@ unsigned int wxDataViewMainWindow::GetLastVisibleRow()
return wxMin( GetRowCount()-1, row ); return wxMin( GetRowCount()-1, row );
} }
unsigned int wxDataViewMainWindow::GetLastFullyVisibleRow()
{
unsigned int row = GetLastVisibleRow();
int bottom = GetLineStart(row) + GetLineHeight(row);
m_owner->CalcScrolledPosition(-1, bottom, NULL, &bottom);
if ( bottom > GetClientSize().y )
return wxMax(0, row - 1);
else
return row;
}
unsigned int wxDataViewMainWindow::GetRowCount() const unsigned int wxDataViewMainWindow::GetRowCount() const
{ {
if ( m_count == -1 ) if ( m_count == -1 )
@ -5491,7 +5505,7 @@ void wxDataViewCtrl::EnsureVisibleRowCol( int row, int column )
row = m_clientArea->GetRowCount(); row = m_clientArea->GetRowCount();
int first = m_clientArea->GetFirstVisibleRow(); int first = m_clientArea->GetFirstVisibleRow();
int last = m_clientArea->GetLastVisibleRow(); int last = m_clientArea->GetLastFullyVisibleRow();
if( row < first ) if( row < first )
m_clientArea->ScrollTo( row, column ); m_clientArea->ScrollTo( row, column );
else if( row > last ) else if( row > last )
@ -6178,7 +6192,7 @@ wxAccStatus wxDataViewCtrlAccessible::GetState(int childId, long* state)
if ( !dvWnd->IsSingleSel() ) if ( !dvWnd->IsSingleSel() )
st |= wxACC_STATE_SYSTEM_MULTISELECTABLE | wxACC_STATE_SYSTEM_EXTSELECTABLE; st |= wxACC_STATE_SYSTEM_MULTISELECTABLE | wxACC_STATE_SYSTEM_EXTSELECTABLE;
if ( rowNum < dvWnd->GetFirstVisibleRow() || rowNum > dvWnd->GetLastVisibleRow() ) if ( rowNum < dvWnd->GetFirstVisibleRow() || rowNum > dvWnd->GetLastFullyVisibleRow() )
st |= wxACC_STATE_SYSTEM_OFFSCREEN; st |= wxACC_STATE_SYSTEM_OFFSCREEN;
if ( dvWnd->GetCurrentRow() == rowNum ) if ( dvWnd->GetCurrentRow() == rowNum )
st |= wxACC_STATE_SYSTEM_FOCUSED; st |= wxACC_STATE_SYSTEM_FOCUSED;