PageRenderTime 31ms CodeModel.GetById 21ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Source/FR_VAR.PAS

http://github.com/FastReports/FreeReport
Pascal | 174 lines | 135 code | 27 blank | 12 comment | 14 complexity | 84d8da598da86d4ef2d7750aca91e6b0 MD5 | raw file
  1
  2{*****************************************}
  3{                                         }
  4{             FastReport v2.3             }
  5{             Variables form              }
  6{                                         }
  7{  Copyright (c) 1998-99 by Tzyganenko A. }
  8{                                         }
  9{*****************************************}
 10
 11unit FR_Var;
 12
 13interface
 14
 15{$I FR.inc}
 16
 17uses
 18  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
 19  Forms, Dialogs, StdCtrls, FR_Const;
 20
 21type
 22
 23  TfrVarForm = class(TForm)
 24    ValList: TListBox;
 25    ValCombo: TComboBox;
 26    Label1: TLabel;
 27    procedure ValListKeyDown(Sender: TObject; var Key: Word;
 28      Shift: TShiftState);
 29    procedure ValComboClick(Sender: TObject);
 30    procedure FormActivate(Sender: TObject);
 31    procedure FormCreate(Sender: TObject);
 32    procedure ValListMouseDown(Sender: TObject; Button: TMouseButton;
 33      Shift: TShiftState; X, Y: Integer);
 34    procedure FormDeactivate(Sender: TObject);
 35    procedure FormKeyDown(Sender: TObject; var Key: Word;
 36      Shift: TShiftState);
 37  private
 38    { Private declarations }
 39    function CurVal: String;
 40    function CurDataSet: String;
 41    procedure GetVariables;
 42    procedure GetSpecValues;
 43    procedure GetFRVariables;
 44    procedure FillValCombo;
 45  public
 46    { Public declarations }
 47    SelectedItem: String;
 48  end;
 49
 50var
 51  frVarForm: TfrVarForm;
 52
 53implementation
 54
 55{$R *.DFM}
 56
 57uses FR_Class;
 58
 59var
 60  LastCategory: String;
 61
 62function TfrVarForm.CurVal: String;
 63begin
 64  Result := '';
 65  if ValList.ItemIndex <> -1 then
 66    Result := ValList.Items[ValList.ItemIndex];
 67end;
 68
 69function TfrVarForm.CurDataSet: String;
 70begin
 71  Result := '';
 72  if ValCombo.ItemIndex <> -1 then
 73    Result := ValCombo.Items[ValCombo.ItemIndex];
 74end;
 75
 76procedure TfrVarForm.FillValCombo;
 77var
 78  s: TStringList;
 79begin
 80  s := TStringList.Create;
 81  CurReport.GetCategoryList(s);
 82  s.Add(LoadStr(SSpecVal));
 83  s.Add(LoadStr(SFRVariables));
 84  ValCombo.Items.Assign(s);
 85  s.Free;
 86end;
 87
 88procedure TfrVarForm.ValComboClick(Sender: TObject);
 89begin
 90  if CurDataSet = LoadStr(SFRVariables) then
 91    GetFRVariables
 92  else if CurDataSet = LoadStr(SSpecVal) then
 93    GetSpecValues else
 94    GetVariables;
 95end;
 96
 97procedure TfrVarForm.GetVariables;
 98begin
 99  CurReport.GetVarList(ValCombo.ItemIndex, ValList.Items);
100end;
101
102procedure TfrVarForm.GetSpecValues;
103var
104  i: Integer;
105begin
106  with ValList.Items do
107  begin
108    Clear;
109    for i := 0 to frSpecCount-1 do
110      if i <> 1 then
111        Add(frSpecArr[i]);
112  end;
113end;
114
115procedure TfrVarForm.GetFRVariables;
116var
117  i: Integer;
118begin
119  with ValList.Items do
120  begin
121    Clear;
122    for i := 0 to frVariables.Count - 1 do
123      Add(frVariables.Name[i]);
124  end;
125end;
126
127procedure TfrVarForm.ValListKeyDown(Sender: TObject; var Key: Word;
128  Shift: TShiftState);
129begin
130  if Key = vk_Return then ModalResult := mrOk;
131end;
132
133procedure TfrVarForm.ValListMouseDown(Sender: TObject;
134  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
135begin
136  ModalResult := mrOk;
137end;
138
139procedure TfrVarForm.FormKeyDown(Sender: TObject; var Key: Word;
140  Shift: TShiftState);
141begin
142  if Key = vk_Escape then
143    ModalResult := mrCancel;
144end;
145
146procedure TfrVarForm.FormCreate(Sender: TObject);
147begin
148  Caption := LoadStr(frRes + 440);
149  Label1.Caption := LoadStr(frRes + 441);
150end;
151
152procedure TfrVarForm.FormActivate(Sender: TObject);
153begin
154  FillValCombo;
155  if ValCombo.Items.IndexOf(LastCategory) <> -1 then
156    ValCombo.ItemIndex := ValCombo.Items.IndexOf(LastCategory) else
157    ValCombo.ItemIndex := 0;
158  ValComboClick(nil);
159end;
160
161procedure TfrVarForm.FormDeactivate(Sender: TObject);
162begin
163  if ModalResult = mrOk then
164    if CurDataSet <> LoadStr(SSpecVal) then
165      SelectedItem := CurVal
166    else
167      if ValList.ItemIndex > 0 then
168        SelectedItem := frSpecFuncs[ValList.ItemIndex + 1] else
169        SelectedItem := frSpecFuncs[0];
170  LastCategory := ValCombo.Items[ValCombo.ItemIndex];
171end;
172
173end.
174