tvplaint: Add missing files of fulldemo (ExVpRptSetup.*)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5060 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-08-01 10:08:42 +00:00
parent 84084e84f5
commit 96c497ed73
2 changed files with 290 additions and 0 deletions

View File

@ -0,0 +1,100 @@
object frmReportSetup: TfrmReportSetup
Left = 380
Height = 138
Top = 138
Width = 254
BorderStyle = bsDialog
Caption = 'Report Setup'
ClientHeight = 138
ClientWidth = 254
Color = clBtnFace
Font.Color = clWindowText
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '1.4.4.0'
object lblStartDate: TLabel
Left = 16
Height = 15
Top = 16
Width = 54
Caption = 'Start Date:'
FocusControl = edStartDate
ParentColor = False
end
object lblEndDate: TLabel
Left = 20
Height = 15
Top = 40
Width = 50
Caption = 'End Date:'
FocusControl = edEndDate
ParentColor = False
end
object lblFormat: TLabel
Left = 29
Height = 15
Top = 75
Width = 41
Caption = 'Format:'
FocusControl = VpPrintFormatComboBox1
ParentColor = False
end
object btnOK: TButton
Left = 90
Height = 25
Top = 104
Width = 75
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 3
end
object btnCancel: TButton
Left = 170
Height = 25
Top = 104
Width = 75
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 4
end
object VpPrintFormatComboBox1: TVpPrintFormatComboBox
Left = 76
Height = 23
Top = 72
Width = 169
ItemHeight = 15
Sorted = True
TabOrder = 2
end
object edStartDate: TDateEdit
Left = 76
Height = 23
Top = 12
Width = 171
CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
OKCaption = 'OK'
CancelCaption = 'Cancel'
DateOrder = doNone
ButtonWidth = 23
NumGlyphs = 1
MaxLength = 0
TabOrder = 0
end
object edEndDate: TDateEdit
Left = 76
Height = 23
Top = 36
Width = 171
CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
OKCaption = 'OK'
CancelCaption = 'Cancel'
DateOrder = doNone
ButtonWidth = 23
NumGlyphs = 1
MaxLength = 0
TabOrder = 1
end
end

View File

@ -0,0 +1,190 @@
{* ***** BEGIN LICENSE BLOCK ***** *}
{* Version: MPL 1.1 *}
{* *}
{* The contents of this file are subject to the Mozilla Public License *}
{* Version 1.1 (the "License"); you may not use this file except in *}
{* compliance with the License. You may obtain a copy of the License at *}
{* http://www.mozilla.org/MPL/ *}
{* *}
{* Software distributed under the License is distributed on an "AS IS" basis, *}
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
{* for the specific language governing rights and limitations under the *}
{* License. *}
{* *}
{* The Original Code is TurboPower Visual PlanIt *}
{* *}
{* The Initial Developer of the Original Code is TurboPower Software *}
{* *}
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
{* TurboPower Software Inc. All Rights Reserved. *}
{* *}
{* Contributor(s): *}
{* *}
{* ***** END LICENSE BLOCK ***** *}
unit ExVpRptSetup;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, EditBtn,
VpBaseDS, VpPrtFmtCBox;
type
TReportDataRec = record
StartDate, EndDate : TDateTime;
Format : string;
end;
{ TfrmReportSetup }
TfrmReportSetup = class(TForm)
btnOK: TButton;
btnCancel: TButton;
lblStartDate: TLabel;
lblEndDate: TLabel;
lblFormat: TLabel;
edStartDate: TDateEdit;
edEndDate: TDateEdit;
VpPrintFormatComboBox1: TVpPrintFormatComboBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure PositionControls;
procedure SetCaptions;
function GetControlLink: TVpControlLink;
procedure SetControlLink(const Value: TVpControlLink);
function GetDate(Index: Integer): TDateTime;
procedure SetDate(Index: Integer; Value: TDateTime);
procedure SaveData(out ReportData: TReportDataRec);
public
{ Public declarations }
function Execute(var ReportData: TReportDataRec) : Boolean;
property ControlLink : TVpControlLink
read GetControlLink write SetControlLink;
property StartDate : TDateTime index 1
read GetDate write SetDate;
property EndDate : TDateTime index 2
read GetDate write SetDate;
end;
var
frmReportSetup: TfrmReportSetup;
ReportData: TReportDataRec = (StartDate: 0; EndDate: 0; Format: '');
implementation
{$R *.LFM}
uses
Math, VpSR, VpMisc;
{ TfrmReportSetup }
function TfrmReportSetup.Execute(var ReportData: TReportDataRec) : Boolean;
begin
StartDate := ReportData.StartDate;
EndDate := ReportData.EndDate;
VpPrintFormatCombobox1.ItemIndex := ControlLink.Printer.Find(ReportData.Format);
Result := ShowModal = mrOk;
if Result then
SaveData(ReportData);
end;
procedure TfrmReportSetup.FormCreate(Sender: TObject);
begin
SetCaptions;
end;
procedure TfrmReportSetup.FormShow(Sender: TObject);
begin
PositionControls;
end;
function TfrmReportSetup.GetControlLink: TVpControlLink;
begin
Result := VpPrintFormatComboBox1.ControlLink;
end;
function TfrmReportSetup.GetDate(Index: Integer) : TDateTime;
begin
Result := 0.0;
case Index of
1: Result := edStartDate.Date;
2: Result := edEndDate.Date;
end;
end;
procedure TfrmReportSetup.PositionControls;
var
w: Integer;
delta: Integer = 8;
begin
delta := ScaleX(8, DesignTimeDPI);
w := Maxvalue([GetLabelWidth(lblStartDate), GetLabelWidth(lblEndDate), GetLabelWidth(lblFormat)]);
edStartDate.Left := delta + w + delta;
lblStartDate.Left := edStartDate.Left - delta - GetLabelWidth(lblStartDate);
edEndDate.Left := edStartDate.Left;
lblEndDate.Left := edEndDate.Left - delta - GetLabelWidth(lblEndDate);
VpPrintFormatCombobox1.Left := edStartDate.Left;
lblFormat.Left := VpPrintFormatCombobox1.Left - delta - GetLabelWidth(lblFormat);
ClientWidth := RightOf(edStartDate) + delta;
w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel));
btnOK.Width := w;
btnCancel.Width := w;
btnCancel.Left := ClientWidth - delta - w;
btnOK.Left := btnCancel.Left - delta - w;
end;
procedure TfrmReportSetup.SaveData(out ReportData: TReportDataRec);
begin
if (edStartDate.Text = '') and (edEndDate.Text = '') then begin
ReportData.StartDate := now;
ReportData.EndDate := now;
end else
if (edStartDate.Text = '') then begin
ReportData.EndDate := edEndDate.Date;
ReportData.StartDate := edEndDate.Date;
end else
if (edEndDate.Text = '') then begin
ReportData.StartDate := edStartDate.Date;
ReportData.EndDate := edStartDate.date;
end else
begin
ReportData.StartDate := edStartDate.Date;
ReportData.EndDate := edEndDate.Date;
end;
ReportData.Format := VpPrintFormatComboBox1.Text;
end;
procedure TfrmReportSetup.SetCaptions;
begin
Caption := RSReportSetup;
lblStartDate.Caption := RSStartTimeLbl;
lblEndDate.Caption := RSEndTimeLbl;
lblFormat.Caption := RSFormatLbl;
btnOK.Caption := RSOKBtn;
btnCancel.Caption := RSCancelBtn;
end;
procedure TfrmReportSetup.SetControlLink(const Value: TVpControlLink);
begin
VpPrintFormatComboBox1.ControlLink := Value;
end;
procedure TfrmReportSetup.SetDate(Index: Integer;
Value: TDateTime);
begin
case Index of
1: edStartDate.Date := Value;
2: edEndDate.Date := Value;
end;
end;
end.