1 /*
2  * $Id: itemlist.h,v 1.24 2012/03/21 21:15:30 tom Exp $
3  */
4 
5 #ifndef CDKINCLUDES
6 #ifndef CDKITEMLIST_H
7 #define CDKITEMLIST_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-2004,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 the CDK itemlist widget structure.
59  */
60 struct SItemList {
61    CDKOBJS	obj;
62    WINDOW *	parent;
63    WINDOW *	win;
64    WINDOW *	shadowWin;
65    WINDOW *	labelWin;
66    WINDOW *	fieldWin;
67    int		titleAdj;
68    chtype *	label;
69    int		labelLen;
70    int		fieldWidth;
71    chtype **	item;
72    int *	itemPos;
73    int *	itemLen;
74    int		listSize;
75    int		currentItem;
76    int		defaultItem;
77    int		boxWidth;
78    int		boxHeight;
79    EExitType	exitType;
80    boolean	shadow;
81 };
82 typedef struct SItemList CDKITEMLIST;
83 
84 /*
85  * This creates a pointer to a CDK itemlist widget.
86  */
87 CDKITEMLIST *newCDKItemlist (
88 		CDKSCREEN *	/* cdkscreen */,
89 		int		/* xpos */,
90 		int		/* ypos */,
91 		const char *	/* title */,
92 		const char *	/* label */,
93 		CDK_CSTRING2	/* itemlist */,
94 		int		/* count */,
95 		int		/* defaultItem */,
96 		boolean		/* Box */,
97 		boolean		/* shadow */);
98 
99 /*
100  * This activates the itemlist widget.
101  */
102 int activateCDKItemlist (
103 		CDKITEMLIST *	/* itemlist */,
104 		chtype *	/* actions */);
105 
106 /*
107  * This injects a single character into the itemlist widget.
108  */
109 #define injectCDKItemlist(obj,input) injectCDKObject(obj,input,Int)
110 
111 /*
112  * These functions set specific elements of the itemlist widget.
113  */
114 void setCDKItemlist (
115 		CDKITEMLIST *	/* itemlist */,
116 		CDK_CSTRING2	/* list */,
117 		int		/* count */,
118 		int		/* current */,
119 		boolean		/* Box */);
120 
121 /*
122  * This function sets the values of the item list widget.
123  */
124 void setCDKItemlistValues (
125 		CDKITEMLIST *	/* itemlist */,
126 		CDK_CSTRING2	/* list */,
127 		int		/* count */,
128 		int		/* defaultItem */);
129 
130 chtype **getCDKItemlistValues (
131 		CDKITEMLIST *	/* itemlist */,
132 		int *		/* size */);
133 
134 /*
135  * This sets the default item in the list.
136  */
137 void setCDKItemlistDefaultItem (
138 		CDKITEMLIST *	/* itemlist */,
139 		int		/* defaultItem */);
140 
141 int getCDKItemlistDefaultItem (
142 		CDKITEMLIST *	/* itemlist */);
143 
144 /*
145  * This returns an index to the current item in the list.
146  */
147 void setCDKItemlistCurrentItem (
148 		CDKITEMLIST *	/* itemlist */,
149 		int		/* currentItem */);
150 
151 int getCDKItemlistCurrentItem (
152 		CDKITEMLIST *	/* itemlist */);
153 
154 /*
155  * This sets the box attribute of the widget.
156  */
157 void setCDKItemlistBox (
158 		CDKITEMLIST *	/* itemlist */,
159 		boolean		/* Box */);
160 
161 boolean getCDKItemlistBox (
162 		CDKITEMLIST *	/* itemlist */);
163 
164 /*
165  * These set the drawing characters of the widget.
166  */
167 #define setCDKItemlistULChar(w,c)          setULCharOf(w,c)
168 #define setCDKItemlistURChar(w,c)          setURCharOf(w,c)
169 #define setCDKItemlistLLChar(w,c)          setLLCharOf(w,c)
170 #define setCDKItemlistLRChar(w,c)          setLRCharOf(w,c)
171 #define setCDKItemlistVerticalChar(w,c)    setVTCharOf(w,c)
172 #define setCDKItemlistHorizontalChar(w,c)  setHZCharOf(w,c)
173 #define setCDKItemlistBoxAttribute(w,c)    setBXAttrOf(w,c)
174 
175 /*
176  * This sets the background color of the widget.
177  */
178 #define setCDKItemlistBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
179 
180 /*
181  * This sets the background attribute of the widget.
182  */
183 #define setCDKItemlistBackgroundAttrib(w,c) setBKAttrOf(w,c)
184 
185 /*
186  * This draws the itemlist widget.
187  */
188 #define drawCDKItemlist(obj,Box) drawCDKObject(obj,Box)
189 
190 /*
191  * This draws the itemlist field.
192  */
193 void drawCDKItemlistField (
194 		CDKITEMLIST *	/* itemlist */,
195 		boolean         /* highlight */);
196 
197 /*
198  * This removes the widget from the screen.
199  */
200 #define eraseCDKItemlist(obj) eraseCDKObject(obj)
201 
202 /*
203  * This moves the widget to the given position.
204  */
205 #define moveCDKItemlist(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
206 
207 /*
208  * This allows the user to interactively move the widget.
209  */
210 #define positionCDKItemlist(widget) positionCDKObject(ObjOf(widget),widget->win)
211 
212 /*
213  * This destroys the widget and all the associated memory.
214  */
215 #define destroyCDKItemlist(obj) destroyCDKObject(obj)
216 
217 /*
218  * These functions set the pre/post process functions.
219  */
220 #define setCDKItemlistPreProcess(w,f,d)  setCDKObjectPreProcess(ObjOf(w),f,d)
221 #define setCDKItemlistPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
222 
223 #ifdef __cplusplus
224 }
225 #endif
226 
227 #endif /* CDKITEMLIST_H */
228 #endif /* CDKINCLUDES */
229