void ProperList::EnsureVisible(size_t n) { if(!IsRowVisible(n)) { size_t ve = GetVisibleRowsEnd(); if(n > ve) { ScrollRows(n - ve); } else { ScrollToRow(n); } } }
bool wxVListBox::DoSetCurrent(int current) { wxASSERT_MSG( current == wxNOT_FOUND || (current >= 0 && (size_t)current < GetItemCount()), wxT("wxVListBox::DoSetCurrent(): invalid item index") ); if ( current == m_current ) { // nothing to do return false; } if ( m_current != wxNOT_FOUND ) RefreshRow(m_current); m_current = current; if ( m_current != wxNOT_FOUND ) { // if the line is not visible at all, we scroll it into view but we // don't need to refresh it -- it will be redrawn anyhow if ( !IsVisible(m_current) ) { ScrollToRow(m_current); } else // line is at least partly visible { // it is, indeed, only partly visible, so scroll it into view to // make it entirely visible // BUT scrolling down when m_current is first visible makes it // completely hidden, so that is even worse while ( (size_t)m_current + 1 == GetVisibleRowsEnd() && (size_t)m_current != GetVisibleRowsBegin() && ScrollToRow(GetVisibleBegin() + 1) ) ; // but in any case refresh it as even if it was only partly visible // before we need to redraw it entirely as its background changed RefreshRow(m_current); } } return true; }
bool ContentBoxCtrol::DoSetCurrent(int current) { wxASSERT_MSG( current == wxNOT_FOUND || (current >= 0 && (size_t)current < GetItemCount()), "ContentBoxCtrol::DoSetCurrent(): invalid item index" ); if ( current == m_current ) { // nothing to do return false; } if ( m_current != wxNOT_FOUND ) wxVScrolledWindow::RefreshRow(m_current); m_current = current; if ( m_current != wxNOT_FOUND ) { // if the line is not visible at all, we scroll it into view but we // don't need to refresh it -- it will be redrawn anyhow if ( !IsVisible(m_current) ) { ScrollToRow(m_current); } else // line is at least partly visible { // it is, indeed, only partly visible, so scroll it into view to // make it entirely visible while ( (size_t)m_current == GetVisibleRowsEnd() && ScrollToRow(GetVisibleBegin()+1) ) ; // but in any case refresh it as even if it was only partly visible // before we need to redraw it entirely as its background changed wxVScrolledWindow::RefreshRow(m_current); } } return true; }