home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / bits / bitblit / dellayer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-05-23  |  1.8 KB  |  74 lines

  1. /*
  2.  * name:         dellayer
  3.  *
  4.  * description: delete layer lp from the screen.
  5.  *
  6.  * synopsis:     dellayer (lp)
  7.  *              struct layer    *lp;
  8.  *
  9.  * globals:      bottomlayer  (r/w)
  10.  *              toplayer      (w)
  11.  *
  12.  * calls:        upfront     (upfront.c)
  13.  *              background   (background.c)
  14.  *              bfree        (bfree.c)
  15.  *              free         (libc)
  16.  *
  17.  * called by:    this is a top level routine.
  18.  */
  19. #include "layers.h"
  20.  
  21. extern struct layer *toplayer;
  22. extern struct layer *bottomlayer;
  23.  
  24. dellayer (lp)
  25. struct layer  *lp;
  26. {
  27.    struct obscured *op;
  28.    struct obscured *nop;
  29.  
  30.  /*
  31.   * pull the layer to the front
  32.  * it now has no obscured pieces,
  33.   * and is a contiguous rectangle on the screen
  34.  */
  35.    (void) upfront (lp);
  36.  /*
  37.  * colour the screen rectangle the background colour
  38.  */
  39.    (void) background (&(lp -> ly_rect));
  40.  /*
  41.   * push the layer to the back using upfront()
  42.  */
  43.    while (lp -> ly_back != null)          /* lp not rearmost layer */
  44.        (void) upfront (bottomlayer);   /* rearmost layer */
  45.  /*
  46.  * all storage needed for the obscured portions of the layer
  47.   * is now bound to the layer,
  48.  * since it obscures no other layer,
  49.  * so free all storage associated with the layer
  50.  */
  51.    for (op = lp -> ly_obs; op != null;) {
  52.    /* op = each obscured part of lp */
  53.        nop = op;
  54.        op = op -> ob_next;
  55.        (void) bfree (nop -> ob_bmap);
  56.        free ((char *) nop);
  57.    }
  58.  /*
  59.  * unlink the layer from the layer list
  60.  */
  61.    if (lp -> ly_back != null)
  62.        lp -> ly_back -> ly_front = lp -> ly_front;
  63.    else
  64.        bottomlayer = lp -> ly_front;
  65.    if (lp -> ly_front != null)
  66.        lp -> ly_front -> ly_back = lp -> ly_back;
  67.    else
  68.         toplayer = lp -> ly_back;
  69.  /*
  70.  * free the layer storage
  71.  */
  72.    free ((char *) lp);
  73. }
  74.