diff --git a/applications/lazstats/source/LazStats.lpi b/applications/lazstats/source/LazStats.lpi
index 3256533b8..184b7184f 100644
--- a/applications/lazstats/source/LazStats.lpi
+++ b/applications/lazstats/source/LazStats.lpi
@@ -121,7 +121,7 @@
-
+
@@ -1176,331 +1176,347 @@
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/applications/lazstats/source/LazStats.lpr b/applications/lazstats/source/LazStats.lpr
index ea6dfea7e..f5503f6f3 100644
--- a/applications/lazstats/source/LazStats.lpr
+++ b/applications/lazstats/source/LazStats.lpr
@@ -8,8 +8,7 @@ uses
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, tachartlazaruspkg, tachartprint, lhelpcontrolpkg,
- Globals, LicenseUnit, OptionsUnit, MainDM, MainUnit, ReportFrameUnit,
-BasicStatsFormUnit;
+ Globals, LicenseUnit, OptionsUnit, MainDM, MainUnit;
{$R LazStats.res}
@@ -29,7 +28,6 @@ begin
end;
Application.CreateForm(TMainDataModule, MainDataModule);
Application.CreateForm(TOS3MainFrm, OS3MainFrm);
- Application.CreateForm(TBasicStatsForm, BasicStatsForm);
Application.Run;
end.
diff --git a/applications/lazstats/source/forms/misc/basicstatschartformunit.lfm b/applications/lazstats/source/forms/misc/basicstatschartformunit.lfm
new file mode 100644
index 000000000..7266ea254
--- /dev/null
+++ b/applications/lazstats/source/forms/misc/basicstatschartformunit.lfm
@@ -0,0 +1,18 @@
+inherited BasicStatsChartForm: TBasicStatsChartForm
+ OnActivate = nil
+ OnCreate = FormCreate
+ inherited ParamsPanel: TPanel
+ inherited CloseBtn: TButton
+ OnClick = CloseBtnClick
+ end
+ inherited ComputeBtn: TButton
+ OnClick = ComputeBtnClick
+ end
+ inherited ResetBtn: TButton
+ OnClick = ResetBtnClick
+ end
+ inherited HelpBtn: TButton
+ OnClick = HelpBtnClick
+ end
+ end
+end
diff --git a/applications/lazstats/source/forms/misc/basicstatschartformunit.pas b/applications/lazstats/source/forms/misc/basicstatschartformunit.pas
new file mode 100644
index 000000000..27359ffd1
--- /dev/null
+++ b/applications/lazstats/source/forms/misc/basicstatschartformunit.pas
@@ -0,0 +1,62 @@
+{ Template for LazStats forms containing the ParamsPanel and a ChartFrame }
+
+unit BasicStatsChartFormUnit;
+
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
+ ChartFrameUnit, BasicStatsParamsFormUnit;
+
+type
+
+ { TBasicStatsChartForm }
+
+ TBasicStatsChartForm = class(TBasicStatsParamsForm)
+ private
+
+ protected
+ FChartFrame: TChartFrame;
+
+ public
+ constructor Create(AOwner: TComponent); override;
+
+ end;
+
+var
+ BasicStatsChartForm: TBasicStatsChartForm;
+
+
+implementation
+
+{$R *.lfm}
+
+uses
+ Utils;
+
+{ TBasicStatsChartForm }
+
+constructor TBasicStatsChartForm.Create(AOwner: TComponent);
+begin
+ inherited;
+
+ FChartFrame := TChartFrame.Create(self);
+ FChartFrame.Parent := Self;
+ FChartFrame.Align := alClient;
+ FChartFrame.Chart.BottomAxis.Intervals.MaxLength := 80;
+ FChartFrame.Chart.BottomAxis.Intervals.MinLength := 30;
+ FChartFrame.BorderSpacing.Left := 4;
+ FChartFrame.BorderSpacing.Top := 8;
+ FChartFrame.BorderSpacing.Bottom := 8;
+ FChartFrame.BorderSpacing.Right := 8;
+
+ InitToolbar(FChartFrame.ChartToolbar, tpRight);
+
+ Reset;
+end;
+
+end.
+
diff --git a/applications/lazstats/source/forms/misc/basicstatsparamsformunit.lfm b/applications/lazstats/source/forms/misc/basicstatsparamsformunit.lfm
new file mode 100644
index 000000000..05f571e00
--- /dev/null
+++ b/applications/lazstats/source/forms/misc/basicstatsparamsformunit.lfm
@@ -0,0 +1,96 @@
+inherited BasicStatsParamsForm: TBasicStatsParamsForm
+ Caption = 'BasicStatsParamsForm'
+ OnActivate = FormActivate
+ OnCreate = FormCreate
+ Position = poMainFormCenter
+ object ParamsPanel: TPanel[0]
+ Left = 8
+ Height = 443
+ Top = 8
+ Width = 291
+ Align = alLeft
+ BorderSpacing.Left = 8
+ BorderSpacing.Top = 8
+ BorderSpacing.Right = 4
+ BorderSpacing.Bottom = 8
+ BevelOuter = bvNone
+ ClientHeight = 443
+ ClientWidth = 291
+ TabOrder = 0
+ object CloseBtn: TButton
+ AnchorSideRight.Control = ParamsPanel
+ AnchorSideRight.Side = asrBottom
+ AnchorSideBottom.Control = ParamsPanel
+ AnchorSideBottom.Side = asrBottom
+ Left = 236
+ Height = 25
+ Top = 418
+ Width = 55
+ Anchors = [akRight, akBottom]
+ AutoSize = True
+ BorderSpacing.Left = 8
+ BorderSpacing.Top = 8
+ Caption = 'Close'
+ TabOrder = 0
+ end
+ object ComputeBtn: TButton
+ AnchorSideTop.Control = CloseBtn
+ AnchorSideRight.Control = CloseBtn
+ Left = 153
+ Height = 25
+ Top = 418
+ Width = 75
+ Anchors = [akTop, akRight]
+ BorderSpacing.Left = 8
+ BorderSpacing.Right = 8
+ Caption = 'Compute'
+ TabOrder = 1
+ end
+ object ResetBtn: TButton
+ AnchorSideTop.Control = CloseBtn
+ AnchorSideRight.Control = ComputeBtn
+ Left = 91
+ Height = 25
+ Top = 418
+ Width = 54
+ Anchors = [akTop, akRight]
+ AutoSize = True
+ BorderSpacing.Left = 8
+ BorderSpacing.Right = 8
+ Caption = 'Reset'
+ TabOrder = 2
+ end
+ object HelpBtn: TButton
+ AnchorSideTop.Control = CloseBtn
+ AnchorSideRight.Control = ResetBtn
+ Left = 32
+ Height = 25
+ Top = 418
+ Width = 51
+ Anchors = [akTop, akRight]
+ AutoSize = True
+ BorderSpacing.Right = 8
+ Caption = 'Help'
+ TabOrder = 3
+ end
+ object ButtonBevel: TBevel
+ AnchorSideLeft.Control = ParamsPanel
+ AnchorSideRight.Control = ParamsPanel
+ AnchorSideRight.Side = asrBottom
+ AnchorSideBottom.Control = CloseBtn
+ Left = 0
+ Height = 8
+ Top = 402
+ Width = 291
+ Anchors = [akLeft, akRight, akBottom]
+ Shape = bsBottomLine
+ end
+ end
+ object ParamsSplitter: TSplitter[1]
+ Left = 303
+ Height = 459
+ Top = 0
+ Width = 5
+ ResizeStyle = rsPattern
+ end
+end
diff --git a/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas b/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas
new file mode 100644
index 000000000..597fa2da9
--- /dev/null
+++ b/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas
@@ -0,0 +1,154 @@
+unit BasicStatsParamsFormUnit;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
+ ContextHelpUnit, BasicStatsFormUnit;
+
+type
+
+ { TBasicStatsParamsForm }
+
+ TBasicStatsParamsForm = class(TBasicStatsForm)
+ ButtonBevel: TBevel;
+ CloseBtn: TButton;
+ ComputeBtn: TButton;
+ ResetBtn: TButton;
+ HelpBtn: TButton;
+ ParamsPanel: TPanel;
+ ParamsSplitter: TSplitter;
+ procedure CloseBtnClick(Sender: TObject);
+ procedure ComputeBtnClick(Sender: TObject);
+ procedure FormActivate(Sender: TObject);
+ procedure FormCreate(Sender: TObject);
+ procedure HelpBtnClick(Sender: TObject);
+ procedure ResetBtnClick(Sender: TObject);
+ private
+
+ protected
+ FAutoSized: Boolean;
+ procedure AdjustConstraints; virtual;
+ procedure Compute; virtual;
+ function Validate(out AMsg: String; out AControl: TWinControl): Boolean; virtual;
+
+ public
+ constructor Create(AOwner: TComponent); override;
+
+ end;
+
+var
+ BasicStatsParamsForm: TBasicStatsParamsForm;
+
+
+implementation
+
+{$R *.lfm}
+
+uses
+ Math,
+ Utils;
+
+
+{ TBasicStatsParamsForm }
+
+constructor TBasicStatsParamsForm.Create(AOwner: TComponent);
+begin
+ inherited;
+ CloseBtn.OnClick := @CloseBtnClick;
+ ComputeBtn.OnClick := @ComputeBtnClick;
+ ResetBtn.OnClick := @ResetBtnClick;
+ HelpBtn.OnClick := @HelpBtnClick;
+end;
+
+
+procedure TBasicStatsParamsForm.AdjustConstraints;
+begin
+ // be be overridden
+end;
+
+
+procedure TBasicStatsParamsForm.CloseBtnClick(Sender: TObject);
+begin
+ Close;
+end;
+
+
+procedure TBasicStatsParamsForm.Compute;
+begin
+ // to be overridden
+end;
+
+
+procedure TBasicStatsParamsForm.ComputeBtnClick(Sender: TObject);
+var
+ msg: String;
+ C: TWinControl;
+begin
+ if not Validate(msg, C) then
+ begin
+ if Assigned(C) and C.CanFocus then
+ C.SetFocus;
+ ErrorMsg(msg);
+ exit;
+ end;
+
+ Compute;
+end;
+
+procedure TBasicStatsParamsForm.FormActivate(Sender: TObject);
+var
+ w: Integer;
+begin
+ if FAutoSized then
+ exit;
+
+ w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
+ ResetBtn.Constraints.MinWidth := w;
+ ComputeBtn.Constraints.MinWidth := w;
+ CloseBtn.Constraints.MinWidth := w;
+
+ AdjustConstraints;
+
+ if Width < Constraints.MinWidth then Width := 1; // enforce constraints
+ if Height < Constraints.MinHeight then Height := 1;
+
+ Position := poDesigned;
+ FAutoSized := true;
+end;
+
+
+procedure TBasicStatsParamsForm.FormCreate(Sender: TObject);
+begin
+ InitForm(self);
+ Reset;
+end;
+
+
+procedure TBasicStatsParamsForm.HelpBtnClick(Sender: TObject);
+begin
+ if ContextHelpForm = nil then
+ Application.CreateForm(TContextHelpForm, ContextHelpForm);
+ ContextHelpForm.HelpMessage((Sender as TButton).Tag);
+end;
+
+
+procedure TBasicStatsParamsForm.ResetBtnClick(Sender: TObject);
+begin
+ Reset;
+end;
+
+
+function TBasicStatsParamsForm.Validate(out AMsg: String;
+ out AControl: TWinControl): Boolean;
+begin
+ AMsg := '';
+ AControl := nil;
+ Result := true;
+end;
+
+
+end.
+