6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus,
11 TKeySettingItem = class(TObject)
17 property Action: TAction read FAction write FAction;
18 property ShortCut: TShortCut read FShortCut write FShortCut;
19 property Gesture : string read FGesture write FGesture;
22 TKeySettingForm = class(TForm)
27 CancelBotton: TButton;
32 StatusBar: TStatusBar;
34 PageControl1: TPageControl;
41 GestureSetButton: TButton;
42 GestureCheckBox: TCheckBox;
43 procedure FormCreate(Sender: TObject);
44 procedure FormDestroy(Sender: TObject);
45 procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
47 procedure HotKeyEnter(Sender: TObject);
48 procedure HotKeyExit(Sender: TObject);
49 procedure FormKeyDown(Sender: TObject; var Key: Word;
51 procedure SetButtonClick(Sender: TObject);
52 procedure OkBottonClick(Sender: TObject);
53 procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem;
54 Data: Integer; var Compare: Integer);
55 procedure GestureSetButtonClick(Sender: TObject);
56 procedure OnGestureStart(Sender: TObject);
57 procedure OnGestureMove(Sender: TObject);
58 procedure OnGestureEnd(Sender: TObject);
59 procedure GestureCheckBoxClick(Sender: TObject);
60 procedure GestureEditChange(Sender: TObject);
61 procedure GestureEditKeyDown(Sender: TObject; var Key: Word;
67 EditorForm: TEditorForm;
71 // KeySettingForm: TKeySettingForm;
76 Giko, GikoUtil, Gesture, GikoDataModule, GikoSystem;
79 GUESTURE_NOTHING = '
\82È
\82µ';
83 procedure TKeySettingForm.FormCreate(Sender: TObject);
87 KeyItem: TKeySettingItem;
90 //for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
91 for i := 0 to GikoDM.GikoFormActionList.ActionCount - 1 do begin
92 //if GikoForm.ActionList.Actions[i] is TAction then begin
93 if GikoDM.GikoFormActionList.Actions[i] is TAction then begin
94 if GikoDM.GikoFormActionList.Actions[i].Tag <> 0 then
96 ListItem := ListView.Items.Add;
97 ListItem.Caption := TAction(GikoDM.GikoFormActionList.Actions[i]).Hint;
98 ListItem.SubItems.Add(TAction(GikoDM.GikoFormActionList.Actions[i]).Category);
99 ListItem.SubItems.Add(ShortCutToText(TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut));
100 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
101 TAction( GikoDM.GikoFormActionList.Actions[i] ) ) );
102 ListItem.ImageIndex := TAction(GikoDM.GikoFormActionList.Actions[i]).ImageIndex;
103 KeyItem := TKeySettingItem.Create;
104 KeyItem.Action := TAction(GikoDM.GikoFormActionList.Actions[i]);
105 KeyItem.ShortCut := TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut;
106 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
107 TAction( GikoDM.GikoFormActionList.Actions[i] ) );
108 ListItem.Data := KeyItem;
111 if ListView.Items.Count > 0 then
112 ListView.Selected := ListView.Items[0];
113 EditorForm := TEditorForm.Create(Self);
114 GikoSys.LoadKeySetting(EditorForm.ActionList, GikoSys.GetEditorKeyFileName);
116 for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin
117 if EditorForm.ActionList.Actions[i] is TAction then begin
118 if EditorForm.ActionList.Actions[i].Tag <> 0 then
120 ListItem := ListView1.Items.Add;
121 ListItem.Caption := TAction(EditorForm.ActionList.Actions[i]).Hint;
122 ListItem.SubItems.Add(TAction(EditorForm.ActionList.Actions[i]).Category);
123 ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut));
124 ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex;
125 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
126 TAction( EditorForm.ActionList.Actions[i] ) ) );
127 KeyItem := TKeySettingItem.Create;
128 KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]);
129 KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut;
130 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
131 TAction( EditorForm.ActionList.Actions[i] ) );
132 ListItem.Data := KeyItem;
135 ListView1.SmallImages := EditorForm.HotToobarImageList;
139 // ActionListView.SortType := stText;
140 StatusBar.Height := 21;
141 StatusBar.Width := 21;
142 PageControl1.ActivePageIndex := 0;
143 GestureCheckBox.Checked := GikoSys.Setting.GestureEnabled;
144 GestureCheckBoxClick( Sender );
147 MouseGesture.OnGestureStart := OnGestureStart;
148 MouseGesture.OnGestureMove := OnGestureMove;
149 MouseGesture.OnGestureEnd := OnGestureEnd;
150 MouseGesture.SetHook( Handle );
153 procedure TKeySettingForm.FormDestroy(Sender: TObject);
157 for i := 0 to ListView.Items.Count - 1 do begin
158 if TObject(ListView.Items[i].Data) is TKeySettingItem then
159 TKeySettingItem(ListView.Items[i].Data).Free;
161 for i := 0 to ListView1.Items.Count - 1 do begin
162 if TObject(ListView1.Items[i].Data) is TKeySettingItem then
163 TKeySettingItem(ListView1.Items[i].Data).Free;
168 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
169 Item: TListItem; Selected: Boolean);
171 KeyItem: TKeySettingItem;
173 if not Selected then Exit;
175 if TObject(Item.Data) is TKeySettingItem then begin
176 KeyItem := TKeySettingItem(Item.Data);
177 HotKey.HotKey := KeyItem.ShortCut;
178 GestureEdit.Text := KeyItem.Gesture;
182 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
184 OkBotton.Default := False;
185 CancelBotton.Cancel := False;
188 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
190 OkBotton.Default := True;
191 CancelBotton.Cancel := True;
194 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
197 if Key in [8, 27, 32, 46] then begin
198 HotKey.HotKey := ShortCut(Key, Shift);
203 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
205 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
206 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·';
207 ERR_TITLE = '
\83G
\83\89\81[';
211 KeyItem: TKeySettingItem;
212 ActiveListView: TListView;
214 if PageControl1.ActivePage.TabIndex <> 0 then
215 ActiveListView := ListView1
217 ActiveListView := ListView;
219 if ActiveListView.Selected = nil then Exit;
220 if HotKey.HotKey = 13 then begin
221 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
226 //
\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é
227 for i := 0 to ActiveListView.Items.Count - 1 do begin
228 if ActiveListView.Selected = ActiveListView.Items[i] then
230 Item := ActiveListView.Items[i];
231 if TObject(Item.Data) is TKeySettingItem then begin
232 KeyItem := TKeySettingItem(Item.Data);
233 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
234 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
240 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
241 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
242 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
243 KeyItem.ShortCut := HotKey.HotKey;
244 ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
248 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
252 KeyItem: TKeySettingItem;
255 GikoSys.Setting.GestureEnabled := GestureCheckBox.Checked;
256 GikoSys.Setting.Gestures.ClearGesture;
257 for i := 0 to ListView.Items.Count - 1 do begin
258 Item := ListView.Items[i];
259 if TObject(Item.Data) is TKeySettingItem then begin
260 KeyItem := TKeySettingItem(Item.Data);
261 KeyItem.Action.ShortCut := KeyItem.ShortCut;
262 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
265 for i := 0 to ListView1.Items.Count - 1 do begin
266 Item := ListView1.Items[i];
267 if TObject(Item.Data) is TKeySettingItem then begin
268 KeyItem := TKeySettingItem(Item.Data);
269 KeyItem.Action.ShortCut := KeyItem.ShortCut;
270 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
276 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
277 Item2: TListItem; Data: Integer; var Compare: Integer);
279 if Item1.SubItems[0] > Item2.SubItems[0] then
281 else if Item1.SubItems[0] < Item2.SubItems[0] then
287 procedure TKeySettingForm.GestureSetButtonClick(Sender: TObject);
289 ERR_MSG = '
\93ü
\97Í
\82µ
\82½
\83W
\83F
\83X
\83`
\83\83\81[
\82Í
\8aù
\82É
\8eg
\97p
\82³
\82ê
\82Ä
\82¢
\82Ü
\82·';
290 ERR_TITLE = '
\83G
\83\89\81[';
294 KeyItem: TKeySettingItem;
295 ActiveListView: TListView;
296 chechList : TListView;
298 if PageControl1.ActivePage.TabIndex <> 0 then
299 ActiveListView := ListView1
301 ActiveListView := ListView;
303 if ActiveListView.Selected = nil then Exit;
304 if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin
305 GestureEdit.Text := '';
306 Item := ActiveListView.Selected;
307 Item.SubItems[2] := '';
308 if TObject(Item.Data) is TKeySettingItem then begin
309 KeyItem := TKeySettingItem(Item.Data);
310 KeyItem.Gesture := '';
315 //
\8c»
\8dÝ
\91I
\91ð
\82³
\82ê
\82Ä
\82¢
\82éAction
\88È
\8aO
\82Å
\93¯
\82¶
\83W
\83F
\83X
\83`
\83\83\81[
\82ª
\82 \82ê
\82Î
\83G
\83\89\81[
\82Æ
\82·
\82é
316 chechList := ListView;
317 for j := 0 to 1 do begin
319 chechList := ListView1;
322 for i := 0 to chechList.Items.Count - 1 do begin
323 if ActiveListView.Selected = chechList.Items[i] then
325 Item := chechList.Items[i];
326 if TObject(Item.Data) is TKeySettingItem then begin
327 KeyItem := TKeySettingItem(Item.Data);
328 if (GestureEdit.Text <> GUESTURE_NOTHING)
329 and (KeyItem.Gesture = GestureEdit.Text) then begin
330 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
338 //
\83W
\83F
\83X
\83`
\83\83\81[
\90Ý
\92è
339 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
340 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
341 KeyItem.Gesture := GestureEdit.Text;
342 if GestureEdit.Text = GUESTURE_NOTHING then
343 ActiveListView.Selected.SubItems[2] := ''
345 ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
349 procedure TKeySettingForm.OnGestureStart(Sender: TObject);
351 GestureEdit.Text := '';
354 procedure TKeySettingForm.OnGestureMove(Sender: TObject);
356 GestureEdit.Text := MouseGesture.GetGestureStr;
359 procedure TKeySettingForm.OnGestureEnd(Sender: TObject);
361 GestureEdit.Text := MouseGesture.GetGestureStr;
364 procedure TKeySettingForm.GestureCheckBoxClick(Sender: TObject);
366 GestureEdit.Enabled := GestureCheckBox.Checked;
367 GestureSetButton.Enabled := GestureCheckBox.Checked;
370 procedure TKeySettingForm.GestureEditChange(Sender: TObject);
373 if GestureEdit.Text = '' then
374 GestureEdit.Text := GUESTURE_NOTHING;
378 procedure TKeySettingForm.GestureEditKeyDown(Sender: TObject;
379 var Key: Word; Shift: TShiftState);
381 if (ssShift in Shift) and (MouseGesture.GetGestureStr = '') then
382 GestureEdit.Text := '';