1 /*
2  * $Id: menu.h,v 1.22 2012/03/21 21:15:30 tom Exp $
3  */
4 
5 #ifndef CDKINCLUDES
6 #ifndef CDKMENU_H
7 #define CDKMENU_H	1
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #ifndef CDK_H
14 #define CDKINCLUDES
15 #include <cdk.h>
16 #undef CDKINCLUDES
17 #include <binding.h>
18 #include <cdkscreen.h>
19 #include <cdk_objs.h>
20 #endif
21 
22 /*
23  * Changes 1999-2005,2012 copyright Thomas E. Dickey
24  *
25  * Copyright 1999, Mike Glover
26  * All rights reserved.
27  *
28  * Redistribution and use in source and binary forms, with or without
29  * modification, are permitted provided that the following conditions
30  * are met:
31  * 1. Redistributions of source code must retain the above copyright
32  *    notice, this list of conditions and the following disclaimer.
33  * 2. Redistributions in binary form must reproduce the above copyright
34  *    notice, this list of conditions and the following disclaimer in the
35  *    documentation and/or other materials provided with the distribution.
36  * 3. All advertising materials mentioning features or use of this software
37  *    must display the following acknowledgment:
38  * 	This product includes software developed by Mike Glover
39  * 	and contributors.
40  * 4. Neither the name of Mike Glover, nor the names of contributors
41  *    may be used to endorse or promote products derived from this software
42  *    without specific prior written permission.
43  *
44  * THIS SOFTWARE IS PROVIDED BY MIKE GLOVER AND CONTRIBUTORS ``AS IS'' AND
45  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47  * ARE DISCLAIMED.  IN NO EVENT SHALL MIKE GLOVER OR CONTRIBUTORS BE LIABLE
48  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54  * SUCH DAMAGE.
55  */
56 
57 /*
58  * Define menu specific values.
59  */
60 #define MAX_MENU_ITEMS	30
61 #define MAX_SUB_ITEMS	98
62 
63 /*
64  * Define the CDK menu widget structure.
65  */
66 struct SMenu {
67    CDKOBJS	obj;
68    WINDOW *	parent;
69    WINDOW *	pullWin[MAX_MENU_ITEMS];
70    WINDOW *	titleWin[MAX_MENU_ITEMS];
71    chtype *	title[MAX_MENU_ITEMS];
72    int		titleLen[MAX_MENU_ITEMS];
73    chtype *	sublist[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
74    int		sublistLen[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
75    int		subsize[MAX_MENU_ITEMS];
76    int		menuPos;
77    int		menuItems;
78    chtype	titleAttr;
79    chtype	subtitleAttr;
80    int		currentTitle;
81    int		currentSubtitle;
82    int		lastTitle;
83    int		lastSubtitle;
84    EExitType	exitType;
85    int		lastSelection;
86 };
87 typedef struct SMenu CDKMENU;
88 
89 /*
90  * This creates a new CDK menu widget pointer.
91  */
92 CDKMENU *newCDKMenu (
93 		CDKSCREEN *	/* cdkscreen */,
94 		const char *	/* menulist */ [MAX_MENU_ITEMS][MAX_SUB_ITEMS],
95 		int 		/* menuitems */,
96 		int *		/* subsize */,
97 		int *		/* menuloc */,
98 		int		/* menuPos */,
99 		chtype 		/* titleattr */,
100 		chtype 		/* subtitleattr */);
101 
102 /*
103  * This activates the menu.
104  */
105 int activateCDKMenu (
106 		CDKMENU *	/* menu */,
107 		chtype *	/* actions */);
108 
109 /*
110  * This injects a single character into the menu widget.
111  */
112 #define injectCDKMenu(obj,input) injectCDKObject(obj,input,Int)
113 
114 /*
115  * These set specific attributes of the menu.
116  */
117 void setCDKMenu (
118 		CDKMENU *	/* menu */,
119 		int 		/* menuItem */,
120 		int 		/* subMenuItem */,
121 		chtype 		/* titleHighlight */,
122 		chtype 		/* subTitleHighlight */);
123 
124 /*
125  * This returns the current item the menu is on.
126  */
127 void setCDKMenuCurrentItem (
128 		CDKMENU *	/* menu */,
129 		int 		/* menuItem */,
130 		int 		/* subMenuItem */);
131 
132 void getCDKMenuCurrentItem (
133 		CDKMENU *	/* menu */,
134 		int *		/* menuItem */,
135 		int *		/* subMenuItem */);
136 
137 /*
138  * This sets the highlight of the title.
139  */
140 void setCDKMenuTitleHighlight (
141 		CDKMENU *	/* menu */,
142 		chtype 		/* highlight */);
143 
144 chtype getCDKMenuTitleHighlight (
145 		CDKMENU *	/* menu */);
146 
147 /*
148  * This sets the sub-menu title highlight.
149  */
150 void setCDKMenuSubTitleHighlight (
151 		CDKMENU *	/* menu */,
152 		chtype 		/* highlight */);
153 
154 chtype getCDKMenuSubTitleHighlight (
155 		CDKMENU *	/* menu */);
156 
157 /*
158  * This draws the menu on the screen.
159  */
160 #define drawCDKMenu(obj,box) drawCDKObject(obj,box)
161 
162 void drawCDKMenuSubwin (
163 		CDKMENU *	/* menu */);
164 
165 /*
166  * This erases the complere menu widget from the screen.
167  */
168 #define eraseCDKMenu(obj) eraseCDKObject(obj)
169 
170 void eraseCDKMenuSubwin (
171 		CDKMENU *	/* menu */);
172 
173 /*
174  * This sets the background color of the widget.
175  */
176 #define setCDKMenuBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
177 
178 /*
179  * This sets the background attribute of the widget.
180  */
181 #define setCDKMenuBackgroundAttrib(w,c) setBKAttrOf(w,c)
182 
183 /*
184  * This destroys the menu widget.
185  */
186 #define destroyCDKMenu(obj) destroyCDKObject(obj)
187 
188 /*
189  * These set the pre/post process callback functions.
190  */
191 #define setCDKMenuPreProcess(w,f,d)  setCDKObjectPreProcess(ObjOf(w),f,d)
192 #define setCDKMenuPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* CDKMENU_H */
199 #endif /* CDKINCLUDES */
200