Repaired semantics of EVT_GRID_SELECT_CELL.

Added OnKeyUp handler for selection with Shift+arrow keys.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2000-03-31 17:04:54 +00:00
parent 848bb8e625
commit 1904bfd1e9
3 changed files with 70 additions and 47 deletions

View File

@@ -1052,11 +1052,11 @@ public:
void EndBatch()
{
if ( m_batchCount > 0 )
{
m_batchCount--;
if ( !m_batchCount )
Refresh();
}
{
m_batchCount--;
if ( !m_batchCount )
Refresh();
}
}
int GetBatchCount() { return m_batchCount; }
@@ -1713,6 +1713,7 @@ protected:
void OnPaint( wxPaintEvent& );
void OnSize( wxSizeEvent& );
void OnKeyDown( wxKeyEvent& );
void OnKeyUp( wxKeyEvent& );
void OnEraseBackground( wxEraseEvent& );

View File

@@ -182,6 +182,7 @@ private:
void OnPaint( wxPaintEvent &event );
void OnMouseEvent( wxMouseEvent& event );
void OnKeyDown( wxKeyEvent& );
void OnKeyUp( wxKeyEvent& );
void OnEraseBackground( wxEraseEvent& );
@@ -2987,6 +2988,7 @@ BEGIN_EVENT_TABLE( wxGridWindow, wxPanel )
EVT_PAINT( wxGridWindow::OnPaint )
EVT_MOUSE_EVENTS( wxGridWindow::OnMouseEvent )
EVT_KEY_DOWN( wxGridWindow::OnKeyDown )
EVT_KEY_UP( wxGridWindow::OnKeyUp )
EVT_ERASE_BACKGROUND( wxGridWindow::OnEraseBackground )
END_EVENT_TABLE()
@@ -3037,7 +3039,7 @@ void wxGridWindow::OnMouseEvent( wxMouseEvent& event )
}
// This seems to be required for wxMotif otherwise the mouse
// This seems to be required for wxMotif/wxGTK otherwise the mouse
// cursor must be in the cell edit control to get key events
//
void wxGridWindow::OnKeyDown( wxKeyEvent& event )
@@ -3045,6 +3047,11 @@ void wxGridWindow::OnKeyDown( wxKeyEvent& event )
if ( !m_owner->ProcessEvent( event ) ) event.Skip();
}
void wxGridWindow::OnKeyUp( wxKeyEvent& event )
{
if ( !m_owner->ProcessEvent( event ) ) event.Skip();
}
void wxGridWindow::OnEraseBackground( wxEraseEvent& WXUNUSED(event) )
{
@@ -3060,6 +3067,7 @@ BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow )
EVT_PAINT( wxGrid::OnPaint )
EVT_SIZE( wxGrid::OnSize )
EVT_KEY_DOWN( wxGrid::OnKeyDown )
EVT_KEY_UP( wxGrid::OnKeyUp )
EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground )
END_EVENT_TABLE()
@@ -5146,24 +5154,6 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
// try local handlers
//
if ( !event.ShiftDown() &&
m_selectingKeyboard != wxGridNoCellCoords )
{
if ( m_selectingTopLeft != wxGridNoCellCoords &&
m_selectingBottomRight != wxGridNoCellCoords )
m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
m_selectingTopLeft.GetCol(),
m_selectingBottomRight.GetRow(),
m_selectingBottomRight.GetCol(),
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
m_selectingTopLeft = wxGridNoCellCoords;
m_selectingBottomRight = wxGridNoCellCoords;
m_selectingKeyboard = wxGridNoCellCoords;
}
switch ( event.KeyCode() )
{
case WXK_UP:
@@ -5319,12 +5309,40 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
m_inOnKeyDown = FALSE;
}
void wxGrid::OnKeyUp( wxKeyEvent& event )
{
// try local handlers
//
if ( event.KeyCode() == WXK_SHIFT )
{
if ( m_selectingTopLeft != wxGridNoCellCoords &&
m_selectingBottomRight != wxGridNoCellCoords )
m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
m_selectingTopLeft.GetCol(),
m_selectingBottomRight.GetRow(),
m_selectingBottomRight.GetCol(),
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
m_selectingTopLeft = wxGridNoCellCoords;
m_selectingBottomRight = wxGridNoCellCoords;
m_selectingKeyboard = wxGridNoCellCoords;
}
}
void wxGrid::OnEraseBackground(wxEraseEvent&)
{
}
void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
{
if ( SendEvent( wxEVT_GRID_SELECT_CELL, coords.GetRow(), coords.GetCol() ) )
{
// the event has been intercepted - do nothing
return;
}
if ( m_currentCellCoords != wxGridNoCellCoords )
{
HideCellEditControl();

View File

@@ -518,13 +518,13 @@ void wxGridSelection::SelectCell( int row, int col,
if ( m_selectionMode == wxGrid::wxGridSelectRows )
{
SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1,
ControlDown, ShiftDown, AltDown, MetaDown);
ControlDown, ShiftDown, AltDown, MetaDown);
return;
}
else if ( m_selectionMode == wxGrid::wxGridSelectColumns )
{
SelectBlock(0, col, m_grid->GetNumberRows() - 1, col,
ControlDown, ShiftDown, AltDown, MetaDown);
ControlDown, ShiftDown, AltDown, MetaDown);
return;
}
else if ( IsInSelection ( row, col ) )
@@ -540,14 +540,14 @@ void wxGridSelection::SelectCell( int row, int col,
// Send event
if (sendEvent)
{
wxGridEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_SELECT_CELL,
m_grid,
row, col,
-1, -1,
TRUE,
ControlDown, ShiftDown,
AltDown, MetaDown);
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
m_grid,
wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ),
TRUE,
ControlDown, ShiftDown,
AltDown, MetaDown);
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
}
}
@@ -590,12 +590,14 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
// Send event
wxGridEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_SELECT_CELL,
m_grid,
row, col, -1, -1, FALSE,
ControlDown, ShiftDown,
AltDown, MetaDown );
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
m_grid,
wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ),
FALSE,
ControlDown, ShiftDown,
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
return;
}
@@ -714,12 +716,14 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
wxGridCellCoords( row, col ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
wxGridEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_SELECT_CELL,
m_grid,
row, col, -1, -1, FALSE,
ControlDown, ShiftDown,
AltDown, MetaDown );
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
m_grid,
wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ),
FALSE,
ControlDown, ShiftDown,
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
break;
}
@@ -833,7 +837,7 @@ void wxGridSelection::ClearSelection()
m_grid,
wxGridCellCoords( 0, 0 ),
wxGridCellCoords( m_grid->GetNumberRows() - 1,
m_grid->GetNumberCols() - 1 ),
m_grid->GetNumberCols() - 1 ),
FALSE );
m_grid->GetEventHandler()->ProcessEvent(gridEvt);