home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNFINDSL - Find the first selectable item in a
- * menu, given starting coordinates.
- *
- * Synopsis presult = mnfindsl (pmenu, pitem, row, col, pcode);
- *
- * BITEM *presult Pointer to the item in the
- * menu's item list which matches
- * row and col, or NIL for
- * failure.
- * BMENU *pmenu Pointer to menu in which to
- * search item list. Needed to
- * pass to MNMCHITM.
- * BITEM *pitem Pointer to item in list to start
- * search at, or NIL to start at
- * first item.
- * int row, Requested row and column of
- * col item MNFINDSL searches for.
- * int *pcode Pointer to variable to return
- * error code in. NIL if error code
- * should not be returned.
- *
- * Description MNFINDSL searches from a given point in the item
- * list of a menu for an item at a given row and
- * column.
- *
- * If it is not found, then MNFINDSL searches for
- * an item in the requested column, any row.
- *
- * If it is not found, then MNFINDSL searches for
- * an item in the requested row, any coulmn.
- *
- * If it is not found, then MNFINDSL searches for
- * any selectable item.
- *
- * If it is not found, then MNFINDSL returns NIL.
- *
- * Returns presult Pointer to BITEM found, or
- * NIL if failure.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
-
- #include <bmenu.h>
-
-
- BITEM *mnfindsl (pmenu, pitem, row, col, pcode)
- BMENU *pmenu;
- BITEM *pitem;
- int row, col;
- int *pcode;
- {
- int code;
-
- /* First try to find one that matches the row and */
- /* column specifications exactly. */
- if (((pitem = mnmchitm (pmenu, pitem, row, col,
- 0, &code)) == NIL) &&
- (code == WN_NO_ERROR))
-
- /* Next try to find one that matches the column */
- /* requested. */
- if (((pitem = mnmchitm (pmenu, pitem, -1, col,
- 0, &code)) == NIL) &&
- (code == WN_NO_ERROR))
-
- /* Next try to find one that matches the row */
- /* requested. */
- if (((pitem = mnmchitm (pmenu, pitem, row, -1,
- 0, &code)) == NIL) &&
- (code == WN_NO_ERROR))
-
- /* Next try to find any selectable item at all! */
- if (((pitem = mnmchitm (pmenu, pitem, -1, -1,
- 0, &code)) == NIL) &&
- (code == WN_NO_ERROR))
-
- return (NIL);
-
- if (code != WN_NO_ERROR)
- {
- if (pcode != NIL)
- *pcode = code;
- return (NIL);
- }
-
- else
- return (pitem);
- }