- wxClientDC dc( m_gridWin );
- PrepareDC( dc );
- x = wxMax( x, GetColLeft(m_dragRowOrCol) +
- GetColMinimalWidth(m_dragRowOrCol) );
- dc.SetLogicalFunction(wxINVERT);
- if ( m_dragLastPos >= 0 )
- {
- dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top + ch );
- }
- dc.DrawLine( x, top, x, top + ch );
- m_dragLastPos = x;
+ const wxRect rectWin(CalcUnscrolledPosition(wxPoint(0, 0)),
+ m_gridWin->GetClientSize());
+
+ // erase the previously drawn line, if any
+ if ( m_dragLastPos >= 0 )
+ oper.DrawParallelLineInRect(dc, rectWin, m_dragLastPos);
+
+ // we need the vertical position for rows and horizontal for columns here
+ m_dragLastPos = oper.Dual().Select(CalcUnscrolledPosition(event.GetPosition()));
+
+ // don't allow resizing beneath the minimal size
+ const int posMin = oper.GetLineStartPos(this, m_dragRowOrCol) +
+ oper.GetMinimalLineSize(this, m_dragRowOrCol);
+ if ( m_dragLastPos < posMin )
+ m_dragLastPos = posMin;
+
+ // and draw it at the new position
+ oper.DrawParallelLineInRect(dc, rectWin, m_dragLastPos);
+}
+
+void wxGrid::DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords)
+{
+ if ( !m_isDragging )
+ {
+ // Don't start doing anything until the mouse has been dragged far
+ // enough
+ const wxPoint& pt = event.GetPosition();
+ if ( m_startDragPos == wxDefaultPosition )
+ {
+ m_startDragPos = pt;
+ return;