if ( m_moveToCol < 0 )
markerX = GetColRight( GetColAt( m_numCols - 1 ) );
+ else if ( x >= (GetColLeft( m_moveToCol ) + (GetColWidth(m_moveToCol) / 2)) )
+ {
+ m_moveToCol = GetColAt( GetColPos( m_moveToCol ) + 1 );
+ if ( m_moveToCol < 0 )
+ markerX = GetColRight( GetColAt( m_numCols - 1 ) );
+ else
+ markerX = GetColLeft( m_moveToCol );
+ }
else
markerX = GetColLeft( m_moveToCol );
DrawColLabel( dc, XToCol( m_dragLastPos ) );
}
+ const wxColour *color;
//Moving to the same place? Don't draw a marker
if ( (m_moveToCol == m_dragRowOrCol)
|| (GetColPos( m_moveToCol ) == GetColPos( m_dragRowOrCol ) + 1)
|| (m_moveToCol < 0 && m_dragRowOrCol == GetColAt( m_numCols - 1 )))
- {
- m_dragLastPos = -1;
- return;
- }
+ color = wxLIGHT_GREY;
+ else
+ color = wxBLUE;
//Draw the marker
- wxPen pen( *wxBLUE, 2 );
+ wxPen pen( *color, 2 );
dc.SetPen(pen);
dc.DrawLine( markerX, 0, markerX, ch );
}
else
{
- m_waitForSlowClick = m_currentCellCoords == coords && coords != wxGridNoCellCoords;
+ m_waitForSlowClick = m_currentCellCoords == coords &&
+ coords != wxGridNoCellCoords;
SetCurrentCell( coords );
- if ( m_selection )
- {
- if ( m_selection->GetSelectionMode() !=
- wxGrid::wxGridSelectCells )
- {
- HighlightBlock( coords, coords );
- }
- }
}
}
}
break;
case WXK_SPACE:
- if ( event.ControlDown() )
+ // Ctrl-Space selects the current column, Shift-Space -- the
+ // current row and Ctrl-Shift-Space -- everything
+ switch ( m_selection ? event.GetModifiers() : wxMOD_NONE )
{
- if ( m_selection )
- {
- m_selection->ToggleCellSelection(
- m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol(),
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
- }
- break;
- }
+ case wxMOD_CONTROL:
+ m_selection->SelectCol(m_currentCellCoords.GetCol());
+ break;
- if ( !IsEditable() )
- MoveCursorRight( false );
- else
- event.Skip();
+ case wxMOD_SHIFT:
+ m_selection->SelectRow(m_currentCellCoords.GetRow());
+ break;
+
+ case wxMOD_CONTROL | wxMOD_SHIFT:
+ m_selection->SelectBlock(0, 0,
+ m_numRows - 1, m_numCols - 1);
+ break;
+
+ case wxMOD_NONE:
+ if ( !IsEditable() )
+ {
+ MoveCursorRight(false);
+ break;
+ }
+ //else: fall through
+
+ default:
+ event.Skip();
+ }
break;
default:
wxGridCellAttr *attr = GetCellAttr(row, col);
wxGridCellEditor *editor = attr->GetEditor(this, row, col);
+ const bool editorHadFocus = editor->GetControl()->HasFocus();
editor->Show( false );
editor->DecRef();
attr->DecRef();
- m_gridWin->SetFocus();
+ // return the focus to the grid itself if the editor had it
+ //
+ // note that we must not do this unconditionally to avoid stealing
+ // focus from the window which just received it if we are hiding the
+ // editor precisely because we lost focus
+ if ( editorHadFocus )
+ m_gridWin->SetFocus();
// refresh whole row to the right
wxRect rect( CellToRect(row, col) );