home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNHILIT0 -- Move or remove menu highlight bar
- * or item description.
- *
- * Synopsis presult = mnhilit0(pmenu,pitem,option);
- *
- * BMENU *presult Pointer to newly-changed BMENU
- * structure, or NIL if failure.
- * BITEM *pitem Address of menu item to highlight.
- * If NIL then no item is highlighted.
- * Ignored if MN_UNHIGHLIGHT specified.
- * int option Option bits:
- * MN_HIGHLIGHT
- * MN_UNHIGHLIGHT (ignores row and col)
- * MN_USE_DESCRIPTION
- * WN_UPDATE or WN_NO_UPDATE
- *
- * Description This function highlights a menu item or removes the
- * highlight bar. It optionally adds or removes the item's
- * Lotus-style description string.
- *
- * This function can work on protected menu items.
- *
- * Returns presult Pointer to newly-changed BMENU
- * structure, or NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_OPT Unknown option.
- * MN_BAD_MENU pmenu is invalid.
- * WN_BAD_WIN pmenu->pwin is invalid.
- * MN_BAD_ITEM pitem is invalid.
- *
- * WN_NOT_SHOWN Internal error.
- * WN_BAD_DEV Internal error.
- * WN_ILL_DIM Internal error.
- * WN_NULL_PTR Internal error.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
-
- #include <bmenu.h>
-
- BMENU *mnhilit0(pmenu,pitem,option)
- BMENU *pmenu;
- BITEM *pitem;
- int option;
- {
- int remove = ( (pitem == NIL)
- || (MN_UNHIGHLIGHT ==
- (option & (MN_HIGHLIGHT | MN_UNHIGHLIGHT))));
- int desc = (option & MN_USE_DESCRIPTION);
-
- REGION strip; /* Region to force into viewport*/
- LOC begin_strip,end_strip; /* Points to force into viewport*/
-
-
- mnvalidm(pmenu) /* Validate menu. */
-
- if (pmenu->pbar_item != NIL)
- { /* A bar is currently shown. */
-
- if (pmenu->internals.desc_shown) /* If description shown */
- { /* and if */
- if ( remove /* no bar wanted */
- || !desc /* or no description */
- /* wanted */
- || pmenu->pbar_item != pitem) /* or bar moved */
- {
- /* then remove description. */
- if (pmenu->pbar_item->llen &&
- NIL == wnscrblk(pmenu->pwin,
- pmenu->pbar_item->lrow,
- pmenu->pbar_item->lcol,
- pmenu->pbar_item->lrow,
- (pmenu->pbar_item->lcol
- + pmenu->pbar_item->llen) - 1,
- utlonyb(pmenu->pwin->attr),
- uthinyb(pmenu->pwin->attr),
- WNSCR_LEFT,0,WN_NO_UPDATE))
- return NIL;
- pmenu->internals.desc_shown = 0;
- }
- }
- if ( remove /* If removing bar */
- || pmenu->pbar_item != pitem) /* or bar moved */
- {
- /* remove old highlight bar. */
- if (NIL == mnatr(pmenu,pmenu->pbar_item,MN_UNHIGHLIGHT))
- return NIL;
- pmenu->pbar_prev = pmenu->pbar_item;
- pmenu->pbar_item = NIL;
- }
- }
-
- if (!remove)
- {
- if (pmenu->pbar_item != pitem)
- { /* Light new highlight bar. */
- if (NIL == mnatr(pmenu,pitem,MN_HIGHLIGHT))
- return NIL;
- if (pmenu->pbar_item != NIL)
- pmenu->pbar_prev = pmenu->pbar_item;
- pmenu->pbar_item = pitem;
- }
-
- if ( desc
- && pitem->llen
- && !pmenu->internals.desc_shown)
- { /* Show description. */
- if (NIL == wnwrrect(pmenu->pwin,
- pitem->lrow,pitem->lcol,
- pitem->lrow,pitem->lrow + pitem->llen - 1,
- pitem->plstring,
- utlonyb(pmenu->longattr),
- uthinyb(pmenu->longattr),
- CHARS_ONLY | WN_NO_UPDATE))
- return NIL;
- pmenu->internals.desc_shown = 1;
-
- /* Force description into viewport. */
- strip.ul.row = pitem->lrow;
- begin_strip.row = pitem->lrow;
- strip.lr.row = pitem->lrow;
- end_strip.row = pitem->lrow;
-
- strip.ul.col = pitem->lcol;
- begin_strip.col = pitem->lcol;
- strip.lr.col = pitem->lcol + pitem->llen - 1;
- end_strip.col = pitem->lcol + pitem->llen - 1;
-
- if (NIL == wnshoblk(pmenu->pwin,
- &strip,&begin_strip,&end_strip,
- WN_NO_UPDATE))
- return NIL;
- }
-
- /* Force item into viewport. */
- strip.ul.row = pitem->row;
- begin_strip.row = pitem->row;
- strip.lr.row = pitem->row;
- end_strip.row = pitem->row;
-
- strip.ul.col = pitem->col;
- begin_strip.col = pitem->col;
- strip.lr.col = pitem->col + pitem->len - 1;
- end_strip.col = pitem->col + pitem->len - 1;
-
- if (NIL == wnshoblk(pmenu->pwin,
- &strip,&begin_strip,&end_strip,
- WN_NO_UPDATE))
- return NIL;
- }
-
- if ( WN_UPDATE == (option & (WN_UPDATE | WN_NO_UPDATE))
- && !pmenu->pwin->options.delayed)
- if (NIL == wnupdate(pmenu->pwin))
- return NIL;
-
- return pmenu; /* Success. */
- }