From da1a1d25fc79b9386d1aa4f2d1d3f552164070a9 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 6 Dec 2022 22:16:18 +0000 Subject: [PATCH] GridPrinter: Support fixed col numbering. Better support of grid column formatting. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8637 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/gridprinter/source/gridprn.pas | 50 ++++++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/components/gridprinter/source/gridprn.pas b/components/gridprinter/source/gridprn.pas index eb55d822c..b87bdf47d 100644 --- a/components/gridprinter/source/gridprn.pas +++ b/components/gridprinter/source/gridprn.pas @@ -864,6 +864,12 @@ begin exit; lGrid := TGridAccess(FGrid); + if (ACol = 0) and (FFixedCols > 0) and (ARow >= FFixedRows) and (goFixedRowNumbering in lGrid.Options) then + begin + Result := IntToStr(ARow - FFixedRows + 1); + exit; + end; + if lGrid.Columns.Enabled and (ACol >= FFixedCols) and (ARow = 0) and (FFixedRows > 0) then begin col := lGrid.Columns[ACol - FFixedCols]; @@ -1086,7 +1092,9 @@ end; procedure TGridPrinter.PrepareCanvas(ACanvas: TCanvas; ACol, ARow: Integer); var lGrid: TGridAccess; + col: TGridColumn; textStyle: TTextStyle; + font: TFont; begin lGrid := TGridAccess(FGrid); @@ -1095,18 +1103,56 @@ begin if (ACol < FFixedCols) or (ARow < FFixedRows) then ACanvas.Brush.Color := GetBrushColor(IfThen(lGrid.FixedColor = clBtnFace, $E0E0E0, lGrid.FixedColor)) else + if lGrid.Columns.Enabled and (ACol >= FFixedCols) then + begin + col := lGrid.Columns[ACol - FFixedCols]; + ACanvas.Brush.Color := GetBrushColor(col.Color); + end else begin if Odd(ARow) then ACanvas.Brush.Color := GetBrushColor(lGrid.Color) else ACanvas.Brush.Color := GetBrushColor(lGrid.AlternateColor); end; + // Font - SelectFont(ACanvas, lGrid.Font, FPrintScaleFactor); - ACanvas.Font.Color := GetFontColor(lGrid.Font.Color); + if lGrid.Columns.Enabled and (ACol >= FFixedCols) then + begin + col := lGrid.Columns[ACol - FFixedCols]; + if (ARow < FFixedRows) then + font := col.Title.Font + else + font := col.Font; + SelectFont(ACanvas, font, FPrintScaleFactor); + ACanvas.Font.Color := GetFontColor(font.Color); + end else + begin + SelectFont(ACanvas, lGrid.Font, FPrintScaleFactor); + ACanvas.Font.Color := GetFontColor(lGrid.Font.Color); + end; FixFontSize(ACanvas.Font); + // Text style textStyle := DefaultTextStyle; + if lGrid.Columns.Enabled and (ACol >= FFixedCols) then + begin + col := lGrid.Columns[ACol - FFixedCols]; + if (ARow < FFixedRows) then + begin + textStyle.Alignment := col.Title.Alignment; + textStyle.Layout := col.Title.Layout; + if col.Title.MultiLine then + begin + textStyle.Wordbreak := true; + textStyle.SingleLine := false; + textStyle.EndEllipsis := false; + end; + end else + begin + textStyle.Alignment := col.Alignment; + textStyle.Layout := col.Layout; + end; + end; if (goCellEllipsis in lGrid.Options) then textStyle.EndEllipsis := true; ACanvas.TextStyle := textStyle;