Merge branch 'grid-selection-compat'
Fix wxGrid selection functions compatibility. See https://github.com/wxWidgets/wxWidgets/pull/2568
This commit is contained in:
@@ -2301,17 +2301,12 @@ void wxGrid::Render( wxDC& dc,
|
|||||||
|
|
||||||
// remove grid selection, don't paint selection colour
|
// remove grid selection, don't paint selection colour
|
||||||
// unless we have wxGRID_DRAW_SELECTION
|
// unless we have wxGRID_DRAW_SELECTION
|
||||||
// block selections are the only ones catered for here
|
wxGridSelection* selectionOrig = NULL;
|
||||||
wxGridCellCoordsArray selectedCells;
|
if ( m_selection && !( style & wxGRID_DRAW_SELECTION ) )
|
||||||
bool hasSelection = IsSelection();
|
|
||||||
if ( hasSelection && !( style & wxGRID_DRAW_SELECTION ) )
|
|
||||||
{
|
{
|
||||||
selectedCells = GetSelectionBlockTopLeft();
|
// remove the selection temporarily, it will be restored below
|
||||||
// non block selections may not have a bottom right
|
selectionOrig = m_selection;
|
||||||
if ( GetSelectionBlockBottomRight().size() )
|
m_selection = NULL;
|
||||||
selectedCells.Add( GetSelectionBlockBottomRight()[ 0 ] );
|
|
||||||
|
|
||||||
ClearSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// store user device origin
|
// store user device origin
|
||||||
@@ -2437,12 +2432,9 @@ void wxGrid::Render( wxDC& dc,
|
|||||||
dc.SetDeviceOrigin( userOriginX, userOriginY );
|
dc.SetDeviceOrigin( userOriginX, userOriginY );
|
||||||
dc.SetUserScale( scaleUserX, scaleUserY );
|
dc.SetUserScale( scaleUserX, scaleUserY );
|
||||||
|
|
||||||
if ( selectedCells.size() && !( style & wxGRID_DRAW_SELECTION ) )
|
if ( selectionOrig )
|
||||||
{
|
{
|
||||||
SelectBlock( selectedCells[ 0 ].GetRow(),
|
m_selection = selectionOrig;
|
||||||
selectedCells[ 0 ].GetCol(),
|
|
||||||
selectedCells[ selectedCells.size() -1 ].GetRow(),
|
|
||||||
selectedCells[ selectedCells.size() -1 ].GetCol() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -746,10 +746,6 @@ wxGridCellCoordsArray wxGridSelection::GetCellSelection() const
|
|||||||
|
|
||||||
wxGridCellCoordsArray wxGridSelection::GetBlockSelectionTopLeft() const
|
wxGridCellCoordsArray wxGridSelection::GetBlockSelectionTopLeft() const
|
||||||
{
|
{
|
||||||
// return blocks only in wxGridSelectCells selection mode
|
|
||||||
if ( m_selectionMode != wxGrid::wxGridSelectCells )
|
|
||||||
return wxGridCellCoordsArray();
|
|
||||||
|
|
||||||
wxGridCellCoordsArray coords;
|
wxGridCellCoordsArray coords;
|
||||||
const size_t count = m_selection.size();
|
const size_t count = m_selection.size();
|
||||||
coords.reserve(count);
|
coords.reserve(count);
|
||||||
@@ -762,9 +758,6 @@ wxGridCellCoordsArray wxGridSelection::GetBlockSelectionTopLeft() const
|
|||||||
|
|
||||||
wxGridCellCoordsArray wxGridSelection::GetBlockSelectionBottomRight() const
|
wxGridCellCoordsArray wxGridSelection::GetBlockSelectionBottomRight() const
|
||||||
{
|
{
|
||||||
if ( m_selectionMode != wxGrid::wxGridSelectCells )
|
|
||||||
return wxGridCellCoordsArray();
|
|
||||||
|
|
||||||
wxGridCellCoordsArray coords;
|
wxGridCellCoordsArray coords;
|
||||||
const size_t count = m_selection.size();
|
const size_t count = m_selection.size();
|
||||||
coords.reserve(count);
|
coords.reserve(count);
|
||||||
|
@@ -1163,6 +1163,16 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SelectionMode", "[grid]")
|
|||||||
CHECK( m_grid->IsInSelection(5, 1) );
|
CHECK( m_grid->IsInSelection(5, 1) );
|
||||||
CHECK( !m_grid->IsInSelection(3, 1) );
|
CHECK( !m_grid->IsInSelection(3, 1) );
|
||||||
|
|
||||||
|
// Check that top left/bottom right selection functions still work in row
|
||||||
|
// selection mode.
|
||||||
|
wxGridCellCoordsArray arr = m_grid->GetSelectionBlockTopLeft();
|
||||||
|
REQUIRE( arr.size() == 1 );
|
||||||
|
CHECK( arr[0] == wxGridCellCoords(5, 0) );
|
||||||
|
|
||||||
|
arr = m_grid->GetSelectionBlockBottomRight();
|
||||||
|
REQUIRE( arr.size() == 1 );
|
||||||
|
CHECK( arr[0] == wxGridCellCoords(5, 1) );
|
||||||
|
|
||||||
//Test row selection be selecting a single cell and checking the whole
|
//Test row selection be selecting a single cell and checking the whole
|
||||||
//row is selected
|
//row is selected
|
||||||
m_grid->ClearSelection();
|
m_grid->ClearSelection();
|
||||||
|
Reference in New Issue
Block a user