6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil,
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;
77 GUESTURE_NOTHING = '
\82È
\82µ';
81 procedure TKeySettingForm.FormCreate(Sender: TObject);
85 KeyItem: TKeySettingItem;
88 for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
89 if GikoForm.ActionList.Actions[i] is TAction then begin
90 if GikoForm.ActionList.Actions[i].Tag <> 0 then
92 ListItem := ListView.Items.Add;
93 ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint;
94 ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category);
95 ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut));
96 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
97 TAction( GikoForm.ActionList.Actions[i] ) ) );
98 ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex;
99 KeyItem := TKeySettingItem.Create;
100 KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]);
101 KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut;
102 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
103 TAction( GikoForm.ActionList.Actions[i] ) );
104 ListItem.Data := KeyItem;
107 if ListView.Items.Count > 0 then
108 ListView.Selected := ListView.Items[0];
109 EditorForm := TEditorForm.Create(Self);
110 GikoSys.LoadEditorKeySetting(EditorForm.ActionList);
112 for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin
113 if EditorForm.ActionList.Actions[i] is TAction then begin
114 if EditorForm.ActionList.Actions[i].Tag <> 0 then
116 ListItem := ListView1.Items.Add;
117 ListItem.Caption := TAction(EditorForm.ActionList.Actions[i]).Hint;
118 ListItem.SubItems.Add(TAction(EditorForm.ActionList.Actions[i]).Category);
119 ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut));
120 ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex;
121 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
122 TAction( GikoForm.ActionList.Actions[i] ) ) );
123 KeyItem := TKeySettingItem.Create;
124 KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]);
125 KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut;
126 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
127 TAction( GikoForm.ActionList.Actions[i] ) );
128 ListItem.Data := KeyItem;
131 ListView1.SmallImages := EditorForm.HotToobarImageList;
135 // ActionListView.SortType := stText;
136 StatusBar.Height := 21;
137 StatusBar.Width := 21;
138 PageControl1.ActivePageIndex := 0;
139 GestureCheckBox.Checked := GikoSys.Setting.GestureEnabled;
140 GestureCheckBoxClick( Sender );
143 MouseGesture.OnGestureStart := OnGestureStart;
144 MouseGesture.OnGestureMove := OnGestureMove;
145 MouseGesture.OnGestureEnd := OnGestureEnd;
146 MouseGesture.SetHook( Handle );
149 procedure TKeySettingForm.FormDestroy(Sender: TObject);
153 for i := 0 to ListView.Items.Count - 1 do begin
154 if TObject(ListView.Items[i].Data) is TKeySettingItem then
155 TKeySettingItem(ListView.Items[i].Data).Free;
157 for i := 0 to ListView1.Items.Count - 1 do begin
158 if TObject(ListView1.Items[i].Data) is TKeySettingItem then
159 TKeySettingItem(ListView1.Items[i].Data).Free;
164 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
165 Item: TListItem; Selected: Boolean);
167 KeyItem: TKeySettingItem;
169 if not Selected then Exit;
171 if TObject(Item.Data) is TKeySettingItem then begin
172 KeyItem := TKeySettingItem(Item.Data);
173 HotKey.HotKey := KeyItem.ShortCut;
174 GestureEdit.Text := KeyItem.Gesture;
178 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
180 OkBotton.Default := False;
181 CancelBotton.Cancel := False;
184 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
186 OkBotton.Default := True;
187 CancelBotton.Cancel := True;
190 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
193 if Key in [8, 27, 32, 46] then begin
194 HotKey.HotKey := ShortCut(Key, Shift);
199 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
201 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
202 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·';
203 ERR_TITLE = '
\83G
\83\89\81[';
207 KeyItem: TKeySettingItem;
208 ActiveListView: TListView;
210 if PageControl1.ActivePage.TabIndex <> 0 then
211 ActiveListView := ListView1
213 ActiveListView := ListView;
215 if ActiveListView.Selected = nil then Exit;
216 if HotKey.HotKey = 13 then begin
217 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
222 //
\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é
223 for i := 0 to ActiveListView.Items.Count - 1 do begin
224 if ActiveListView.Selected = ActiveListView.Items[i] then
226 Item := ActiveListView.Items[i];
227 if TObject(Item.Data) is TKeySettingItem then begin
228 KeyItem := TKeySettingItem(Item.Data);
229 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
230 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
236 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
237 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
238 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
239 KeyItem.ShortCut := HotKey.HotKey;
240 ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
244 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
248 KeyItem: TKeySettingItem;
251 GikoSys.Setting.GestureEnabled := GestureCheckBox.Checked;
252 GikoSys.Setting.Gestures.ClearGesture;
253 for i := 0 to ListView.Items.Count - 1 do begin
254 Item := ListView.Items[i];
255 if TObject(Item.Data) is TKeySettingItem then begin
256 KeyItem := TKeySettingItem(Item.Data);
257 KeyItem.Action.ShortCut := KeyItem.ShortCut;
258 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
261 for i := 0 to ListView1.Items.Count - 1 do begin
262 Item := ListView1.Items[i];
263 if TObject(Item.Data) is TKeySettingItem then begin
264 KeyItem := TKeySettingItem(Item.Data);
265 KeyItem.Action.ShortCut := KeyItem.ShortCut;
266 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
272 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
273 Item2: TListItem; Data: Integer; var Compare: Integer);
275 if Item1.SubItems[0] > Item2.SubItems[0] then
277 else if Item1.SubItems[0] < Item2.SubItems[0] then
283 procedure TKeySettingForm.GestureSetButtonClick(Sender: TObject);
285 ERR_MSG = '
\93ü
\97Í
\82µ
\82½
\83W
\83F
\83X
\83`
\83\83\81[
\82Í
\8aù
\82É
\8eg
\97p
\82³
\82ê
\82Ä
\82¢
\82Ü
\82·';
286 ERR_TITLE = '
\83G
\83\89\81[';
290 KeyItem: TKeySettingItem;
291 ActiveListView: TListView;
293 if PageControl1.ActivePage.TabIndex <> 0 then
294 ActiveListView := ListView1
296 ActiveListView := ListView;
298 if ActiveListView.Selected = nil then Exit;
299 if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin
300 GestureEdit.Text := '';
301 Item := ActiveListView.Selected;
302 Item.SubItems[2] := '';
303 if TObject(Item.Data) is TKeySettingItem then begin
304 KeyItem := TKeySettingItem(Item.Data);
305 KeyItem.Gesture := '';
310 //
\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é
311 for i := 0 to ActiveListView.Items.Count - 1 do begin
312 if ActiveListView.Selected = ActiveListView.Items[i] then
314 Item := ActiveListView.Items[i];
315 if TObject(Item.Data) is TKeySettingItem then begin
316 KeyItem := TKeySettingItem(Item.Data);
317 if (GestureEdit.Text <> '')
318 and (KeyItem.Gesture = GestureEdit.Text) then begin
319 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
325 //
\83W
\83F
\83X
\83`
\83\83\81[
\90Ý
\92è
326 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
327 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
328 KeyItem.Gesture := GestureEdit.Text;
329 if GestureEdit.Text = GUESTURE_NOTHING then
330 ActiveListView.Selected.SubItems[2] := ''
332 ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
336 procedure TKeySettingForm.OnGestureStart(Sender: TObject);
338 GestureEdit.Text := '';
341 procedure TKeySettingForm.OnGestureMove(Sender: TObject);
343 GestureEdit.Text := MouseGesture.GetGestureStr;
346 procedure TKeySettingForm.OnGestureEnd(Sender: TObject);
348 GestureEdit.Text := MouseGesture.GetGestureStr;
351 procedure TKeySettingForm.GestureCheckBoxClick(Sender: TObject);
353 GestureEdit.Enabled := GestureCheckBox.Checked;
354 GestureSetButton.Enabled := GestureCheckBox.Checked;
357 procedure TKeySettingForm.GestureEditChange(Sender: TObject);
360 if GestureEdit.Text = '' then
361 GestureEdit.Text := GUESTURE_NOTHING;
365 procedure TKeySettingForm.GestureEditKeyDown(Sender: TObject;
366 var Key: Word; Shift: TShiftState);
368 if (ssShift in Shift) and (MouseGesture.GetGestureStr = '') then
369 GestureEdit.Text := '';