2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: consrv/include/rect.h
5 * PURPOSE: Rectangle helper functions
6 * PROGRAMMERS: Gé van Geldorp
12 #define ConioInitRect(Rect, top, left, bottom, right) \
14 ((Rect)->Top) = top; \
15 ((Rect)->Left) = left; \
16 ((Rect)->Bottom) = bottom; \
17 ((Rect)->Right) = right; \
19 #define ConioIsRectEmpty(Rect) \
20 (((Rect)->Left > (Rect)->Right) || ((Rect)->Top > (Rect)->Bottom))
22 #define ConioRectHeight(Rect) \
23 (((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) - ((Rect)->Top) + 1)
24 #define ConioRectWidth(Rect) \
25 (((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
28 static __inline BOOLEAN
29 ConioGetIntersection(OUT PSMALL_RECT Intersection
,
33 if ( ConioIsRectEmpty(Rect1
) ||
34 ConioIsRectEmpty(Rect2
) ||
35 (Rect1
->Top
> Rect2
->Bottom
) ||
36 (Rect1
->Left
> Rect2
->Right
) ||
37 (Rect1
->Bottom
< Rect2
->Top
) ||
38 (Rect1
->Right
< Rect2
->Left
) )
40 /* The rectangles do not intersect */
41 ConioInitRect(Intersection
, 0, -1, 0, -1);
45 ConioInitRect(Intersection
,
46 max(Rect1
->Top
, Rect2
->Top
),
47 max(Rect1
->Left
, Rect2
->Left
),
48 min(Rect1
->Bottom
, Rect2
->Bottom
),
49 min(Rect1
->Right
, Rect2
->Right
));
54 static __inline BOOLEAN
55 ConioGetUnion(OUT PSMALL_RECT Union
,
59 if (ConioIsRectEmpty(Rect1
))
61 if (ConioIsRectEmpty(Rect2
))
63 ConioInitRect(Union
, 0, -1, 0, -1);
71 else if (ConioIsRectEmpty(Rect2
))
78 min(Rect1
->Top
, Rect2
->Top
),
79 min(Rect1
->Left
, Rect2
->Left
),
80 max(Rect1
->Bottom
, Rect2
->Bottom
),
81 max(Rect1
->Right
, Rect2
->Right
));