From fe4f02b65382d147ac24dadce957d843a8946389 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Mon, 15 Aug 2016 12:26:52 +0000 Subject: [PATCH] RxFPC:fix export to pdf cell background color (tnx. Graeme Geldenhuys) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5091 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../Demos/RxDbGridExportToPDF/project1.lps | 71 +++++++++++++------ components/rx/trunk/rxdbgridexportpdf.pas | 11 +-- 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/components/rx/trunk/Demos/RxDbGridExportToPDF/project1.lps b/components/rx/trunk/Demos/RxDbGridExportToPDF/project1.lps index 173d28f5e..dbe3f9c56 100644 --- a/components/rx/trunk/Demos/RxDbGridExportToPDF/project1.lps +++ b/components/rx/trunk/Demos/RxDbGridExportToPDF/project1.lps @@ -3,13 +3,13 @@ - + - + @@ -18,10 +18,9 @@ - - - + + @@ -87,12 +86,13 @@ + - - - + + + - + @@ -455,10 +455,10 @@ - + - + @@ -481,8 +481,25 @@ + + + + + + + + + + + + + + + + + - + @@ -564,32 +581,44 @@ - + - + - + - + - + - - + + - - + + + + + + + + + + + + + + diff --git a/components/rx/trunk/rxdbgridexportpdf.pas b/components/rx/trunk/rxdbgridexportpdf.pas index ef0c6aa65..776d2fb59 100644 --- a/components/rx/trunk/rxdbgridexportpdf.pas +++ b/components/rx/trunk/rxdbgridexportpdf.pas @@ -139,7 +139,10 @@ function ColorToDdfColor(C:TColor):TARGBColor; var A:array [1..4] of byte absolute C; begin - Result:={A[1] shl 24 +} A[1] shl 16 + A[2] shl 8 + A[3]; + if C = clWindow then + Result:=clWhite + else + Result:={A[1] shl 24 +} A[1] shl 16 + A[2] shl 8 + A[3]; end; { TPdfExportOptions } @@ -262,6 +265,7 @@ begin CP:=-1; FCurPage:=nil; + for i:=0 to FRxDBGrid.Columns.Count - 1 do begin C:=FRxDBGrid.Columns[i]; @@ -273,8 +277,8 @@ begin end; FCurPage.SetColor(ColorToDdfColor(FRxDBGrid.BorderColor), true); //Border - //FCurPage.SetColor(ColorToDdfColor(C.Color), false); // Fill color - FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, false, true); + FCurPage.SetColor(ColorToDdfColor(C.Color), false); // Fill color + FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, true, true); if Assigned(C.Field) then begin @@ -284,7 +288,6 @@ begin WriteTextRect(FExportFontBody, X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, C.Field.DisplayText, C.Alignment); end; - X:=X + C.Width; end; end;