fix row/column deselection in row-or-column selection mode (it wasn't doing anything)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1c9588456e
commit
475be9ce00
@ -8083,7 +8083,8 @@ void wxGrid::DeselectLine(int line, const wxGridOperations& oper)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const wxGridSelectionModes mode = m_selection->GetSelectionMode();
|
const wxGridSelectionModes mode = m_selection->GetSelectionMode();
|
||||||
if ( mode == oper.GetSelectionMode() )
|
if ( mode == oper.GetSelectionMode() ||
|
||||||
|
mode == wxGrid::wxGridSelectRowsOrColumns )
|
||||||
{
|
{
|
||||||
const wxGridCellCoords c(oper.MakeCoords(line, 0));
|
const wxGridCellCoords c(oper.MakeCoords(line, 0));
|
||||||
if ( m_selection->IsInSelection(c) )
|
if ( m_selection->IsInSelection(c) )
|
||||||
|
@ -700,6 +700,7 @@ wxGridSelection::ToggleCellSelection(int row, int col,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rowSelectionWasChanged = false;
|
||||||
// remove a cell from a row, adding up to two new blocks
|
// remove a cell from a row, adding up to two new blocks
|
||||||
if ( m_selectionMode != wxGrid::wxGridSelectColumns )
|
if ( m_selectionMode != wxGrid::wxGridSelectColumns )
|
||||||
{
|
{
|
||||||
@ -712,6 +713,8 @@ wxGridSelection::ToggleCellSelection(int row, int col,
|
|||||||
n--;
|
n--;
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
|
rowSelectionWasChanged = true;
|
||||||
|
|
||||||
if (m_selectionMode == wxGrid::wxGridSelectCells)
|
if (m_selectionMode == wxGrid::wxGridSelectCells)
|
||||||
{
|
{
|
||||||
if ( col > 0 )
|
if ( col > 0 )
|
||||||
@ -724,6 +727,7 @@ wxGridSelection::ToggleCellSelection(int row, int col,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool colSelectionWasChanged = false;
|
||||||
// remove a cell from a column, adding up to two new blocks
|
// remove a cell from a column, adding up to two new blocks
|
||||||
if ( m_selectionMode != wxGrid::wxGridSelectRows )
|
if ( m_selectionMode != wxGrid::wxGridSelectRows )
|
||||||
{
|
{
|
||||||
@ -736,6 +740,8 @@ wxGridSelection::ToggleCellSelection(int row, int col,
|
|||||||
n--;
|
n--;
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
|
colSelectionWasChanged = true;
|
||||||
|
|
||||||
if (m_selectionMode == wxGrid::wxGridSelectCells)
|
if (m_selectionMode == wxGrid::wxGridSelectCells)
|
||||||
{
|
{
|
||||||
if ( row > 0 )
|
if ( row > 0 )
|
||||||
@ -751,73 +757,92 @@ wxGridSelection::ToggleCellSelection(int row, int col,
|
|||||||
// Refresh the screen and send the event; according to m_selectionMode,
|
// Refresh the screen and send the event; according to m_selectionMode,
|
||||||
// we need to either update only the cell, or the whole row/column.
|
// we need to either update only the cell, or the whole row/column.
|
||||||
wxRect r;
|
wxRect r;
|
||||||
switch (m_selectionMode)
|
if ( m_selectionMode == wxGrid::wxGridSelectCells )
|
||||||
{
|
{
|
||||||
case wxGrid::wxGridSelectCells:
|
if ( !m_grid->GetBatchCount() )
|
||||||
{
|
{
|
||||||
if ( !m_grid->GetBatchCount() )
|
r = m_grid->BlockToDeviceRect(
|
||||||
{
|
|
||||||
r = m_grid->BlockToDeviceRect(
|
|
||||||
wxGridCellCoords( row, col ),
|
|
||||||
wxGridCellCoords( row, col ) );
|
|
||||||
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
|
||||||
wxEVT_GRID_RANGE_SELECT,
|
|
||||||
m_grid,
|
|
||||||
wxGridCellCoords( row, col ),
|
wxGridCellCoords( row, col ),
|
||||||
wxGridCellCoords( row, col ),
|
wxGridCellCoords( row, col ) );
|
||||||
false,
|
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
|
||||||
kbd );
|
|
||||||
m_grid->GetEventHandler()->ProcessEvent( gridEvt );
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGrid::wxGridSelectRows:
|
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
||||||
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
|
m_grid,
|
||||||
|
wxGridCellCoords( row, col ),
|
||||||
|
wxGridCellCoords( row, col ),
|
||||||
|
false,
|
||||||
|
kbd );
|
||||||
|
m_grid->GetEventHandler()->ProcessEvent( gridEvt );
|
||||||
|
}
|
||||||
|
else // rows/columns selection mode
|
||||||
|
{
|
||||||
|
if ( m_selectionMode != wxGrid::wxGridSelectColumns &&
|
||||||
|
rowSelectionWasChanged )
|
||||||
{
|
{
|
||||||
if ( !m_grid->GetBatchCount() )
|
int numCols = m_grid->GetNumberCols();
|
||||||
|
for ( int colFrom = 0, colTo = 0; colTo <= numCols; ++colTo )
|
||||||
{
|
{
|
||||||
r = m_grid->BlockToDeviceRect(
|
if ( m_colSelection.Index(colTo) >= 0 || colTo == numCols )
|
||||||
wxGridCellCoords( row, 0 ),
|
{
|
||||||
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
|
if ( colFrom < colTo )
|
||||||
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
|
{
|
||||||
|
if ( !m_grid->GetBatchCount() )
|
||||||
|
{
|
||||||
|
r = m_grid->BlockToDeviceRect(
|
||||||
|
wxGridCellCoords( row, colFrom ),
|
||||||
|
wxGridCellCoords( row, colTo-1 ) );
|
||||||
|
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
||||||
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
|
m_grid,
|
||||||
|
wxGridCellCoords( row, colFrom ),
|
||||||
|
wxGridCellCoords( row, colTo - 1 ),
|
||||||
|
false,
|
||||||
|
kbd );
|
||||||
|
m_grid->GetEventHandler()->ProcessEvent( gridEvt );
|
||||||
|
}
|
||||||
|
|
||||||
|
colFrom = colTo + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
|
||||||
wxEVT_GRID_RANGE_SELECT,
|
|
||||||
m_grid,
|
|
||||||
wxGridCellCoords( row, 0 ),
|
|
||||||
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ),
|
|
||||||
false,
|
|
||||||
kbd );
|
|
||||||
m_grid->GetEventHandler()->ProcessEvent( gridEvt );
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGrid::wxGridSelectColumns:
|
if ( m_selectionMode != wxGrid::wxGridSelectRows &&
|
||||||
|
colSelectionWasChanged )
|
||||||
{
|
{
|
||||||
if ( !m_grid->GetBatchCount() )
|
int numRows = m_grid->GetNumberRows();
|
||||||
|
for ( int rowFrom = 0, rowTo = 0; rowTo <= numRows; ++rowTo )
|
||||||
{
|
{
|
||||||
r = m_grid->BlockToDeviceRect(
|
if ( m_rowSelection.Index(rowTo) >= 0 || rowTo == numRows )
|
||||||
wxGridCellCoords( 0, col ),
|
{
|
||||||
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
|
if (rowFrom < rowTo)
|
||||||
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
|
{
|
||||||
|
if ( !m_grid->GetBatchCount() )
|
||||||
|
{
|
||||||
|
r = m_grid->BlockToDeviceRect(
|
||||||
|
wxGridCellCoords( rowFrom, col ),
|
||||||
|
wxGridCellCoords( rowTo - 1, col ) );
|
||||||
|
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
||||||
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
|
m_grid,
|
||||||
|
wxGridCellCoords( rowFrom, col ),
|
||||||
|
wxGridCellCoords( rowTo - 1, col ),
|
||||||
|
false,
|
||||||
|
kbd );
|
||||||
|
m_grid->GetEventHandler()->ProcessEvent( gridEvt );
|
||||||
|
}
|
||||||
|
|
||||||
|
rowFrom = rowTo + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
|
||||||
wxEVT_GRID_RANGE_SELECT,
|
|
||||||
m_grid,
|
|
||||||
wxGridCellCoords( 0, col ),
|
|
||||||
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ),
|
|
||||||
false,
|
|
||||||
kbd );
|
|
||||||
m_grid->GetEventHandler()->ProcessEvent( gridEvt );
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user