Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/InputAssist.pas

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


Revision 1.5.2.1 - (show annotations) (download) (as text)
Wed May 31 15:39:42 2006 UTC (17 years, 10 months ago) by h677
Branch: Bb52
CVS Tags: v1_52_1_658, v1_52_1_657, v1_52_0_656
Changes since 1.5: +10 -5 lines
File MIME type: text/x-pascal
ニアー?ホ・ュ。シ。ヲ・ォ・ニ・エ・熙ホセ?酘ノイテ、ヌ、ュ、ハ、、、隍ヲ、ヒス、タオ

1 unit InputAssist;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ComCtrls, GikoListView, Menus, ExtCtrls, ImgList,
8 InputAssistDataModule, StdActns, ActnList, GikoSystem;
9
10 type
11 TInputAssistForm = class(TForm)
12 Panel1: TPanel;
13 Panel2: TPanel;
14 GikoListView1: TGikoListView;
15 Panel3: TPanel;
16 KeyNameEdit: TLabeledEdit;
17 CategoryNameEdit: TLabeledEdit;
18 Panel4: TPanel;
19 TextMemo: TMemo;
20 ColumnImageList: TImageList;
21 InputAssistFormActionList: TActionList;
22 EditCut1: TEditCut;
23 EditCopy1: TEditCopy;
24 EditPaste1: TEditPaste;
25 EditSelectAll1: TEditSelectAll;
26 EditUndo1: TEditUndo;
27 EditDelete1: TEditDelete;
28 GroupBox1: TGroupBox;
29 Panel5: TPanel;
30 CloseButton: TButton;
31 ApplyButton: TButton;
32 DeleteButton: TButton;
33 AddButton: TButton;
34 Panel6: TPanel;
35 Panel7: TPanel;
36 CategoryComboBox: TComboBox;
37 CategoryComboLabel: TLabel;
38 InsertButton: TButton;
39 InsertButtonAction: TAction;
40 CloseAction: TAction;
41 procedure FormCreate(Sender: TObject);
42 procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem;
43 Selected: Boolean);
44 procedure AddButtonClick(Sender: TObject);
45 procedure DeleteButtonClick(Sender: TObject);
46 procedure ApplyButtonClick(Sender: TObject);
47 procedure FormClose(Sender: TObject; var Action: TCloseAction);
48 procedure GikoListView1Compare(Sender: TObject; Item1,
49 Item2: TListItem; Data: Integer; var Compare: Integer);
50 procedure GikoListView1ColumnClick(Sender: TObject;
51 Column: TListColumn);
52 procedure CloseButtonClick(Sender: TObject);
53 procedure CategoryComboBoxKeyPress(Sender: TObject; var Key: Char);
54 procedure CategoryComboBoxChange(Sender: TObject);
55 procedure InsertButtonActionUpdate(Sender: TObject);
56 procedure InsertButtonActionExecute(Sender: TObject);
57 procedure CloseActionExecute(Sender: TObject);
58 private
59 { Private ?ス?ス?ス?ス }
60 FSortColumn : Integer;
61 FInsertText : String;
62 procedure AddListViewItem(ResWord : TResistWord);
63 public
64 { Public ?ス?ス?ス?ス }
65 procedure SetUpFromEditor();
66 procedure SetUpFromMain();
67 function GetInsertText(): String;
68 end;
69
70 var
71 InputAssistForm: TInputAssistForm;
72
73 implementation
74
75 uses Setting, MojuUtils;
76
77
78 {$R *.dfm}
79 //! ?スt?スH?ス[?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
80 procedure TInputAssistForm.FormCreate(Sender: TObject);
81 var
82 wp: TWindowPlacement;
83 i : Integer;
84 column: TListColumn;
85 begin
86 //?スE?スB?ス?ス?スh?スE?ス?ス?ス?ス?スu?ス?ス?ス?ス
87 wp.length := sizeof(wp);
88 wp.rcNormalPosition.Top := GikoSys.Setting.InputAssistFormTop;
89 wp.rcNormalPosition.Left := GikoSys.Setting.InputAssistFormLeft;
90
91 wp.rcNormalPosition.Bottom := GikoSys.Setting.InputAssistFormTop
92 + GikoSys.Setting.InputAssistFormHeight;
93 wp.rcNormalPosition.Right := GikoSys.Setting.InputAssistFormLeft
94 + GikoSys.Setting.InputAssistFormWidth;
95 wp.showCmd := SW_HIDE;
96 SetWindowPlacement(Handle, @wp);
97
98 FSortColumn := 0;
99 GikoListView1.Columns.Clear;
100 column := GikoListView1.Columns.Add;
101 column.ImageIndex := 0;
102 column.Caption := '?スL?ス[';
103 column.Width := 150;
104 column := GikoListView1.Columns.Add;
105 column.Caption := '?スJ?スe?スS?ス?ス';
106 column.Width := 80;
107 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
108 AddListViewItem(InputAssistDM.GetResistWord(i));
109 end;
110 //?ス\?ス[?スg?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス (?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スA?スC?スe?ス?ス?ス?ス?スL?ス[?ス?ス?ス?ス?ス?ス?スX?ス?ス?ス?ス?ス?ス?ス?ス)
111 InputAssistDM.Sorted := False;
112 end;
113 //! ?ス?ス?ス?ス?ス?ス?スA?スC?スe?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス
114 procedure TInputAssistForm.AddListViewItem(ResWord : TResistWord);
115 var
116 item: TListItem;
117 begin
118 item := GikoListView1.Items.Add;
119 item.ImageIndex := -1;
120 item.Caption := resWord.GetKey;
121 item.SubItems.Add(resWord.GetCategory);
122 item.Data := resWord;
123 end;
124 //! ?スo?ス^?スP?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スA?スC?スe?ス?ス?ス?ス?スI?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
125 procedure TInputAssistForm.GikoListView1SelectItem(Sender: TObject;
126 Item: TListItem; Selected: Boolean);
127 begin
128 if (Item <> nil) and (Item.Data <> nil) then begin
129 KeyNameEdit.Text := TResistWord(Item.Data).GetKey;
130 CategoryNameEdit.Text := TResistWord(Item.Data).GetCategory;
131 TextMemo.Lines.Text := TResistWord(Item.Data).GetText;
132 end else begin
133 TextMemo.Lines.Text := '';
134 end;
135 end;
136 //! ?ス?ス?ス?ス?ス{?ス^?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
137 procedure TInputAssistForm.AddButtonClick(Sender: TObject);
138 var
139 resWord : TResistWord;
140 begin
141 if (Length(KeyNameEdit.Text) = 0) then begin
142 ShowMessage('?スL?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スB');
143 end else begin
144 if (not InputAssistDM.IsDupulicate(
145 KeyNameEdit.Text, CategoryNameEdit.Text) ) then begin
146 resWord := InputAssistDM.Add(KeyNameEdit.Text);
147 resWord.SetCategory(CategoryNameEdit.Text);
148 resWord.SetText(TextMemo.Text);
149 AddListViewItem(resWord);
150 GikoListView1.AlphaSort;
151 end else begin
152 ShowMessage('?ス?ス?ス?ス?ス?ス?スL?ス[?ス?ス?スE?スJ?スe?スS?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スo?ス^?ス?ス?ス?ス?ス?ス?ス?ス?スB');
153 end;
154 end;
155 end;
156 //! ?ス?ス?ス?ス?ス{?ス^?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
157 procedure TInputAssistForm.DeleteButtonClick(Sender: TObject);
158 begin
159 if GikoListView1.Selected <> nil then begin
160 InputAssistDM.DeleteResistWord(GikoListView1.Selected.Data);
161 GikoListView1.Selected.Data := nil;
162 GikoListView1.DeleteSelected;
163 end;
164 end;
165 //! ?スK?スp?ス{?ス^?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
166 procedure TInputAssistForm.ApplyButtonClick(Sender: TObject);
167 var
168 resWord : TResistWord;
169 begin
170 if GikoListView1.Selected <> nil then begin
171 if (Length(KeyNameEdit.Text) = 0) then begin
172 ShowMessage('?スL?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スB');
173 end else begin
174 resWord := TResistWord(GikoListView1.Selected.Data);
175 resWord.SetKey(KeyNameEdit.Text);
176 resWord.SetCategory(CategoryNameEdit.Text);
177 resWord.SetText(TextMemo.Text);
178 // ?ス?ス?ス?ス?ス?ス?スX?スV
179 GikoListView1.Selected.Caption := resWord.GetKey;
180 GikoListView1.Selected.SubItems[0] := resWord.GetCategory;
181 GikoListView1.AlphaSort;
182 end;
183 end;
184 end;
185 //! ?スt?スH?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
186 procedure TInputAssistForm.FormClose(Sender: TObject;
187 var Action: TCloseAction);
188 begin
189 GikoSys.Setting.InputAssistFormTop := Self.Top;
190 GikoSys.Setting.InputAssistFormLeft := Self.Left;
191 GikoSys.Setting.InputAssistFormHeight := Self.Height;
192 GikoSys.Setting.InputAssistFormWidth := Self.Width;
193 //?ス\?ス[?スg?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス
194 InputAssistDM.Sorted := True;
195 end;
196 //! ?スo?ス^?スP?ス?ス?ス?ス?ス?ス?ス?ス?ス\?ス[?スg?スp?ス?ス?ス?ス?スr?ス?ス?ス?ス
197 procedure TInputAssistForm.GikoListView1Compare(Sender: TObject; Item1,
198 Item2: TListItem; Data: Integer; var Compare: Integer);
199 begin
200 if ((FSortColumn and 2) > 0) then begin
201 // ?スJ?スe?スS?ス?ス?ス?ス?ス\?ス[?スg
202 Compare := CompareStr(
203 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
204 if (Compare = 0) then begin
205 Compare := CompareStr(
206 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
207 end;
208 end else begin
209 // ?スL?ス[?ス?ス?ス\?ス[?スg
210 Compare := CompareStr(
211 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
212 if (Compare = 0) then begin
213 Compare := CompareStr(
214 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
215 end;
216 end;
217 // ?ス?ス?ス?ス?ス~?ス?ス?ス?ス?ス?ス?ス]
218 if ((FSortColumn and 1) > 0) then begin
219 Compare := Compare * -1;
220 end;
221 ;
222 end;
223 //! ?スo?ス^?スP?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スX?スg?ス?ス?スJ?ス?ス?ス?ス?スN?ス?ス?スb?スN?スC?スx?ス?ス?スg
224 procedure TInputAssistForm.GikoListView1ColumnClick(Sender: TObject;
225 Column: TListColumn);
226 var
227 i : Integer;
228 begin
229 if Column <> nil then begin
230 // ?スC?ス?ス?ス[?スW?ス?ス?ス?ス?ス?ス
231 for i := 0 to GikoListView1.Columns.Count - 1 do begin
232 GikoListView1.Column[i].ImageIndex := -1;
233 end;
234
235 // FSortColumn ?ス?ス?ス?ス:?ス?ス?ス?ス ?ス?ス?ス?ス?スF?ス~?ス?ス
236 if Column.Caption = '?スL?ス[' then begin
237 if FSortColumn = 0 then begin
238 FSortColumn := 1;
239 end else begin
240 FSortColumn := 0;
241 end;
242 end else begin
243 if FSortColumn = 2 then begin
244 FSortColumn := 3;
245 end else begin
246 FSortColumn := 2;
247 end;
248 end;
249 Column.ImageIndex := (FSortColumn and 1);
250 GikoListView1.AlphaSort;
251 end;
252
253 end;
254 //! ?スI?ス?ス?ス{?ス^?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg
255 procedure TInputAssistForm.CloseButtonClick(Sender: TObject);
256 begin
257 Close();
258 end;
259 //! ?スJ?スe?スS?ス?ス?スi?ス?ス?ス?ス?スR?ス?ス?ス{?ス{?スb?スN?スX?ス?ス?ス?ス?ス?ス?ス?ス?スp?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スC?スx?ス?ス?スg?ス?ス?ス?ス
260 procedure TInputAssistForm.CategoryComboBoxKeyPress(Sender: TObject;
261 var Key: Char);
262 begin
263 Key := #0;
264 end;
265 //! ?スJ?スe?スS?ス?ス?スi?ス?ス?ス?ス?スR?ス?ス?ス{?ス{?スb?スN?スX?ス?ス?ス?ス?スJ?スe?スS?ス?ス?ス?ス?スX?ス?ス?ス?ス
266 procedure TInputAssistForm.CategoryComboBoxChange(Sender: TObject);
267 var
268 i : Integer;
269 key : String;
270 begin
271 LockWindowUpdate(GikoListView1.Handle);
272 GikoListView1.Clear;
273 if (CategoryComboBox.ItemIndex <= 0) then begin
274 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
275 AddListViewItem(InputAssistDM.GetResistWord(i));
276 end;
277 end else begin
278 key := CategoryComboBox.Items[CategoryComboBox.ItemIndex];
279 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
280 if (key = InputAssistDM.GetResistWord(i).GetCategory) then begin
281 AddListViewItem(InputAssistDM.GetResistWord(i));
282 end;
283 end;
284 end;
285 LockWindowUpdate(0);
286 end;
287
288 procedure TInputAssistForm.SetUpFromMain();
289 begin
290 Self.Caption := '?ス?ス?ス?ス?スA?スV?スX?スg?ス?ス?ス?ス';
291 Panel3.Visible := True;
292 Panel5.Visible := True;
293 Panel7.Visible := False;
294 TextMemo.ReadOnly := False;
295 FInsertText := '';
296 CloseAction.ShortCut := TShortCut(0);
297 end;
298 procedure TInputAssistForm.SetUpFromEditor();
299 var
300 cat : TStringList;
301 begin
302 Self.Caption := '?ス?ス?ス?ス?スA?スV?スX?スg';
303 Panel3.Visible := False;
304 Panel5.Visible := False;
305 Panel7.Visible := True;
306 TextMemo.ReadOnly := True;
307 FInsertText := '';
308 CloseAction.ShortCut := ShortCut(VK_ESCAPE, []);
309 // ?ス?ス?ス?ス?スp
310 cat := TStringList.Create;
311 try
312 InputAssistDM.GetCategoryList(cat);
313 CategoryComboBox.Items.Clear;
314 CategoryComboBox.Items.Add('');
315 CategoryComboBox.Items.AddStrings(cat);
316 CategoryComboBox.ItemIndex := 0;
317 finally
318 cat.Free;
319 end;
320 end;
321 function TInputAssistForm.GetInsertText(): String;
322 begin
323 Result := FInsertText;
324 end;
325
326 procedure TInputAssistForm.InsertButtonActionUpdate(Sender: TObject);
327 begin
328 InsertButtonAction.Enabled := (GikoListView1.Selected <> nil);
329 end;
330
331 procedure TInputAssistForm.InsertButtonActionExecute(Sender: TObject);
332 begin
333 if (GikoListView1.Selected = nil) then begin
334 FInsertText := '';
335 Self.ModalResult := mrNone;
336 end else begin
337 FInsertText := TResistWord(GikoListView1.Selected.Data).GetText;
338 Self.ModalResult := mrOk;
339 end;
340 end;
341
342 procedure TInputAssistForm.CloseActionExecute(Sender: TObject);
343 begin
344 Self.ModalResult := mrCancel;
345 end;
346
347 end.

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