type
// \88È\89º\82Ì5\82Â\82Ì\83N\83\89\83X\82Ì\92è\8b`\82Í\81A\8f¬\82³\82¢\95û\82©\82ç\81¨\91å\82«\82¢\95û\82Ö\81A\82Æ
// \8bL\8fq\82µ\82Ä\82 \82é(\8aÜ\82Ü\82ê\82é\95û\82©\82ç\8aÜ\82Þ\95û\81A\82Ì\8f\87\94Ô)
- TReplacePreset = class;
- TReplacePresets = class;
// \8c\9f\8dõ\8cê\82Æ\92u\8a·\8cê\82Ì\83y\83A\82Æ\82»\82Ì\83I\83v\83V\83\87\83\93\82ð\8bL\98^\82·\82é\8d\\91¢\91Ì
TReplacePairRec = record
published
property BeforeStr: string read GetBeforeStr write SetBeforeStr;
property AfterStr: string read GetAfterStr write SetAfterStr;
- property IgnoreCase: boolean read GetIgnoreCase write SetIgnoreCase;
- property UseRegExp: boolean read GetUseRegExp write SetUseRegExp;
+ property IgnoreCase: boolean read GetIgnoreCase write SetIgnoreCase default false;
+ property UseRegExp: boolean read GetUseRegExp write SetUseRegExp default false;
end;
// TReplacePair\82Ì\83R\83\8c\83N\83V\83\87\83\93\83N\83\89\83X\81B
// TReplacePair\82Ì\83R\83\8c\83N\83V\83\87\83\93\82ð\95Û\8e\9d\82µ\81A\83^\83C\83g\83\8b\82È\82Ç\82ð\82Ü\82Æ\82ß\82Ä
// 1\82Â\82Ì\83v\83\8a\83Z\83b\83g\90Ý\92è\8d\80\96Ú\82ð\95\\8c»\82·\82é\83N\83\89\83X
- TReplacePreset = class(TComponent)
+ TReplacePreset = class(TCollectionItem)
private
FTitle: string;
FPairs: TReplacePairCollection;
FShortCut: TShortCut;
- FOwnerList: TReplacePresets;
procedure SetPairs(const Value: TReplacePairCollection);
procedure SetShortCut(const Value: TShortCut);
procedure SetTitle(const Value: string);
- procedure SetOwnerList(const Value: TReplacePresets);
public
- constructor Create(AOwner: TComponent); override;
+ constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
- function HasParent: boolean; override;
- function GetParentComponent: TComponent; override;
- property OwnerList: TReplacePresets read FOwnerList write SetOwnerList;
published
property Pairs: TReplacePairCollection read FPairs write SetPairs;
property Title: string read FTitle write SetTitle;
property ShortCut: TShortCut read FShortCut write SetShortCut;
end;
+ TReplacePresetCollection = class(TCollection)
+ private
+ function GetItem(Index: Integer): TReplacePreset;
+ public
+ function Add: TReplacePreset;
+ property Items[Index: Integer]: TReplacePreset read GetItem; default;
+ end;
+
// \8dÅ\8fI\93I\82É\82±\82ê\82ð\83V\83\8a\83A\83\89\83C\83Y\82·\82é
TReplacePresets = class(TComponent)
private
- FPresets: TObjectList;
- function GetPreset(Index: Integer): TReplacePreset;
- function GetCount: Integer;
+ FPresets: TReplacePresetCollection;
+ procedure SetPresets(const Value: TReplacePresetCollection);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
- procedure IncludePreset(APreset: TReplacePreset);
- procedure ExcludePreset(APreset: TReplacePreset);
procedure Assign(Source: TPersistent); override;
- procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
- property Preset[Index: Integer]: TReplacePreset read GetPreset; default;
- property Count: Integer read GetCount;
+ published
+ property Presets: TReplacePresetCollection read FPresets write SetPresets;
end;
implementation
end;
end;
-constructor TReplacePreset.Create(AOwner: TComponent);
+constructor TReplacePreset.Create(Collection: TCollection);
begin
inherited;
FPairs := TReplacePairCollection.Create(TReplacePair);
inherited;
end;
-function TReplacePreset.GetParentComponent: TComponent;
-begin
- if FOwnerList <> nil then
- Result := FOwnerList
- else
- Result := inherited GetParentComponent;
-end;
-
-function TReplacePreset.HasParent: boolean;
-begin
- if FOwnerList <> nil then
- Result := true
- else
- Result := inherited HasParent;
-end;
-
-procedure TReplacePreset.SetOwnerList(const Value: TReplacePresets);
-begin
- if FOwnerList <> Value then
- begin
- if FOwnerList <> nil then
- FOwnerList.ExcludePreset(Self);
- if Value <> nil then
- Value.IncludePreset(Self);
- FOwnerList := Value;
- end;
-end;
-
procedure TReplacePreset.SetPairs(const Value: TReplacePairCollection);
begin
FPairs.Assign(Value);
constructor TReplacePresets.Create(AOwner: TComponent);
begin
inherited;
- // DO NOT OWN OBJECTS
- FPresets := TObjectList.Create(false);
+ FPresets := TReplacePresetCollection.Create(TReplacePreset);
end;
destructor TReplacePresets.Destroy;
inherited;
end;
-procedure TReplacePresets.ExcludePreset(APreset: TReplacePreset);
+procedure TReplacePresets.SetPresets(
+ const Value: TReplacePresetCollection);
begin
- FPresets.Remove(APreset);
-end;
-
-procedure TReplacePresets.GetChildren(Proc: TGetChildProc;
- Root: TComponent);
-var i: Integer;
-begin
- inherited;
- for i := 0 to FPresets.Count-1 do
- Proc(FPresets[i] as TComponent);
-end;
-
-function TReplacePresets.GetCount: Integer;
-begin
- Result := FPresets.Count;
-end;
-
-function TReplacePresets.GetPreset(Index: Integer): TReplacePreset;
-begin
- Result := FPresets[Index] as TReplacePreset;
-end;
-
-procedure TReplacePresets.IncludePreset(APreset: TReplacePreset);
-begin
- FPresets.Add(APreset);
+ FPresets.Assign(Value);
end;
{ TReplacePairCollection }
Result := (inherited GetItem(Index)) as TReplacePair;
end;
+{ TReplacePresetCollection }
+
+function TReplacePresetCollection.Add: TReplacePreset;
+begin
+ Result := inherited Add as TReplacePreset;
+end;
+
+function TReplacePresetCollection.GetItem(Index: Integer): TReplacePreset;
+begin
+ Result := inherited GetItem(Index) as TReplacePreset;
+end;
+
initialization
Classes.RegisterClass(TReplacePresets);