You've already forked lazarus-ccr
LazStats: LazStats: Prepare more generalized layout by add form ancestors TBasicStatsReportForm and TBasicStatsReportAndChartForm
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7727 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
@ -121,7 +122,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item7>
|
||||
</RequiredPackages>
|
||||
<Units Count="178">
|
||||
<Units Count="180">
|
||||
<Unit0>
|
||||
<Filename Value="LazStats.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -1517,6 +1518,22 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="GroupFreqUnit"/>
|
||||
</Unit177>
|
||||
<Unit178>
|
||||
<Filename Value="forms\misc\basicstatsreportfromunit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="BasicStatsReportForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="BasicStatsReportFromUnit"/>
|
||||
</Unit178>
|
||||
<Unit179>
|
||||
<Filename Value="forms\misc\basicstatsreportandchartformunit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="BasicStatsReportAndChartForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="BasicStatsReportAndChartFormUnit"/>
|
||||
</Unit179>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -7,8 +7,9 @@ uses
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, tachartlazaruspkg, tachartprint, lhelpcontrolpkg,
|
||||
Globals, LicenseUnit, OptionsUnit, MainDM, MainUnit;
|
||||
Forms, tachartlazaruspkg, tachartprint, lhelpcontrolpkg, Globals, LicenseUnit,
|
||||
OptionsUnit, MainDM, MainUnit, BasicStatsReportFromUnit,
|
||||
BasicStatsReportAndChartFormUnit;
|
||||
|
||||
{$R LazStats.res}
|
||||
|
||||
@ -28,6 +29,8 @@ begin
|
||||
end;
|
||||
Application.CreateForm(TMainDataModule, MainDataModule);
|
||||
Application.CreateForm(TOS3MainFrm, OS3MainFrm);
|
||||
Application.CreateForm(TBasicStatsReportAndChartForm,
|
||||
BasicStatsReportAndChartForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
@ -1,25 +1,27 @@
|
||||
inherited GroupFreqForm: TGroupFreqForm
|
||||
Height = 212
|
||||
Height = 279
|
||||
Width = 673
|
||||
Caption = 'Group Frequency Analysis'
|
||||
ClientHeight = 212
|
||||
ClientHeight = 279
|
||||
ClientWidth = 673
|
||||
inherited ParamsPanel: TPanel
|
||||
Height = 196
|
||||
ClientHeight = 196
|
||||
Height = 263
|
||||
ClientHeight = 263
|
||||
inherited CloseBtn: TButton
|
||||
Top = 171
|
||||
Top = 238
|
||||
end
|
||||
inherited ComputeBtn: TButton
|
||||
Top = 171
|
||||
Top = 238
|
||||
end
|
||||
inherited ResetBtn: TButton
|
||||
Top = 171
|
||||
Top = 238
|
||||
end
|
||||
inherited HelpBtn: TButton
|
||||
Tag = 162
|
||||
Top = 171
|
||||
Top = 238
|
||||
end
|
||||
inherited ButtonBevel: TBevel
|
||||
Top = 155
|
||||
Top = 222
|
||||
end
|
||||
object Label1: TLabel[5]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
@ -38,7 +40,7 @@ inherited GroupFreqForm: TGroupFreqForm
|
||||
AnchorSideRight.Control = GrpInBtn
|
||||
AnchorSideBottom.Control = ButtonBevel
|
||||
Left = 0
|
||||
Height = 138
|
||||
Height = 205
|
||||
Top = 17
|
||||
Width = 126
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
@ -184,6 +186,6 @@ inherited GroupFreqForm: TGroupFreqForm
|
||||
end
|
||||
end
|
||||
inherited ParamsSplitter: TSplitter
|
||||
Height = 212
|
||||
Height = 279
|
||||
end
|
||||
end
|
||||
|
@ -32,12 +32,12 @@ type
|
||||
procedure VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
private
|
||||
FLabelsSource: TListChartSource;
|
||||
procedure UpdateBtnStates;
|
||||
|
||||
protected
|
||||
procedure AdjustConstraints; override;
|
||||
procedure Compute; override;
|
||||
procedure Plot(XLabels: StrDyneVec; FreqValues: DblDyneVec; XTitle: String);
|
||||
procedure UpdateBtnStates; override;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -83,8 +83,8 @@ end;
|
||||
|
||||
|
||||
procedure TGroupFreqForm.Compute;
|
||||
VAR
|
||||
nogroups, mingrp, maxgrp, grpcol, minfreq, maxfreq: integer;
|
||||
var
|
||||
grpcol: integer;
|
||||
cellStr: string;
|
||||
i, numValues, valueIdx: integer;
|
||||
freq: DblDyneVec = nil; // Could be IntDyneVec, but easier plotting with Dbl
|
||||
@ -243,21 +243,21 @@ procedure TGroupFreqForm.Reset;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
VarList.Clear;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
GrpVarEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
|
||||
FChartFrame.Clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGroupFreqForm.UpdateBtnStates;
|
||||
begin
|
||||
GrpInBtn.Enabled := VarList.ItemIndex > -1;
|
||||
inherited;
|
||||
GrpInBtn.Enabled := (VarList.ItemIndex > -1);
|
||||
GrpOutBtn.Enabled := (GrpVarEdit.Text <> '');
|
||||
FChartFrame.UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
inherited BasicStatsChartForm: TBasicStatsChartForm
|
||||
OnActivate = nil
|
||||
OnCreate = FormCreate
|
||||
inherited ParamsPanel: TPanel
|
||||
inherited CloseBtn: TButton
|
||||
OnClick = CloseBtnClick
|
||||
|
@ -20,9 +20,11 @@ type
|
||||
|
||||
protected
|
||||
FChartFrame: TChartFrame;
|
||||
procedure UpdateBtnStates; override;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Reset; override;
|
||||
|
||||
end;
|
||||
|
||||
@ -58,5 +60,21 @@ begin
|
||||
Reset;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsChartForm.Reset;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(FChartFrame) then
|
||||
FChartFrame.Clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsChartForm.UpdateBtnStates;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(FChartFrame) then
|
||||
FChartFrame.UpdateBtnStates;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
inherited BasicStatsParamsForm: TBasicStatsParamsForm
|
||||
Caption = 'BasicStatsParamsForm'
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
Position = poMainFormCenter
|
||||
object ParamsPanel: TPanel[0]
|
||||
Left = 8
|
||||
|
@ -22,16 +22,17 @@ type
|
||||
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 Activate; override;
|
||||
procedure AdjustConstraints; virtual;
|
||||
procedure Compute; virtual;
|
||||
procedure InitForm;
|
||||
procedure UpdateBtnStates; virtual;
|
||||
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; virtual;
|
||||
|
||||
public
|
||||
@ -49,7 +50,7 @@ implementation
|
||||
|
||||
uses
|
||||
Math,
|
||||
Utils;
|
||||
Globals, Utils;
|
||||
|
||||
|
||||
{ TBasicStatsParamsForm }
|
||||
@ -57,6 +58,10 @@ uses
|
||||
constructor TBasicStatsParamsForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
InitForm;
|
||||
Reset;
|
||||
|
||||
CloseBtn.OnClick := @CloseBtnClick;
|
||||
ComputeBtn.OnClick := @ComputeBtnClick;
|
||||
ResetBtn.OnClick := @ResetBtnClick;
|
||||
@ -64,6 +69,29 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsParamsForm.Activate;
|
||||
var
|
||||
w: Integer;
|
||||
begin
|
||||
if FAutoSized then
|
||||
exit;
|
||||
|
||||
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
|
||||
HelpBtn.Constraints.MinWidth := 2;
|
||||
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.AdjustConstraints;
|
||||
begin
|
||||
// be be overridden
|
||||
@ -98,34 +126,6 @@ begin
|
||||
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
|
||||
@ -135,12 +135,26 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsParamsForm.InitForm;
|
||||
begin
|
||||
Width := Scale96ToFont(DEFAULT_WIDTH);
|
||||
Height := Scale96ToFont(DEFAULT_HEIGHT);
|
||||
Position := poMainFormCenter;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsParamsForm.ResetBtnClick(Sender: TObject);
|
||||
begin
|
||||
Reset;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsParamsForm.UpdateBtnStates;
|
||||
begin
|
||||
// to be overridden
|
||||
end;
|
||||
|
||||
|
||||
function TBasicStatsParamsForm.Validate(out AMsg: String;
|
||||
out AControl: TWinControl): Boolean;
|
||||
begin
|
||||
|
@ -0,0 +1,22 @@
|
||||
inherited BasicStatsReportAndChartForm: TBasicStatsReportAndChartForm
|
||||
object PageControl: TPageControl[2]
|
||||
Left = 312
|
||||
Height = 443
|
||||
Top = 8
|
||||
Width = 397
|
||||
ActivePage = ReportPage
|
||||
Align = alClient
|
||||
BorderSpacing.Left = 4
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
TabIndex = 0
|
||||
TabOrder = 2
|
||||
object ReportPage: TTabSheet
|
||||
Caption = 'Report'
|
||||
end
|
||||
object ChartPage: TTabSheet
|
||||
Caption = 'Chart'
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,78 @@
|
||||
unit BasicStatsReportAndChartFormUnit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
|
||||
StdCtrls, ReportFrameUnit, ChartFrameUnit, BasicStatsParamsFormUnit;
|
||||
|
||||
type
|
||||
|
||||
{ TBasicStatsReportAndChartForm }
|
||||
|
||||
TBasicStatsReportAndChartForm = class(TBasicStatsParamsForm)
|
||||
PageControl: TPageControl;
|
||||
ReportPage: TTabSheet;
|
||||
ChartPage: TTabSheet;
|
||||
private
|
||||
|
||||
protected
|
||||
FReportFrame: TReportFrame;
|
||||
FChartFrame: TChartFrame;
|
||||
procedure UpdateBtnStates; override;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Reset; override;
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
BasicStatsReportAndChartForm: TBasicStatsReportAndChartForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
constructor TBasicStatsReportAndChartForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
FReportFrame := TReportFrame.Create(self);
|
||||
FReportFrame.Parent := ReportPage;
|
||||
FReportFrame.Align := alClient;
|
||||
|
||||
FChartFrame := TChartFrame.Create(self);
|
||||
FChartFrame.Parent := ChartPage;
|
||||
FChartFrame.Align := alClient;
|
||||
FChartFrame.Chart.BottomAxis.Intervals.MaxLength := 80;
|
||||
FChartFrame.Chart.BottomAxis.Intervals.MinLength := 30;
|
||||
|
||||
Reset;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsReportAndChartForm.Reset;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(FReportFrame) then
|
||||
FReportFrame.Clear;
|
||||
if Assigned(FChartFrame) then
|
||||
FChartFrame.Clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsReportAndChartForm.UpdateBtnStates;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(FReportFrame) then
|
||||
FReportFrame.UpdateBtnStates;
|
||||
if Assigned(FChartFrame) then
|
||||
FChartFrame.UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
@ -0,0 +1,4 @@
|
||||
inherited BasicStatsReportForm: TBasicStatsReportForm
|
||||
Caption = 'BasicStatsReportForm'
|
||||
OnCreate = FormCreate
|
||||
end
|
@ -0,0 +1,73 @@
|
||||
unit BasicStatsReportFromUnit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
|
||||
ReportFrameUnit, BasicStatsParamsFormUnit;
|
||||
|
||||
type
|
||||
|
||||
{ TBasicStatsReportForm }
|
||||
|
||||
TBasicStatsReportForm = class(TBasicStatsParamsForm)
|
||||
private
|
||||
|
||||
protected
|
||||
FReportFrame: TReportFrame;
|
||||
procedure UpdateBtnStates; override;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Reset; override;
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
BasicStatsReportForm: TBasicStatsReportForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Utils;
|
||||
|
||||
constructor TBasicStatsReportForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
FReportFrame := TReportFrame.Create(self);
|
||||
FReportFrame.Parent := Self;
|
||||
FReportFrame.Align := alClient;
|
||||
FReportFrame.BorderSpacing.Left := 4;
|
||||
FReportFrame.BorderSpacing.Top := 8;
|
||||
FReportFrame.BorderSpacing.Bottom := 8;
|
||||
FReportFrame.BorderSpacing.Right := 8;
|
||||
|
||||
InitToolbar(FReportFrame.ReportToolbar, tpRight);
|
||||
|
||||
Reset;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsReportForm.Reset;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(FReportFrame) then
|
||||
FReportFrame.Clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBasicStatsReportForm.UpdateBtnStates;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(FReportFrame) then
|
||||
FReportFrame.UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user