/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/source/StNVLAry.pas
ViewVC logotype

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/source/StNVLAry.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (show annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 5608 byte(s)
Added tpsystools component
1 // Upgraded to Delphi 2009: Sebastian Zierer
2
3 (* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is TurboPower SysTools
17 *
18 * The Initial Developer of the Original Code is
19 * TurboPower Software
20 *
21 * Portions created by the Initial Developer are Copyright (C) 1996-2002
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 *
26 * ***** END LICENSE BLOCK ***** *)
27
28 {*********************************************************}
29 {* SysTools: StNVLAry.pas 4.04 *}
30 {*********************************************************}
31 {* SysTools: non visual component for TStLArray *}
32 {*********************************************************}
33
34 {$I StDefine.inc}
35
36 unit StNVLAry;
37
38 interface
39
40 uses
41 Windows,
42 Classes,
43 StBase, StLArr, StNVCont;
44
45 type
46 TStNVLArray = class(TStNVContainerBase)
47 {.Z+}
48 protected {private}
49 {property variables}
50 FContainer : TStLArray; {instance of the container}
51 FElementCount : LongInt;
52 FElementSize : Cardinal;
53
54 {property methods}
55 function GetStoreable : Boolean;
56 procedure SetElementCount(Value : LongInt);
57 procedure SetElementSize(Value : Cardinal);
58 procedure SetStoreable(Value : Boolean);
59
60 {internal methods}
61 procedure RecreateContainer;
62
63 protected
64 function GetOnCompare : TStCompareEvent;
65 override;
66 function GetOnDisposeData : TStDisposeDataEvent;
67 override;
68 function GetOnLoadData : TStLoadDataEvent;
69 override;
70 function GetOnStoreData : TStStoreDataEvent;
71 override;
72 procedure SetOnCompare(Value : TStCompareEvent);
73 override;
74 procedure SetOnDisposeData(Value : TStDisposeDataEvent);
75 override;
76 procedure SetOnLoadData(Value : TStLoadDataEvent);
77 override;
78 procedure SetOnStoreData(Value : TStStoreDataEvent);
79 override;
80
81 public
82 constructor Create(AOwner : TComponent);
83 override;
84 destructor Destroy;
85 override;
86 {.Z-}
87
88 property Container : TStLArray
89 read FContainer;
90
91 published
92 property ElementCount : LongInt
93 read FElementCount
94 write SetElementCount default 10;
95
96 property ElementSize : Cardinal
97 read FElementSize
98 write SetElementSize default SizeOf(LongInt);
99
100 property ElementsStorable : Boolean
101 read GetStoreable
102 write SetStoreable default False;
103
104 property OnCompare;
105 property OnDisposeData;
106 property OnLoadData;
107 property OnStoreData;
108 end;
109
110
111 implementation
112
113 {*** TStNVLArray ***}
114
115 constructor TStNVLArray.Create(AOwner : TComponent);
116 begin
117 inherited Create(AOwner);
118
119 {defaults}
120 FElementCount := 10;
121 FElementSize := SizeOf(LongInt);
122
123 if Classes.GetClass(TStLArray.ClassName) = nil then
124 RegisterClass(TStLArray);
125
126 FContainer := TStLArray.Create(FElementCount, FElementSize);
127 end;
128
129 destructor TStNVLArray.Destroy;
130 begin
131 FContainer.Free;
132 FContainer := nil;
133
134 inherited Destroy;
135 end;
136
137 function TStNVLArray.GetOnCompare : TStCompareEvent;
138 begin
139 Result := FContainer.OnCompare;
140 end;
141
142 function TStNVLArray.GetOnDisposeData : TStDisposeDataEvent;
143 begin
144 Result := FContainer.OnDisposeData;
145 end;
146
147 function TStNVLArray.GetOnLoadData : TStLoadDataEvent;
148 begin
149 Result := FContainer.OnLoadData;
150 end;
151
152 function TStNVLArray.GetOnStoreData : TStStoreDataEvent;
153 begin
154 Result := FContainer.OnStoreData;
155 end;
156
157 function TStNVLArray.GetStoreable : Boolean;
158 begin
159 Result := FContainer.ElementsStorable;
160 end;
161
162 procedure TStNVLArray.RecreateContainer;
163 var
164 HoldOnCompare : TStCompareEvent;
165 HoldOnDisposeData : TStDisposeDataEvent;
166 HoldOnLoadData : TStLoadDataEvent;
167 HoldOnStoreData : TStStoreDataEvent;
168 begin
169 HoldOnCompare := FContainer.OnCompare;
170 HoldOnDisposeData := FContainer.OnDisposeData;
171 HoldOnLoadData := FContainer.OnLoadData;
172 HoldOnStoreData := FContainer.OnStoreData;
173 FContainer.Free;
174 FContainer := TStLArray.Create(FElementCount, FElementSize);
175 FContainer.OnCompare := HoldOnCompare;
176 FContainer.OnDisposeData := HoldOnDisposeData;
177 FContainer.OnLoadData := HoldOnLoadData;
178 FContainer.OnStoreData := HoldOnStoreData;
179 end;
180
181 procedure TStNVLArray.SetElementCount(Value : LongInt);
182 begin
183 FElementCount := Value;
184 RecreateContainer;
185 end;
186
187 procedure TStNVLArray.SetElementSize(Value : Cardinal);
188 begin
189 FElementSize := Value;
190 RecreateContainer;
191 end;
192
193 procedure TStNVLArray.SetOnCompare(Value : TStCompareEvent);
194 begin
195 FContainer.OnCompare := Value;
196 end;
197
198 procedure TStNVLArray.SetOnDisposeData(Value : TStDisposeDataEvent);
199 begin
200 FContainer.OnDisposeData := Value;
201 end;
202
203 procedure TStNVLArray.SetOnLoadData(Value : TStLoadDataEvent);
204 begin
205 FContainer.OnLoadData := Value;
206 end;
207
208 procedure TStNVLArray.SetOnStoreData(Value : TStStoreDataEvent);
209 begin
210 FContainer.OnStoreData := Value;
211 end;
212
213 procedure TStNVLArray.SetStoreable(Value : Boolean);
214 begin
215 FContainer.ElementsStorable := Value;
216 end;
217
218
219 end.

  ViewVC Help
Powered by ViewVC 1.1.20