[Win32k]
[reactos.git] / reactos / subsystems / win32 / win32k / objects / rect.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
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.
9 *
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.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include <win32k.h>
21
22 #define NDEBUG
23 #include <debug.h>
24
25 /* FUNCTIONS *****************************************************************/
26
27 BOOL
28 FASTCALL
29 RECTL_bUnionRect(RECTL *prclDst, const RECTL *prcl1, const RECTL *prcl2)
30 {
31 if (RECTL_bIsEmptyRect(prcl1))
32 {
33 if (RECTL_bIsEmptyRect(prcl2))
34 {
35 RECTL_vSetEmptyRect(prclDst);
36 return FALSE;
37 }
38 else
39 {
40 *prclDst = *prcl2;
41 }
42 }
43 else
44 {
45 if (RECTL_bIsEmptyRect(prcl2))
46 {
47 *prclDst = *prcl1;
48 }
49 else
50 {
51 prclDst->left = min(prcl1->left, prcl2->left);
52 prclDst->top = min(prcl1->top, prcl2->top);
53 prclDst->right = max(prcl1->right, prcl2->right);
54 prclDst->bottom = max(prcl1->bottom, prcl2->bottom);
55 }
56 }
57
58 return TRUE;
59 }
60
61
62 BOOL
63 FASTCALL
64 RECTL_bIntersectRect(RECTL* prclDst, const RECTL* prcl1, const RECTL* prcl2)
65 {
66 prclDst->left = max(prcl1->left, prcl2->left);
67 prclDst->right = min(prcl1->right, prcl2->right);
68
69 if (prclDst->left < prclDst->right)
70 {
71 prclDst->top = max(prcl1->top, prcl2->top);
72 prclDst->bottom = min(prcl1->bottom, prcl2->bottom);
73
74 if (prclDst->top < prclDst->bottom)
75 {
76 return TRUE;
77 }
78 }
79
80 RECTL_vSetEmptyRect(prclDst);
81
82 return FALSE;
83 }
84
85 VOID
86 FASTCALL
87 RECTL_vMakeWellOrdered(RECTL *prcl)
88 {
89 LONG lTmp;
90 if (prcl->left > prcl->right)
91 {
92 lTmp = prcl->left;
93 prcl->left = prcl->right;
94 prcl->right = lTmp;
95 }
96 if (prcl->top > prcl->bottom)
97 {
98 lTmp = prcl->top;
99 prcl->top = prcl->bottom;
100 prcl->bottom = lTmp;
101 }
102 }
103
104 VOID
105 FASTCALL
106 RECTL_vInflateRect(RECTL *rect, INT dx, INT dy)
107 {
108 rect->left -= dx;
109 rect->top -= dy;
110 rect->right += dx;
111 rect->bottom += dy;
112 }
113
114 /* EOF */