Merge branch 'fix-grid-resizing'
Fix bugs in wxGrid mouse handling and simplify the code. See https://github.com/wxWidgets/wxWidgets/pull/2018
This commit is contained in:
@@ -3003,7 +3003,6 @@ private:
|
|||||||
void DoGridProcessTab(wxKeyboardState& kbdState);
|
void DoGridProcessTab(wxKeyboardState& kbdState);
|
||||||
|
|
||||||
// common implementations of methods defined for both rows and columns
|
// common implementations of methods defined for both rows and columns
|
||||||
bool DoEndDragResizeLine(const wxGridOperations& oper, wxGridWindow *gridWindow);
|
|
||||||
int PosToLinePos(int pos, bool clipToMinMax,
|
int PosToLinePos(int pos, bool clipToMinMax,
|
||||||
const wxGridOperations& oper,
|
const wxGridOperations& oper,
|
||||||
wxGridWindow *gridWindow) const;
|
wxGridWindow *gridWindow) const;
|
||||||
|
@@ -4551,38 +4551,39 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.ShiftDown() && !event.CmdDown() )
|
// Process the mouse down event depending on the current cursor mode. Note
|
||||||
|
// that this assumes m_cursorMode was set in the mouse move event hendler.
|
||||||
|
switch ( m_cursorMode )
|
||||||
{
|
{
|
||||||
if ( m_selection )
|
case WXGRID_CURSOR_RESIZE_ROW:
|
||||||
|
case WXGRID_CURSOR_RESIZE_COL:
|
||||||
|
{
|
||||||
|
int dragRowOrCol = wxNOT_FOUND;
|
||||||
|
if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL )
|
||||||
|
dragRowOrCol = XToEdgeOfCol(pos.x);
|
||||||
|
else
|
||||||
|
dragRowOrCol = YToEdgeOfRow(pos.y);
|
||||||
|
wxCHECK_RET( dragRowOrCol != -1, "Can't determine row or column in resizing mode" );
|
||||||
|
|
||||||
|
DoStartResizeRowOrCol(dragRowOrCol);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXGRID_CURSOR_SELECT_CELL:
|
||||||
|
case WXGRID_CURSOR_SELECT_ROW:
|
||||||
|
case WXGRID_CURSOR_SELECT_COL:
|
||||||
|
DisableCellEditControl();
|
||||||
|
MakeCellVisible(coords);
|
||||||
|
|
||||||
|
if (event.ShiftDown() && !event.CmdDown())
|
||||||
|
{
|
||||||
|
if (m_selection)
|
||||||
{
|
{
|
||||||
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
|
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
|
||||||
MakeCellVisible(coords);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Clicking on (or very near) the separating lines shouldn't change the
|
|
||||||
// selection when it's used for resizing -- but should still do it if
|
|
||||||
// resizing is disabled (notice that we intentionally don't check for
|
|
||||||
// it being disabled for a particular row/column as it would be
|
|
||||||
// surprising to have different mouse behaviour in different parts of
|
|
||||||
// the same grid, so we only check for it being globally disabled).
|
|
||||||
int dragRowOrCol = wxNOT_FOUND;
|
|
||||||
if ( CanDragGridColEdges() )
|
|
||||||
dragRowOrCol = XToEdgeOfCol(pos.x);
|
|
||||||
|
|
||||||
if ( dragRowOrCol == wxNOT_FOUND && CanDragGridRowEdges() )
|
|
||||||
dragRowOrCol = YToEdgeOfRow(pos.y);
|
|
||||||
|
|
||||||
if ( dragRowOrCol != wxNOT_FOUND )
|
|
||||||
{
|
|
||||||
DoStartResizeRowOrCol(dragRowOrCol);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisableCellEditControl();
|
|
||||||
MakeCellVisible( coords );
|
|
||||||
|
|
||||||
if ( event.CmdDown() && !event.ShiftDown() )
|
if ( event.CmdDown() && !event.ShiftDown() )
|
||||||
{
|
{
|
||||||
if ( m_selection )
|
if ( m_selection )
|
||||||
@@ -4637,6 +4638,12 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
|
|||||||
|
|
||||||
SetCurrentCell(coords);
|
SetCurrentCell(coords);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXGRID_CURSOR_MOVE_COL:
|
||||||
|
// Nothing to do here for this case.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -4707,14 +4714,14 @@ wxGrid::DoGridMouseMoveEvent(wxMouseEvent& WXUNUSED(event),
|
|||||||
// cell corner, as this is a more common operation.
|
// cell corner, as this is a more common operation.
|
||||||
if ( dragCol >= 0 && CanDragGridColEdges() && CanDragColSize(dragCol) )
|
if ( dragCol >= 0 && CanDragGridColEdges() && CanDragColSize(dragCol) )
|
||||||
{
|
{
|
||||||
if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
|
if ( m_cursorMode != WXGRID_CURSOR_RESIZE_COL )
|
||||||
{
|
{
|
||||||
ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, gridWindow, false);
|
ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, gridWindow, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( dragRow >= 0 && CanDragGridRowEdges() && CanDragRowSize(dragRow) )
|
else if ( dragRow >= 0 && CanDragGridRowEdges() && CanDragRowSize(dragRow) )
|
||||||
{
|
{
|
||||||
if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
|
if ( m_cursorMode != WXGRID_CURSOR_RESIZE_ROW)
|
||||||
{
|
{
|
||||||
ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, gridWindow, false);
|
ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, gridWindow, false);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user