menu.priv.h revision 50276
1202375Srdivacky/****************************************************************************
2202375Srdivacky * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3202375Srdivacky *                                                                          *
4202375Srdivacky * Permission is hereby granted, free of charge, to any person obtaining a  *
5202375Srdivacky * copy of this software and associated documentation files (the            *
6202375Srdivacky * "Software"), to deal in the Software without restriction, including      *
7202375Srdivacky * without limitation the rights to use, copy, modify, merge, publish,      *
8202375Srdivacky * distribute, distribute with modifications, sublicense, and/or sell       *
9202375Srdivacky * copies of the Software, and to permit persons to whom the Software is    *
10202375Srdivacky * furnished to do so, subject to the following conditions:                 *
11202375Srdivacky *                                                                          *
12202375Srdivacky * The above copyright notice and this permission notice shall be included  *
13202375Srdivacky * in all copies or substantial portions of the Software.                   *
14202375Srdivacky *                                                                          *
15249423Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16210299Sed * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17249423Sdim * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18249423Sdim * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19202375Srdivacky * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20202375Srdivacky * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21202375Srdivacky * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22202375Srdivacky *                                                                          *
23243830Sdim * Except as contained in this notice, the name(s) of the above copyright   *
24243830Sdim * holders shall not be used in advertising or otherwise to promote the     *
25202375Srdivacky * sale, use or other dealings in this Software without prior written       *
26243830Sdim * authorization.                                                           *
27243830Sdim ****************************************************************************/
28243830Sdim
29243830Sdim/****************************************************************************
30243830Sdim *   Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997            *
31243830Sdim ****************************************************************************/
32243830Sdim
33243830Sdim/***************************************************************************
34243830Sdim* Module menu.priv.h                                                       *
35243830Sdim* Top level private header file for all libnmenu modules                   *
36243830Sdim***************************************************************************/
37243830Sdim
38243830Sdim#include "mf_common.h"
39243830Sdim#include "menu.h"
40243830Sdim
41243830Sdim/* Backspace code */
42243830Sdim#define BS (8)
43243830Sdim
44243830Sdimextern ITEM _nc_Default_Item;
45243830Sdimextern MENU _nc_Default_Menu;
46243830Sdim
47243830Sdim/* Normalize item to default if none was given */
48243830Sdim#define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
49243830Sdim
50243830Sdim/* Normalize menu to default if none was given */
51243830Sdim#define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
52243830Sdim
53243830Sdim/* Get the user defined (framing) window of the menu */
54243830Sdim#define Get_Menu_UserWin(menu) ((menu)->userwin ? (menu)->userwin : stdscr)
55243830Sdim
56243830Sdim/* Normalize menu window */
57243830Sdim#define Get_Menu_Window(  menu ) \
58243830Sdim   ((menu)->usersub  ? (menu)->usersub  : Get_Menu_UserWin(menu))
59243830Sdim
60243830Sdim/* menu specific status flags */
61243830Sdim#define _LINK_NEEDED    (0x04)
62243830Sdim#define _MARK_ALLOCATED (0x08)
63243830Sdim
64243830Sdim#define ALL_MENU_OPTS (                 \
65243830Sdim		       O_ONEVALUE     | \
66243830Sdim		       O_SHOWDESC     | \
67243830Sdim		       O_ROWMAJOR     | \
68243830Sdim		       O_IGNORECASE   | \
69243830Sdim		       O_SHOWMATCH    | \
70243830Sdim		       O_NONCYCLIC    )
71243830Sdim
72251662Sdim#define ALL_ITEM_OPTS (O_SELECTABLE)
73251662Sdim
74243830Sdim/* Move to the window position of an item and draw it */
75243830Sdim#define Move_And_Post_Item(menu,item) \
76243830Sdim  {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\
77243830Sdim   _nc_Post_Item((menu),(item));}
78243830Sdim
79243830Sdim#define Move_To_Current_Item(menu,item) \
80243830Sdim  if ( (item) != (menu)->curitem)\
81243830Sdim    {\
82243830Sdim      Move_And_Post_Item(menu,item);\
83243830Sdim      Move_And_Post_Item(menu,(menu)->curitem);\
84243830Sdim    }
85243830Sdim
86243830Sdim/* This macro ensures, that the item becomes visible, if possible with the
87243830Sdim   specified row as the top row of the window. If this is not possible,
88243830Sdim   the top row will be adjusted and the value is stored in the row argument.
89243830Sdim*/
90243830Sdim#define Adjust_Current_Item(menu,row,item) \
91243830Sdim  { if ((item)->y < row) \
92243830Sdim      row = (item)->y;\
93243830Sdim    if ( (item)->y >= (row + (menu)->arows) )\
94243830Sdim      row = ( (item)->y < ((menu)->rows - row) ) ? \
95243830Sdim            (item)->y : (menu)->rows - (menu)->arows;\
96243830Sdim    _nc_New_TopRow_and_CurrentItem(menu,row,item); }
97243830Sdim
98243830Sdim/* Reset the match pattern buffer */
99243830Sdim#define Reset_Pattern(menu) \
100243830Sdim  { (menu)->pindex = 0; \
101243830Sdim    (menu)->pattern[0] = '\0'; }
102243830Sdim
103243830Sdim/* Internal functions. */
104243830Sdimextern void _nc_Draw_Menu(const MENU *);
105243830Sdimextern void _nc_Show_Menu(const MENU *);
106243830Sdimextern void _nc_Calculate_Item_Length_and_Width(MENU *);
107243830Sdimextern void _nc_Post_Item(const MENU *, const ITEM *);
108243830Sdimextern bool _nc_Connect_Items(MENU *, ITEM **);
109243830Sdimextern void _nc_Disconnect_Items(MENU *);
110243830Sdimextern void _nc_New_TopRow_and_CurrentItem(MENU *,int, ITEM *);
111243830Sdimextern void _nc_Link_Items(MENU *);
112243830Sdimextern int  _nc_Match_Next_Character_In_Item_Name(MENU*,int,ITEM**);
113243830Sdimextern int  _nc_menu_cursor_pos(const MENU* menu, const ITEM* item,
114243830Sdim				int* pY, int* pX);
115243830Sdim