From ff691862d054583735667502827b8129b4248887 Mon Sep 17 00:00:00 2001 From: jesusr Date: Fri, 8 Jan 2010 08:42:51 +0000 Subject: [PATCH] PowerPDF, added polygon object git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1122 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/powerpdf/PReport.pas | 82 +++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/components/powerpdf/PReport.pas b/components/powerpdf/PReport.pas index a29216da7..f84528a23 100644 --- a/components/powerpdf/PReport.pas +++ b/components/powerpdf/PReport.pas @@ -103,6 +103,10 @@ type TPRCompressionMethod = TPdfCompressionMethod; TPRViewerPreference = TPdfViewerPreference; TPRViewerPreferences = TPdfViewerPreferences; + TPRPoint = record + x,y: single; + end; + TPRPointArray = array of TPRPoint; { TPReport } TPReport = class(TAbstractPReport) @@ -430,6 +434,7 @@ type property LineStyle: TPenStyle read FLineStyle write SetLineStyle; property FillColor: TColor read FFillColor write SetFillColor default clNone; end; + TPRShapeClass = class of TPRShape; { TPRRect } TPRRect = class(TPRShape) @@ -445,6 +450,14 @@ type procedure Print(ACanvas: TPRCanvas; ARect: TRect); override; end; + { TPRPolygon } + TPRPolygon = class(TPRShape) + protected + procedure Print(ACanvas: TPRCanvas; ARect: TRect); override; + public + Points: TPRPointArray; + end; + { TPRImage } TPRImage = class(TPRItem) private @@ -521,6 +534,8 @@ type end; + function PRPoint(x,y:single): TPRPoint; + const LINE_PITCH: integer = 378; LINE_COLOR: TColor = clSilver; @@ -697,6 +712,12 @@ begin end; end; +function PRPoint(x, y: single): TPRPoint; +begin + result.x := x; + result.y := y; +end; + { TPReport } // Create @@ -2423,6 +2444,67 @@ begin ADoc.OutlineRoot.Reference := Self; end; +{ TPRPolygon } + +procedure TPRPolygon.Print(ACanvas: TPRCanvas; ARect: TRect); +var + Canvas: TPDFCanvas; + i,h: Integer; + Pts: TPRPointArray; +begin + if Length(Points)<2 then + exit; + + h := GetPage.Height; + + SetLength(Pts, Length(Points)); + for i:=0 to Length(Points)-1 do + begin + Pts[i].x := Points[i].x; + Pts[i].y := h - Points[i].y; + end; + + Canvas := ACanvas.PDFCanvas; + + SetDash(Canvas, FLineStyle); + + Canvas.MoveTo(Pts[0].x, Pts[0].y); + for i:=1 to Length(Pts)-1 do + Canvas.LineTo(Pts[i].x, Pts[i].y); + + if (FillColor <> clNone) and (Length(Points)>2) then + canvas.SetRGBFillColor(FFillColor); + + if LineColor <> clNone then + begin + Canvas.SetRGBStrokeColor(FLineColor); + Canvas.SetLineWidth(FLineWidth); + end; + + if FillColor <> clNone then + if Length(Points)>2 then + if (LineColor <> clNone) and (LineStyle <> psClear) then + Canvas.ClosepathFillStroke + else + begin + Canvas.Closepath; + Canvas.Fill; + end + else + begin + Canvas.Stroke; + Canvas.Newpath; + end + else + if Length(Points)>2 then + Canvas.ClosePathStroke + else + begin + Canvas.Stroke; + Canvas.Newpath; + end; +end; + end.