GridPrinter: Fix drawing of too-wide grid lines in TsWorksheetGrid preview.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8626 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-11-16 22:41:22 +00:00
parent fcb139c902
commit 3a6f3503fe
3 changed files with 76 additions and 32 deletions

View File

@@ -14,6 +14,7 @@ type
{ TMainForm }
TMainForm = class(TForm)
Bevel1: TBevel;
btnPrint: TButton;
btnPreview: TButton;
btnOpenFile: TButton;
@@ -70,6 +71,13 @@ procedure TMainForm.GridPrinter1AfterPrint(Sender: TObject);
begin
sWorksheetGrid1.Canvas := FGridCanvas;
varCellPadding := FOldPadding;
// Restore drawing of the grid lines by the grid printer.
GridPrinter1.Options := GridPrinter1.Options + [
gpoHorGridLines, gpoVertGridLines,
gpoFixedHorGridLines, gpoFixedVertGridLines,
gpoHeaderBorderLines
];
end;
procedure TMainForm.GridPrinter1BeforePrint(Sender: TObject);
@@ -78,6 +86,15 @@ begin
sWorksheetGrid1.Canvas := GridPrinter1.Canvas;
FOldPadding := varCellPadding;
FNewPadding := GridPrinter1.Padding - varCellPadding;
// The TsWorksheetGrid paints the grid lines in the DrawCell method. To
// avoid duplicate drawing (which, BTW, is offset by 1 pixel) we turn off
// painting of the grid lines by the grid printer.
GridPrinter1.Options := GridPrinter1.Options - [
gpoHorGridLines, gpoVertGridLines,
gpoFixedHorGridLines, gpoFixedVertGridLines,
gpoHeaderBorderLines
];
end;
procedure TMainForm.btnPrintClick(Sender: TObject);