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;
18 procedure lstRulesMeasureItem(Control: TWinControl; Index: Integer;
20 procedure lstRulesDrawItem(Control: TWinControl; Index: Integer;
21 Rect: TRect; State: TOwnerDrawState);
22 procedure lstRulesClickCheck(Sender: TObject);
23 procedure EditRule(Sender: TObject);
24 procedure btnAddClick(Sender: TObject);
25 procedure btnDeleteClick(Sender: TObject);
26 procedure btnUpClick(Sender: TObject);
27 procedure btnDownClick(Sender: TObject);
30 procedure ExecuteEditRule(Rule: TBottleChainRule);
33 procedure UpdateDisplay;
40 procedure TfrmBottleChainList.lstRulesMeasureItem(Control: TWinControl; Index: Integer;
45 ARect := lstRules.ItemRect(Index);
46 ARect.Left := ARect.Left + 2;
47 ARect.Right := ARect.Right - 2;
49 Str := BottleChainRuleList[Index].StringExpression;
51 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
52 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
53 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
54 Height := ARect.Bottom - ARect.Top;
57 ARect.Left := ARect.Left + 5;
58 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
59 Str := BottleChainRuleList[Index].Title;
60 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
61 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
62 Height := Height + ARect.Bottom - ARect.Top;
66 procedure TfrmBottleChainList.lstRulesDrawItem(Control: TWinControl; Index: Integer;
67 Rect: TRect; State: TOwnerDrawState);
71 lstRules.Canvas.FillRect(Rect);
73 //
\83e
\83L
\83X
\83g
\95`
\89æ
\97Ì
\88æ
\82Ì
\83}
\81[
\83W
\83\93\82ð
\8eæ
\82é
74 Rect.Left := Rect.Left + 2;
75 Rect.Top := Rect.Top + 2;
76 Rect.Right := Rect.Right - 2;
77 Rect.Bottom := Rect.Bottom - 2;
79 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
80 Str := BottleChainRuleList[Index].Title;
81 y := DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
82 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
83 Str := BottleChainRuleList[Index].StringExpression;
84 Rect.Top := Rect.Top + y;
85 Rect.Left := Rect.Left + 5;
86 DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
89 procedure TfrmBottleChainList.UpdateDisplay;
91 sel: TBottleChainRule;
93 i := lstRules.ItemIndex;
95 if i <= BottleChainRuleList.Count-1 then
96 sel := BottleChainRuleList[i]
97 else if BottleChainRuleList.Count > 0 then
98 sel := BottleChainRuleList[BottleChainRuleList.Count-1]
103 lstRules.Items.BeginUpdate;
104 lstRules.Items.Clear;
105 for i := 0 to BottleChainRuleList.Count-1 do begin
106 lstRules.Items.Add(BottleChainRuleList.Rules[i].StringExpression);
107 lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
109 lstRules.Items.EndUpdate;
110 lstRules.ItemIndex := BottleChainRuleList.List.IndexOf(sel);
113 procedure TfrmBottleChainList.lstRulesClickCheck(Sender: TObject);
116 for i := 0 to BottleChainRuleList.Count-1 do begin
117 BottleChainRuleList[i].Enabled := lstRules.Checked[i];
121 procedure TfrmBottleChainList.EditRule(Sender: TObject);
123 if lstRules.ItemIndex <> -1 then begin
124 ExecuteEditRule(BottleChainRuleList[lstRules.ItemIndex]);
129 procedure TfrmBottleChainList.btnAddClick(Sender: TObject);
130 var New: TBottleChainRule;
132 New := TBottleChainRule.Create(BottleChainRuleList);
133 New.RuleList := BottleChainRuleList; //
\8e©
\95ª
\82ð
\83\8a\83X
\83g
\82É
\92Ç
\89Á
\82·
\82é
135 ExecuteEditRule(New);
139 procedure TfrmBottleChainList.btnDeleteClick(Sender: TObject);
140 var Del: TBottleChainRule;
142 if lstRules.ItemIndex < 0 then Exit;
143 Del := BottleChainRuleList[lstRules.ItemIndex];
148 procedure TfrmBottleChainList.btnUpClick(Sender: TObject);
151 i := lstRules.ItemIndex;
153 BottleChainRuleList.List.Move(i, i - 1);
154 lstRules.ItemIndex := i - 1;
159 procedure TfrmBottleChainList.btnDownClick(Sender: TObject);
162 i := lstRules.ItemIndex;
163 if (i >= 0) and (i < lstRules.Items.Count-1) then begin
164 BottleChainRuleList.List.Move(i, i + 1);
165 lstRules.ItemIndex := i + 1;
170 procedure TfrmBottleChainList.ExecuteEditRule(Rule: TBottleChainRule);
171 var MyfrmBottleChainRuleEditor: TfrmBottleChainRuleEditor;
173 Application.CreateForm(TfrmBottleChainRuleEditor, MyfrmBottleChainRuleEditor);
174 with MyfrmBottleChainRuleEditor do begin