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: StNVLMat.pas 4.04 *}
|
30 |
{*********************************************************}
|
31 |
{* SysTools:non visual component for TStLMatrix *}
|
32 |
{*********************************************************}
|
33 |
|
34 |
{$I StDefine.inc}
|
35 |
|
36 |
unit StNVLMat;
|
37 |
|
38 |
interface
|
39 |
|
40 |
uses
|
41 |
Windows,
|
42 |
Classes,
|
43 |
StBase, StLArr, StNVCont;
|
44 |
|
45 |
type
|
46 |
TStNVLMatrix = class(TStNVContainerBase)
|
47 |
{.Z+}
|
48 |
protected {private}
|
49 |
{property variables}
|
50 |
FContainer : TStLMatrix; {instance of the container}
|
51 |
FCols : Cardinal;
|
52 |
FRows : Cardinal;
|
53 |
FElementSize : Cardinal;
|
54 |
|
55 |
{property methods}
|
56 |
function GetStoreable : Boolean;
|
57 |
procedure SetCols(Value : Cardinal);
|
58 |
procedure SetRows(Value : Cardinal);
|
59 |
procedure SetElementSize(Value : Cardinal);
|
60 |
procedure SetStoreable(Value : Boolean);
|
61 |
|
62 |
{internal methods}
|
63 |
procedure RecreateContainer;
|
64 |
|
65 |
protected
|
66 |
function GetOnCompare : TStCompareEvent;
|
67 |
override;
|
68 |
function GetOnDisposeData : TStDisposeDataEvent;
|
69 |
override;
|
70 |
function GetOnLoadData : TStLoadDataEvent;
|
71 |
override;
|
72 |
function GetOnStoreData : TStStoreDataEvent;
|
73 |
override;
|
74 |
procedure SetOnCompare(Value : TStCompareEvent);
|
75 |
override;
|
76 |
procedure SetOnDisposeData(Value : TStDisposeDataEvent);
|
77 |
override;
|
78 |
procedure SetOnLoadData(Value : TStLoadDataEvent);
|
79 |
override;
|
80 |
procedure SetOnStoreData(Value : TStStoreDataEvent);
|
81 |
override;
|
82 |
|
83 |
public
|
84 |
constructor Create(AOwner : TComponent);
|
85 |
override;
|
86 |
destructor Destroy;
|
87 |
override;
|
88 |
{.Z-}
|
89 |
|
90 |
property Container : TStLMatrix
|
91 |
read FContainer;
|
92 |
|
93 |
published
|
94 |
property Cols : Cardinal
|
95 |
read FCols
|
96 |
write SetCols default 2;
|
97 |
|
98 |
property Rows : Cardinal
|
99 |
read FRows
|
100 |
write SetRows default 10;
|
101 |
|
102 |
property ElementSize : Cardinal
|
103 |
read FElementSize
|
104 |
write SetElementSize default SizeOf(LongInt);
|
105 |
|
106 |
property ElementsStorable : Boolean
|
107 |
read GetStoreable
|
108 |
write SetStoreable default False;
|
109 |
|
110 |
property OnCompare;
|
111 |
property OnDisposeData;
|
112 |
property OnLoadData;
|
113 |
property OnStoreData;
|
114 |
end;
|
115 |
|
116 |
|
117 |
implementation
|
118 |
|
119 |
{*** TStNVLMatrix ***}
|
120 |
|
121 |
constructor TStNVLMatrix.Create(AOwner : TComponent);
|
122 |
begin
|
123 |
inherited Create(AOwner);
|
124 |
|
125 |
{defaults}
|
126 |
FCols := 2;
|
127 |
FRows := 10;
|
128 |
FElementSize := SizeOf(LongInt);
|
129 |
|
130 |
if Classes.GetClass(TStLMatrix.ClassName) = nil then
|
131 |
RegisterClass(TStLMatrix);
|
132 |
|
133 |
FContainer := TStLMatrix.Create(FRows, FCols, FElementSize);
|
134 |
end;
|
135 |
|
136 |
destructor TStNVLMatrix.Destroy;
|
137 |
begin
|
138 |
FContainer.Free;
|
139 |
FContainer := nil;
|
140 |
|
141 |
inherited Destroy;
|
142 |
end;
|
143 |
|
144 |
function TStNVLMatrix.GetOnCompare : TStCompareEvent;
|
145 |
begin
|
146 |
Result := FContainer.OnCompare;
|
147 |
end;
|
148 |
|
149 |
function TStNVLMatrix.GetOnDisposeData : TStDisposeDataEvent;
|
150 |
begin
|
151 |
Result := FContainer.OnDisposeData;
|
152 |
end;
|
153 |
|
154 |
function TStNVLMatrix.GetOnLoadData : TStLoadDataEvent;
|
155 |
begin
|
156 |
Result := FContainer.OnLoadData;
|
157 |
end;
|
158 |
|
159 |
function TStNVLMatrix.GetOnStoreData : TStStoreDataEvent;
|
160 |
begin
|
161 |
Result := FContainer.OnStoreData;
|
162 |
end;
|
163 |
|
164 |
function TStNVLMatrix.GetStoreable : Boolean;
|
165 |
begin
|
166 |
Result := FContainer.ElementsStorable;
|
167 |
end;
|
168 |
|
169 |
procedure TStNVLMatrix.RecreateContainer;
|
170 |
var
|
171 |
HoldOnCompare : TStCompareEvent;
|
172 |
HoldOnDisposeData : TStDisposeDataEvent;
|
173 |
HoldOnLoadData : TStLoadDataEvent;
|
174 |
HoldOnStoreData : TStStoreDataEvent;
|
175 |
begin
|
176 |
HoldOnCompare := FContainer.OnCompare;
|
177 |
HoldOnDisposeData := FContainer.OnDisposeData;
|
178 |
HoldOnLoadData := FContainer.OnLoadData;
|
179 |
HoldOnStoreData := FContainer.OnStoreData;
|
180 |
FContainer.Free;
|
181 |
FContainer := TStLMatrix.Create(FRows, FCols, FElementSize);
|
182 |
FContainer.OnCompare := HoldOnCompare;
|
183 |
FContainer.OnDisposeData := HoldOnDisposeData;
|
184 |
FContainer.OnLoadData := HoldOnLoadData;
|
185 |
FContainer.OnStoreData := HoldOnStoreData;
|
186 |
end;
|
187 |
|
188 |
procedure TStNVLMatrix.SetCols(Value : Cardinal);
|
189 |
begin
|
190 |
FCols := Value;
|
191 |
RecreateContainer;
|
192 |
end;
|
193 |
|
194 |
procedure TStNVLMatrix.SetElementSize(Value : Cardinal);
|
195 |
begin
|
196 |
FElementSize := Value;
|
197 |
RecreateContainer;
|
198 |
end;
|
199 |
|
200 |
procedure TStNVLMatrix.SetOnCompare(Value : TStCompareEvent);
|
201 |
begin
|
202 |
FContainer.OnCompare := Value;
|
203 |
end;
|
204 |
|
205 |
procedure TStNVLMatrix.SetOnDisposeData(Value : TStDisposeDataEvent);
|
206 |
begin
|
207 |
FContainer.OnDisposeData := Value;
|
208 |
end;
|
209 |
|
210 |
procedure TStNVLMatrix.SetOnLoadData(Value : TStLoadDataEvent);
|
211 |
begin
|
212 |
FContainer.OnLoadData := Value;
|
213 |
end;
|
214 |
|
215 |
procedure TStNVLMatrix.SetOnStoreData(Value : TStStoreDataEvent);
|
216 |
begin
|
217 |
FContainer.OnStoreData := Value;
|
218 |
end;
|
219 |
|
220 |
procedure TStNVLMatrix.SetRows(Value : Cardinal);
|
221 |
begin
|
222 |
FRows := Value;
|
223 |
RecreateContainer;
|
224 |
end;
|
225 |
|
226 |
procedure TStNVLMatrix.SetStoreable(Value : Boolean);
|
227 |
begin
|
228 |
FContainer.ElementsStorable := Value;
|
229 |
end;
|
230 |
|
231 |
|
232 |
end.
|