home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wngetopt -- Retrieve window option or status
- *
- * Synopsis presult = wngetopt(pwin,item,pvalue);
- *
- * BWINDOW *presult Pointer to window, or NIL if
- * failure.
- * BWINDOW *pwin Pointer to window.
- * int item Identifying code number of data item
- * to return.
- * int *pvalue Pointer to variable to receive data
- * value.
- *
- * Description This function retrieves one item of information about a
- * window's characteristics or status.
- *
- * For certain items, an error may occur if the window is
- * not attached to a screen location. (That is, the window
- * must have been displayed with WNDSPLAY. It is okay if
- * the window has been hidden with WNHIDE, but not if it
- * has been removed with WNREMOVE.)
- *
- * An error also occurs if the item requested is unknown or
- * if pwin does not point to a valid window.
- *
- * Returns presult Pointer to window, or NIL if
- * failure.
- * *pvalue Data value (unless error).
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_WIN *pwin is invalid.
- * WN_NOT_SHOWN *pwin not currently
- * attached to screen
- * location.
- * WN_BAD_OPT Unknown item.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bwindow.h>
-
- /* Macro to build a case statement which does a simple lookup or */
- /* calculation. */
-
- #define easycase(item_num,data) \
- case (item_num): \
- *pvalue = (data); \
- presult = pwin; \
- break;
-
- /* Macro to build a case statement whose success depends on the */
- /* window being currently displayed (although perhaps hidden). */
- /* (This is a stub version to allow easy future installation of */
- /* case-by-case data checking.) */
-
- #define dispcase(item_num,data) easycase(item_num,data)
-
- BWINDOW *wngetopt(pwin,item,pvalue)
- BWINDOW *pwin;
- int item,*pvalue;
- {
- BWINDOW *presult;
-
- if (wnvalwin(pwin) == NIL) /* Validate window structure. */
- {
- wnerror(WN_BAD_WIN);
- return NIL;
- }
-
- if (item < 0) /* This kind of item is */
- { /* meaningless unless window is */
- /* displayed. */
- if ( pwin->where_shown.dev != MONO
- && pwin->where_shown.dev != COLOR)
- {
- wnerror(WN_NOT_SHOWN);
- return NIL;
- }
- }
-
- switch (item)
- {
- /* Dimensions of data area */
- easycase( WN_ROWS, pwin->img.dim.h)
- easycase( WN_COLS, pwin->img.dim.w)
-
- /* Where the window is displayed*/
- easycase( WN_DEVICE, pwin->where_shown.dev)
- dispcase( WN_PAGE, pwin->where_shown.page)
- dispcase( WN_ROW_CORNER, pwin->where_shown.corner.row)
- dispcase( WN_COL_CORNER, pwin->where_shown.corner.col)
- /* Area covered by window */
- /* & border */
- dispcase( WN_ROW_OVERALL,pwin->where_prev.corner.row)
- dispcase( WN_COL_OVERALL,pwin->where_prev.corner.col)
- dispcase( WN_HT_OVERALL, pwin->prev.dim.h)
- dispcase( WN_WID_OVERALL,pwin->prev.dim.w)
-
- /* Whether it's hidden. */
- dispcase( WN_HIDDEN, pwin->options.hidden)
-
- /* Cursor on/off state & scan */
- /* lines */
- easycase( WN_CUR_OFF, pwin->options.cur_off)
- easycase( WN_CUR_HIGH, pwin->cur_type.high) /* Upper line */
- easycase( WN_CUR_LOW, pwin->cur_type.low) /* Lower line */
-
- /* User-controllable options */
- easycase( WN_DELAYED, pwin->options.delayed)
- easycase( WN_REMOVABLE, pwin->options.removable)
-
- /* Internal effects of */
- /* displaying windows */
- easycase( WN_FROZEN, pwin->internals.frozen)
- easycase( WN_DIRTY, pwin->internals.dirty)
- easycase( WN_ANY_DATA_COVERED, pwin->internals.any_data_covered)
-
- /* Cursor location */
- easycase( WN_ROW_REL, pwin->cur_loc.row) /* Relative to */
- easycase( WN_COL_REL, pwin->cur_loc.col) /* data area */
-
- /* Absolute cursor location on */
- /* screen */
- #define ABS_LOC(type) ( pwin->where_shown.corner.type \
- + pwin->cur_loc .type)
-
- dispcase( WN_ROW_ABS, ABS_LOC(row))
- dispcase( WN_COL_ABS, ABS_LOC(col))
-
- /* Default attributes */
- easycase( WN_ATTR, pwin->attr)
-
- /* Border */
- easycase( WN_BOR_TYPE, pwin->bord.type)
- easycase( WN_BOR_CHAR, (int) pwin->bord.ch)
- easycase( WN_BOR_ATTR, pwin->bord.attr)
-
- /* Whether this is the current */
- /* window */
- easycase( WN_IS_CURRENT, (pwin == b_pcurwin))
-
- /* Whether this window (among */
- /* all the windows displayed on */
- /* its page) is the one whose */
- /* cursor is active. */
-
- #define PNode (b_pactnode[pwin->where_shown.dev][pwin->where_shown.page])
-
- dispcase( WN_ACTIVE_CUR,(pwin->pnode==PNode && pwin==PNode->pwin))
-
- default:
- wnerror(WN_BAD_OPT); /* Unknown item requested. */
- presult = NIL;
- break;
- }
-
- return presult;
- }