-
Notifications
You must be signed in to change notification settings - Fork 7
/
pospolite.view.basics.generics.inc
1086 lines (865 loc) · 20.2 KB
/
pospolite.view.basics.generics.inc
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ TPLNumberRange }
constructor TPLNumberRange.Create(const AMin, AMax: T);
begin
min := AMin;
max := AMax;
end;
class function TPLNumberRange.InRanges(const AValue: T;
const ARanges: array of TPLNumberRangeT): TPLBool;
var
i: SizeInt;
begin
Result := false;
for i := Low(ARanges) to High(ARanges) do begin
if (ARanges[i].min <= AValue) and (AValue <= ARanges[i].max) then exit(true);
end;
end;
function TPLNumberRange.Correct(const ANumber: Variant): T;
begin
if ANumber < min then Result := min else
if ANumber > max then Result := max else
Result := T(ANumber);
end;
{ TPLListEnumerator }
function TPLListEnumerator.GetCurrent: E;
begin
Result := FList[FIndex];
end;
constructor TPLListEnumerator.Create(const AList: L);
begin
inherited Create;
FList := AList;
FIndex := -1;
end;
function TPLListEnumerator.MoveNext: TPLBool;
begin
if FIndex+1 < FList.Count then begin
Result := true;
Inc(FIndex);
end else Result := false;
end;
procedure TPLListEnumerator.Reset;
begin
FIndex := 0;
end;
{ TPLObjectList }
function TPLObjectList.GetItem(AIndex: SizeInt): T;
begin
if (AIndex < 0) or (AIndex >= FSize) then
Result := nil
else
Result := FArray[AIndex];
end;
procedure TPLObjectList.SetItem(AIndex: SizeInt; AValue: T);
begin
if (AIndex < 0) or (AIndex >= FSize) then exit;
FArray[AIndex] := AValue;
end;
function TPLObjectList.DefaultCompare(a, b: T): TPLBool;
begin
Result := a = b;
end;
procedure TPLObjectList.MergeArray(var AArray: TListOfT; l, r, x, y: TPLInt;
AComparator: specialize TPLObjectListSortCompare<T>);
var
i, j, k, s: TPLInt;
c: TListOfT;
a: TListOfT absolute AArray;
begin
i := l;
j := y;
k := 0;
SetLength(c, r - l + 1 + y - x + 1);
while (l <= r) and (x <= y) do begin
if AComparator(a[l], a[x]) = -1 then begin
c[k] := a[l];
Inc(l);
end else begin
c[k] := a[x];
Inc(x);
end;
Inc(k);
end;
if l <= r then for s := l to r do begin
c[k] := a[s];
Inc(k);
end else for s := x to y do begin
c[k] := a[s];
Inc(k);
end;
k := 0;
for s := i to j do begin
a[s] := c[k];
Inc(k);
end;
end;
procedure TPLObjectList.SortArray(AArray: TListOfT; ALeft, ARight: TPLInt;
AComparator: specialize TPLObjectListSortCompare<T>);
var
m: TPLInt;
begin
if ALeft >= ARight then exit;
m := (ALeft + ARight) div 2;
SortArray(AArray, ALeft, m, AComparator);
SortArray(AArray, m + 1, ARight, AComparator);
MergeArray(AArray, ALeft, m, m + 1, ARight, AComparator);
end;
function TPLObjectList.GetEnumerator: IObjectListEnumerator;
begin
Result := TObjectListEnumerator.Create(Self);
end;
function TPLObjectList.Find(AItem: T; AComparator: specialize
TPLObjectListFindCompare<T>): SizeInt;
var
i: SizeInt;
begin
Result := -1;
if not Assigned(AComparator) then AComparator := @DefaultCompare;
for i := 0 to FSize-1 do
if AComparator(FArray[i], AItem) then exit(i);
end;
procedure TPLObjectList.Sort(AComparator: specialize TPLObjectListSortCompare<T>);
begin
if not Assigned(AComparator) then exit;
SortArray(FArray, 0, Length(FArray)-1, AComparator);
end;
constructor TPLObjectList.Create(AFreeObjects: TPLBool);
begin
inherited Create;
FSize := 0;
FFreeObjects := AFreeObjects;
SetLength(FArray, 0);
end;
destructor TPLObjectList.Destroy;
begin
Clear;
inherited Destroy;
end;
procedure TPLObjectList.Add(AItem: T);
begin
if FSize >= MaxListSize then exit;
SetLength(FArray, FSize + 1);
FArray[FSize] := AItem;
FSize += 1;
end;
procedure TPLObjectList.CustomInsert(AIndex: SizeInt; AItem, ATempItem: T);
var
i: SizeInt;
begin
if Empty then begin
Add(AItem);
if Assigned(ATempItem) then ATempItem.Free;
exit;
end;
if AIndex < 0 then AIndex := 0
else if AIndex > Count-1 then AIndex := max(0, Count);
if AIndex < Count then begin
SetLength(FArray, Count+1);
FArray[Count] := ATempItem;
for i := High(FArray) downto AIndex do
FArray[i] := FArray[i-1];
FArray[AIndex] := AItem;
FSize += 1;
end else Add(AItem);
if Assigned(ATempItem) then ATempItem.Free;
end;
procedure TPLObjectList.Insert(AIndex: SizeInt; AItem: T);
begin
CustomInsert(AIndex, AItem, nil);
end;
procedure TPLObjectList.Replace(AIndex1, AIndex2: SizeInt);
var
pom: T;
begin
if (AIndex1 = AIndex2) or (AIndex1 < 0) or (AIndex2 < 0) or (AIndex1 >= Count)
or (AIndex2 >= Count) then exit;
pom := Item[AIndex1];
Item[AIndex1] := Item[AIndex2];
Item[AIndex2] := pom;
end;
procedure TPLObjectList.Remove(AItem: T);
var
id, i: SizeInt;
begin
id := Find(AItem);
if id < 0 then exit;
if FFreeObjects then FArray[id].Free;
for i := id to FSize-2 do
FArray[i] := FArray[i + 1];
FSize := FSize - 1;
SetLength(FArray, FSize);
end;
function TPLObjectList.Count: SizeInt;
begin
Result := FSize;
end;
function TPLObjectList.Empty: TPLBool;
begin
Result := FSize = 0;
end;
procedure TPLObjectList.Clear;
var
i: integer;
begin
if FFreeObjects then begin
for i := 0 to FSize-1 do FArray[i].Free;
end;
FSize := 0;
SetLength(FArray, FSize);
end;
function TPLObjectList.Last: T;
begin
Result := GetItem(FSize - 1);
end;
function TPLObjectList.First: T;
begin
Result := GetItem(0);
end;
function TPLObjectList.Poll: T;
begin
Result := First;
if not Empty then Remove(First);
end;
function TPLObjectList.Pop: T;
begin
Result := Last;
if not Empty then Remove(Last);
end;
function TPLObjectList.Duplicate: specialize IPLObjectList<T>;
var
x: T;
begin
Result := TPLObjectList.Create(FFreeObjects);
for x in self do Result.Add(x);
end;
procedure TPLObjectList.SetObjectsFreeing(const AValue: TPLBool);
begin
FFreeObjects := AValue;
end;
{ TPLList }
function TPLList.GetItem(AIndex: SizeInt): T;
begin
if (AIndex < 0) or (AIndex >= FSize) then
Result := Default(T)
else
Result := FArray[AIndex];
end;
function TPLList.GetData: Pointer;
begin
if FSize > 0 then Result := @FArray[0] else Result := nil;
end;
procedure TPLList.SetItem(AIndex: SizeInt; AValue: T);
begin
if (AIndex < 0) or (AIndex >= FSize) then exit;
FArray[AIndex] := AValue;
end;
function TPLList.GetEnumerator: IListEnumerator;
begin
Result := TListEnumerator.Create(Self);
end;
constructor TPLList.Create;
begin
inherited Create;
FSize := 0;
SetLength(FArray, 0);
end;
destructor TPLList.Destroy;
begin
Clear;
inherited Destroy;
end;
procedure TPLList.Add(AItem: T);
begin
if FSize >= MaxListSize then exit;
SetLength(FArray, FSize + 1);
FArray[FSize] := AItem;
FSize += 1;
end;
procedure TPLList.Remove(AItem: T);
var
id, i: SizeInt;
begin
id := Find(AItem);
if id < 0 then exit;
for i := id to FSize-2 do
FArray[i] := FArray[i + 1];
FSize := FSize - 1;
SetLength(FArray, FSize);
end;
function TPLList.Find(AItem: T): SizeInt;
var
i: SizeInt;
begin
Result := -1;
for i := 0 to FSize-1 do
if FArray[i] = AItem then exit(i);
end;
function TPLList.Count: SizeInt;
begin
Result := FSize;
end;
function TPLList.Empty: TPLBool;
begin
Result := FSize = 0;
end;
procedure TPLList.Clear;
begin
FSize := 0;
SetLength(FArray, FSize);
end;
function TPLList.Last: T;
begin
Result := GetItem(FSize - 1);
end;
function TPLList.First: T;
begin
Result := GetItem(0);
end;
function TPLList.Poll: T;
begin
Result := First;
if not Empty then Remove(First);
end;
function TPLList.Pop: T;
begin
Result := Last;
if not Empty then Remove(Last);
end;
function TPLList.Duplicate: specialize IPLList<T>;
var
x: T;
begin
Result := TPLList.Create;
for x in self do Result.Add(x);
end;
{ TPLInterfaceList }
procedure TPLInterfaceList.Add(AItem: I);
begin
AItem._AddRef;
inherited Add(AItem);
end;
procedure TPLInterfaceList.Remove(AItem: I);
begin
AItem._Release;
inherited Remove(AItem);
end;
procedure TPLInterfaceList.Clear;
var
x: SizeInt;
begin
for x := Low(FArray) to High(FArray) do
FArray[x]._Release;
inherited Clear;
end;
function TPLInterfaceList.Duplicate: specialize IPLInterfaceList<I>;
var
x: I;
begin
Result := TPLInterfaceList.Create;
for x in self do Result.Add(x);
end;
{ TPLFuncs }
class procedure TPLFuncs.Swap(var A, B: T);
var
tmp: T;
begin
tmp := A;
A := B;
B := tmp;
end;
class function TPLFuncs.NewArray(ATab: array of T): specialize TArray<T>;
var
i: TPLInt;
begin
SetLength(Result, Length(ATab));
for i := Low(ATab) to High(ATab) do
Result[i] := ATab[i];
end;
class function TPLFuncs.NewList(ATab: array of T): specialize TPLList<T>;
var
i: SizeInt;
begin
Result := ListHelper.Create;
for i := Low(ATab) to High(ATab) do
Result.Add(ATab[i]);
end;
class function TPLFuncs.ToString(ATab: specialize TArray<T>): TPLString;
var
v: Variant;
i: SizeInt;
begin
Result := '[';
for i := Low(ATab) to High(ATab) do begin
v := ATab[i];
if VarIsStr(v) then
Result += '''' + v + ''''
else
Result += VarToStr(v);
if i < High(ATab) then Result += ', ';
end;
Result += ']';
end;
class procedure TPLFuncs.FillArray(var ATab: array of T; const AValue: T);
var
i: SizeInt;
begin
for i := Low(ATab) to High(ATab) do
ATab[i] := AValue;
end;
class function TPLFuncs.Extract(const AList: specialize TPLList<T>): specialize TArray<T>;
begin
Result := TPLFuncs.NewArray(AList.FArray);
end;
{ TPLFuncsOfClass }
class function TPLFuncsOfClass.DefaultComparator(const AObject: T;
const ACriteria: Variant): TPLSign;
begin
case VarCompareValue(ObjectToVariant(AObject), ACriteria) of
vrEqual: Result := 0;
vrLessThan: Result := -1;
else Result := 1;
end;
end;
class function TPLFuncsOfClass.InternalBinarySearch(AList: ListHelper;
const ACriteria: Variant; c: ComparatorHelper; ALeft, ARight: SizeInt): SizeInt;
var
m: SizeInt;
begin
if ARight >= ALeft then begin
m := ALeft + (ARight - ALeft) div 2;
if c(AList[m], ACriteria) = 0 then exit(m);
if c(AList[m], ACriteria) = -1 then exit(InternalBinarySearch(AList, ACriteria, c, ALeft, m - 1));
exit(InternalBinarySearch(AList, ACriteria, c, m + 1, ARight));
end;
Result := -1;
end;
class function TPLFuncsOfClass.InternalSearch(AList: ListHelper; const ACriteria: Variant;
c: ComparatorHelper): SizeInt;
var
bound: SizeInt = 1;
begin
Result := -1;
if AList.Count = 0 then exit;
while (bound < AList.Count) and (c(AList[bound], ACriteria) = -1) do bound *= 2;
Result := InternalBinarySearch(AList, ACriteria, c, bound div 2, min(bound + 1, AList.Count - 1));
end;
class procedure TPLFuncsOfClass.Swap(var A, B: T);
var
tmp: T;
begin
tmp := A;
A := B;
B := tmp;
end;
class function TPLFuncsOfClass.NewList(ATab: array of T; const AFreeObjects: TPLBool): specialize TPLObjectList<T>;
var
i: SizeInt;
begin
Result := ListHelper.Create(AFreeObjects);
for i := Low(ATab) to High(ATab) do
Result.Add(ATab[i]);
end;
class function TPLFuncsOfClass.NewArray(ATab: array of T): specialize TArray<T>;
var
i: SizeInt;
begin
SetLength(Result, Length(ATab));
for i := Low(ATab) to High(ATab) do
Result[i] := ATab[i];
end;
class function TPLFuncsOfClass.Extract(const AList: specialize TPLObjectList<T>): specialize TArray<T>;
begin
Result := TPLFuncsOfClass.NewArray(AList.FArray);
end;
class function TPLFuncsOfClass.FastSearch(AList: specialize TPLObjectList<T>;
const ACriteria: Variant; ACustomComparator: specialize TPLFuncsOfClassComparator<T>): SizeInt;
begin
if not Assigned(ACustomComparator) then ACustomComparator := @DefaultComparator;
Result := InternalSearch(AList, ACriteria, ACustomComparator);
end;
{ TPLParameter }
class operator TPLParameter.=(a, b: TPLParameter) r: TPLBool;
begin
r := (a.Key = b.Key) and (a.Value = b.Value);
end;
constructor TPLParameter.Create(AKey: K; AValue: V);
begin
Key := AKey;
Value := AValue;
end;
{ TPLHTMLObjectAttributes }
function TPLHTMLObjectAttributes.GetCharset: TPLHTMLObjectAttribute;
begin
Result := FPtrs[7];
end;
function TPLHTMLObjectAttributes.GetClass: TPLHTMLObjectAttribute;
begin
Result := FPtrs[0];
end;
function TPLHTMLObjectAttributes.GetHref: TPLHTMLObjectAttribute;
begin
Result := FPtrs[4];
end;
function TPLHTMLObjectAttributes.GetId: TPLHTMLObjectAttribute;
begin
Result := FPtrs[2];
end;
function TPLHTMLObjectAttributes.GetName: TPLHTMLObjectAttribute;
begin
Result := FPtrs[1];
end;
function TPLHTMLObjectAttributes.GetRel: TPLHTMLObjectAttribute;
begin
Result := FPtrs[8];
end;
function TPLHTMLObjectAttributes.GetSrc: TPLHTMLObjectAttribute;
begin
Result := FPtrs[5];
end;
function TPLHTMLObjectAttributes.GetStyle: TPLHTMLObjectAttribute;
begin
Result := FPtrs[3];
end;
function TPLHTMLObjectAttributes.GetType: TPLHTMLObjectAttribute;
begin
Result := FPtrs[6];
end;
procedure TPLHTMLObjectAttributes.UpdateConsts;
begin
FPtrs[0] := Get('class');
FPtrs[1] := Get('name');
FPtrs[2] := Get('id');
FPtrs[3] := Get('style');
FPtrs[4] := Get('href');
FPtrs[5] := Get('src');
FPtrs[6] := Get('type');
FPtrs[7] := Get('charset');
FPtrs[8] := Get('rel');
end;
procedure TPLHTMLObjectAttributes.Add(AItem: TPLHTMLObjectAttribute);
begin
inherited Add(AItem);
UpdateConsts;
end;
procedure TPLHTMLObjectAttributes.Remove(AItem: TPLHTMLObjectAttribute);
begin
inherited Remove(AItem);
UpdateConsts;
end;
procedure TPLHTMLObjectAttributes.Clear;
begin
inherited Clear;
UpdateConsts;
end;
function TPLHTMLObjectAttributes.Get(AName: TPLString): TPLHTMLObjectAttribute;
var
a: TPLHTMLObjectAttribute;
begin
AName := AName.Trim.ToLower;
if AName.IsEmpty then exit(Default(TPLHTMLObjectAttribute));
for a in Self do
if a.Key.ToLower = AName then exit(a);
Result := Default(TPLHTMLObjectAttribute);
end;
function TPLHTMLObjectAttributes.Has(AName: TPLString): TPLBool;
begin
Result := Get(AName) <> Default(TPLHTMLObjectAttribute);
end;
function TPLHTMLObjectAttributes.ToString: TPLString;
var
attr: TPLHTMLObjectAttribute;
begin
Result := '';
for attr in self do
Result += attr.Key + '="' + attr.Value + '" ';
Result := Result.Trim;
end;
{ TPLHTMLObject }
function TPLHTMLObject.GetAttributes: TPLHTMLObjectAttributes;
begin
Result := FAttributes;
end;
function TPLHTMLObject.GetChild(const AName: TPLString): TPLHTMLObject;
var
c: TPLHTMLObject;
begin
for c in FChildren do begin
if c.Name.ToLower = AName.ToLower then exit(c);
end;
Result := nil;
end;
function TPLHTMLObject.GetChildren: TPLHTMLObjects;
begin
Result := FChildren;
end;
function TPLHTMLObject.GetJSObject: IPLJSBasicObject;
begin
Result := FJSObject;
end;
function TPLHTMLObject.GetName: TPLString;
begin
Result := FName;
end;
function TPLHTMLObject.GetNodeType: TPLHTMLObjectNodeType;
begin
Result := FNodeType;
end;
function TPLHTMLObject.GetParent: TPLHTMLObject;
begin
Result := FParent;
end;
function TPLHTMLObject.GetPosition: SizeInt;
begin
Result := FPosition;
end;
function TPLHTMLObject.GetState: TPLCSSElementState;
begin
Result := FState;
end;
function TPLHTMLObject.GetText: TPLString;
begin
Result := FText;
end;
function TPLHTMLObject.GetZoom: TPLFloat;
begin
Result := FZoom;
end;
procedure TPLHTMLObject.SetName(AValue: TPLString);
begin
AValue := AValue.Trim;
if (FName = AValue) or (AValue.IsEmpty) then exit;
FName := AValue;
end;
procedure TPLHTMLObject.SetNodeType(AValue: TPLHTMLObjectNodeType);
begin
FNodeType := AValue;
end;
procedure TPLHTMLObject.SetParent(AValue: TPLHTMLObject);
begin
FParent := AValue;
end;
procedure TPLHTMLObject.SetPosition(AValue: SizeInt);
begin
FPosition := AValue;
end;
procedure TPLHTMLObject.SetState(AValue: TPLCSSElementState);
begin
FState := AValue;
end;
procedure TPLHTMLObject.SetText(AValue: TPLString);
begin
FText := AValue;
end;
procedure TPLHTMLObject.SetZoom(AValue: TPLFloat);
begin
if (AValue = FZoom) or (AValue <= 0) or (AValue > 10) then exit;
FZoom := AValue;
end;
procedure TPLHTMLObject.DoDraw(ACanvas: Pointer);
begin
// ...
end;
function TPLHTMLObject.DoToHTMLChildren: TPLString;
var
obj: TPLHTMLObject;
begin
Result := '';
for obj in FChildren do
Result += obj.ToHTML + LineEnding;
end;
procedure TPLHTMLObject.InitStates;
begin
// ...
end;
procedure TPLHTMLObject.DoneStates;
begin
// ...
end;
constructor TPLHTMLObject.Create(AParent: TPLHTMLObject);
begin
inherited Create;
FName := 'basic_object';
FText := '';
FState := esNormal;
FZoom := 1;
FPosition := 0;
FZIndex := 0;
FParent := AParent;
FAttributes := TPLHTMLObjectAttributes.Create;
FChildren := TPLHTMLObjects.Create;
InitStates;
end;
destructor TPLHTMLObject.Destroy;
begin
DoneStates;
FAttributes.Free;
FChildren.Free;
inherited Destroy;
end;
function TPLHTMLObject.Clone: IPLHTMLObject;
begin
Result := TPLHTMLObject.Create(FParent as TPLHTMLObject);
end;
function TPLHTMLObject.GetCSSProperty(const AName: TPLString;
AState: TPLCSSElementState; AUseCommonPrefixes: TPLBool): Pointer;
begin
Result := nil;
end;
function TPLHTMLObject.GetCSSPropertyValue(const AName: TPLString;
AState: TPLCSSElementState; AUseCommonPrefixes: TPLBool; AIndex: SizeInt
): Pointer;
begin
Result := nil;
end;
procedure TPLHTMLObject.SetCSSPropertyValue(const AName: TPLString;
const AValue: Pointer; AState: TPLCSSElementState; AIndex: SizeInt);
begin
// ...
end;
procedure TPLHTMLObject.UpdateScrollbars;
begin
// ...
end;
procedure TPLHTMLObject.Draw(ACanvas: Pointer);
var
obj: TPLHTMLObject;
wr: TPLBool;
begin
if not isVisible or (Display = 'none') then exit;
wr := Assigned(Parent) and (Parent.ZIndex <= ZIndex);
if wr then DoDraw(ACanvas);
for obj in FChildren do
obj.Draw(ACanvas);
if not wr then DoDraw(ACanvas);
end;
function TPLHTMLObject.ToHTML: TPLString;
begin
Result := DoToHTMLChildren;
end;
function TPLHTMLObject.ToObject: TPLHTMLObject;
begin
Result := self;
end;
function TPLHTMLObject.PositionInParent: SizeInt;
var
i: SizeInt;
begin
Result := -1;
if not Assigned(FParent) then exit;
for i := 0 to FParent.Children.Count-1 do begin
if FParent.Children[i] = self then exit(i);
end;
end;
procedure TPLHTMLObject.RefreshStyles(const AParentStyles);
begin
// ...
end;
procedure TPLHTMLObject.UpdateLayout;
var
obj: TPLHTMLObject;
begin
if not IsVisible or (Display = 'none') then exit;
for obj in Children do
obj.UpdateLayout;
// size
for obj in Children do
obj.UpdateSizeLayout;
UpdateSizeLayout;
// position
UpdatePositionLayout;
for obj in Children do
obj.UpdatePositionLayout;
end;
procedure TPLHTMLObject.UpdatePositionLayout;
begin
// ...
end;
procedure TPLHTMLObject.UpdateSizeLayout;
begin
// ...
end;
procedure TPLHTMLObject.ApplyInlineStyles;
begin
// ...
end;
function TPLHTMLObject.GetWidth: TPLFloat;
begin
Result := 0;
end;
function TPLHTMLObject.GetHeight: TPLFloat;
begin
Result := 0;
end;
function TPLHTMLObject.GetTop: TPLFloat;
begin
Result := 0;