Use GetCellSize() return value instead of checking rows/columns
No real changes, just use the value returned by the function to determine if the cell is inside a multi-cell, instead of comparing rows/columns with 0 to make code slightly more readable and self explanatory.
This commit is contained in:
@@ -4742,8 +4742,8 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG
|
|||||||
wxGridCellCoords coords = XYToCell(pos, gridWindow);
|
wxGridCellCoords coords = XYToCell(pos, gridWindow);
|
||||||
|
|
||||||
int cell_rows, cell_cols;
|
int cell_rows, cell_cols;
|
||||||
GetCellSize( coords.GetRow(), coords.GetCol(), &cell_rows, &cell_cols );
|
if ( GetCellSize( coords.GetRow(), coords.GetCol(), &cell_rows, &cell_cols )
|
||||||
if ( (cell_rows < 0) || (cell_cols < 0) )
|
== CellSpan_Inside )
|
||||||
{
|
{
|
||||||
coords.SetRow(coords.GetRow() + cell_rows);
|
coords.SetRow(coords.GetRow() + cell_rows);
|
||||||
coords.SetCol(coords.GetCol() + cell_cols);
|
coords.SetCol(coords.GetCol() + cell_cols);
|
||||||
@@ -6135,10 +6135,9 @@ void wxGrid::DrawGridCellArea( wxDC& dc, const wxGridCellCoordsArray& cells )
|
|||||||
int row, col, cell_rows, cell_cols;
|
int row, col, cell_rows, cell_cols;
|
||||||
row = cells[i].GetRow();
|
row = cells[i].GetRow();
|
||||||
col = cells[i].GetCol();
|
col = cells[i].GetCol();
|
||||||
GetCellSize( row, col, &cell_rows, &cell_cols );
|
|
||||||
|
|
||||||
// If this cell is part of a multicell block, find owner for repaint
|
// If this cell is part of a multicell block, find owner for repaint
|
||||||
if ( cell_rows <= 0 || cell_cols <= 0 )
|
if ( GetCellSize( row, col, &cell_rows, &cell_cols ) == CellSpan_Inside )
|
||||||
{
|
{
|
||||||
wxGridCellCoords cell( row + cell_rows, col + cell_cols );
|
wxGridCellCoords cell( row + cell_rows, col + cell_cols );
|
||||||
bool marked = false;
|
bool marked = false;
|
||||||
@@ -6506,26 +6505,31 @@ wxGrid::DrawRangeGridLines(wxDC& dc,
|
|||||||
for ( int col = topLeft.GetCol(); col <= bottomRight.GetCol(); col++ )
|
for ( int col = topLeft.GetCol(); col <= bottomRight.GetCol(); col++ )
|
||||||
{
|
{
|
||||||
int cell_rows, cell_cols;
|
int cell_rows, cell_cols;
|
||||||
GetCellSize( row, col, &cell_rows, &cell_cols );
|
switch ( GetCellSize( row, col, &cell_rows, &cell_cols ) )
|
||||||
if ( cell_rows > 1 || cell_cols > 1 ) // multi cell
|
|
||||||
{
|
{
|
||||||
rect = CellToRect( row, col );
|
case CellSpan_Main: // multi cell
|
||||||
// cater for scaling
|
rect = CellToRect( row, col );
|
||||||
// device origin already set in ::Render() for x, y
|
// cater for scaling
|
||||||
rect.x = dc.LogicalToDeviceX( rect.x );
|
// device origin already set in ::Render() for x, y
|
||||||
rect.y = dc.LogicalToDeviceY( rect.y );
|
rect.x = dc.LogicalToDeviceX( rect.x );
|
||||||
rect.width = dc.LogicalToDeviceXRel( rect.width );
|
rect.y = dc.LogicalToDeviceY( rect.y );
|
||||||
rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1;
|
rect.width = dc.LogicalToDeviceXRel( rect.width );
|
||||||
clippedcells.Subtract( rect );
|
rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1;
|
||||||
}
|
clippedcells.Subtract( rect );
|
||||||
else if ( cell_rows < 0 || cell_cols < 0 ) // part of multicell
|
break;
|
||||||
{
|
|
||||||
rect = CellToRect( row + cell_rows, col + cell_cols );
|
case CellSpan_Inside: // part of multicell
|
||||||
rect.x = dc.LogicalToDeviceX( rect.x );
|
rect = CellToRect( row + cell_rows, col + cell_cols );
|
||||||
rect.y = dc.LogicalToDeviceY( rect.y );
|
rect.x = dc.LogicalToDeviceX( rect.x );
|
||||||
rect.width = dc.LogicalToDeviceXRel( rect.width );
|
rect.y = dc.LogicalToDeviceY( rect.y );
|
||||||
rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1;
|
rect.width = dc.LogicalToDeviceXRel( rect.width );
|
||||||
clippedcells.Subtract( rect );
|
rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1;
|
||||||
|
clippedcells.Subtract( rect );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CellSpan_None:
|
||||||
|
// Nothing special to do.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6597,20 +6601,25 @@ void wxGrid::DrawAllGridWindowLines(wxDC& dc, const wxRegion & WXUNUSED(reg), wx
|
|||||||
{
|
{
|
||||||
int i = GetColAt( colPos );
|
int i = GetColAt( colPos );
|
||||||
|
|
||||||
GetCellSize( j, i, &cell_rows, &cell_cols );
|
switch ( GetCellSize( j, i, &cell_rows, &cell_cols ) )
|
||||||
if ((cell_rows > 1) || (cell_cols > 1))
|
|
||||||
{
|
{
|
||||||
rect = CellToRect(j,i);
|
case CellSpan_Main:
|
||||||
rect.Offset(-gridOffset);
|
rect = CellToRect(j,i);
|
||||||
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
rect.Offset(-gridOffset);
|
||||||
clippedcells.Subtract(rect);
|
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
||||||
}
|
clippedcells.Subtract(rect);
|
||||||
else if ((cell_rows < 0) || (cell_cols < 0))
|
break;
|
||||||
{
|
|
||||||
rect = CellToRect(j + cell_rows, i + cell_cols);
|
case CellSpan_Inside:
|
||||||
rect.Offset(-gridOffset);
|
rect = CellToRect(j + cell_rows, i + cell_cols);
|
||||||
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
rect.Offset(-gridOffset);
|
||||||
clippedcells.Subtract(rect);
|
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
||||||
|
clippedcells.Subtract(rect);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CellSpan_None:
|
||||||
|
// Nothing special to do.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7228,8 +7237,7 @@ void wxGrid::DoShowCellEditControl()
|
|||||||
|
|
||||||
// if this is part of a multicell, find owner (topleft)
|
// if this is part of a multicell, find owner (topleft)
|
||||||
int cell_rows, cell_cols;
|
int cell_rows, cell_cols;
|
||||||
GetCellSize( row, col, &cell_rows, &cell_cols );
|
if ( GetCellSize( row, col, &cell_rows, &cell_cols ) == CellSpan_Inside )
|
||||||
if ( cell_rows <= 0 || cell_cols <= 0 )
|
|
||||||
{
|
{
|
||||||
row += cell_rows;
|
row += cell_rows;
|
||||||
col += cell_cols;
|
col += cell_cols;
|
||||||
@@ -7637,13 +7645,12 @@ wxRect wxGrid::CellToRect( int row, int col ) const
|
|||||||
{
|
{
|
||||||
int i, cell_rows, cell_cols;
|
int i, cell_rows, cell_cols;
|
||||||
rect.width = rect.height = 0;
|
rect.width = rect.height = 0;
|
||||||
GetCellSize( row, col, &cell_rows, &cell_cols );
|
if ( GetCellSize( row, col, &cell_rows, &cell_cols ) == CellSpan_Inside )
|
||||||
// if negative then find multicell owner
|
{
|
||||||
if (cell_rows < 0)
|
|
||||||
row += cell_rows;
|
row += cell_rows;
|
||||||
if (cell_cols < 0)
|
col += cell_cols;
|
||||||
col += cell_cols;
|
GetCellSize( row, col, &cell_rows, &cell_cols );
|
||||||
GetCellSize( row, col, &cell_rows, &cell_cols );
|
}
|
||||||
|
|
||||||
rect.x = GetColLeft(col);
|
rect.x = GetColLeft(col);
|
||||||
rect.y = GetRowTop(row);
|
rect.y = GetRowTop(row);
|
||||||
|
Reference in New Issue
Block a user