home *** CD-ROM | disk | FTP | other *** search
- /* clip.c and clip.h */
- /* A separate compilation unit for the clipping functions */
- /* In clip.h: declare public things (i.e., the functions) */
- /* In clip.c: make the actual definitions */
-
- /* First of all, include our own header file, which will */
- /* declare our public functions */
- #include "clip.h"
-
- #include<clib/graphics_protos.h>
- #include<clib/layers_protos.h>
-
- /* Set a clip region on internal part of window */
- int setClipInternal(struct Window* win)
- {
- /* Make a rectangle that describes the inside of the window */
- struct Rectangle rect;
- rect.MinX = win->BorderLeft;
- rect.MinY = win->BorderTop;
- rect.MaxX = win->Width - win->BorderRight - 1;
- rect.MaxY = win->Height - win->BorderBottom - 1;
- return setClipSized(win, &rect);
- }
-
- /* Set a clip region on a specified part of window */
- int setClipSized(struct Window* win, struct Rectangle* size)
- {
- /* Make a new region */
- struct Region* reg;
- if(reg = NewRegion())
- {
- /* Make the region equal to the size rectangle */
- if(OrRectRegion(reg, size))
- {
- /* Set the clip region on the window's layer */
- InstallClipRegion(win->WLayer, reg);
- /* Say we succeeded */
- return TRUE;
- }
- else
- {
- /* Failed to set region, so delete it */
- DisposeRegion(reg);
- }
- }
- /* If we get this far then we've failed */
- return FALSE;
- }
-
- /* Remove the clip region from a window */
- void removeClip(struct Window* win)
- {
- struct Region* reg;
- if(reg = InstallClipRegion(win->WLayer, NULL))
- {
- /* If a clip region is installed we assume it's our new one */
- /* and so delete it */
- DisposeRegion(reg);
- }
- }
-