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;
88 CenterForm: TCustomForm;
91 //for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
92 for i := 0 to GikoDM.GikoFormActionList.ActionCount - 1 do begin
93 //if GikoForm.ActionList.Actions[i] is TAction then begin
94 if GikoDM.GikoFormActionList.Actions[i] is TAction then begin
95 if GikoDM.GikoFormActionList.Actions[i].Tag <> 0 then
97 ListItem := ListView.Items.Add;
98 ListItem.Caption := TAction(GikoDM.GikoFormActionList.Actions[i]).Hint;
99 ListItem.SubItems.Add(TAction(GikoDM.GikoFormActionList.Actions[i]).Category);
100 ListItem.SubItems.Add(ShortCutToText(TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut));
101 ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
102 TAction( GikoDM.GikoFormActionList.Actions[i] ) ) );
103 ListItem.ImageIndex := TAction(GikoDM.GikoFormActionList.Actions[i]).ImageIndex;
104 KeyItem := TKeySettingItem.Create;
105 KeyItem.Action := TAction(GikoDM.GikoFormActionList.Actions[i]);
106 KeyItem.ShortCut := TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut;
107 KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
108 TAction( GikoDM.GikoFormActionList.Actions[i] ) );
109 ListItem.Data := KeyItem;
112 if ListView.Items.Count > 0 then
113 ListView.Selected := ListView.Items[0];
114 EditorForm := TEditorForm.Create(Self);
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 );
152 CenterForm := TCustomForm(Owner);
153 if Assigned(CenterForm) then begin
154 Left := ((CenterForm.Width - Width) div 2) + CenterForm.Left;
155 Top := ((CenterForm.Height - Height) div 2) + CenterForm.Top;
157 Left := (Screen.Width - Width) div 2;
158 Top := (Screen.Height - Height) div 2;
162 procedure TKeySettingForm.FormDestroy(Sender: TObject);
166 for i := 0 to ListView.Items.Count - 1 do begin
167 if TObject(ListView.Items[i].Data) is TKeySettingItem then
168 TKeySettingItem(ListView.Items[i].Data).Free;
170 for i := 0 to ListView1.Items.Count - 1 do begin
171 if TObject(ListView1.Items[i].Data) is TKeySettingItem then
172 TKeySettingItem(ListView1.Items[i].Data).Free;
177 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
178 Item: TListItem; Selected: Boolean);
180 KeyItem: TKeySettingItem;
182 if not Selected then Exit;
184 if TObject(Item.Data) is TKeySettingItem then begin
185 KeyItem := TKeySettingItem(Item.Data);
186 HotKey.HotKey := KeyItem.ShortCut;
187 GestureEdit.Text := KeyItem.Gesture;
191 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
193 OkBotton.Default := False;
194 CancelBotton.Cancel := False;
197 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
199 OkBotton.Default := True;
200 CancelBotton.Cancel := True;
203 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
206 if Key in [8, 27, 32, 46] then begin
207 HotKey.HotKey := ShortCut(Key, Shift);
212 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
214 ERR_ENT = 'Enter
\83L
\81[
\82Í
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82Æ
\82µ
\82Ä
\8eg
\97p
\82Å
\82«
\82Ü
\82¹
\82ñ';
215 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·';
216 ERR_TITLE = '
\83G
\83\89\81[';
220 KeyItem: TKeySettingItem;
221 ActiveListView: TListView;
223 if PageControl1.ActivePage.TabIndex <> 0 then
224 ActiveListView := ListView1
226 ActiveListView := ListView;
228 if ActiveListView.Selected = nil then Exit;
229 if HotKey.HotKey = 13 then begin
230 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
235 //
\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é
236 for i := 0 to ActiveListView.Items.Count - 1 do begin
237 if ActiveListView.Selected = ActiveListView.Items[i] then
239 Item := ActiveListView.Items[i];
240 if TObject(Item.Data) is TKeySettingItem then begin
241 KeyItem := TKeySettingItem(Item.Data);
242 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
243 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
249 //
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\90Ý
\92è
250 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
251 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
252 KeyItem.ShortCut := HotKey.HotKey;
253 ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
257 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
261 KeyItem: TKeySettingItem;
264 GikoSys.Setting.GestureEnabled := GestureCheckBox.Checked;
265 GikoSys.Setting.Gestures.ClearGesture;
266 for i := 0 to ListView.Items.Count - 1 do begin
267 Item := ListView.Items[i];
268 if TObject(Item.Data) is TKeySettingItem then begin
269 KeyItem := TKeySettingItem(Item.Data);
270 KeyItem.Action.ShortCut := KeyItem.ShortCut;
271 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
274 for i := 0 to ListView1.Items.Count - 1 do begin
275 Item := ListView1.Items[i];
276 if TObject(Item.Data) is TKeySettingItem then begin
277 KeyItem := TKeySettingItem(Item.Data);
278 KeyItem.Action.ShortCut := KeyItem.ShortCut;
279 GikoSys.Setting.Gestures.AddGesture( KeyItem.Gesture, KeyItem.Action );
285 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
286 Item2: TListItem; Data: Integer; var Compare: Integer);
288 if Item1.SubItems[0] > Item2.SubItems[0] then
290 else if Item1.SubItems[0] < Item2.SubItems[0] then
296 procedure TKeySettingForm.GestureSetButtonClick(Sender: TObject);
298 ERR_MSG = '
\93ü
\97Í
\82µ
\82½
\83W
\83F
\83X
\83`
\83\83\81[
\82Í
\8aù
\82É
\8eg
\97p
\82³
\82ê
\82Ä
\82¢
\82Ü
\82·';
299 ERR_TITLE = '
\83G
\83\89\81[';
303 KeyItem: TKeySettingItem;
304 ActiveListView: TListView;
305 chechList : TListView;
307 if PageControl1.ActivePage.TabIndex <> 0 then
308 ActiveListView := ListView1
310 ActiveListView := ListView;
312 if ActiveListView.Selected = nil then Exit;
313 if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin
314 GestureEdit.Text := '';
315 Item := ActiveListView.Selected;
316 Item.SubItems[2] := '';
317 if TObject(Item.Data) is TKeySettingItem then begin
318 KeyItem := TKeySettingItem(Item.Data);
319 KeyItem.Gesture := '';
324 //
\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é
325 chechList := ListView;
326 for j := 0 to 1 do begin
328 chechList := ListView1;
331 for i := 0 to chechList.Items.Count - 1 do begin
332 if ActiveListView.Selected = chechList.Items[i] then
334 Item := chechList.Items[i];
335 if TObject(Item.Data) is TKeySettingItem then begin
336 KeyItem := TKeySettingItem(Item.Data);
337 if (GestureEdit.Text <> GUESTURE_NOTHING)
338 and (KeyItem.Gesture = GestureEdit.Text) then begin
339 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
347 //
\83W
\83F
\83X
\83`
\83\83\81[
\90Ý
\92è
348 if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
349 KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
350 KeyItem.Gesture := GestureEdit.Text;
351 if GestureEdit.Text = GUESTURE_NOTHING then
352 ActiveListView.Selected.SubItems[2] := ''
354 ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
358 procedure TKeySettingForm.OnGestureStart(Sender: TObject);
360 GestureEdit.Text := '';
363 procedure TKeySettingForm.OnGestureMove(Sender: TObject);
365 GestureEdit.Text := MouseGesture.GetGestureStr;
368 procedure TKeySettingForm.OnGestureEnd(Sender: TObject);
370 GestureEdit.Text := MouseGesture.GetGestureStr;
374 procedure TKeySettingForm.GestureCheckBoxClick(Sender: TObject);
376 GestureEdit.Enabled := GestureCheckBox.Checked;
377 GestureSetButton.Enabled := GestureCheckBox.Checked;
380 procedure TKeySettingForm.GestureEditChange(Sender: TObject);
383 if GestureEdit.Text = '' then
384 GestureEdit.Text := GUESTURE_NOTHING;
388 procedure TKeySettingForm.GestureEditKeyDown(Sender: TObject;
389 var Key: Word; Shift: TShiftState);
391 if (ssShift in Shift) and (MouseGesture.GetGestureStr = '') then
392 GestureEdit.Text := '';