Added drag-shrinking

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis 2000-02-04 08:41:34 +00:00
parent 2cce705aad
commit da6af900f1

View File

@ -1845,9 +1845,12 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
if ( event.Dragging() )
{
m_isDragging = TRUE;
if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
{
// Hide the edit control, so it
// won't interfer with drag-shrinking.
if ( IsCellEditControlEnabled() )
HideCellEditControl();
if ( coords != wxGridNoCellCoords )
{
if ( !IsSelection() )
@ -1856,7 +1859,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
}
else
{
if ( !IsInSelection( coords ) )
SelectBlock( m_currentCellCoords, coords );
}
}
@ -1901,6 +1903,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
{
SendEvent( EVT_GRID_RANGE_SELECT, -1, -1, event );
}
// Show the edit control, if it has
// been hidden for drag-shrinking.
if ( IsCellEditControlEnabled() )
ShowCellEditControl();
}
m_dragLastPos = -1;
@ -4223,6 +4229,8 @@ void wxGrid::SelectCol( int col, bool addToSelected )
void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
{
int temp;
bool changed = false;
wxGridCellCoords updateTopLeft, updateBottomRight;
if ( topRow > bottomRow )
{
@ -4238,12 +4246,47 @@ void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
rightCol = temp;
}
m_selectedTopLeft.Set( topRow, leftCol );
m_selectedBottomRight.Set( bottomRow, rightCol );
updateTopLeft = m_selectedTopLeft;
if (m_selectedTopLeft != wxGridCellCoords( topRow, leftCol ) )
{
m_selectedTopLeft = wxGridCellCoords( topRow, leftCol );
if (updateTopLeft == wxGridNoCellCoords)
{
updateTopLeft = m_selectedTopLeft;
}
else
{
if(updateTopLeft.GetRow() > topRow)
updateTopLeft.SetRow(topRow);
if (updateTopLeft.GetCol() > leftCol)
updateTopLeft.SetCol(leftCol);
}
changed = true;
}
wxRect r;
r = SelectionToDeviceRect();
updateBottomRight = m_selectedBottomRight;
if (m_selectedBottomRight != wxGridCellCoords( bottomRow, rightCol ) )
{
m_selectedBottomRight = wxGridCellCoords( bottomRow, rightCol );
if (updateBottomRight == wxGridNoCellCoords)
{
updateBottomRight = m_selectedBottomRight;
}
else
{
if (updateBottomRight.GetRow() < bottomRow)
updateBottomRight.SetRow(bottomRow);
if (updateBottomRight.GetCol() < rightCol)
updateBottomRight.SetCol(rightCol);
}
changed = true;
}
if (changed)
{
wxRect r( BlockToDeviceRect( updateTopLeft, updateBottomRight ) );
m_gridWin->Refresh( TRUE, &r );
}
// only generate an event if the block is not being selected by
// dragging the mouse (in which case the event will be generated in
@ -4276,17 +4319,18 @@ void wxGrid::ClearSelection()
}
// This function returns the rectangle that encloses the selected cells
// This function returns the rectangle that encloses the given block
// in device coords clipped to the client size of the grid window.
//
wxRect wxGrid::SelectionToDeviceRect()
wxRect wxGrid::BlockToDeviceRect(const wxGridCellCoords & TopLeft,
const wxGridCellCoords & BottomRight)
{
wxRect rect;
wxRect cellRect;
if ( IsSelection() )
{
cellRect = CellToRect( m_selectedTopLeft );
cellRect = CellToRect( TopLeft );
if ( cellRect != wxGridNoCellRect )
{
rect = cellRect;
@ -4296,7 +4340,7 @@ wxRect wxGrid::SelectionToDeviceRect()
rect = wxRect( 0, 0, 0, 0 );
}
cellRect = CellToRect( m_selectedBottomRight );
cellRect = CellToRect( BottomRight );
if ( cellRect != wxGridNoCellRect )
{
rect += cellRect;