source: trunk/Forms/UFormCategorySelect.pas

Last change on this file was 207, checked in by chronos, 3 years ago
  • Modified: Updated Common package.
  • Modified: CoolTranslator package merged into Common package.
  • Fixed: Build with Lazarus 2.0.12
File size: 2.1 KB
Line 
1unit UFormCategorySelect;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 UAcronym;
10
11type
12
13 { TFormCategorySelect }
14
15 TFormCategorySelect = class(TForm)
16 ButtonOk: TButton;
17 ButtonCancel: TButton;
18 ListBox1: TListBox;
19 procedure FormCreate(Sender: TObject);
20 procedure FormShow(Sender: TObject);
21 procedure ListBox1DblClick(Sender: TObject);
22 procedure ListBox1KeyPress(Sender: TObject; var Key: char);
23 private
24 { private declarations }
25 public
26 procedure Load(RemoveItems: TStrings);
27 end;
28
29var
30 FormCategorySelect: TFormCategorySelect;
31
32resourcestring
33 SCategory = 'Category';
34 SRemoveCategory = 'Remove categories';
35 SRemoveCategoryQuery = 'Do you really want to remove selected categories?';
36
37implementation
38
39{$R *.lfm}
40
41uses
42 UCore;
43
44{ TFormCategorySelect }
45
46procedure TFormCategorySelect.FormShow(Sender: TObject);
47begin
48end;
49
50procedure TFormCategorySelect.FormCreate(Sender: TObject);
51begin
52 Core.Translator.TranslateComponentRecursive(Self);
53 Core.ThemeManager.UseTheme(Self);
54end;
55
56procedure TFormCategorySelect.ListBox1DblClick(Sender: TObject);
57begin
58 ButtonOk.Click;
59end;
60
61procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: char);
62begin
63 if Key = #13 then ButtonOk.Click;
64end;
65
66procedure TFormCategorySelect.Load(RemoveItems: TStrings);
67var
68 Index: Integer;
69 I: Integer;
70begin
71 with Core.AcronymDb do begin
72 ListBox1.Sorted := False;
73 while ListBox1.Items.Count < Categories.Count do
74 ListBox1.Items.Add('');
75 while ListBox1.Items.Count > Categories.Count do
76 ListBox1.Items.Delete(ListBox1.Items.Count - 1);
77 for I := 0 to Categories.Count - 1 do begin
78 ListBox1.Items.Strings[I] := TAcronymCategory(Categories[I]).Name;
79 ListBox1.Items.Objects[I] := Categories[I];
80 ListBox1.Selected[I] := False;
81 end;
82 ListBox1.Sorted := True;
83 for I := 0 to RemoveItems.Count - 1 do begin
84 Index := ListBox1.Items.IndexOf(RemoveItems[I]);
85 if Index <> -1 then ListBox1.Items.Delete(Index);
86 end;
87 end;
88end;
89
90end.
91
Note: See TracBrowser for help on using the repository browser.