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 btnDuplicate: TButton;
19 procedure lstRulesMeasureItem(Control: TWinControl; Index: Integer;
21 procedure lstRulesDrawItem(Control: TWinControl; Index: Integer;
22 Rect: TRect; State: TOwnerDrawState);
23 procedure lstRulesClickCheck(Sender: TObject);
24 procedure EditRule(Sender: TObject);
25 procedure btnAddClick(Sender: TObject);
26 procedure btnDeleteClick(Sender: TObject);
27 procedure btnUpClick(Sender: TObject);
28 procedure btnDownClick(Sender: TObject);
29 procedure btnDuplicateClick(Sender: TObject);
31 function ExecuteEditRule(Rule: TBottleChainRule): boolean;
32 procedure UpdateCheckBox;
33 procedure UpdateHeight;
35 procedure UpdateDisplay;
42 procedure TfrmBottleChainList.lstRulesMeasureItem(Control: TWinControl; Index: Integer;
47 ARect := lstRules.ItemRect(Index);
48 ARect.Left := ARect.Left + 2;
49 ARect.Right := ARect.Right - 2;
51 Str := BottleChainRuleList[Index].StringExpression;
53 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
54 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
55 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
56 Height := ARect.Bottom - ARect.Top;
59 ARect.Left := ARect.Left + 5;
60 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
61 Str := BottleChainRuleList[Index].Title;
62 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
63 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
64 Height := Height + ARect.Bottom - ARect.Top;
68 procedure TfrmBottleChainList.lstRulesDrawItem(Control: TWinControl; Index: Integer;
69 Rect: TRect; State: TOwnerDrawState);
73 lstRules.Canvas.FillRect(Rect);
75 //
\83e
\83L
\83X
\83g
\95`
\89æ
\97Ì
\88æ
\82Ì
\83}
\81[
\83W
\83\93\82ð
\8eæ
\82é
76 Rect.Left := Rect.Left + 2;
77 Rect.Top := Rect.Top + 2;
78 Rect.Right := Rect.Right - 2;
79 Rect.Bottom := Rect.Bottom - 2;
81 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
82 Str := BottleChainRuleList[Index].Title;
83 y := DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
84 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
85 Str := BottleChainRuleList[Index].StringExpression;
86 Rect.Top := Rect.Top + y;
87 Rect.Left := Rect.Left + 5;
88 DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
91 procedure TfrmBottleChainList.UpdateDisplay;
93 sel: TBottleChainRule;
95 i := lstRules.ItemIndex;
97 if i <= BottleChainRuleList.Count-1 then
98 sel := BottleChainRuleList[i]
99 else if BottleChainRuleList.Count > 0 then
100 sel := BottleChainRuleList[BottleChainRuleList.Count-1]
105 lstRules.Items.BeginUpdate;
106 lstRules.Items.Clear;
107 for i := 0 to BottleChainRuleList.Count-1 do begin
108 lstRules.Items.Add(BottleChainRuleList.Rules[i].StringExpression);
109 lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
111 lstRules.Items.EndUpdate;
112 lstRules.ItemIndex := BottleChainRuleList.List.IndexOf(sel);
115 procedure TfrmBottleChainList.lstRulesClickCheck(Sender: TObject);
118 for i := 0 to BottleChainRuleList.Count-1 do begin
119 BottleChainRuleList[i].Enabled := lstRules.Checked[i];
123 procedure TfrmBottleChainList.EditRule(Sender: TObject);
125 Edit: TBottleChainRule;
127 if lstRules.ItemIndex <> -1 then
129 Edit := TBottleChainRule.Create(nil);
131 Edit.Assign(BottleChainRuleList[lstRules.ItemIndex]);
132 if ExecuteEditRule(Edit) then
133 BottleChainRuleList[lstRules.ItemIndex].Assign(Edit);
141 procedure TfrmBottleChainList.btnAddClick(Sender: TObject);
143 New: TBottleChainRule;
145 New := TBottleChainRule.Create(BottleChainRuleList);
148 if ExecuteEditRule(New) then
150 New.RuleList := BottleChainRuleList; //
\8e©
\95ª
\82ð
\83\8a\83X
\83g
\82É
\92Ç
\89Á
\82·
\82é
160 procedure TfrmBottleChainList.btnDeleteClick(Sender: TObject);
162 Del: TBottleChainRule;
165 Index := lstRules.ItemIndex;
168 Del := BottleChainRuleList[Index];
170 lstRules.Items.Delete(Index);
173 procedure TfrmBottleChainList.btnUpClick(Sender: TObject);
176 i := lstRules.ItemIndex;
178 BottleChainRuleList.List.Move(i, i - 1);
179 lstRules.Items.Move(i, i-1);
180 lstRules.ItemIndex := i - 1;
185 procedure TfrmBottleChainList.btnDownClick(Sender: TObject);
188 i := lstRules.ItemIndex;
189 if (i >= 0) and (i < lstRules.Items.Count-1) then begin
190 BottleChainRuleList.List.Move(i, i + 1);
191 lstRules.Items.Move(i, i+1);
192 lstRules.ItemIndex := i + 1;
197 function TfrmBottleChainList.ExecuteEditRule(Rule: TBottleChainRule): boolean;
198 var MyfrmBottleChainRuleEditor: TfrmBottleChainRuleEditor;
200 Application.CreateForm(TfrmBottleChainRuleEditor, MyfrmBottleChainRuleEditor);
201 with MyfrmBottleChainRuleEditor do begin
203 Result := Execute(Rule);
210 procedure TfrmBottleChainList.btnDuplicateClick(Sender: TObject);
212 New: TBottleChainRule;
214 if lstRules.ItemIndex <> -1 then
216 New := TBottleChainRule.Create(BottleChainRuleList);
217 New.Assign(BottleChainRuleList.Rules[lstRules.ItemIndex]);
218 New.RuleList := BottleChainRuleList; //
\82±
\82ê
\82Å
\83\8b\81[
\83\8b\83\8a\83X
\83g
\82É
\82Í
\92Ç
\89Á
\82³
\82ê
\82é
219 lstRules.Items.Insert(lstRules.ItemIndex + 1, New.StringExpression);
225 procedure TfrmBottleChainList.UpdateCheckBox;
229 for i := 0 to BottleChainRuleList.Count-1 do
230 lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
233 procedure TfrmBottleChainList.UpdateHeight;
237 Style := lbOwnerDrawFixed;
238 Style := lbOwnerDrawVariable;