menu.priv.h revision 1.1
1
2/***************************************************************************
3*                            COPYRIGHT NOTICE                              *
4****************************************************************************
5*                ncurses is copyright (C) 1992-1995                        *
6*                          Zeyd M. Ben-Halim                               *
7*                          zmbenhal@netcom.com                             *
8*                          Eric S. Raymond                                 *
9*                          esr@snark.thyrsus.com                           *
10*                                                                          *
11*        Permission is hereby granted to reproduce and distribute ncurses  *
12*        by any means and for any fee, whether alone or as part of a       *
13*        larger distribution, in source or in binary form, PROVIDED        *
14*        this notice is included with any such distribution, and is not    *
15*        removed from any of its header files. Mention of ncurses in any   *
16*        applications linked with it is highly appreciated.                *
17*                                                                          *
18*        ncurses comes AS IS with no warranty, implied or expressed.       *
19*                                                                          *
20***************************************************************************/
21
22/***************************************************************************
23* Module menu.priv.h                                                       *
24* Top level private header file for all libnmenu modules                   *
25***************************************************************************/
26
27#include "mf_common.h"
28#include "menu.h"
29
30/* Backspace code */
31#define BS (8)
32
33extern ITEM _nc_Default_Item;
34extern MENU _nc_Default_Menu;
35
36/* Normalize item to default if none was given */
37#define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
38
39/* Normalize menu to default if none was given */
40#define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
41
42/* Normalize menu window */
43#define Get_Menu_Window(  menu ) \
44   ( (menu)->usersub  ? (menu)->usersub  : (\
45     (menu)->userwin  ? (menu)->userwin  : stdscr ))
46
47/* menu specific status flags */
48#define _LINK_NEEDED    (0x04)
49
50#define ALL_MENU_OPTS (                 \
51		       O_ONEVALUE     | \
52		       O_SHOWDESC     | \
53		       O_ROWMAJOR     | \
54		       O_IGNORECASE   | \
55		       O_SHOWMATCH    | \
56		       O_NONCYCLIC    )
57
58#define ALL_ITEM_OPTS (O_SELECTABLE)
59
60/* Move to the window position of an item and draw it */
61#define Move_And_Post_Item(menu,item) \
62  {wmove((menu)->win,(item)->y,((menu)->itemlen+1)*(item)->x);\
63   _nc_Post_Item((menu),(item));}
64
65#define Move_To_Current_Item(menu,item) \
66  if ( (item) != (menu)->curitem)\
67    {\
68      Move_And_Post_Item(menu,item);\
69      Move_And_Post_Item(menu,(menu)->curitem);\
70    }
71
72/* This macro ensures, that the item becomes visible, if possible with the
73   specified row as the top row of the window. If this is not possible,
74   the top row will be adjusted and the value is stored in the row argument.
75*/
76#define Adjust_Current_Item(menu,row,item) \
77  { if ((item)->y < row) \
78      row = (item)->y;\
79    if ( (item)->y >= (row + (menu)->height) )\
80      row = ( (item)->y < ((menu)->rows - row) ) ? \
81            (item)->y : (menu)->rows - (menu)->height;\
82    _nc_New_TopRow_and_CurrentItem(menu,row,item); }
83
84/* Reset the match pattern buffer */
85#define Reset_Pattern(menu) \
86  { (menu)->pindex = 0; \
87    (menu)->pattern[0] = '\0'; }
88
89/* Internal functions. */
90extern void _nc_Draw_Menu(const MENU *);
91extern void _nc_Show_Menu(const MENU *);
92extern void _nc_Calculate_Item_Length_and_Width(MENU *);
93extern void _nc_Post_Item(const MENU *, const ITEM *);
94extern bool _nc_Connect_Items(MENU *, ITEM **);
95extern void _nc_Disconnect_Items(MENU *);
96extern void _nc_New_TopRow_and_CurrentItem(MENU *,int, ITEM *);
97extern void _nc_Link_Items(MENU *);
98