6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ComCtrls, GikoListView, Menus, ExtCtrls, ImgList,
8 InputAssistDataModule, StdActns, ActnList, GikoSystem;
11 TInputAssistForm = class(TForm)
14 GikoListView1: TGikoListView;
16 KeyNameEdit: TLabeledEdit;
17 CategoryNameEdit: TLabeledEdit;
20 ColumnImageList: TImageList;
21 InputAssistFormActionList: TActionList;
24 EditPaste1: TEditPaste;
25 EditSelectAll1: TEditSelectAll;
27 EditDelete1: TEditDelete;
32 DeleteButton: TButton;
36 CategoryComboBox: TComboBox;
37 CategoryComboLabel: TLabel;
38 InsertButton: TButton;
39 InsertButtonAction: TAction;
41 procedure FormCreate(Sender: TObject);
42 procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem;
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;
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);
60 FSortColumn : Integer;
62 procedure AddListViewItem(ResWord : TResistWord);
65 procedure SetUpFromEditor();
66 procedure SetUpFromMain();
67 function GetInsertText(): String;
71 InputAssistForm: TInputAssistForm;
75 uses Setting, MojuUtils;
79 //!
\83t
\83H
\81[
\83\80\90¶
\90¬
\82Ì
\83C
\83x
\83\93\83g
80 procedure TInputAssistForm.FormCreate(Sender: TObject);
86 //
\83E
\83B
\83\93\83h
\83E
\82Ì
\88Ê
\92u
\90Ý
\92è
87 wp.length := sizeof(wp);
88 wp.rcNormalPosition.Top := GikoSys.Setting.InputAssistFormTop;
89 wp.rcNormalPosition.Left := GikoSys.Setting.InputAssistFormLeft;
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);
99 GikoListView1.Columns.Clear;
100 column := GikoListView1.Columns.Add;
101 column.ImageIndex := 0;
102 column.Caption := '
\83L
\81[';
104 column := GikoListView1.Columns.Add;
105 column.Caption := '
\83J
\83e
\83S
\83\8a';
107 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
108 AddListViewItem(InputAssistDM.GetResistWord(i));
110 //
\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¢)
111 InputAssistDM.Sorted := False;
113 //!
\88ê
\97\97\82É
\83A
\83C
\83e
\83\80\82ð
\92Ç
\89Á
\82·
\82é
\8f\88\97\9d
114 procedure TInputAssistForm.AddListViewItem(ResWord : TResistWord);
118 item := GikoListView1.Items.Add;
119 item.ImageIndex := -1;
120 item.Caption := resWord.GetKey;
121 item.SubItems.Add(resWord.GetCategory);
122 item.Data := resWord;
124 //!
\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
125 procedure TInputAssistForm.GikoListView1SelectItem(Sender: TObject;
126 Item: TListItem; Selected: Boolean);
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;
133 TextMemo.Lines.Text := '';
136 //!
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
137 procedure TInputAssistForm.AddButtonClick(Sender: TObject);
139 resWord : TResistWord;
141 if (Length(KeyNameEdit.Text) = 0) then begin
142 ShowMessage('
\83L
\81[
\96¼
\82ð
\90Ý
\92è
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B');
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;
152 ShowMessage('
\93¯
\88ê
\82Ì
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\96¼
\82Å
\8aù
\82É
\93o
\98^
\8dÏ
\82Ý
\82Å
\82·
\81B');
156 //!
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
157 procedure TInputAssistForm.DeleteButtonClick(Sender: TObject);
159 if GikoListView1.Selected <> nil then begin
160 InputAssistDM.DeleteResistWord(GikoListView1.Selected.Data);
161 GikoListView1.Selected.Data := nil;
162 GikoListView1.DeleteSelected;
165 //!
\93K
\97p
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
166 procedure TInputAssistForm.ApplyButtonClick(Sender: TObject);
168 resWord : TResistWord;
170 if GikoListView1.Selected <> nil then begin
171 if (Length(KeyNameEdit.Text) = 0) then begin
172 ShowMessage('
\83L
\81[
\96¼
\82ð
\96³
\82µ
\82É
\82Í
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B');
174 resWord := TResistWord(GikoListView1.Selected.Data);
175 resWord.SetKey(KeyNameEdit.Text);
176 resWord.SetCategory(CategoryNameEdit.Text);
177 resWord.SetText(TextMemo.Text);
178 //
\88ê
\97\97\82Ì
\8dX
\90V
179 GikoListView1.Selected.Caption := resWord.GetKey;
180 GikoListView1.Selected.SubItems[0] := resWord.GetCategory;
181 GikoListView1.AlphaSort;
185 //!
\83t
\83H
\81[
\83\80\82ð
\95Â
\82¶
\82é
\82Æ
\82«
\82Ì
\83C
\83x
\83\93\83g
186 procedure TInputAssistForm.FormClose(Sender: TObject;
187 var Action: TCloseAction);
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 //
\83\
\81[
\83g
\8fó
\91Ô
\82Ì
\90Ý
\92è
194 InputAssistDM.Sorted := True;
196 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82Ì
\83\
\81[
\83g
\97p
\82Ì
\94ä
\8ar
\8f\88\97\9d
197 procedure TInputAssistForm.GikoListView1Compare(Sender: TObject; Item1,
198 Item2: TListItem; Data: Integer; var Compare: Integer);
200 if ((FSortColumn and 2) > 0) then begin
201 //
\83J
\83e
\83S
\83\8a\82Å
\83\
\81[
\83g
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));
209 //
\83L
\81[
\82Å
\83\
\81[
\83g
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]));
217 //
\8f¸
\8f\87\8d~
\8f\87\82Ì
\94½
\93]
218 if ((FSortColumn and 1) > 0) then begin
219 Compare := Compare * -1;
223 //!
\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
224 procedure TInputAssistForm.GikoListView1ColumnClick(Sender: TObject;
225 Column: TListColumn);
229 if Column <> nil then begin
230 //
\83C
\83\81\81[
\83W
\82Ì
\8dí
\8f\9c
231 for i := 0 to GikoListView1.Columns.Count - 1 do begin
232 GikoListView1.Column[i].ImageIndex := -1;
235 // FSortColumn
\8bô
\90\94:
\8f¸
\8f\87 \8aï
\90\94\81F
\8d~
\8f\87
236 if Column.Caption = '
\83L
\81[' then begin
237 if FSortColumn = 0 then begin
243 if FSortColumn = 2 then begin
249 Column.ImageIndex := (FSortColumn and 1);
250 GikoListView1.AlphaSort;
254 //!
\8fI
\97¹
\83{
\83^
\83\93\82ð
\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
255 procedure TInputAssistForm.CloseButtonClick(Sender: TObject);
259 //!
\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
260 procedure TInputAssistForm.CategoryComboBoxKeyPress(Sender: TObject;
265 //!
\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
266 procedure TInputAssistForm.CategoryComboBoxChange(Sender: TObject);
271 LockWindowUpdate(GikoListView1.Handle);
273 if (CategoryComboBox.ItemIndex <= 0) then begin
274 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
275 AddListViewItem(InputAssistDM.GetResistWord(i));
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));
288 procedure TInputAssistForm.SetUpFromMain();
290 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g
\90Ý
\92è';
291 Panel3.Visible := True;
292 Panel5.Visible := True;
293 Panel7.Visible := False;
294 TextMemo.ReadOnly := False;
296 CloseAction.ShortCut := TShortCut(0);
298 procedure TInputAssistForm.SetUpFromEditor();
302 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g';
303 Panel3.Visible := False;
304 Panel5.Visible := False;
305 Panel7.Visible := True;
306 TextMemo.ReadOnly := True;
308 CloseAction.ShortCut := ShortCut(VK_ESCAPE, []);
310 cat := TStringList.Create;
312 InputAssistDM.GetCategoryList(cat);
313 CategoryComboBox.Items.Clear;
314 CategoryComboBox.Items.Add('');
315 CategoryComboBox.Items.AddStrings(cat);
316 CategoryComboBox.ItemIndex := 0;
321 function TInputAssistForm.GetInsertText(): String;
323 Result := FInsertText;
326 procedure TInputAssistForm.InsertButtonActionUpdate(Sender: TObject);
328 InsertButtonAction.Enabled := (GikoListView1.Selected <> nil);
331 procedure TInputAssistForm.InsertButtonActionExecute(Sender: TObject);
333 if (GikoListView1.Selected = nil) then begin
335 Self.ModalResult := mrNone;
337 FInsertText := TResistWord(GikoListView1.Selected.Data).GetText;
338 Self.ModalResult := mrOk;
342 procedure TInputAssistForm.CloseActionExecute(Sender: TObject);
344 Self.ModalResult := mrCancel;