home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wnunhide -- Redisplay hidden window.
- *
- * Synopsis presult = wnunhide(pwin);
- *
- * BWINDOW *presult Pointer to newly-redisplayed BWINDOW
- * structure, or NIL if failure.
- * BWINDOW *pwin Pointer to BWINDOW structure to
- * redisplay.
- *
- * Description This function redisplays a window that has been
- * previously displayed but is now hidden. The window's
- * location and border are the same as before.
- *
- * There is no effect if the window is currently displayed
- * and visible.
- *
- * The window's cursor is not activated. The window is not
- * made current if it was not previously current.
- *
- * If the window covers any part of the data area of the
- * window whose cursor is active, then that window's cursor
- * is deactivated and the screen's cursor is made
- * invisible.
- *
- * An error occurs if pwin does not point to a valid window
- * structure, or if the window has been designated "not
- * removable", or if the window is not currently attached
- * to a display device and page, or if the dimensions of
- * the screen have changed (due to a change of mode) so
- * that the window no longer fits on the screen.
- *
- * In the event of most types of errors, this function will
- * mark the window as not being displayed anywhere, so it
- * may be possible to redisplay the window using WNDSPLAY.
- *
- * Returns presult Pointer to newly-hidden BWINDOW
- * structure, or NIL if failure.
- * *pwin Several fields altered.
- * b_pactnode[][] Window node with active cursor.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_WIN *pwin is invalid.
- * WN_NOT_SHOWN Not attached to device
- * and page.
- * WN_NO_MEMORY Insufficient memory.
- * WN_BAD_NODE Internal error.
- * WN_BAD_DEV Internal error.
- * WN_BAD_PAGE Internal error.
- * WN_COVERED Internal error.
- * WN_ILL_DIM Internal error.
- * WN_NULL_PTR Internal error.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- * Version 3.02 March 20, 1987
- * Removed static variables to allow re-entrancy.
- * Corrected error in call to WNCOVER.
- *
- **/
-
- #include <bwindow.h>
-
- #define restore_video() \
- (scpage(old_npage),scchgdev(old_dev),(void) scpage(old_page))
-
- BWINDOW *wnunhide(pwin)
- BWINDOW *pwin;
- {
- int mode,columns,act_page;
- int old_dev,old_page,old_npage;
-
- if (wnvalwin(pwin) == NIL) /* Validate window structure */
- {
- wnerror(WN_BAD_WIN);
- return NIL;
- }
-
- old_page = b_curpage; /* Note current page on former */
- /* device. */
-
- /* Note former device. */
- old_dev = scmode(&mode,&columns,&act_page);
-
- if (wnseldev(&pwin->where_shown,&pwin->img.dim,&old_npage))
- { /* Validate and select device */
- /* and page. */
- wnerror(WN_NOT_SHOWN);
- return NIL;
- }
-
- if (!pwin->options.hidden) /* Quit if not hidden. */
- {
- restore_video();
- return pwin; /* (This is not an error.) */
- }
-
- if (wnpgrem(pwin) == NIL) /* Remove existing node. */
- {
- pwin->where_shown.dev = ABSENT;
- restore_video();
- return NIL;
- }
-
- /* Add this window to linked */
- /* list for this display page. */
- if (NIL == (pwin->pnode = wnpgadd(pwin,
- pwin->where_shown.dev,
- pwin->where_shown.page)))
- {
- pwin->where_shown.dev = ABSENT;
- restore_video();
- return NIL;
- }
-
-
- if (pwin->options.removable) /* Read previous screen contents*/
- if (wngetimg(&pwin->prev,&pwin->where_prev) == NIL)
- {
- wnpgrem(pwin); /* Clean up after failure. */
- pwin->where_shown.dev = ABSENT;
- restore_video();
- return NIL;
- }
-
- if (NIL == wnputimg(&pwin->img, /* Write the data. */
- &pwin->where_shown))
- {
- wnpgrem(pwin); /* Clean up after failure. */
- pwin->where_shown.dev = ABSENT;
- restore_video();
- return NIL;
- }
-
- wnputbor(&pwin->img.dim,
- &pwin->bord,
- &pwin->where_shown); /* Write the border. */
-
- pwin->options.hidden = /* Displayed, not hidden*/
- pwin->internals.frozen = /* Not covered. */
- pwin->internals.dirty = /* No pending writes. */
- pwin->internals.any_data_covered = 0; /* Not covered. */
- pwin->internals.cur_frozen = 1; /* Inactive cursor. */
-
- if (pwin->pnode->below != NIL) /* If other windows are shown */
- /* on this page, then */
- { /* mark them if covered. */
- if (wncover(pwin->pnode->below,
- &pwin->where_prev.corner,
- &pwin->prev.dim) == NIL)
- {
- wnpgrem(pwin); /* Clean up after failure. */
- pwin->where_shown.dev = ABSENT;
- restore_video();
- return NIL;
- }
- }
-
- restore_video();
-
- return pwin;
- }