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);
115 for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin
116 if EditorForm.ActionList.Actions[i] is TAction then begin
117 if EditorForm.ActionList.Actions[i].Tag <> 0 then
119 ListItem := ListView1.Items.Add;
120 ListItem.Caption := TAction(EditorForm.ActionList.Actions[i]).Hint;
121 ListItem.SubItems.Add(TAction(EditorForm.ActionList.Actions[i]).Category);
122 ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut));
123 ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex;
124 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
125 TAction( EditorForm.ActionList.Actions[i] ) ) );
126 KeyItem := TKeySettingItem.Create;
127 KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]);
128 KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut;
129 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
130 TAction( EditorForm.ActionList.Actions[i] ) );
131 ListItem.Data := KeyItem;
134 ListView1.SmallImages := EditorForm.HotToobarImageList;
138 // ActionListView.SortType := stText;
139 StatusBar.Height := 21;
140 StatusBar.Width := 21;
141 PageControl1.ActivePageIndex := 0;
142 GestureCheckBox.Checked := GikoSys.Setting.GestureEnabled;
143 GestureCheckBoxClick( Sender );
146 MouseGesture.OnGestureStart := OnGestureStart;
147 MouseGesture.OnGestureMove := OnGestureMove;
148 MouseGesture.OnGestureEnd := OnGestureEnd;
149 MouseGesture.SetHook( Handle );
152 procedure TKeySettingForm.FormDestroy(Sender: TObject);
156 for i := 0 to ListView.Items.Count - 1 do begin
157 if TObject(ListView.Items[i].Data) is TKeySettingItem then
158 TKeySettingItem(ListView.Items[i].Data).Free;
160 for i := 0 to ListView1.Items.Count - 1 do begin
161 if TObject(ListView1.Items[i].Data) is TKeySettingItem then
162 TKeySettingItem(ListView1.Items[i].Data).Free;
167 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
168 Item: TListItem; Selected: Boolean);
170 KeyItem: TKeySettingItem;
172 if not Selected then Exit;
174 if TObject(Item.Data) is TKeySettingItem then begin
175 KeyItem := TKeySettingItem(Item.Data);
176 HotKey.HotKey := KeyItem.ShortCut;
177 GestureEdit.Text := KeyItem.Gesture;
181 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
183 OkBotton.Default := False;
184 CancelBotton.Cancel := False;
187 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
189 OkBotton.Default := True;
190 CancelBotton.Cancel := True;
193 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
196 if Key in [8, 27, 32, 46] then begin
197 HotKey.HotKey := ShortCut(Key, Shift);
202 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
204 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
205 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·';
206 ERR_TITLE = '
\83G
\83\89\81[';
210 KeyItem: TKeySettingItem;
211 ActiveListView: TListView;
213 if PageControl1.ActivePage.TabIndex <> 0 then
214 ActiveListView := ListView1
216 ActiveListView := ListView;
218 if ActiveListView.Selected = nil then Exit;
219 if HotKey.HotKey = 13 then begin
220 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
225 //
\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é
226 for i := 0 to ActiveListView.Items.Count - 1 do begin
227 if ActiveListView.Selected = ActiveListView.Items[i] then
229 Item := ActiveListView.Items[i];
230 if TObject(Item.Data) is TKeySettingItem then begin
231 KeyItem := TKeySettingItem(Item.Data);
232 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
233 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
239 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
240 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
241 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
242 KeyItem.ShortCut := HotKey.HotKey;
243 ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
247 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
251 KeyItem: TKeySettingItem;
254 GikoSys.Setting.GestureEnabled := GestureCheckBox.Checked;
255 GikoSys.Setting.Gestures.ClearGesture;
256 for i := 0 to ListView.Items.Count - 1 do begin
257 Item := ListView.Items[i];
258 if TObject(Item.Data) is TKeySettingItem then begin
259 KeyItem := TKeySettingItem(Item.Data);
260 KeyItem.Action.ShortCut := KeyItem.ShortCut;
261 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
264 for i := 0 to ListView1.Items.Count - 1 do begin
265 Item := ListView1.Items[i];
266 if TObject(Item.Data) is TKeySettingItem then begin
267 KeyItem := TKeySettingItem(Item.Data);
268 KeyItem.Action.ShortCut := KeyItem.ShortCut;
269 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
275 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
276 Item2: TListItem; Data: Integer; var Compare: Integer);
278 if Item1.SubItems[0] > Item2.SubItems[0] then
280 else if Item1.SubItems[0] < Item2.SubItems[0] then
286 procedure TKeySettingForm.GestureSetButtonClick(Sender: TObject);
288 ERR_MSG = '
\93ü
\97Í
\82µ
\82½
\83W
\83F
\83X
\83`
\83\83\81[
\82Í
\8aù
\82É
\8eg
\97p
\82³
\82ê
\82Ä
\82¢
\82Ü
\82·';
289 ERR_TITLE = '
\83G
\83\89\81[';
293 KeyItem: TKeySettingItem;
294 ActiveListView: TListView;
295 chechList : TListView;
297 if PageControl1.ActivePage.TabIndex <> 0 then
298 ActiveListView := ListView1
300 ActiveListView := ListView;
302 if ActiveListView.Selected = nil then Exit;
303 if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin
304 GestureEdit.Text := '';
305 Item := ActiveListView.Selected;
306 Item.SubItems[2] := '';
307 if TObject(Item.Data) is TKeySettingItem then begin
308 KeyItem := TKeySettingItem(Item.Data);
309 KeyItem.Gesture := '';
314 //
\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é
315 chechList := ListView;
316 for j := 0 to 1 do begin
318 chechList := ListView1;
321 for i := 0 to chechList.Items.Count - 1 do begin
322 if ActiveListView.Selected = chechList.Items[i] then
324 Item := chechList.Items[i];
325 if TObject(Item.Data) is TKeySettingItem then begin
326 KeyItem := TKeySettingItem(Item.Data);
327 if (GestureEdit.Text <> GUESTURE_NOTHING)
328 and (KeyItem.Gesture = GestureEdit.Text) then begin
329 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
337 //
\83W
\83F
\83X
\83`
\83\83\81[
\90Ý
\92è
338 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
339 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
340 KeyItem.Gesture := GestureEdit.Text;
341 if GestureEdit.Text = GUESTURE_NOTHING then
342 ActiveListView.Selected.SubItems[2] := ''
344 ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
348 procedure TKeySettingForm.OnGestureStart(Sender: TObject);
350 GestureEdit.Text := '';
353 procedure TKeySettingForm.OnGestureMove(Sender: TObject);
355 GestureEdit.Text := MouseGesture.GetGestureStr;
358 procedure TKeySettingForm.OnGestureEnd(Sender: TObject);
360 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 := '';