diff options
author | Jean-Marc Levecque <jean-marc.levecque@jmlesite.fr> | 2011-12-27 11:35:42 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2012-02-13 15:45:59 +0200 |
commit | 25ec462c6313b59964f614b937117b41b19ddae1 (patch) | |
tree | 695c6ec27e22b9cddce0d3c6aaa51cda062c25d8 | |
parent | 581b4f7392fe5c30818b18d2f642a285c7da5c78 (diff) | |
download | fpGUI-25ec462c6313b59964f614b937117b41b19ddae1.tar.xz |
Added image position refering to columns in report tool
Signed-off-by: Jean-Marc Levecque <jean-marc.levecque@jmlesite.fr>
-rw-r--r-- | extras/contributed/report_tool/demo/u_demo.pas | 20 | ||||
-rw-r--r-- | extras/contributed/report_tool/reportengine/u_command.pas | 33 | ||||
-rw-r--r-- | extras/contributed/report_tool/reportengine/u_report.pas | 172 |
3 files changed, 141 insertions, 84 deletions
diff --git a/extras/contributed/report_tool/demo/u_demo.pas b/extras/contributed/report_tool/demo/u_demo.pas index c42f9d3b..2807a641 100644 --- a/extras/contributed/report_tool/demo/u_demo.pas +++ b/extras/contributed/report_tool/demo/u_demo.pas @@ -1514,6 +1514,7 @@ procedure TF_Demo.PrintImage(Preview: Boolean); var FtTitle,FtText: Integer; IlTitle,IlText: Integer; + Col1,Col2,Col3: Integer; begin with FReport do begin @@ -1525,20 +1526,23 @@ with FReport do FtTitle:= Font('helvetica-15:bold',clBlack); FtText:= Font('helvetica-7',clBlack); // create line spacings to be used - IlTitle:= LineSpace(3,0,3); + IlTitle:= LineSpace(0,0,3); IlText:= LineSpace(1,0,0); + Col1:= Column(20,60,2); + Col2:= Column(80,60,2); + Col3:= Column(140,60,2); WriteHeader(cnCenter,lnEnd,'SHOWING IMAGES',ColDefaut,FtTitle,IlTitle); // write page number and total of pages on each page NumPageFooter(cnRight,lnEnd,'Page','of',True,ColDefaut,FtText,IlText); // paint some images - ImageHeader(10,12,'poppy.jpg',4); - ImagePage(40,50,'poppy.jpg',3); - ImagePage(50,80,'poppy.jpg',2); - ImagePage(60,140,'poppy.jpg'); - ImagePage(100,30,'radiobuttons.bmp'); + ImageHeader(0,0,'poppy.jpg',Col1,4); + ImagePage(30,40,'poppy.jpg',ColDefaut,3); + ImagePage(40,70,'poppy.jpg',ColDefaut,2); + ImagePage(50,130,'poppy.jpg'); + ImagePage(0,20,'radiobuttons.bmp',Col3); Page; - ImagePage(80,30,'poppy-nb.jpg'); - ImagePage(30,120,'poppy.jpg',2); + ImagePage(0,0,'poppy-nb.jpg',Col2); + ImagePage(20,100,'poppy.jpg',ColDefaut,2); Page; // preparation is finished, so create PDF objects EndWrite; diff --git a/extras/contributed/report_tool/reportengine/u_command.pas b/extras/contributed/report_tool/reportengine/u_command.pas index 2f51978b..dd1359a5 100644 --- a/extras/contributed/report_tool/reportengine/u_command.pas +++ b/extras/contributed/report_tool/reportengine/u_command.pas @@ -81,9 +81,9 @@ type procedure LoadLineHorizFooter(APosXBegin,APosYBegin: Single; AColumn: Integer; APosXEnd,APosYEnd: Single; AStyle: Integer); procedure LoadLineHorizGroupe(AHeight: Single); procedure LoadSurf(APos: T_Points; AColor: TfpgColor); - procedure LoadImgHeader(APosX,APosY,AImgNum: Integer); - procedure LoadImgPage(APosX,APosY,AImgNum: Integer); - procedure LoadImgFooter(APosX,APosY,AImgNum: Integer); + procedure LoadImgHeader(APosX,APosY: Single; AColumn,AImgNum: Integer); + procedure LoadImgPage(APosX,APosY: Single; AColumn,AImgNum: Integer); + procedure LoadImgFooter(APosX,APosY: Single; AColumn,AImgNum: Integer); function GetCmdPage(NumPage: Integer): TList; property CmdHeader: TList read FHeader; property CmdFooter: TList read FFooter; @@ -342,13 +342,15 @@ type T_Image = class(T_Command) private FImage: Integer; - FPosX: Integer; - FPosY: Integer; + FColumn: Integer; + FPosX: Single; + FPosY: Single; public - constructor Create(APosX,APosY,AImageNum: Integer); + constructor Create(APosX,APosY: Single; AColumn,AImageNum: Integer); property GetImage: Integer read FImage; - property GetPosX: Integer read FPosX; - property GetPosY: Integer read FPosY; + property GetColumn: Integer read FColumn; + property GetPosX: Single read FPosX; + property GetPosY: Single read FPosY; end; var @@ -579,21 +581,21 @@ VCommand:= T_Surface.Create(APos,AColor); T_Page(Pages[Pred(FPages.Count)]).Commands.Add(VCommand); end; -procedure T_Section.LoadImgHeader(APosX,APosY,AImgNum: Integer); +procedure T_Section.LoadImgHeader(APosX,APosY: Single; AColumn,AImgNum: Integer); begin -VCommand:= T_Image.Create(APosX,APosY,AImgNum); +VCommand:= T_Image.Create(APosX,APosY,AColumn,AImgNum); FHeader.Add(VCommand); end; -procedure T_Section.LoadImgPage(APosX,APosY,AImgNum: Integer); +procedure T_Section.LoadImgPage(APosX,APosY: Single; AColumn,AImgNum: Integer); begin -VCommand:= T_Image.Create(APosX,APosY,AImgNum); +VCommand:= T_Image.Create(APosX,APosY,AColumn,AImgNum); T_Page(Pages[Pred(FPages.Count)]).Commands.Add(VCommand); end; -procedure T_Section.LoadImgFooter(APosX,APosY,AImgNum: Integer); +procedure T_Section.LoadImgFooter(APosX,APosY: Single; AColumn,AImgNum: Integer); begin -VCommand:= T_Image.Create(APosX,APosY,AImgNum); +VCommand:= T_Image.Create(APosX,APosY,AColumn,AImgNum); FFooter.Add(VCommand); end; @@ -846,10 +848,11 @@ FStyle:= AStyle; FZone:= AZone; end; -constructor T_Image.Create(APosX,APosY,AImageNum: Integer); +constructor T_Image.Create(APosX,APosY: Single; AColumn,AImageNum: Integer); begin inherited Create; FImage:= AImageNum; +FColumn:= AColumn; FPosX:= APosX; FPosY:= APosY; end; diff --git a/extras/contributed/report_tool/reportengine/u_report.pas b/extras/contributed/report_tool/reportengine/u_report.pas index 9750820b..10a7178f 100644 --- a/extras/contributed/report_tool/reportengine/u_report.pas +++ b/extras/contributed/report_tool/reportengine/u_report.pas @@ -23,7 +23,7 @@ interface uses Classes, SysUtils, StrUtils, fpg_base, fpg_main, - fpg_panel, fpg_imgfmt_bmp, fpg_imgfmt_jpg, + fpg_panel, fpg_dialogs, fpg_imgfmt_bmp, fpg_imgfmt_jpg, U_Command, U_Pdf; type @@ -80,7 +80,7 @@ type procedure DrawALine(XBegin,YBegin,XEnd,YEnd: Single; StyLine: Integer); procedure DrawAHorizLine(XBegin,YBegin: Single; Column: Integer; XEnd: Single; StyLine: Integer; Zone: TZone); procedure PaintSurface(Points: T_Points; Couleur: TfpgColor); - procedure PaintImage(PosX,PosY,ImgNum: Integer; Zone: TZone); + procedure PaintImage(PosX,PosY: Single; Column,ImgNum: Integer; Zone: TZone); function GetSectionTitle: string; procedure SetSectionTitle(ATitle: string); public @@ -269,15 +269,15 @@ type // SpAfter = empty space after the horizontal line : numeric value in the measurement unit (msMM or msInch) // ColNum = column reference, default between left and right margins // StyleNum = reference of the line style - procedure SpaceHeader(Verti: Single; ColNum: Integer=0; BkColorNum: Integer= -1); + procedure SpaceHeader(Verti: Single; ColNum: Integer= 0; BkColorNum: Integer= -1); // Verti = height of the empty space : numeric value in the measurement unit (msMM or msInch) // ColNum = column reference, default between left and right margins // BkColorNum = background color reference, if > -1, replaces the column background color if any - procedure SpacePage(Verti: Single; ColNum: Integer=0; BkColorNum: Integer= -1); + procedure SpacePage(Verti: Single; ColNum: Integer= 0; BkColorNum: Integer= -1); // Verti = height of the empty space : numeric value in the measurement unit (msMM or msInch) // ColNum = column reference, default between left and right margins // BkColorNum = background color reference, if > -1, replaces the column background color if any - procedure SpaceFooter(Verti: Single; ColNum: Integer=0; BkColorNum: Integer= -1); + procedure SpaceFooter(Verti: Single; ColNum: Integer= 0; BkColorNum: Integer= -1); // Verti = height of the empty space : numeric value in the measurement unit (msMM or msInch) // ColNum = column reference, default between left and right margins // BkColorNum = background color reference, if > -1, replaces the column background color if any @@ -319,18 +319,36 @@ type // XLimits = list of horizontal positions of limit points // YLimits = list of vertical positions of limit points // AColor = colour to be painted within the limits - procedure ImageHeader(Horiz,Verti: Single; ImgFileName: string; Scale: Integer= 1); + procedure ImageHeader(Horiz,Verti: Single; ImgFileName: string; ColNum: Integer= 0; Scale: Integer= 1); // draw a bmp or jpg image at the defined position // Horiz = horizontal position in numeric value in the measurement unit (msMM or msInch) // Verti = vertical position in numeric value in the measurement unit (msMM or msInch) - procedure ImagePage(Horiz,Verti: Single; ImgFileName: string; Scale: Integer= 1); + // ImgFileName = name of the image file + // ColNum = column reference, default between left and right margins + // Scale = 1 for full size + // 2 for 1/2 size + // 3 for 1/3 size + // 4 for 1/4 size + procedure ImagePage(Horiz,Verti: Single; ImgFileName: string; ColNum: Integer= 0; Scale: Integer= 1); // draw a bmp or jpg image at the defined position // Horiz = horizontal position in numeric value in the measurement unit (msMM or msInch) // Verti = vertical position in numeric value in the measurement unit (msMM or msInch) - procedure ImageFooter(Horiz,Verti: Single; ImgFileName: string; Scale: Integer= 1); + // ImgFileName = name of the image file + // ColNum = column reference, default between left and right margins + // Scale = 1 for full size + // 2 for 1/2 size + // 3 for 1/3 size + // 4 for 1/4 size + procedure ImageFooter(Horiz,Verti: Single; ImgFileName: string; ColNum: Integer= 0; Scale: Integer= 1); // draw a bmp or jpg image at the defined position // Horiz = horizontal position in numeric value in the measurement unit (msMM or msInch) // Verti = vertical position in numeric value in the measurement unit (msMM or msInch) + // ImgFileName = name of the image file + // ColNum = column reference, default between left and right margins + // Scale = 1 for full size + // 2 for 1/2 size + // 3 for 1/3 size + // 4 for 1/4 size property Language: Char read FVersion write FVersion; property Visualiser: Boolean read FVisualization write FVisualization; property NumSection: Integer read FNmSection write FNmSection; @@ -791,7 +809,7 @@ with T_Section(Sections[Pred(NumSection)]) do if Cmd is T_Image then with Cmd as T_Image do - PaintImage(GetPosX,GetPosY,GetImage,zHeader); + PaintImage(GetPosX,GetPosY,GetColumn,GetImage,zHeader); end; if GetCmdPage(NumPageSection).Count> 0 then @@ -817,7 +835,7 @@ with T_Section(Sections[Pred(NumSection)]) do if Cmd is T_Image then with Cmd as T_Image do - PaintImage(GetPosX,GetPosY,GetImage,zPage); + PaintImage(GetPosX,GetPosY,GetColumn,GetImage,zPage); end; if CmdFooter.Count> 0 then @@ -844,7 +862,7 @@ with T_Section(Sections[Pred(NumSection)]) do if Cmd is T_Image then with Cmd as T_Image do - PaintImage(GetPosX,GetPosY,GetImage,zFooter); + PaintImage(GetPosX,GetPosY,GetColumn,GetImage,zFooter); end; if CmdFrames.Count> 0 then @@ -2141,21 +2159,35 @@ with T_Section(Sections[Pred(NumSection)]) do end; end; -procedure T_Report.PaintImage(PosX,PosY,ImgNum: Integer; Zone: TZone); +procedure T_Report.PaintImage(PosX,PosY: Single; Column,ImgNum: Integer; Zone: TZone); begin with T_Section(Sections[Pred(NumSection)]) do case FPreparation of ppPrepare: + begin + if Column> -1 + then + PosX:= T_Column(Columns[Column]).ColPos+PosX; case Zone of zHeader: - LoadImgHeader(PosX,PosY,ImgNum); + begin + PosY:= FCurrentMargin.T+PosY; + LoadImgHeader(PosX,PosY,Column,ImgNum); + end; zPage: - LoadImgPage(PosX,PosY,ImgNum); + begin + PosY:= FCurrentMargin.T+FHeaderHeight+PosY; + LoadImgPage(PosX,PosY,Column,ImgNum); + end; zFooter: - LoadImgFooter(PosX,PosY,ImgNum); + begin + PosY:= FCurrentMargin.B-FFooterHeight+PosY; + LoadImgFooter(PosX,PosY,Column,ImgNum); + end; end; + end; ppVisualize: - FCanvas.DrawImage(PosX,PosY,TfpgImage(Images[ImgNum])); + FCanvas.DrawImage(Round(PosX),Round(PosY),TfpgImage(Images[ImgNum])); ppPdfFile: begin PdfImg:= TPdfImg.Create; @@ -2892,79 +2924,97 @@ for Cpt:= 0 to Pred(Size) do PaintSurface(Ends,AColor); end; -procedure T_Report.ImageHeader(Horiz,Verti: Single; ImgFileName: string; Scale: Integer); +procedure T_Report.ImageHeader(Horiz,Verti: Single; ImgFileName: string; ColNum,Scale: Integer); var - PosH,PosV,RefImage: Integer; + RefImage: Integer; Image: TfpgImage; begin -PosH:= Round(Dim2Pixels(Horiz)); -PosV:= Round(Dim2Pixels(Verti)); -RefImage:= ImageNames.IndexOf(IntToStr(Scale)+ImgFileName); -if RefImage= -1 +Horiz:= Dim2Pixels(Horiz); +Verti:= Dim2Pixels(Verti); +if FileExists(ImgFileName) then begin - if Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'bmp' + RefImage:= ImageNames.IndexOf(IntToStr(Scale)+ImgFileName); + if RefImage= -1 then begin - Image:= LoadImage_BMP(ImgFileName); - Scale:= 1; + if Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'bmp' + then + begin + Image:= LoadImage_BMP(ImgFileName); + Scale:= 1; + end; + if (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'jpg') or (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),4)= 'jpeg') + then + Image:= LoadImage_JPG(ImgFileName,Scale); + RefImage:= Images.Add(Image); end; - if (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'jpg') or (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),4)= 'jpeg') - then - Image:= LoadImage_JPG(ImgFileName,Scale); - RefImage:= Images.Add(Image); - end; -PaintImage(PosH,PosV,RefImage,zHeader); + PaintImage(Horiz,Verti,ColNum,RefImage,zHeader); + end +else + ShowMessage('Image '+ImgFileName+' is missing'); end; -procedure T_Report.ImagePage(Horiz,Verti: Single; ImgFileName: string; Scale: Integer); +procedure T_Report.ImagePage(Horiz,Verti: Single; ImgFileName: string; ColNum,Scale: Integer); var - PosH,PosV,RefImage: Integer; + RefImage: Integer; Image: TfpgImage; begin -PosH:= Round(Dim2Pixels(Horiz)); -PosV:= Round(Dim2Pixels(Verti)); -RefImage:= ImageNames.IndexOf(IntToStr(Scale)+ImgFileName); -if RefImage= -1 +Horiz:= Dim2Pixels(Horiz); +Verti:= Dim2Pixels(Verti); +if FileExists(ImgFileName) then begin - if Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'bmp' + RefImage:= ImageNames.IndexOf(IntToStr(Scale)+ImgFileName); + if RefImage= -1 then begin - Image:= LoadImage_BMP(ImgFileName); - Scale:= 1; + if Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'bmp' + then + begin + Image:= LoadImage_BMP(ImgFileName); + Scale:= 1; + end; + if (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'jpg') or (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),4)= 'jpeg') + then + Image:= LoadImage_JPG(ImgFileName,Scale); + RefImage:= Images.Add(Image); end; - if (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'jpg') or (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),4)= 'jpeg') - then - Image:= LoadImage_JPG(ImgFileName,Scale); - RefImage:= Images.Add(Image); - end; -PaintImage(PosH,PosV,RefImage,zPage); + PaintImage(Horiz,Verti,ColNum,RefImage,zPage); + end +else + ShowMessage('Image '+ImgFileName+' is missing'); end; -procedure T_Report.ImageFooter(Horiz,Verti: Single; ImgFileName: string; Scale: Integer); +procedure T_Report.ImageFooter(Horiz,Verti: Single; ImgFileName: string; ColNum,Scale: Integer); var - PosH,PosV,RefImage: Integer; + RefImage: Integer; Image: TfpgImage; begin -PosH:= Round(Dim2Pixels(Horiz)); -PosV:= Round(Dim2Pixels(Verti)); -RefImage:= ImageNames.IndexOf(IntToStr(Scale)+ImgFileName); -if RefImage= -1 +Horiz:= Dim2Pixels(Horiz); +Verti:= Dim2Pixels(Verti); +if FileExists(ImgFileName) then begin - if Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'bmp' + RefImage:= ImageNames.IndexOf(IntToStr(Scale)+ImgFileName); + if RefImage= -1 then begin - Image:= LoadImage_BMP(ImgFileName); - Scale:= 1; + if Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'bmp' + then + begin + Image:= LoadImage_BMP(ImgFileName); + Scale:= 1; + end; + if (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'jpg') or (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),4)= 'jpeg') + then + Image:= LoadImage_JPG(ImgFileName,Scale); + RefImage:= Images.Add(Image); end; - if (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),3)= 'jpg') or (Copy(ImgFileName,Succ(Pos('.',ImgFileName)),4)= 'jpeg') - then - Image:= LoadImage_JPG(ImgFileName,Scale); - RefImage:= Images.Add(Image); - end; -PaintImage(PosH,PosV,RefImage,zFooter); + PaintImage(Horiz,Verti,ColNum,RefImage,zFooter); + end +else + ShowMessage('Image '+ImgFileName+' is missing'); end; end. |