1 /*
2  * $Id: buttonbox.h,v 1.27 2012/03/21 21:15:30 tom Exp $
3  */
4 
5 #ifndef CDKINCLUDES
6 #ifndef CDKBUTTONBOX_H
7 #define CDKBUTTONBOX_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 the CDK buttonbox structure.
59  */
60 struct SButtonBox {
61    CDKOBJS	obj;
62    WINDOW *	parent;
63    WINDOW *	win;
64    WINDOW *	shadowWin;
65    int		titleAdj;
66    chtype **	button;
67    int *	buttonLen;
68    int *	buttonPos;
69    int *	columnWidths;
70    int		buttonCount;
71    int		buttonWidth;
72    int		currentButton;
73    int		rows;
74    int		cols;
75    int		colAdjust;
76    int		rowAdjust;
77    int		boxWidth;
78    int		boxHeight;
79    chtype	ButtonAttrib;
80    EExitType	exitType;
81    boolean	shadow;
82    chtype	highlight;
83 };
84 typedef struct SButtonBox CDKBUTTONBOX;
85 
86 /*
87  * This returns a CDK buttonbox widget pointer.
88  */
89 CDKBUTTONBOX *newCDKButtonbox (
90 		CDKSCREEN *	/* cdkscreen */,
91 		int		/* xPos */,
92 		int		/* yPos */,
93 		int		/* height */,
94 		int		/* width */,
95 		const char *	/* title */,
96 		int		/* rows */,
97 		int		/* cols */,
98 		CDK_CSTRING2	/* buttons */,
99 		int		/* buttonCount */,
100 		chtype		/* highlight */,
101 		boolean		/* Box */,
102 		boolean		/* shadow */);
103 
104 /*
105  * This activates the widget.
106  */
107 int activateCDKButtonbox (
108 		CDKBUTTONBOX *	/* buttonbox */,
109 		chtype *	/* actions */);
110 
111 /*
112  * This injects a single character into the widget.
113  */
114 #define injectCDKButtonbox(obj,input) injectCDKObject(obj,input,Int)
115 
116 /*
117  * This sets multiple attributes of the widget.
118  */
119 void setCDKButtonbox (
120 		CDKBUTTONBOX *	/* buttonbox */,
121 		chtype		/* highlight */,
122 		boolean		/* Box */);
123 
124 void setCDKButtonboxCurrentButton (
125 		CDKBUTTONBOX *	/* buttonbox */,
126 		int		/* button */);
127 
128 int getCDKButtonboxCurrentButton (
129 		CDKBUTTONBOX *	/* buttonbox */);
130 
131 int getCDKButtonboxButtonCount (
132 		CDKBUTTONBOX *	/* buttonbox */);
133 
134 /*
135  * This sets the highlight attribute for the buttonbox.
136  */
137 void setCDKButtonboxHighlight (
138 		CDKBUTTONBOX *	/* buttonbox */,
139 		chtype		/* highlight */);
140 
141 chtype getCDKButtonboxHighlight (
142 		CDKBUTTONBOX *	/* buttonbox */);
143 
144 /*
145  * This sets the box attribute of the widget.
146  */
147 void setCDKButtonboxBox (
148 		CDKBUTTONBOX *	/* buttonbox */,
149 		boolean		/* Box */);
150 
151 boolean getCDKButtonboxBox (
152 		CDKBUTTONBOX *	/* buttonbox */);
153 
154 /*
155  * These set the drawing characters of the widget.
156  */
157 #define setCDKButtonboxULChar(w,c)         setULCharOf(w,c)
158 #define setCDKButtonboxURChar(w,c)         setURCharOf(w,c)
159 #define setCDKButtonboxLLChar(w,c)         setLLCharOf(w,c)
160 #define setCDKButtonboxLRChar(w,c)         setLRCharOf(w,c)
161 #define setCDKButtonboxVerticalChar(w,c)   setVTCharOf(w,c)
162 #define setCDKButtonboxHorizontalChar(w,c) setHZCharOf(w,c)
163 #define setCDKButtonboxBoxAttribute(w,c)   setBXAttrOf(w,c)
164 
165 /*
166  * This sets the background color of the widget.
167  */
168 #define setCDKButtonboxBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
169 
170 /*
171  * This sets the background attribute of the widget.
172  */
173 #define setCDKButtonboxBackgroundAttrib(w,c) setBKAttrOf(w,c)
174 
175 /*
176  * This draws the buttonbox box widget.
177  */
178 #define drawCDKButtonbox(obj,box) drawCDKObject(obj,box)
179 
180 void drawCDKButtonboxButtons (
181 		CDKBUTTONBOX *	/* buttonbox */);
182 
183 /*
184  * This erases the buttonbox box from the screen.
185  */
186 #define eraseCDKButtonbox(obj) eraseCDKObject(obj)
187 
188 /*
189  * This moves the buttonbox box to a new screen location.
190  */
191 #define moveCDKButtonbox(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
192 
193 /*
194  * This allows the user to position the widget on the screen interactively.
195  */
196 #define positionCDKButtonbox(widget) positionCDKObject(ObjOf(widget),widget->win)
197 
198 /*
199  * This destroys the widget and all the memory associated with it.
200  */
201 #define destroyCDKButtonbox(obj) destroyCDKObject(obj)
202 
203 /*
204  * This redraws the buttonbox box buttonboxs.
205  */
206 void redrawCDKButtonboxButtonboxs (
207 		CDKBUTTONBOX *	/* buttonbox */);
208 
209 /*
210  * These set the pre/post process functions of the buttonbox widget.
211  */
212 #define setCDKButtonboxPreProcess(w,f,d)  setCDKObjectPreProcess(ObjOf(w),f,d)
213 #define setCDKButtonboxPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* CDKBUTTONBOX_H */
220 #endif /* CDKINCLUDES */
221