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);
65 EditorForm: TEditorForm;
69 // KeySettingForm: TKeySettingForm;
75 GUESTURE_NOTHING = '
\82È
\82µ';
79 procedure TKeySettingForm.FormCreate(Sender: TObject);
83 KeyItem: TKeySettingItem;
86 for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
87 if GikoForm.ActionList.Actions[i] is TAction then begin
88 if GikoForm.ActionList.Actions[i].Tag <> 0 then
90 ListItem := ListView.Items.Add;
91 ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint;
92 ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category);
93 ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut));
94 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
95 TAction( GikoForm.ActionList.Actions[i] ) ) );
96 ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex;
97 KeyItem := TKeySettingItem.Create;
98 KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]);
99 KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut;
100 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
101 TAction( GikoForm.ActionList.Actions[i] ) );
102 ListItem.Data := KeyItem;
105 if ListView.Items.Count > 0 then
106 ListView.Selected := ListView.Items[0];
107 EditorForm := TEditorForm.Create(Self);
108 GikoSys.LoadEditorKeySetting(EditorForm.ActionList);
110 for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin
111 if EditorForm.ActionList.Actions[i] is TAction then begin
112 if EditorForm.ActionList.Actions[i].Tag <> 0 then
114 ListItem := ListView1.Items.Add;
115 ListItem.Caption := TAction(EditorForm.ActionList.Actions[i]).Hint;
116 ListItem.SubItems.Add(TAction(EditorForm.ActionList.Actions[i]).Category);
117 ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut));
118 ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex;
119 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
120 TAction( GikoForm.ActionList.Actions[i] ) ) );
121 KeyItem := TKeySettingItem.Create;
122 KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]);
123 KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut;
124 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
125 TAction( GikoForm.ActionList.Actions[i] ) );
126 ListItem.Data := KeyItem;
129 ListView1.SmallImages := EditorForm.HotToobarImageList;
133 // ActionListView.SortType := stText;
134 StatusBar.Height := 21;
135 StatusBar.Width := 21;
136 PageControl1.ActivePageIndex := 0;
137 GestureCheckBox.Checked := GikoSys.Setting.GestureEnabled;
138 GestureCheckBoxClick( Sender );
141 MouseGesture.OnGestureStart := OnGestureStart;
142 MouseGesture.OnGestureMove := OnGestureMove;
143 MouseGesture.OnGestureEnd := OnGestureEnd;
144 MouseGesture.SetHook( Handle );
147 procedure TKeySettingForm.FormDestroy(Sender: TObject);
151 for i := 0 to ListView.Items.Count - 1 do begin
152 if TObject(ListView.Items[i].Data) is TKeySettingItem then
153 TKeySettingItem(ListView.Items[i].Data).Free;
155 for i := 0 to ListView1.Items.Count - 1 do begin
156 if TObject(ListView1.Items[i].Data) is TKeySettingItem then
157 TKeySettingItem(ListView1.Items[i].Data).Free;
162 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
163 Item: TListItem; Selected: Boolean);
165 KeyItem: TKeySettingItem;
167 if not Selected then Exit;
169 if TObject(Item.Data) is TKeySettingItem then begin
170 KeyItem := TKeySettingItem(Item.Data);
171 HotKey.HotKey := KeyItem.ShortCut;
172 GestureEdit.Text := KeyItem.Gesture;
176 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
178 OkBotton.Default := False;
179 CancelBotton.Cancel := False;
182 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
184 OkBotton.Default := True;
185 CancelBotton.Cancel := True;
188 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
191 if Key in [8, 27, 32, 46] then begin
192 HotKey.HotKey := ShortCut(Key, Shift);
197 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
199 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
200 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·';
201 ERR_TITLE = '
\83G
\83\89\81[';
205 KeyItem: TKeySettingItem;
206 ActiveListView: TListView;
208 if PageControl1.ActivePage.TabIndex <> 0 then
209 ActiveListView := ListView1
211 ActiveListView := ListView;
213 if ActiveListView.Selected = nil then Exit;
214 if HotKey.HotKey = 13 then begin
215 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
220 //
\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é
221 for i := 0 to ActiveListView.Items.Count - 1 do begin
222 if ActiveListView.Selected = ActiveListView.Items[i] then
224 Item := ActiveListView.Items[i];
225 if TObject(Item.Data) is TKeySettingItem then begin
226 KeyItem := TKeySettingItem(Item.Data);
227 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
228 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
234 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
235 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
236 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
237 KeyItem.ShortCut := HotKey.HotKey;
238 ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
242 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
246 KeyItem: TKeySettingItem;
249 GikoSys.Setting.GestureEnabled := GestureCheckBox.Checked;
250 GikoSys.Setting.Gestures.ClearGesture;
251 for i := 0 to ListView.Items.Count - 1 do begin
252 Item := ListView.Items[i];
253 if TObject(Item.Data) is TKeySettingItem then begin
254 KeyItem := TKeySettingItem(Item.Data);
255 KeyItem.Action.ShortCut := KeyItem.ShortCut;
256 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
259 for i := 0 to ListView1.Items.Count - 1 do begin
260 Item := ListView1.Items[i];
261 if TObject(Item.Data) is TKeySettingItem then begin
262 KeyItem := TKeySettingItem(Item.Data);
263 KeyItem.Action.ShortCut := KeyItem.ShortCut;
264 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
270 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
271 Item2: TListItem; Data: Integer; var Compare: Integer);
273 if Item1.SubItems[0] > Item2.SubItems[0] then
275 else if Item1.SubItems[0] < Item2.SubItems[0] then
281 procedure TKeySettingForm.GestureSetButtonClick(Sender: TObject);
283 ERR_MSG = '
\93ü
\97Í
\82µ
\82½
\83W
\83F
\83X
\83`
\83\83\81[
\82Í
\8aù
\82É
\8eg
\97p
\82³
\82ê
\82Ä
\82¢
\82Ü
\82·';
284 ERR_TITLE = '
\83G
\83\89\81[';
288 KeyItem: TKeySettingItem;
289 ActiveListView: TListView;
291 if PageControl1.ActivePage.TabIndex <> 0 then
292 ActiveListView := ListView1
294 ActiveListView := ListView;
296 if ActiveListView.Selected = nil then Exit;
297 if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin
298 GestureEdit.Text := '';
299 Item := ActiveListView.Selected;
300 Item.SubItems[2] := '';
301 if TObject(Item.Data) is TKeySettingItem then begin
302 KeyItem := TKeySettingItem(Item.Data);
303 KeyItem.Gesture := '';
308 //
\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é
309 for i := 0 to ActiveListView.Items.Count - 1 do begin
310 if ActiveListView.Selected = ActiveListView.Items[i] then
312 Item := ActiveListView.Items[i];
313 if TObject(Item.Data) is TKeySettingItem then begin
314 KeyItem := TKeySettingItem(Item.Data);
315 if (GestureEdit.Text <> '')
316 and (KeyItem.Gesture = GestureEdit.Text) then begin
317 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
323 //
\83W
\83F
\83X
\83`
\83\83\81[
\90Ý
\92è
324 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
325 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
326 KeyItem.Gesture := GestureEdit.Text;
327 if GestureEdit.Text = GUESTURE_NOTHING then
328 ActiveListView.Selected.SubItems[2] := ''
330 ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
334 procedure TKeySettingForm.OnGestureStart(Sender: TObject);
336 GestureEdit.Text := '';
339 procedure TKeySettingForm.OnGestureMove(Sender: TObject);
341 GestureEdit.Text := MouseGesture.GetGestureStr;
344 procedure TKeySettingForm.OnGestureEnd(Sender: TObject);
346 GestureEdit.Text := MouseGesture.GetGestureStr;
349 procedure TKeySettingForm.GestureCheckBoxClick(Sender: TObject);
351 GestureEdit.Enabled := GestureCheckBox.Checked;
352 GestureSetButton.Enabled := GestureCheckBox.Checked;
355 procedure TKeySettingForm.GestureEditChange(Sender: TObject);
358 if GestureEdit.Text = '' then
359 GestureEdit.Text := GUESTURE_NOTHING;