From: Michael Bedward Date: Thu, 7 Oct 1999 06:36:41 +0000 (+0000) Subject: Added page up and page down key support. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/66242c80071ebe77246d52d407a7bea6817f090e?ds=inline Added page up and page down key support. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- 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 &&