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

  1. /**
  2. *
  3. * Name        wnforget -- Detach window from screen location
  4. *                without cleaning screen up.
  5. *
  6. * Synopsis    presult = wnforget(pwin);
  7. *
  8. *        BWINDOW *presult  Pointer to newly-removed BWINDOW
  9. *                  structure, or NIL if failure.
  10. *        BWINDOW *pwin      Pointer to BWINDOW structure to
  11. *                  remove.
  12. *
  13. * Description    This function "removes" a window from the video display
  14. *        page where it is displayed without actually modifying
  15. *        any displayed characters.  That is, the previous screen
  16. *        data is not replaced (even in the case of a removable
  17. *        window).
  18. *
  19. *        An error occurs if pwin does not point to a valid window
  20. *        structure or if the window is not currently displayed.
  21. *
  22. *        Use WNREMOVE to gracefully clean up the screen as the
  23. *        window is detached from it.  Use WNDSTROY (with or
  24. *        without WNFORGET) to discard the entire window structure
  25. *        as well.
  26. *
  27. * Returns    presult       Pointer to newly-removed BWINDOW
  28. *                  structure, or NIL if failure.
  29. *        *pwin          Several fields altered.
  30. *        b_pactnode[][]      Window node with active cursor.
  31. *        b_wnerr       Possible values:
  32. *                  (No change)       Success.
  33. *                  WN_BAD_WIN       *pwin is invalid.
  34. *                  WN_NOT_SHOWN       Not currently shown.
  35. *                  WN_BAD_NODE       Internal error.
  36. *                  WN_BAD_PAGE       Internal error.
  37. *                  WN_BAD_DEV       Internal error.
  38. *
  39. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  40. *
  41. * Version    3.02 March 20, 1987
  42. *        Corrected value of presult in case when WNPGREM succeeds.
  43. *
  44. **/
  45.  
  46. #include <bwindow.h>
  47.  
  48. BWINDOW *wnforget(pwin)
  49. BWINDOW *pwin;
  50. {
  51.     int     dev,page;
  52.     BWINDOW *presult;
  53.  
  54.     if (wnvalwin(pwin) == NIL)          /* Validate window pointer.     */
  55.     {
  56.     wnerror(WN_BAD_WIN);
  57.     return NIL;
  58.     }
  59.  
  60.     dev = pwin->where_shown.dev;
  61.     if (dev != MONO && dev != COLOR)  /* Ensure it's showing.         */
  62.     {
  63.     wnerror(WN_NOT_SHOWN);
  64.     return NIL;
  65.     }
  66.  
  67.     if (b_pcurwin == pwin)          /* If this window is current,   */
  68.     b_pcurwin = NIL;          /* mark no window as current.   */
  69.  
  70.     page = pwin->where_shown.page;
  71.     if (b_pactnode[dev][page]->pwin == pwin)
  72.     {                      /* Then this window is the one  */
  73.                       /* whose cursor is active.      */
  74.     b_pactnode[dev][page] = NIL;
  75.                       /* Now no window has an active  */
  76.                       /* cursor.              */
  77.                       /* (But don't touch the visible */
  78.                       /* cursor.)              */
  79.     }
  80.     pwin->internals.cur_frozen = 1;
  81.  
  82.     presult = wnpgrem(pwin);          /* Remove from linked list.     */
  83.  
  84.     if (presult != NIL)
  85.     {                      /* Mark as not shown.          */
  86.     pwin->where_shown.dev =
  87.     pwin->where_prev.dev  = ABSENT;
  88.     pwin->internals.dirty =
  89.     pwin->options.hidden  = 0;
  90.     }
  91.  
  92.     pwin->internals.temp_hid = 0;     /* Correct internal flag in     */
  93.                       /* case it remains set.          */
  94.  
  95.     return presult;              /* Success.              */
  96. }
  97.