+ }
+
+ if ( m_selection )
+ m_selection->UpdateRows( pos, -((int)numRows) );
+ wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider();
+ if (attrProvider)
+ {
+ attrProvider->UpdateAttrRows( pos, -((int)numRows) );
+
+// ifdef'd out following patch from Paul Gammans
+#if 0
+ // No need to touch column attributes, unless we
+ // removed _all_ rows, in this case, we remove
+ // all column attributes.
+ // I hate to do this here, but the
+ // needed data is not available inside UpdateAttrRows.
+ if ( !GetNumberRows() )
+ attrProvider->UpdateAttrCols( 0, -GetNumberCols() );
+#endif
+ }
+
+ if ( !GetBatchCount() )
+ {
+ CalcDimensions();
+ m_rowLabelWin->Refresh();
+ }
+ }
+ result = true;
+ break;
+
+ case wxGRIDTABLE_NOTIFY_COLS_INSERTED:
+ {
+ size_t pos = msg.GetCommandInt();
+ int numCols = msg.GetCommandInt2();
+ m_numCols += numCols;
+
+ if ( m_useNativeHeader )
+ GetGridColHeader()->SetColumnCount(m_numCols);
+
+ if ( !m_colAt.IsEmpty() )
+ {
+ //Shift the column IDs
+ int i;
+ for ( i = 0; i < m_numCols - numCols; i++ )
+ {
+ if ( m_colAt[i] >= (int)pos )
+ m_colAt[i] += numCols;
+ }
+
+ m_colAt.Insert( pos, pos, numCols );
+
+ //Set the new columns' positions
+ for ( i = pos + 1; i < (int)pos + numCols; i++ )
+ {
+ m_colAt[i] = i;
+ }
+ }
+
+ if ( !m_colWidths.IsEmpty() )
+ {
+ m_colWidths.Insert( m_defaultColWidth, pos, numCols );
+ m_colRights.Insert( 0, pos, numCols );
+
+ int right = 0;
+ if ( pos > 0 )
+ right = m_colRights[GetColAt( pos - 1 )];
+
+ int colPos;
+ for ( colPos = pos; colPos < m_numCols; colPos++ )
+ {
+ i = GetColAt( colPos );
+
+ right += m_colWidths[i];
+ m_colRights[i] = right;
+ }
+ }
+
+ if ( m_currentCellCoords == wxGridNoCellCoords )
+ {
+ // if we have just inserted cols into an empty grid the current
+ // cell will be undefined...
+ //
+ SetCurrentCell( 0, 0 );
+ }
+
+ if ( m_selection )
+ m_selection->UpdateCols( pos, numCols );
+ wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider();
+ if (attrProvider)
+ attrProvider->UpdateAttrCols( pos, numCols );
+ if ( !GetBatchCount() )
+ {
+ CalcDimensions();
+ m_colWindow->Refresh();
+ }
+ }
+ result = true;
+ break;
+
+ case wxGRIDTABLE_NOTIFY_COLS_APPENDED:
+ {
+ int numCols = msg.GetCommandInt();
+ int oldNumCols = m_numCols;
+ m_numCols += numCols;
+ if ( m_useNativeHeader )
+ GetGridColHeader()->SetColumnCount(m_numCols);
+
+ if ( !m_colAt.IsEmpty() )
+ {
+ m_colAt.Add( 0, numCols );
+
+ //Set the new columns' positions
+ int i;
+ for ( i = oldNumCols; i < m_numCols; i++ )
+ {
+ m_colAt[i] = i;
+ }
+ }
+
+ if ( !m_colWidths.IsEmpty() )
+ {
+ m_colWidths.Add( m_defaultColWidth, numCols );
+ m_colRights.Add( 0, numCols );
+
+ int right = 0;
+ if ( oldNumCols > 0 )
+ right = m_colRights[GetColAt( oldNumCols - 1 )];
+
+ int colPos;
+ for ( colPos = oldNumCols; colPos < m_numCols; colPos++ )
+ {
+ i = GetColAt( colPos );
+
+ right += m_colWidths[i];
+ m_colRights[i] = right;
+ }
+ }
+
+ if ( m_currentCellCoords == wxGridNoCellCoords )
+ {
+ // if we have just inserted cols into an empty grid the current
+ // cell will be undefined...
+ //
+ SetCurrentCell( 0, 0 );
+ }
+ if ( !GetBatchCount() )
+ {
+ CalcDimensions();
+ m_colWindow->Refresh();
+ }
+ }
+ result = true;
+ break;
+
+ case wxGRIDTABLE_NOTIFY_COLS_DELETED:
+ {
+ size_t pos = msg.GetCommandInt();
+ int numCols = msg.GetCommandInt2();
+ m_numCols -= numCols;
+ if ( m_useNativeHeader )
+ GetGridColHeader()->SetColumnCount(m_numCols);
+
+ if ( !m_colAt.IsEmpty() )
+ {
+ int colID = GetColAt( pos );
+
+ m_colAt.RemoveAt( pos, numCols );
+
+ //Shift the column IDs
+ int colPos;
+ for ( colPos = 0; colPos < m_numCols; colPos++ )
+ {
+ if ( m_colAt[colPos] > colID )
+ m_colAt[colPos] -= numCols;
+ }
+ }
+
+ if ( !m_colWidths.IsEmpty() )
+ {
+ m_colWidths.RemoveAt( pos, numCols );
+ m_colRights.RemoveAt( pos, numCols );
+
+ int w = 0;
+ int colPos;
+ for ( colPos = 0; colPos < m_numCols; colPos++ )
+ {
+ i = GetColAt( colPos );
+
+ w += m_colWidths[i];
+ m_colRights[i] = w;
+ }
+ }
+
+ if ( !m_numCols )
+ {
+ m_currentCellCoords = wxGridNoCellCoords;
+ }
+ else
+ {
+ if ( m_currentCellCoords.GetCol() >= m_numCols )
+ m_currentCellCoords.Set( 0, 0 );
+ }
+
+ if ( m_selection )
+ m_selection->UpdateCols( pos, -((int)numCols) );
+ wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider();
+ if (attrProvider)
+ {
+ attrProvider->UpdateAttrCols( pos, -((int)numCols) );
+
+// ifdef'd out following patch from Paul Gammans
+#if 0
+ // No need to touch row attributes, unless we
+ // removed _all_ columns, in this case, we remove
+ // all row attributes.
+ // I hate to do this here, but the
+ // needed data is not available inside UpdateAttrCols.
+ if ( !GetNumberCols() )
+ attrProvider->UpdateAttrRows( 0, -GetNumberRows() );
+#endif
+ }
+
+ if ( !GetBatchCount() )
+ {
+ CalcDimensions();
+ m_colWindow->Refresh();
+ }
+ }
+ result = true;
+ break;
+ }
+
+ if (result && !GetBatchCount() )
+ m_gridWin->Refresh();
+
+ return result;
+}
+
+wxArrayInt wxGrid::CalcRowLabelsExposed( const wxRegion& reg ) const
+{
+ wxRegionIterator iter( reg );
+ wxRect r;
+
+ wxArrayInt rowlabels;
+
+ int top, bottom;
+ while ( iter )
+ {
+ r = iter.GetRect();
+
+ // TODO: remove this when we can...
+ // There is a bug in wxMotif that gives garbage update
+ // rectangles if you jump-scroll a long way by clicking the
+ // scrollbar with middle button. This is a work-around
+ //
+#if defined(__WXMOTIF__)
+ int cw, ch;
+ m_gridWin->GetClientSize( &cw, &ch );
+ if ( r.GetTop() > ch )
+ r.SetTop( 0 );
+ r.SetBottom( wxMin( r.GetBottom(), ch ) );
+#endif
+
+ // logical bounds of update region
+ //
+ int dummy;
+ CalcUnscrolledPosition( 0, r.GetTop(), &dummy, &top );
+ CalcUnscrolledPosition( 0, r.GetBottom(), &dummy, &bottom );
+
+ // find the row labels within these bounds
+ //
+ int row;
+ for ( row = internalYToRow(top); row < m_numRows; row++ )
+ {
+ if ( GetRowBottom(row) < top )
+ continue;
+
+ if ( GetRowTop(row) > bottom )
+ break;
+
+ rowlabels.Add( row );
+ }
+
+ ++iter;
+ }
+
+ return rowlabels;
+}
+
+wxArrayInt wxGrid::CalcColLabelsExposed( const wxRegion& reg ) const
+{
+ wxRegionIterator iter( reg );
+ wxRect r;
+
+ wxArrayInt colLabels;
+
+ int left, right;
+ while ( iter )
+ {
+ r = iter.GetRect();
+
+ // TODO: remove this when we can...
+ // There is a bug in wxMotif that gives garbage update
+ // rectangles if you jump-scroll a long way by clicking the
+ // scrollbar with middle button. This is a work-around
+ //
+#if defined(__WXMOTIF__)
+ int cw, ch;
+ m_gridWin->GetClientSize( &cw, &ch );
+ if ( r.GetLeft() > cw )
+ r.SetLeft( 0 );
+ r.SetRight( wxMin( r.GetRight(), cw ) );
+#endif
+
+ // logical bounds of update region
+ //
+ int dummy;
+ CalcUnscrolledPosition( r.GetLeft(), 0, &left, &dummy );
+ CalcUnscrolledPosition( r.GetRight(), 0, &right, &dummy );
+
+ // find the cells within these bounds
+ //
+ int col;
+ int colPos;
+ for ( colPos = GetColPos( internalXToCol(left) ); colPos < m_numCols; colPos++ )
+ {
+ col = GetColAt( colPos );
+
+ if ( GetColRight(col) < left )
+ continue;
+
+ if ( GetColLeft(col) > right )
+ break;
+
+ colLabels.Add( col );
+ }
+
+ ++iter;
+ }
+
+ return colLabels;
+}
+
+wxGridCellCoordsArray wxGrid::CalcCellsExposed( const wxRegion& reg ) const
+{
+ wxRegionIterator iter( reg );
+ wxRect r;
+
+ wxGridCellCoordsArray cellsExposed;
+
+ int left, top, right, bottom;
+ while ( iter )
+ {
+ r = iter.GetRect();
+
+ // TODO: remove this when we can...
+ // There is a bug in wxMotif that gives garbage update
+ // rectangles if you jump-scroll a long way by clicking the
+ // scrollbar with middle button. This is a work-around
+ //
+#if defined(__WXMOTIF__)
+ int cw, ch;
+ m_gridWin->GetClientSize( &cw, &ch );
+ if ( r.GetTop() > ch ) r.SetTop( 0 );
+ if ( r.GetLeft() > cw ) r.SetLeft( 0 );
+ r.SetRight( wxMin( r.GetRight(), cw ) );
+ r.SetBottom( wxMin( r.GetBottom(), ch ) );
+#endif
+
+ // logical bounds of update region
+ //
+ CalcUnscrolledPosition( r.GetLeft(), r.GetTop(), &left, &top );
+ CalcUnscrolledPosition( r.GetRight(), r.GetBottom(), &right, &bottom );
+
+ // find the cells within these bounds
+ wxArrayInt cols;
+ for ( int row = internalYToRow(top); row < m_numRows; row++ )
+ {
+ if ( GetRowBottom(row) <= top )
+ continue;
+
+ if ( GetRowTop(row) > bottom )
+ break;
+
+ // add all dirty cells in this row: notice that the columns which
+ // are dirty don't depend on the row so we compute them only once
+ // for the first dirty row and then reuse for all the next ones
+ if ( cols.empty() )
+ {
+ // do determine the dirty columns
+ for ( int pos = XToPos(left); pos <= XToPos(right); pos++ )
+ cols.push_back(GetColAt(pos));
+
+ // if there are no dirty columns at all, nothing to do
+ if ( cols.empty() )
+ break;
+ }
+
+ const size_t count = cols.size();
+ for ( size_t n = 0; n < count; n++ )
+ cellsExposed.Add(wxGridCellCoords(row, cols[n]));
+ }
+
+ ++iter;
+ }
+
+ return cellsExposed;
+}
+
+
+void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
+{
+ int x, y, row;
+ wxPoint pos( event.GetPosition() );
+ CalcUnscrolledPosition( pos.x, pos.y, &x, &y );
+
+ if ( event.Dragging() )
+ {
+ if (!m_isDragging)
+ {
+ m_isDragging = true;
+ m_rowLabelWin->CaptureMouse();
+ }
+
+ if ( event.LeftIsDown() )
+ {
+ switch ( m_cursorMode )
+ {
+ case WXGRID_CURSOR_RESIZE_ROW:
+ {
+ int cw, ch, left, dummy;
+ m_gridWin->GetClientSize( &cw, &ch );
+ CalcUnscrolledPosition( 0, 0, &left, &dummy );
+
+ wxClientDC dc( m_gridWin );
+ PrepareDC( dc );
+ y = wxMax( y,
+ GetRowTop(m_dragRowOrCol) +
+ GetRowMinimalHeight(m_dragRowOrCol) );
+ dc.SetLogicalFunction(wxINVERT);
+ if ( m_dragLastPos >= 0 )
+ {
+ dc.DrawLine( left, m_dragLastPos, left+cw, m_dragLastPos );
+ }
+ dc.DrawLine( left, y, left+cw, y );
+ m_dragLastPos = y;
+ }
+ break;
+
+ case WXGRID_CURSOR_SELECT_ROW:
+ {
+ if ( (row = YToRow( y )) >= 0 )
+ {
+ if ( m_selection )
+ m_selection->SelectRow(row, event);
+ }
+ }
+ break;
+
+ // default label to suppress warnings about "enumeration value
+ // 'xxx' not handled in switch
+ default:
+ break;
+ }
+ }
+ return;
+ }
+
+ if ( m_isDragging && (event.Entering() || event.Leaving()) )
+ return;
+
+ if (m_isDragging)
+ {
+ if (m_rowLabelWin->HasCapture())
+ m_rowLabelWin->ReleaseMouse();
+ m_isDragging = false;
+ }
+
+ // ------------ Entering or leaving the window
+ //
+ if ( event.Entering() || event.Leaving() )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin);
+ }
+
+ // ------------ Left button pressed
+ //
+ else if ( event.LeftDown() )
+ {
+ row = YToEdgeOfRow(y);
+ if ( row != wxNOT_FOUND && CanDragRowSize(row) )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin);
+ }
+ else // not a request to start resizing
+ {
+ row = YToRow(y);
+ if ( row >= 0 &&
+ !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
+ {
+ if ( !event.ShiftDown() && !event.CmdDown() )
+ ClearSelection();
+ if ( m_selection )
+ {
+ if ( event.ShiftDown() )
+ {
+ m_selection->SelectBlock
+ (
+ m_currentCellCoords.GetRow(), 0,
+ row, GetNumberCols() - 1,
+ event
+ );
+ }
+ else
+ {
+ m_selection->SelectRow(row, event);
+ }
+ }
+
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
+ }
+ }
+ }
+
+ // ------------ Left double click
+ //
+ else if (event.LeftDClick() )
+ {
+ row = YToEdgeOfRow(y);
+ if ( row != wxNOT_FOUND && CanDragRowSize(row) )
+ {
+ // adjust row height depending on label text
+ //
+ // TODO: generate RESIZING event, see #10754
+ AutoSizeRowLabelSize( row );
+
+ SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, row, -1, event);
+
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
+ m_dragLastPos = -1;
+ }
+ else // not on row separator or it's not resizeable
+ {
+ row = YToRow(y);
+ if ( row >=0 &&
+ !SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, row, -1, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+ }
+
+ // ------------ Left button released
+ //
+ else if ( event.LeftUp() )
+ {
+ if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
+ DoEndDragResizeRow(event);
+
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin);
+ m_dragLastPos = -1;
+ }
+
+ // ------------ Right button down
+ //
+ else if ( event.RightDown() )
+ {
+ row = YToRow(y);
+ if ( row >=0 &&
+ !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, row, -1, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+
+ // ------------ Right double click
+ //
+ else if ( event.RightDClick() )
+ {
+ row = YToRow(y);
+ if ( row >= 0 &&
+ !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, row, -1, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+
+ // ------------ No buttons down and mouse moving
+ //
+ else if ( event.Moving() )
+ {
+ m_dragRowOrCol = YToEdgeOfRow( y );
+ if ( m_dragRowOrCol != wxNOT_FOUND )
+ {
+ if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
+ {
+ if ( CanDragRowSize(m_dragRowOrCol) )
+ ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, m_rowLabelWin, false);
+ }
+ }
+ else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin, false);
+ }
+ }
+}
+
+void wxGrid::UpdateColumnSortingIndicator(int col)
+{
+ wxCHECK_RET( col != wxNOT_FOUND, "invalid column index" );
+
+ if ( m_useNativeHeader )
+ GetGridColHeader()->UpdateColumn(col);
+ else if ( m_nativeColumnLabels )
+ m_colWindow->Refresh();
+ //else: sorting indicator display not yet implemented in grid version
+}
+
+void wxGrid::SetSortingColumn(int col, bool ascending)
+{
+ if ( col == m_sortCol )
+ {
+ // we are already using this column for sorting (or not sorting at all)
+ // but we might still change the sorting order, check for it
+ if ( m_sortCol != wxNOT_FOUND && ascending != m_sortIsAscending )
+ {
+ m_sortIsAscending = ascending;
+
+ UpdateColumnSortingIndicator(m_sortCol);
+ }
+ }
+ else // we're changing the column used for sorting
+ {
+ const int sortColOld = m_sortCol;
+
+ // change it before updating the column as we want GetSortingColumn()
+ // to return the correct new value
+ m_sortCol = col;
+
+ if ( sortColOld != wxNOT_FOUND )
+ UpdateColumnSortingIndicator(sortColOld);
+
+ if ( m_sortCol != wxNOT_FOUND )
+ {
+ m_sortIsAscending = ascending;
+ UpdateColumnSortingIndicator(m_sortCol);
+ }
+ }
+}
+
+void wxGrid::DoColHeaderClick(int col)
+{
+ // we consider that the grid was resorted if this event is processed and
+ // not vetoed
+ if ( SendEvent(wxEVT_GRID_COL_SORT, -1, col) == 1 )
+ {
+ SetSortingColumn(col, IsSortingBy(col) ? !m_sortIsAscending : true);
+ Refresh();
+ }
+}
+
+void wxGrid::DoStartResizeCol(int col)
+{
+ m_dragRowOrCol = col;
+ m_dragLastPos = -1;
+ DoUpdateResizeColWidth(GetColWidth(m_dragRowOrCol));
+}
+
+void wxGrid::DoUpdateResizeCol(int x)
+{
+ int cw, ch, dummy, top;
+ m_gridWin->GetClientSize( &cw, &ch );
+ CalcUnscrolledPosition( 0, 0, &dummy, &top );
+
+ 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;
+}
+
+void wxGrid::DoUpdateResizeColWidth(int w)
+{
+ DoUpdateResizeCol(GetColLeft(m_dragRowOrCol) + w);
+}
+
+void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
+{
+ int x, y;
+ wxPoint pos( event.GetPosition() );
+ CalcUnscrolledPosition( pos.x, pos.y, &x, &y );
+
+ int col = XToCol(x);
+ if ( event.Dragging() )
+ {
+ if (!m_isDragging)
+ {
+ m_isDragging = true;
+ GetColLabelWindow()->CaptureMouse();
+
+ if ( m_cursorMode == WXGRID_CURSOR_MOVE_COL && col != -1 )
+ DoStartMoveCol(col);
+ }
+
+ if ( event.LeftIsDown() )
+ {
+ switch ( m_cursorMode )
+ {
+ case WXGRID_CURSOR_RESIZE_COL:
+ DoUpdateResizeCol(x);
+ break;
+
+ case WXGRID_CURSOR_SELECT_COL:
+ {
+ if ( col != -1 )
+ {
+ if ( m_selection )
+ m_selection->SelectCol(col, event);
+ }
+ }
+ break;
+
+ case WXGRID_CURSOR_MOVE_COL:
+ {
+ int posNew = XToPos(x);
+ int colNew = GetColAt(posNew);
+
+ // determine the position of the drop marker
+ int markerX;
+ if ( x >= GetColLeft(colNew) + (GetColWidth(colNew) / 2) )
+ markerX = GetColRight(colNew);
+ else
+ markerX = GetColLeft(colNew);
+
+ if ( markerX != m_dragLastPos )
+ {
+ wxClientDC dc( GetColLabelWindow() );
+ DoPrepareDC(dc);
+
+ int cw, ch;
+ GetColLabelWindow()->GetClientSize( &cw, &ch );
+
+ markerX++;
+
+ //Clean up the last indicator
+ if ( m_dragLastPos >= 0 )
+ {
+ wxPen pen( GetColLabelWindow()->GetBackgroundColour(), 2 );
+ dc.SetPen(pen);
+ dc.DrawLine( m_dragLastPos + 1, 0, m_dragLastPos + 1, ch );
+ dc.SetPen(wxNullPen);
+
+ if ( XToCol( m_dragLastPos ) != -1 )
+ DrawColLabel( dc, XToCol( m_dragLastPos ) );
+ }
+
+ const wxColour *color;
+ //Moving to the same place? Don't draw a marker
+ if ( colNew == m_dragRowOrCol )
+ color = wxLIGHT_GREY;
+ else
+ color = wxBLUE;
+
+ //Draw the marker
+ wxPen pen( *color, 2 );
+ dc.SetPen(pen);
+
+ dc.DrawLine( markerX, 0, markerX, ch );
+
+ dc.SetPen(wxNullPen);
+
+ m_dragLastPos = markerX - 1;
+ }
+ }
+ break;
+
+ // default label to suppress warnings about "enumeration value
+ // 'xxx' not handled in switch
+ default:
+ break;
+ }
+ }
+ return;
+ }
+
+ if ( m_isDragging && (event.Entering() || event.Leaving()) )
+ return;
+
+ if (m_isDragging)
+ {
+ if (GetColLabelWindow()->HasCapture())
+ GetColLabelWindow()->ReleaseMouse();
+ m_isDragging = false;
+ }
+
+ // ------------ Entering or leaving the window
+ //
+ if ( event.Entering() || event.Leaving() )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
+ }
+
+ // ------------ Left button pressed
+ //
+ else if ( event.LeftDown() )
+ {
+ int col = XToEdgeOfCol(x);
+ if ( col != wxNOT_FOUND && CanDragColSize(col) )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, GetColLabelWindow());
+ }
+ else // not a request to start resizing
+ {
+ col = XToCol(x);
+ if ( col >= 0 &&
+ !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
+ {
+ if ( m_canDragColMove )
+ {
+ //Show button as pressed
+ wxClientDC dc( GetColLabelWindow() );
+ int colLeft = GetColLeft( col );
+ int colRight = GetColRight( col ) - 1;
+ dc.SetPen( wxPen( GetColLabelWindow()->GetBackgroundColour(), 1 ) );
+ dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 );
+ dc.DrawLine( colLeft, 1, colRight, 1 );
+
+ ChangeCursorMode(WXGRID_CURSOR_MOVE_COL, GetColLabelWindow());
+ }
+ else
+ {
+ if ( !event.ShiftDown() && !event.CmdDown() )
+ ClearSelection();
+ if ( m_selection )
+ {
+ if ( event.ShiftDown() )
+ {
+ m_selection->SelectBlock
+ (
+ 0, m_currentCellCoords.GetCol(),
+ GetNumberRows() - 1, col,
+ event
+ );
+ }
+ else
+ {
+ m_selection->SelectCol(col, event);
+ }
+ }
+
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, GetColLabelWindow());
+ }
+ }
+ }
+ }
+
+ // ------------ Left double click
+ //
+ if ( event.LeftDClick() )
+ {
+ const int colEdge = XToEdgeOfCol(x);
+ if ( colEdge == -1 )
+ {
+ if ( col >= 0 &&
+ ! SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, col, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+ else
+ {
+ // adjust column width depending on label text
+ //
+ // TODO: generate RESIZING event, see #10754
+ AutoSizeColLabelSize( colEdge );
+
+ SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, colEdge, event);
+
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
+ m_dragLastPos = -1;
+ }
+ }
+
+ // ------------ Left button released
+ //
+ else if ( event.LeftUp() )
+ {
+ switch ( m_cursorMode )
+ {
+ case WXGRID_CURSOR_RESIZE_COL:
+ DoEndDragResizeCol(event);
+ break;
+
+ case WXGRID_CURSOR_MOVE_COL:
+ if ( m_dragLastPos == -1 || col == m_dragRowOrCol )
+ {
+ // the column didn't actually move anywhere
+ if ( col != -1 )
+ DoColHeaderClick(col);
+ m_colWindow->Refresh(); // "unpress" the column
+ }
+ else
+ {
+ DoEndMoveCol(XToPos(x));
+ }
+ break;
+
+ case WXGRID_CURSOR_SELECT_COL:
+ case WXGRID_CURSOR_SELECT_CELL:
+ case WXGRID_CURSOR_RESIZE_ROW:
+ case WXGRID_CURSOR_SELECT_ROW:
+ if ( col != -1 )
+ DoColHeaderClick(col);
+ break;
+ }
+
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
+ m_dragLastPos = -1;
+ }
+
+ // ------------ Right button down
+ //
+ else if ( event.RightDown() )
+ {
+ if ( col >= 0 &&
+ !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, col, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+
+ // ------------ Right double click
+ //
+ else if ( event.RightDClick() )
+ {
+ if ( col >= 0 &&
+ !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, col, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+
+ // ------------ No buttons down and mouse moving
+ //
+ else if ( event.Moving() )
+ {
+ m_dragRowOrCol = XToEdgeOfCol( x );
+ if ( m_dragRowOrCol >= 0 )
+ {
+ if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
+ {
+ if ( CanDragColSize(m_dragRowOrCol) )
+ ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, GetColLabelWindow(), false);
+ }
+ }
+ else if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow(), false);
+ }
+ }
+}
+
+void wxGrid::ProcessCornerLabelMouseEvent( wxMouseEvent& event )
+{
+ if ( event.LeftDown() )
+ {
+ // indicate corner label by having both row and
+ // col args == -1
+ //
+ if ( !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, event ) )
+ {
+ SelectAll();
+ }
+ }
+ else if ( event.LeftDClick() )
+ {
+ SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, event );
+ }
+ else if ( event.RightDown() )
+ {
+ if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+ else if ( event.RightDClick() )
+ {
+ if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, event ) )
+ {
+ // no default action at the moment
+ }
+ }
+}
+
+void wxGrid::CancelMouseCapture()
+{
+ // cancel operation currently in progress, whatever it is
+ if ( m_winCapture )
+ {
+ m_isDragging = false;
+ m_startDragPos = wxDefaultPosition;
+
+ m_cursorMode = WXGRID_CURSOR_SELECT_CELL;
+ m_winCapture->SetCursor( *wxSTANDARD_CURSOR );
+ m_winCapture = NULL;
+
+ // remove traces of whatever we drew on screen
+ Refresh();
+ }
+}
+
+void wxGrid::ChangeCursorMode(CursorMode mode,
+ wxWindow *win,
+ bool captureMouse)
+{
+#if wxUSE_LOG_TRACE
+ static const wxChar *const cursorModes[] =
+ {
+ wxT("SELECT_CELL"),
+ wxT("RESIZE_ROW"),
+ wxT("RESIZE_COL"),
+ wxT("SELECT_ROW"),
+ wxT("SELECT_COL"),
+ wxT("MOVE_COL"),
+ };
+
+ wxLogTrace(wxT("grid"),
+ wxT("wxGrid cursor mode (mouse capture for %s): %s -> %s"),
+ win == m_colWindow ? wxT("colLabelWin")
+ : win ? wxT("rowLabelWin")
+ : wxT("gridWin"),
+ cursorModes[m_cursorMode], cursorModes[mode]);
+#endif // wxUSE_LOG_TRACE
+
+ if ( mode == m_cursorMode &&
+ win == m_winCapture &&
+ captureMouse == (m_winCapture != NULL))
+ return;
+
+ if ( !win )
+ {
+ // by default use the grid itself
+ win = m_gridWin;
+ }
+
+ if ( m_winCapture )
+ {
+ m_winCapture->ReleaseMouse();
+ m_winCapture = NULL;
+ }
+
+ m_cursorMode = mode;
+
+ switch ( m_cursorMode )
+ {
+ case WXGRID_CURSOR_RESIZE_ROW:
+ win->SetCursor( m_rowResizeCursor );
+ break;
+
+ case WXGRID_CURSOR_RESIZE_COL:
+ win->SetCursor( m_colResizeCursor );
+ break;
+
+ case WXGRID_CURSOR_MOVE_COL:
+ win->SetCursor( wxCursor(wxCURSOR_HAND) );
+ break;
+
+ default:
+ win->SetCursor( *wxSTANDARD_CURSOR );
+ break;
+ }
+
+ // we need to capture mouse when resizing
+ bool resize = m_cursorMode == WXGRID_CURSOR_RESIZE_ROW ||
+ m_cursorMode == WXGRID_CURSOR_RESIZE_COL;
+
+ if ( captureMouse && resize )
+ {
+ win->CaptureMouse();
+ m_winCapture = win;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// grid mouse event processing
+// ----------------------------------------------------------------------------
+
+void
+wxGrid::DoGridCellDrag(wxMouseEvent& event,
+ const wxGridCellCoords& coords,
+ bool isFirstDrag)
+{
+ if ( coords == wxGridNoCellCoords )
+ return; // we're outside any valid cell
+
+ // Hide the edit control, so it won't interfere with drag-shrinking.
+ if ( IsCellEditControlShown() )
+ {
+ HideCellEditControl();
+ SaveEditControlValue();
+ }
+
+ switch ( event.GetModifiers() )
+ {
+ case wxMOD_CMD:
+ if ( m_selectedBlockCorner == wxGridNoCellCoords)
+ m_selectedBlockCorner = coords;
+ UpdateBlockBeingSelected(m_selectedBlockCorner, coords);
+ break;
+
+ case wxMOD_NONE:
+ if ( CanDragCell() )
+ {
+ if ( isFirstDrag )
+ {
+ if ( m_selectedBlockCorner == wxGridNoCellCoords)
+ m_selectedBlockCorner = coords;
+
+ SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event);
+ return;
+ }
+ }
+
+ UpdateBlockBeingSelected(m_currentCellCoords, coords);
+ break;
+
+ default:
+ // we don't handle the other key modifiers
+ event.Skip();
+ }
+}
+
+void wxGrid::DoGridLineDrag(wxMouseEvent& event, const wxGridOperations& oper)
+{
+ wxClientDC dc(m_gridWin);
+ PrepareDC(dc);
+ dc.SetLogicalFunction(wxINVERT);
+
+ 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;
+ }
+
+ if ( abs(m_startDragPos.x - pt.x) <= DRAG_SENSITIVITY &&
+ abs(m_startDragPos.y - pt.y) <= DRAG_SENSITIVITY )
+ return;
+ }
+
+ const bool isFirstDrag = !m_isDragging;
+ m_isDragging = true;
+
+ switch ( m_cursorMode )
+ {
+ case WXGRID_CURSOR_SELECT_CELL:
+ DoGridCellDrag(event, coords, isFirstDrag);
+ break;
+
+ case WXGRID_CURSOR_RESIZE_ROW:
+ DoGridLineDrag(event, wxGridRowOperations());
+ break;
+
+ case WXGRID_CURSOR_RESIZE_COL:
+ DoGridLineDrag(event, wxGridColumnOperations());
+ break;
+
+ default:
+ event.Skip();
+ }
+
+ if ( isFirstDrag )
+ {
+ wxASSERT_MSG( !m_winCapture, "shouldn't capture the mouse twice" );
+
+ m_winCapture = m_gridWin;
+ m_winCapture->CaptureMouse();
+ }
+}
+
+void
+wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
+ const wxGridCellCoords& coords,
+ const wxPoint& pos)
+{
+ if ( SendEvent(wxEVT_GRID_CELL_LEFT_CLICK, coords, event) )
+ {
+ // event handled by user code, no need to do anything here
+ return;
+ }
+
+ if ( !event.CmdDown() )
+ ClearSelection();
+
+ if ( event.ShiftDown() )
+ {
+ if ( m_selection )
+ {
+ m_selection->SelectBlock(m_currentCellCoords, coords, event);
+ m_selectedBlockCorner = coords;
+ }
+ }
+ else if ( XToEdgeOfCol(pos.x) < 0 && YToEdgeOfRow(pos.y) < 0 )
+ {
+ DisableCellEditControl();
+ MakeCellVisible( coords );
+
+ if ( event.CmdDown() )
+ {
+ if ( m_selection )
+ {
+ m_selection->ToggleCellSelection(coords, event);
+ }
+
+ m_selectedBlockTopLeft = wxGridNoCellCoords;
+ m_selectedBlockBottomRight = wxGridNoCellCoords;
+ m_selectedBlockCorner = coords;
+ }
+ else
+ {
+ m_waitForSlowClick = m_currentCellCoords == coords &&
+ coords != wxGridNoCellCoords;
+ SetCurrentCell( coords );
+ }
+ }
+}
+
+void
+wxGrid::DoGridCellLeftDClick(wxMouseEvent& event,
+ const wxGridCellCoords& coords,
+ const wxPoint& pos)
+{
+ if ( XToEdgeOfCol(pos.x) < 0 && YToEdgeOfRow(pos.y) < 0 )
+ {
+ if ( !SendEvent(wxEVT_GRID_CELL_LEFT_DCLICK, coords, event) )
+ {
+ // we want double click to select a cell and start editing
+ // (i.e. to behave in same way as sequence of two slow clicks):
+ m_waitForSlowClick = true;
+ }
+ }
+}
+
+void
+wxGrid::DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords)
+{
+ if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
+ {
+ if (m_winCapture)
+ {
+ m_winCapture->ReleaseMouse();
+ m_winCapture = NULL;
+ }
+
+ if ( coords == m_currentCellCoords && m_waitForSlowClick && CanEnableCellControl() )
+ {
+ ClearSelection();
+ EnableCellEditControl();
+
+ wxGridCellAttr *attr = GetCellAttr(coords);
+ wxGridCellEditor *editor = attr->GetEditor(this, coords.GetRow(), coords.GetCol());
+ editor->StartingClick();
+ editor->DecRef();
+ attr->DecRef();
+
+ m_waitForSlowClick = false;
+ }
+ else if ( m_selectedBlockTopLeft != wxGridNoCellCoords &&
+ m_selectedBlockBottomRight != wxGridNoCellCoords )
+ {
+ if ( m_selection )
+ {
+ m_selection->SelectBlock( m_selectedBlockTopLeft,
+ m_selectedBlockBottomRight,
+ event );
+ }
+
+ m_selectedBlockTopLeft = wxGridNoCellCoords;
+ m_selectedBlockBottomRight = wxGridNoCellCoords;
+
+ // Show the edit control, if it has been hidden for
+ // drag-shrinking.
+ ShowCellEditControl();
+ }
+ }
+ else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
+ DoEndDragResizeRow(event);
+ }
+ else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
+ DoEndDragResizeCol(event);
+ }
+
+ m_dragLastPos = -1;
+}
+
+void
+wxGrid::DoGridMouseMoveEvent(wxMouseEvent& WXUNUSED(event),
+ const wxGridCellCoords& coords,
+ const wxPoint& pos)
+{
+ if ( coords.GetRow() < 0 || coords.GetCol() < 0 )
+ {
+ // out of grid cell area
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
+ return;
+ }
+
+ int dragRow = YToEdgeOfRow( pos.y );
+ int dragCol = XToEdgeOfCol( pos.x );
+
+ // Dragging on the corner of a cell to resize in both
+ // directions is not implemented yet...
+ //
+ if ( dragRow >= 0 && dragCol >= 0 )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
+ return;
+ }
+
+ if ( dragRow >= 0 && CanDragGridSize() && CanDragRowSize(dragRow) )
+ {
+ if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
+ {
+ m_dragRowOrCol = dragRow;
+ ChangeCursorMode(WXGRID_CURSOR_RESIZE_ROW, NULL, false);
+ }
+ }
+ // When using the native header window we can only resize the columns by
+ // dragging the dividers in it because we can't make it enter into the
+ // column resizing mode programmatically
+ else if ( dragCol >= 0 && !m_useNativeHeader &&
+ CanDragGridSize() && CanDragColSize(dragCol) )
+ {
+ if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
+ {
+ m_dragRowOrCol = dragCol;
+ ChangeCursorMode(WXGRID_CURSOR_RESIZE_COL, NULL, false);
+ }
+ }
+ else // Neither on a row or col edge
+ {
+ if ( m_cursorMode != WXGRID_CURSOR_SELECT_CELL )
+ {
+ ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL);
+ }
+ }
+}
+
+void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event)
+{
+ if ( event.Entering() || event.Leaving() )
+ {
+ // we don't care about these events but we must not reset m_isDragging
+ // if they happen so return before anything else is done
+ event.Skip();
+ return;
+ }
+
+ const wxPoint pos = CalcUnscrolledPosition(event.GetPosition());
+
+ // coordinates of the cell under mouse
+ wxGridCellCoords coords = XYToCell(pos);
+
+ int cell_rows, cell_cols;
+ GetCellSize( coords.GetRow(), coords.GetCol(), &cell_rows, &cell_cols );
+ if ( (cell_rows < 0) || (cell_cols < 0) )
+ {
+ coords.SetRow(coords.GetRow() + cell_rows);
+ coords.SetCol(coords.GetCol() + cell_cols);
+ }
+
+ if ( event.Dragging() )
+ {
+ if ( event.LeftIsDown() )
+ DoGridDragEvent(event, coords);
+ else
+ event.Skip();
+ return;
+ }
+
+ m_isDragging = false;
+ m_startDragPos = wxDefaultPosition;
+
+ // deal with various button presses
+ if ( event.IsButton() )
+ {
+ if ( coords != wxGridNoCellCoords )
+ {
+ DisableCellEditControl();
+
+ if ( event.LeftDown() )
+ DoGridCellLeftDown(event, coords, pos);
+ else if ( event.LeftDClick() )
+ DoGridCellLeftDClick(event, coords, pos);
+ else if ( event.RightDown() )
+ SendEvent(wxEVT_GRID_CELL_RIGHT_CLICK, coords, event);
+ else if ( event.RightDClick() )
+ SendEvent(wxEVT_GRID_CELL_RIGHT_DCLICK, coords, event);
+ }
+
+ // this one should be called even if we're not over any cell
+ if ( event.LeftUp() )
+ {
+ DoGridCellLeftUp(event, coords);
+ }
+ }
+ else if ( event.Moving() )
+ {
+ DoGridMouseMoveEvent(event, coords, pos);
+ }
+ else // unknown mouse event?
+ {
+ event.Skip();
+ }
+}
+
+// this function returns true only if the size really changed
+bool wxGrid::DoEndDragResizeLine(const wxGridOperations& oper)
+{
+ if ( m_dragLastPos == -1 )
+ return false;
+
+ const wxGridOperations& doper = oper.Dual();
+
+ const wxSize size = m_gridWin->GetClientSize();
+
+ const wxPoint ptOrigin = CalcUnscrolledPosition(wxPoint(0, 0));
+
+ // erase the last line we drew
+ wxClientDC dc(m_gridWin);
+ PrepareDC(dc);
+ dc.SetLogicalFunction(wxINVERT);
+
+ const int posLineStart = oper.Select(ptOrigin);
+ const int posLineEnd = oper.Select(ptOrigin) + oper.Select(size);
+
+ oper.DrawParallelLine(dc, posLineStart, posLineEnd, m_dragLastPos);
+
+ // temporarily hide the edit control before resizing
+ HideCellEditControl();
+ SaveEditControlValue();
+
+ // do resize the line
+ const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);
+ const int lineSizeOld = oper.GetLineSize(this, m_dragRowOrCol);
+ oper.SetLineSize(this, m_dragRowOrCol,
+ wxMax(m_dragLastPos - lineStart,
+ oper.GetMinimalLineSize(this, m_dragRowOrCol)));
+ const bool
+ sizeChanged = oper.GetLineSize(this, m_dragRowOrCol) != lineSizeOld;
+
+ m_dragLastPos = -1;
+
+ // refresh now if we're not frozen
+ if ( !GetBatchCount() )
+ {
+ // we need to refresh everything beyond the resized line in the header
+ // window
+
+ // get the position from which to refresh in the other direction
+ wxRect rect(CellToRect(oper.MakeCoords(m_dragRowOrCol, 0)));
+ rect.SetPosition(CalcScrolledPosition(rect.GetPosition()));
+
+ // we only need the ordinate (for rows) or abscissa (for columns) here,
+ // and need to cover the entire window in the other direction
+ oper.Select(rect) = 0;
+
+ wxRect rectHeader(rect.GetPosition(),
+ oper.MakeSize
+ (
+ oper.GetHeaderWindowSize(this),
+ doper.Select(size) - doper.Select(rect)
+ ));
+
+ oper.GetHeaderWindow(this)->Refresh(true, &rectHeader);
+
+
+ // also refresh the grid window: extend the rectangle
+ if ( m_table )
+ {
+ oper.SelectSize(rect) = oper.Select(size);
+
+ int subtractLines = 0;
+ const int lineStart = oper.PosToLine(this, posLineStart);
+ if ( lineStart >= 0 )
+ {
+ // ensure that if we have a multi-cell block we redraw all of
+ // it by increasing the refresh area to cover it entirely if a
+ // part of it is affected
+ const int lineEnd = oper.PosToLine(this, posLineEnd, true);
+ for ( int line = lineStart; line < lineEnd; line++ )
+ {
+ int cellLines = oper.Select(
+ GetCellSize(oper.MakeCoords(m_dragRowOrCol, line)));
+ if ( cellLines < subtractLines )
+ subtractLines = cellLines;
+ }
+ }
+
+ int startPos =
+ oper.GetLineStartPos(this, m_dragRowOrCol + subtractLines);
+ startPos = doper.CalcScrolledPosition(this, startPos);
+
+ doper.Select(rect) = startPos;
+ doper.SelectSize(rect) = doper.Select(size) - startPos;
+
+ m_gridWin->Refresh(false, &rect);
+ }
+ }
+
+ // show the edit control back again
+ ShowCellEditControl();
+
+ return sizeChanged;
+}
+
+void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event)
+{
+ // TODO: generate RESIZING event, see #10754
+
+ if ( DoEndDragResizeLine(wxGridRowOperations()) )
+ SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event);
+}
+
+void wxGrid::DoEndDragResizeCol(const wxMouseEvent& event)
+{
+ // TODO: generate RESIZING event, see #10754
+
+ if ( DoEndDragResizeLine(wxGridColumnOperations()) )
+ SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event);
+}
+
+void wxGrid::DoStartMoveCol(int col)
+{
+ m_dragRowOrCol = col;
+}
+
+void wxGrid::DoEndMoveCol(int pos)
+{
+ wxASSERT_MSG( m_dragRowOrCol != -1, "no matching DoStartMoveCol?" );
+
+ if ( SendEvent(wxEVT_GRID_COL_MOVE, -1, m_dragRowOrCol) != -1 )
+ SetColPos(m_dragRowOrCol, pos);
+ //else: vetoed by user
+
+ m_dragRowOrCol = -1;
+}
+
+void wxGrid::RefreshAfterColPosChange()
+{
+ // recalculate the column rights as the column positions have changed,
+ // unless we calculate them dynamically because all columns widths are the
+ // same and it's easy to do
+ if ( !m_colWidths.empty() )
+ {
+ int colRight = 0;
+ for ( int colPos = 0; colPos < m_numCols; colPos++ )
+ {
+ int colID = GetColAt( colPos );
+
+ colRight += m_colWidths[colID];
+ m_colRights[colID] = colRight;
+ }
+ }
+
+ // and make the changes visible
+ if ( m_useNativeHeader )
+ {
+ if ( m_colAt.empty() )
+ GetGridColHeader()->ResetColumnsOrder();
+ else
+ GetGridColHeader()->SetColumnsOrder(m_colAt);
+ }
+ else
+ {
+ m_colWindow->Refresh();
+ }
+ m_gridWin->Refresh();
+}
+
+void wxGrid::SetColumnsOrder(const wxArrayInt& order)
+{
+ m_colAt = order;
+
+ RefreshAfterColPosChange();
+}
+
+void wxGrid::SetColPos(int idx, int pos)
+{
+ // we're going to need m_colAt now, initialize it if needed
+ if ( m_colAt.empty() )
+ {
+ m_colAt.reserve(m_numCols);
+ for ( int i = 0; i < m_numCols; i++ )
+ m_colAt.push_back(i);
+ }
+
+ wxHeaderCtrl::MoveColumnInOrderArray(m_colAt, idx, pos);
+
+ RefreshAfterColPosChange();
+}
+
+void wxGrid::ResetColPos()
+{
+ m_colAt.clear();
+
+ RefreshAfterColPosChange();
+}
+
+void wxGrid::EnableDragColMove( bool enable )
+{
+ if ( m_canDragColMove == enable )
+ return;
+
+ if ( m_useNativeHeader )
+ {
+ // update all columns to make them [not] reorderable
+ GetGridColHeader()->SetColumnCount(m_numCols);
+ }
+
+ m_canDragColMove = enable;
+
+ // we use to call ResetColPos() from here if !enable but this doesn't seem
+ // right as it would mean there would be no way to "freeze" the current
+ // columns order by disabling moving them after putting them in the desired
+ // order, whereas now you can always call ResetColPos() manually if needed
+}
+
+
+//
+// ------ interaction with data model
+//
+bool wxGrid::ProcessTableMessage( wxGridTableMessage& msg )
+{
+ switch ( msg.GetId() )
+ {
+ case wxGRIDTABLE_REQUEST_VIEW_GET_VALUES:
+ return GetModelValues();
+
+ case wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES:
+ return SetModelValues();
+
+ case wxGRIDTABLE_NOTIFY_ROWS_INSERTED:
+ case wxGRIDTABLE_NOTIFY_ROWS_APPENDED:
+ case wxGRIDTABLE_NOTIFY_ROWS_DELETED:
+ case wxGRIDTABLE_NOTIFY_COLS_INSERTED:
+ case wxGRIDTABLE_NOTIFY_COLS_APPENDED:
+ case wxGRIDTABLE_NOTIFY_COLS_DELETED:
+ return Redimension( msg );
+
+ default:
+ return false;
+ }
+}
+
+// The behaviour of this function depends on the grid table class
+// Clear() function. For the default wxGridStringTable class the
+// behaviour is to replace all cell contents with wxEmptyString but
+// not to change the number of rows or cols.
+//
+void wxGrid::ClearGrid()
+{
+ if ( m_table )
+ {
+ if (IsCellEditControlEnabled())
+ DisableCellEditControl();
+
+ m_table->Clear();
+ if (!GetBatchCount())
+ m_gridWin->Refresh();
+ }
+}
+
+bool
+wxGrid::DoModifyLines(bool (wxGridTableBase::*funcModify)(size_t, size_t),
+ int pos, int num, bool WXUNUSED(updateLabels) )
+{
+ wxCHECK_MSG( m_created, false, "must finish creating the grid first" );
+
+ if ( !m_table )
+ return false;
+
+ if ( IsCellEditControlEnabled() )
+ DisableCellEditControl();
+
+ return (m_table->*funcModify)(pos, num);
+
+ // the table will have sent the results of the insert row
+ // operation to this view object as a grid table message
+}
+
+bool
+wxGrid::DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t),
+ int num, bool WXUNUSED(updateLabels))
+{
+ wxCHECK_MSG( m_created, false, "must finish creating the grid first" );
+
+ if ( !m_table )
+ return false;
+
+ return (m_table->*funcAppend)(num);
+}
+
+// ----------------------------------------------------------------------------
+// event generation helpers
+// ----------------------------------------------------------------------------
+
+void
+wxGrid::SendGridSizeEvent(wxEventType type,
+ int row, int col,
+ const wxMouseEvent& mouseEv)
+{
+ int rowOrCol = row == -1 ? col : row;
+
+ wxGridSizeEvent gridEvt( GetId(),
+ type,
+ this,
+ rowOrCol,
+ mouseEv.GetX() + GetRowLabelSize(),
+ mouseEv.GetY() + GetColLabelSize(),
+ mouseEv);
+
+ GetEventHandler()->ProcessEvent(gridEvt);
+}
+
+// Generate a grid event based on a mouse event and return:
+// -1 if the event was vetoed
+// +1 if the event was processed (but not vetoed)
+// 0 if the event wasn't handled
+int
+wxGrid::SendEvent(const wxEventType type,
+ int row, int col,
+ const wxMouseEvent& mouseEv)
+{
+ bool claimed, vetoed;
+
+ if ( type == wxEVT_GRID_RANGE_SELECT )
+ {
+ // Right now, it should _never_ end up here!
+ wxGridRangeSelectEvent gridEvt( GetId(),
+ type,
+ this,
+ m_selectedBlockTopLeft,
+ m_selectedBlockBottomRight,
+ true,
+ mouseEv);
+
+ claimed = GetEventHandler()->ProcessEvent(gridEvt);
+ vetoed = !gridEvt.IsAllowed();
+ }
+ else if ( type == wxEVT_GRID_LABEL_LEFT_CLICK ||
+ type == wxEVT_GRID_LABEL_LEFT_DCLICK ||
+ type == wxEVT_GRID_LABEL_RIGHT_CLICK ||
+ type == wxEVT_GRID_LABEL_RIGHT_DCLICK )
+ {
+ wxPoint pos = mouseEv.GetPosition();
+
+ if ( mouseEv.GetEventObject() == GetGridRowLabelWindow() )
+ pos.y += GetColLabelSize();
+ if ( mouseEv.GetEventObject() == GetGridColLabelWindow() )
+ pos.x += GetRowLabelSize();
+
+ wxGridEvent gridEvt( GetId(),
+ type,
+ this,
+ row, col,
+ pos.x,
+ pos.y,
+ false,
+ mouseEv);
+ claimed = GetEventHandler()->ProcessEvent(gridEvt);
+ vetoed = !gridEvt.IsAllowed();
+ }
+ else
+ {
+ wxGridEvent gridEvt( GetId(),
+ type,
+ this,
+ row, col,
+ mouseEv.GetX() + GetRowLabelSize(),
+ mouseEv.GetY() + GetColLabelSize(),
+ false,
+ mouseEv);
+ claimed = GetEventHandler()->ProcessEvent(gridEvt);
+ vetoed = !gridEvt.IsAllowed();
+ }
+
+ // A Veto'd event may not be `claimed' so test this first
+ if (vetoed)
+ return -1;
+
+ return claimed ? 1 : 0;
+}
+
+// Generate a grid event of specified type, return value same as above
+//
+int
+wxGrid::SendEvent(const wxEventType type, int row, int col, const wxString& s)
+{
+ wxGridEvent gridEvt( GetId(), type, this, row, col );
+ gridEvt.SetString(s);
+
+ const bool claimed = GetEventHandler()->ProcessEvent(gridEvt);
+
+ // A Veto'd event may not be `claimed' so test this first
+ if ( !gridEvt.IsAllowed() )
+ return -1;
+
+ return claimed ? 1 : 0;
+}
+
+void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
+{
+ // needed to prevent zillions of paint events on MSW
+ wxPaintDC dc(this);
+}
+
+void wxGrid::Refresh(bool eraseb, const wxRect* rect)
+{
+ // Don't do anything if between Begin/EndBatch...
+ // EndBatch() will do all this on the last nested one anyway.
+ if ( m_created && !GetBatchCount() )
+ {
+ // Refresh to get correct scrolled position:
+ wxScrolledWindow::Refresh(eraseb, rect);
+
+ if (rect)
+ {
+ int rect_x, rect_y, rectWidth, rectHeight;
+ int width_label, width_cell, height_label, height_cell;
+ int x, y;
+
+ // Copy rectangle can get scroll offsets..
+ rect_x = rect->GetX();
+ rect_y = rect->GetY();
+ rectWidth = rect->GetWidth();
+ rectHeight = rect->GetHeight();
+
+ width_label = m_rowLabelWidth - rect_x;
+ if (width_label > rectWidth)
+ width_label = rectWidth;
+
+ height_label = m_colLabelHeight - rect_y;
+ if (height_label > rectHeight)
+ height_label = rectHeight;
+
+ if (rect_x > m_rowLabelWidth)
+ {
+ x = rect_x - m_rowLabelWidth;
+ width_cell = rectWidth;
+ }
+ else
+ {
+ x = 0;
+ width_cell = rectWidth - (m_rowLabelWidth - rect_x);
+ }
+
+ if (rect_y > m_colLabelHeight)
+ {
+ y = rect_y - m_colLabelHeight;
+ height_cell = rectHeight;
+ }
+ else
+ {
+ y = 0;
+ height_cell = rectHeight - (m_colLabelHeight - rect_y);
+ }
+
+ // Paint corner label part intersecting rect.
+ if ( width_label > 0 && height_label > 0 )
+ {
+ wxRect anotherrect(rect_x, rect_y, width_label, height_label);
+ m_cornerLabelWin->Refresh(eraseb, &anotherrect);
+ }
+
+ // Paint col labels part intersecting rect.
+ if ( width_cell > 0 && height_label > 0 )
+ {
+ wxRect anotherrect(x, rect_y, width_cell, height_label);
+ m_colWindow->Refresh(eraseb, &anotherrect);
+ }
+
+ // Paint row labels part intersecting rect.
+ if ( width_label > 0 && height_cell > 0 )
+ {
+ wxRect anotherrect(rect_x, y, width_label, height_cell);
+ m_rowLabelWin->Refresh(eraseb, &anotherrect);
+ }
+
+ // Paint cell area part intersecting rect.
+ if ( width_cell > 0 && height_cell > 0 )
+ {
+ wxRect anotherrect(x, y, width_cell, height_cell);
+ m_gridWin->Refresh(eraseb, &anotherrect);
+ }
+ }
+ else
+ {
+ m_cornerLabelWin->Refresh(eraseb, NULL);
+ m_colWindow->Refresh(eraseb, NULL);
+ m_rowLabelWin->Refresh(eraseb, NULL);
+ m_gridWin->Refresh(eraseb, NULL);
+ }
+ }
+}
+
+void wxGrid::OnSize(wxSizeEvent& WXUNUSED(event))
+{
+ if (m_targetWindow != this) // check whether initialisation has been done
+ {
+ // reposition our children windows
+ CalcWindowSizes();
+ }
+}
+
+void wxGrid::OnKeyDown( wxKeyEvent& event )
+{
+ if ( m_inOnKeyDown )
+ {
+ // shouldn't be here - we are going round in circles...
+ //
+ wxFAIL_MSG( wxT("wxGrid::OnKeyDown called while already active") );
+ }
+
+ m_inOnKeyDown = true;
+
+ // propagate the event up and see if it gets processed
+ wxWindow *parent = GetParent();
+ wxKeyEvent keyEvt( event );
+ keyEvt.SetEventObject( parent );
+
+ if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
+ {
+ if (GetLayoutDirection() == wxLayout_RightToLeft)
+ {
+ if (event.GetKeyCode() == WXK_RIGHT)
+ event.m_keyCode = WXK_LEFT;
+ else if (event.GetKeyCode() == WXK_LEFT)
+ event.m_keyCode = WXK_RIGHT;
+ }
+
+ // try local handlers
+ switch ( event.GetKeyCode() )
+ {
+ case WXK_UP:
+ if ( event.ControlDown() )
+ MoveCursorUpBlock( event.ShiftDown() );
+ else
+ MoveCursorUp( event.ShiftDown() );
+ break;
+
+ case WXK_DOWN:
+ if ( event.ControlDown() )
+ MoveCursorDownBlock( event.ShiftDown() );
+ else
+ MoveCursorDown( event.ShiftDown() );
+ break;
+
+ case WXK_LEFT:
+ if ( event.ControlDown() )
+ MoveCursorLeftBlock( event.ShiftDown() );
+ else
+ MoveCursorLeft( event.ShiftDown() );
+ break;
+
+ case WXK_RIGHT:
+ if ( event.ControlDown() )
+ MoveCursorRightBlock( event.ShiftDown() );
+ else
+ MoveCursorRight( event.ShiftDown() );
+ break;
+
+ case WXK_RETURN:
+ case WXK_NUMPAD_ENTER:
+ if ( event.ControlDown() )
+ {
+ event.Skip(); // to let the edit control have the return
+ }
+ else
+ {
+ if ( GetGridCursorRow() < GetNumberRows()-1 )
+ {
+ MoveCursorDown( event.ShiftDown() );
+ }
+ else
+ {
+ // at the bottom of a column
+ DisableCellEditControl();
+ }
+ }
+ break;
+
+ case WXK_ESCAPE:
+ ClearSelection();
+ break;
+
+ case WXK_TAB:
+ if (event.ShiftDown())
+ {
+ if ( GetGridCursorCol() > 0 )
+ {
+ MoveCursorLeft( false );
+ }
+ else
+ {
+ // at left of grid
+ DisableCellEditControl();
+ }
+ }
+ else
+ {
+ if ( GetGridCursorCol() < GetNumberCols() - 1 )
+ {
+ MoveCursorRight( false );
+ }
+ else
+ {
+ // at right of grid
+ DisableCellEditControl();
+ }
+ }
+ break;
+
+ case WXK_HOME:
+ if ( event.ControlDown() )
+ {
+ GoToCell(0, 0);
+ }
+ else
+ {
+ event.Skip();
+ }
+ break;
+
+ case WXK_END:
+ if ( event.ControlDown() )
+ {
+ GoToCell(m_numRows - 1, m_numCols - 1);
+ }
+ else
+ {
+ event.Skip();
+ }
+ break;
+
+ case WXK_PAGEUP:
+ MovePageUp();
+ break;
+
+ case WXK_PAGEDOWN:
+ MovePageDown();
+ break;
+
+ case WXK_SPACE:
+ // Ctrl-Space selects the current column, Shift-Space -- the
+ // current row and Ctrl-Shift-Space -- everything
+ switch ( m_selection ? event.GetModifiers() : wxMOD_NONE )
+ {
+ case wxMOD_CONTROL:
+ m_selection->SelectCol(m_currentCellCoords.GetCol());
+ break;
+
+ case wxMOD_SHIFT:
+ m_selection->SelectRow(m_currentCellCoords.GetRow());
+ break;
+
+ case wxMOD_CONTROL | wxMOD_SHIFT:
+ m_selection->SelectBlock(0, 0,
+ m_numRows - 1, m_numCols - 1);
+ break;
+
+ case wxMOD_NONE:
+ if ( !IsEditable() )
+ {
+ MoveCursorRight(false);
+ break;
+ }
+ //else: fall through
+
+ default:
+ event.Skip();
+ }
+ break;
+
+ default:
+ event.Skip();
+ break;
+ }
+ }
+
+ m_inOnKeyDown = false;
+}
+
+void wxGrid::OnKeyUp( wxKeyEvent& event )
+{
+ // try local handlers
+ //
+ if ( event.GetKeyCode() == WXK_SHIFT )
+ {
+ if ( m_selectedBlockTopLeft != wxGridNoCellCoords &&
+ m_selectedBlockBottomRight != wxGridNoCellCoords )
+ {
+ if ( m_selection )
+ {
+ m_selection->SelectBlock(
+ m_selectedBlockTopLeft,
+ m_selectedBlockBottomRight,
+ event);
+ }
+ }
+
+ m_selectedBlockTopLeft = wxGridNoCellCoords;
+ m_selectedBlockBottomRight = wxGridNoCellCoords;
+ m_selectedBlockCorner = wxGridNoCellCoords;
+ }
+}
+
+void wxGrid::OnChar( wxKeyEvent& event )
+{
+ // is it possible to edit the current cell at all?
+ if ( !IsCellEditControlEnabled() && CanEnableCellControl() )
+ {
+ // yes, now check whether the cells editor accepts the key
+ int row = m_currentCellCoords.GetRow();
+ int col = m_currentCellCoords.GetCol();
+ wxGridCellAttr *attr = GetCellAttr(row, col);
+ wxGridCellEditor *editor = attr->GetEditor(this, row, col);
+
+ // <F2> is special and will always start editing, for
+ // other keys - ask the editor itself
+ if ( (event.GetKeyCode() == WXK_F2 && !event.HasModifiers())
+ || editor->IsAcceptedKey(event) )
+ {
+ // ensure cell is visble
+ MakeCellVisible(row, col);
+ EnableCellEditControl();
+
+ // a problem can arise if the cell is not completely
+ // visible (even after calling MakeCellVisible the
+ // control is not created and calling StartingKey will
+ // crash the app
+ if ( event.GetKeyCode() != WXK_F2 && editor->IsCreated() && m_cellEditCtrlEnabled )
+ editor->StartingKey(event);
+ }
+ else
+ {
+ event.Skip();
+ }
+
+ editor->DecRef();
+ attr->DecRef();
+ }
+ else
+ {
+ event.Skip();
+ }
+}
+
+void wxGrid::OnEraseBackground(wxEraseEvent&)
+{
+}
+
+bool wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
+{
+ if ( SendEvent(wxEVT_GRID_SELECT_CELL, coords) == -1 )
+ {
+ // the event has been vetoed - do nothing
+ return false;
+ }
+
+#if !defined(__WXMAC__)
+ wxClientDC dc( m_gridWin );
+ PrepareDC( dc );
+#endif
+
+ if ( m_currentCellCoords != wxGridNoCellCoords )
+ {
+ DisableCellEditControl();
+
+ if ( IsVisible( m_currentCellCoords, false ) )
+ {
+ wxRect r;
+ r = BlockToDeviceRect( m_currentCellCoords, m_currentCellCoords );
+ if ( !m_gridLinesEnabled )
+ {
+ r.x--;
+ r.y--;
+ r.width++;
+ r.height++;
+ }
+
+ wxGridCellCoordsArray cells = CalcCellsExposed( r );
+
+ // Otherwise refresh redraws the highlight!
+ m_currentCellCoords = coords;
+
+#if defined(__WXMAC__)
+ m_gridWin->Refresh(true /*, & r */);
+#else
+ DrawGridCellArea( dc, cells );
+ DrawAllGridLines( dc, r );
+#endif
+ }
+ }
+
+ m_currentCellCoords = coords;
+
+ wxGridCellAttr *attr = GetCellAttr( coords );
+#if !defined(__WXMAC__)
+ DrawCellHighlight( dc, attr );
+#endif
+ attr->DecRef();
+
+ return true;
+}
+
+void
+wxGrid::UpdateBlockBeingSelected(int topRow, int leftCol,
+ int bottomRow, int rightCol)
+{
+ if ( m_selection )
+ {
+ switch ( m_selection->GetSelectionMode() )
+ {
+ default:
+ wxFAIL_MSG( "unknown selection mode" );
+ // fall through
+
+ case wxGridSelectCells:
+ // arbitrary blocks selection allowed so just use the cell
+ // coordinates as is
+ break;
+
+ case wxGridSelectRows:
+ // only full rows selection allowd, ensure that we do select
+ // full rows
+ leftCol = 0;
+ rightCol = GetNumberCols() - 1;
+ break;
+
+ case wxGridSelectColumns:
+ // same as above but for columns
+ topRow = 0;
+ bottomRow = GetNumberRows() - 1;
+ break;
+
+ case wxGridSelectRowsOrColumns:
+ // in this mode we can select only full rows or full columns so
+ // it doesn't make sense to select blocks at all (and we can't
+ // extend the block because there is no preferred direction, we
+ // could only extend it to cover the entire grid but this is
+ // not useful)
+ return;
+ }
+ }
+
+ m_selectedBlockCorner = wxGridCellCoords(bottomRow, rightCol);
+ MakeCellVisible(m_selectedBlockCorner);
+
+ EnsureFirstLessThanSecond(topRow, bottomRow);
+ EnsureFirstLessThanSecond(leftCol, rightCol);
+
+ wxGridCellCoords updateTopLeft = wxGridCellCoords(topRow, leftCol),
+ updateBottomRight = wxGridCellCoords(bottomRow, rightCol);
+
+ // First the case that we selected a completely new area
+ if ( m_selectedBlockTopLeft == wxGridNoCellCoords ||
+ m_selectedBlockBottomRight == wxGridNoCellCoords )
+ {
+ wxRect rect;
+ rect = BlockToDeviceRect( wxGridCellCoords ( topRow, leftCol ),
+ wxGridCellCoords ( bottomRow, rightCol ) );
+ m_gridWin->Refresh( false, &rect );
+ }
+
+ // Now handle changing an existing selection area.
+ else if ( m_selectedBlockTopLeft != updateTopLeft ||
+ m_selectedBlockBottomRight != updateBottomRight )
+ {
+ // Compute two optimal update rectangles:
+ // Either one rectangle is a real subset of the
+ // other, or they are (almost) disjoint!
+ wxRect rect[4];
+ bool need_refresh[4];
+ need_refresh[0] =
+ need_refresh[1] =
+ need_refresh[2] =
+ need_refresh[3] = false;
+ int i;
+
+ // Store intermediate values
+ wxCoord oldLeft = m_selectedBlockTopLeft.GetCol();
+ wxCoord oldTop = m_selectedBlockTopLeft.GetRow();
+ wxCoord oldRight = m_selectedBlockBottomRight.GetCol();
+ wxCoord oldBottom = m_selectedBlockBottomRight.GetRow();
+
+ // Determine the outer/inner coordinates.
+ EnsureFirstLessThanSecond(oldLeft, leftCol);
+ EnsureFirstLessThanSecond(oldTop, topRow);
+ EnsureFirstLessThanSecond(rightCol, oldRight);
+ EnsureFirstLessThanSecond(bottomRow, oldBottom);
+
+ // Now, either the stuff marked old is the outer
+ // rectangle or we don't have a situation where one
+ // is contained in the other.
+
+ if ( oldLeft < leftCol )
+ {
+ // Refresh the newly selected or deselected
+ // area to the left of the old or new selection.
+ need_refresh[0] = true;
+ rect[0] = BlockToDeviceRect(
+ wxGridCellCoords( oldTop, oldLeft ),
+ wxGridCellCoords( oldBottom, leftCol - 1 ) );
+ }
+
+ if ( oldTop < topRow )
+ {
+ // Refresh the newly selected or deselected
+ // area above the old or new selection.
+ need_refresh[1] = true;
+ rect[1] = BlockToDeviceRect(
+ wxGridCellCoords( oldTop, leftCol ),
+ wxGridCellCoords( topRow - 1, rightCol ) );
+ }
+
+ if ( oldRight > rightCol )
+ {
+ // Refresh the newly selected or deselected
+ // area to the right of the old or new selection.
+ need_refresh[2] = true;
+ rect[2] = BlockToDeviceRect(
+ wxGridCellCoords( oldTop, rightCol + 1 ),
+ wxGridCellCoords( oldBottom, oldRight ) );
+ }
+
+ if ( oldBottom > bottomRow )
+ {
+ // Refresh the newly selected or deselected
+ // area below the old or new selection.
+ need_refresh[3] = true;
+ rect[3] = BlockToDeviceRect(
+ wxGridCellCoords( bottomRow + 1, leftCol ),
+ wxGridCellCoords( oldBottom, rightCol ) );
+ }
+
+ // various Refresh() calls
+ for (i = 0; i < 4; i++ )
+ if ( need_refresh[i] && rect[i] != wxGridNoCellRect )
+ m_gridWin->Refresh( false, &(rect[i]) );
+ }
+
+ // change selection
+ m_selectedBlockTopLeft = updateTopLeft;
+ m_selectedBlockBottomRight = updateBottomRight;
+}
+
+//
+// ------ functions to get/send data (see also public functions)
+//
+
+bool wxGrid::GetModelValues()
+{
+ // Hide the editor, so it won't hide a changed value.
+ HideCellEditControl();
+
+ if ( m_table )
+ {
+ // all we need to do is repaint the grid
+ //
+ m_gridWin->Refresh();
+ return true;
+ }