Paint method

void Paint()
override

Implementation

void Paint()
{

  _gridSizing.Invalidate();
  TGridDrawInfo DrawInfo = TGridDrawInfo();


  TGridCell CreateGridCell(TableCellElement Handle, int Col, int Row, TGridDrawState State)
  {
    return TGridCell(Handle, Col, Row, State);
  }

  void DrawCells(int ACol, int ARow, int StartX, int StartY, int StopX, int StopY, TGridDrawState IncludeDrawState)
  {
    TableSectionElement body = _grid!.body;

    bool Focused = IsActiveControl();
    TRect Where = TRect();

    int CurRow = ARow;
    Where.top = StartY;
    while((Where.top < StopY) && (CurRow < RowCount))
    {
      int CurCol = ACol;
      Where.left = StartX;
      Where.bottom = Where.top + GetRowHeights(CurRow);
      while((Where.left < StopX) && (CurCol < ColCount))
      {
        Where.right = Where.left + GetColWidths(CurCol);

        // define cell [CurRow, CurCol]
        TableCellElement? cell;
        int ci = CurCol;
        if(ci>=DrawInfo.Horz.FixedCellCount)
          ci-=DrawInfo.Horz.FirstGridCell-1;
        if(CurRow<body.rows.length)
        {
          TableRowElement row = body.rows[CurRow];
          if(ci<row.cells.length)
          {
            cell = row.cells[ci];
            cell.style.display = Where.right > Where.left? null : 'none';
          }
        }

        if((Where.right > Where.left)/* && RectVisible(Canvas.Handle, Where)*/)
        {
          TGridDrawState DrawState = TGridDrawState();
          DrawState.assign(IncludeDrawState);
          if(Focused && (CurRow == Row) && (Options.contains(GridOptions.RowSelect)? true : CurCol == Col))
            DrawState << TGridDrawStates.Focused;



            if(cell != null)
              DrawCell(CreateGridCell(cell, CurCol, CurRow, DrawState));

        }
        Where.left = Where.right + DrawInfo.Horz.EffectiveLineWidth;
        CurCol++;
      }
      Where.top = Where.bottom + DrawInfo.Vert.EffectiveLineWidth;
      CurRow++;
    }
  }


  CalcDrawInfo(DrawInfo);


  DrawCells(0, 0, 0, 0, DrawInfo.Horz.FixedBoundary, DrawInfo.Vert.FixedBoundary, TGridDrawState.from({ TGridDrawStates.Fixed }));
  DrawCells(LeftCol, 0, DrawInfo.Horz.FixedBoundary - _colOffset, 0, DrawInfo.Horz.GridBoundary, DrawInfo.Vert.FixedBoundary, TGridDrawState.from({ TGridDrawStates.Fixed }));
  DrawCells(0, TopRow, 0, DrawInfo.Vert.FixedBoundary, DrawInfo.Horz.FixedBoundary, DrawInfo.Vert.GridBoundary, TGridDrawState.from( { TGridDrawStates.Fixed }));
  DrawCells(LeftCol, TopRow, DrawInfo.Horz.FixedBoundary - _colOffset, DrawInfo.Vert.FixedBoundary, DrawInfo.Horz.GridBoundary, DrawInfo.Vert.GridBoundary, TGridDrawState());


}