Applied revised patch 606235 (Cell overflow refresh fixed).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17188 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2002-09-15 00:29:49 +00:00
parent e52d9c784e
commit 39b80349a1

View File

@@ -1564,11 +1564,12 @@ void wxGridCellStringRenderer::Draw(wxGrid& grid,
int hAlign, vAlign; int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign); attr.GetAlignment(&hAlign, &vAlign);
int overflowCols = 0;
if (attr.GetOverflow()) if (attr.GetOverflow())
{ {
int cols = grid.GetNumberCols(); int cols = grid.GetNumberCols();
int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth(); int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth();
int overflowCols = 0;
int cell_rows, cell_cols; int cell_rows, cell_cols;
attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <=0 attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <=0
if ((best_width > rectCell.width) && (col < cols) && grid.GetTable()) if ((best_width > rectCell.width) && (col < cols) && grid.GetTable())
@@ -1576,54 +1577,64 @@ void wxGridCellStringRenderer::Draw(wxGrid& grid,
int i, c_cols, c_rows; int i, c_cols, c_rows;
for (i = col+cell_cols; i < cols; i++) for (i = col+cell_cols; i < cols; i++)
{ {
// check w/ anchor cell for multicell block bool is_empty = TRUE;
grid.GetCellSize(row, i, &c_rows, &c_cols); for (int j=row; j<row+cell_rows; j++)
if (c_rows > 0) c_rows = 0;
if (grid.GetTable()->IsEmptyCell(row+c_rows, i))
{ {
rect.width += grid.GetColSize(i); // check w/ anchor cell for multicell block
if (rect.width >= best_width) break; grid.GetCellSize(row, i, &c_rows, &c_cols);
if (c_rows > 0) c_rows = 0;
if (grid.GetTable()->IsEmptyCell(row+c_rows, i))
{
is_empty = FALSE;
break;
}
} }
if (is_empty)
rect.width += grid.GetColSize(i);
else else
{ {
i--; i--;
break; break;
} }
} if (rect.width >= best_width) break;
overflowCols = i - col - cell_cols; }
if (overflowCols >= cols) overflowCols = cols - 1; overflowCols = i - col - cell_cols + 1;
} if (overflowCols >= cols) overflowCols = cols - 1;
}
if (overflowCols > 0) // redraw overflow cells w/ proper hilight if (overflowCols > 0) // redraw overflow cells w/ proper hilight
{ {
hAlign = wxALIGN_LEFT; // if oveflowed then it's left aligned
wxRect clip = rect; wxRect clip = rect;
clip.x += rectCell.width;
// draw each overflow cell individually // draw each overflow cell individually
int col_end = col+cell_cols+overflowCols; int col_end = col+cell_cols+overflowCols;
if (col_end >= grid.GetNumberCols()) if (col_end >= grid.GetNumberCols())
col_end = grid.GetNumberCols() - 1; col_end = grid.GetNumberCols() - 1;
for (int i = col+cell_cols; i <= col_end; i++) for (int i = col+cell_cols; i <= col_end; i++)
{ {
clip.x += grid.GetColSize(i-1) - 1;
clip.width = grid.GetColSize(i) - 1; clip.width = grid.GetColSize(i) - 1;
dc.DestroyClippingRegion(); dc.DestroyClippingRegion();
dc.SetClippingRegion(clip); dc.SetClippingRegion(clip);
SetTextColoursAndFont(grid, attr, dc, grid.IsInSelection(row,i)); SetTextColoursAndFont(grid, attr, dc,
grid.IsInSelection(row,i));
grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
rect, hAlign, vAlign); rect, hAlign, vAlign);
clip.x += grid.GetColSize(i) - 1;
} }
rect = rectCell; rect = rectCell;
rect.Inflate(-1); rect.Inflate(-1);
rect.width++; rect.width++;
dc.DestroyClippingRegion(); // DrawTextRectangle sets it again dc.DestroyClippingRegion();
} }
} }
// now we only have to draw the text // now we only have to draw the text
SetTextColoursAndFont(grid, attr, dc, isSelected); SetTextColoursAndFont(grid, attr, dc, isSelected);
grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
rect, hAlign, vAlign); rect, hAlign, vAlign);
} }
@@ -7254,35 +7265,36 @@ void wxGrid::ShowCellEditControl()
editor->Show( TRUE, attr ); editor->Show( TRUE, attr );
// resize editor to overflow into righthand cells if allowed // resize editor to overflow into righthand cells if allowed
wxCoord maxRight = rect.width; int maxWidth = rect.width;
wxString value = GetCellValue(row, col); wxString value = GetCellValue(row, col);
if ( (value != wxEmptyString) && (attr->GetOverflow()) ) if ( (value != wxEmptyString) && (attr->GetOverflow()) )
{ {
wxClientDC dc(m_gridWin); int y;
wxCoord y = 0; GetTextExtent(value, &maxWidth, &y,
dc.SetFont(attr->GetFont()); NULL, NULL, &attr->GetFont());
dc.GetTextExtent(value, &maxRight, &y); if (maxWidth < rect.width) maxWidth = rect.width;
if (maxRight > m_gridWin->GetClientSize().GetWidth()) }
maxRight = m_gridWin->GetClientSize().GetWidth(); int client_right = m_gridWin->GetClientSize().GetWidth();
if (rect.x+maxWidth > client_right)
maxWidth = client_right - rect.x;
int cell_rows, cell_cols; if ((maxWidth > rect.width) && (col < m_numCols) && m_table)
attr->GetSize( &cell_rows, &cell_cols ); {
GetCellSize( row, col, &cell_rows, &cell_cols );
if ((maxRight > rect.width) && (col < m_numCols) && m_table) // may have changed earlier
{ for (int i = col+cell_cols; i < m_numCols; i++)
int i; {
for (i = col+cell_cols; i < m_numCols; i++) int c_rows, c_cols;
{ GetCellSize( row, i, &c_rows, &c_cols );
int c_rows, c_cols; // looks weird going over a multicell
// looks weird going over a multicell if (m_table->IsEmptyCell(row,i) &&
GetCellSize( row, i, &c_rows, &c_cols ); (rect.width < maxWidth) && (c_rows == 1))
if (m_table->IsEmptyCell(row,i) && (rect.GetRight() < maxRight) && (c_rows == 1)) rect.width += GetColWidth(i);
rect.width += GetColWidth(i); else
else break;
break; }
} if (rect.GetRight() > client_right)
if (rect.GetRight() > maxRight) rect.SetRight(maxRight-1); rect.SetRight(client_right-1);
}
} }
editor->SetSize( rect ); editor->SetSize( rect );