git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17143
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
bool isSelected)
{
wxRect rect = rectCell;
bool isSelected)
{
wxRect rect = rectCell;
+ rect.Inflate(-1);
+
+ // erase only this cells background, overflow cells should have been erased
+ wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected);
+
+ int hAlign, vAlign;
+ attr.GetAlignment(&hAlign, &vAlign);
if (attr.GetOverflow())
{
int cols = grid.GetNumberCols();
int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth();
if (attr.GetOverflow())
{
int cols = grid.GetNumberCols();
int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth();
int cell_rows, cell_cols;
attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <=0
if ((best_width > rectCell.width) && (col < cols) && grid.GetTable())
int cell_rows, cell_cols;
attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <=0
if ((best_width > rectCell.width) && (col < cols) && grid.GetTable())
rect.width += grid.GetColSize(i);
if (rect.width >= best_width) break;
}
rect.width += grid.GetColSize(i);
if (rect.width >= best_width) break;
}
+ else
+ {
+ i--;
+ break;
+ }
+ overflowCols = i - col - cell_cols;
+ if (overflowCols >= cols) overflowCols = cols - 1;
+ }
- // erase only this cells background, overflow cells should have been erased
- wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected);
+ if (overflowCols > 0) // redraw overflow cells w/ proper hilight
+ {
+ wxRect clip = rect;
- // now we only have to draw the text
- SetTextColoursAndFont(grid, attr, dc, isSelected);
+ // draw each overflow cell individually
+ int col_end = col+cell_cols+overflowCols;
+ if (col_end >= grid.GetNumberCols())
+ col_end = grid.GetNumberCols() - 1;
- int hAlign, vAlign;
- attr.GetAlignment(&hAlign, &vAlign);
+ for (int i = col+cell_cols; i <= col_end; i++)
+ {
+ clip.x += grid.GetColSize(i-1) - 1;
+ clip.width = grid.GetColSize(i) - 1;
+ dc.DestroyClippingRegion();
+ dc.SetClippingRegion(clip);
+
+ SetTextColoursAndFont(grid, attr, dc, grid.IsInSelection(row,i));
+ grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
+ rect, hAlign, vAlign);
+ }
+ rect = rectCell;
+ rect.Inflate(-1);
+ rect.width++;
+ dc.DestroyClippingRegion(); // DrawTextRectangle sets it again
+ }
+ }
+ // now we only have to draw the text
+ SetTextColoursAndFont(grid, attr, dc, isSelected);
grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
rect, hAlign, vAlign);
}
grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
rect, hAlign, vAlign);
}
{
if ( !m_numRows || !m_numCols ) return;
{
if ( !m_numRows || !m_numCols ) return;
- int i, j, k, l, numCells = cells.GetCount();
+ int i, numCells = cells.GetCount();
int row, col, cell_rows, cell_cols;
wxGridCellCoordsArray redrawCells;
int row, col, cell_rows, cell_cols;
wxGridCellCoordsArray redrawCells;
{
wxGridCellCoords cell(row+cell_rows, col+cell_cols);
bool marked = FALSE;
{
wxGridCellCoords cell(row+cell_rows, col+cell_cols);
bool marked = FALSE;
- for ( j = 0; j < numCells; j++ )
+ for ( int j = 0; j < numCells; j++ )
{
if ( cell == cells[j] )
{
{
if ( cell == cells[j] )
{
if (!marked)
{
int count = redrawCells.GetCount();
if (!marked)
{
int count = redrawCells.GetCount();
- for (j = 0; j < count; j++)
+ for (int j = 0; j < count; j++)
{
if ( cell == redrawCells[j] )
{
{
if ( cell == redrawCells[j] )
{
// If this cell is empty, find cell to left that might want to overflow
if (m_table && m_table->IsEmptyCell(row, col))
{
// If this cell is empty, find cell to left that might want to overflow
if (m_table && m_table->IsEmptyCell(row, col))
{
- for ( l = 0; l < cell_rows; l++ )
+ for ( int l = 0; l < cell_rows; l++ )
- for (j = col-1; j >= 0; j--)
+ // find a cell in this row to left alreay marked for repaint
+ int left = col;
+ for (int k = 0; k < int(redrawCells.GetCount()); k++)
+ if ((redrawCells[k].GetCol() < left) &&
+ (redrawCells[k].GetRow() == row))
+ left=redrawCells[k].GetCol();
+
+ if (left == col) left = 0; // oh well
+
+ for (int j = col-1; j >= left; j--)
{
if (!m_table->IsEmptyCell(row+l, j))
{
{
if (!m_table->IsEmptyCell(row+l, j))
{
wxGridCellCoords cell(row+l, j);
bool marked = FALSE;
wxGridCellCoords cell(row+l, j);
bool marked = FALSE;
- for (k = 0; k < numCells; k++)
+ for (int k = 0; k < numCells; k++)
{
if ( cell == cells[k] )
{
{
if ( cell == cells[k] )
{
if (!marked)
{
int count = redrawCells.GetCount();
if (!marked)
{
int count = redrawCells.GetCount();
- for (k = 0; k < count; k++)
+ for (int k = 0; k < count; k++)
{
if ( cell == redrawCells[k] )
{
{
if ( cell == redrawCells[k] )
{
editor->Show( TRUE, attr );
// resize editor to overflow into righthand cells if allowed
editor->Show( TRUE, attr );
// resize editor to overflow into righthand cells if allowed
+ wxCoord maxRight = rect.width;
wxString value = GetCellValue(row, col);
if ( (value != wxEmptyString) && (attr->GetOverflow()) )
{
wxClientDC dc(m_gridWin);
wxString value = GetCellValue(row, col);
if ( (value != wxEmptyString) && (attr->GetOverflow()) )
{
wxClientDC dc(m_gridWin);
- wxCoord y = 0, best_width = 0;
dc.SetFont(attr->GetFont());
dc.SetFont(attr->GetFont());
- dc.GetTextExtent(value, &best_width, &y);
+ dc.GetTextExtent(value, &maxRight, &y);
+ if (maxRight > m_gridWin->GetClientSize().GetWidth())
+ maxRight = m_gridWin->GetClientSize().GetWidth();
int cell_rows, cell_cols;
attr->GetSize( &cell_rows, &cell_cols );
int cell_rows, cell_cols;
attr->GetSize( &cell_rows, &cell_cols );
- if ((best_width > rect.width) && (col < m_numCols) && m_table)
+ if ((maxRight > rect.width) && (col < m_numCols) && m_table)
{
int i;
for (i = col+cell_cols; i < m_numCols; i++)
{
{
int i;
for (i = col+cell_cols; i < m_numCols; i++)
{
- if (m_table->IsEmptyCell(row,i))
- {
- rect.width += GetColWidth(i);
- if (rect.width >= best_width) break;
- }
- else
- break;
+ int c_rows, c_cols;
+ // looks weird going over a multicell
+ GetCellSize( row, i, &c_rows, &c_cols );
+ if (m_table->IsEmptyCell(row,i) && (rect.GetRight() < maxRight) && (c_rows == 1))
+ rect.width += GetColWidth(i);
+ else
+ break;
+ if (rect.GetRight() > maxRight) rect.SetRight(maxRight-1);
}
}
editor->SetSize( rect );
}
}
editor->SetSize( rect );