diff --git a/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.lfm b/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.lfm index c1fcd050a..bfe94d3e4 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.lfm +++ b/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.lfm @@ -8,101 +8,36 @@ inherited CrossTabFrm: TCrossTabFrm Caption = 'Cross Tabulation' ClientHeight = 358 ClientWidth = 879 - OnActivate = FormActivate - OnCreate = FormCreate - Position = poMainFormCenter - object ParamsPanel: TPanel[0] - Left = 8 + inherited ParamsPanel: TPanel Height = 342 - Top = 8 Width = 320 - Align = alLeft - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 4 - BorderSpacing.Bottom = 8 - BevelOuter = bvNone ClientHeight = 342 ClientWidth = 320 - TabOrder = 0 - object Bevel2: TBevel - AnchorSideLeft.Control = ParamsPanel - AnchorSideRight.Control = ParamsPanel - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CloseBtn - Left = 0 - Height = 8 - Top = 301 - Width = 320 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine - end - object CloseBtn: TButton - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = ParamsPanel - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = ParamsPanel - AnchorSideBottom.Side = asrBottom + inherited CloseBtn: TButton Left = 265 - Height = 25 Top = 317 - Width = 55 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - Caption = 'Close' - ModalResult = 11 - OnClick = CloseBtnClick TabOrder = 7 end - object ResetBtn: TButton - AnchorSideTop.Control = CloseBtn - AnchorSideRight.Control = ComputeBtn - Left = 119 - Height = 25 + inherited ComputeBtn: TButton + Left = 182 Top = 317 - Width = 54 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Right = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 5 - end - object HelpBtn: TButton - AnchorSideTop.Control = CloseBtn - AnchorSideRight.Control = ResetBtn - Left = 60 - Height = 25 - Top = 317 - Width = 51 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Right = 8 - Caption = 'Help' - OnClick = HelpBtnClick - TabOrder = 4 - end - object ComputeBtn: TButton - AnchorSideTop.Control = CloseBtn - AnchorSideRight.Control = CloseBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 181 - Height = 25 - Top = 317 - Width = 76 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Right = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick TabOrder = 6 end - object Label1: TLabel + inherited ResetBtn: TButton + Left = 120 + Top = 317 + TabOrder = 5 + end + inherited HelpBtn: TButton + Left = 61 + Top = 317 + TabOrder = 4 + end + inherited ButtonBevel: TBevel + Top = 301 + Width = 320 + end + object Label1: TLabel[5] AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel Left = 0 @@ -112,7 +47,7 @@ inherited CrossTabFrm: TCrossTabFrm Caption = 'Available Variables' ParentColor = False end - object Label2: TLabel + object Label2: TLabel[6] AnchorSideLeft.Control = SelList Left = 182 Height = 15 @@ -121,12 +56,12 @@ inherited CrossTabFrm: TCrossTabFrm Caption = 'Variables to Analyze' ParentColor = False end - object VarList: TListBox + object VarList: TListBox[7] AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Control = Label1 AnchorSideTop.Side = asrBottom AnchorSideRight.Control = InBtn - AnchorSideBottom.Control = Bevel2 + AnchorSideBottom.Control = ButtonBevel Left = 0 Height = 284 Top = 17 @@ -140,7 +75,7 @@ inherited CrossTabFrm: TCrossTabFrm OnSelectionChange = VarListSelectionChange TabOrder = 0 end - object SelList: TListBox + object SelList: TListBox[8] AnchorSideLeft.Control = InBtn AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Label2 @@ -161,7 +96,7 @@ inherited CrossTabFrm: TCrossTabFrm OnSelectionChange = VarListSelectionChange TabOrder = 3 end - object InBtn: TBitBtn + object InBtn: TBitBtn[9] AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideBottom.Control = VertCenterBevel @@ -176,7 +111,7 @@ inherited CrossTabFrm: TCrossTabFrm Spacing = 0 TabOrder = 1 end - object OutBtn: TBitBtn + object OutBtn: TBitBtn[10] AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = VertCenterBevel @@ -193,7 +128,7 @@ inherited CrossTabFrm: TCrossTabFrm Spacing = 0 TabOrder = 2 end - object VertCenterBevel: TBevel + object VertCenterBevel: TBevel[11] AnchorSideLeft.Control = InBtn AnchorSideTop.Control = VarList AnchorSideTop.Side = asrCenter @@ -207,28 +142,8 @@ inherited CrossTabFrm: TCrossTabFrm Shape = bsSpacer end end - object ParamsSplitter: TSplitter[1] + inherited ParamsSplitter: TSplitter Left = 332 Height = 358 - Top = 0 - Width = 5 - ResizeStyle = rsPattern - end - object PageControl: TPageControl[2] - Left = 341 - Height = 342 - Top = 8 - Width = 530 - 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 end end diff --git a/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas b/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas index 59038ecf3..11453f73f 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas @@ -9,49 +9,36 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, - Globals, MainUnit, DataProcs, MatrixLib, ContextHelpUnit, - BasicStatsFormUnit, ReportFrameUnit; + Globals, MainUnit, MatrixLib, ReportFrameUnit, BasicStatsReportFormUnit; type { TCrossTabFrm } - TCrossTabFrm = class(TBasicStatsForm) - ComputeBtn: TButton; - PageControl: TPageControl; - ParamsPanel: TPanel; - ParamsSplitter: TSplitter; - ReportPage: TTabSheet; + TCrossTabFrm = class(TBasicStatsReportForm) VertCenterBevel: TBevel; - Bevel2: TBevel; - HelpBtn: TButton; InBtn: TBitBtn; OutBtn: TBitBtn; - ResetBtn: TButton; - CloseBtn: TButton; Label1: TLabel; Label2: TLabel; VarList: TListBox; SelList: 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 VarListDblClick(Sender: TObject); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); private - FReportFrame: TReportFrame; - FAutosized: Boolean; procedure Prepare(out AVarList, AColNoSelected: IntDyneVec); - procedure UpdateBtnStates; + + protected + procedure AdjustConstraints; override; + procedure Compute; override; + procedure UpdateBtnStates; override; public + constructor Create(AOwner: TComponent); override; procedure Reset; override; end; @@ -73,10 +60,10 @@ uses type TCrossTabCalculator = class private - FReport: TStrings; - FVarList: IntDyneVec; FDataGrid: TStringGrid; FColNoSelected: IntDyneVec; + FVarList: IntDyneVec; + FReport: TStrings; grandsum, sum, index: integer; no_in_list, length_array: integer; @@ -315,19 +302,35 @@ end; { TCrossTabFrm } -procedure TCrossTabFrm.CloseBtnClick(Sender: TObject); +constructor TCrossTabFrm.Create(AOwner: TComponent); begin - Close; + inherited; end; -procedure TCrossTabFrm.ComputeBtnClick(Sender: TObject); +procedure TCrossTabFrm.AdjustConstraints; +begin + inherited; + ParamsPanel.Constraints.MinWidth := Max( + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + Max(Label1.Width, Label2.Width) + InBtn.Width + VarList.BorderSpacing.Right * 2 + ); + ParamsPanel.Constraints.MinHeight := 200; + + Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;; + Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + 2*ParamsPanel.BorderSpacing.Top; +end; + + +procedure TCrossTabFrm.Compute; var lReport: TStringList; calculator: TCrossTabCalculator; var_list: IntDyneVec = nil; colNoSelected: IntDyneVec = nil; begin + inherited; + if SelList.Items.Count = 0 then begin ErrorMsg('No variables selected for analysis.'); @@ -355,60 +358,6 @@ begin end; -procedure TCrossTabFrm.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, - Max(Label1.Width, Label2.Width) + InBtn.Width + VarList.BorderSpacing.Right * 2 - ); - ParamsPanel.Constraints.MinHeight := 200; - - Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;; - Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + 2*ParamsPanel.BorderSpacing.Top; - if Width < Constraints.MinWidth then Width := 1; // enforce constraints - if Height < Constraints.MinHeight then Height := 1; - - Position := poDesigned; - FAutoSized := true; -end; - - -procedure TCrossTabFrm.FormCreate(Sender: TObject); -begin - Assert(OS3MainFrm <> nil); - - InitForm(self); - - FReportFrame := TReportFrame.Create(self); - with FReportFrame do - begin - Parent := ReportPage; - Align := alClient; - end; - - Reset; -end; - - -procedure TCrossTabFrm.HelpBtnClick(Sender: TObject); -begin - if ContextHelpForm = nil then - Application.CreateForm(TContextHelpForm, ContextHelpForm); - ContextHelpForm.HelpMessage((Sender as TButton).Tag); -end; - - procedure TCrossTabFrm.InBtnClick(Sender: TObject); var i: integer; @@ -489,13 +438,9 @@ begin for i := 1 to NoVariables do VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); UpdateBtnStates; - FReportFrame.Clear; -end; - - -procedure TCrossTabFrm.ResetBtnClick(Sender: TObject); -begin - Reset; + + if FReportFrame <> nil then + FReportFrame.Clear; end; @@ -536,7 +481,8 @@ begin end; OutBtn.Enabled := lSelected; - FReportFrame.UpdateBtnStates; + if FReportFrame <> nil then + FReportFrame.UpdateBtnStates; end;