-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDW.CORE.MergeSortFunc.pas
83 lines (73 loc) · 1.74 KB
/
DW.CORE.MergeSortFunc.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
unit DW.CORE.MergeSortFunc;
interface
uses Classes, Controls;
function ControlRenderingSort(AItem1: Pointer; AItem2: Pointer): Integer;
function TabIndexSort(AItem1: Pointer; AItem2: Pointer): Integer;
implementation
uses DWGlobal, DWTypes, DW.VCL.TabControl;
function TabIndexSort(AItem1: Pointer; AItem2: Pointer): Integer;
var
LTab1, LTab2: Integer;
begin
if TComponent(AItem1) is TDWTabPage then
begin
LTab1 := TDWTabPage(AItem1).TabIndex;
end
else
begin
LTab1 := -1;
end;
if TComponent(AItem2) is TDWTabPage then
begin
LTab2 := TDWTabPage(AItem2).TabIndex;
end
else
begin
LTab2 := -1;
end;
Result := LTab1 - LTab2;
end;
function ControlRenderingSort(AItem1: Pointer; AItem2: Pointer): Integer;
var
LTop1, LLeft1, LTop2, LLeft2, LIdx1, LIdx2: Integer;
begin
if TComponent(AItem1) is TControl then
begin
LTop1 := TControl(AItem1).Top;
LLeft1 := TControl(AItem1).Left;
LIdx1 := TControl(AItem1).ComponentIndex;
end
else
begin
LTop1 := -1;
LLeft1 := -1;
LIdx1 := -1;
end;
if TComponent(AItem2) is TControl then
begin
LTop2 := TControl(AItem2).Top;
LLeft2 := TControl(AItem2).Left;
LIdx2 := TControl(AItem2).ComponentIndex;
end
else
begin
LTop2 := -1;
LLeft2 := -1;
LIdx2 := -1;
end;
if gIWBSRenderingSortMethod = bsrmSortYX then
begin
Result := LTop1 - LTop2;
if Abs(Result) < gIWBSRenderingGridPrecision then
Result := LLeft1 - LLeft2;
end
else
begin
Result := LLeft1 - LLeft2;
if Abs(Result) < gIWBSRenderingGridPrecision then
Result := LTop1 - LTop2;
end;
if Result = 0 then
Result := LIdx1 - LIdx2;
end;
end.