diff options
author | rjohnson <rjohnson> | 1998-04-01 09:51:44 (GMT) |
---|---|---|
committer | rjohnson <rjohnson> | 1998-04-01 09:51:44 (GMT) |
commit | 066ea7fd88d49cb456f74da71dbe875e4fc0aabb (patch) | |
tree | 8fb30cb152c4dc191be47fa043d2e6f5ea38c7ba /win/tkWinRegion.c | |
parent | 13242623d2ff3ea02ab6a62bfb48a7dbb5c27e22 (diff) | |
download | tk-066ea7fd88d49cb456f74da71dbe875e4fc0aabb.zip tk-066ea7fd88d49cb456f74da71dbe875e4fc0aabb.tar.gz tk-066ea7fd88d49cb456f74da71dbe875e4fc0aabb.tar.bz2 |
Initial revision
Diffstat (limited to 'win/tkWinRegion.c')
-rw-r--r-- | win/tkWinRegion.c | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/win/tkWinRegion.c b/win/tkWinRegion.c new file mode 100644 index 0000000..3303022 --- /dev/null +++ b/win/tkWinRegion.c @@ -0,0 +1,179 @@ +/* + * tkWinRegion.c -- + * + * Tk Region emulation code. + * + * Copyright (c) 1995 Sun Microsystems, Inc. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * SCCS: @(#) tkWinRegion.c 1.7 96/05/03 11:05:54 + */ + +#include "tkWinInt.h" + + +/* + *---------------------------------------------------------------------- + * + * TkCreateRegion -- + * + * Construct an empty region. + * + * Results: + * Returns a new region handle. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +TkRegion +TkCreateRegion() +{ + RECT rect; + memset(&rect, 0, sizeof(RECT)); + return (TkRegion) CreateRectRgnIndirect(&rect); +} + +/* + *---------------------------------------------------------------------- + * + * TkDestroyRegion -- + * + * Destroy the specified region. + * + * Results: + * None. + * + * Side effects: + * Frees the storage associated with the specified region. + * + *---------------------------------------------------------------------- + */ + +void +TkDestroyRegion(r) + TkRegion r; +{ + DeleteObject((HRGN) r); +} + +/* + *---------------------------------------------------------------------- + * + * TkClipBox -- + * + * Computes the bounding box of a region. + * + * Results: + * Sets rect_return to the bounding box of the region. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkClipBox(r, rect_return) + TkRegion r; + XRectangle* rect_return; +{ + RECT rect; + GetRgnBox((HRGN)r, &rect); + rect_return->x = (short) rect.left; + rect_return->y = (short) rect.top; + rect_return->width = (short) (rect.right - rect.left); + rect_return->height = (short) (rect.bottom - rect.top); +} + +/* + *---------------------------------------------------------------------- + * + * TkIntersectRegion -- + * + * Compute the intersection of two regions. + * + * Results: + * Returns the result in the dr_return region. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkIntersectRegion(sra, srb, dr_return) + TkRegion sra; + TkRegion srb; + TkRegion dr_return; +{ + CombineRgn((HRGN) dr_return, (HRGN) sra, (HRGN) srb, RGN_AND); +} + +/* + *---------------------------------------------------------------------- + * + * TkUnionRectWithRegion -- + * + * Create the union of a source region and a rectangle. + * + * Results: + * Returns the result in the dr_return region. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkUnionRectWithRegion(rectangle, src_region, dest_region_return) + XRectangle* rectangle; + TkRegion src_region; + TkRegion dest_region_return; +{ + HRGN rectRgn = CreateRectRgn(rectangle->x, rectangle->y, + rectangle->x + rectangle->width, rectangle->y + rectangle->height); + CombineRgn((HRGN) dest_region_return, (HRGN) src_region, + (HRGN) rectRgn, RGN_OR); + DeleteObject(rectRgn); +} + +/* + *---------------------------------------------------------------------- + * + * TkRectInRegion -- + * + * Test whether a given rectangle overlaps with a region. + * + * Results: + * Returns RectanglePart or RectangleOut. Note that this is + * not a complete implementation since it doesn't test for + * RectangleIn. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkRectInRegion(r, x, y, width, height) + TkRegion r; + int x; + int y; + unsigned int width; + unsigned int height; +{ + RECT rect; + rect.top = y; + rect.left = x; + rect.bottom = y+height; + rect.right = x+width; + return RectInRegion((HRGN)r, &rect) ? RectanglePart : RectangleOut; +} |