+ int cw, ch;
+ m_gridWin->GetClientSize(&cw, &ch);
+ CalcUnscrolledPosition( 0, 0, &left, &top );
+ CalcUnscrolledPosition( cw, ch, &right, &bottom );
+#endif
+
+ // avoid drawing grid lines past the last row and col
+ //
+ right = wxMin( right, GetColRight(GetColAt( m_numCols - 1 )) );
+ bottom = wxMin( bottom, GetRowBottom(m_numRows - 1) );
+
+ // no gridlines inside multicells, clip them out
+ int leftCol = GetColPos( internalXToCol(left) );
+ int topRow = internalYToRow(top);
+ int rightCol = GetColPos( internalXToCol(right) );
+ int bottomRow = internalYToRow(bottom);
+
+#if !defined(__WXMAC__) || wxMAC_USE_CORE_GRAPHICS
+ wxRegion clippedcells(0, 0, cw, ch);
+
+ int i, j, cell_rows, cell_cols;
+ wxRect rect;
+
+ for (j=topRow; j<=bottomRow; j++)
+ {
+ int colPos;
+ for (colPos=leftCol; colPos<=rightCol; colPos++)
+ {
+ i = GetColAt( colPos );
+
+ GetCellSize( j, i, &cell_rows, &cell_cols );
+ if ((cell_rows > 1) || (cell_cols > 1))
+ {
+ rect = CellToRect(j,i);
+ CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ clippedcells.Subtract(rect);
+ }
+ else if ((cell_rows < 0) || (cell_cols < 0))
+ {
+ rect = CellToRect(j + cell_rows, i + cell_cols);
+ CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
+ clippedcells.Subtract(rect);
+ }
+ }
+ }
+#else
+ wxRegion clippedcells( left, top, right - left, bottom - top );
+
+ int i, j, cell_rows, cell_cols;
+ wxRect rect;
+
+ for (j=topRow; j<=bottomRow; j++)
+ {
+ for (i=leftCol; i<=rightCol; i++)
+ {
+ GetCellSize( j, i, &cell_rows, &cell_cols );
+ if ((cell_rows > 1) || (cell_cols > 1))
+ {
+ rect = CellToRect(j, i);
+ clippedcells.Subtract(rect);
+ }
+ else if ((cell_rows < 0) || (cell_cols < 0))
+ {
+ rect = CellToRect(j + cell_rows, i + cell_cols);
+ clippedcells.Subtract(rect);
+ }
+ }
+ }