unit ResComponent;
interface
uses
System.SysUtils, System.Classes,
System.Generics.Collections,
System.Contnrs,
VCL.Forms,
DesignIntf, DesignEditors;
type
TText0 =
type Integer;
TText0Property =
class(TPropertyEditor)
public
function GetAttributes: TPropertyAttributes;
override;
procedure Initialize;
override;
procedure Edit;
override;
function GetValue:
string;
override;
procedure SetValue(
const Value:
string);
overload;
override;
end;
type
TResourceHolderItem =
class(TCollectionItem)
private
FStringList: TStringList;
FTextProperty: TText0Property;
procedure setStringList(AValue: TStringList);
public
constructor Create(Collention: TCollection);
override;
destructor Destroy;
override;
published
property Element: TStringList
read FStringList
write setStringList;
property Text: TText0Property
read FTextProperty
write FTextProperty;
end;
TResourceHolder =
class(TCollection)
private
function GetItem(AIndex: Integer): TResourceHolderItem;
procedure SetItem(AIndex: Integer; AValue: TResourceHolderItem);
public
property Items[
Index : Integer]: TResourceHolderItem
read GetItem
write SetItem;
end;
TCompressedResource =
class(TComponent)
private
FStringList: TStringList;
FCollection: TResourceHolder;
procedure SetStringList(AValue: TStringList);
procedure SetCollection(AValue: TResourceHolder);
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property Collection: TResourceHolder
read FCollection
write SetCollection;
property StringList: TStringList
read FStringList
write SetStringList;
end;
procedure Register;
implementation
constructor TResourceHolderItem.Create(Collention: TCollection);
begin
inherited;
FStringList := TStringList.Create;
end;
destructor TResourceHolderItem.Destroy;
begin
FStringList.Clear;
FStringList.Free;
FStringList :=
nil;
inherited;
end;
procedure TResourceHolder.SetItem(AIndex: Integer; AValue: TResourceHolderItem);
begin
inherited Items[AIndex] := AValue;
end;
function TResourceHolder.GetItem(AIndex: Integer): TResourceHolderItem;
begin
result := TResourceHolderItem(
inherited Items[AIndex]);
end;
procedure TResourceHolderItem.setStringList(AValue: TStringList);
begin
FStringList.Assign(AValue);
end;
constructor TCompressedResource.Create(AOwner: TComponent);
begin
inherited;
FStringList := TStringList.Create;
FCollection := TResourceHolder.Create(TResourceHolderItem);
end;
destructor TCompressedResource.Destroy;
begin
FStringList.Clear;
FStringList.Free;
FStringList :=
nil;
FCollection.Clear;
FCollection.Free;
FCollection :=
nil;
inherited;
end;
procedure TCompressedResource.SetStringList(AValue: TStringList);
begin
FStringList.Assign(AValue);
end;
procedure TCompressedResource.SetCollection(AValue: TResourceHolder);
begin
FCollection.Assign(AValue);
end;
procedure TText0Property.Edit;
var
F: TForm;
begin
F := TForm.Create(
nil);
try
F.Position := poScreenCenter;
F.Height := Screen.Height - 100;
F.Width := 500;
F.ShowModal;
finally
F.Free;
end;
end;
function TText0Property.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TText0Property.GetValue:
string;
begin
Result := '
100';
end;
procedure TText0Property.Initialize;
begin
inherited;
end;
procedure TText0Property.SetValue(
const Value:
string);
begin
SetOrdValue(StrToInt(Trim(Copy(Value, 1, Pos('
:', Value + '
:') - 1))));
end;
procedure Register;
begin
RegisterPropertyEditor(
TypeInfo(TText0),
TResourceHolderItem,
'
Text',
TText0Property);
RegisterComponents('
KALLUP', [TCompressedResource]);
end;
end.