diff --git a/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.lfm b/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.lfm index 9afdb03cc..efb45ae12 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.lfm +++ b/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.lfm @@ -8,109 +8,40 @@ inherited BreakDownFrm: TBreakDownFrm Caption = 'Breakdown' ClientHeight = 363 ClientWidth = 873 - OnActivate = FormActivate - OnCreate = FormCreate - Position = poMainFormCenter - object ParamsPanel: TPanel[0] - Left = 8 + inherited ParamsPanel: TPanel Height = 347 - Top = 8 Width = 344 - Align = alLeft - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 4 - BorderSpacing.Bottom = 8 - BevelOuter = bvNone ClientHeight = 347 ClientWidth = 344 - TabOrder = 0 - object CloseBtn: TButton - AnchorSideRight.Control = ParamsPanel - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = ParamsPanel - AnchorSideBottom.Side = asrBottom + inherited CloseBtn: TButton Left = 289 - Height = 25 Top = 322 - Width = 55 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - Caption = 'Close' - ModalResult = 11 - OnClick = CloseBtnClick - TabOrder = 11 - end - object ResetBtn: TButton - AnchorSideRight.Control = ComputeBtn - AnchorSideBottom.Control = ParamsPanel - AnchorSideBottom.Side = asrBottom - Left = 143 - Height = 25 - Top = 322 - Width = 54 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 9 - end - object HelpBtn: TButton - Tag = 109 - AnchorSideRight.Control = ResetBtn - AnchorSideBottom.Control = ParamsPanel - AnchorSideBottom.Side = asrBottom - Left = 84 - Height = 25 - Top = 322 - Width = 51 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 12 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - Caption = 'Help' - OnClick = HelpBtnClick TabOrder = 8 end - object Bevel1: TBevel - AnchorSideLeft.Control = ParamsPanel - AnchorSideRight.Control = ParamsPanel - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CloseBtn - Left = 0 - Height = 8 - Top = 306 - Width = 344 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine - end - object ComputeBtn: TButton - AnchorSideRight.Control = CloseBtn - AnchorSideBottom.Control = ParamsPanel - AnchorSideBottom.Side = asrBottom - Left = 205 - Height = 25 + inherited ComputeBtn: TButton + Left = 206 + Top = 322 + TabOrder = 9 + end + inherited ResetBtn: TButton + Left = 144 Top = 322 - Width = 76 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick TabOrder = 10 end - object CheckGroup1: TCheckGroup + inherited HelpBtn: TButton + Left = 85 + Top = 322 + TabOrder = 11 + end + inherited ButtonBevel: TBevel + Top = 306 + Width = 344 + end + object CheckGroup1: TCheckGroup[5] AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Side = asrBottom AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Bevel1 + AnchorSideBottom.Control = ButtonBevel Left = 0 Height = 51 Top = 255 @@ -139,7 +70,7 @@ inherited BreakDownFrm: TBreakDownFrm 0100000002 } end - object AvailLabel: TLabel + object AvailLabel: TLabel[6] AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel Left = 0 @@ -149,7 +80,7 @@ inherited BreakDownFrm: TBreakDownFrm Caption = 'Available Variables' ParentColor = False end - object AnalLabel: TLabel + object AnalLabel: TLabel[7] AnchorSideLeft.Control = SelList AnchorSideTop.Control = ParamsPanel Left = 194 @@ -159,7 +90,7 @@ inherited BreakDownFrm: TBreakDownFrm Caption = 'Variables to Analyze' ParentColor = False end - object SelLabel: TLabel + object SelLabel: TLabel[8] AnchorSideLeft.Control = SelList AnchorSideBottom.Control = DepVar Left = 194 @@ -171,7 +102,7 @@ inherited BreakDownFrm: TBreakDownFrm Caption = 'Selected Continuous Variable' ParentColor = False end - object VarList: TListBox + object VarList: TListBox[9] AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Control = AvailLabel AnchorSideTop.Side = asrBottom @@ -190,7 +121,7 @@ inherited BreakDownFrm: TBreakDownFrm OnSelectionChange = VarListSelectionChange TabOrder = 0 end - object SelList: TListBox + object SelList: TListBox[10] AnchorSideLeft.Control = InBtn AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = AnalLabel @@ -211,7 +142,7 @@ inherited BreakDownFrm: TBreakDownFrm OnSelectionChange = SelListSelectionChange TabOrder = 3 end - object DepVar: TEdit + object DepVar: TEdit[11] AnchorSideLeft.Control = SelList AnchorSideTop.Control = SelLabel AnchorSideTop.Side = asrBottom @@ -230,7 +161,7 @@ inherited BreakDownFrm: TBreakDownFrm TabOrder = 6 Text = 'DepVar' end - object InBtn: TBitBtn + object InBtn: TBitBtn[12] AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = VarList @@ -244,7 +175,7 @@ inherited BreakDownFrm: TBreakDownFrm Spacing = 0 TabOrder = 1 end - object OutBtn: TBitBtn + object OutBtn: TBitBtn[13] AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = InBtn @@ -260,7 +191,7 @@ inherited BreakDownFrm: TBreakDownFrm Spacing = 0 TabOrder = 2 end - object SelVarInBtn: TBitBtn + object SelVarInBtn: TBitBtn[14] AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideBottom.Control = SelVarOutBtn @@ -276,7 +207,7 @@ inherited BreakDownFrm: TBreakDownFrm Spacing = 0 TabOrder = 4 end - object SelVarOutBtn: TBitBtn + object SelVarOutBtn: TBitBtn[15] AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideBottom.Control = VarList @@ -293,25 +224,22 @@ inherited BreakDownFrm: TBreakDownFrm TabOrder = 5 end end - object ParamsSplitter: TSplitter[1] + inherited ParamsSplitter: TSplitter Left = 356 Height = 363 - Top = 0 - Width = 5 - ResizeStyle = rsPattern end - object PageControl1: TPageControl[2] + object PageControl: TPageControl[2] Left = 365 Height = 347 Top = 8 Width = 500 - ActivePage = AnovaPage + ActivePage = BreakDownPage Align = alClient BorderSpacing.Left = 4 BorderSpacing.Top = 8 BorderSpacing.Right = 8 BorderSpacing.Bottom = 8 - TabIndex = 1 + TabIndex = 0 TabOrder = 2 object BreakDownPage: TTabSheet Caption = 'Report' diff --git a/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.pas b/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.pas index 345b9964e..609cf0926 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/breakdownunit.pas @@ -9,65 +9,52 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls, - MainUnit, Globals, FunctionsLib, DataProcs, ContextHelpUnit, - BasicStatsFormUnit, ReportFrameUnit; + MainUnit, Globals, DataProcs, BasicStatsReportFormUnit, ReportFrameUnit; type { TBreakDownFrm } - TBreakDownFrm = class(TBasicStatsForm) - Bevel1: TBevel; - ComputeBtn: TButton; - HelpBtn: TButton; + TBreakDownFrm = class(TBasicStatsReportForm) InBtn: TBitBtn; OutBtn: TBitBtn; - PageControl1: TPageControl; - ParamsPanel: TPanel; + PageControl: TPageControl; SelVarInBtn: TBitBtn; SelVarOutBtn: TBitBtn; - ResetBtn: TButton; - CloseBtn: TButton; CheckGroup1: TCheckGroup; DepVar: TEdit; AvailLabel: TLabel; AnalLabel: TLabel; SelLabel: TLabel; SelList: TListBox; - ParamsSplitter: TSplitter; BreakDownPage: TTabSheet; AnovaPage: TTabSheet; VarList: TListBox; - procedure CloseBtnClick(Sender: TObject); - procedure ComputeBtnClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure HelpBtnClick(Sender: TObject); procedure InBtnClick(Sender: TObject); procedure OutBtnClick(Sender: TObject); - procedure ResetBtnClick(Sender: TObject); procedure SelListDblClick(Sender: TObject); - procedure SelListSelectionChange(Sender: TObject; User: boolean); + procedure SelListSelectionChange(Sender: TObject; {%H-}User: boolean); procedure SelVarInBtnClick(Sender: TObject); procedure SelVarOutBtnClick(Sender: TObject); procedure VarListDblClick(Sender: TObject); - procedure VarListSelectionChange(Sender: TObject; User: boolean); + procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); private - { private declarations } - FBreakdownReportFrame: TReportFrame; FANOVAReportFrame: TReportFrame; - FAutoSized: Boolean; procedure ANOVA(ListSize: Integer; Freq, Selected, Minimum, Subscript, Levels, Displace: IntDyneVec; Mean, SS: DblDyneVec; AReport: TStrings); procedure GetLevels(const AMinimum, AMaximum, ALevels, ADisplace: IntDyneVec); procedure GetMinMax(const AMinimum, AMaximum, ASelected: IntDyneVec); function Index_Pos(const X, ADisplace: IntDyneVec; AListSize: integer): Integer; - procedure UpdateBtnStates; + + protected + procedure AdjustConstraints; override; + procedure Compute; override; + procedure UpdateBtnStates; override; public - { public declarations } + constructor Create(AOwner: TComponent); override; procedure Reset; override; end; @@ -87,6 +74,44 @@ uses { TBreakDownFrm } +constructor TBreakDownFrm.Create(AOwner: TComponent); +begin + inherited; + + FReportFrame.Parent := BreakDownPage; + + FANOVAReportFrame := TReportFrame.Create(ANOVAPage); + with FANOVAReportFrame do + begin + Parent := ANOVAPage; + Align := alClient; + end; + + PageControl.ActivePage := BreakdownPage; + + Reset; +end; + + +procedure TBreakDownFrm.AdjustConstraints; +begin + inherited; + + ParamsPanel.Constraints.MinWidth := Max( + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + SelLabel.Width * 2 + InBtn.Width + VarList.BorderSpacing.Right * 2); + ParamsPanel.Constraints.MinHeight := InBtn.Top + + 4*InBtn.Height + 3*OutBtn.BorderSpacing.Bottom + + CheckGroup1.BorderSpacing.Top + CheckGroup1.Height + ButtonBevel.Height + + CloseBtn.BorderSpacing.Top + CloseBtn.Height; + + Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300; + Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Left*2; + if Width < Constraints.MinWidth then Width := 1; // enforce constraints + if Height < Constraints.MinHeight then Height := 1; +end; + + procedure TBreakDownFrm.ANOVA(ListSize: Integer; Freq, Selected, Minimum, Subscript, Levels, Displace: IntDyneVec; Mean, SS: DblDyneVec; AReport: TStrings); var @@ -167,7 +192,7 @@ begin AReport.Add('Insufficient data for ANOVA'); AReport.Add(''); - AReport.Add(DIVIDER_SMALL_AUTO); + AReport.Add(DIVIDER_AUTO); AReport.Add(''); SSB := 0.0; @@ -252,13 +277,7 @@ begin end; -procedure TBreakDownFrm.CloseBtnClick(Sender: TObject); -begin - Close; -end; - - -procedure TBreakDownFrm.ComputeBtnClick(Sender: TObject); +procedure TBreakDownFrm.Compute; label Label1, Label3, Label4, NextStep; var @@ -288,6 +307,8 @@ var tempval: string; lReport: TStrings; begin + inherited; + // Identify columns of variables to analyze and the dependent var. NoSelected := SelList.Items.Count; @@ -470,7 +491,8 @@ begin lReport.Add('Std. Dev. across levels: ********'); lReport.Add(''); - lReport.Add('==============================================================='); + lReport.Add(DIVIDER_AUTO); +// lReport.Add('==============================================================='); lReport.Add(''); //OutputFrm.ShowModal; //OutputFrm.Clear; @@ -516,7 +538,7 @@ begin lReport.Add('Overall Standard Deviation: %8.3f', [SD]); end; - FBreakdownReportFrame.DisplayReport(lReport); + FReportFrame.DisplayReport(lReport); lReport.Clear; // Do ANOVA's if requested @@ -526,6 +548,7 @@ begin // Show ANOVA in pagecontrol FANovaReportFrame.DisplayReport(lReport); end; + AnovaPage.TabVisible := CheckGroup1.Checked[0]; finally lReport.Free; @@ -533,61 +556,6 @@ begin end; -procedure TBreakDownFrm.FormActivate(Sender: TObject); -var - w: 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; - - ParamsPanel.Constraints.MinWidth := Max( - 4*w + 3*CloseBtn.BorderSpacing.Left, - SelLabel.Width * 2 + InBtn.Width + VarList.BorderSpacing.Right * 2); - ParamsPanel.Constraints.MinHeight := InBtn.Top + - 4*InBtn.Height + 3*OutBtn.BorderSpacing.Bottom + - CheckGroup1.BorderSpacing.Top + CheckGroup1.Height + Bevel1.Height + - CloseBtn.BorderSpacing.Top + CloseBtn.Height; - - Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300; - Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Left*2; - if Width < Constraints.MinWidth then Width := 1; // enforce constraints - if Height < Constraints.MinHeight then Height := 1; - - Position := poDesigned; - FAutoSized := true; -end; - - -procedure TBreakDownFrm.FormCreate(Sender: TObject); -begin - Assert(OS3MainFrm <> nil); - - InitForm(self); - - FBreakDownReportFrame := TReportFrame.Create(self); - with FBreakdownReportFrame do - begin - Parent := BreakDownPage; - Align := alClient; - end; - - FANOVAReportFrame := TReportFrame.Create(ANOVAPage); - with FANOVAReportFrame do - begin - Parent := ANOVAPage; - Align := alClient; - end; - - Reset; -end; - - procedure TBreakDownFrm.GetLevels(const AMinimum, AMaximum, ALevels, ADisplace: IntDyneVec); var i: Integer; @@ -633,13 +601,6 @@ begin end; end; -procedure TBreakDownFrm.HelpBtnClick(Sender: TObject); -begin - if ContextHelpForm = nil then - Application.CreateForm(TContextHelpForm, ContextHelpForm); - ContextHelpForm.HelpMessage((Sender as TButton).Tag); -end; - procedure TBreakDownFrm.InBtnClick(Sender: TObject); var @@ -704,8 +665,10 @@ begin for i := 1 to NoVariables do VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); - FBreakdownReportFrame.Clear; - FAnovaReportFrame.Clear; + if FReportFrame <> nil then + FReportFrame.Clear; + if FAnovaReportFrame <> nil then + FAnovaReportFrame.Clear; BreakdownPage.Caption := 'Report'; AnovaPage.TabVisible := false; @@ -714,12 +677,6 @@ begin end; -procedure TBreakDownFrm.ResetBtnClick(Sender: TObject); -begin - Reset; -end; - - procedure TBreakDownFrm.SelListDblClick(Sender: TObject); var index: Integer; @@ -788,8 +745,10 @@ begin SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = ''); SelVarOutBtn.Enabled := (DepVar.Text <> ''); - FBreakdownReportFrame.UpdateBtnStates; - FAnovaReportFrame.UpdateBtnStates; + if FReportFrame <> nil then + FReportFrame.UpdateBtnStates; + if FAnovaReportFrame <> nil then + FAnovaReportFrame.UpdateBtnStates; end;