6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil,
11 TKeySettingItem = class(TObject)
16 property Action: TAction read FAction write FAction;
17 property ShortCut: TShortCut read FShortCut write FShortCut;
20 TKeySettingForm = class(TForm)
25 CancelBotton: TButton;
30 StatusBar: TStatusBar;
32 PageControl1: TPageControl;
37 procedure FormCreate(Sender: TObject);
38 procedure FormDestroy(Sender: TObject);
39 procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
41 procedure HotKeyEnter(Sender: TObject);
42 procedure HotKeyExit(Sender: TObject);
43 procedure FormKeyDown(Sender: TObject; var Key: Word;
45 procedure SetButtonClick(Sender: TObject);
46 procedure OkBottonClick(Sender: TObject);
47 procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem;
48 Data: Integer; var Compare: Integer);
53 EditorForm: TEditorForm;
57 // KeySettingForm: TKeySettingForm;
65 procedure TKeySettingForm.FormCreate(Sender: TObject);
69 KeyItem: TKeySettingItem;
72 for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
73 if GikoForm.ActionList.Actions[i] is TAction then begin
74 if GikoForm.ActionList.Actions[i].Tag <> 0 then
76 ListItem := ListView.Items.Add;
77 ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint;
78 ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category);
79 ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut));
80 ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex;
81 KeyItem := TKeySettingItem.Create;
82 KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]);
83 KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut;
84 ListItem.Data := KeyItem;
87 if ListView.Items.Count > 0 then
88 ListView.Selected := ListView.Items[0];
89 EditorForm := TEditorForm.Create(Self);
90 GikoSys.LoadEditorKeySetting(EditorForm.ActionList);
92 for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin
93 if EditorForm.ActionList.Actions[i] is TAction then begin
94 if EditorForm.ActionList.Actions[i].Tag <> 0 then
96 ListItem := ListView1.Items.Add;
97 ListItem.Caption := TAction(EditorForm.ActionList.Actions[i]).Hint;
98 ListItem.SubItems.Add(TAction(EditorForm.ActionList.Actions[i]).Category);
99 ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut));
100 ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex;
101 KeyItem := TKeySettingItem.Create;
102 KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]);
103 KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut;
104 ListItem.Data := KeyItem;
107 ListView1.SmallImages := EditorForm.HotToobarImageList;
111 // ActionListView.SortType := stText;
112 StatusBar.Height := 21;
113 StatusBar.Width := 21;
114 PageControl1.ActivePageIndex := 0;
117 procedure TKeySettingForm.FormDestroy(Sender: TObject);
121 for i := 0 to ListView.Items.Count - 1 do begin
122 if TObject(ListView.Items[i].Data) is TKeySettingItem then
123 TKeySettingItem(ListView.Items[i].Data).Free;
125 for i := 0 to ListView1.Items.Count - 1 do begin
126 if TObject(ListView1.Items[i].Data) is TKeySettingItem then
127 TKeySettingItem(ListView1.Items[i].Data).Free;
132 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
133 Item: TListItem; Selected: Boolean);
135 KeyItem: TKeySettingItem;
137 if not Selected then Exit;
139 if TObject(Item.Data) is TKeySettingItem then begin
140 KeyItem := TKeySettingItem(Item.Data);
141 HotKey.HotKey := KeyItem.ShortCut;
145 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
147 OkBotton.Default := False;
148 CancelBotton.Cancel := False;
151 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
153 OkBotton.Default := True;
154 CancelBotton.Cancel := True;
157 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
160 if Key in [8, 27, 32, 46] then begin
161 HotKey.HotKey := ShortCut(Key, Shift);
166 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
168 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
169 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·';
170 ERR_TITLE = '
\83G
\83\89\81[';
174 KeyItem: TKeySettingItem;
175 ActiveListView: TListView;
177 if PageControl1.ActivePage.TabIndex <> 0 then
178 ActiveListView := ListView1
180 ActiveListView := ListView;
182 if ActiveListView.Selected = nil then Exit;
183 if HotKey.HotKey = 13 then begin
184 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
189 //
\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é
190 for i := 0 to ActiveListView.Items.Count - 1 do begin
191 if ActiveListView.Selected = ActiveListView.Items[i] then
193 Item := ActiveListView.Items[i];
194 if TObject(Item.Data) is TKeySettingItem then begin
195 KeyItem := TKeySettingItem(Item.Data);
196 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
197 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
203 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
204 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
205 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
206 KeyItem.ShortCut := HotKey.HotKey;
207 ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
211 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
215 KeyItem: TKeySettingItem;
217 for i := 0 to ListView.Items.Count - 1 do begin
218 Item := ListView.Items[i];
219 if TObject(Item.Data) is TKeySettingItem then begin
220 KeyItem := TKeySettingItem(Item.Data);
221 KeyItem.Action.ShortCut := KeyItem.ShortCut;
224 for i := 0 to ListView1.Items.Count - 1 do begin
225 Item := ListView1.Items[i];
226 if TObject(Item.Data) is TKeySettingItem then begin
227 KeyItem := TKeySettingItem(Item.Data);
228 KeyItem.Action.ShortCut := KeyItem.ShortCut;
234 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
235 Item2: TListItem; Data: Integer; var Compare: Integer);
237 if Item1.SubItems[0] > Item2.SubItems[0] then
239 else if Item1.SubItems[0] < Item2.SubItems[0] then