returns false if centering was requested but not executed because there where not enough lines below the requested index and it can be usefull to call ScrollToIndex again when more lines are available
| 1426 | // because there where not enough lines below the requested index |
| 1427 | // and it can be usefull to call ScrollToIndex again when more lines are available |
| 1428 | bool CLogView::ScrollToIndex(int index, bool center) |
| 1429 | { |
| 1430 | if (index < 0 || index >= static_cast<int>(m_logLines.size())) |
| 1431 | return true; |
| 1432 | |
| 1433 | ClearSelection(); |
| 1434 | SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); |
| 1435 | |
| 1436 | int paddingLines = GetCountPerPage() / 2; |
| 1437 | int minTopIndex = std::max(0, index - paddingLines); |
| 1438 | |
| 1439 | // this ensures the line is visible and not at the top of the view |
| 1440 | // if it does not need to be, also when coming from a higher index |
| 1441 | EnsureVisible(minTopIndex, false); |
| 1442 | EnsureVisible(index, false); |
| 1443 | |
| 1444 | if (index > paddingLines) |
| 1445 | { |
| 1446 | // if there are more items above the index then half a page, then centering may be possible. |
| 1447 | if (center) |
| 1448 | { |
| 1449 | int maxBottomIndex = std::min<int>(m_logLines.size() - 1, index + paddingLines); |
| 1450 | EnsureVisible(maxBottomIndex, false); |
| 1451 | return (maxBottomIndex == (index + paddingLines)); |
| 1452 | } |
| 1453 | } |
| 1454 | return true; |
| 1455 | } |
| 1456 | |
| 1457 | void CLogView::ScrollDown() |
| 1458 | { |
nothing calls this directly
no test coverage detected