ba44d7a31c834db4054791bfd9ef9c48fb60789b
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: rect.c,v 1.7 2002/09/03 22:44:20 dwelch Exp $
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/windows/input.c
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * 09-05-2001 CSH Created
29 /* INCLUDES ******************************************************************/
35 /* FUNCTIONS *****************************************************************/
38 CopyRect(LPRECT lprcDst
, CONST RECT
*lprcSrc
)
55 InflateRect(LPRECT rect
, int dx
, int dy
)
65 IntersectRect(LPRECT lprcDst
,
69 if (IsRectEmpty(lprcSrc1
) || IsRectEmpty(lprcSrc2
) ||
70 lprcSrc1
->left
>= lprcSrc2
->right
||
71 lprcSrc2
->left
>= lprcSrc1
->right
||
72 lprcSrc1
->top
>= lprcSrc2
->bottom
||
73 lprcSrc2
->top
>= lprcSrc1
->bottom
)
75 SetRectEmpty(lprcDst
);
78 lprcDst
->left
= max(lprcSrc1
->left
, lprcSrc2
->left
);
79 lprcDst
->right
= min(lprcSrc1
->right
, lprcSrc2
->right
);
80 lprcDst
->top
= max(lprcSrc1
->top
, lprcSrc2
->top
);
81 lprcDst
->bottom
= min(lprcSrc1
->bottom
, lprcSrc2
->bottom
);
85 IsRectEmpty(CONST RECT
*lprc
)
87 return((lprc
->left
>= lprc
->right
) || (lprc
->top
>= lprc
->bottom
));
91 OffsetRect(LPRECT rect
, int dx
, int dy
)
101 PtInRect(CONST RECT
*lprc
, POINT pt
)
103 return((pt
.x
>= lprc
->left
) && (pt
.x
< lprc
->right
) &&
104 (pt
.y
>= lprc
->top
) && (pt
.y
< lprc
->bottom
));
108 SetRect(LPRECT lprc
, int xLeft
, int yTop
, int xRight
, int yBottom
)
112 lprc
->right
= xRight
;
113 lprc
->bottom
= yBottom
;
118 SetRectEmpty(LPRECT lprc
)
120 lprc
->left
= lprc
->right
= lprc
->top
= lprc
->bottom
= 0;
125 SubtractRect(LPRECT lprcDst
, CONST RECT
*lprcSrc1
, CONST RECT
*lprcSrc2
)
132 UnionRect(LPRECT lprcDst
, CONST RECT
*lprcSrc1
, CONST RECT
*lprcSrc2
)
134 if (IsRectEmpty(lprcSrc1
))
136 if (IsRectEmpty(lprcSrc2
))
138 SetRectEmpty(lprcDst
);
143 *lprcDst
= *lprcSrc2
;
148 if (IsRectEmpty(lprcSrc2
))
150 *lprcDst
= *lprcSrc1
;
154 lprcDst
->left
= min(lprcSrc1
->left
, lprcSrc2
->left
);
155 lprcDst
->top
= min(lprcSrc1
->top
, lprcSrc2
->top
);
156 lprcDst
->right
= max(lprcSrc1
->right
, lprcSrc2
->right
);
157 lprcDst
->bottom
= max(lprcSrc1
->bottom
, lprcSrc2
->bottom
);