Skip to content

Commit

Permalink
Fix generic wxDVC::EnsureVisible() to show full row
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vslavik committed Jan 12, 2017
1 parent 195df9a commit 1f56389
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/generic/datavgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ class wxDataViewMainWindow: public wxWindow
// the displaying number of the tree are changing along with the
// expanding/collapsing of the tree nodes
unsigned int GetLastVisibleRow();
unsigned int GetLastFullyVisibleRow();
unsigned int GetRowCount() const;

const wxSelectionStore& GetSelections() const { return m_selection; }
Expand Down Expand Up @@ -2872,6 +2873,19 @@ unsigned int wxDataViewMainWindow::GetLastVisibleRow()
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
{
if ( m_count == -1 )
Expand Down Expand Up @@ -5491,7 +5505,7 @@ void wxDataViewCtrl::EnsureVisibleRowCol( int row, int column )
row = m_clientArea->GetRowCount();

int first = m_clientArea->GetFirstVisibleRow();
int last = m_clientArea->GetLastVisibleRow();
int last = m_clientArea->GetLastFullyVisibleRow();
if( row < first )
m_clientArea->ScrollTo( row, column );
else if( row > last )
Expand Down Expand Up @@ -6178,7 +6192,7 @@ wxAccStatus wxDataViewCtrlAccessible::GetState(int childId, long* state)
if ( !dvWnd->IsSingleSel() )
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;
if ( dvWnd->GetCurrentRow() == rowNum )
st |= wxACC_STATE_SYSTEM_FOCUSED;
Expand Down

0 comments on commit 1f56389

Please sign in to comment.