You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7765 8e941d3f-bd1b-0410-a28a-d453659cc2b4
179 lines
3.5 KiB
ObjectPascal
179 lines
3.5 KiB
ObjectPascal
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 HelpBtnClick(Sender: TObject);
|
|
procedure ResetBtnClick(Sender: TObject);
|
|
private
|
|
|
|
protected
|
|
FAutoSized: Boolean;
|
|
procedure Activate; override;
|
|
procedure AdjustConstraints; virtual;
|
|
procedure Compute; virtual;
|
|
procedure InitForm; virtual;
|
|
procedure UpdateBtnStates; 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,
|
|
Globals, Utils;
|
|
|
|
|
|
{ TBasicStatsParamsForm }
|
|
|
|
constructor TBasicStatsParamsForm.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
|
|
InitForm;
|
|
Reset;
|
|
|
|
CloseBtn.OnClick := @CloseBtnClick;
|
|
ComputeBtn.OnClick := @ComputeBtnClick;
|
|
ResetBtn.OnClick := @ResetBtnClick;
|
|
HelpBtn.OnClick := @HelpBtnClick;
|
|
end;
|
|
|
|
|
|
procedure TBasicStatsParamsForm.Activate;
|
|
var
|
|
w: Integer;
|
|
topSpacing, bottomSpacing: Integer;
|
|
begin
|
|
if FAutoSized then
|
|
exit;
|
|
|
|
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
|
|
HelpBtn.Constraints.MinWidth := w;
|
|
ResetBtn.Constraints.MinWidth := w;
|
|
ComputeBtn.Constraints.MinWidth := w;
|
|
CloseBtn.Constraints.MinWidth := w;
|
|
|
|
AdjustConstraints;
|
|
|
|
topSpacing := max(ParamsPanel.BorderSpacing.Top, ParamsPanel.BorderSpacing.Around);
|
|
bottomSpacing := max(ParamsPanel.BorderSpacing.Bottom, ParamsPanel.BorderSpacing.Around);
|
|
|
|
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + topSpacing + bottomSpacing;
|
|
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;
|
|
|
|
if Width < Constraints.MinWidth then Width := 1; // enforce constraints
|
|
if Height < Constraints.MinHeight then Height := 1;
|
|
|
|
Position := poDesigned;
|
|
FAutoSized := true;
|
|
|
|
inherited;
|
|
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;
|
|
UpdateBtnStates;
|
|
end;
|
|
|
|
|
|
procedure TBasicStatsParamsForm.HelpBtnClick(Sender: TObject);
|
|
begin
|
|
if ContextHelpForm = nil then
|
|
Application.CreateForm(TContextHelpForm, ContextHelpForm);
|
|
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
|
|
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
|
|
AMsg := '';
|
|
AControl := nil;
|
|
Result := true;
|
|
end;
|
|
|
|
|
|
end.
|
|
|