Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/KeySetting.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.1.1 - (show annotations) (download) (as text) (vendor branch)
Sat Aug 9 13:51:06 2003 UTC (20 years, 8 months ago) by hi_
Branch: hi
CVS Tags: b37, c33_4, b34, b35, b36, b33, b44, b41, b40, b43
Branch point for: stable
Changes since 1.1: +0 -0 lines
File MIME type: text/x-pascal
ソキオャコ?ョ

1 unit KeySetting;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil;
8
9 type
10 TKeySettingItem = class(TObject)
11 private
12 FAction: TAction;
13 FShortCut: TShortCut;
14 public
15 property Action: TAction read FAction write FAction;
16 property ShortCut: TShortCut read FShortCut write FShortCut;
17 end;
18
19 TKeySettingForm = class(TForm)
20 Panel1: TPanel;
21 Panel2: TPanel;
22 Panel3: TPanel;
23 OkBotton: TButton;
24 CancelBotton: TButton;
25 Label1: TLabel;
26 Label2: TLabel;
27 HotKey: THotKey;
28 SetButton: TButton;
29 StatusBar: TStatusBar;
30 Panel4: TPanel;
31 PageControl1: TPageControl;
32 TabSheet1: TTabSheet;
33 TabSheet2: TTabSheet;
34 ListView: TListView;
35 ListView1: TListView;
36 procedure FormCreate(Sender: TObject);
37 procedure FormDestroy(Sender: TObject);
38 procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
39 Selected: Boolean);
40 procedure HotKeyEnter(Sender: TObject);
41 procedure HotKeyExit(Sender: TObject);
42 procedure FormKeyDown(Sender: TObject; var Key: Word;
43 Shift: TShiftState);
44 procedure SetButtonClick(Sender: TObject);
45 procedure OkBottonClick(Sender: TObject);
46 procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem;
47 Data: Integer; var Compare: Integer);
48 private
49 { Private ?ス?ス?ス?ス }
50 public
51 { Public ?ス?ス?ス?ス }
52 end;
53
54 //var
55 // KeySettingForm: TKeySettingForm;
56
57 implementation
58
59 uses Giko;
60
61 {$R *.dfm}
62
63 procedure TKeySettingForm.FormCreate(Sender: TObject);
64 var
65 i: Integer;
66 ListItem: TListItem;
67 KeyItem: TKeySettingItem;
68 begin
69 for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin
70 if GikoForm.ActionList.Actions[i] is TAction then begin
71 if GikoForm.ActionList.Actions[i].Tag <> 0 then
72 Continue;
73 ListItem := ListView.Items.Add;
74 ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint;
75 ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category);
76 ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut));
77 ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex;
78 KeyItem := TKeySettingItem.Create;
79 KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]);
80 KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut;
81 ListItem.Data := KeyItem;
82 end;
83 end;
84 if ListView.Items.Count > 0 then
85 ListView.Selected := ListView.Items[0];
86 // ActionListView.SortType := stText;
87 StatusBar.Height := 21;
88 StatusBar.Width := 21;
89 end;
90
91 procedure TKeySettingForm.FormDestroy(Sender: TObject);
92 var
93 i: Integer;
94 begin
95 for i := 0 to ListView.Items.Count - 1 do begin
96 if TObject(ListView.Items[i].Data) is TKeySettingItem then
97 TKeySettingItem(ListView.Items[i].Data).Free;
98 end;
99 end;
100
101 procedure TKeySettingForm.ListViewSelectItem(Sender: TObject;
102 Item: TListItem; Selected: Boolean);
103 var
104 KeyItem: TKeySettingItem;
105 begin
106 if not Selected then Exit;
107
108 if TObject(Item.Data) is TKeySettingItem then begin
109 KeyItem := TKeySettingItem(Item.Data);
110 HotKey.HotKey := KeyItem.ShortCut;
111 end;
112 end;
113
114 procedure TKeySettingForm.HotKeyEnter(Sender: TObject);
115 begin
116 OkBotton.Default := False;
117 CancelBotton.Cancel := False;
118 end;
119
120 procedure TKeySettingForm.HotKeyExit(Sender: TObject);
121 begin
122 OkBotton.Default := True;
123 CancelBotton.Cancel := True;
124 end;
125
126 procedure TKeySettingForm.FormKeyDown(Sender: TObject; var Key: Word;
127 Shift: TShiftState);
128 begin
129 if Key in [8, 27, 32, 46] then begin
130 HotKey.HotKey := ShortCut(Key, Shift);
131 Key := 0;
132 end;
133 end;
134
135 procedure TKeySettingForm.SetButtonClick(Sender: TObject);
136 const
137 ERR_ENT = 'Enter?スL?ス[?ス?ス?スV?ス?ス?ス[?スg?スJ?スb?スg?ス?ス?ス?ス?ス?ス?スg?スp?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス';
138 ERR_MSG = '?ス?ス?ス?ス?ス?ス?ス?ス?スV?ス?ス?ス[?スg?スJ?スb?スg?ス?ス?ス?ス?ス?ス?スg?スp?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス';
139 ERR_TITLE = '?スG?ス?ス?ス[';
140 var
141 i: Integer;
142 Item: TListItem;
143 KeyItem: TKeySettingItem;
144 begin
145 if ListView.Selected = nil then Exit;
146 if HotKey.HotKey = 13 then begin
147 MsgBox(Handle, ERR_ENT, ERR_TITLE, MB_OK or MB_ICONSTOP);
148 HotKey.SetFocus;
149 Exit;
150 end;
151
152 //?ス?ス?ス?ス?スI?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スAction?ス?ス?スO?ス?ス?ス?ス?ス?ス?スV?ス?ス?ス[?スg?スJ?スb?スg?ス?ス?ス?ス?ス?ス?ス?ス?スG?ス?ス?ス[?ス?ス?ス?ス?ス?ス
153 for i := 0 to ListView.Items.Count - 1 do begin
154 if ListView.Selected = ListView.Items[i] then
155 Continue;
156 Item := ListView.Items[i];
157 if TObject(Item.Data) is TKeySettingItem then begin
158 KeyItem := TKeySettingItem(Item.Data);
159 if (HotKey.HotKey <> 0) and (KeyItem.ShortCut = HotKey.HotKey) then begin
160 MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP);
161 HotKey.SetFocus;
162 Exit;
163 end;
164 end;
165 end;
166 //?スV?ス?ス?ス[?スg?スJ?スb?スg?ス?ス?ス?ス
167 if TObject(ListView.Selected.Data) is TKeySettingItem then begin
168 KeyItem := TKeySettingItem(ListView.Selected.Data);
169 KeyItem.ShortCut := HotKey.HotKey;
170 ListView.Selected.SubItems[1] := ShortCutToText(HotKey.HotKey);
171 end;
172 end;
173
174 procedure TKeySettingForm.OkBottonClick(Sender: TObject);
175 var
176 i: Integer;
177 Item: TListItem;
178 KeyItem: TKeySettingItem;
179 begin
180 for i := 0 to ListView.Items.Count - 1 do begin
181 Item := ListView.Items[i];
182 if TObject(Item.Data) is TKeySettingItem then begin
183 KeyItem := TKeySettingItem(Item.Data);
184 KeyItem.Action.ShortCut := KeyItem.ShortCut;
185 end;
186 end;
187 end;
188
189 procedure TKeySettingForm.ListViewCompare(Sender: TObject; Item1,
190 Item2: TListItem; Data: Integer; var Compare: Integer);
191 begin
192 if Item1.SubItems[0] > Item2.SubItems[0] then
193 Compare := 1
194 else if Item1.SubItems[0] < Item2.SubItems[0] then
195 Compare := -1
196 else
197 Compare := 0;
198 end;
199
200 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26