OSDN Git Service

File save and load implemented
authornaru <bottle@mikage.to>
Wed, 1 Jan 2003 18:20:18 +0000 (18:20 +0000)
committernaru <bottle@mikage.to>
Wed, 1 Jan 2003 18:20:18 +0000 (18:20 +0000)
bottleclient/BottleChainListFrame.dfm
bottleclient/BottleChainListFrame.pas
bottleclient/BottleChainRule.pas
bottleclient/BottleChainRuleEditor.dfm
bottleclient/BottleChainRuleEditor.pas

index e4eed69..91b9296 100755 (executable)
@@ -11,11 +11,9 @@ object frmBottleChainList: TfrmBottleChainList
     Top = 0
     Width = 193
     Height = 240
+    OnClickCheck = lstRulesClickCheck
     Align = alLeft
     ItemHeight = 16
-    Items.Strings = (
-      'hoge'
-      'nyo')
     Style = lbOwnerDrawVariable
     TabOrder = 0
     OnDrawItem = lstRulesDrawItem
index 05b5256..9d7d033 100755 (executable)
@@ -17,10 +17,12 @@ type
     procedure lstRulesDrawItem(Control: TWinControl; Index: Integer;
       Rect: TRect; State: TOwnerDrawState);
     procedure Button1Click(Sender: TObject);
+    procedure lstRulesClickCheck(Sender: TObject);
   private
     { Private \90é\8c¾ }
   public
     { Public \90é\8c¾ }
+    procedure UpdateDisplay;
   end;
 
 implementation
@@ -32,19 +34,41 @@ procedure TfrmBottleChainList.lstRulesMeasureItem(Control: TWinControl; Index: I
 var Str: String;
     ARect: TRect;
 begin
-  ARect := Rect(0, 0, lstRules.Width, lstRules.Height);
-  Str := lstRules.Items[Index];
+  ARect := lstRules.ItemRect(Index);
+  Str := BottleChainRuleList[Index].StringExpression;
+  //
+  lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
   DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
     ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
   Height := ARect.Bottom - ARect.Top;
+  //
+  lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
+  Str := BottleChainRuleList[Index].Title;
+  DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
+    ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
+  Height := Height + ARect.Bottom - ARect.Top;
+  Height := Height + 4;
 end;
 
 procedure TfrmBottleChainList.lstRulesDrawItem(Control: TWinControl; Index: Integer;
   Rect: TRect; State: TOwnerDrawState);
 var Str: String;
+    y: integer;
 begin
   lstRules.Canvas.FillRect(Rect);
-  Str := lstRules.Items[Index];
+
+  // \83e\83L\83X\83g\95`\89æ\97Ì\88æ\82Ì\83}\81[\83W\83\93\82ð\8eæ\82é
+  Rect.Left := Rect.Left + 2;
+  Rect.Top := Rect.Top + 2;
+  Rect.Right := Rect.Right - 2;
+  Rect.Bottom := Rect.Bottom - 2;
+
+  lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
+  Str := BottleChainRuleList[Index].Title;
+  y := DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_EDITCONTROL or DT_WORDBREAK);
+  lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
+  Str := BottleChainRuleList[Index].StringExpression;
+  Rect.Top := Rect.Top + y;
   DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_EDITCONTROL or DT_WORDBREAK);
 end;
 
@@ -71,4 +95,22 @@ begin
   ShowMessage(ComponentToString(instance));
 end;
 
+procedure TfrmBottleChainList.UpdateDisplay;
+var i: integer;
+begin
+  lstRules.Items.Clear;
+  for i := 0 to BottleChainRuleList.Count-1 do begin
+    lstRules.Items.Add(BottleChainRuleList.Rules[i].StringExpression);
+    lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
+  end;
+end;
+
+procedure TfrmBottleChainList.lstRulesClickCheck(Sender: TObject);
+var i: integer;
+begin
+  for i := 0 to BottleChainRuleList.Count-1 do begin
+    BottleChainRuleList[i].Enabled := lstRules.Checked[i];
+  end;
+end;
+
 end.
index 56d9761..d77eb02 100755 (executable)
@@ -25,6 +25,7 @@ type
     function GetParentComponent: TComponent; override;
     class function Editable: boolean; virtual;
     function Edit: boolean; virtual; abstract;
+    function StringExpression: String; virtual; abstract;
     property Rule: TBottleChainRule read FRule write SetRule;
   end;
 
@@ -55,9 +56,13 @@ type
     FConditions: TObjectList;
     FActions: TObjectList;
     FRuleList: TBottleChainRuleList;
+    FEnabled: boolean;
+    FTitle: String;
     procedure SetActions(const Value: TObjectList);
     procedure SetConditions(const Value: TObjectList);
     procedure SetRuleList(const Value: TBottleChainRuleList);
+    procedure SetEnabled(const Value: boolean);
+    procedure SetTitle(const Value: String);
   protected
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
     procedure SetParentComonent(AParent: TComponent);
@@ -75,6 +80,9 @@ type
     property Conditions: TObjectList read FConditions write SetConditions;
     property Actions: TObjectList read FActions write SetActions;
     property RuleList: TBottleChainRuleList read FRuleList write SetRuleList;
+  published
+    property Enabled: boolean read FEnabled write SetEnabled;
+    property Title: String read FTitle write SetTitle;
   end;
 
   // \83\8b\81[\83\8b\82Ì\83\8a\83X\83g
@@ -92,7 +100,7 @@ type
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     property Count: integer read GetCount;
-    property Rules[Index: integer]: TBottleChainRule read GetRules;
+    property Rules[Index: integer]: TBottleChainRule read GetRules; default;
   end;
 
   {\82±\82±\82©\82ç\8cÂ\95Ê}
@@ -121,6 +129,8 @@ const
     TBottleChainChannelCondition
   );
 
+var BottleChainRuleList: TBottleChainRuleList;
+
 function ComponentToString(Component: TComponent): string;
 function StringToComponent(Value: string): TComponent;
 
@@ -299,7 +309,7 @@ begin
   chs := '';
   for i := 0 to FChannels.Count-1 do begin
     if i > 0 then chs := chs + ' \82© ';
-    chs := chs + FChannels[i];
+    chs := Format('%s\81u%s\81v', [chs, FChannels[i]]);
   end;
   Result := Format('\8eó\90M\83`\83\83\83\93\83l\83\8b\82ª %s \82Ì\82Æ\82«', [chs]);
 end;
@@ -408,6 +418,24 @@ begin
     if i > 0 then Result := Result + '\81A\82³\82ç\82É';
     Result := Result + (FConditions[i] as TBottleChainCondition).StringExpression;
   end;
+  if FActions.Count = 0 then begin
+    Result := Result + '\89½\82à\82µ\82È\82¢';
+  end else begin
+    for i := 0 to FActions.Count-1 do begin
+      if i > 0 then Result := Result + '\81A\82³\82ç\82É';
+      Result := Result + (FActions[i] as TBottleChainAction).StringExpression;
+    end;
+  end;
+end;
+
+procedure TBottleChainRule.SetEnabled(const Value: boolean);
+begin
+  FEnabled := Value;
+end;
+
+procedure TBottleChainRule.SetTitle(const Value: String);
+begin
+  FTitle := Value;
 end;
 
 { TBottleChainRuleList }
index 1233ec9..110d37d 100755 (executable)
@@ -2,7 +2,7 @@ object frmBottleChainListEditor: TfrmBottleChainListEditor
   Left = 544
   Top = 401
   Width = 415
-  Height = 312
+  Height = 315
   Caption = #12452#12505#12531#12488#35373#23450
   Color = clBtnFace
   Font.Charset = SHIFTJIS_CHARSET
@@ -13,12 +13,65 @@ object frmBottleChainListEditor: TfrmBottleChainListEditor
   OldCreateOrder = False
   PixelsPerInch = 96
   TextHeight = 12
-  object CheckListBox1: TCheckListBox
-    Left = 168
+  object PageControl1: TPageControl
+    Left = 16
     Top = 16
-    Width = 217
-    Height = 161
-    ItemHeight = 12
+    Width = 369
+    Height = 177
+    ActivePage = tstGeneral
     TabOrder = 0
+    object tstGeneral: TTabSheet
+      Caption = #19968#33324
+      object Label1: TLabel
+        Left = 24
+        Top = 56
+        Width = 87
+        Height = 12
+        Caption = #12523#12540#12523#12398#12479#12452#12488#12523
+      end
+      object cbxRuleEnabled: TCheckBox
+        Left = 24
+        Top = 16
+        Width = 225
+        Height = 17
+        Caption = #12371#12398#12523#12540#12523#12434#26377#21177#12395#12377#12427
+        TabOrder = 0
+      end
+      object Edit1: TEdit
+        Left = 120
+        Top = 56
+        Width = 217
+        Height = 20
+        TabOrder = 1
+      end
+    end
+    object tstCondition: TTabSheet
+      Caption = #26465#20214
+      ImageIndex = 1
+    end
+    object tstAction: TTabSheet
+      Caption = #12450#12463#12471#12519#12531
+      ImageIndex = 2
+    end
+  end
+  object btnClose: TButton
+    Left = 312
+    Top = 256
+    Width = 75
+    Height = 25
+    Caption = #38281#12376#12427'(&C)'
+    Default = True
+    TabOrder = 1
+  end
+  object memStringExpression: TMemo
+    Left = 16
+    Top = 200
+    Width = 369
+    Height = 49
+    Lines.Strings = (
+      'memStringExpression')
+    ParentColor = True
+    ReadOnly = True
+    TabOrder = 2
   end
 end
index 298cbc9..7c1fad3 100755 (executable)
@@ -4,11 +4,19 @@ interface
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, CheckLst;
+  Dialogs, StdCtrls, CheckLst, ComCtrls;
 
 type
   TfrmBottleChainListEditor = class(TForm)
-    CheckListBox1: TCheckListBox;
+    PageControl1: TPageControl;
+    tstGeneral: TTabSheet;
+    tstCondition: TTabSheet;
+    tstAction: TTabSheet;
+    cbxRuleEnabled: TCheckBox;
+    Label1: TLabel;
+    Edit1: TEdit;
+    btnClose: TButton;
+    memStringExpression: TMemo;
   private
     { Private \90é\8c¾ }
   public