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;
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;
45 procedure FormCreate(Sender: TObject);
46 procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem;
48 procedure AddButtonClick(Sender: TObject);
49 procedure DeleteButtonClick(Sender: TObject);
50 procedure ApplyButtonClick(Sender: TObject);
51 procedure FormClose(Sender: TObject; var Action: TCloseAction);
52 procedure GikoListView1Compare(Sender: TObject; Item1,
53 Item2: TListItem; Data: Integer; var Compare: Integer);
54 procedure GikoListView1ColumnClick(Sender: TObject;
56 procedure CloseButtonClick(Sender: TObject);
57 procedure CategoryComboBoxKeyPress(Sender: TObject; var Key: Char);
58 procedure CategoryComboBoxChange(Sender: TObject);
59 procedure InsertButtonActionUpdate(Sender: TObject);
60 procedure InsertButtonActionExecute(Sender: TObject);
61 procedure CloseActionExecute(Sender: TObject);
64 FSortColumn : Integer;
66 procedure AddListViewItem(ResWord : TResistWord);
67 procedure SetCategory(combo: TComboBox);
70 procedure SetUpFromEditor();
71 procedure SetUpFromMain();
72 function GetInsertText(): String;
76 InputAssistForm: TInputAssistForm;
80 uses Setting, MojuUtils;
84 //!
\83t
\83H
\81[
\83\80\90¶
\90¬
\82Ì
\83C
\83x
\83\93\83g
85 procedure TInputAssistForm.FormCreate(Sender: TObject);
91 //
\83E
\83B
\83\93\83h
\83E
\82Ì
\88Ê
\92u
\90Ý
\92è
92 wp.length := sizeof(wp);
93 wp.rcNormalPosition.Top := GikoSys.Setting.InputAssistFormTop;
94 wp.rcNormalPosition.Left := GikoSys.Setting.InputAssistFormLeft;
96 wp.rcNormalPosition.Bottom := GikoSys.Setting.InputAssistFormTop
97 + GikoSys.Setting.InputAssistFormHeight;
98 wp.rcNormalPosition.Right := GikoSys.Setting.InputAssistFormLeft
99 + GikoSys.Setting.InputAssistFormWidth;
100 wp.showCmd := SW_HIDE;
101 SetWindowPlacement(Handle, @wp);
104 GikoListView1.Columns.Clear;
105 column := GikoListView1.Columns.Add;
106 column.ImageIndex := 0;
107 column.Caption := '
\83L
\81[';
109 column := GikoListView1.Columns.Add;
110 column.Caption := '
\83J
\83e
\83S
\83\8a';
112 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
113 AddListViewItem(InputAssistDM.GetResistWord(i));
115 //
\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¢)
116 InputAssistDM.Sorted := False;
118 //!
\88ê
\97\97\82É
\83A
\83C
\83e
\83\80\82ð
\92Ç
\89Á
\82·
\82é
\8f\88\97\9d
119 procedure TInputAssistForm.AddListViewItem(ResWord : TResistWord);
123 item := GikoListView1.Items.Add;
124 item.ImageIndex := -1;
125 item.Caption := resWord.GetKey;
126 item.SubItems.Add(resWord.GetCategory);
127 item.Data := resWord;
129 //!
\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
130 procedure TInputAssistForm.GikoListView1SelectItem(Sender: TObject;
131 Item: TListItem; Selected: Boolean);
133 if (Item <> nil) and (Item.Data <> nil) then begin
134 KeyNameEdit.Text := TResistWord(Item.Data).GetKey;
135 CategoryNameComboBox.Text := TResistWord(Item.Data).GetCategory;
136 TextMemo.Lines.Text := TResistWord(Item.Data).GetText;
138 TextMemo.Lines.Text := '';
141 //!
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
142 procedure TInputAssistForm.AddButtonClick(Sender: TObject);
144 resWord : TResistWord;
146 if (Length(KeyNameEdit.Text) = 0) then begin
147 ShowMessage('
\83L
\81[
\96¼
\82ð
\90Ý
\92è
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B');
149 if (not InputAssistDM.IsDupulicate(
150 KeyNameEdit.Text, CategoryNameComboBox.Text) ) then begin
151 resWord := InputAssistDM.Add(KeyNameEdit.Text);
152 resWord.SetCategory(CategoryNameComboBox.Text);
153 resWord.SetText(TextMemo.Text);
154 AddListViewItem(resWord);
155 SetCategory(CategoryNameComboBox);
156 GikoListView1.AlphaSort;
158 ShowMessage('
\93¯
\88ê
\82Ì
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\96¼
\82Å
\8aù
\82É
\93o
\98^
\8dÏ
\82Ý
\82Å
\82·
\81B');
162 //!
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
163 procedure TInputAssistForm.DeleteButtonClick(Sender: TObject);
165 if GikoListView1.Selected <> nil then begin
166 InputAssistDM.DeleteResistWord(GikoListView1.Selected.Data);
167 GikoListView1.Selected.Data := nil;
168 GikoListView1.DeleteSelected;
171 //!
\93K
\97p
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
172 procedure TInputAssistForm.ApplyButtonClick(Sender: TObject);
174 resWord : TResistWord;
176 if GikoListView1.Selected <> nil then begin
177 if (Length(KeyNameEdit.Text) = 0) then begin
178 ShowMessage('
\83L
\81[
\96¼
\82ð
\96³
\82µ
\82É
\82Í
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B');
180 if (not InputAssistDM.IsDupulicate(
181 KeyNameEdit.Text, CategoryNameComboBox.Text) ) then begin
182 resWord := TResistWord(GikoListView1.Selected.Data);
183 resWord.SetKey(KeyNameEdit.Text);
184 resWord.SetCategory(CategoryNameComboBox.Text);
185 resWord.SetText(TextMemo.Text);
186 //
\88ê
\97\97\82Ì
\8dX
\90V
187 GikoListView1.Selected.Caption := resWord.GetKey;
188 GikoListView1.Selected.SubItems[0] := resWord.GetCategory;
189 SetCategory(CategoryNameComboBox);
190 GikoListView1.AlphaSort;
192 ShowMessage('
\93¯
\88ê
\82Ì
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\96¼
\82Å
\8aù
\82É
\93o
\98^
\8dÏ
\82Ý
\82Å
\82·
\81B');
197 //!
\83t
\83H
\81[
\83\80\82ð
\95Â
\82¶
\82é
\82Æ
\82«
\82Ì
\83C
\83x
\83\93\83g
198 procedure TInputAssistForm.FormClose(Sender: TObject;
199 var Action: TCloseAction);
201 GikoSys.Setting.InputAssistFormTop := Self.Top;
202 GikoSys.Setting.InputAssistFormLeft := Self.Left;
203 GikoSys.Setting.InputAssistFormHeight := Self.Height;
204 GikoSys.Setting.InputAssistFormWidth := Self.Width;
205 //
\83\
\81[
\83g
\8fó
\91Ô
\82Ì
\90Ý
\92è
206 InputAssistDM.Sorted := True;
208 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82Ì
\83\
\81[
\83g
\97p
\82Ì
\94ä
\8ar
\8f\88\97\9d
209 procedure TInputAssistForm.GikoListView1Compare(Sender: TObject; Item1,
210 Item2: TListItem; Data: Integer; var Compare: Integer);
212 if ((FSortColumn and 2) > 0) then begin
213 //
\83J
\83e
\83S
\83\8a\82Å
\83\
\81[
\83g
214 Compare := CompareStr(
215 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
216 if (Compare = 0) then begin
217 Compare := CompareStr(
218 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
221 //
\83L
\81[
\82Å
\83\
\81[
\83g
222 Compare := CompareStr(
223 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
224 if (Compare = 0) then begin
225 Compare := CompareStr(
226 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
229 //
\8f¸
\8f\87\8d~
\8f\87\82Ì
\94½
\93]
230 if ((FSortColumn and 1) > 0) then begin
231 Compare := Compare * -1;
235 //!
\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
236 procedure TInputAssistForm.GikoListView1ColumnClick(Sender: TObject;
237 Column: TListColumn);
241 if Column <> nil then begin
242 //
\83C
\83\81\81[
\83W
\82Ì
\8dí
\8f\9c
243 for i := 0 to GikoListView1.Columns.Count - 1 do begin
244 GikoListView1.Column[i].ImageIndex := -1;
247 // FSortColumn
\8bô
\90\94:
\8f¸
\8f\87 \8aï
\90\94\81F
\8d~
\8f\87
248 if Column.Caption = '
\83L
\81[' then begin
249 if FSortColumn = 0 then begin
255 if FSortColumn = 2 then begin
261 Column.ImageIndex := (FSortColumn and 1);
262 GikoListView1.AlphaSort;
266 //!
\8fI
\97¹
\83{
\83^
\83\93\82ð
\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
267 procedure TInputAssistForm.CloseButtonClick(Sender: TObject);
271 //!
\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
272 procedure TInputAssistForm.CategoryComboBoxKeyPress(Sender: TObject;
277 //!
\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
278 procedure TInputAssistForm.CategoryComboBoxChange(Sender: TObject);
283 LockWindowUpdate(GikoListView1.Handle);
285 if (CategoryComboBox.ItemIndex <= 0) then begin
286 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
287 AddListViewItem(InputAssistDM.GetResistWord(i));
290 key := CategoryComboBox.Items[CategoryComboBox.ItemIndex];
291 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
292 if (key = InputAssistDM.GetResistWord(i).GetCategory) then begin
293 AddListViewItem(InputAssistDM.GetResistWord(i));
299 //!
\83J
\83e
\83S
\83\8a\83R
\83\93\83{
\83{
\83b
\83N
\83X
\90Ý
\92è
300 procedure TInputAssistForm.SetCategory(combo: TComboBox);
305 cat := TStringList.Create;
307 InputAssistDM.GetCategoryList(cat);
308 combo.Items.BeginUpdate;
311 combo.Items.AddStrings(cat);
312 combo.ItemIndex := 0;
313 combo.Items.EndUpdate;
319 procedure TInputAssistForm.SetUpFromMain();
321 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g
\90Ý
\92è';
322 Panel3.Visible := True;
323 Panel5.Visible := True;
324 Panel7.Visible := False;
325 TextMemo.ReadOnly := False;
327 CloseAction.ShortCut := TShortCut(0);
328 //
\92Ç
\89Á
\97p
\83L
\81[
\93ü
\97ÍOK
329 SetCategory(CategoryNameComboBox);
331 procedure TInputAssistForm.SetUpFromEditor();
335 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g';
336 Panel3.Visible := False;
337 Panel5.Visible := False;
338 Panel7.Visible := True;
339 TextMemo.ReadOnly := True;
341 CloseAction.ShortCut := ShortCut(VK_ESCAPE, []);
343 SetCategory(CategoryComboBox);
345 function TInputAssistForm.GetInsertText(): String;
347 Result := FInsertText;
350 procedure TInputAssistForm.InsertButtonActionUpdate(Sender: TObject);
352 InsertButtonAction.Enabled := (GikoListView1.Selected <> nil);
355 procedure TInputAssistForm.InsertButtonActionExecute(Sender: TObject);
357 if (GikoListView1.Selected = nil) then begin
359 Self.ModalResult := mrNone;
361 FInsertText := TResistWord(GikoListView1.Selected.Data).GetText;
362 Self.ModalResult := mrOk;
366 procedure TInputAssistForm.CloseActionExecute(Sender: TObject);
368 Self.ModalResult := mrCancel;