1 |
torben |
2671 |
// 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: StNVBits.pas 4.04 *}
|
30 |
|
|
{*********************************************************}
|
31 |
|
|
{* SysTools: non visual component for TStBits *}
|
32 |
|
|
{*********************************************************}
|
33 |
|
|
|
34 |
|
|
{$I StDefine.inc}
|
35 |
|
|
|
36 |
|
|
unit StNVBits;
|
37 |
|
|
|
38 |
|
|
interface
|
39 |
|
|
|
40 |
|
|
uses
|
41 |
|
|
Windows,
|
42 |
|
|
Classes,
|
43 |
|
|
StBase, StBits, StNVCont;
|
44 |
|
|
|
45 |
|
|
type
|
46 |
|
|
TStNVBits = class(TStNVContainerBase)
|
47 |
|
|
{.Z+}
|
48 |
|
|
protected {private}
|
49 |
|
|
{property variables}
|
50 |
|
|
FContainer : TStBits; {instance of the container}
|
51 |
|
|
FMaxBits : LongInt;
|
52 |
|
|
|
53 |
|
|
{property methods}
|
54 |
|
|
procedure SetMaxBits(Value : LongInt);
|
55 |
|
|
|
56 |
|
|
protected
|
57 |
|
|
{virtual property methods}
|
58 |
|
|
function GetOnLoadData : TStLoadDataEvent;
|
59 |
|
|
override;
|
60 |
|
|
function GetOnStoreData : TStStoreDataEvent;
|
61 |
|
|
override;
|
62 |
|
|
procedure SetOnLoadData(Value : TStLoadDataEvent);
|
63 |
|
|
override;
|
64 |
|
|
procedure SetOnStoreData(Value : TStStoreDataEvent);
|
65 |
|
|
override;
|
66 |
|
|
|
67 |
|
|
public
|
68 |
|
|
constructor Create(AOwner : TComponent);
|
69 |
|
|
override;
|
70 |
|
|
destructor Destroy;
|
71 |
|
|
override;
|
72 |
|
|
{.Z-}
|
73 |
|
|
|
74 |
|
|
property Container : TStBits
|
75 |
|
|
read FContainer;
|
76 |
|
|
|
77 |
|
|
published
|
78 |
|
|
property MaxBits : LongInt
|
79 |
|
|
read FMaxBits
|
80 |
|
|
write SetMaxBits default 100;
|
81 |
|
|
|
82 |
|
|
property OnLoadData;
|
83 |
|
|
property OnStoreData;
|
84 |
|
|
end;
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
implementation
|
88 |
|
|
|
89 |
|
|
{*** TStNVBits ***}
|
90 |
|
|
|
91 |
|
|
constructor TStNVBits.Create(AOwner : TComponent);
|
92 |
|
|
begin
|
93 |
|
|
inherited Create(AOwner);
|
94 |
|
|
|
95 |
|
|
{defaults}
|
96 |
|
|
FMaxBits := 100;
|
97 |
|
|
|
98 |
|
|
if Classes.GetClass(TStBits.ClassName) = nil then
|
99 |
|
|
RegisterClass(TStBits);
|
100 |
|
|
|
101 |
|
|
FContainer := TStBits.Create(FMaxBits-1);
|
102 |
|
|
end;
|
103 |
|
|
|
104 |
|
|
destructor TStNVBits.Destroy;
|
105 |
|
|
begin
|
106 |
|
|
FContainer.Free;
|
107 |
|
|
FContainer := nil;
|
108 |
|
|
|
109 |
|
|
inherited Destroy;
|
110 |
|
|
end;
|
111 |
|
|
|
112 |
|
|
function TStNVBits.GetOnLoadData : TStLoadDataEvent;
|
113 |
|
|
begin
|
114 |
|
|
Result := FContainer.OnLoadData;
|
115 |
|
|
end;
|
116 |
|
|
|
117 |
|
|
function TStNVBits.GetOnStoreData : TStStoreDataEvent;
|
118 |
|
|
begin
|
119 |
|
|
Result := FContainer.OnStoreData;
|
120 |
|
|
end;
|
121 |
|
|
|
122 |
|
|
procedure TStNVBits.SetMaxBits(Value : LongInt);
|
123 |
|
|
var
|
124 |
|
|
HoldOnLoadData : TStLoadDataEvent;
|
125 |
|
|
HoldOnStoreData : TStStoreDataEvent;
|
126 |
|
|
begin
|
127 |
|
|
{setting MaxBits will destroy exisiting data}
|
128 |
|
|
if Value < 0 then
|
129 |
|
|
Value := 0;
|
130 |
|
|
FMaxBits := Value;
|
131 |
|
|
|
132 |
|
|
HoldOnLoadData := FContainer.OnLoadData;
|
133 |
|
|
HoldOnStoreData := FContainer.OnStoreData;
|
134 |
|
|
FContainer.Free;
|
135 |
|
|
FContainer := TStBits.Create(FMaxBits-1);
|
136 |
|
|
FContainer.OnLoadData := HoldOnLoadData;
|
137 |
|
|
FContainer.OnStoreData := HoldOnStoreData;
|
138 |
|
|
end;
|
139 |
|
|
|
140 |
|
|
procedure TStNVBits.SetOnLoadData(Value : TStLoadDataEvent);
|
141 |
|
|
begin
|
142 |
|
|
FContainer.OnLoadData := Value;
|
143 |
|
|
end;
|
144 |
|
|
|
145 |
|
|
procedure TStNVBits.SetOnStoreData(Value : TStStoreDataEvent);
|
146 |
|
|
begin
|
147 |
|
|
FContainer.OnStoreData := Value;
|
148 |
|
|
end;
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
end.
|