blob: bb5286f28c303e6a454c7be1b8c3106fe3ba3408 (
plain)
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
|
function NSMakeRange (loc: NSUInteger; len: NSUInteger): NSRange;
begin
result.location := loc;
result.length := len;
end;
function NSMaxRange (range: NSRange): NSUInteger;
begin
result := range.location + range.length;
end;
function NSLocationInRange (loc: NSUInteger; range: NSRange): boolean;
begin
if (loc <= range.location + range.length) and (loc >= range.location) then
result := true
else
result := false;
end;
function NSEqualRanges (range1, range2: NSRange): boolean;
begin
if (range1.location = range2.location) and (range1.length = range2.length) then
result := true
else
result := false;
end;
function NSMakePoint (x: CGFloat; y: CGFloat): NSPoint;
begin
result.y := y;
result.x := x;
end;
function NSMakeSize(w: CGFloat; h: CGFloat): NSSize;
begin
result.width := w;
result.height := h;
end;
function NSMakeRect(x, y: CGFloat; w, h: CGFloat): NSRect;
begin
result.origin.x := x;
result.origin.y := y;
result.size.width := w;
result.size.height := h;
end;
function NSMaxX (aRect: NSRect): CGFloat;
begin
result := aRect.origin.x + aRect.size.width;
end;
function NSMaxY (aRect: NSRect): CGFloat;
begin
result := aRect.origin.y + aRect.size.height;
end;
function NSMidX (aRect: NSRect): CGFloat;
begin
result := (aRect.origin.x + aRect.size.width) * 0.5 ;
end;
function NSMidY (aRect: NSRect): CGFloat;
begin
result := (aRect.origin.y + aRect.size.height) * 0.5 ;
end;
function NSMinX (aRect: NSRect): CGFloat;
begin
result := aRect.origin.x;
end;
function NSMinY (aRect: NSRect): CGFloat;
begin
result := aRect.origin.y;
end;
function NSWidth (aRect: NSRect): CGFloat;
begin
result := aRect.size.width;
end;
function NSHeight (aRect: NSRect): CGFloat;
begin
result := aRect.size.height;
end;
function NSRectFromCGRect (aRect: CGRect): NSRect;
begin
result.origin.x := aRect.origin.x;
result.origin.y := aRect.origin.y;
result.size.width := aRect.size.width;
result.size.height := aRect.size.height;
end;
function NSRectToCGRect (aRect: NSRect): CGRect;
begin
result.origin.x := aRect.origin.x;
result.origin.y := aRect.origin.y;
result.size.width := aRect.size.width;
result.size.height := aRect.size.height;
end;
function NSPointFromCGPoint (aPoint: CGPoint): NSPoint;
begin
result.y := aPoint.y;
result.x := aPoint.x;
end;
function NSPointToCGPoint (aPoint: NSPoint): CGPoint;
begin
result.y := aPoint.y;
result.x := aPoint.x;
end;
function NSSizeFromCGSize(aSize: CGSize): NSSize;
begin
result.width := aSize.width;
result.height := aSize.height;
end;
function NSSizeToCGSize(aSize: NSSize): CGSize;
begin
result.width := aSize.width;
result.height := aSize.height;
end;
function NSSTR (inString: PChar): NSString;
begin
Result := NSString(CFSTR(inString));
end;
|