День добрый. Пишу компонент одно из свойств которого - коллекция. Проблема в том что в дизайн-тайме почему-то не вызывается редактор коллекции. Вроде и GetOwner переопределил.
unit ZsMemo;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, StrUtils;
type
TZsMemo = class;
TZsSpecialWords = class;
TZsOptions= Class;
TZsSpecialWord = class(TCollectionItem)
private
FZsSpecialWords: TZsSpecialWords;
FEnabled: boolean;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property Enabled: boolean read FEnabled write FEnabled;
end;
TZsSpecialWordClass = class of TZsSpecialWord;
TZsSpecialWords = class(TCollection)
private
FOwner: TPersistent;
FZsMemo: TZsMemo;
function GetWord(index:integer): TZsSpecialWord;
procedure SetWord(Index: Integer; Value: TZsSpecialWord);
protected
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TPersistent;ZsMemo:TZsMemo; ZsSpecialWordClass:TZsSpecialWordClass);
destructor Destroy; override;
function AddSpecialWord(NameWord:string): TZsSpecialWord;
procedure DelSpecialWord(index:integer);
property Items[Index: Integer]: TZsSpecialWord read GetWord write SetWord; default;
end;
TZsOptions= Class(TPersistent)
private
FZsMemo: TZsMemo;
FSpecialWords: TZsSpecialWords;
procedure SetSpecialWords(Value: TZsSpecialWords);
public
constructor Create(ZsMemo:TZsMemo);
destructor Destroy; override;
published
property SpecialWords: TZsSpecialWords read FSpecialWords write SetSpecialWords;
end;
TZsMemo = class(TMemo)
private
FOptions: TZsOptions;
procedure SetOptions(Value: TZsOptions);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property PopupMenu;
property Align;
property Enabled;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property ReadOnly;
property Options: TZsOptions read FOptions write SetOptions;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('ZsControls', [TZsMemo]);
end;
constructor TZsSpecialWords.Create(AOwner: TPersistent; ZsMemo:TZsMemo; ZsSpecialWordClass:TZsSpecialWordClass);
begin
FOwner:=AOwner;
inherited Create(ZsSpecialWordClass);
FZsMemo:=ZsMemo;
end;
destructor TZsSpecialWords.Destroy;
begin
inherited;
end;
function TZsSpecialWords.GetOwner: TPersistent;
begin
Result:=FOwner;
end;
function TZsSpecialWords.AddSpecialWord(NameWord:string): TZsSpecialWord;
begin
Result := TZsSpecialWord(inherited Add);
end;
procedure TZsSpecialWords.DelSpecialWord(index:integer);
begin
inherited Delete(index);
end;
function TZsSpecialWords.GetWord(index:integer): TZsSpecialWord;
begin
Result := TZsSpecialWord(inherited Items[Index]);
end;
procedure TZsSpecialWords.SetWord(Index: Integer; Value: TZsSpecialWord);
begin
Items[Index].Assign(Value);
end;
constructor TZsSpecialWord.Create(Collection: TCollection);
begin
inherited Create(Collection);
if Assigned(Collection) and (Collection is TZsSpecialWords) then
FZsSpecialWords := TZsSpecialWords(Collection);
FEnabled := true;
end;
destructor TZsSpecialWord.Destroy;
begin
inherited;
end;
constructor TZsOptions.Create(ZsMemo:TZsMemo);
begin
inherited Create;
FZsMemo:=ZsMemo;
FSpecialWords := TZsSpecialWords.Create(self, ZsMemo, TZsSpecialWord);
end;
destructor TZsOptions.Destroy;
begin
FreeAndNil(FSpecialWords);
inherited Destroy;
end;
procedure TZsOptions.SetSpecialWords(Value: TZsSpecialWords);
begin
FSpecialWords.Assign(Value);
end;
constructor TZsMemo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FOptions := TZsOptions.Create(Self);
end;
destructor TZsMemo.Destroy;
begin
FreeAndNil(FOptions);
inherited Destroy;
end;
procedure TZsMemo.SetOptions(Value: TZsOptions);
begin
FOptions.Assign(Value);
end;
end.