- wxClientDC dc(m_gridWin);
- wxCoord y = 0;
- dc.SetFont(attr->GetFont());
- 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 );
-
- if ((maxRight > rect.width) && (col < m_numCols) && m_table)
- {
- int i;
- for (i = col+cell_cols; i < m_numCols; i++)
- {
- 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);
- }
+ int y;
+ GetTextExtent(value, &maxWidth, &y,
+ NULL, NULL, &attr->GetFont());
+ if (maxWidth < rect.width) maxWidth = rect.width;
+ }
+ int client_right = m_gridWin->GetClientSize().GetWidth();
+ if (rect.x+maxWidth > client_right)
+ maxWidth = client_right - rect.x;
+
+ if ((maxWidth > rect.width) && (col < m_numCols) && m_table)
+ {
+ GetCellSize( row, col, &cell_rows, &cell_cols );
+ // may have changed earlier
+ for (int i = col+cell_cols; i < m_numCols; i++)
+ {
+ int c_rows, c_cols;
+ GetCellSize( row, i, &c_rows, &c_cols );
+ // looks weird going over a multicell
+ if (m_table->IsEmptyCell(row,i) &&
+ (rect.width < maxWidth) && (c_rows == 1))
+ rect.width += GetColWidth(i);
+ else
+ break;
+ }
+ if (rect.GetRight() > client_right)
+ rect.SetRight(client_right-1);