From 3ebc76eea5142b939a58b78d6ce9a6229d149d4d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 15 Apr 2020 00:01:56 +0200 Subject: [PATCH] Always explicitly set split orientation in DeselectBlock() No real changes, just make the code more clear by always explicitly selecting either wxHORIZONTAL or wxVERTICAL instead of default for the former for no good reason (by symmetry, it is not a better choice than wxVERTICAL). Also list all wxGridSelection enum elements in the switch over selection mode to avoid warnings about not handling wxGridSelectRows. --- src/generic/gridsel.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index fc41b359bd..7f382f3715 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -269,33 +269,29 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block, if ( !m_selection[n].Intersects(canonicalizedBlock) ) continue; - int splitOrientation = wxHORIZONTAL; + int splitOrientation = -1; switch ( m_selectionMode ) { - case wxGrid::wxGridSelectCells: - if ( selBlock.GetLeftCol() == 0 && - selBlock.GetRightCol() == m_grid->GetNumberCols() - 1 ) - break; - - if ( selBlock.GetTopRow() == 0 && - selBlock.GetBottomRow() == m_grid->GetNumberRows() - 1 ) - splitOrientation = wxVERTICAL; - + case wxGrid::wxGridSelectRows: + splitOrientation = wxHORIZONTAL; break; case wxGrid::wxGridSelectColumns: splitOrientation = wxVERTICAL; break; + case wxGrid::wxGridSelectCells: case wxGrid::wxGridSelectRowsOrColumns: if ( selBlock.GetLeftCol() == 0 && selBlock.GetRightCol() == m_grid->GetNumberCols() - 1 ) - break; - - splitOrientation = wxVERTICAL; + splitOrientation = wxHORIZONTAL; + else + splitOrientation = wxVERTICAL; break; } + wxASSERT_MSG( splitOrientation != -1, "unknown selection mode" ); + const wxGridBlockDiffResult result = selBlock.Difference(canonicalizedBlock, splitOrientation);