xref: /titanic_44/usr/src/lib/libeti/menu/inc/private.h (revision 3c112a2b34403220c06c3e2fcac403358cfba168)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright (c) 1997, by Sun Mircrosystems, Inc.
28  * All rights reserved.
29  */
30 
31 #ifndef _MENU_PRIVATE_H
32 #define	_MENU_PRIVATE_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.9	*/
35 
36 #include <menu.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /* Menu macros to access menu structure */
43 
44 #define	Height(m)	(m)->height
45 #define	Width(m)	(m)->width
46 #define	Rows(m)		(m)->rows
47 #define	Cols(m)		(m)->cols
48 #define	FRows(m)	(m)->frows
49 #define	FCols(m)	(m)->fcols
50 #define	MaxName(m)	(m)->namelen
51 #define	MaxDesc(m)	(m)->desclen
52 #define	Marklen(m)	(m)->marklen
53 #define	Itemlen(m)	(m)->itemlen
54 #define	Pattern(m)	(m)->pattern
55 #define	Pindex(m)	(m)->pindex
56 #define	IthPattern(m, i)	(m)->pattern[i]
57 #define	Win(m)		(m)->win
58 #define	Sub(m)		(m)->sub
59 #define	UserWin(m)	(m)->userwin
60 #define	UserSub(m)	(m)->usersub
61 #define	UW(m)		(UserWin(m) ? UserWin(m) : stdscr)
62 #define	US(m)		(UserSub(m) ? UserSub(m) : UW(m))
63 #define	Items(m)	(m)->items
64 #define	IthItem(m, i)	(m)->items[i]
65 #define	Nitems(m)	(m)->nitems
66 #define	Current(m)	(m)->curitem
67 #define	Top(m)		(m)->toprow
68 #define	Pad(m)		(m)->pad
69 #define	Fore(m)		(m)->fore
70 #define	Back(m)		(m)->back
71 #define	Grey(m)		(m)->grey
72 #define	InvalidAttr(a)	(((a) & (chtype) A_ATTRIBUTES) != (a))
73 #define	Mhelp(m)	(m)->help
74 #define	Muserptr(m)	(m)->userptr
75 #define	Mopt(m)		(m)->opt
76 #define	Mark(m)		(m)->mark
77 #define	Mstatus(m)	(m)->status
78 #define	Posted(m)	(Mstatus(m) & _POSTED)
79 #define	Indriver(m)	(Mstatus(m) & _IN_DRIVER)
80 #define	LinkNeeded(m)	(Mstatus(m) & _LINK_NEEDED)
81 #define	SetPost(m)	(Mstatus(m) |= _POSTED)
82 #define	SetDriver(m)	(Mstatus(m) |= _IN_DRIVER)
83 #define	SetLink(m)	(Mstatus(m) |= _LINK_NEEDED)
84 #define	ResetPost(m)	(Mstatus(m) &= ~_POSTED)
85 #define	ResetDriver(m)	(Mstatus(m) &= ~_IN_DRIVER)
86 #define	ResetLink(m)	(Mstatus(m) &= ~_LINK_NEEDED)
87 #define	SMinit(m)	(m)->menuinit
88 #define	SMterm(m)	(m)->menuterm
89 #define	SIinit(m)	(m)->iteminit
90 #define	SIterm(m)	(m)->itemterm
91 #define	Minit(m)	if (m->menuinit) { \
92 			    SetDriver(m); \
93 			    (m)->menuinit(m); \
94 			    ResetDriver(m); \
95 			}
96 #define	Mterm(m)	if (m->menuterm) { \
97 			    SetDriver(m); \
98 			    (m)->menuterm(m); \
99 			    ResetDriver(m); \
100 			}
101 #define	Iinit(m)	if (m->iteminit) { \
102 			    SetDriver(m); \
103 			    (m)->iteminit(m); \
104 			    ResetDriver(m); \
105 			}
106 #define	Iterm(m)	if (m->itemterm) { \
107 			    SetDriver(m); \
108 			    (m)->itemterm(m); \
109 			    ResetDriver(m); \
110 			}
111 
112 /* Define access to Mopt */
113 
114 #define	OneValue(m)	(Mopt(m) & O_ONEVALUE)
115 #define	ShowDesc(m)	(Mopt(m) & O_SHOWDESC)
116 #define	RowMajor(m)	(Mopt(m) & O_ROWMAJOR)
117 #define	IgnoreCase(m)	(Mopt(m) & O_IGNORECASE)
118 #define	ShowMatch(m)	(Mopt(m) & O_SHOWMATCH)
119 #define	Cyclic(m)	(!(Mopt(m) & O_NONCYCLIC))
120 
121 /* Item macros to access item structure */
122 
123 #define	Name(i)		(i)->name.str
124 #define	NameLen(i)	(i)->name.length
125 #define	Description(i)	(i)->description.str
126 #define	DescriptionLen(i)	(i)->description.length
127 #define	Index(i)	(i)->index
128 #define	Y(i)		(i)->y
129 #define	X(i)		(i)->x
130 #define	Imenu(i)	(i)->imenu
131 #define	Value(i)	(i)->value
132 #define	Ihelp(i)	(i)->help
133 #define	Iuserptr(i)	(i)->userptr
134 #define	Iopt(i)		(i)->opt
135 #define	Istatus(i)	(i)->status
136 #define	Up(i)		(i)->up
137 #define	Down(i)		(i)->down
138 #define	Left(i)		(i)->left
139 #define	Right(i)	(i)->right
140 #define	Selectable(i)	(Iopt(i) & O_SELECTABLE)
141 
142 /* Default menu macros */
143 
144 #define	Dfl_Menu	(&_Default_Menu)
145 #define	Dfl_Item	(&_Default_Item)
146 
147 #define	max(a, b)	((a) > (b)) ? (a) : (b)
148 #define	min(a, b)	((a) < (b)) ? (a) : (b)
149 
150 extern MENU		_Default_Menu;
151 extern ITEM		_Default_Item;
152 
153 extern void		_affect_change(MENU *, int, ITEM *);
154 extern void		_chk_current(MENU *, int *, ITEM *);
155 extern void		_chk_top(MENU *, int *, ITEM *);
156 extern void		_disconnect(MENU *);
157 extern void		_draw(MENU *);
158 extern void		_link_items(MENU *);
159 extern void		_move_post_item(MENU *, ITEM *);
160 extern void		_movecurrent(MENU *, ITEM *);
161 extern void		_position_cursor(MENU *);
162 extern void		_scale(MENU *);
163 extern void		_show(MENU *);
164 extern int		_match(MENU *, char, ITEM **);
165 extern int		_connect(MENU *, ITEM **);
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif	/* _MENU_PRIVATE_H */
172