home *** CD-ROM | disk | FTP | other *** search
- /*
- * name: dellayer
- *
- * description: delete layer lp from the screen.
- *
- * synopsis: dellayer (lp)
- * struct layer *lp;
- *
- * globals: bottomlayer (r/w)
- * toplayer (w)
- *
- * calls: upfront (upfront.c)
- * background (background.c)
- * bfree (bfree.c)
- * free (libc)
- *
- * called by: this is a top level routine.
- */
- #include "layers.h"
-
- extern struct layer *toplayer;
- extern struct layer *bottomlayer;
-
- dellayer (lp)
- struct layer *lp;
- {
- struct obscured *op;
- struct obscured *nop;
-
- /*
- * pull the layer to the front
- * it now has no obscured pieces,
- * and is a contiguous rectangle on the screen
- */
- (void) upfront (lp);
- /*
- * colour the screen rectangle the background colour
- */
- (void) background (&(lp -> ly_rect));
- /*
- * push the layer to the back using upfront()
- */
- while (lp -> ly_back != null) /* lp not rearmost layer */
- (void) upfront (bottomlayer); /* rearmost layer */
- /*
- * all storage needed for the obscured portions of the layer
- * is now bound to the layer,
- * since it obscures no other layer,
- * so free all storage associated with the layer
- */
- for (op = lp -> ly_obs; op != null;) {
- /* op = each obscured part of lp */
- nop = op;
- op = op -> ob_next;
- (void) bfree (nop -> ob_bmap);
- free ((char *) nop);
- }
- /*
- * unlink the layer from the layer list
- */
- if (lp -> ly_back != null)
- lp -> ly_back -> ly_front = lp -> ly_front;
- else
- bottomlayer = lp -> ly_front;
- if (lp -> ly_front != null)
- lp -> ly_front -> ly_back = lp -> ly_back;
- else
- toplayer = lp -> ly_back;
- /*
- * free the layer storage
- */
- free ((char *) lp);
- }