home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / MNATR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  2.1 KB  |  84 lines

  1. /**
  2. *
  3. * Name        MNATR -- Change attributes on item in a menu.
  4. *
  5. * Synopsis    presult = mnatr (pmenu, pitem, mode);
  6. *
  7. *        BMENU *presult    Pointer to newly-changed BMENU
  8. *                structure, or NIL if failure.
  9. *        const BITEM *pitem
  10. *                Item to change attributes on.
  11. *        int    mode    MN_UNHIGHLIGHT to unhighlight the
  12. *                item, MN_HIGHLIGHT to highlight it.
  13. *
  14. * Description    This function changes the attributes on a given item
  15. *        in a given menu.  Nothing else in the menu's window
  16. *        is changed.
  17. *
  18. *        The output is delayed.
  19. *
  20. * Returns    presult       Pointer to newly-changed BWINDOW
  21. *                  structure, or NIL if failure.
  22. *        b_wnerr       Possible values:
  23. *                  (No change)       Success.
  24. *                  MN_BAD_MENU       Pmenu is invalid.
  25. *                  MN_BAD_ITEM       Pitem is invalid.
  26. *                  WN_BAD_WIN       Pmenu->pwin is invalid.
  27. *                  WN_NOT_SHOWN       Internal error.
  28. *                  WN_BAD_DEV       Internal error.
  29. *                  WN_NULL_PTR       Internal error.
  30. *
  31. * Version    6.00 (C)Copyright Blaise Computing Inc.  1987,1989
  32. *
  33. **/
  34.  
  35. #include <bmenu.h>
  36.  
  37. BMENU *mnatr (pmenu, pitem, mode)
  38. BMENU *pmenu;
  39. const BITEM *pitem;
  40. int    mode;
  41. {
  42.  
  43.         /* Validate menu data structures.            */
  44.     mnvalidm (pmenu)
  45.  
  46.         /* Check validity of item.                */
  47.     if (pitem == NIL)
  48.     wnreterr (WN_ILL_VALUE);
  49.     if (pitem->signature != MN_ITEM_SIGN)
  50.     wnreterr (MN_BAD_ITEM);
  51.  
  52.         /* Set attributes on the menu item.            */
  53.     if (mode == MN_HIGHLIGHT)
  54.     {
  55.     if (wnatrblk (pmenu->pwin,
  56.               pitem->row, pitem->col,
  57.               pitem->row,
  58.               (pitem->col + pitem->len) - 1,
  59.               utlonyb (pmenu->hilattr),
  60.               uthinyb (pmenu->hilattr), WN_NO_UPDATE) == NIL)
  61.         return (NIL);
  62.     }
  63.     else
  64.         /* Un-highlight item                    */
  65.     if (pitem->pcharattr)
  66.     {
  67.         if (NIL == wnwrrect(pmenu->pwin,
  68.                 pitem->row,pitem->col,
  69.                 pitem->row,pitem->col + pitem->len - 1,
  70.                 pitem->pcharattr,
  71.                 -1,-1,CHAR_ATTR | WN_NO_UPDATE))
  72.         return(NIL);
  73.     }
  74.     else
  75.         if (wnatrblk (pmenu->pwin,
  76.               pitem->row, pitem->col,
  77.               pitem->row,
  78.               (pitem->col + pitem->len) - 1,
  79.               utlonyb (pitem->attr),
  80.               uthinyb (pitem->attr), WN_NO_UPDATE) == NIL)
  81.         return (NIL);
  82.     return (pmenu);
  83. }
  84.