OSDN Git Service

各クラス間の親子関係のロジック、さらに試行錯誤中。
authornaru <bottle@mikage.to>
Sat, 20 Mar 2004 04:21:58 +0000 (04:21 +0000)
committernaru <bottle@mikage.to>
Sat, 20 Mar 2004 04:21:58 +0000 (04:21 +0000)
TReplacePresetsとTReplacePresetの間はTComponentの親子階層にしてみた。
ReplacePresetとTReplacePairCollectionとの間はダイレクトに繋いでみた。

bottleclient/ReplacePresetEditor.dfm
bottleclient/ReplacePresetEditor.pas
bottleclient/StrReplace.pas

index e9992d6..6efdf03 100644 (file)
@@ -1,9 +1,10 @@
 object frmReplacePresetEditor: TfrmReplacePresetEditor
-  Left = 445
-  Top = 303
-  Width = 389
-  Height = 344
+  Left = 511
+  Top = 373
+  BorderStyle = bsDialog
   Caption = #25991#23383#21015#12398#32622#25563#12503#12522#12475#12483#12488
+  ClientHeight = 313
+  ClientWidth = 369
   Color = clBtnFace
   Font.Charset = SHIFTJIS_CHARSET
   Font.Color = clWindowText
@@ -11,12 +12,13 @@ object frmReplacePresetEditor: TfrmReplacePresetEditor
   Font.Name = #65325#65331' '#65328#12468#12471#12483#12463
   Font.Style = []
   OldCreateOrder = True
+  Position = poDesktopCenter
   PixelsPerInch = 96
   TextHeight = 12
   object lvwPairs: TListView
     Left = 0
     Top = 0
-    Width = 381
+    Width = 369
     Height = 129
     Align = alTop
     Columns = <
@@ -37,42 +39,66 @@ object frmReplacePresetEditor: TfrmReplacePresetEditor
     ViewStyle = vsReport
   end
   object btnAdd: TButton
-    Left = 80
-    Top = 240
+    Left = 72
+    Top = 136
     Width = 67
     Height = 25
+    Hint = #32622#25563#12527#12540#12489#12398#12506#12450#12434#36861#21152
     Caption = #36861#21152'(&I)'
     TabOrder = 1
   end
   object btnDelete: TButton
-    Left = 152
-    Top = 240
+    Left = 144
+    Top = 136
     Width = 67
     Height = 25
+    Hint = #32622#25563#12527#12540#12489#12398#12506#12450#12434#21066#38500
     Caption = #21066#38500'(&D)'
     TabOrder = 2
   end
   object btnMoveUp: TButton
-    Left = 232
-    Top = 240
+    Left = 224
+    Top = 136
     Width = 67
     Height = 25
+    Hint = #19978#12395#31227#21205
     Caption = #19978#12408'(&U)'
     TabOrder = 3
   end
   object btnMoveDown: TButton
-    Left = 304
-    Top = 240
+    Left = 296
+    Top = 136
     Width = 67
     Height = 25
-    Caption = #19979#12408'(&O)'
+    Hint = #19979#12395#31227#21205
+    Caption = #19979#12408'(&W)'
     TabOrder = 4
   end
   inline StrReplaceFrame: TfrmStrReplaceFrame
     Left = 7
-    Top = 136
+    Top = 168
     Width = 354
     Height = 100
     TabOrder = 5
   end
+  object btnOk: TButton
+    Left = 280
+    Top = 280
+    Width = 83
+    Height = 25
+    Hint = #22793#26356#20869#23481#12434#30906#23450#12375#12390#12480#12452#12450#12525#12464#12434#38281#12376#12427
+    Caption = '&OK'
+    Default = True
+    TabOrder = 6
+  end
+  object btnCancel: TButton
+    Left = 200
+    Top = 280
+    Width = 75
+    Height = 25
+    Hint = #22793#26356#20869#23481#12434#12461#12515#12531#12475#12523#12375#12390#12480#12452#12450#12525#12464#12434#38281#12376#12427
+    Cancel = True
+    Caption = #12461#12515#12531#12475#12523
+    TabOrder = 7
+  end
 end
index 51ad643..9d67dfc 100644 (file)
@@ -14,15 +14,17 @@ type
     btnMoveUp: TButton;
     btnMoveDown: TButton;
     StrReplaceFrame: TfrmStrReplaceFrame;
+    btnOk: TButton;
+    btnCancel: TButton;
   private
-    FPairs: TReplacePairs;
-    procedure SetPairs(const Value: TReplacePairs);
+    FPairs: TReplacePairCollection;
+    procedure SetPairs(const Value: TReplacePairCollection);
   protected
     procedure UpdateControls;
   public
     constructor Create(AOwner: TCOmponent); override;
     destructor Destroy; override;
-    property Pairs: TReplacePairs read FPairs write SetPairs;
+    property Pairs: TReplacePairCollection read FPairs write SetPairs;
   end;
 
 implementation
@@ -34,7 +36,7 @@ implementation
 constructor TfrmReplacePresetEditor.Create(AOwner: TCOmponent);
 begin
   inherited;
-  FPairs := TReplacePairs.Create(nil);
+  FPairs := TReplacePairCollection.Create(nil);
 end;
 
 destructor TfrmReplacePresetEditor.Destroy;
@@ -43,7 +45,7 @@ begin
   inherited;
 end;
 
-procedure TfrmReplacePresetEditor.SetPairs(const Value: TReplacePairs);
+procedure TfrmReplacePresetEditor.SetPairs(const Value: TReplacePairCollection);
 begin
   FPairs.Assign(Value);
   UpdateControls;
@@ -58,7 +60,7 @@ begin
   lvwPairs.Items.Clear;
   for i := 0 to FPairs.Count-1 do
   begin
-    Pair := FPairs.Pair[i];
+    Pair := FPairs[i];
     with lvwPairs.Items.Add do
     begin
       Caption := Pair.BeforeStr;
index 3b923c6..bf3cefc 100644 (file)
@@ -46,29 +46,13 @@ type
   end;
 
   // TReplacePair\82Ì\83R\83\8c\83N\83V\83\87\83\93\83N\83\89\83X\81B
-  // \82±\82Ì\83\86\83j\83b\83g\82Ì\8aO\82©\82ç\83C\83\93\83X\83^\83\93\83X\89»\82µ\82È\82¢\82±\82Æ
   TReplacePairCollection = class(TCollection)
-  public
-    function ExecuteReplace(TargetStr: string): string;
-  end;
-
-  // TReplacePairCollection\82ð\95ï\82Þ\83N\83\89\83X\81B
-  // \82±\82Ì\83\8c\83x\83\8b\82ÅRead/WriteComponent\82ª\89Â\94\\82É\82È\82é\82æ\82¤\82É\82·\82é
-  TReplacePairs = class(TComponent)
   private
-    FPairs: TReplacePairCollection;
-    procedure SetPairs(const Value: TReplacePairCollection);
-    function GetPair(Index: Integer): TReplacePair;
-    procedure SetPair(Index: Integer; const Value: TReplacePair);
-    function GetCount: Integer;
+    function GetItem(Index: Integer): TReplacePair;
   public
-    procedure Assign(Source: TPersistent); override;
-    property Pair[Index: Integer]: TReplacePair read GetPair write SetPair;
-    property Count: Integer read GetCount;
-  published
-    constructor Create(AOwner: TComponent); override;
-    destructor Destroy; override;
-    property Pairs: TReplacePairCollection read FPairs write SetPairs;
+    function Add: TReplacePair;
+    property Items[Index: Integer]: TReplacePair read GetItem; default;
+    function ExecuteReplace(TargetStr: string): string;
   end;
 
   // 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Ä
@@ -76,10 +60,10 @@ type
   TReplacePreset = class(TComponent)
   private
     FTitle: string;
-    FPairs: TReplacePairs;
+    FPairs: TReplacePairCollection;
     FShortCut: TShortCut;
     FOwnerList: TReplacePresets;
-    procedure SetPairs(const Value: TReplacePairs);
+    procedure SetPairs(const Value: TReplacePairCollection);
     procedure SetShortCut(const Value: TShortCut);
     procedure SetTitle(const Value: string);
     procedure SetOwnerList(const Value: TReplacePresets);
@@ -91,7 +75,7 @@ type
     function GetParentComponent: TComponent; override;
     property OwnerList: TReplacePresets read FOwnerList write SetOwnerList;
   published
-    property Pairs: TReplacePairs read FPairs write SetPairs;
+    property Pairs: TReplacePairCollection read FPairs write SetPairs;
     property Title: string read FTitle write SetTitle;
     property ShortCut: TShortCut read FShortCut write SetShortCut;
   end;
@@ -200,7 +184,7 @@ end;
 constructor TReplacePreset.Create(AOwner: TComponent);
 begin
   inherited;
-  FPairs := TReplacePairs.Create(nil);
+  FPairs := TReplacePairCollection.Create(TReplacePair);
 end;
 
 destructor TReplacePreset.Destroy;
@@ -237,7 +221,7 @@ begin
   end;
 end;
 
-procedure TReplacePreset.SetPairs(const Value: TReplacePairs);
+procedure TReplacePreset.SetPairs(const Value: TReplacePairCollection);
 begin
   FPairs.Assign(Value);
 end;
@@ -309,50 +293,13 @@ begin
   FPresets.Add(APreset);
 end;
 
-{ TReplacePairs }
-
-procedure TReplacePairs.Assign(Source: TPersistent);
-begin
-  if not (Source is TReplacePairs) then
-    inherited
-  else
-    FPairs.Assign((Source as TReplacePairs).FPairs);
-end;
-
-constructor TReplacePairs.Create(AOwner: TComponent);
-begin
-  inherited;
-  FPairs := TReplacePairCollection.Create(TReplacePair);
-end;
-
-destructor TReplacePairs.Destroy;
-begin
-  FPairs.Free;
-  inherited;
-end;
-
-function TReplacePairs.GetCount: Integer;
-begin
-  Result := FPairs.Count;
-end;
-
-function TReplacePairs.GetPair(Index: Integer): TReplacePair;
-begin
-  Result := FPairs.Items[Index] as TReplacePair; 
-end;
-
-procedure TReplacePairs.SetPair(Index: Integer; const Value: TReplacePair);
-begin
-  FPairs.Items[Index].Assign(Value);
-end;
+{ TReplacePairCollection }
 
-procedure TReplacePairs.SetPairs(const Value: TReplacePairCollection);
+function TReplacePairCollection.Add: TReplacePair;
 begin
-  FPairs.Assign(Value);
+  Result := inherited Add as TReplacePair;
 end;
 
-{ TReplacePairCollection }
-
 function TReplacePairCollection.ExecuteReplace(TargetStr: string): string;
 var
   i: Integer;
@@ -364,6 +311,11 @@ begin
   end;
 end;
 
+function TReplacePairCollection.GetItem(Index: Integer): TReplacePair;
+begin
+  Result := (inherited GetItem(Index)) as TReplacePair;
+end;
+
 initialization
 
 Classes.RegisterClass(TReplacePresets);