From 695a3263181ddb1b8dd5ec965a8e6ffd12682d3e Mon Sep 17 00:00:00 2001 From: Michael Bedward Date: Tue, 8 Aug 2000 10:43:16 +0000 Subject: [PATCH] Added Paul Gamman's patch for 0 as FALSE in bool editor and renderer. Fixed bug in grid selection code that caused crashes (e.g. when grid had just 1 col and mode was row selection). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/grid.cpp | 10 ++++++++-- src/generic/gridsel.cpp | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index baed28017d..5e8559b6c4 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -1189,7 +1189,10 @@ void wxGridCellBoolEditor::BeginEdit(int row, int col, wxGrid* grid) if (grid->GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL)) m_startValue = grid->GetTable()->GetValueAsBool(row, col); else - m_startValue = !!grid->GetTable()->GetValue(row, col); + { + wxString cellval( grid->GetTable()->GetValue(row, col) ); + m_startValue = !( !cellval || (cellval == "0") ); + } CBox()->SetValue(m_startValue); CBox()->SetFocus(); } @@ -1795,7 +1798,10 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid, if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) ) value = grid.GetTable()->GetValueAsBool(row, col); else - value = !!grid.GetTable()->GetValue(row, col); + { + wxString cellval( grid.GetTable()->GetValue(row, col) ); + value = !( !cellval || (cellval == "0") ); + } if ( value ) { diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index f6e4b2ba71..2781694fb5 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -402,7 +402,11 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol, } // Handle single cell selection in SelectCell. - if ( topRow == bottomRow && leftCol == rightCol ) + // (MB: added check for selection mode here to prevent + // crashes if, for example, we are select rows and the + // grid only has 1 col) + if ( m_selectionMode == wxGrid::wxGridSelectCells && + topRow == bottomRow && leftCol == rightCol ) SelectCell( topRow, leftCol, ControlDown, ShiftDown, AltDown, MetaDown, sendEvent ); -- 2.45.2