]> ncurses.scripts.mit.edu Git - ncurses.git/blob - menu/menu.priv.h
ncurses 4.1
[ncurses.git] / menu / menu.priv.h
1 /*-----------------------------------------------------------------------------+
2 |           The ncurses menu library is  Copyright (C) 1995-1997               |
3 |             by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de>                 |
4 |                          All Rights Reserved.                                |
5 |                                                                              |
6 | Permission to use, copy, modify, and distribute this software and its        |
7 | documentation for any purpose and without fee is hereby granted, provided    |
8 | that the above copyright notice appear in all copies and that both that      |
9 | copyright notice and this permission notice appear in supporting             |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the        |
12 | software without specific, written prior permission.                         | 
13 |                                                                              |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO  |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-  |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR   |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH    |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE.                                     |
21 +-----------------------------------------------------------------------------*/
22
23 /***************************************************************************
24 * Module menu.priv.h                                                       *
25 * Top level private header file for all libnmenu modules                   *
26 ***************************************************************************/
27
28 #include "mf_common.h"
29 #include "menu.h"
30
31 /* Backspace code */
32 #define BS (8)
33
34 extern ITEM _nc_Default_Item;
35 extern MENU _nc_Default_Menu;
36
37 /* Normalize item to default if none was given */
38 #define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
39
40 /* Normalize menu to default if none was given */
41 #define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
42
43 /* Normalize menu window */
44 #define Get_Menu_Window(  menu ) \
45    ( (menu)->usersub  ? (menu)->usersub  : (\
46      (menu)->userwin  ? (menu)->userwin  : stdscr ))
47
48 /* menu specific status flags */
49 #define _LINK_NEEDED    (0x04)
50 #define _MARK_ALLOCATED (0x08)
51
52 #define ALL_MENU_OPTS (                 \
53                        O_ONEVALUE     | \
54                        O_SHOWDESC     | \
55                        O_ROWMAJOR     | \
56                        O_IGNORECASE   | \
57                        O_SHOWMATCH    | \
58                        O_NONCYCLIC    )
59
60 #define ALL_ITEM_OPTS (O_SELECTABLE)
61
62 /* Move to the window position of an item and draw it */
63 #define Move_And_Post_Item(menu,item) \
64   {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\
65    _nc_Post_Item((menu),(item));}
66
67 #define Move_To_Current_Item(menu,item) \
68   if ( (item) != (menu)->curitem)\
69     {\
70       Move_And_Post_Item(menu,item);\
71       Move_And_Post_Item(menu,(menu)->curitem);\
72     }
73
74 /* This macro ensures, that the item becomes visible, if possible with the
75    specified row as the top row of the window. If this is not possible,
76    the top row will be adjusted and the value is stored in the row argument. 
77 */
78 #define Adjust_Current_Item(menu,row,item) \
79   { if ((item)->y < row) \
80       row = (item)->y;\
81     if ( (item)->y >= (row + (menu)->arows) )\
82       row = ( (item)->y < ((menu)->rows - row) ) ? \
83             (item)->y : (menu)->rows - (menu)->arows;\
84     _nc_New_TopRow_and_CurrentItem(menu,row,item); }
85
86 /* Reset the match pattern buffer */
87 #define Reset_Pattern(menu) \
88   { (menu)->pindex = 0; \
89     (menu)->pattern[0] = '\0'; }
90
91 /* Internal functions. */                                               
92 extern void _nc_Draw_Menu(const MENU *);
93 extern void _nc_Show_Menu(const MENU *);
94 extern void _nc_Calculate_Item_Length_and_Width(MENU *);
95 extern void _nc_Post_Item(const MENU *, const ITEM *);
96 extern bool _nc_Connect_Items(MENU *, ITEM **);
97 extern void _nc_Disconnect_Items(MENU *);
98 extern void _nc_New_TopRow_and_CurrentItem(MENU *,int, ITEM *);
99 extern void _nc_Link_Items(MENU *);