m_item_vis.c revision 166124
1217309Snwhitehorn/****************************************************************************
2251843Sbapt * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
3220749Snwhitehorn *                                                                          *
4251843Sbapt * Permission is hereby granted, free of charge, to any person obtaining a  *
5217309Snwhitehorn * copy of this software and associated documentation files (the            *
6220749Snwhitehorn * "Software"), to deal in the Software without restriction, including      *
7220749Snwhitehorn * without limitation the rights to use, copy, modify, merge, publish,      *
8220749Snwhitehorn * distribute, distribute with modifications, sublicense, and/or sell       *
9220749Snwhitehorn * copies of the Software, and to permit persons to whom the Software is    *
10220749Snwhitehorn * furnished to do so, subject to the following conditions:                 *
11220749Snwhitehorn *                                                                          *
12220749Snwhitehorn * The above copyright notice and this permission notice shall be included  *
13220749Snwhitehorn * in all copies or substantial portions of the Software.                   *
14220749Snwhitehorn *                                                                          *
15220749Snwhitehorn * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16220749Snwhitehorn * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17220749Snwhitehorn * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18220749Snwhitehorn * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19220749Snwhitehorn * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20220749Snwhitehorn * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21220749Snwhitehorn * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22220749Snwhitehorn *                                                                          *
23220749Snwhitehorn * Except as contained in this notice, the name(s) of the above copyright   *
24220749Snwhitehorn * holders shall not be used in advertising or otherwise to promote the     *
25220749Snwhitehorn * sale, use or other dealings in this Software without prior written       *
26220749Snwhitehorn * authorization.                                                           *
27220749Snwhitehorn ****************************************************************************/
28220749Snwhitehorn
29220749Snwhitehorn/****************************************************************************
30217309Snwhitehorn *   Author:  Juergen Pfeifer, 1995,1997                                    *
31217309Snwhitehorn ****************************************************************************/
32217309Snwhitehorn
33217309Snwhitehorn/***************************************************************************
34251843Sbapt* Module m_item_vis                                                        *
35217309Snwhitehorn* Tell if menu item is visible                                             *
36217309Snwhitehorn***************************************************************************/
37217309Snwhitehorn
38217309Snwhitehorn#include "menu.priv.h"
39217309Snwhitehorn
40217309SnwhitehornMODULE_ID("$Id: m_item_vis.c,v 1.15 2004/12/25 21:40:09 tom Exp $")
41217309Snwhitehorn
42217309Snwhitehorn/*---------------------------------------------------------------------------
43217309Snwhitehorn|   Facility      :  libnmenu
44217309Snwhitehorn|   Function      :  bool item_visible(const ITEM *item)
45217309Snwhitehorn|
46217309Snwhitehorn|   Description   :  A item is visible if it currently appears in the
47217309Snwhitehorn|                    subwindow of a posted menu.
48251843Sbapt|
49217309Snwhitehorn|   Return Values :  TRUE  if visible
50217309Snwhitehorn|                    FALSE if invisible
51217309Snwhitehorn+--------------------------------------------------------------------------*/
52217309SnwhitehornNCURSES_EXPORT(bool)
53217309Snwhitehornitem_visible(const ITEM * item)
54217309Snwhitehorn{
55217309Snwhitehorn  MENU *menu;
56217309Snwhitehorn
57217309Snwhitehorn  T((T_CALLED("item_visible(%p)"), item));
58217309Snwhitehorn  if (item &&
59217309Snwhitehorn      (menu = item->imenu) &&
60217309Snwhitehorn      (menu->status & _POSTED) &&
61217309Snwhitehorn      ((menu->toprow + menu->arows) > (item->y)) &&
62217309Snwhitehorn      (item->y >= menu->toprow))
63217309Snwhitehorn    returnBool(TRUE);
64217309Snwhitehorn  else
65217309Snwhitehorn    returnBool(FALSE);
66217309Snwhitehorn}
67217309Snwhitehorn
68217309Snwhitehorn/* m_item_vis.c ends here */
69217309Snwhitehorn