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

  1. /**
  2. *
  3. * Name        MNDISABL -- Disable keys bound to locations which
  4. *                do not have selectable items.
  5. *
  6. * Synopsis    presult = mndisabl (pmenu);
  7. *
  8. *        BMENU *presult    Pointer to just-changed BMENU
  9. *                structure, or NIL if failure.
  10. *        BMENU *pmenu    Pointer to BMENU in which to
  11. *                disable certain key bindings.
  12. *
  13. * Description    This function disables keys which are bound to
  14. *        nonexistent or protected items, and enables
  15. *        keys which were previously disabled by MNDISABL,
  16. *        but which now point to valid items.
  17. *
  18. * Returns    presult       Pointer to newly-changed BMENU
  19. *                  structure, or NIL if failure.
  20. *        b_wnerr       Possible values:
  21. *                  (No change)    Success.
  22. *                  MN_BAD_MENU    Invalid menu.
  23. *                  MN_BAD_KEY    Invalid keymap entry.
  24. *                  MN_BAD_ITEM    Invalid menu item found.
  25. *
  26. * Version    6.00 (C)Copyright Blaise Computing Inc.  1987,1989
  27. *
  28. **/
  29.  
  30.  
  31.  
  32. #include <bmenu.h>
  33.  
  34.  
  35. BMENU *mndisabl (pmenu)
  36. BMENU *pmenu;
  37. {
  38.     BKEYMAP *pkey;
  39.     int      code;
  40.  
  41.         /* Validate menu data structures.            */
  42.     mnvalidm (pmenu)
  43.  
  44.         /* Go through entire key list...            */
  45.     for (pkey = pmenu->pkeys;  pkey != NIL;  pkey = pkey->next)
  46.     {
  47.         /* Check key signature.                 */
  48.     if (pkey->signature != MN_KEY_SIGN)
  49.         wnreterr (MN_BAD_KEY);
  50.  
  51.         /* If the key is bound to a particular location,    */
  52.     if (MNMOVE (pkey->action) == MN_SELECT)
  53.     {
  54.         /* and there is no selectable item at that        */
  55.         /* location...                        */
  56.         if (mnmchitm (pmenu, NIL, pkey->row, pkey->col, 0, &code) == NIL)
  57.         /* Disable the key if no error walking the item list*/
  58.         {
  59.         if (code == WN_NO_ERROR)
  60.             pkey->action |= MN_TEMP_DISABLE;
  61.         else
  62.             return (NIL);
  63.         }
  64.  
  65.         /* Enable keys which match items now but were        */
  66.         /* temporarily disabled in the past.            */
  67.         else if (pkey->action & MN_TEMP_DISABLE)
  68.         pkey->action &= ~(MN_TEMP_DISABLE);
  69.     }
  70.     }
  71.  
  72.     return (pmenu);
  73. }
  74.