-
Notifications
You must be signed in to change notification settings - Fork 3
/
dlg_formats.pas
85 lines (57 loc) · 1.58 KB
/
dlg_formats.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
73
74
75
76
77
78
79
80
81
82
83
84
85
unit dlg_formats;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, ExtCtrls,
PV_Bitmap, PV_BitmapFormats;
type
{ TFormatsDlg }
TFormatsDlg = class(TForm)
Panel1: TPanel;
SG: TStringGrid;
procedure FormCreate(Sender: TObject);
private
public
end;
var
FormatsDlg: TFormatsDlg;
implementation
uses Unit1;
{$R *.lfm}
{ TFormatsDlg }
function ListSort(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result := CompareStr( List[Index1] , List[Index2] );
end;
procedure TFormatsDlg.FormCreate(Sender: TObject);
var i: Integer;
Ext, AName: String;
R: TPV_BitmapReader;
W: TPV_BitmapWriter;
Reader,Writer: String;
SumR,SumW: Integer;
Temp: TStringList;
begin
SG.ColWidths[0] := 250;
SG.Rows[0].CommaText := 'Format,Read,Write';
SG.RowCount := BitmapFormats.Count+1;
SumR := 0;
SumW := 0;
Temp := TStringList.Create;
for i:=0 to BitmapFormats.Count-1 do begin
BitmapFormats.Item(i, Ext, AName, R, W);
if R = nil then Reader := ''
else Reader := '+';
if W = nil then Writer := ''
else Writer := '+';
if R <> nil then Inc(SumR);
if W <> nil then Inc(SumW);
Temp.Add( '"' + AName + ' (.' + Ext + ')",' + Reader + ',' + Writer );
end;
Temp.CustomSort(@ListSort);
for i:=0 to Temp.Count-1 do
SG.Rows[i+1].CommaText := Temp[i];
Temp.Free;
Panel1.Caption := 'Read: ' + IntToStr(SumR) + ', Write: ' + IntToStr(SumW);
end;
end.