+ case WXK_HOME:
+ {
+ if( wholeCellVisible )
+ {
+ // no special processing needed...
+ event.Skip();
+ break;
+ }
+
+ // do special processing for partly visible cell...
+
+ // get the widths of all cells previous to this one
+ int colXPos = 0;
+ for ( int i = 0; i < col; i++ )
+ {
+ colXPos += m_grid->GetColSize(i);
+ }
+
+ int xUnit = 1, yUnit = 1;
+ m_grid->GetScrollPixelsPerUnit(&xUnit, &yUnit);
+ if (col != 0)
+ {
+ m_grid->Scroll(colXPos/xUnit-1, m_grid->GetScrollPos(wxVERTICAL));
+ }
+ else
+ {
+ m_grid->Scroll(colXPos/xUnit, m_grid->GetScrollPos(wxVERTICAL));
+ }
+ event.Skip();
+ break;
+ }
+ case WXK_END:
+ {
+ if( wholeCellVisible )
+ {
+ // no special processing needed...
+ event.Skip();
+ break;
+ }
+
+ // do special processing for partly visible cell...
+
+ int textWidth = 0;
+ wxString value = m_grid->GetCellValue(row, col);
+ if ( wxEmptyString != value )
+ {
+ // get width of cell CONTENTS (text)
+ int y;
+ wxFont font = m_grid->GetCellFont(row, col);
+ m_grid->GetTextExtent(value, &textWidth, &y, NULL, NULL, &font);
+ // try to RIGHT align the text by scrolling
+ int client_right = m_grid->GetGridWindow()->GetClientSize().GetWidth();
+ // (m_grid->GetScrollLineX()*2) is a factor for not scrolling to far,
+ // otherwise the last part of the cell content might be hidden below the scroll bar
+ // FIXME: maybe there is a more suitable correction?
+ textWidth -= (client_right - (m_grid->GetScrollLineX()*2));
+ if ( textWidth < 0 )
+ {
+ textWidth = 0;
+ }
+ }
+
+ // get the widths of all cells previous to this one
+ int colXPos = 0;
+ for ( int i = 0; i < col; i++ )
+ {
+ colXPos += m_grid->GetColSize(i);
+ }
+ // and add the (modified) text width of the cell contents
+ // as we'd like to see the last part of the cell contents
+ colXPos += textWidth;
+
+ int xUnit = 1, yUnit = 1;
+ m_grid->GetScrollPixelsPerUnit(&xUnit, &yUnit);
+ m_grid->Scroll(colXPos/xUnit-1, m_grid->GetScrollPos(wxVERTICAL));
+ event.Skip();
+ break;
+ }
+