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 resWord := InputAssistDM.Add(KeyNameEdit.Text);
145 resWord.SetCategory(CategoryNameEdit.Text);
146 resWord.SetText(TextMemo.Text);
147 AddListViewItem(resWord);
148 GikoListView1.AlphaSort;
151 //!
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
152 procedure TInputAssistForm.DeleteButtonClick(Sender: TObject);
154 if GikoListView1.Selected <> nil then begin
155 InputAssistDM.DeleteResistWord(GikoListView1.Selected.Data);
156 GikoListView1.Selected.Data := nil;
157 GikoListView1.DeleteSelected;
160 //!
\93K
\97p
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
161 procedure TInputAssistForm.ApplyButtonClick(Sender: TObject);
163 resWord : TResistWord;
165 if GikoListView1.Selected <> nil then begin
166 if (Length(KeyNameEdit.Text) = 0) then begin
167 ShowMessage('
\83L
\81[
\96¼
\82ð
\96³
\82µ
\82É
\82Í
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B');
169 resWord := TResistWord(GikoListView1.Selected.Data);
170 resWord.SetKey(KeyNameEdit.Text);
171 resWord.SetCategory(CategoryNameEdit.Text);
172 resWord.SetText(TextMemo.Text);
173 //
\88ê
\97\97\82Ì
\8dX
\90V
174 GikoListView1.Selected.Caption := resWord.GetKey;
175 GikoListView1.Selected.SubItems[0] := resWord.GetCategory;
176 GikoListView1.AlphaSort;
180 //!
\83t
\83H
\81[
\83\80\82ð
\95Â
\82¶
\82é
\82Æ
\82«
\82Ì
\83C
\83x
\83\93\83g
181 procedure TInputAssistForm.FormClose(Sender: TObject;
182 var Action: TCloseAction);
184 GikoSys.Setting.InputAssistFormTop := Self.Top;
185 GikoSys.Setting.InputAssistFormLeft := Self.Left;
186 GikoSys.Setting.InputAssistFormHeight := Self.Height;
187 GikoSys.Setting.InputAssistFormWidth := Self.Width;
188 //
\83\
\81[
\83g
\8fó
\91Ô
\82Ì
\90Ý
\92è
189 InputAssistDM.Sorted := True;
191 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82Ì
\83\
\81[
\83g
\97p
\82Ì
\94ä
\8ar
\8f\88\97\9d
192 procedure TInputAssistForm.GikoListView1Compare(Sender: TObject; Item1,
193 Item2: TListItem; Data: Integer; var Compare: Integer);
195 if ((FSortColumn and 2) > 0) then begin
196 //
\83J
\83e
\83S
\83\8a\82Å
\83\
\81[
\83g
197 Compare := CompareStr(
198 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
199 if (Compare = 0) then begin
200 Compare := CompareStr(
201 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
204 //
\83L
\81[
\82Å
\83\
\81[
\83g
205 Compare := CompareStr(
206 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
207 if (Compare = 0) then begin
208 Compare := CompareStr(
209 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
212 //
\8f¸
\8f\87\8d~
\8f\87\82Ì
\94½
\93]
213 if ((FSortColumn and 1) > 0) then begin
214 Compare := Compare * -1;
218 //!
\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
219 procedure TInputAssistForm.GikoListView1ColumnClick(Sender: TObject;
220 Column: TListColumn);
224 if Column <> nil then begin
225 //
\83C
\83\81\81[
\83W
\82Ì
\8dí
\8f\9c
226 for i := 0 to GikoListView1.Columns.Count - 1 do begin
227 GikoListView1.Column[i].ImageIndex := -1;
230 // FSortColumn
\8bô
\90\94:
\8f¸
\8f\87 \8aï
\90\94\81F
\8d~
\8f\87
231 if Column.Caption = '
\83L
\81[' then begin
232 if FSortColumn = 0 then begin
238 if FSortColumn = 2 then begin
244 Column.ImageIndex := (FSortColumn and 1);
245 GikoListView1.AlphaSort;
249 //!
\8fI
\97¹
\83{
\83^
\83\93\82ð
\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
250 procedure TInputAssistForm.CloseButtonClick(Sender: TObject);
254 //!
\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
255 procedure TInputAssistForm.CategoryComboBoxKeyPress(Sender: TObject;
260 //!
\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
261 procedure TInputAssistForm.CategoryComboBoxChange(Sender: TObject);
266 LockWindowUpdate(GikoListView1.Handle);
268 if (CategoryComboBox.ItemIndex <= 0) then begin
269 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
270 AddListViewItem(InputAssistDM.GetResistWord(i));
273 key := CategoryComboBox.Items[CategoryComboBox.ItemIndex];
274 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
275 if (key = InputAssistDM.GetResistWord(i).GetCategory) then begin
276 AddListViewItem(InputAssistDM.GetResistWord(i));
283 procedure TInputAssistForm.SetUpFromMain();
285 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g
\90Ý
\92è';
286 Panel3.Visible := True;
287 Panel5.Visible := True;
288 Panel7.Visible := False;
289 TextMemo.ReadOnly := False;
291 CloseAction.ShortCut := TShortCut(0);
293 procedure TInputAssistForm.SetUpFromEditor();
297 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g';
298 Panel3.Visible := False;
299 Panel5.Visible := False;
300 Panel7.Visible := True;
301 TextMemo.ReadOnly := True;
303 CloseAction.ShortCut := ShortCut(VK_ESCAPE, []);
305 cat := TStringList.Create;
307 InputAssistDM.GetCategoryList(cat);
308 CategoryComboBox.Items.Clear;
309 CategoryComboBox.Items.Add('');
310 CategoryComboBox.Items.AddStrings(cat);
311 CategoryComboBox.ItemIndex := 0;
316 function TInputAssistForm.GetInsertText(): String;
318 Result := FInsertText;
321 procedure TInputAssistForm.InsertButtonActionUpdate(Sender: TObject);
323 InsertButtonAction.Enabled := (GikoListView1.Selected <> nil);
326 procedure TInputAssistForm.InsertButtonActionExecute(Sender: TObject);
328 if (GikoListView1.Selected = nil) then begin
330 Self.ModalResult := mrNone;
332 FInsertText := TResistWord(GikoListView1.Selected.Data).GetText;
333 Self.ModalResult := mrOk;
337 procedure TInputAssistForm.CloseActionExecute(Sender: TObject);
339 Self.ModalResult := mrCancel;