OSDN Git Service

This commit was manufactured by cvs2svn to create branch 'Bb62'.
[gikonavigoeson/gikonavi.git] / KeySetting.pas
index 25217a1..eb1adf3 100644 (file)
@@ -4,8 +4,8 @@ interface
 
 uses
        Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-       Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil,
-    Editor;
+       Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus,
+       Editor;
 
 type
        TKeySettingItem = class(TObject)
@@ -57,11 +57,14 @@ type
                procedure OnGestureMove(Sender: TObject);
                procedure OnGestureEnd(Sender: TObject);
     procedure GestureCheckBoxClick(Sender: TObject);
+    procedure GestureEditChange(Sender: TObject);
+    procedure GestureEditKeyDown(Sender: TObject; var Key: Word;
+      Shift: TShiftState);
        private
                { Private \90é\8c¾ }
        public
                { Public \90é\8c¾ }
-        EditorForm: TEditorForm;
+               EditorForm: TEditorForm;
        end;
 
 //var
@@ -69,7 +72,11 @@ type
 
 implementation
 
-uses Giko, Gesture;
+uses
+       Giko, GikoUtil, Gesture, GikoDataModule, GikoSystem;
+
+const
+       GUESTURE_NOTHING        = '\82È\82µ';
 
 {$R *.dfm}
 
@@ -80,29 +87,30 @@ var
        KeyItem: TKeySettingItem;
 
 begin
-       for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
-               if GikoForm.ActionList.Actions[i] is TAction then begin
-                       if GikoForm.ActionList.Actions[i].Tag <> 0 then
+       //for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
+       for i := 0 to GikoDM.GikoFormActionList.ActionCount - 1 do begin
+               //if GikoForm.ActionList.Actions[i] is TAction then begin
+               if GikoDM.GikoFormActionList.Actions[i] is TAction then begin
+                       if GikoDM.GikoFormActionList.Actions[i].Tag <> 0 then
                                Continue;
                        ListItem := ListView.Items.Add;
-                       ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint;
-                       ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category);
-                       ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut));
+                       ListItem.Caption := TAction(GikoDM.GikoFormActionList.Actions[i]).Hint;
+                       ListItem.SubItems.Add(TAction(GikoDM.GikoFormActionList.Actions[i]).Category);
+                       ListItem.SubItems.Add(ShortCutToText(TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut));
                        ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
-                               TAction( GikoForm.ActionList.Actions[i] ) ) );
-                       ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex;
+                               TAction( GikoDM.GikoFormActionList.Actions[i] ) ) );
+                       ListItem.ImageIndex := TAction(GikoDM.GikoFormActionList.Actions[i]).ImageIndex;
                        KeyItem := TKeySettingItem.Create;
-                       KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]);
-                       KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut;
+                       KeyItem.Action := TAction(GikoDM.GikoFormActionList.Actions[i]);
+                       KeyItem.ShortCut := TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut;
                        KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
-                               TAction( GikoForm.ActionList.Actions[i] ) );
+                               TAction( GikoDM.GikoFormActionList.Actions[i] ) );
                        ListItem.Data := KeyItem;
                end;
        end;
        if ListView.Items.Count > 0 then
                ListView.Selected := ListView.Items[0];
        EditorForm := TEditorForm.Create(Self);
-       GikoSys.LoadEditorKeySetting(EditorForm.ActionList);
        try
                for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin
                        if EditorForm.ActionList.Actions[i] is TAction then begin
@@ -114,12 +122,12 @@ begin
                                ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut));
                                ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex;
                                ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture(
-                                       TAction( GikoForm.ActionList.Actions[i] ) ) );
+                                       TAction( EditorForm.ActionList.Actions[i] ) ) );
                                KeyItem := TKeySettingItem.Create;
                                KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]);
                                KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut;
                                KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture(
-                                       TAction( GikoForm.ActionList.Actions[i] ) );
+                                       TAction( EditorForm.ActionList.Actions[i] ) );
                                ListItem.Data := KeyItem;
                        end;
                end;
@@ -166,6 +174,7 @@ begin
        if TObject(Item.Data) is TKeySettingItem then begin
                KeyItem := TKeySettingItem(Item.Data);
                HotKey.HotKey := KeyItem.ShortCut;
+               GestureEdit.Text := KeyItem.Gesture;
        end;
 end;
 
@@ -279,10 +288,11 @@ const
        ERR_MSG = '\93ü\97Í\82µ\82½\83W\83F\83X\83`\83\83\81[\82Í\8aù\82É\8eg\97p\82³\82ê\82Ä\82¢\82Ü\82·';
        ERR_TITLE = '\83G\83\89\81[';
 var
-       i: Integer;
+       i, j: Integer;
        Item: TListItem;
        KeyItem: TKeySettingItem;
        ActiveListView: TListView;
+       chechList : TListView;
 begin
        if PageControl1.ActivePage.TabIndex <> 0 then
                ActiveListView := ListView1
@@ -292,28 +302,46 @@ begin
        if ActiveListView.Selected = nil then Exit;
        if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin
                GestureEdit.Text := '';
+               Item := ActiveListView.Selected;
+               Item.SubItems[2] := '';
+               if TObject(Item.Data) is TKeySettingItem then begin
+                       KeyItem := TKeySettingItem(Item.Data);
+                       KeyItem.Gesture := '';
+               end;
                Exit;
        end;
 
        // \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é
-       for i := 0 to ActiveListView.Items.Count - 1 do begin
-               if ActiveListView.Selected = ActiveListView.Items[i] then
-                       Continue;
-               Item := ActiveListView.Items[i];
-               if TObject(Item.Data) is TKeySettingItem then begin
-                       KeyItem := TKeySettingItem(Item.Data);
-                       if KeyItem.Gesture = GestureEdit.Text then begin
-                               MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
-                               HotKey.SetFocus;
-                               Exit;
+       chechList := ListView;
+       for j := 0 to 1 do begin
+               if j <> 0 then begin
+                       chechList := ListView1;
+               end;
+
+               for i := 0 to chechList.Items.Count - 1 do begin
+                       if ActiveListView.Selected = chechList.Items[i] then
+                               Continue;
+                       Item := chechList.Items[i];
+                       if TObject(Item.Data) is TKeySettingItem then begin
+                               KeyItem := TKeySettingItem(Item.Data);
+                               if (GestureEdit.Text <> GUESTURE_NOTHING)
+                               and (KeyItem.Gesture = GestureEdit.Text) then begin
+                                       MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
+                                       HotKey.SetFocus;
+                                       Exit;
+                               end;
                        end;
                end;
        end;
+
        // \83W\83F\83X\83`\83\83\81[\90Ý\92è
        if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin
                KeyItem := TKeySettingItem(ActiveListView.Selected.Data);
                KeyItem.Gesture := GestureEdit.Text;
-               ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
+               if GestureEdit.Text = GUESTURE_NOTHING then
+                       ActiveListView.Selected.SubItems[2] := ''
+               else
+                       ActiveListView.Selected.SubItems[2] := GestureEdit.Text;
        end;
 end;
 
@@ -330,6 +358,7 @@ end;
 procedure TKeySettingForm.OnGestureEnd(Sender: TObject);
 begin
        GestureEdit.Text := MouseGesture.GetGestureStr;
+    MouseGesture.Clear;
 end;
 
 procedure TKeySettingForm.GestureCheckBoxClick(Sender: TObject);
@@ -338,4 +367,19 @@ begin
        GestureSetButton.Enabled := GestureCheckBox.Checked;
 end;
 
+procedure TKeySettingForm.GestureEditChange(Sender: TObject);
+begin
+
+       if GestureEdit.Text = '' then
+               GestureEdit.Text := GUESTURE_NOTHING;
+
+end;
+
+procedure TKeySettingForm.GestureEditKeyDown(Sender: TObject;
+  var Key: Word; Shift: TShiftState);
+begin
+       if (ssShift in Shift) and (MouseGesture.GetGestureStr = '') then
+       GestureEdit.Text := '';
+end;
+
 end.