1{
2    This file is part of the Free Component Library.
3    Copyright (c) 2017 Michael Van Canneyt, member of the Free Pascal development team
4
5    Report property editor.
6
7    See the file COPYING.FPC, included in this distribution,
8    for details about the copyright.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 **********************************************************************}
15unit frmfpreportproperties;
16
17{$mode objfpc}{$H+}
18
19interface
20
21uses
22  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
23  StdCtrls, fpreport, reportdesignbaseforms;
24
25type
26  TForm = TBaseReportEditorForm;
27
28  { TReportPropertiesForm }
29
30  TReportPropertiesForm = class(TForm)
31    BPReportProps: TButtonPanel;
32    CBTwoPass: TCheckBox;
33    ETitle: TEdit;
34    EAuthor: TEdit;
35    LLDateCreated: TLabel;
36    LDateCreation: TLabel;
37    Label2: TLabel;
38    LCBTwoPass: TLabel;
39    LTitle: TLabel;
40    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
41  protected
42    procedure SetReport(AValue: TFPCustomReport); override;
43  Public
44    Procedure FormToReport; virtual;
45    Procedure ReportToForm; virtual;
46  end;
47
48implementation
49
50{$R *.lfm}
51
52{ TReportPropertiesForm }
53
54procedure TReportPropertiesForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
55begin
56  CanClose:=true;
57  If ModalResult=mrOK then
58    FormToReport;
59end;
60
61procedure TReportPropertiesForm.SetReport(AValue: TFPCustomReport);
62begin
63  Inherited;
64  if Assigned(Report) then
65    ReportToForm;
66end;
67
68procedure TReportPropertiesForm.FormToReport;
69begin
70  If Not Assigned(Report) then
71    Raise Exception.Create('No report to save to');
72  Report.Author  := EAuthor.Text;
73  Report.Title   := ETitle.Text;
74  Report.TwoPass := CBTWopass.Checked;
75end;
76
77procedure TReportPropertiesForm.ReportToForm;
78begin
79  If Not Assigned(Report) then
80    Raise Exception.Create('No report to load');
81  EAuthor.Text:=Report.Author;
82  ETitle.Text:=Report.Title;
83  CBTWopass.Checked:=Report.TwoPass;
84  LDateCreation.Caption:=FormatDateTime('ddd yyyy-mm-dd hh:nn:ss',Report.DateCreated);
85end;
86
87initialization
88  ReportPropertiesFormClass:=TReportPropertiesForm;
89end.
90
91