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

  1. /**
  2. *
  3. * Name        MNFINDSL - Find the first selectable item in a
  4. *               menu, given starting coordinates.
  5. *
  6. * Synopsis    presult = mnfindsl (pmenu, pitem, row, col, pcode);
  7. *
  8. *        BITEM *presult    Pointer to the item in the
  9. *                menu's item list which matches
  10. *                row and col, or NIL for
  11. *                failure.
  12. *        BMENU *pmenu    Pointer to menu in which to
  13. *                search item list.  Needed to
  14. *                pass to MNMCHITM.
  15. *        BITEM *pitem    Pointer to item in list to start
  16. *                search at, or NIL to start at
  17. *                first item.
  18. *        int    row,    Requested row and column of
  19. *               col    item MNFINDSL searches for.
  20. *        int   *pcode    Pointer to variable to return
  21. *                error code in.    NIL if error code
  22. *                should not be returned.
  23. *
  24. * Description    MNFINDSL searches from a given point in the item
  25. *        list of a menu for an item at a given row and
  26. *        column.
  27. *
  28. *        If it is not found, then MNFINDSL searches for
  29. *        an item in the requested column, any row.
  30. *
  31. *        If it is not found, then MNFINDSL searches for
  32. *        an item in the requested row, any coulmn.
  33. *
  34. *        If it is not found, then MNFINDSL searches for
  35. *        any selectable item.
  36. *
  37. *        If it is not found, then MNFINDSL returns NIL.
  38. *
  39. * Returns    presult     Pointer to BITEM found, or
  40. *                NIL if failure.
  41. *
  42. * Version    6.00 (C)Copyright Blaise Computing Inc.  1987,1989
  43. *
  44. **/
  45.  
  46.  
  47. #include <bmenu.h>
  48.  
  49.  
  50. BITEM *mnfindsl (pmenu, pitem, row, col, pcode)
  51. BMENU *pmenu;
  52. BITEM *pitem;
  53. int    row, col;
  54. int   *pcode;
  55. {
  56.     int code;
  57.  
  58.         /* First try to find one that matches the row and   */
  59.         /* column specifications exactly.            */
  60.     if (((pitem = mnmchitm (pmenu, pitem, row, col,
  61.                 0, &code)) == NIL) &&
  62.     (code == WN_NO_ERROR))
  63.  
  64.         /* Next try to find one that matches the column     */
  65.         /* requested.                        */
  66.     if (((pitem = mnmchitm (pmenu, pitem, -1, col,
  67.                 0, &code)) == NIL) &&
  68.         (code == WN_NO_ERROR))
  69.  
  70.         /* Next try to find one that matches the row        */
  71.         /* requested.                        */
  72.         if (((pitem = mnmchitm (pmenu, pitem, row, -1,
  73.                     0, &code)) == NIL) &&
  74.         (code == WN_NO_ERROR))
  75.  
  76.         /* Next try to find any selectable item at all!     */
  77.         if (((pitem = mnmchitm (pmenu, pitem, -1, -1,
  78.                     0, &code)) == NIL) &&
  79.             (code == WN_NO_ERROR))
  80.  
  81.             return (NIL);
  82.  
  83.     if (code != WN_NO_ERROR)
  84.     {
  85.     if (pcode != NIL)
  86.         *pcode = code;
  87.     return (NIL);
  88.     }
  89.  
  90.     else
  91.     return (pitem);
  92. }
  93.