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