1 unit BottleChainListFrame;
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, BottleChainEvent, BottleChainRule, StdCtrls, CheckLst,
11 TfrmBottleChainList = class(TFrame)
12 lstRules: TCheckListBox;
16 procedure lstRulesMeasureItem(Control: TWinControl; Index: Integer;
18 procedure lstRulesDrawItem(Control: TWinControl; Index: Integer;
19 Rect: TRect; State: TOwnerDrawState);
20 procedure Button1Click(Sender: TObject);
21 procedure lstRulesClickCheck(Sender: TObject);
22 procedure EditRule(Sender: TObject);
23 procedure btnAddClick(Sender: TObject);
24 procedure btnDeleteClick(Sender: TObject);
29 procedure UpdateDisplay;
36 procedure TfrmBottleChainList.lstRulesMeasureItem(Control: TWinControl; Index: Integer;
41 ARect := lstRules.ItemRect(Index);
42 Str := BottleChainRuleList[Index].StringExpression;
44 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
45 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
46 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
47 Height := ARect.Bottom - ARect.Top;
49 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
50 Str := BottleChainRuleList[Index].Title;
51 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
52 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
53 Height := Height + ARect.Bottom - ARect.Top;
57 procedure TfrmBottleChainList.lstRulesDrawItem(Control: TWinControl; Index: Integer;
58 Rect: TRect; State: TOwnerDrawState);
62 lstRules.Canvas.FillRect(Rect);
64 //
\83e
\83L
\83X
\83g
\95`
\89æ
\97Ì
\88æ
\82Ì
\83}
\81[
\83W
\83\93\82ð
\8eæ
\82é
65 Rect.Left := Rect.Left + 2;
66 Rect.Top := Rect.Top + 2;
67 Rect.Right := Rect.Right - 2;
68 Rect.Bottom := Rect.Bottom - 2;
70 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
71 Str := BottleChainRuleList[Index].Title;
72 y := DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_EDITCONTROL or DT_WORDBREAK);
73 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
74 Str := BottleChainRuleList[Index].StringExpression;
75 Rect.Top := Rect.Top + y;
76 DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_EDITCONTROL or DT_WORDBREAK);
79 procedure TfrmBottleChainList.Button1Click(Sender: TObject);
80 var instance: TBottleChainRuleList;
81 rule: TBottleChainRule;
82 condition: TBottleChainCondition;
85 instance := TBottleChainRuleList.Create(nil);
87 rule := TBottleChainRule.Create(instance);
88 rule.RuleList := instance;
89 condition := TBottleChainChannelCondition.Create(rule);
90 (condition as TBottleChainChannelCondition).Channels.Add('
\8fd
\97v');
91 (condition as TBottleChainChannelCondition).Channels.Add('Important');
92 Condition.Rule := rule;
93 str := ComponentToString(instance);
98 instance := StringToComponent(str) as TBottleChainRuleList;
99 ShowMessage(ComponentToString(instance));
102 procedure TfrmBottleChainList.UpdateDisplay;
105 lstRules.Items.Clear;
106 for i := 0 to BottleChainRuleList.Count-1 do begin
107 lstRules.Items.Add(BottleChainRuleList.Rules[i].StringExpression);
108 lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
112 procedure TfrmBottleChainList.lstRulesClickCheck(Sender: TObject);
115 for i := 0 to BottleChainRuleList.Count-1 do begin
116 BottleChainRuleList[i].Enabled := lstRules.Checked[i];
120 procedure TfrmBottleChainList.EditRule(Sender: TObject);
122 if lstRules.ItemIndex <> -1 then begin
123 frmBottleChainRuleEditor.Execute(BottleChainRuleList[lstRules.ItemIndex]);
128 procedure TfrmBottleChainList.btnAddClick(Sender: TObject);
129 var New: TBottleChainRule;
131 New := TBottleChainRule.Create(BottleChainRuleList);
132 New.RuleList := BottleChainRuleList; //
\8e©
\95ª
\82ð
\83\8a\83X
\83g
\82É
\92Ç
\89Á
\82·
\82é
133 frmBottleChainRuleEditor.Execute(New);
137 procedure TfrmBottleChainList.btnDeleteClick(Sender: TObject);
138 var Del: TBottleChainRule;
140 if lstRules.ItemIndex < 0 then Exit;
141 Del := BottleChainRuleList[lstRules.ItemIndex];