From: Stefan Neis Date: Wed, 11 Sep 2002 21:44:16 +0000 (+0000) Subject: Fixed CoordToRowOrCol according to Patch 607387. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d57ad377014fbcd0609fe68dcd30196b037d2473?ds=inline Fixed CoordToRowOrCol according to Patch 607387. Reverted the "Prevented dragging dividers outside cells" change which just worked around the symptoms of the bug in CoordToRowOrCol. Removed posssibility to resize columns even from below the grid or rows from the right of the grid - that kind of "dragging dividers" wasn't even prevented by the previous change (according to Patch 607387). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 1685c4030c..19025bf5c2 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -3092,7 +3092,7 @@ bool wxGridStringTable::DeleteRows( size_t pos, size_t numRows ) if ( numRows >= curNumRows ) { - m_data.Clear(); // don't release memory just yet + m_data.Clear(); } else { @@ -5308,6 +5308,13 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) // else if ( event.Moving() && !event.IsButton() ) { + if( coords.GetRow() < 0 || coords.GetCol() < 0 ) + { + // out of grid cell area + ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL); + return; + } + int dragRow = YToEdgeOfRow( y ); int dragCol = XToEdgeOfCol( x ); @@ -5320,7 +5327,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) return; } - if ( dragRow >= 0 && dragRow < GetNumberRows()) + if ( dragRow >= 0 ) { m_dragRowOrCol = dragRow; @@ -5338,7 +5345,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) return; } - if ( dragCol >= 0 && dragCol < GetNumberCols()) + if ( dragCol >= 0 ) { m_dragRowOrCol = dragCol; @@ -7331,11 +7338,12 @@ static int CoordToRowOrCol(int coord, int defaultDist, int minDist, defaultDist = 1; size_t i_max = coord / defaultDist, i_min = 0; + if (BorderArray.IsEmpty()) { - if((int) i_max <= nMax) + if((int) i_max < nMax) return i_max; - return maxOnOverflow ? (int)i_max : -1; + return maxOnOverflow ? nMax - 1 : -1; } if ( i_max >= BorderArray.GetCount())