+ Compatibility checks and code reformatting

This commit is contained in:
michael 2004-01-10 19:00:20 +00:00
parent ea7ed753c8
commit 01c02d63bb

View File

@ -23,10 +23,10 @@ unit types;
{$endif Win32}
{$ifndef ver1_0}
const
const
RT_RCDATA = PChar(10);
type
type
DWORD = LongWord;
PLongint = System.PLongint;
@ -49,7 +49,8 @@ unit types;
TBooleanDynArray = array of Boolean;
TStringDynArray = array of AnsiString;
TWideStringDynArray = array of WideString;
{$ifdef Win32}
{$ifdef Win32}
TPoint = Windows.TPoint;
{$else}
TPoint = packed record
@ -85,13 +86,14 @@ unit types;
end;
PSmallPoint = ^TSmallPoint;
type
type
TOleChar = WideChar;
POleStr = PWideChar;
PPOleStr = ^POleStr;
{$ifndef win32}
const
const
STGTY_STORAGE = 1;
STGTY_STREAM = 2;
STGTY_LOCKBYTES = 3;
@ -152,7 +154,7 @@ unit types;
GUID_NULL: TGUID = '{00000000-0000-0000-0000-000000000000}';
type
type
PCLSID = PGUID;
TCLSID = TGUID;
@ -227,55 +229,70 @@ unit types;
{$endif HASINTF}
{$endif win32}
function EqualRect(const r1,r2 : TRect) : Boolean;
function Rect(Left,Top,Right,Bottom : Integer) : TRect;
function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
function Point(x,y : Integer) : TPoint;
function PtInRect(const Rect : TRect; const p : TPoint) : Boolean;
function IntersectRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
function UnionRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
function IsRectEmpty(const Rect : TRect) : Boolean;
function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
function EqualRect(const r1,r2 : TRect) : Boolean;
function Rect(Left,Top,Right,Bottom : Integer) : TRect;
function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
function Point(x,y : Integer) : TPoint;
function PtInRect(const Rect : TRect; const p : TPoint) : Boolean;
function IntersectRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
function UnionRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
function IsRectEmpty(const Rect : TRect) : Boolean;
function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
function CenterPoint(const Rect: TRect): TPoint;
{$endif ver1_0}
implementation
implementation
{$ifndef ver1_0}
function EqualRect(const r1,r2 : TRect) : Boolean;
begin
EqualRect:=(r1.left=r2.left) and (r1.right=r2.right) and (r1.top=r2.top) and (r1.bottom=r2.bottom);
end;
function Rect(Left,Top,Right,Bottom : Integer) : TRect;
begin
function EqualRect(const r1,r2 : TRect) : Boolean;
begin
EqualRect:=(r1.left=r2.left) and (r1.right=r2.right) and (r1.top=r2.top) and (r1.bottom=r2.bottom);
end;
function Rect(Left,Top,Right,Bottom : Integer) : TRect;
begin
Rect.Left:=Left;
Rect.Top:=Top;
Rect.Right:=Right;
Rect.Bottom:=Bottom;
end;
end;
function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
begin
function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
begin
Bounds.Left:=ALeft;
Bounds.Top:=ATop;
Bounds.Right:=ALeft+AWidth;
Bounds.Bottom:=ATop+AHeight;
end;
end;
function Point(x,y : Integer) : TPoint;
begin
function Point(x,y : Integer) : TPoint;
begin
Point.x:=x;
Point.y:=y;
end;
end;
function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;
begin
PtInRect:=(p.y>=Rect.Top) and (p.y<Rect.Bottom) and (p.x>=Rect.Left) and (p.x<Rect.Right);
end;
function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;
function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
begin
begin
PtInRect:=(p.y>=Rect.Top) and
(p.y<Rect.Bottom) and
(p.x>=Rect.Left) and
(p.x<Rect.Right);
end;
function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
begin
Rect:=R1;
with R2 do
begin
@ -295,10 +312,10 @@ unit types;
end
else
IntersectRect:=true;
end;
end;
function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
begin
function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
begin
Rect:=R1;
with R2 do
begin
@ -318,15 +335,15 @@ unit types;
end
else
UnionRect:=true;
end;
end;
function IsRectEmpty(const Rect : TRect) : Boolean;
begin
function IsRectEmpty(const Rect : TRect) : Boolean;
begin
IsRectEmpty:=(Rect.Right<=Rect.Left) or (Rect.Bottom<=Rect.Top);
end;
end;
function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
begin
function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
begin
if assigned(@Rect) then
begin
with Rect do
@ -340,14 +357,28 @@ unit types;
end
else
OffsetRect:=false;
end;
function CenterPoint(const Rect: TRect): TPoint;
begin
With Rect do
begin
Result.X:=(Left+Right) div 2;
Result.Y:=(Top+Bottom) div 2;
end;
end;
{$endif ver1_0}
end.
{
$Log$
Revision 1.5 2003-10-05 19:10:03 florian
Revision 1.6 2004-01-10 19:00:20 michael
+ Compatibility checks and code reformatting
Revision 1.5 2003/10/05 19:10:03 florian
* fixed some delphi compatibilty issues
Revision 1.4 2003/04/24 11:09:36 florian