-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsvgViewer.Icons.Search.pas
More file actions
158 lines (136 loc) · 3.71 KB
/
Copy pathsvgViewer.Icons.Search.pas
File metadata and controls
158 lines (136 loc) · 3.71 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
unit svgViewer.Icons.Search;
interface
uses
vcl.Graphics,
vcl.GraphUtil,
svgViewer.Types;
type
TSearchIconList = class(TInterfacedObject,ISVGIconList,ISVGSearchList,ISVGTwoToneIconList,ISVGUserFolderList)
private
fFillColor : TColor;
fToneColor : TColor;
fBaseList : ISVGIconList;
fMatch : TArray<Integer>;
fSearchText : string;
protected
function GetCount : integer;
function GetName(Index:Integer):string;
function GetSource(Index:Integer):string;
function GetFillColor : TColor;
procedure SetFillColor(Value:TColor);
function GetSearchText : string;
procedure SetSearchText(const Value:String);
function GetBaseList : ISVGIconList;
procedure SetBaseList(value : ISVGIconLIst);
function GetToneColor : TColor;
procedure SetToneColor(Value:TColor);
procedure SetDirectory(value:String);
function GetDirectory:string;
public
property Count : integer read GetCount;
property Name[index:integer] : string read GetName;
property Source[index:integer] : string read GetSource;
property FillColor : TColor read GetFillColor write SetFillColor default clNone;
property ToneColor : TColor read GetToneColor write SetToneColor;
property BaseList : ISVGIconList read GetBaseList write SetBaseList;
property SearchText : string read GetSearchText write SetSearchText;
end;
implementation
uses
SysUtils,
StrUtils;
{ TSearchIconList }
function TSearchIconList.GetBaseList: ISVGIconList;
begin
result := fBaseList;
end;
function TSearchIconList.GetCount: integer;
begin
if fSearchText = '' then
result := fBaseList.count
else
Result := Length(fMatch);
end;
function TSearchIconList.GetDirectory: string;
var
FolderList : ISVGUserFolderList;
begin
Result := '';
if Supports(fBaseList,ISVGUserFolderList,FolderList) then
result := FolderList.Directory;
end;
function TSearchIconList.GetFillColor: TColor;
begin
result := fFillColor;
end;
function TSearchIconList.GetName(Index: Integer): string;
begin
if fSearchText = '' then
Result := fBaseList.Name[Index]
else
Result := fBaseList.Name[fMatch[index]];
end;
function TSearchIconList.GetSearchText: string;
begin
Result := fSearchText;
end;
function TSearchIconList.GetSource(Index: Integer): string;
begin
if fSearchText = '' then
Result := fBaseList.source[index]
else
Result := fBaseList.Source[fMatch[index]];
end;
function TSearchIconList.GetToneColor: TColor;
begin
Result := fToneColor;
end;
procedure TSearchIconList.SetBaseList(value: ISVGIconLIst);
var
IconTone : ISVGTwoToneIconList;
begin
fBaseList := Value;
fBaseList.FillColor := fFillColor;
if Supports(fBaseList,ISVGTwoToneIconList,IconTone) then
IconTone.ToneColor := fToneColor;
SetSearchText(fSearchText);
end;
procedure TSearchIconList.SetDirectory(value: String);
var
FolderList : ISVGUserFolderList;
begin
if Supports(fBaseList,ISVGUserFolderList,FolderList) then
Folderlist.Directory := value;
end;
procedure TSearchIconList.SetFillColor(Value: TColor);
begin
fFillColor := Value;
if assigned(fBaseList) then
fBaseList.FillColor := fFillColor;
end;
procedure TSearchIconList.SetSearchText(const Value: String);
var
ix,iy : integer;
begin
fSearchText := Value;
SetLength(fMatch,fBaseList.COunt);
iy := 0;
for ix := 0 to fBaseList.Count-1 do
begin
if ContainsText(fBaseList.Name[ix],fSearchText) then
begin
fMatch[iy] := ix;
inc(iy);
end;
end;
SetLength(fMatch,iy);
end;
procedure TSearchIconList.SetToneColor(Value: TColor);
var
IconTone : ISVGTwoToneIconList;
begin
fToneColor := Value;
if Supports(fBaseList,ISVGTwoToneIconList,IconTone) then
IconTone.ToneColor := fToneColor;
end;
end.