home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / WNUNHIDE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-13  |  4.9 KB  |  164 lines

  1. /**
  2. *
  3. * Name        wnunhide -- Redisplay hidden window.
  4. *
  5. * Synopsis    presult = wnunhide(pwin);
  6. *
  7. *        BWINDOW *presult  Pointer to newly-redisplayed BWINDOW
  8. *                  structure, or NIL if failure.
  9. *        BWINDOW *pwin      Pointer to BWINDOW structure to
  10. *                  redisplay.
  11. *
  12. * Description    This function redisplays a window that has been
  13. *        previously displayed but is now hidden.  The window's
  14. *        location and border are the same as before.
  15. *
  16. *        There is no effect if the window is currently displayed
  17. *        and visible.
  18. *
  19. *        The window's cursor is not activated.  The window is not
  20. *        made current if it was not previously current.
  21. *
  22. *        If the window covers any part of the data area of the
  23. *        window whose cursor is active, then that window's cursor
  24. *        is deactivated and the screen's cursor is made
  25. *        invisible.
  26. *
  27. *        An error occurs if pwin does not point to a valid window
  28. *        structure, or if the window has been designated "not
  29. *        removable", or if the window is not currently attached
  30. *        to a display device and page, or if the dimensions of
  31. *        the screen have changed (due to a change of mode) so
  32. *        that the window no longer fits on the screen.
  33. *
  34. *        In the event of most types of errors, this function will
  35. *        mark the window as not being displayed anywhere, so it
  36. *        may be possible to redisplay the window using WNDSPLAY.
  37. *
  38. * Returns    presult       Pointer to newly-hidden BWINDOW
  39. *                  structure, or NIL if failure.
  40. *        *pwin          Several fields altered.
  41. *        b_pactnode[][]      Window node with active cursor.
  42. *        b_wnerr       Possible values:
  43. *                  (No change)       Success.
  44. *                  WN_BAD_WIN       *pwin is invalid.
  45. *                  WN_NOT_SHOWN       Not attached to device
  46. *                           and page.
  47. *                  WN_NO_MEMORY       Insufficient memory.
  48. *                  WN_BAD_NODE       Internal error.
  49. *                  WN_BAD_DEV       Internal error.
  50. *                  WN_BAD_PAGE       Internal error.
  51. *                  WN_COVERED       Internal error.
  52. *                  WN_ILL_DIM       Internal error.
  53. *                  WN_NULL_PTR       Internal error.
  54. *
  55. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  56. *
  57. * Version    3.02 March 20, 1987
  58. *        Removed static variables to allow re-entrancy.
  59. *        Corrected error in call to WNCOVER.
  60. *
  61. **/
  62.  
  63. #include <bwindow.h>
  64.  
  65. #define restore_video()                           \
  66.      (scpage(old_npage),scchgdev(old_dev),(void) scpage(old_page))
  67.  
  68. BWINDOW *wnunhide(pwin)
  69. BWINDOW *pwin;
  70. {
  71.     int mode,columns,act_page;
  72.     int old_dev,old_page,old_npage;
  73.  
  74.     if (wnvalwin(pwin) == NIL)          /* Validate window structure    */
  75.     {
  76.     wnerror(WN_BAD_WIN);
  77.     return NIL;
  78.     }
  79.  
  80.     old_page = b_curpage;          /* Note current page on former  */
  81.                       /* device.              */
  82.  
  83.                       /* Note former device.          */
  84.     old_dev  = scmode(&mode,&columns,&act_page);
  85.  
  86.     if (wnseldev(&pwin->where_shown,&pwin->img.dim,&old_npage))
  87.     {                      /* Validate and select device   */
  88.                       /* and page.              */
  89.     wnerror(WN_NOT_SHOWN);
  90.     return NIL;
  91.     }
  92.  
  93.     if (!pwin->options.hidden)          /* Quit if not hidden.          */
  94.     {
  95.     restore_video();
  96.     return pwin;              /* (This is not an error.)      */
  97.     }
  98.  
  99.     if (wnpgrem(pwin) == NIL)          /* Remove existing node.          */
  100.     {
  101.     pwin->where_shown.dev = ABSENT;
  102.     restore_video();
  103.     return NIL;
  104.     }
  105.  
  106.                       /* Add this window to linked    */
  107.                       /* list for this display page.  */
  108.     if (NIL == (pwin->pnode = wnpgadd(pwin,
  109.                       pwin->where_shown.dev,
  110.                       pwin->where_shown.page)))
  111.     {
  112.     pwin->where_shown.dev = ABSENT;
  113.     restore_video();
  114.     return NIL;
  115.     }
  116.  
  117.  
  118.     if (pwin->options.removable)      /* Read previous screen contents*/
  119.     if (wngetimg(&pwin->prev,&pwin->where_prev) == NIL)
  120.     {
  121.         wnpgrem(pwin);          /* Clean up after failure.      */
  122.         pwin->where_shown.dev = ABSENT;
  123.         restore_video();
  124.         return NIL;
  125.     }
  126.  
  127.     if (NIL == wnputimg(&pwin->img,           /* Write the data.      */
  128.             &pwin->where_shown))
  129.     {
  130.     wnpgrem(pwin);              /* Clean up after failure.      */
  131.     pwin->where_shown.dev = ABSENT;
  132.     restore_video();
  133.     return NIL;
  134.     }
  135.  
  136.     wnputbor(&pwin->img.dim,
  137.          &pwin->bord,
  138.          &pwin->where_shown);     /* Write the border.          */
  139.  
  140.     pwin->options.hidden         =          /* Displayed, not hidden*/
  141.     pwin->internals.frozen         =          /* Not covered.          */
  142.     pwin->internals.dirty         =          /* No pending writes.   */
  143.     pwin->internals.any_data_covered = 0;     /* Not covered.          */
  144.     pwin->internals.cur_frozen         = 1;     /* Inactive cursor.     */
  145.  
  146.     if (pwin->pnode->below != NIL)    /* If other windows are shown   */
  147.                       /* on this page, then          */
  148.     {                      /* mark them if covered.          */
  149.     if (wncover(pwin->pnode->below,
  150.             &pwin->where_prev.corner,
  151.             &pwin->prev.dim)           == NIL)
  152.     {
  153.         wnpgrem(pwin);          /* Clean up after failure.      */
  154.         pwin->where_shown.dev = ABSENT;
  155.         restore_video();
  156.         return NIL;
  157.     }
  158.     }
  159.  
  160.     restore_video();
  161.  
  162.     return pwin;
  163. }
  164.