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 CategoryNameEdit: TLabeledEdit;
44 procedure FormCreate(Sender: TObject);
45 procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem;
47 procedure AddButtonClick(Sender: TObject);
48 procedure DeleteButtonClick(Sender: TObject);
49 procedure ApplyButtonClick(Sender: TObject);
50 procedure FormClose(Sender: TObject; var Action: TCloseAction);
51 procedure GikoListView1Compare(Sender: TObject; Item1,
52 Item2: TListItem; Data: Integer; var Compare: Integer);
53 procedure GikoListView1ColumnClick(Sender: TObject;
55 procedure CloseButtonClick(Sender: TObject);
56 procedure CategoryComboBoxKeyPress(Sender: TObject; var Key: Char);
57 procedure CategoryComboBoxChange(Sender: TObject);
58 procedure InsertButtonActionUpdate(Sender: TObject);
59 procedure InsertButtonActionExecute(Sender: TObject);
60 procedure CloseActionExecute(Sender: TObject);
63 FSortColumn : Integer;
65 procedure AddListViewItem(ResWord : TResistWord);
68 procedure SetUpFromEditor();
69 procedure SetUpFromMain();
70 function GetInsertText(): String;
74 InputAssistForm: TInputAssistForm;
78 uses Setting, MojuUtils;
82 //!
\83t
\83H
\81[
\83\80\90¶
\90¬
\82Ì
\83C
\83x
\83\93\83g
83 procedure TInputAssistForm.FormCreate(Sender: TObject);
89 //
\83E
\83B
\83\93\83h
\83E
\82Ì
\88Ê
\92u
\90Ý
\92è
90 wp.length := sizeof(wp);
91 wp.rcNormalPosition.Top := GikoSys.Setting.InputAssistFormTop;
92 wp.rcNormalPosition.Left := GikoSys.Setting.InputAssistFormLeft;
94 wp.rcNormalPosition.Bottom := GikoSys.Setting.InputAssistFormTop
95 + GikoSys.Setting.InputAssistFormHeight;
96 wp.rcNormalPosition.Right := GikoSys.Setting.InputAssistFormLeft
97 + GikoSys.Setting.InputAssistFormWidth;
98 wp.showCmd := SW_HIDE;
99 SetWindowPlacement(Handle, @wp);
102 GikoListView1.Columns.Clear;
103 column := GikoListView1.Columns.Add;
104 column.ImageIndex := 0;
105 column.Caption := '
\83L
\81[';
107 column := GikoListView1.Columns.Add;
108 column.Caption := '
\83J
\83e
\83S
\83\8a';
110 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
111 AddListViewItem(InputAssistDM.GetResistWord(i));
113 //
\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¢)
114 InputAssistDM.Sorted := False;
116 //!
\88ê
\97\97\82É
\83A
\83C
\83e
\83\80\82ð
\92Ç
\89Á
\82·
\82é
\8f\88\97\9d
117 procedure TInputAssistForm.AddListViewItem(ResWord : TResistWord);
121 item := GikoListView1.Items.Add;
122 item.ImageIndex := -1;
123 item.Caption := resWord.GetKey;
124 item.SubItems.Add(resWord.GetCategory);
125 item.Data := resWord;
127 //!
\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
128 procedure TInputAssistForm.GikoListView1SelectItem(Sender: TObject;
129 Item: TListItem; Selected: Boolean);
131 if (Item <> nil) and (Item.Data <> nil) then begin
132 KeyNameEdit.Text := TResistWord(Item.Data).GetKey;
133 CategoryNameEdit.Text := TResistWord(Item.Data).GetCategory;
134 TextMemo.Lines.Text := TResistWord(Item.Data).GetText;
136 TextMemo.Lines.Text := '';
139 //!
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
140 procedure TInputAssistForm.AddButtonClick(Sender: TObject);
142 resWord : TResistWord;
144 if (Length(KeyNameEdit.Text) = 0) then begin
145 ShowMessage('
\83L
\81[
\96¼
\82ð
\90Ý
\92è
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B');
147 if (not InputAssistDM.IsDupulicate(
148 KeyNameEdit.Text, CategoryNameEdit.Text) ) then begin
149 resWord := InputAssistDM.Add(KeyNameEdit.Text);
150 resWord.SetCategory(CategoryNameEdit.Text);
151 resWord.SetText(TextMemo.Text);
152 AddListViewItem(resWord);
153 GikoListView1.AlphaSort;
155 ShowMessage('
\93¯
\88ê
\82Ì
\83L
\81[
\96¼
\81E
\83J
\83e
\83S
\83\8a\96¼
\82Å
\8aù
\82É
\93o
\98^
\8dÏ
\82Ý
\82Å
\82·
\81B');
159 //!
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
160 procedure TInputAssistForm.DeleteButtonClick(Sender: TObject);
162 if GikoListView1.Selected <> nil then begin
163 InputAssistDM.DeleteResistWord(GikoListView1.Selected.Data);
164 GikoListView1.Selected.Data := nil;
165 GikoListView1.DeleteSelected;
168 //!
\93K
\97p
\83{
\83^
\83\93\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
169 procedure TInputAssistForm.ApplyButtonClick(Sender: TObject);
171 resWord : TResistWord;
173 if GikoListView1.Selected <> nil then begin
174 if (Length(KeyNameEdit.Text) = 0) then begin
175 ShowMessage('
\83L
\81[
\96¼
\82ð
\96³
\82µ
\82É
\82Í
\82Å
\82«
\82Ü
\82¹
\82ñ
\81B');
177 resWord := TResistWord(GikoListView1.Selected.Data);
178 resWord.SetKey(KeyNameEdit.Text);
179 resWord.SetCategory(CategoryNameEdit.Text);
180 resWord.SetText(TextMemo.Text);
181 //
\88ê
\97\97\82Ì
\8dX
\90V
182 GikoListView1.Selected.Caption := resWord.GetKey;
183 GikoListView1.Selected.SubItems[0] := resWord.GetCategory;
184 GikoListView1.AlphaSort;
188 //!
\83t
\83H
\81[
\83\80\82ð
\95Â
\82¶
\82é
\82Æ
\82«
\82Ì
\83C
\83x
\83\93\83g
189 procedure TInputAssistForm.FormClose(Sender: TObject;
190 var Action: TCloseAction);
192 GikoSys.Setting.InputAssistFormTop := Self.Top;
193 GikoSys.Setting.InputAssistFormLeft := Self.Left;
194 GikoSys.Setting.InputAssistFormHeight := Self.Height;
195 GikoSys.Setting.InputAssistFormWidth := Self.Width;
196 //
\83\
\81[
\83g
\8fó
\91Ô
\82Ì
\90Ý
\92è
197 InputAssistDM.Sorted := True;
199 //!
\93o
\98^
\92P
\8cê
\88ê
\97\97\82Ì
\83\
\81[
\83g
\97p
\82Ì
\94ä
\8ar
\8f\88\97\9d
200 procedure TInputAssistForm.GikoListView1Compare(Sender: TObject; Item1,
201 Item2: TListItem; Data: Integer; var Compare: Integer);
203 if ((FSortColumn and 2) > 0) then begin
204 //
\83J
\83e
\83S
\83\8a\82Å
\83\
\81[
\83g
205 Compare := CompareStr(
206 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
207 if (Compare = 0) then begin
208 Compare := CompareStr(
209 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
212 //
\83L
\81[
\82Å
\83\
\81[
\83g
213 Compare := CompareStr(
214 ZenToHan(Item1.Caption), ZenToHan(Item2.Caption));
215 if (Compare = 0) then begin
216 Compare := CompareStr(
217 ZenToHan(Item1.SubItems[0]), ZenToHan(Item2.SubItems[0]));
220 //
\8f¸
\8f\87\8d~
\8f\87\82Ì
\94½
\93]
221 if ((FSortColumn and 1) > 0) then begin
222 Compare := Compare * -1;
226 //!
\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
227 procedure TInputAssistForm.GikoListView1ColumnClick(Sender: TObject;
228 Column: TListColumn);
232 if Column <> nil then begin
233 //
\83C
\83\81\81[
\83W
\82Ì
\8dí
\8f\9c
234 for i := 0 to GikoListView1.Columns.Count - 1 do begin
235 GikoListView1.Column[i].ImageIndex := -1;
238 // FSortColumn
\8bô
\90\94:
\8f¸
\8f\87 \8aï
\90\94\81F
\8d~
\8f\87
239 if Column.Caption = '
\83L
\81[' then begin
240 if FSortColumn = 0 then begin
246 if FSortColumn = 2 then begin
252 Column.ImageIndex := (FSortColumn and 1);
253 GikoListView1.AlphaSort;
257 //!
\8fI
\97¹
\83{
\83^
\83\93\82ð
\89\9f\89º
\8e\9e\82Ì
\83C
\83x
\83\93\83g
258 procedure TInputAssistForm.CloseButtonClick(Sender: TObject);
262 //!
\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
263 procedure TInputAssistForm.CategoryComboBoxKeyPress(Sender: TObject;
268 //!
\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
269 procedure TInputAssistForm.CategoryComboBoxChange(Sender: TObject);
274 LockWindowUpdate(GikoListView1.Handle);
276 if (CategoryComboBox.ItemIndex <= 0) then begin
277 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
278 AddListViewItem(InputAssistDM.GetResistWord(i));
281 key := CategoryComboBox.Items[CategoryComboBox.ItemIndex];
282 for i := 0 to InputAssistDM.ResistWordCount - 1 do begin
283 if (key = InputAssistDM.GetResistWord(i).GetCategory) then begin
284 AddListViewItem(InputAssistDM.GetResistWord(i));
291 procedure TInputAssistForm.SetUpFromMain();
293 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g
\90Ý
\92è';
294 Panel3.Visible := True;
295 Panel5.Visible := True;
296 Panel7.Visible := False;
297 TextMemo.ReadOnly := False;
299 CloseAction.ShortCut := TShortCut(0);
301 procedure TInputAssistForm.SetUpFromEditor();
305 Self.Caption := '
\93ü
\97Í
\83A
\83V
\83X
\83g';
306 Panel3.Visible := False;
307 Panel5.Visible := False;
308 Panel7.Visible := True;
309 TextMemo.ReadOnly := True;
311 CloseAction.ShortCut := ShortCut(VK_ESCAPE, []);
313 cat := TStringList.Create;
315 InputAssistDM.GetCategoryList(cat);
316 CategoryComboBox.Items.Clear;
317 CategoryComboBox.Items.Add('');
318 CategoryComboBox.Items.AddStrings(cat);
319 CategoryComboBox.ItemIndex := 0;
324 function TInputAssistForm.GetInsertText(): String;
326 Result := FInsertText;
329 procedure TInputAssistForm.InsertButtonActionUpdate(Sender: TObject);
331 InsertButtonAction.Enabled := (GikoListView1.Selected <> nil);
334 procedure TInputAssistForm.InsertButtonActionExecute(Sender: TObject);
336 if (GikoListView1.Selected = nil) then begin
338 Self.ModalResult := mrNone;
340 FInsertText := TResistWord(GikoListView1.Selected.Data).GetText;
341 Self.ModalResult := mrOk;
345 procedure TInputAssistForm.CloseActionExecute(Sender: TObject);
347 Self.ModalResult := mrCancel;