6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ComCtrls, GikoListView, Menus, ExtCtrls, ImgList,
8 InputAssistDataModule, StdActns, ActnList, GikoSystem, IniFiles;
11 TInputAssistForm = class(TForm)
14 GikoListView1: TGikoListView;
18 ColumnImageList: TImageList;
19 InputAssistFormActionList: TActionList;
22 EditPaste1: TEditPaste;
23 EditSelectAll1: TEditSelectAll;
25 EditDelete1: TEditDelete;
30 DeleteButton: TButton;
34 CategoryComboBox: TComboBox;
35 CategoryComboLabel: TLabel;
36 InsertButton: TButton;
37 InsertButtonAction: TAction;
40 KeyNameEdit: TLabeledEdit;
42 CategoryPanel: TPanel;
43 CategoryNameComboBox: TComboBox;
44 CategoryNameLabel: TLabel;
46 procedure FormCreate(Sender: TObject);
47 procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem;
49 procedure AddButtonClick(Sender: TObject);
50 procedure DeleteButtonClick(Sender: TObject);
51 procedure ApplyButtonClick(Sender: TObject);
52 procedure FormClose(Sender: TObject; var Action: TCloseAction);
53 procedure GikoListView1Compare(Sender: TObject; Item1,
54 Item2: TListItem; Data: Integer; var Compare: Integer);
55 procedure GikoListView1ColumnClick(Sender: TObject;
57 procedure CloseButtonClick(Sender: TObject);
58 procedure CategoryComboBoxKeyPress(Sender: TObject; var Key: Char);
59 procedure CategoryComboBoxChange(Sender: TObject);
60 procedure InsertButtonActionUpdate(Sender: TObject);
61 procedure InsertButtonActionExecute(Sender: TObject);
62 procedure CloseActionExecute(Sender: TObject);
63 procedure DiffButtonClick(Sender: TObject);
66 FSortColumn : Integer;
68 procedure AddListViewItem(ResWord : TResistWord);
69 procedure SetCategory(combo: TComboBox; selected: String);
70 function ValidateKey(key, category: String): boolean;
73 procedure SetUpFromEditor();
74 procedure SetUpFromMain();
75 function GetInsertText(): String;
79 InputAssistForm: TInputAssistForm;
83 uses Setting, MojuUtils;
87 //!
\83t
\83H
\81[
\83\80\90¶
\90¬
\82Ì
\83C
\83x
\83\93\83g
88 procedure TInputAssistForm.FormCreate(Sender: TObject);
94 //
\83E
\83B
\83\93\83h
\83E
\82Ì
\88Ê
\92u
\90Ý
\92è
95 wp.length := sizeof(wp);
96 wp.rcNormalPosition.Top := GikoSys.Setting.InputAssistFormTop;
97 wp.rcNormalPosition.Left := GikoSys.Setting.InputAssistFormLeft;
99 wp.rcNormalPosition.Bottom := GikoSys.Setting.InputAssistFormTop
100 + GikoSys.Setting.InputAssistFormHeight;
101 wp.rcNormalPosition.Right := GikoSys.Setting.InputAssistFormLeft
102 + GikoSys.Setting.InputAssistFormWidth;
103 wp.showCmd := SW_HIDE;
104 SetWindowPlacement(Handle, @wp);
107 GikoListView1.Columns.Clear;
108 column := GikoListView1.Columns.Add;
109 column.ImageIndex := 0;
110 column.Caption := '
\83L
\81[';
112 column := GikoListView1.Columns.Add;
113 column.Caption := '
\83J
\83e
\83S
\83\8a';
115 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
116 AddListViewItem(InputAssistDM.GetResistWord(i));
118 //
\83\
\81[
\83g
\8fó
\91Ô
\82ð
\89ð
\8f\9c (
\89ð
\8f\9c\82µ
\82È
\82¢
\82Æ
\83A
\83C
\83e
\83\80\82Ì
\83L
\81[
\96¼
\82ð
\95Ï
\8dX
\82Å
\82«
\82È
\82¢)
119 InputAssistDM.Sorted := False;
121 //!
\88ê
\97\97\82É
\83A
\83C
\83e
\83\80\82ð
\92Ç
\89Á
\82·
\82é
\8f\88\97\9d
122 procedure TInputAssistForm.AddListViewItem(ResWord : TResistWord);
126 item := GikoListView1.Items.Add;
127 item.ImageIndex := -1;
128 item.Caption := resWord.GetKey;
129 item.SubItems.Add(resWord.GetCategory);
130 item.Data := resWord;
132 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82©
\82ç
\83A
\83C
\83e
\83\80\82ð
\91I
\91ð
\82µ
\82½
\82Æ
\82«
\82Ì
\83C
\83x
\83\93\83g
133 procedure TInputAssistForm.GikoListView1SelectItem(Sender: TObject;
134 Item: TListItem; Selected: Boolean);
136 if (Item <> nil) and (Item.Data <> nil) then begin
137 KeyNameEdit.Text := TResistWord(Item.Data).GetKey;
138 CategoryNameComboBox.Text := TResistWord(Item.Data).GetCategory;
139 TextMemo.Lines.Text := TResistWord(Item.Data).GetText;
141 TextMemo.Lines.Text := '';
144 //!
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
145 procedure TInputAssistForm.AddButtonClick(Sender: TObject);
147 resWord : TResistWord;
149 if (ValidateKey(KeyNameEdit.Text, CategoryNameComboBox.Text)) then begin
150 if (not InputAssistDM.IsDupulicate(
151 KeyNameEdit.Text, CategoryNameComboBox.Text) ) then begin
152 resWord := InputAssistDM.Add(KeyNameEdit.Text);
153 resWord.SetCategory(CategoryNameComboBox.Text);
154 resWord.SetText(TextMemo.Text);
155 AddListViewItem(resWord);
156 SetCategory(CategoryNameComboBox, resWord.GetCategory);
157 GikoListView1.AlphaSort;
159 ShowMessage('
\93¯
\88ê
\82Ì
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\96¼
\82Å
\8aù
\82É
\93o
\98^
\8dÏ
\82Ý
\82Å
\82·
\81B');
163 //!
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\97L
\8cø
\83`
\83F
\83b
\83N
164 function TInputAssistForm.ValidateKey(key, category: String): boolean;
167 if (Length(key) = 0) then begin
168 ShowMessage('
\83L
\81[
\96¼
\82ð
\90Ý
\92è
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B');
171 if (Length(category) = 0) then begin
172 ShowMessage('
\83J
\83e
\83S
\83\8a\82ð
\90Ý
\92è
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B');
178 //!
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
179 procedure TInputAssistForm.DeleteButtonClick(Sender: TObject);
181 if GikoListView1.Selected <> nil then begin
182 InputAssistDM.DeleteResistWord(GikoListView1.Selected.Data);
183 GikoListView1.Selected.Data := nil;
184 GikoListView1.DeleteSelected;
187 //!
\93K
\97p
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
188 procedure TInputAssistForm.ApplyButtonClick(Sender: TObject);
190 resWord : TResistWord;
192 if GikoListView1.Selected <> nil then begin
193 if (ValidateKey(KeyNameEdit.Text, CategoryNameComboBox.Text)) then begin
194 resWord := TResistWord(GikoListView1.Selected.Data);
195 //
\95Ï
\8dX
\91O
\82Ì
\83L
\81[
\81^
\83J
\83e
\83S
\83\8a\82Æ
\93¯
\88ê
\82à
\82µ
\82
\82Í
\81A
\91¼
\82Æ
\8fd
\95¡
\96³
\82µ
196 if ((resWord.GetKey = KeyNameEdit.Text)
197 and (resWord.GetCategory = CategoryNameComboBox.Text)) or
198 (not InputAssistDM.IsDupulicate(
199 KeyNameEdit.Text, CategoryNameComboBox.Text) ) then begin
200 resWord.SetCategory(CategoryNameComboBox.Text);
201 resWord.SetText(TextMemo.Text);
202 //
\83L
\81[
\82ª
\95Ï
\82í
\82é
\82Æ
\82«
\82Í
\81AChangeKey
\82ð
\8cÄ
\82Ô
203 if (resWord.GetKey <> KeyNameEdit.Text) then begin
204 resWord.SetKey(KeyNameEdit.Text);
205 InputAssistDM.ChangeKey(resWord);
207 //
\88ê
\97\97\82Ì
\8dX
\90V
208 GikoListView1.Selected.Caption := resWord.GetKey;
209 GikoListView1.Selected.SubItems[0] := resWord.GetCategory;
210 SetCategory(CategoryNameComboBox, resWord.GetCategory);
211 GikoListView1.AlphaSort;
213 ShowMessage('
\93¯
\88ê
\82Ì
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\96¼
\82Å
\8aù
\82É
\93o
\98^
\8dÏ
\82Ý
\82Å
\82·
\81B');
218 //!
\83t
\83H
\81[
\83\80\82ð
\95Â
\82¶
\82é
\82Æ
\82«
\82Ì
\83C
\83x
\83\93\83g
219 procedure TInputAssistForm.FormClose(Sender: TObject;
220 var Action: TCloseAction);
222 GikoSys.Setting.InputAssistFormTop := Self.Top;
223 GikoSys.Setting.InputAssistFormLeft := Self.Left;
224 GikoSys.Setting.InputAssistFormHeight := Self.Height;
225 GikoSys.Setting.InputAssistFormWidth := Self.Width;
226 //
\83\
\81[
\83g
\8fó
\91Ô
\82Ì
\90Ý
\92è
227 InputAssistDM.Sorted := True;
229 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82Ì
\83\
\81[
\83g
\97p
\82Ì
\94ä
\8ar
\8f\88\97\9d
230 procedure TInputAssistForm.GikoListView1Compare(Sender: TObject; Item1,
231 Item2: TListItem; Data: Integer; var Compare: Integer);
233 if ((FSortColumn and 2) > 0) then begin
234 //
\83J
\83e
\83S
\83\8a\82Å
\83\
\81[
\83g
235 Compare := CompareStr(
236 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
237 if (Compare = 0) then begin
238 Compare := CompareStr(
239 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
242 //
\83L
\81[
\82Å
\83\
\81[
\83g
243 Compare := CompareStr(
244 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
245 if (Compare = 0) then begin
246 Compare := CompareStr(
247 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
250 //
\8f¸
\8f\87\8d~
\8f\87\82Ì
\94½
\93]
251 if ((FSortColumn and 1) > 0) then begin
252 Compare := Compare * -1;
256 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82Ì
\83\8a\83X
\83g
\82Ì
\83J
\83\89\83\80\83N
\83\8a\83b
\83N
\83C
\83x
\83\93\83g
257 procedure TInputAssistForm.GikoListView1ColumnClick(Sender: TObject;
258 Column: TListColumn);
262 if Column <> nil then begin
263 //
\83C
\83\81\81[
\83W
\82Ì
\8dí
\8f\9c
264 for i := 0 to GikoListView1.Columns.Count - 1 do begin
265 GikoListView1.Column[i].ImageIndex := -1;
268 // FSortColumn
\8bô
\90\94:
\8f¸
\8f\87 \8aï
\90\94\81F
\8d~
\8f\87
269 if Column.Caption = '
\83L
\81[' then begin
270 if FSortColumn = 0 then begin
276 if FSortColumn = 2 then begin
282 Column.ImageIndex := (FSortColumn and 1);
283 GikoListView1.AlphaSort;
287 //!
\8fI
\97¹
\83{
\83^
\83\93\82ð
\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
288 procedure TInputAssistForm.CloseButtonClick(Sender: TObject);
292 //!
\83J
\83e
\83S
\83\8a\8di
\8d\9e\82Ý
\83R
\83\93\83{
\83{
\83b
\83N
\83X
\82ð
\93Ç
\8eæ
\90ê
\97p
\82É
\82·
\82é
\82½
\82ß
\82Ì
\83C
\83x
\83\93\83g
\8f\88\97\9d
293 procedure TInputAssistForm.CategoryComboBoxKeyPress(Sender: TObject;
298 //!
\83J
\83e
\83S
\83\8a\8di
\8d\9e\82Ý
\83R
\83\93\83{
\83{
\83b
\83N
\83X
\82Å
\82Ì
\83J
\83e
\83S
\83\8a\95Ï
\8dX
\8f\88\97\9d
299 procedure TInputAssistForm.CategoryComboBoxChange(Sender: TObject);
304 LockWindowUpdate(GikoListView1.Handle);
306 if (CategoryComboBox.ItemIndex <= 0) then begin
307 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
308 AddListViewItem(InputAssistDM.GetResistWord(i));
311 key := CategoryComboBox.Items[CategoryComboBox.ItemIndex];
312 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
313 if (key = InputAssistDM.GetResistWord(i).GetCategory) then begin
314 AddListViewItem(InputAssistDM.GetResistWord(i));
320 //!
\83J
\83e
\83S
\83\8a\83R
\83\93\83{
\83{
\83b
\83N
\83X
\90Ý
\92è
321 procedure TInputAssistForm.SetCategory(combo: TComboBox; selected: String);
327 cat := TStringList.Create;
329 InputAssistDM.GetCategoryList(cat);
330 combo.Items.BeginUpdate;
333 combo.Items.AddStrings(cat);
334 combo.ItemIndex := 0;
335 combo.Items.EndUpdate;
336 //
\91I
\91ð
\8dÏ
\82Ý
\82Ì
\83J
\83e
\83S
\83\8a\82É
\83C
\83\93\83f
\83b
\83N
\83X
\82ð
\95Ï
\8dX
337 i := combo.Items.IndexOf(selected);
338 if (i <> -1) then begin
339 combo.ItemIndex := i;
346 procedure TInputAssistForm.SetUpFromMain();
348 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g
\90Ý
\92è';
349 Panel3.Visible := True;
350 Panel5.Visible := True;
351 Panel7.Visible := False;
352 TextMemo.ReadOnly := False;
354 CloseAction.ShortCut := TShortCut(0);
355 //
\92Ç
\89Á
\97p
\83L
\81[
\93ü
\97ÍOK
356 SetCategory(CategoryNameComboBox, '');
358 procedure TInputAssistForm.SetUpFromEditor();
360 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g';
361 Panel3.Visible := False;
362 Panel5.Visible := False;
363 Panel7.Visible := True;
364 TextMemo.ReadOnly := True;
366 CloseAction.ShortCut := ShortCut(VK_ESCAPE, []);
368 SetCategory(CategoryComboBox, '');
370 function TInputAssistForm.GetInsertText(): String;
372 Result := FInsertText;
375 procedure TInputAssistForm.InsertButtonActionUpdate(Sender: TObject);
377 InsertButtonAction.Enabled := (GikoListView1.Selected <> nil);
380 procedure TInputAssistForm.InsertButtonActionExecute(Sender: TObject);
382 if (GikoListView1.Selected = nil) then begin
384 Self.ModalResult := mrNone;
386 FInsertText := TResistWord(GikoListView1.Selected.Data).GetText;
387 Self.ModalResult := mrOk;
391 procedure TInputAssistForm.CloseActionExecute(Sender: TObject);
393 Self.ModalResult := mrCancel;
396 procedure TInputAssistForm.DiffButtonClick(Sender: TObject);
400 SecList: TStringList;
401 KeyList: TStringList;
408 resWord : TResistWord;
411 ini := TIniFile.Create(GikoSys.Setting.GetDefaultFilesFileName);
412 DefPath := ini.ReadString('InputAssist', 'FROM', '');
414 if (DefPath = '') then begin
415 Application.MessageBox('default
\83t
\83@
\83C
\83\8b\82ª
\92è
\8b`
\82³
\82ê
\82Ä
\82¢
\82Ü
\82¹
\82ñ
\81B', '
\8d·
\95ª
\93o
\98^', MB_OK or MB_ICONERROR);
419 DefPath := GikoSys.GetAppDir + DefPath;
420 if (FileExists(DefPath) = False) then begin
421 Application.MessageBox('default
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\81B', '
\8d·
\95ª
\93o
\98^', MB_OK or MB_ICONERROR);
426 SecList := TStringList.Create;
427 ini := TIniFile.Create(DefPath);
429 ini.ReadSections(SecList);
430 if (SecList.Count > 0) then begin
431 KeyList := TStringList.Create;
432 MaxCnt := SecList.Count - 1;
433 for Cnt := 0 to MaxCnt do begin;
435 ini.ReadSection(SecList.Strings[Cnt], KeyList);
436 if (KeyList.Count > 0) then begin;
437 MaxCnt2 := KeyList.Count - 1;
438 for Cnt2 := 0 to MaxCnt2 do begin
439 DatString := ini.ReadString(SecList.Strings[Cnt], KeyList.Strings[Cnt2], '');
440 if (DatString = '') then
443 if (not InputAssistDM.IsDupulicate(
444 KeyList.Strings[Cnt2], SecList.Strings[Cnt]) ) then begin
445 resWord := InputAssistDM.Add(KeyList.Strings[Cnt2]);
446 resWord.SetCategory(SecList.Strings[Cnt]);
447 resWord.SetText(DatString);
448 AddListViewItem(resWord);
449 RegCnt := RegCnt + 1;
460 if (RegCnt > 0) then begin
461 SetCategory(CategoryNameComboBox, '');
462 GikoListView1.AlphaSort;
465 ResMsg := IntToStr(RegCnt) + '
\8c\8f\93o
\98^
\82µ
\82Ü
\82µ
\82½
\81B';
466 Application.MessageBox(PChar(ResMsg), '
\8d·
\95ª
\93o
\98^', MB_OK or MB_ICONINFORMATION);