@Nimoee: wenn du gleich gesagt hättest, dass du auch keine Ahnung hast wie das geht, anstatt den Eindruck zu vermitteln du wüsstest es, sagst es aber nicht wäre es vielleicht einfacher gewesen...
Aber ok, dann geb ich mal Code-Beispiele für beide Möglichkeiten:
1) Enumerations-Typ
Delphi-Quellcode:
TMyEnumeration = (meFirst, meSecond, meThird, meFourth);
TMyObject = class(TComponent)
private
FMyEnumeration: TMyEnumeration;
published
property MyEnumeration: TMyEnumeration read FMyEnumeration write FMyEnumeration;
end;
2) TPersisten-Nachfolger
Delphi-Quellcode:
TMyPersistentObject = class(TPersistent)
private
FIntegerProperty: Integer;
FStringProperty: String;
FColorProperty: TColor;
public
procedure Assign(Source: TPersistent); override;
published
property StringProperty: String read FStringProperty write FStringProperty;
property IntegerProperty: Integer read FIntegerProperty write FIntegerProperty;
property ColorProperty: TColor read FColorProperty write FColorProperty;
{...}
end;
TMyObject = class(TComponent)
private
FMyPersistentObject: TMyPersistentObject;
procedure SetMyPersistentObject(const Value: TMyPersistentObject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property MyPersistenObject: TMyPersistentObject read FMyPersistentObject write SetMyPersistentObject;
end;
{ TMyPersistentObject }
procedure TMyPersistentObject.Assign(Source: TPersistent);
begin
if (Source <> nil) and (Source is TMyPersistentObject) then
with TMyPersistentObject(Source) do
begin
Self.FIntegerProperty := FIntegerProperty;
Self.FStringProperty := FStringProperty;
Self.FColorProperty := FColorProperty;
end
else
inherited Assign(Source);
end;
{ TMyObject }
constructor TMyObject.Create(AOwner: TComponent);
begin
inherited;
FMyPersistentObject := TMyPersistentObject.Create;
end;
destructor TMyObject.Destroy;
begin
FMyPersistentObject.Free;
inherited;
end;
procedure TMyObject.SetMyPersistentObject(const Value: TMyPersistentObject);
begin
FMyPersistentObject.Assign(Value);
end;