You've already forked lazarus-ccr
GridPrinter: Fix TsWorksheetGrid scaling in preview/printout.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8627 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -39,6 +39,7 @@ type
|
||||
ACanvas: TCanvas; ACol, ARow: Integer; ARect: TRect);
|
||||
private
|
||||
FGridCanvas: TCanvas;
|
||||
FOldZoomFactor: Double;
|
||||
FOldPadding: Integer;
|
||||
FNewPadding: Integer;
|
||||
|
||||
@ -67,23 +68,15 @@ begin
|
||||
sWorkbookSource1.LoadFromSpreadsheetFile(ParamStr(1));
|
||||
end;
|
||||
|
||||
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);
|
||||
begin
|
||||
// We want to draw on the printer/preview canvas. Therefore, we assign the
|
||||
// grid's canvas to that of the GridPrinter. In order to restore the grid
|
||||
// canvas after printing, we store its old canvas.
|
||||
FGridCanvas := sWorksheetGrid1.Canvas;
|
||||
sWorksheetGrid1.Canvas := GridPrinter1.Canvas;
|
||||
|
||||
//
|
||||
FOldPadding := varCellPadding;
|
||||
FNewPadding := GridPrinter1.Padding - varCellPadding;
|
||||
|
||||
@ -95,6 +88,28 @@ begin
|
||||
gpoFixedHorGridLines, gpoFixedVertGridLines,
|
||||
gpoHeaderBorderLines
|
||||
];
|
||||
|
||||
// Store the worksheetgrid's ZoomFactor. We may have to change it
|
||||
FOldZoomFactor := sWorksheetGrid1.ZoomFactor;
|
||||
sWorksheetGrid1.ZoomFactor := GridPrinter1.PrintScaleFactor;
|
||||
end;
|
||||
|
||||
procedure TMainForm.GridPrinter1AfterPrint(Sender: TObject);
|
||||
begin
|
||||
// Restore the worksheetgrid's Canvas.
|
||||
sWorksheetGrid1.Canvas := FGridCanvas;
|
||||
|
||||
varCellPadding := FOldPadding;
|
||||
|
||||
// Restore drawing of the grid lines by the grid printer.
|
||||
GridPrinter1.Options := GridPrinter1.Options + [
|
||||
gpoHorGridLines, gpoVertGridLines,
|
||||
gpoFixedHorGridLines, gpoFixedVertGridLines,
|
||||
gpoHeaderBorderLines
|
||||
];
|
||||
|
||||
// Restore the worksheetgrid's ZoomFactor
|
||||
sWorksheetGrid1.ZoomFactor := FOldZoomFactor;
|
||||
end;
|
||||
|
||||
procedure TMainForm.btnPrintClick(Sender: TObject);
|
||||
|
Reference in New Issue
Block a user