source: tags/1.4.0/Forms/UFormAcronym.pas

Last change on this file was 96, checked in by chronos, 8 years ago
  • Fixed: Dynamically created forms were not translated.
File size: 3.7 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 UCore, UFormCategorySelect;
59
60{ TFormAcronym }
61
62procedure TFormAcronym.FormClose(Sender: TObject; var CloseAction: TCloseAction
63 );
64begin
65 Core.PersistentForm1.Save(Self);
66end;
67
68procedure TFormAcronym.FormCreate(Sender: TObject);
69begin
70 Core.CoolTranslator1.TranslateComponentRecursive(Self);
71end;
72
73procedure TFormAcronym.ACategoryAddExecute(Sender: TObject);
74var
75 I: Integer;
76begin
77 FormCategorySelect := TFormCategorySelect.Create(Self);
78 try
79 FormCategorySelect.Load(ListBoxCategories.Items);
80 if FormCategorySelect.ShowModal = mrOk then begin
81 for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
82 if FormCategorySelect.ListBox1.Selected[I] then begin
83 ListBoxCategories.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
84 end;
85 end;
86 finally
87 FreeAndNil(FormCategorySelect);
88 end;
89end;
90
91procedure TFormAcronym.ACategoryRemoveExecute(Sender: TObject);
92var
93 I: Integer;
94begin
95 if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
96 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
97 for I := ListBoxCategories.Items.Count - 1 downto 0 do
98 if ListBoxCategories.Selected[I] then
99 ListBoxCategories.Items.Delete(I);
100 UpdateInterface;
101 end;
102end;
103
104procedure TFormAcronym.EditMeaningKeyPress(Sender: TObject; var Key: char);
105begin
106 if Ord(Key) = 13 then ButtonOk.Click;
107 if Ord(Key) = 27 then ButtonCancel.Click;
108end;
109
110procedure TFormAcronym.FormShow(Sender: TObject);
111begin
112 Core.PersistentForm1.Load(Self);
113 UpdateInterface;
114end;
115
116procedure TFormAcronym.ListBoxCategoriesSelectionChange(Sender: TObject; User: boolean);
117begin
118 UpdateInterface;
119end;
120
121procedure TFormAcronym.UpdateInterface;
122begin
123 ACategoryRemove.Enabled := ListBoxCategories.ItemIndex <> -1;
124end;
125
126procedure TFormAcronym.Load(Entry: TAcronymEntry);
127begin
128 EditAcronym.Text := Entry.Name;
129 EditMeaning.Text := Entry.Meaning;
130 MemoDescription.Text := Entry.Description;
131 ListBoxCategories.Items.Assign(Entry.Categories);
132 ListBoxImportSources.Items.Assign(Entry.Sources);
133end;
134
135procedure TFormAcronym.Save(Entry: TAcronymEntry);
136begin
137 Entry.Name := EditAcronym.Text;
138 Entry.Meaning := EditMeaning.Text;
139 Entry.Description := MemoDescription.Text;
140 Entry.Categories.Assign(ListBoxCategories.Items);
141end;
142
143end.
144
Note: See TracBrowser for help on using the repository browser.