source: tags/1.3.0/Forms/UFormAcronym.pas

Last change on this file was 89, checked in by chronos, 8 years ago
  • Added: Show from which imports acronym meanings comes from.

This would easy correcting wrong acronyms directly in source.

  • Modified: References to categories stored more efficiently in XML project file.
File size: 3.6 KB
Line 
1unit UFormAcronym;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
9 StdCtrls, ActnList, UAcronym;
10
11type
12
13 { TFormAcronym }
14
15 TFormAcronym = class(TForm)
16 ACategoryRemove: TAction;
17 ACategoryAdd: TAction;
18 ActionList1: TActionList;
19 Button1: TButton;
20 Button2: TButton;
21 ButtonOk: TButton;
22 ButtonCancel: TButton;
23 EditAcronym: TEdit;
24 EditMeaning: TEdit;
25 Label1: TLabel;
26 Label2: TLabel;
27 Label3: TLabel;
28 Label4: TLabel;
29 Label5: TLabel;
30 ListBoxCategories: TListBox;
31 ListBoxImportSources: TListBox;
32 MemoDescription: TMemo;
33 MenuItem1: TMenuItem;
34 MenuItem2: TMenuItem;
35 PopupMenuCategory: TPopupMenu;
36 procedure ACategoryAddExecute(Sender: TObject);
37 procedure ACategoryRemoveExecute(Sender: TObject);
38 procedure EditMeaningKeyPress(Sender: TObject; var Key: char);
39 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
40 procedure FormCreate(Sender: TObject);
41 procedure FormShow(Sender: TObject);
42 procedure ListBoxCategoriesSelectionChange(Sender: TObject; User: boolean);
43 private
44 procedure UpdateInterface;
45 public
46 procedure Load(Entry: TAcronymEntry);
47 procedure Save(Entry: TAcronymEntry);
48 end;
49
50var
51 FormAcronym: TFormAcronym;
52
53implementation
54
55{$R *.lfm}
56
57uses
58 UFormMain, UFormCategorySelect;
59
60{ TFormAcronym }
61
62procedure TFormAcronym.FormClose(Sender: TObject; var CloseAction: TCloseAction
63 );
64begin
65 FormMain.PersistentForm1.Save(Self);
66end;
67
68procedure TFormAcronym.FormCreate(Sender: TObject);
69begin
70
71end;
72
73procedure TFormAcronym.ACategoryAddExecute(Sender: TObject);
74var
75 I: Integer;
76begin
77 FormCategorySelect.Load(ListBoxCategories.Items);
78 if FormCategorySelect.ShowModal = mrOk then begin
79 for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
80 if FormCategorySelect.ListBox1.Selected[I] then begin
81 ListBoxCategories.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
82 end;
83 end;
84end;
85
86procedure TFormAcronym.ACategoryRemoveExecute(Sender: TObject);
87var
88 I: Integer;
89begin
90 if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
91 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
92 for I := ListBoxCategories.Items.Count - 1 downto 0 do
93 if ListBoxCategories.Selected[I] then
94 ListBoxCategories.Items.Delete(I);
95 UpdateInterface;
96 end;
97end;
98
99procedure TFormAcronym.EditMeaningKeyPress(Sender: TObject; var Key: char);
100begin
101 if Ord(Key) = 13 then ButtonOk.Click;
102 if Ord(Key) = 27 then ButtonCancel.Click;
103end;
104
105procedure TFormAcronym.FormShow(Sender: TObject);
106begin
107 FormMain.PersistentForm1.Load(Self);
108 UpdateInterface;
109end;
110
111procedure TFormAcronym.ListBoxCategoriesSelectionChange(Sender: TObject; User: boolean);
112begin
113 UpdateInterface;
114end;
115
116procedure TFormAcronym.UpdateInterface;
117begin
118 ACategoryRemove.Enabled := ListBoxCategories.ItemIndex <> -1;
119end;
120
121procedure TFormAcronym.Load(Entry: TAcronymEntry);
122begin
123 EditAcronym.Text := Entry.Name;
124 EditMeaning.Text := Entry.Meaning;
125 MemoDescription.Text := Entry.Description;
126 ListBoxCategories.Items.Assign(Entry.Categories);
127 ListBoxImportSources.Items.Assign(Entry.Sources);
128end;
129
130procedure TFormAcronym.Save(Entry: TAcronymEntry);
131begin
132 Entry.Name := EditAcronym.Text;
133 Entry.Meaning := EditMeaning.Text;
134 Entry.Description := MemoDescription.Text;
135 Entry.Categories.Assign(ListBoxCategories.Items);
136end;
137
138end.
139
Note: See TracBrowser for help on using the repository browser.