diff --git a/applications/lazstats/LazStats.chm b/applications/lazstats/LazStats.chm index 24ed877d1..6c48819f7 100644 Binary files a/applications/lazstats/LazStats.chm and b/applications/lazstats/LazStats.chm differ diff --git a/applications/lazstats/docs/HelpNDoc/LazStats.hnd b/applications/lazstats/docs/HelpNDoc/LazStats.hnd index c8645d25f..9636bdd08 100644 Binary files a/applications/lazstats/docs/HelpNDoc/LazStats.hnd and b/applications/lazstats/docs/HelpNDoc/LazStats.hnd differ diff --git a/applications/lazstats/source/forms/simulations/gensequnit.lfm b/applications/lazstats/source/forms/simulations/gensequnit.lfm index 557e2344e..7ce38ec06 100644 --- a/applications/lazstats/source/forms/simulations/gensequnit.lfm +++ b/applications/lazstats/source/forms/simulations/gensequnit.lfm @@ -1,23 +1,27 @@ object GenSeqFrm: TGenSeqFrm Left = 390 - Height = 192 + Height = 231 Top = 114 Width = 367 AutoSize = True + BorderStyle = bsDialog Caption = 'Generation of Sequential Values' - ClientHeight = 192 + ClientHeight = 231 ClientWidth = 367 + OnActivate = FormActivate OnCreate = FormCreate OnShow = FormShow Position = poMainFormCenter LCLVersion = '2.1.0.0' object Label1: TLabel AnchorSideLeft.Control = Owner + AnchorSideTop.Control = StartAtEdit + AnchorSideTop.Side = asrCenter AnchorSideRight.Control = Label2 AnchorSideRight.Side = asrBottom - Left = 47 + Left = 99 Height = 15 - Top = 96 + Top = 94 Width = 99 Anchors = [akTop, akRight] BorderSpacing.Left = 12 @@ -26,10 +30,12 @@ object GenSeqFrm: TGenSeqFrm end object Label2: TLabel AnchorSideLeft.Control = Owner + AnchorSideTop.Control = IncrEdit + AnchorSideTop.Side = asrCenter AnchorSideRight.Control = IncrEdit - Left = 34 + Left = 86 Height = 15 - Top = 127 + Top = 125 Width = 112 Anchors = [akTop, akRight] BorderSpacing.Left = 12 @@ -39,11 +45,13 @@ object GenSeqFrm: TGenSeqFrm end object Label3: TLabel AnchorSideLeft.Control = Owner + AnchorSideTop.Control = LabelEdit + AnchorSideTop.Side = asrCenter AnchorSideRight.Control = Label2 AnchorSideRight.Side = asrBottom - Left = 41 + Left = 93 Height = 15 - Top = 160 + Top = 156 Width = 105 Anchors = [akTop, akRight] BorderSpacing.Left = 12 @@ -52,11 +60,12 @@ object GenSeqFrm: TGenSeqFrm end object RadioGroup1: TRadioGroup AnchorSideLeft.Control = Owner + AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = Owner - Left = 8 + Left = 71 Height = 74 Top = 8 - Width = 236 + Width = 225 AutoFill = False AutoSize = True BorderSpacing.Left = 8 @@ -69,30 +78,29 @@ object GenSeqFrm: TGenSeqFrm ChildSizing.Layout = cclTopToBottomThenLeftToRight ChildSizing.ControlsPerLine = 2 ClientHeight = 54 - ClientWidth = 232 + ClientWidth = 221 Items.Strings = ( 'All Current Cases' - 'Number of Cases = ' + 'Number of Cases:' ) OnClick = RadioGroup1Click TabOrder = 0 object StaticText1: TStaticText - Left = 140 + Left = 129 Height = 19 Top = 6 Width = 80 Caption = ' ' - TabOrder = 2 + TabOrder = 1 end object NoCasesEdit: TEdit - Left = 140 + Left = 129 Height = 23 Top = 25 Width = 80 Alignment = taRightJustify BorderSpacing.Left = 3 - OnExit = NoCasesEditExit - TabOrder = 3 + TabOrder = 0 Text = 'NoCasesEdit' end end @@ -100,7 +108,7 @@ object GenSeqFrm: TGenSeqFrm AnchorSideLeft.Control = LabelEdit AnchorSideTop.Control = RadioGroup1 AnchorSideTop.Side = asrBottom - Left = 154 + Left = 206 Height = 23 Top = 90 Width = 78 @@ -113,7 +121,7 @@ object GenSeqFrm: TGenSeqFrm AnchorSideLeft.Control = LabelEdit AnchorSideTop.Control = StartAtEdit AnchorSideTop.Side = asrBottom - Left = 154 + Left = 206 Height = 23 Top = 121 Width = 78 @@ -127,100 +135,75 @@ object GenSeqFrm: TGenSeqFrm AnchorSideTop.Side = asrBottom AnchorSideRight.Control = RadioGroup1 AnchorSideRight.Side = asrBottom - Left = 154 + Left = 206 Height = 23 Top = 152 Width = 78 Anchors = [akTop, akRight] BorderSpacing.Top = 8 BorderSpacing.Right = 12 - BorderSpacing.Bottom = 8 + BorderSpacing.Bottom = 4 TabOrder = 3 Text = 'LabelEdit' end - object Panel1: TPanel - AnchorSideLeft.Control = RadioGroup1 - AnchorSideLeft.Side = asrBottom - AnchorSideBottom.Control = LabelEdit - AnchorSideBottom.Side = asrBottom - Left = 260 - Height = 136 - Top = 39 - Width = 76 - Anchors = [akLeft, akBottom] + object CloseBtn: TButton + AnchorSideTop.Control = Bevel1 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 304 + Height = 25 + Top = 195 + Width = 55 + Anchors = [akTop, akRight] AutoSize = True - BorderSpacing.Left = 16 + BorderSpacing.Top = 8 BorderSpacing.Right = 8 - BevelOuter = bvNone - ChildSizing.VerticalSpacing = 12 - ClientHeight = 136 - ClientWidth = 76 + BorderSpacing.Bottom = 8 + Caption = 'Close' + ModalResult = 11 TabOrder = 4 - object ResetBtn: TButton - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = Panel1 - AnchorSideRight.Control = Panel1 - AnchorSideRight.Side = asrBottom - Left = 0 - Height = 25 - Top = 0 - Width = 76 - Anchors = [akTop, akLeft, akRight] - AutoSize = True - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 0 - end - object CancelBtn: TButton - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = ResetBtn - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Panel1 - AnchorSideRight.Side = asrBottom - Left = 0 - Height = 25 - Top = 37 - Width = 76 - Anchors = [akTop, akLeft, akRight] - AutoSize = True - BorderSpacing.Top = 8 - Caption = 'Cancel' - ModalResult = 2 - TabOrder = 1 - end - object ComputeBtn: TButton - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = CancelBtn - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Panel1 - AnchorSideRight.Side = asrBottom - Left = 0 - Height = 25 - Top = 74 - Width = 76 - Anchors = [akTop, akLeft, akRight] - AutoSize = True - BorderSpacing.Top = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick - TabOrder = 2 - end - object ReturnBtn: TButton - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = ComputeBtn - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Panel1 - AnchorSideRight.Side = asrBottom - Left = 0 - Height = 25 - Top = 111 - Width = 76 - Anchors = [akTop, akLeft, akRight] - AutoSize = True - BorderSpacing.Top = 8 - Caption = 'Return' - ModalResult = 1 - TabOrder = 3 - end + end + object ComputeBtn: TButton + AnchorSideTop.Control = CloseBtn + AnchorSideRight.Control = CloseBtn + Left = 220 + Height = 25 + Top = 195 + Width = 76 + Anchors = [akTop, akRight] + AutoSize = True + BorderSpacing.Right = 8 + Caption = 'Compute' + OnClick = ComputeBtnClick + TabOrder = 5 + end + object ResetBtn: TButton + AnchorSideTop.Control = CloseBtn + AnchorSideRight.Control = ComputeBtn + Left = 158 + Height = 25 + Top = 195 + Width = 54 + Anchors = [akTop, akRight] + AutoSize = True + BorderSpacing.Left = 8 + BorderSpacing.Right = 8 + Caption = 'Reset' + OnClick = ResetBtnClick + TabOrder = 6 + end + object Bevel1: TBevel + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = LabelEdit + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 8 + Top = 179 + Width = 367 + Anchors = [akTop, akLeft, akRight] + Shape = bsBottomLine end end diff --git a/applications/lazstats/source/forms/simulations/gensequnit.pas b/applications/lazstats/source/forms/simulations/gensequnit.pas index d9ce6af6a..c38326045 100644 --- a/applications/lazstats/source/forms/simulations/gensequnit.pas +++ b/applications/lazstats/source/forms/simulations/gensequnit.pas @@ -15,12 +15,11 @@ type { TGenSeqFrm } TGenSeqFrm = class(TForm) + Bevel1: TBevel; NoCasesEdit: TEdit; - Panel1: TPanel; ResetBtn: TButton; - CancelBtn: TButton; ComputeBtn: TButton; - ReturnBtn: TButton; + CloseBtn: TButton; LabelEdit: TEdit; Label3: TLabel; StartAtEdit: TEdit; @@ -30,9 +29,9 @@ type RadioGroup1: TRadioGroup; StaticText1: TStaticText; procedure ComputeBtnClick(Sender: TObject); + procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); - procedure NoCasesEditExit(Sender: TObject); procedure RadioGroup1Click(Sender: TObject); procedure ResetBtnClick(Sender: TObject); private @@ -47,79 +46,120 @@ var implementation +uses + Math; + { TGenSeqFrm } procedure TGenSeqFrm.ResetBtnClick(Sender: TObject); begin - RadioGroup1.ItemIndex := 1; - NoCasesEdit.Text := ''; - StartAtEdit.Text := ''; - IncrEdit.Text := ''; - LabelEdit.Text := ''; + RadioGroup1.ItemIndex := 1; + NoCasesEdit.Text := ''; + StartAtEdit.Text := ''; + IncrEdit.Text := ''; + LabelEdit.Text := ''; end; procedure TGenSeqFrm.FormShow(Sender: TObject); begin - ResetBtnClick(self); + ResetBtnClick(self); end; procedure TGenSeqFrm.ComputeBtnClick(Sender: TObject); var - i, col : integer; - First, Increment : double; + i, col: integer; + First, Increment: double; begin - if StartAtEdit.Text = '' then + if RadioGroup1.ItemIndex = 1 then begin + if NoCasesEdit.Text = '' then begin - ShowMessage('Error! No starting value provided.'); - exit; + NoCasesEdit.Setfocus; + MessageDlg('Number of cases to generate not specified.', mtError, [mbOK], 0); + exit; end; - if IncrEdit.Text = '' then + if not TryStrToInt(NoCasesEdit.Text, NCases) or (NCases <= 0) then begin - ShowMessage('Error! No increment value provided.'); - exit; + NoCasesEdit.SetFocus; + MessageDlg('Number of cases must be a valid, positive integer.', mtError, [mbOK], 0); + exit; end; - if LabelEdit.Text = '' then - begin - ShowMessage('Error! No variable label provided.'); - exit; - end; - if NoCases < Ncases then - begin - OS3MainFrm.DataGrid.RowCount := NCases + 1; - OS3MainFrm.NoCasesEdit.Text := IntToStr(NCases); - NoCases := Ncases; - end; - if NoVariables <= 0 then // a new data file - begin - OS3MainFrm.DataGrid.ColCount := 2; - OS3MainFrm.DataGrid.RowCount := Ncases + 1; - for i := 1 to Ncases do - OS3MainFrm.DataGrid.Cells[0,i] := format('Case %d',[i]); - col := 1; - DictionaryFrm.DictGrid.RowCount := 1; - DictionaryFrm.DictGrid.ColCount := 8; - DictionaryFrm.NewVar(col); - DictionaryFrm.DictGrid.Cells[1,col] := LabelEdit.Text; - OS3MainFrm.DataGrid.Cells[1,0] := LabelEdit.Text; - DictionaryFrm.DictGrid.RowCount := 2; - NoVariables := 1; + end else + NCases := NoCases; - end - else // existing data file - begin - col := NoVariables + 1; - DictionaryFrm.NewVar(col); - DictionaryFrm.DictGrid.Cells[1,col] := LabelEdit.Text; - end; + if (StartAtEdit.Text = '') or not TryStrToFloat(StartAtEdit.Text, First) then + begin + StartAtEdit.Setfocus; + MessageDlg('No starting value provided.', mtError, [mbOK], 0); + exit; + end; - First := StrToFloat(StartAtEdit.Text); - Increment := StrToFloat(IncrEdit.Text); + if (IncrEdit.Text = '') then + begin + IncrEdit.SetFocus; + MessageDlg('No increment value provided.', mtError, [mbOK], 0); + exit; + end; + if not TryStrToFloat(IncrEdit.Text, Increment) or (Increment <= 0) then + begin + IncrEdit.SetFocus; + MessageDlg('No valid increment value provided.', mtError, [mbOK], 0); + exit; + end; + + if LabelEdit.Text = '' then + begin + LabelEdit.SetFocus; + MessageDlg('No variable label provided.', mtError, [mbOK], 0); + exit; + end; + + if NoCases < Ncases then + begin + OS3MainFrm.DataGrid.RowCount := NCases + 1; + OS3MainFrm.NoCasesEdit.Text := IntToStr(NCases); + NoCases := Ncases; + end; + + if NoVariables <= 0 then // a new data file + begin + OS3MainFrm.DataGrid.ColCount := 2; + OS3MainFrm.DataGrid.RowCount := Ncases + 1; for i := 1 to Ncases do - begin - OS3MainFrm.DataGrid.Cells[col,i] := format('%8.3f',[First]); - First := First + Increment; - end; - OS3MainFrm.NoVarsEdit.Text := IntToStr(NoVariables); + OS3MainFrm.DataGrid.Cells[0,i] := format('Case %d',[i]); + col := 1; + DictionaryFrm.DictGrid.RowCount := 1; + DictionaryFrm.DictGrid.ColCount := 8; + DictionaryFrm.NewVar(col); + DictionaryFrm.DictGrid.Cells[1,col] := LabelEdit.Text; + OS3MainFrm.DataGrid.Cells[1,0] := LabelEdit.Text; + DictionaryFrm.DictGrid.RowCount := 2; + NoVariables := 1; + end + else // existing data file + begin + col := NoVariables + 1; + DictionaryFrm.NewVar(col); + DictionaryFrm.DictGrid.Cells[1,col] := LabelEdit.Text; + end; + + First := StrToFloat(StartAtEdit.Text); + Increment := StrToFloat(IncrEdit.Text); + for i := 1 to Ncases do + begin + OS3MainFrm.DataGrid.Cells[col,i] := Format('%.3f', [First]); + First := First + Increment; + end; + OS3MainFrm.NoVarsEdit.Text := IntToStr(NoVariables); +end; + +procedure TGenSeqFrm.FormActivate(Sender: TObject); +var + w: Integer; +begin + w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); + ResetBtn.Constraints.MinWidth := w; + ComputeBtn.Constraints.MinWidth := w; + CloseBtn.Constraints.MinWidth := w; end; procedure TGenSeqFrm.FormCreate(Sender: TObject); @@ -129,28 +169,18 @@ begin Application.CreateForm(TDictionaryFrm, DictionaryFrm); end; -procedure TGenSeqFrm.NoCasesEditExit(Sender: TObject); -begin - if RadioGroup1.ItemIndex = 1 then Ncases := StrToInt(NoCasesEdit.Text); - if (Ncases <= 0) and (RadioGroup1.ItemIndex = 1) then - begin - ShowMessage('Error! No. of cases to generate not specified.'); - exit; - end; -end; - procedure TGenSeqFrm.RadioGroup1Click(Sender: TObject); begin - if RadioGroup1.ItemIndex = 0 then + if RadioGroup1.ItemIndex = 0 then + begin + if NoCases <= 0 then begin - if NoCases <= 0 then - begin - ShowMessage('Error! There are currently no cases!'); - exit; - end - else Ncases := NoCases; - end - else NoCasesEdit.SetFocus; + MessageDlg('There are currently no cases.', mtError, [mbOK], 0); + exit; + end else + Ncases := NoCases; + end else + NoCasesEdit.SetFocus; end; initialization