PageRenderTime 13ms CodeModel.GetById 11ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/FR_DSET.PAS

http://github.com/FastReports/FreeReport
Pascal | 96 lines | 70 code | 17 blank | 9 comment | 4 complexity | 75380c730b89a68c84c0082ecf009df3 MD5 | raw file
 1
 2{*****************************************}
 3{                                         }
 4{             FastReport v2.3             }
 5{             Report dataset              }
 6{                                         }
 7{  Copyright (c) 1998-99 by Tzyganenko A. }
 8{                                         }
 9{*****************************************}
10
11unit FR_DSet;
12
13interface
14
15{$I FR.inc}
16
17uses
18  SysUtils, Windows, Messages, Classes;
19
20type
21  TRangeBegin = (rbFirst, rbCurrent);
22  TRangeEnd = (reLast, reCurrent, reCount);
23  TCheckEOFEvent = procedure(Sender: TObject; var Eof: Boolean) of object;
24
25  TfrDataset = class(TComponent)
26  protected
27    FRangeBegin: TRangeBegin;
28    FRangeEnd: TRangeEnd;
29    FRangeEndCount: Integer;
30    FOnFirst, FOnNext, FOnLast: TNotifyEvent;
31    FOnCheckEOF: TCheckEOFEvent;
32    FRecNo: Integer;
33  public
34    constructor Create(AOwner: TComponent); override;
35    procedure Init; virtual;
36    procedure Exit; virtual;
37    procedure First; virtual;
38    procedure Next; virtual;
39    function Eof: Boolean; virtual;
40    property RangeBegin: TRangeBegin read FRangeBegin write FRangeBegin default rbFirst;
41    property RangeEnd: TRangeEnd read FRangeEnd write FRangeEnd default reLast;
42    property RangeEndCount: Integer read FRangeEndCount write FRangeEndCount default 0;
43    property RecNo: Integer read FRecNo;
44    property OnCheckEOF: TCheckEOFEvent read FOnCheckEOF write FOnCheckEOF;
45    property OnFirst: TNotifyEvent read FOnFirst write FOnFirst;
46    property OnNext: TNotifyEvent read FOnNext write FOnNext;
47  end;
48
49  TfrUserDataset = class(TfrDataset)
50  published
51    property RangeBegin;
52    property RangeEnd;
53    property RangeEndCount;
54    property OnCheckEOF;
55    property OnFirst;
56    property OnNext;
57  end;
58
59implementation
60
61constructor TfrDataSet.Create(AOwner: TComponent);
62begin
63  inherited Create(AOwner);
64  RangeBegin := rbFirst;
65  RangeEnd := reLast;
66end;
67
68procedure TfrDataSet.Init;
69begin
70end;
71
72procedure TfrDataSet.Exit;
73begin
74end;
75
76procedure TfrDataSet.First;
77begin
78  FRecNo := 0;
79  if Assigned(FOnFirst) then FOnFirst(Self);
80end;
81
82procedure TfrDataSet.Next;
83begin
84  Inc(FRecNo);
85  if Assigned(FOnNext) then FOnNext(Self);
86end;
87
88function TfrDataSet.Eof: Boolean;
89begin
90  Result := False;
91  if (FRangeEnd = reCount) and (FRecNo >= FRangeEndCount) then Result := True;
92  if Assigned(FOnCheckEOF) then FOnCheckEOF(Self, Result);
93end;
94
95
96end.