forked from Ravie/quice
-
Notifications
You must be signed in to change notification settings - Fork 2
/
UnitFlagsUnit.pas
72 lines (60 loc) · 1.51 KB
/
UnitFlagsUnit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
unit UnitFlagsUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst, ExtCtrls;
type
TUnitFlagsForm = class(TForm)
Bevel: TBevel;
btCancel: TButton;
btOK: TButton;
clbMain: TCheckListBox;
procedure FormCreate(Sender: TObject);
procedure btOKClick(Sender: TObject);
private
FFlags: int64;
{ Private declarations }
public
{ Public declarations }
property Flags: int64 read FFlags;
procedure Prepare(Text: string);
procedure Load(What: string);
end;
implementation
uses MyDataModule, Functions;
{$R *.dfm}
{ TUnitFlagsForm }
procedure TUnitFlagsForm.btOKClick(Sender: TObject);
var
i: integer;
skip: boolean;
begin
skip := false;
FFlags := 0;
for i := 0 to clbMain.Items.Count - 1 do
if clbMain.Checked[i] then FFlags := FFlags or (1 shl i) else skip := true;
if not skip then fflags := -1;
end;
procedure TUnitFlagsForm.FormCreate(Sender: TObject);
begin
dmMain.Translate.CreateDefaultTranslation(TForm(Self));
dmMain.Translate.TranslateForm(TForm(Self));
end;
procedure TUnitFlagsForm.Load(What: string);
begin
Caption := What;
LoadStringListFromFile(clbMain.Items, What);
if clbMain.Items.Count <= 16 then clbMain.Columns := 1;
end;
procedure TUnitFlagsForm.Prepare(Text: string);
var
i: integer;
begin
FFlags := StrToInt64Def(Text,0);
for i := 0 to clbMain.Items.Count - 1 do
begin
if FFlags and (1 shl i) <> 0 then
clbMain.Checked[i] := true;
end;
end;
end.