Add wxGridSelectNone selection mode
In this mode the user can't select any cells at all in wxGrid.
This commit is contained in:
committed by
Vadim Zeitlin
parent
a64348f3e4
commit
095d1e317c
@@ -98,6 +98,13 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
|
||||
if (selmode == m_selectionMode)
|
||||
return;
|
||||
|
||||
if (selmode == wxGrid::wxGridSelectNone)
|
||||
{
|
||||
ClearSelection();
|
||||
m_selectionMode = selmode;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_selectionMode != wxGrid::wxGridSelectCells )
|
||||
{
|
||||
// if changing form row to column selection
|
||||
@@ -127,6 +134,7 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
|
||||
switch ( selmode )
|
||||
{
|
||||
case wxGrid::wxGridSelectCells:
|
||||
case wxGrid::wxGridSelectNone:
|
||||
wxFAIL_MSG("unreachable");
|
||||
break;
|
||||
|
||||
@@ -160,7 +168,8 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
|
||||
|
||||
void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
|
||||
{
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectColumns )
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectColumns ||
|
||||
m_selectionMode == wxGrid::wxGridSelectNone )
|
||||
return;
|
||||
|
||||
Select(wxGridBlockCoords(row, 0, row, m_grid->GetNumberCols() - 1),
|
||||
@@ -169,7 +178,8 @@ void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
|
||||
|
||||
void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
|
||||
{
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectRows )
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectRows ||
|
||||
m_selectionMode == wxGrid::wxGridSelectNone )
|
||||
return;
|
||||
|
||||
Select(wxGridBlockCoords(0, col, m_grid->GetNumberRows() - 1, col),
|
||||
@@ -214,6 +224,10 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
|
||||
else
|
||||
allowed = 0;
|
||||
break;
|
||||
|
||||
case wxGrid::wxGridSelectNone:
|
||||
allowed = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
wxASSERT_MSG(allowed != -1, "unknown selection mode?");
|
||||
@@ -246,6 +260,10 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block,
|
||||
const wxKeyboardState& kbd,
|
||||
wxEventType eventType)
|
||||
{
|
||||
// In wxGridSelectNone mode, all blocks should already be deselected.
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectNone )
|
||||
return;
|
||||
|
||||
const wxGridBlockCoords canonicalizedBlock = block.Canonicalize();
|
||||
|
||||
size_t count, n;
|
||||
@@ -312,6 +330,10 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block,
|
||||
else
|
||||
splitOrientation = wxVERTICAL;
|
||||
break;
|
||||
|
||||
case wxGrid::wxGridSelectNone:
|
||||
wxFAIL_MSG("unreachable");
|
||||
break;
|
||||
}
|
||||
|
||||
wxASSERT_MSG( splitOrientation != -1, "unknown selection mode" );
|
||||
@@ -517,10 +539,14 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
|
||||
wxASSERT( blockStart.GetRow() != -1 && blockStart.GetCol() != -1 &&
|
||||
blockEnd.GetRow() != -1 && blockEnd.GetCol() != -1 );
|
||||
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectNone )
|
||||
return false;
|
||||
|
||||
// If selection doesn't contain the current cell (which also covers the
|
||||
// special case of nothing being selected yet), we have to create a new
|
||||
// block containing it because it doesn't make sense to extend any existing
|
||||
// block to non-selected current cell.
|
||||
|
||||
if ( !IsInSelection(m_grid->GetGridCursorCoords()) )
|
||||
{
|
||||
SelectBlock(blockStart, blockEnd, kbd, eventType);
|
||||
@@ -574,6 +600,10 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
|
||||
canChangeCol = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case wxGrid::wxGridSelectNone:
|
||||
wxFAIL_MSG("unreachable");
|
||||
break;
|
||||
}
|
||||
|
||||
if ( canChangeRow )
|
||||
@@ -754,7 +784,8 @@ wxGridCellCoordsArray wxGridSelection::GetBlockSelectionBottomRight() const
|
||||
// is, anyhow, the best we can do.
|
||||
wxArrayInt wxGridSelection::GetRowSelection() const
|
||||
{
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectColumns )
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectColumns ||
|
||||
m_selectionMode == wxGrid::wxGridSelectNone )
|
||||
return wxArrayInt();
|
||||
|
||||
wxIntSortedArray uniqueRows;
|
||||
@@ -785,7 +816,8 @@ wxArrayInt wxGridSelection::GetRowSelection() const
|
||||
// See comments for GetRowSelection().
|
||||
wxArrayInt wxGridSelection::GetColSelection() const
|
||||
{
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectRows )
|
||||
if ( m_selectionMode == wxGrid::wxGridSelectRows ||
|
||||
m_selectionMode == wxGrid::wxGridSelectNone )
|
||||
return wxArrayInt();
|
||||
|
||||
wxIntSortedArray uniqueCols;
|
||||
|
||||
Reference in New Issue
Block a user