diff --git a/components/fpreport/design/frmfpreportvariables.lfm b/components/fpreport/design/frmfpreportvariables.lfm index f4c73ec5f7..9bb1ff6059 100644 --- a/components/fpreport/design/frmfpreportvariables.lfm +++ b/components/fpreport/design/frmfpreportvariables.lfm @@ -1,24 +1,23 @@ object ReportVariablesForm: TReportVariablesForm Left = 656 - Height = 365 + Height = 390 Top = 245 - Width = 445 + Width = 616 Caption = 'Report variables' - ClientHeight = 365 - ClientWidth = 445 + ClientHeight = 390 + ClientWidth = 616 OnCloseQuery = FormCloseQuery OnCreate = FormCreate LCLVersion = '1.9.0.0' object LBVariables: TListBox Left = 16 - Height = 277 + Height = 302 Top = 32 - Width = 216 + Width = 208 Anchors = [akTop, akLeft, akRight, akBottom] ItemHeight = 0 OnSelectionChange = LBVariablesSelectionChange - Options = [lboDrawFocusRect] - ScrollWidth = 214 + ScrollWidth = 206 TabOrder = 0 TopIndex = -1 end @@ -33,8 +32,8 @@ object ReportVariablesForm: TReportVariablesForm object BPVariables: TButtonPanel Left = 6 Height = 42 - Top = 317 - Width = 433 + Top = 342 + Width = 604 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True HelpButton.Name = 'HelpButton' @@ -49,7 +48,7 @@ object ReportVariablesForm: TReportVariablesForm object SBDelete: TSpeedButton AnchorSideRight.Control = LBVariables AnchorSideRight.Side = asrBottom - Left = 209 + Left = 201 Height = 22 Top = 5 Width = 23 @@ -59,7 +58,7 @@ object ReportVariablesForm: TReportVariablesForm end object SBAdd: TSpeedButton AnchorSideRight.Control = SBDelete - Left = 186 + Left = 178 Height = 22 Top = 5 Width = 23 @@ -68,18 +67,18 @@ object ReportVariablesForm: TReportVariablesForm ShowCaption = False end object EName: TEdit - Left = 302 + Left = 305 Height = 27 - Top = 40 - Width = 120 + Top = 32 + Width = 288 Anchors = [akTop, akRight] TabOrder = 2 Text = 'EName' end object CBType: TComboBox - Left = 302 - Height = 31 - Top = 72 + Left = 305 + Height = 27 + Top = 64 Width = 120 Anchors = [akTop, akRight] ItemHeight = 0 @@ -95,9 +94,9 @@ object ReportVariablesForm: TReportVariablesForm TabOrder = 3 end object LEName: TLabel - Left = 238 + Left = 241 Height = 27 - Top = 40 + Top = 32 Width = 58 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -107,21 +106,21 @@ object ReportVariablesForm: TReportVariablesForm ParentColor = False end object LCBType: TLabel - Left = 237 + Left = 240 Height = 29 - Top = 72 + Top = 64 Width = 59 Alignment = taRightJustify Anchors = [akTop, akRight] AutoSize = False - Caption = 'Type' + Caption = 'Data Type' Layout = tlCenter ParentColor = False end object LValue: TLabel - Left = 238 + Left = 241 Height = 27 - Top = 104 + Top = 96 Width = 58 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -131,34 +130,34 @@ object ReportVariablesForm: TReportVariablesForm ParentColor = False end object CBBoolean: TCheckBox - Left = 302 + Left = 576 Height = 22 - Top = 256 + Top = 69 Width = 22 Anchors = [akTop, akRight] TabOrder = 4 end object EString: TEdit - Left = 302 + Left = 305 Height = 27 - Top = 106 - Width = 120 + Top = 98 + Width = 288 Anchors = [akTop, akRight] TabOrder = 5 Text = 'EString' end object SEinteger: TSpinEdit - Left = 302 + Left = 400 Height = 27 - Top = 184 + Top = 112 Width = 86 Anchors = [akTop, akRight] TabOrder = 6 end object SEFloat: TFloatSpinEdit - Left = 302 + Left = 496 Height = 27 - Top = 152 + Top = 112 Width = 88 Anchors = [akTop, akRight] Increment = 1 @@ -168,9 +167,9 @@ object ReportVariablesForm: TReportVariablesForm Value = 0 end object DEDateTime: TDateEdit - Left = 302 + Left = 448 Height = 27 - Top = 216 + Top = 66 Width = 120 CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames] DateOrder = doNone @@ -181,6 +180,106 @@ object ReportVariablesForm: TReportVariablesForm TabOrder = 8 Text = 'DEDateTime' end + object CBAggregate: TCheckBox + Left = 305 + Height = 22 + Top = 136 + Width = 22 + Anchors = [akTop, akRight] + OnChange = CBAggregateChange + TabOrder = 9 + end + object LCBExpression: TLabel + Left = 225 + Height = 23 + Top = 136 + Width = 74 + Alignment = taRightJustify + Anchors = [akTop, akRight] + AutoSize = False + Caption = 'Aggregate' + FocusControl = CBAggregate + ParentColor = False + end + object LValue1: TLabel + Left = 225 + Height = 27 + Top = 168 + Width = 74 + Alignment = taRightJustify + Anchors = [akTop, akRight] + AutoSize = False + Caption = 'Expression' + FocusControl = EExpression + Layout = tlCenter + ParentColor = False + end + object EExpression: TEdit + Left = 305 + Height = 27 + Top = 168 + Width = 288 + Anchors = [akTop, akRight] + TabOrder = 10 + Text = 'EExpression' + end + object LCBResetExpression: TLabel + Left = 225 + Height = 27 + Top = 232 + Width = 74 + Alignment = taRightJustify + Anchors = [akTop, akRight] + AutoSize = False + Caption = 'Reset' + FocusControl = CBResetExpression + Layout = tlCenter + ParentColor = False + end + object CBResetExpression: TComboBox + Left = 306 + Height = 29 + Top = 232 + Width = 288 + Anchors = [akTop, akRight] + ItemHeight = 0 + Items.Strings = ( + 'PageNo' + 'ColNo' + ) + OnSelect = CBTypeSelect + TabOrder = 11 + end + object CBResetType: TComboBox + Left = 305 + Height = 27 + Top = 200 + Width = 120 + Anchors = [akTop, akRight] + ItemHeight = 0 + Items.Strings = ( + 'None' + 'Group' + 'Page' + 'Column' + ) + OnChange = CBResetTypeChange + OnSelect = CBTypeSelect + Style = csDropDownList + TabOrder = 12 + end + object LCBType1: TLabel + Left = 232 + Height = 29 + Top = 198 + Width = 67 + Alignment = taRightJustify + Anchors = [akTop, akRight] + AutoSize = False + Caption = 'Reset Type' + Layout = tlCenter + ParentColor = False + end object ALVariables: TActionList Images = ILVariables left = 192 diff --git a/components/fpreport/design/frmfpreportvariables.pp b/components/fpreport/design/frmfpreportvariables.pp index 157bf73142..511342e467 100644 --- a/components/fpreport/design/frmfpreportvariables.pp +++ b/components/fpreport/design/frmfpreportvariables.pp @@ -40,10 +40,18 @@ type BPVariables: TButtonPanel; CBType: TComboBox; CBBoolean: TCheckBox; + CBAggregate: TCheckBox; + CBResetExpression: TComboBox; + CBResetType: TComboBox; DEDateTime: TDateEdit; EString: TEdit; EName: TEdit; + EExpression: TEdit; ILVariables: TImageList; + LCBExpression: TLabel; + LCBType1: TLabel; + LValue1: TLabel; + LCBResetExpression: TLabel; SEFloat: TFloatSpinEdit; LEName: TLabel; LCBType: TLabel; @@ -55,6 +63,8 @@ type SEinteger: TSpinEdit; procedure ADeleteVariableExecute(Sender: TObject); procedure ADeleteVariableUpdate(Sender: TObject); + procedure CBAggregateChange(Sender: TObject); + procedure CBResetTypeChange(Sender: TObject); procedure CBTypeSelect(Sender: TObject); procedure DoAddVariable(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); @@ -63,10 +73,18 @@ type private FCurrentVariable: TFPReportVariable; FValueControls : Array[TResultType] of TControl; + procedure CheckExpression; + procedure CheckResetType; + procedure FillExpressionsList; + function GetCurrentIsExpression: Boolean; + function GetCurrentResetType: TFPReportResetType; function GetType: TResultType; + procedure SetCurrentIsExpression(AValue: Boolean); + procedure SetCurrentResetType(AValue: TFPReportResetType); procedure SetCurrentVariable(AValue: TFPReportVariable); procedure SetType(AValue: TResultType); Protected + procedure SetReport(AValue: TFPCustomReport); override; procedure SetVariables(AValue: TFPReportVariables); override; procedure ShowCurrentTypeEditor; virtual; procedure SetCurrentVariableFromList; virtual; @@ -75,6 +93,8 @@ type procedure VariablesToForm; virtual; Property CurrentVariable : TFPReportVariable Read FCurrentVariable Write SetCurrentVariable; Property CurrentType : TResultType Read GetType Write SetType; + property CurrentIsExpression : Boolean Read GetCurrentIsExpression Write SetCurrentIsExpression; + Property CurrentResetType : TFPReportResetType Read GetCurrentResetType Write SetCurrentResetType; end; implementation @@ -178,6 +198,16 @@ begin (Sender as TAction).Enabled:=(FCurrentVariable<>Nil); end; +procedure TReportVariablesForm.CBAggregateChange(Sender: TObject); +begin + CheckExpression; +end; + +procedure TReportVariablesForm.CBResetTypeChange(Sender: TObject); +begin + CheckResetType; +end; + procedure TReportVariablesForm.CBTypeSelect(Sender: TObject); begin ShowCurrentTypeEditor; @@ -222,6 +252,54 @@ begin Result:=TResultType(CBType.ItemIndex); end; +function TReportVariablesForm.GetCurrentIsExpression: Boolean; +begin + Result:=CBAggregate.Checked; +end; + +function TReportVariablesForm.GetCurrentResetType: TFPReportResetType; +begin + if CBResetType.ItemIndex=-1 then + Result:=rtNone + else + Result:=TFPReportResetType(CBResetType.ItemIndex) +end; + +procedure TReportVariablesForm.SetCurrentIsExpression(AValue: Boolean); +begin + CBAggregate.Checked:=AValue; + CheckExpression; +end; + +procedure TReportVariablesForm.SetCurrentResetType(AValue: TFPReportResetType); +begin + CBResetType.ItemIndex:=Ord(AValue); + CheckResetType; +end; + +procedure TReportVariablesForm.CheckResetType; + +begin + CBResetType.Enabled:=CBAggregate.Checked; + CBResetExpression.Enabled:=CBAggregate.Checked and (CurrentResetType in [rtGroup]); + Case CurrentResetType of + rtPage: CBResetExpression.Text:='PageNo'; + rtColumn: CBResetExpression.Text:='ColNo'; + rtGroup, + rtNone : if not CBResetExpression.Enabled then + CBResetExpression.Text:='' + end; +end; + +procedure TReportVariablesForm.CheckExpression; + +begin + EExpression.Enabled:=CBAggregate.Checked; + if not EExpression.Enabled then + EExpression.Text:=''; + CheckResetType; +end; + procedure TReportVariablesForm.SetType(AValue: TResultType); begin @@ -229,6 +307,31 @@ begin ShowCurrentTypeEditor; end; +procedure TReportVariablesForm.SetReport(AValue: TFPCustomReport); +begin + inherited SetReport(AValue); + FillExpressionsList; +end; + +procedure TReportVariablesForm.FillExpressionsList; + +Var + R : TFPReport; + S : String; + I,J : Integer; + +begin + R:=TFPReport(Report); + For I:=0 to R.PageCount-1 do + For J:=0 to R.Pages[I].BandCount-1 do + If R.Pages[I].Bands[J] is TFPReportCustomGroupHeaderBand then + begin + S:=TFPReportGroupHeaderBand(R.Pages[I].Bands[J]).GroupCondition; + if (S<>'') then + CBResetExpression.Items.Add(S); + end; +end; + procedure TReportVariablesForm.ShowCurrentTypeEditor; Var @@ -255,6 +358,7 @@ begin end; FCurrentVariable.DataType:=CurrentType; With FCurrentVariable do + begin Case DataType of rtBoolean : AsBoolean:=CBBoolean.Checked; rtInteger : AsInteger:=SEinteger.Value; @@ -263,7 +367,20 @@ begin rtString : AsString := EString.Text; else Raise Exception.Create('Unknown datatype !'); - end + end; + If CurrentIsExpression then + begin + FCurrentVariable.Expression:=EExpression.Text; + FCurrentVariable.ResetType:=CurrentResetType; + FCurrentVariable.ResetValueExpression:=CBResetExpression.Text; + end + else + begin + FCurrentVariable.Expression:=''; + FCurrentVariable.ResetType:=rtNone; + FCurrentVariable.ResetValueExpression:=''; + end + end; end; procedure TReportVariablesForm.ShowCurrentVariable; @@ -275,6 +392,8 @@ begin HV:=Assigned(FCurrentVariable); EName.Enabled:=HV; CBType.Enabled:=HV; + CurrentIsExpression:=HV and (FCurrentVariable.Expression<>''); + CBAggregate.Enabled:=HV; if not HV then begin EName.Text:=''; @@ -295,7 +414,14 @@ begin rtString : EString.Text:=AsString; else Raise Exception.Create('Unknown datatype !'); - end + end; + CurrentIsExpression:=FCurrentVariable.Expression<>''; + If CurrentIsExpression then + begin + EExpression.Text:=FCurrentVariable.Expression; + CurrentResetType:=FCurrentVariable.ResetType; + CBResetExpression.Text:=FCurrentVariable.ResetValueExpression; + end; end; end;