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