home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / WNREDRAW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  4.8 KB  |  169 lines

  1. /**
  2. *
  3. * Name        wnredraw -- Redisplay all windows currently shown
  4. *                on a display page and restore cursor.
  5. *
  6. * Synopsis    result = wnredraw(dev,page);
  7. *
  8. *        int result      Error code, or WN_NO_ERROR if ok.
  9. *        int dev       Video display device (COLOR or MONO).
  10. *        int page      Video display page.
  11. *
  12. * Description    This function redisplays all windows currently shown on
  13. *        a video display page as they are currently recorded in
  14. *        internal data structures.  If one of the displayed
  15. *        windows is designated to have an active cursor, then its
  16. *        cursor is restored.  Hidden windows retain their borders
  17. *        and positions but are not displayed.
  18. *
  19. *        The designated device and page are made current.
  20. *
  21. *        As removable windows are redisplayed, their recorded
  22. *        copies of the previous screen contents are NOT changed.
  23. *
  24. *        An error occurs if dev or page refers to an unavailable
  25. *        video device or display page.
  26. *
  27. * Returns    result          Possible values:
  28. *                  WN_NO_ERROR       Success.
  29. *                  WN_BAD_DEV       Invalid dev.
  30. *                  WN_BAD_PAGE       Invalid page.
  31. *                  WN_BAD_NODE       Internal error.
  32. *                  WN_BAD_WIN       Internal error.
  33. *                  WN_COVERED       Internal error.
  34. *                  WN_NOT_SHOWN       Internal error.
  35. *                  WN_ILL_DIM       Internal error.
  36. *                  WN_NULL_PTR       Internal error.
  37. *
  38. *        b_wnerr       Possible values:
  39. *                  (No change)       Success.
  40. *                  WN_BAD_DEV       Invalid dev.
  41. *                  WN_BAD_PAGE       Invalid page.
  42. *                  WN_BAD_NODE       Internal error.
  43. *                  WN_BAD_WIN       Internal error.
  44. *                  WN_COVERED       Internal error.
  45. *                  WN_NOT_SHOWN       Internal error.
  46. *                  WN_ILL_DIM       Internal error.
  47. *                  WN_NULL_PTR       Internal error.
  48. *
  49. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  50. *
  51. **/
  52.  
  53. #include <bwindow.h>
  54.  
  55. int redraw(WIN_NODE *);           /* Internal function (see below)*/
  56.  
  57. int wnredraw(dev,page)
  58. int dev,page;
  59. {
  60.     int      result;
  61.     WIN_NODE *pnode;
  62.  
  63.     if (dev  < 0 || dev  > MAX_DEVICES) /* Make sure dev & page       */
  64.     return wnerror(WN_BAD_DEV);    /* are at least within range  */
  65.     if (page < 0 || page > MAX_PAGES)    /* for table lookups.          */
  66.     return wnerror(WN_BAD_PAGE);
  67.  
  68.     result = WN_NO_ERROR;
  69.  
  70.                       /* If this page has windows,    */
  71.     if (NIL != (pnode = b_wnlist[dev][page]))
  72.     {
  73.                       /* then redraw the windows.     */
  74.     result = redraw(pnode);
  75.                       /* If that was successful       */
  76.     if (WN_NO_ERROR == result
  77.                       /* and if a window has an       */
  78.                       /* active cursor,           */
  79.         && NIL != (pnode = b_pactnode[dev][page]))
  80.     {
  81.                       /* then activate the correct    */
  82.                       /* cursor.              */
  83.         if (NIL == wncursor(pnode->pwin))
  84.             result = b_wnerr;
  85.     }
  86.     }
  87.  
  88.     return result;
  89. }
  90.  
  91. /**
  92. *
  93. * Name        redraw -- Redisplay all windows currently shown
  94. *              on a display page at or below a given
  95. *              window.
  96. *
  97. * Synopsis    result = redraw(pnode);
  98. *
  99. *        int     result   Error code, or WN_NO_ERROR if ok.
  100. *        WIN_NODE *pnode   Node of uppermost window to redisplay.
  101. *
  102. * Description    This function redisplays a window currently shown on a
  103. *        video display page (and all windows below it) as they
  104. *        are currently recorded in internal data structures.
  105. *        Hidden windows retain their borders and positions but
  106. *        are not displayed.
  107. *
  108. *        The device and page corresponding to this node are made
  109. *        current.
  110. *
  111. *        As removable windows are redisplayed, their recorded
  112. *        copies of the previous screen contents are NOT changed.
  113. *
  114. * Returns    result          Possible values:
  115. *                  WN_NO_ERROR       Success.
  116. *                  WN_BAD_DEV       Internal error.
  117. *                  WN_BAD_PAGE       Internal error.
  118. *                  WN_BAD_NODE       Internal error.
  119. *                  WN_BAD_WIN       Internal error.
  120. *                  WN_COVERED       Internal error.
  121. *                  WN_NOT_SHOWN       Internal error.
  122. *                  WN_ILL_DIM       Internal error.
  123. *                  WN_NULL_PTR       Internal error.
  124. *
  125. *        b_wnerr       Possible values:
  126. *                  (No change)       Success.
  127. *                  (Same as "result" if internal error.)
  128. *
  129. **/
  130.  
  131. static int redraw(pnode)
  132. WIN_NODE *pnode;
  133. {
  134.     int     result;
  135.     BWINDOW *pwin;
  136.  
  137.     if (wnvalnod(pnode) == NIL)
  138.     return wnerror(WN_BAD_NODE);
  139.  
  140.     pwin = pnode->pwin;
  141.     if (wnvalwin(pwin) == NIL)
  142.     return wnerror(WN_BAD_WIN);
  143.  
  144.     pwin->internals.temp_hid = 0;     /* Clean up temp. flag.          */
  145.  
  146.                       /* Redraw lower windows before  */
  147.                       /* handling this one.          */
  148.     if (pnode->below != NIL)
  149.     if (WN_NO_ERROR != (result = redraw(pnode->below)))
  150.         return result;          /* Propagate error back upward. */
  151.  
  152.     if (!pwin->options.hidden)
  153.     {
  154.                       /* Write border.              */
  155.     wnputbor(&pwin->img.dim,
  156.          &pwin->bord,
  157.          &pwin->where_shown);
  158.  
  159.                       /* Write data.              */
  160.     if (NIL == wnputimg(&pwin->img,
  161.                 &pwin->where_shown))
  162.         return b_wnerr;
  163.     }
  164.  
  165.     pwin->internals.dirty = 0;          /* Output is now up-to-date.    */
  166.  
  167.     return WN_NO_ERROR;
  168. }
  169.