wxGridTableBase * GetTable() const { return m_table; }
bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE,
- wxGrid::wxGridSelectionModes selmode =
- wxGrid::wxGridSelectCells );
+ wxGrid::wxGridSelectionModes selmode =
+ wxGrid::wxGridSelectCells );
void ClearGrid();
bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
void SetGridCursor( int row, int col )
{ SetCurrentCell( wxGridCellCoords(row, col) ); }
- bool MoveCursorUp();
- bool MoveCursorDown();
- bool MoveCursorLeft();
- bool MoveCursorRight();
+ bool MoveCursorUp( bool expandSelection );
+ bool MoveCursorDown( bool expandSelection );
+ bool MoveCursorLeft( bool expandSelection );
+ bool MoveCursorRight( bool expandSelection );
bool MovePageDown();
bool MovePageUp();
- bool MoveCursorUpBlock();
- bool MoveCursorDownBlock();
- bool MoveCursorLeftBlock();
- bool MoveCursorRightBlock();
+ bool MoveCursorUpBlock( bool expandSelection );
+ bool MoveCursorDownBlock( bool expandSelection );
+ bool MoveCursorLeftBlock( bool expandSelection );
+ bool MoveCursorRightBlock( bool expandSelection );
// ------ label and gridline formatting
public:
wxGridEvent()
: wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
- m_control(0), m_meta(0), m_shift(0), m_alt(0)
+ m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
{
}
wxGridEvent(int id, wxEventType type, wxObject* obj,
- int row=-1, int col=-1, int x=-1, int y=-1,
+ int row=-1, int col=-1, int x=-1, int y=-1, bool sel = TRUE,
bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
virtual int GetRow() { return m_row; }
virtual int GetCol() { return m_col; }
wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
+ bool Selecting() { return m_selecting; }
bool ControlDown() { return m_control; }
bool MetaDown() { return m_meta; }
bool ShiftDown() { return m_shift; }
int m_col;
int m_x;
int m_y;
+ bool m_selecting;
bool m_control;
bool m_meta;
bool m_shift;
{
m_topLeft = wxGridNoCellCoords;
m_bottomRight = wxGridNoCellCoords;
+ m_selecting = FALSE;
m_control = FALSE;
m_meta = FALSE;
m_shift = FALSE;
wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
+ bool sel = TRUE,
bool control=FALSE, bool shift=FALSE,
bool alt=FALSE, bool meta=FALSE);
int GetBottomRow() { return m_bottomRight.GetRow(); }
int GetLeftCol() { return m_topLeft.GetCol(); }
int GetRightCol() { return m_bottomRight.GetCol(); }
+ bool Selecting() { return m_selecting; }
bool ControlDown() { return m_control; }
bool MetaDown() { return m_meta; }
bool ShiftDown() { return m_shift; }
protected:
wxGridCellCoords m_topLeft;
wxGridCellCoords m_bottomRight;
+ bool m_selecting;
bool m_control;
bool m_meta;
bool m_shift;
void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
void SelectRow( int row, bool addToSelected = FALSE );
void SelectCol( int col, bool addToSelected = FALSE );
- void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol );
- void SelectCell( int row, int col);
+ void SelectBlock( int topRow, int leftCol,
+ int bottomRow, int rightCol,
+ wxMouseEvent* event = 0, bool sendEvent = TRUE );
+ void SelectCell( int row, int col, bool sendEvent = TRUE );
void ToggleCellSelection( int row, int col);
void ClearSelection();
wxMenu *selectionMenu = new wxMenu;
editMenu->Append( ID_CHANGESEL, "Change &selection mode",
- selectionMenu,
- "Change selection mode" );
+ selectionMenu,
+ "Change selection mode" );
selectionMenu->Append( ID_SELCELLS, "Select &Cells" );
selectionMenu->Append( ID_SELROWS, "Select &Rows" );
if ( grid->IsSelection() )
{
for ( int n = 0; n < grid->GetNumberRows(); n++ )
- if ( grid->IsInSelection( n , 0 ) )
- grid->DeleteRows( n, 1 );
+ if ( grid->IsInSelection( n , 0 ) )
+ grid->DeleteRows( n, 1 );
}
}
if ( grid->IsSelection() )
{
for ( int n = 0; n < grid->GetNumberCols(); n++ )
- if ( grid->IsInSelection( 0 , n ) )
- grid->DeleteCols( n, 1 );
+ if ( grid->IsInSelection( 0 , n ) )
+ grid->DeleteCols( n, 1 );
}
}
void GridFrame::OnSelectCell( wxGridEvent& ev )
{
logBuf = "";
- logBuf << "Selected cell at row " << ev.GetRow()
+ if ( ev.Selecting() )
+ logBuf << "Selected ";
+ else
+ logBuf << "Deselected ";
+ logBuf << "cell at row " << ev.GetRow()
<< " col " << ev.GetCol();
wxLogMessage( "%s", logBuf.c_str() );
void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
{
logBuf = "";
- logBuf << "Selected cells from row " << ev.GetTopRow()
- << " col " << ev.GetLeftCol()
- << " to row " << ev.GetBottomRow()
- << " col " << ev.GetRightCol();
+ if ( ev.Selecting() )
+ logBuf << "Selected ";
+ else
+ logBuf << "Deselected ";
+ logBuf << "cells from row " << ev.GetTopRow()
+ << " col " << ev.GetLeftCol()
+ << " to row " << ev.GetBottomRow()
+ << " col " << ev.GetRightCol();
wxLogMessage( "%s", logBuf.c_str() );
ClearSelection();
if ( event.ShiftDown() )
{
- SelectBlock( m_currentCellCoords, coords );
+ m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ coords.GetRow(),
+ coords.GetCol() );
}
else if ( XToEdgeOfCol(x) < 0 &&
YToEdgeOfRow(y) < 0 )
if ( m_selectingTopLeft != wxGridNoCellCoords &&
m_selectingBottomRight != wxGridNoCellCoords )
{
- m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
- m_selectingTopLeft.GetCol(),
- m_selectingBottomRight.GetRow(),
- m_selectingBottomRight.GetCol() );
if (m_winCapture)
{
m_winCapture->ReleaseMouse();
m_winCapture = NULL;
}
- SendEvent( wxEVT_GRID_RANGE_SELECT, -1, -1, event );
+ m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
+ m_selectingTopLeft.GetCol(),
+ m_selectingBottomRight.GetRow(),
+ m_selectingBottomRight.GetCol(),
+ & event );
+ m_selectingTopLeft = wxGridNoCellCoords;
+ m_selectingBottomRight = wxGridNoCellCoords;
}
// Show the edit control, if it has been hidden for
}
else if ( type == wxEVT_GRID_RANGE_SELECT )
{
+ // Right now, it should _never_ end up here!
wxGridRangeSelectEvent gridEvt( GetId(),
type,
this,
m_selectingTopLeft,
m_selectingBottomRight,
+ TRUE,
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
mouseEv.AltDown(),
type,
this,
row, col,
+ false,
mouseEv.GetX(), mouseEv.GetY(),
mouseEv.ControlDown(),
mouseEv.ShiftDown(),
if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
{
- // TODO: Should also support Shift-cursor keys for
- // extending the selection. Maybe add a flag to
- // MoveCursorXXX() and MoveCursorXXXBlock() and
- // just send event.ShiftDown().
-
// try local handlers
//
switch ( event.KeyCode() )
case WXK_UP:
if ( event.ControlDown() )
{
- MoveCursorUpBlock();
+ MoveCursorUpBlock( event.ShiftDown() );
}
else
{
- MoveCursorUp();
+ MoveCursorUp( event.ShiftDown() );
}
break;
case WXK_DOWN:
if ( event.ControlDown() )
{
- MoveCursorDownBlock();
+ MoveCursorDownBlock( event.ShiftDown() );
}
else
{
- MoveCursorDown();
+ MoveCursorDown( event.ShiftDown() );
}
break;
case WXK_LEFT:
if ( event.ControlDown() )
{
- MoveCursorLeftBlock();
+ MoveCursorLeftBlock( event.ShiftDown() );
}
else
{
- MoveCursorLeft();
+ MoveCursorLeft( event.ShiftDown() );
}
break;
case WXK_RIGHT:
if ( event.ControlDown() )
{
- MoveCursorRightBlock();
+ MoveCursorRightBlock( event.ShiftDown() );
}
else
{
- MoveCursorRight();
+ MoveCursorRight( event.ShiftDown() );
}
break;
}
else
{
- MoveCursorDown();
+ MoveCursorDown( event.ShiftDown() );
}
break;
+ case WXK_ESCAPE:
+ m_selection->ClearSelection();
+ break;
+
case WXK_TAB:
if (event.ShiftDown())
- MoveCursorLeft();
+ MoveCursorLeft( FALSE );
else
- MoveCursorRight();
+ MoveCursorRight( FALSE );
break;
case WXK_HOME:
MovePageDown();
break;
+#if 0
case WXK_SPACE:
if ( !IsEditable() )
{
- MoveCursorRight();
+ MoveCursorRight( FALSE );
break;
}
// Otherwise fall through to default
+#else
+ case WXK_SPACE:
+ m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() );
+ break;
+#endif
default:
// alphanumeric keys or F2 (special key just for this) enable
// the cell edit control
+ // On just Shift/Control I get values for event.KeyCode()
+ // that are outside the range where isalnum's behaviour is
+ // well defined, so do an additional sanity check.
if ( !(event.AltDown() ||
event.MetaDown() ||
event.ControlDown()) &&
- (isalnum(event.KeyCode()) || event.KeyCode() == WXK_F2) &&
+ ((isalnum(event.KeyCode()) &&
+ (event.KeyCode() < 256 && event.KeyCode() >= 0)) ||
+ event.KeyCode() == WXK_F2) &&
!IsCellEditControlEnabled() &&
CanEnableCellControl() )
{
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_displayed &&
m_currentCellCoords != wxGridNoCellCoords )
{
// ------ Grid cursor movement functions
//
-bool wxGrid::MoveCursorUp()
+bool wxGrid::MoveCursorUp( bool expandSelection )
{
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetRow() > 0 )
SetCurrentCell( m_currentCellCoords.GetRow() - 1,
m_currentCellCoords.GetCol() );
+ if ( expandSelection )
+ m_selection->SelectCell( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() );
return TRUE;
}
}
-bool wxGrid::MoveCursorDown()
+bool wxGrid::MoveCursorDown( bool expandSelection )
{
// TODO: allow for scrolling
//
SetCurrentCell( m_currentCellCoords.GetRow() + 1,
m_currentCellCoords.GetCol() );
+ if ( expandSelection )
+ m_selection->SelectCell( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() );
return TRUE;
}
}
-bool wxGrid::MoveCursorLeft()
+bool wxGrid::MoveCursorLeft( bool expandSelection )
{
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetCol() > 0 )
SetCurrentCell( m_currentCellCoords.GetRow(),
m_currentCellCoords.GetCol() - 1 );
+ if ( expandSelection )
+ m_selection->SelectCell( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() );
return TRUE;
}
}
-bool wxGrid::MoveCursorRight()
+bool wxGrid::MoveCursorRight( bool expandSelection )
{
if ( m_currentCellCoords != wxGridNoCellCoords &&
m_currentCellCoords.GetCol() < m_numCols - 1 )
SetCurrentCell( m_currentCellCoords.GetRow(),
m_currentCellCoords.GetCol() + 1 );
+ if ( expandSelection )
+ m_selection->SelectCell( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol() );
return TRUE;
}
return FALSE;
}
-bool wxGrid::MoveCursorUpBlock()
+bool wxGrid::MoveCursorUpBlock( bool expandSelection )
{
if ( m_table &&
m_currentCellCoords != wxGridNoCellCoords &&
}
MakeCellVisible( row, col );
+ if ( expandSelection )
+ m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ row, col );
SetCurrentCell( row, col );
return TRUE;
return FALSE;
}
-bool wxGrid::MoveCursorDownBlock()
+bool wxGrid::MoveCursorDownBlock( bool expandSelection )
{
if ( m_table &&
m_currentCellCoords != wxGridNoCellCoords &&
}
MakeCellVisible( row, col );
+ if ( expandSelection )
+ m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ row, col );
SetCurrentCell( row, col );
return TRUE;
return FALSE;
}
-bool wxGrid::MoveCursorLeftBlock()
+bool wxGrid::MoveCursorLeftBlock( bool expandSelection )
{
if ( m_table &&
m_currentCellCoords != wxGridNoCellCoords &&
}
MakeCellVisible( row, col );
+ if ( expandSelection )
+ m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ row, col );
SetCurrentCell( row, col );
return TRUE;
return FALSE;
}
-bool wxGrid::MoveCursorRightBlock()
+bool wxGrid::MoveCursorRightBlock( bool expandSelection )
{
if ( m_table &&
m_currentCellCoords != wxGridNoCellCoords &&
}
MakeCellVisible( row, col );
+ if ( expandSelection )
+ m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ row, col );
SetCurrentCell( row, col );
return TRUE;
m_selection->ClearSelection();
m_selection->SelectRow( row );
-
- wxGridRangeSelectEvent gridEvt( GetId(),
- wxEVT_GRID_RANGE_SELECT,
- this,
- wxGridCellCoords( row, 0 ),
- wxGridCellCoords( row, m_numCols - 1 ) );
-
- GetEventHandler()->ProcessEvent(gridEvt);
}
m_selection->ClearSelection();
m_selection->SelectCol( col );
-
- wxGridRangeSelectEvent gridEvt( GetId(),
- wxEVT_GRID_RANGE_SELECT,
- this,
- wxGridCellCoords( 0, col ),
- wxGridCellCoords( m_numRows - 1, col ) );
-
- GetEventHandler()->ProcessEvent(gridEvt);
}
m_gridWin->Refresh( FALSE, &(rect[i]) );
}
- // only generate an event if the block is not being selected by
- // dragging the mouse (in which case the event will be generated in
- // the mouse event handler)
- if ( !m_isDragging )
- {
- wxGridRangeSelectEvent gridEvt( GetId(),
- wxEVT_GRID_RANGE_SELECT,
- this,
- m_selectingTopLeft,
- m_selectingBottomRight );
-
- GetEventHandler()->ProcessEvent(gridEvt);
- }
+ // never generate an event as it will be generated from
+ // wxGridSelection::SelectBlock!
}
void wxGrid::SelectAll()
IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxEvent )
wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
- int row, int col, int x, int y,
+ int row, int col, int x, int y, bool sel,
bool control, bool shift, bool alt, bool meta )
: wxNotifyEvent( type, id )
{
m_col = col;
m_x = x;
m_y = y;
+ m_selecting = sel;
m_control = control;
m_shift = shift;
m_alt = alt;
wxGridRangeSelectEvent::wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
- bool control, bool shift, bool alt, bool meta )
+ bool sel, bool control,
+ bool shift, bool alt, bool meta )
: wxNotifyEvent( type, id )
{
m_topLeft = topLeft;
m_bottomRight = bottomRight;
+ m_selecting = sel;
m_control = control;
m_shift = shift;
m_alt = alt;
m_blockSelectionTopLeft.RemoveAt(n);
m_blockSelectionBottomRight.RemoveAt(n);
SelectBlock( topRow, 0,
- bottomRow, m_grid->GetNumberCols() - 1 );
+ bottomRow, m_grid->GetNumberCols() - 1,
+ 0, FALSE );
}
}
else // selmode == wxGridSelectColumns)
m_blockSelectionTopLeft.RemoveAt(n);
m_blockSelectionBottomRight.RemoveAt(n);
SelectBlock( 0, leftCol,
- m_grid->GetNumberRows() - 1, rightCol );
+ m_grid->GetNumberRows() - 1, rightCol,
+ 0, FALSE );
}
}
}
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
- // Possibly send event here? This would imply that no event is sent,
- // if the row already was part of the selection.
+ // Send Event
+ wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_RANGE_SELECT,
+ m_grid,
+ wxGridCellCoords( row, 0 ),
+ wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
+
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
}
void wxGridSelection::SelectCol( int col, bool addToSelected )
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
- // Possibly send event here? This would imply that no event is sent,
- // if the row already was part of the selection.
+ // Send Event
+ wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_RANGE_SELECT,
+ m_grid,
+ wxGridCellCoords( 0, col ),
+ wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
+
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
}
-void wxGridSelection::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
+void wxGridSelection::SelectBlock( int topRow, int leftCol,
+ int bottomRow, int rightCol,
+ wxMouseEvent* mouseEv, bool sendEvent )
{
- // Fix the coordinates of the block if potentially needed
+ // Fix the coordinates of the block if needed.
if ( m_selectionMode == wxGrid::wxGridSelectRows )
{
leftCol = 0;
topRow = 0;
bottomRow = m_grid->GetNumberRows() - 1;
}
+ if ( topRow > bottomRow )
+ {
+ int temp = topRow;
+ topRow = bottomRow;
+ bottomRow = temp;
+ }
+
+ if ( leftCol > rightCol )
+ {
+ int temp = leftCol;
+ leftCol = rightCol;
+ rightCol = temp;
+ }
// Handle single cell selection in SelectCell.
if ( topRow == bottomRow && leftCol == rightCol )
- SelectCell( topRow, leftCol );
+ SelectCell( topRow, leftCol, sendEvent );
size_t count, n;
// Remove single cells contained in newly selected block.
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
- // Possibly send event?
+ // Send Event, if not disabled.
+ if ( sendEvent )
+ {
+ if ( mouseEv == 0)
+ {
+ wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_RANGE_SELECT,
+ m_grid,
+ wxGridCellCoords( topRow, leftCol ),
+ wxGridCellCoords( bottomRow, rightCol ) );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
+ }
+ else
+ {
+ wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_RANGE_SELECT,
+ m_grid,
+ wxGridCellCoords( topRow, leftCol ),
+ wxGridCellCoords( bottomRow, rightCol ),
+ TRUE,
+ mouseEv->ControlDown(),
+ mouseEv->ShiftDown(),
+ mouseEv->AltDown(),
+ mouseEv->MetaDown() );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
+ }
+ }
}
-void wxGridSelection::SelectCell( int row, int col)
+void wxGridSelection::SelectCell( int row, int col, bool sendEvent )
{
if ( m_selectionMode == wxGrid::wxGridSelectRows )
{
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
- // Possibly send event?
+ // Send event
+ wxGridEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_SELECT_CELL,
+ m_grid,
+ row, col );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
}
void wxGridSelection::ToggleCellSelection( int row, int col)
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
return;
+
+ // Send event
+ wxGridEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_SELECT_CELL,
+ m_grid,
+ row, col, -1, -1, FALSE );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
}
}
}
if ( m_selectionMode != wxGrid::wxGridSelectColumns )
{
if ( topRow < row )
- SelectBlock( topRow, leftCol, row - 1, rightCol );
+ SelectBlock( topRow, leftCol,
+ row - 1, rightCol, 0, FALSE );
if ( bottomRow > row )
- SelectBlock( row + 1, leftCol, bottomRow, rightCol );
+ SelectBlock( row + 1, leftCol,
+ bottomRow, rightCol, 0, FALSE );
}
if ( m_selectionMode != wxGrid::wxGridSelectRows )
{
if ( leftCol < col )
- SelectBlock( row, leftCol, row, col - 1 );
+ SelectBlock( row, leftCol, row, col - 1, 0, FALSE );
if ( rightCol > col )
- SelectBlock( row, col + 1, row, rightCol );
+ SelectBlock( row, col + 1, row, rightCol, 0, FALSE );
}
}
}
if (m_selectionMode == wxGrid::wxGridSelectCells)
{
if ( col > 0 )
- SelectBlock( row, 0, row, col - 1 );
+ SelectBlock( row, 0, row, col - 1, 0, FALSE );
if ( col < m_grid->GetNumberCols() - 1 )
- SelectBlock( row, col + 1, row, m_grid->GetNumberCols() - 1 );
+ SelectBlock( row, col + 1,
+ row, m_grid->GetNumberCols() - 1,
+ 0, FALSE );
}
}
}
if (m_selectionMode == wxGrid::wxGridSelectCells)
{
if ( row > 0 )
- SelectBlock( 0, col, row - 1, col );
+ SelectBlock( 0, col, row - 1, col, 0, FALSE );
if ( row < m_grid->GetNumberRows() - 1 )
- SelectBlock( row + 1, col, m_grid->GetNumberRows() - 1, col );
+ SelectBlock( row + 1, col,
+ m_grid->GetNumberRows() - 1, col,
+ 0, FALSE );
}
}
}
}
- // Refresh the screen; according to m_selectionMode, we
- // need to either update only the cell, or the whole row/column.
+ // Refresh the screen and send the event; according to m_selectionMode,
+ // we need to either update only the cell, or the whole row/column.
wxRect r;
switch (m_selectionMode)
{
case wxGrid::wxGridSelectCells:
- r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ),
- wxGridCellCoords( row, col ) );
- break;
+ {
+ r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 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 );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
+ break;
+ }
case wxGrid::wxGridSelectRows:
- r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
- wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
- break;
+ {
+ r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
+ wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
+ if ( !m_grid->GetBatchCount() )
+ ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
+ wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_RANGE_SELECT,
+ m_grid,
+ wxGridCellCoords( row, 0 ),
+ wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ),
+ FALSE );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
+ break;
+ }
case wxGrid::wxGridSelectColumns:
- r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
- wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
- break;
+ {
+ r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
+ wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
+ if ( !m_grid->GetBatchCount() )
+ ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
+ wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
+ wxEVT_GRID_RANGE_SELECT,
+ m_grid,
+ wxGridCellCoords( 0, col ),
+ wxGridCellCoords( m_grid->GetNumberRows() - 1, col ),
+ FALSE );
+ m_grid->GetEventHandler()->ProcessEvent(gridEvt);
+ break;
+ }
}
- if ( !m_grid->GetBatchCount() )
- ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
void wxGridSelection::ClearSelection()