6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil;
10 TKeySettingItem = class(TObject)
15 property Action: TAction read FAction write FAction;
16 property ShortCut: TShortCut read FShortCut write FShortCut;
19 TKeySettingForm = class(TForm)
24 CancelBotton: TButton;
29 StatusBar: TStatusBar;
31 PageControl1: TPageControl;
36 procedure FormCreate(Sender: TObject);
37 procedure FormDestroy(Sender: TObject);
38 procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
40 procedure HotKeyEnter(Sender: TObject);
41 procedure HotKeyExit(Sender: TObject);
42 procedure FormKeyDown(Sender: TObject; var Key: Word;
44 procedure SetButtonClick(Sender: TObject);
45 procedure OkBottonClick(Sender: TObject);
46 procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem;
47 Data: Integer; var Compare: Integer);
55 // KeySettingForm: TKeySettingForm;
63 procedure TKeySettingForm.FormCreate(Sender: TObject);
67 KeyItem: TKeySettingItem;
69 for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
70 if GikoForm.ActionList.Actions[i] is TAction then begin
71 if GikoForm.ActionList.Actions[i].Tag <> 0 then
73 ListItem := ListView.Items.Add;
74 ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint;
75 ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category);
76 ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut));
77 ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex;
78 KeyItem := TKeySettingItem.Create;
79 KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]);
80 KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut;
81 ListItem.Data := KeyItem;
84 if ListView.Items.Count > 0 then
85 ListView.Selected := ListView.Items[0];
86 // ActionListView.SortType := stText;
87 StatusBar.Height := 21;
88 StatusBar.Width := 21;
91 procedure TKeySettingForm.FormDestroy(Sender: TObject);
95 for i := 0 to ListView.Items.Count - 1 do begin
96 if TObject(ListView.Items[i].Data) is TKeySettingItem then
97 TKeySettingItem(ListView.Items[i].Data).Free;
101 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
102 Item: TListItem; Selected: Boolean);
104 KeyItem: TKeySettingItem;
106 if not Selected then Exit;
108 if TObject(Item.Data) is TKeySettingItem then begin
109 KeyItem := TKeySettingItem(Item.Data);
110 HotKey.HotKey := KeyItem.ShortCut;
114 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
116 OkBotton.Default := False;
117 CancelBotton.Cancel := False;
120 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
122 OkBotton.Default := True;
123 CancelBotton.Cancel := True;
126 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
129 if Key in [8, 27, 32, 46] then begin
130 HotKey.HotKey := ShortCut(Key, Shift);
135 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
137 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
138 ERR_MSG = '
\93ü
\97Í
\82µ
\82½
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Í
\8aù
\82É
\8eg
\97p
\82³
\82ê
\82Ä
\82¢
\82Ü
\82·';
139 ERR_TITLE = '
\83G
\83\89\81[';
143 KeyItem: TKeySettingItem;
145 if ListView.Selected = nil then Exit;
146 if HotKey.HotKey = 13 then begin
147 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
152 //
\8c»
\8dÝ
\91I
\91ð
\82³
\82ê
\82Ä
\82¢
\82éAction
\88È
\8aO
\82Å
\93¯
\82¶
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82ª
\82 \82ê
\82Î
\83G
\83\89\81[
\82Æ
\82·
\82é
153 for i := 0 to ListView.Items.Count - 1 do begin
154 if ListView.Selected = ListView.Items[i] then
156 Item := ListView.Items[i];
157 if TObject(Item.Data) is TKeySettingItem then begin
158 KeyItem := TKeySettingItem(Item.Data);
159 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
160 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
166 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
167 if TObject(ListView.Selected.Data) is TKeySettingItem then begin
168 KeyItem := TKeySettingItem(ListView.Selected.Data);
169 KeyItem.ShortCut := HotKey.HotKey;
170 ListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
174 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
178 KeyItem: TKeySettingItem;
180 for i := 0 to ListView.Items.Count - 1 do begin
181 Item := ListView.Items[i];
182 if TObject(Item.Data) is TKeySettingItem then begin
183 KeyItem := TKeySettingItem(Item.Data);
184 KeyItem.Action.ShortCut := KeyItem.ShortCut;
189 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
190 Item2: TListItem; Data: Integer; var Compare: Integer);
192 if Item1.SubItems[0] > Item2.SubItems[0] then
194 else if Item1.SubItems[0] < Item2.SubItems[0] then