diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index f36a93b26a..68ca153f98 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -475,6 +475,8 @@ class wxGrid : public wxPanel bool MoveCursorDown(); bool MoveCursorLeft(); bool MoveCursorRight(); + bool MovePageDown(); + bool MovePageUp(); bool MoveCursorUpBlock(); bool MoveCursorDownBlock(); bool MoveCursorLeftBlock(); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index b6a36fe2db..c69d269430 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -1860,6 +1860,14 @@ void wxGrid::OnKeyDown( wxKeyEvent& ev ) } break; + case WXK_PRIOR: + MovePageUp(); + break; + + case WXK_NEXT: + MovePageDown(); + break; + default: // now try the cell edit control // @@ -2363,6 +2371,54 @@ bool wxGrid::MoveCursorRight() return FALSE; } +bool wxGrid::MovePageUp() +{ + if ( m_currentCellCoords != wxGridNoCellCoords && + m_scrollPosY > 0 ) + { + int row = m_currentCellCoords.GetRow(); + int y = m_rowBottoms[ row ] - m_rowHeights[ row ]; + while ( row > 0 ) + { + if ( y + m_rowHeights[row-1] > m_bottom ) break; + y += m_rowHeights[ --row ]; + } + SetVerticalScrollPos( row ); + + SelectCell( row, m_currentCellCoords.GetCol() ); + return TRUE; + } + + return FALSE; +} + +bool wxGrid::MovePageDown() +{ + if ( m_currentCellCoords != wxGridNoCellCoords && + m_scrollPosY + m_wholeRowsVisible < m_numRows ) + { + if ( m_wholeRowsVisible > 0 ) + { + SetVerticalScrollPos( m_scrollPosY + m_wholeRowsVisible ); + } + else if ( m_scrollPosY < m_numRows - 1 ) + { + SetVerticalScrollPos( m_scrollPosY + 1 ); + } + else + { + return FALSE; + } + + // m_scrollPosY will have been updated + // + SelectCell( m_scrollPosY, m_currentCellCoords.GetCol() ); + return TRUE; + } + + return FALSE; +} + bool wxGrid::MoveCursorUpBlock() { if ( m_table &&