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.
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)
40 if(lprcDst == NULL || lprcSrc == NULL)
53 if ((lprc1->left == lprc2->left)
54 && (lprc1->top == lprc2->top)
55 && (lprc1->right == lprc2->right)
56 && (lprc1->bottom == lprc2->bottom))
60 /* TODO: return the correct error code. */
61 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
66 InflateRect(LPRECT rect, int dx, int dy)
76 IntersectRect(LPRECT lprcDst,
80 if (IsRectEmpty(lprcSrc1) || IsRectEmpty(lprcSrc2) ||
81 lprcSrc1->left >= lprcSrc2->right ||
82 lprcSrc2->left >= lprcSrc1->right ||
83 lprcSrc1->top >= lprcSrc2->bottom ||
84 lprcSrc2->top >= lprcSrc1->bottom)
86 SetRectEmpty(lprcDst);
89 lprcDst->left = max(lprcSrc1->left, lprcSrc2->left);
90 lprcDst->right = min(lprcSrc1->right, lprcSrc2->right);
91 lprcDst->top = max(lprcSrc1->top, lprcSrc2->top);
92 lprcDst->bottom = min(lprcSrc1->bottom, lprcSrc2->bottom);
97 IsRectEmpty(CONST RECT *lprc)
99 return((lprc->left >= lprc->right) || (lprc->top >= lprc->bottom));
103 OffsetRect(LPRECT rect, int dx, int dy)
116 PtInRect(CONST RECT *lprc, POINT pt)
118 return((pt.x >= lprc->left) && (pt.x < lprc->right) &&
119 (pt.y >= lprc->top) && (pt.y < lprc->bottom));
123 SetRect(LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom)
127 lprc->right = xRight;
128 lprc->bottom = yBottom;
133 SetRectEmpty(LPRECT lprc)
135 lprc->left = lprc->right = lprc->top = lprc->bottom = 0;
140 SubtractRect(LPRECT lprcDst, CONST RECT *lprcSrc1, CONST RECT *lprcSrc2)
144 if(lprcDst == NULL || lprcSrc1 == NULL || lprcSrc2 == NULL)
147 CopyRect(lprcDst, lprcSrc1);
149 if(!IntersectRect(&tempRect, lprcSrc1, lprcSrc2))
152 if(lprcDst->top == tempRect.top && lprcDst->bottom == tempRect.bottom)
154 if(lprcDst->left == tempRect.left)
155 lprcDst->left = tempRect.right;
156 else if(lprcDst->right == tempRect.right)
157 lprcDst->right = tempRect.left;
159 else if(lprcDst->left == tempRect.left && lprcDst->right == tempRect.right)
161 if(lprcDst->top == tempRect.top)
162 lprcDst->top = tempRect.bottom;
163 else if(lprcDst->right == tempRect.right)
164 lprcDst->right = tempRect.left;
171 UnionRect(LPRECT lprcDst, CONST RECT *lprcSrc1, CONST RECT *lprcSrc2)
173 if (IsRectEmpty(lprcSrc1))
175 if (IsRectEmpty(lprcSrc2))
177 SetRectEmpty(lprcDst);
182 *lprcDst = *lprcSrc2;
187 if (IsRectEmpty(lprcSrc2))
189 *lprcDst = *lprcSrc1;
193 lprcDst->left = min(lprcSrc1->left, lprcSrc2->left);
194 lprcDst->top = min(lprcSrc1->top, lprcSrc2->top);
195 lprcDst->right = max(lprcSrc1->right, lprcSrc2->right);
196 lprcDst->bottom = max(lprcSrc1->bottom, lprcSrc2->bottom);