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
This commit is contained in:
wp_xxyyzz
2022-12-06 22:16:18 +00:00
parent 205529f52c
commit da1a1d25fc

View File

@ -864,6 +864,12 @@ begin
exit; exit;
lGrid := TGridAccess(FGrid); 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 if lGrid.Columns.Enabled and (ACol >= FFixedCols) and (ARow = 0) and (FFixedRows > 0) then
begin begin
col := lGrid.Columns[ACol - FFixedCols]; col := lGrid.Columns[ACol - FFixedCols];
@ -1086,7 +1092,9 @@ end;
procedure TGridPrinter.PrepareCanvas(ACanvas: TCanvas; ACol, ARow: Integer); procedure TGridPrinter.PrepareCanvas(ACanvas: TCanvas; ACol, ARow: Integer);
var var
lGrid: TGridAccess; lGrid: TGridAccess;
col: TGridColumn;
textStyle: TTextStyle; textStyle: TTextStyle;
font: TFont;
begin begin
lGrid := TGridAccess(FGrid); lGrid := TGridAccess(FGrid);
@ -1095,18 +1103,56 @@ begin
if (ACol < FFixedCols) or (ARow < FFixedRows) then if (ACol < FFixedCols) or (ARow < FFixedRows) then
ACanvas.Brush.Color := GetBrushColor(IfThen(lGrid.FixedColor = clBtnFace, $E0E0E0, lGrid.FixedColor)) ACanvas.Brush.Color := GetBrushColor(IfThen(lGrid.FixedColor = clBtnFace, $E0E0E0, lGrid.FixedColor))
else else
if lGrid.Columns.Enabled and (ACol >= FFixedCols) then
begin
col := lGrid.Columns[ACol - FFixedCols];
ACanvas.Brush.Color := GetBrushColor(col.Color);
end else
begin begin
if Odd(ARow) then if Odd(ARow) then
ACanvas.Brush.Color := GetBrushColor(lGrid.Color) ACanvas.Brush.Color := GetBrushColor(lGrid.Color)
else else
ACanvas.Brush.Color := GetBrushColor(lGrid.AlternateColor); ACanvas.Brush.Color := GetBrushColor(lGrid.AlternateColor);
end; end;
// Font // Font
SelectFont(ACanvas, lGrid.Font, FPrintScaleFactor); if lGrid.Columns.Enabled and (ACol >= FFixedCols) then
ACanvas.Font.Color := GetFontColor(lGrid.Font.Color); 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); FixFontSize(ACanvas.Font);
// Text style // Text style
textStyle := DefaultTextStyle; 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 if (goCellEllipsis in lGrid.Options) then
textStyle.EndEllipsis := true; textStyle.EndEllipsis := true;
ACanvas.TextStyle := textStyle; ACanvas.TextStyle := textStyle;