| 4 |
|
|
| 5 |
uses |
uses |
| 6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 7 |
Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil; |
Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil, |
| 8 |
|
Editor; |
| 9 |
|
|
| 10 |
type |
type |
| 11 |
TKeySettingItem = class(TObject) |
TKeySettingItem = class(TObject) |
| 50 |
{ Private 宣言 } |
{ Private 宣言 } |
| 51 |
public |
public |
| 52 |
{ Public 宣言 } |
{ Public 宣言 } |
| 53 |
|
EditorForm: TEditorForm; |
| 54 |
end; |
end; |
| 55 |
|
|
| 56 |
//var |
//var |
| 67 |
i: Integer; |
i: Integer; |
| 68 |
ListItem: TListItem; |
ListItem: TListItem; |
| 69 |
KeyItem: TKeySettingItem; |
KeyItem: TKeySettingItem; |
| 70 |
|
|
| 71 |
begin |
begin |
| 72 |
for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin |
for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin |
| 73 |
if GikoForm.ActionList.Actions[i] is TAction then begin |
if GikoForm.ActionList.Actions[i] is TAction then begin |
| 86 |
end; |
end; |
| 87 |
if ListView.Items.Count > 0 then |
if ListView.Items.Count > 0 then |
| 88 |
ListView.Selected := ListView.Items[0]; |
ListView.Selected := ListView.Items[0]; |
| 89 |
|
EditorForm := TEditorForm.Create(Self); |
| 90 |
|
GikoSys.LoadEditorKeySetting(EditorForm.ActionList); |
| 91 |
|
try |
| 92 |
|
for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin |
| 93 |
|
if EditorForm.ActionList.Actions[i] is TAction then begin |
| 94 |
|
if EditorForm.ActionList.Actions[i].Tag <> 0 then |
| 95 |
|
Continue; |
| 96 |
|
ListItem := ListView1.Items.Add; |
| 97 |
|
ListItem.Caption := TAction(EditorForm.ActionList.Actions[i]).Hint; |
| 98 |
|
ListItem.SubItems.Add(TAction(EditorForm.ActionList.Actions[i]).Category); |
| 99 |
|
ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut)); |
| 100 |
|
ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex; |
| 101 |
|
KeyItem := TKeySettingItem.Create; |
| 102 |
|
KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]); |
| 103 |
|
KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut; |
| 104 |
|
ListItem.Data := KeyItem; |
| 105 |
|
end; |
| 106 |
|
end; |
| 107 |
|
ListView1.SmallImages := EditorForm.HotToobarImageList; |
| 108 |
|
finally |
| 109 |
|
|
| 110 |
|
end; |
| 111 |
// ActionListView.SortType := stText; |
// ActionListView.SortType := stText; |
| 112 |
StatusBar.Height := 21; |
StatusBar.Height := 21; |
| 113 |
StatusBar.Width := 21; |
StatusBar.Width := 21; |
| 114 |
|
PageControl1.ActivePageIndex := 0; |
| 115 |
end; |
end; |
| 116 |
|
|
| 117 |
procedure TKeySettingForm.FormDestroy(Sender: TObject); |
procedure TKeySettingForm.FormDestroy(Sender: TObject); |
| 122 |
if TObject(ListView.Items[i].Data) is TKeySettingItem then |
if TObject(ListView.Items[i].Data) is TKeySettingItem then |
| 123 |
TKeySettingItem(ListView.Items[i].Data).Free; |
TKeySettingItem(ListView.Items[i].Data).Free; |
| 124 |
end; |
end; |
| 125 |
|
for i := 0 to ListView1.Items.Count - 1 do begin |
| 126 |
|
if TObject(ListView1.Items[i].Data) is TKeySettingItem then |
| 127 |
|
TKeySettingItem(ListView1.Items[i].Data).Free; |
| 128 |
|
end; |
| 129 |
|
EditorForm.Release; |
| 130 |
end; |
end; |
| 131 |
|
|
| 132 |
procedure TKeySettingForm.ListViewSelectItem(Sender: TObject; |
procedure TKeySettingForm.ListViewSelectItem(Sender: TObject; |
| 172 |
i: Integer; |
i: Integer; |
| 173 |
Item: TListItem; |
Item: TListItem; |
| 174 |
KeyItem: TKeySettingItem; |
KeyItem: TKeySettingItem; |
| 175 |
|
ActiveListView: TListView; |
| 176 |
begin |
begin |
| 177 |
if ListView.Selected = nil then Exit; |
if PageControl1.ActivePage.TabIndex <> 0 then |
| 178 |
|
ActiveListView := ListView1 |
| 179 |
|
else |
| 180 |
|
ActiveListView := ListView; |
| 181 |
|
|
| 182 |
|
if ActiveListView.Selected = nil then Exit; |
| 183 |
if HotKey.HotKey = 13 then begin |
if HotKey.HotKey = 13 then begin |
| 184 |
MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP); |
MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP); |
| 185 |
HotKey.SetFocus; |
HotKey.SetFocus; |
| 187 |
end; |
end; |
| 188 |
|
|
| 189 |
//現在選択されているAction以外で同じショートカットがあればエラーとする |
//現在選択されているAction以外で同じショートカットがあればエラーとする |
| 190 |
for i := 0 to ListView.Items.Count - 1 do begin |
for i := 0 to ActiveListView.Items.Count - 1 do begin |
| 191 |
if ListView.Selected = ListView.Items[i] then |
if ActiveListView.Selected = ActiveListView.Items[i] then |
| 192 |
Continue; |
Continue; |
| 193 |
Item := ListView.Items[i]; |
Item := ActiveListView.Items[i]; |
| 194 |
if TObject(Item.Data) is TKeySettingItem then begin |
if TObject(Item.Data) is TKeySettingItem then begin |
| 195 |
KeyItem := TKeySettingItem(Item.Data); |
KeyItem := TKeySettingItem(Item.Data); |
| 196 |
if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin |
if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin |
| 201 |
end; |
end; |
| 202 |
end; |
end; |
| 203 |
//ショートカット設定 |
//ショートカット設定 |
| 204 |
if TObject(ListView.Selected.Data) is TKeySettingItem then begin |
if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin |
| 205 |
KeyItem := TKeySettingItem(ListView.Selected.Data); |
KeyItem := TKeySettingItem(ActiveListView.Selected.Data); |
| 206 |
KeyItem.ShortCut := HotKey.HotKey; |
KeyItem.ShortCut := HotKey.HotKey; |
| 207 |
ListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey); |
ActiveListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey); |
| 208 |
end; |
end; |
| 209 |
end; |
end; |
| 210 |
|
|
| 221 |
KeyItem.Action.ShortCut := KeyItem.ShortCut; |
KeyItem.Action.ShortCut := KeyItem.ShortCut; |
| 222 |
end; |
end; |
| 223 |
end; |
end; |
| 224 |
|
for i := 0 to ListView1.Items.Count - 1 do begin |
| 225 |
|
Item := ListView1.Items[i]; |
| 226 |
|
if TObject(Item.Data) is TKeySettingItem then begin |
| 227 |
|
KeyItem := TKeySettingItem(Item.Data); |
| 228 |
|
KeyItem.Action.ShortCut := KeyItem.ShortCut; |
| 229 |
|
end; |
| 230 |
|
end; |
| 231 |
|
|
| 232 |
end; |
end; |
| 233 |
|
|
| 234 |
procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1, |
procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1, |
| 235 |
Item2: TListItem; Data: Integer; var Compare: Integer); |
Item2: TListItem; Data: Integer; var Compare: Integer); |
| 236 |
begin |
begin |
| 237 |
if Item1.SubItems[0] > Item2.SubItems[0] then |
if Item1.SubItems[0] > Item2.SubItems[0] then |
| 238 |
Compare := 1 |
Compare := 1 |
| 239 |
else if Item1.SubItems[0] < Item2.SubItems[0] then |
else if Item1.SubItems[0] < Item2.SubItems[0] then |
| 240 |
Compare := -1 |
Compare := -1 |
| 241 |
else |
else |
| 242 |
Compare := 0; |
Compare := 0; |
| 243 |
end; |
end; |
| 244 |
|
|
| 245 |
end. |
end. |