]> ncurses.scripts.mit.edu Git - ncurses.git/blob - menu/menu.priv.h
b249e435503dde52c1d1a7da4eed14c0df3d4d63
[ncurses.git] / menu / menu.priv.h
1 /****************************************************************************
2  * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *   Author:  Juergen Pfeifer, 1995,1997                                    *
31  *   Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en             *
32  ****************************************************************************/
33
34 /***************************************************************************
35 * Module menu.priv.h                                                       *
36 * Top level private header file for all libnmenu modules                   *
37 ***************************************************************************/
38
39 #ifndef MENU_PRIV_H_incl
40 #define MENU_PRIV_H_incl 1
41
42 #include <ncurses_cfg.h>
43 #include <curses.h>
44
45 #include "mf_common.h"
46 #include "menu.h"
47
48 /* Backspace code */
49 #define BS (8)
50
51 extern NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item;
52 extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu;
53
54 /* Normalize item to default if none was given */
55 #define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
56
57 /* Normalize menu to default if none was given */
58 #define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
59
60 /* Get the user defined (framing) window of the menu */
61 #define Get_Menu_UserWin(menu) ((menu)->userwin ? (menu)->userwin : stdscr)
62
63 /* Normalize menu window */
64 #define Get_Menu_Window(  menu ) \
65    ((menu)->usersub  ? (menu)->usersub  : Get_Menu_UserWin(menu))
66
67 /* menu specific status flags */
68 #define _LINK_NEEDED    (0x04)
69 #define _MARK_ALLOCATED (0x08)
70
71 #define ALL_MENU_OPTS (                 \
72                        O_ONEVALUE     | \
73                        O_SHOWDESC     | \
74                        O_ROWMAJOR     | \
75                        O_IGNORECASE   | \
76                        O_SHOWMATCH    | \
77                        O_NONCYCLIC    )
78
79 #define ALL_ITEM_OPTS (O_SELECTABLE)
80
81 /* Move to the window position of an item and draw it */
82 #define Move_And_Post_Item(menu,item) \
83   {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\
84    _nc_Post_Item((menu),(item));}
85
86 #define Move_To_Current_Item(menu,item) \
87   if ( (item) != (menu)->curitem)\
88     {\
89       Move_And_Post_Item(menu,item);\
90       Move_And_Post_Item(menu,(menu)->curitem);\
91     }
92
93 /* This macro ensures, that the item becomes visible, if possible with the
94    specified row as the top row of the window. If this is not possible,
95    the top row will be adjusted and the value is stored in the row argument.
96 */
97 #define Adjust_Current_Item(menu,row,item) \
98   { if ((item)->y < row) \
99       row = (item)->y;\
100     if ( (item)->y >= (row + (menu)->arows) )\
101       row = ( (item)->y < ((menu)->rows - row) ) ? \
102             (item)->y : (menu)->rows - (menu)->arows;\
103     _nc_New_TopRow_and_CurrentItem(menu,row,item); }
104
105 /* Reset the match pattern buffer */
106 #define Reset_Pattern(menu) \
107   { (menu)->pindex = 0; \
108     (menu)->pattern[0] = '\0'; }
109
110 /* Internal functions. */
111 extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
112 extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
113 extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
114 extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
115 extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
116 extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
117 extern NCURSES_EXPORT(void) _nc_New_TopRow_and_CurrentItem (MENU *,int, ITEM *);
118 extern NCURSES_EXPORT(void) _nc_Link_Items (MENU *);
119 extern NCURSES_EXPORT(int)  _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**);
120 extern NCURSES_EXPORT(int)  _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
121                                 int* pY, int* pX);
122
123 #endif /* MENU_PRIV_H_incl */