1 /*
2  * $Id: dialog.h,v 1.26 2012/03/21 21:15:30 tom Exp $
3  */
4 
5 #ifndef CDKINCLUDES
6 #ifndef CDKDIALOG_H
7 #define CDKDIALOG_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-2003,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  * Declare definitions the dialog box may need.
59  */
60 #define MAX_DIALOG_ROWS		50	/* unused by widgets */
61 #define MAX_DIALOG_BUTTONS	25	/* unused by widgets */
62 #define MIN_DIALOG_WIDTH	10
63 
64 /*
65  * Define the CDK dialog structure.
66  */
67 struct SDialogBox {
68    CDKOBJS	obj;
69    WINDOW *	parent;
70    WINDOW *	win;
71    WINDOW *	shadowWin;
72    chtype **	info;
73    int *	infoLen;
74    int *	infoPos;
75    chtype **	buttonLabel;
76    int *	buttonLen;
77    int *	buttonPos;
78    int		messageRows;
79    int		buttonCount;
80    int		currentButton;
81    int		boxWidth;
82    int		boxHeight;
83    EExitType	exitType;
84    boolean	separator;
85    boolean	shadow;
86    chtype	highlight;
87 };
88 typedef struct SDialogBox CDKDIALOG;
89 
90 /*
91  * This returns a CDK dialog widget pointer.
92  */
93 CDKDIALOG *newCDKDialog (
94 		CDKSCREEN *	/* cdkscreen */,
95 		int		/* xPos */,
96 		int		/* yPos */,
97 		CDK_CSTRING2	/* message */,
98 		int		/* Rows */,
99 		CDK_CSTRING2	/* buttons */,
100 		int		/* buttonCount */,
101 		chtype		/* highlight */,
102 		boolean		/* separator */,
103 		boolean		/* Box */,
104 		boolean		/* shadow */);
105 
106 /*
107  * This activates the widget.
108  */
109 int activateCDKDialog (
110 		CDKDIALOG *	/* dialog */,
111 		chtype *	/* actions */);
112 
113 /*
114  * This injects a single character into the widget.
115  */
116 #define injectCDKDialog(obj,input) injectCDKObject(obj,input,Int)
117 
118 /*
119  * This sets multiple attributes of the widget.
120  */
121 void setCDKDialog (
122 		CDKDIALOG *	/* dialog */,
123 		chtype		/* highlight */,
124 		boolean		/* separator */,
125 		boolean		/* Box */);
126 
127 /*
128  * This sets the highlight attribute for the buttons.
129  */
130 void setCDKDialogHighlight (
131 		CDKDIALOG *	/* dialog */,
132 		chtype		/* highlight */);
133 
134 chtype getCDKDialogHighlight (
135 		CDKDIALOG *	/* dialog */);
136 
137 /*
138  * This sets whether or not the dialog box will have a separator line.
139  */
140 void setCDKDialogSeparator (
141 		CDKDIALOG *	/* dialog */,
142 		boolean		/* separator */);
143 
144 boolean getCDKDialogSeparator (
145 		CDKDIALOG *	/* dialog */);
146 
147 /*
148  * This sets the box attribute of the widget.
149  */
150 void setCDKDialogBox (
151 		CDKDIALOG *	/* dialog */,
152 		boolean		/* Box */);
153 
154 boolean getCDKDialogBox (
155 		CDKDIALOG *	/* dialog */);
156 
157 /*
158  * These set the drawing characters of the widget.
159  */
160 #define setCDKDialogULChar(w,c)            setULCharOf(w,c)
161 #define setCDKDialogURChar(w,c)            setURCharOf(w,c)
162 #define setCDKDialogLLChar(w,c)            setLLCharOf(w,c)
163 #define setCDKDialogLRChar(w,c)            setLRCharOf(w,c)
164 #define setCDKDialogVerticalChar(w,c)      setVTCharOf(w,c)
165 #define setCDKDialogHorizontalChar(w,c)    setHZCharOf(w,c)
166 #define setCDKDialogBoxAttribute(w,c)      setBXAttrOf(w,c)
167 
168 /*
169  * This sets the background color of the widget.
170  */
171 #define setCDKDialogBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
172 
173 /*
174  * This sets the background attribute of the widget.
175  */
176 #define setCDKDialogBackgroundAttrib(w,c) setBKAttrOf(w,c)
177 
178 /*
179  * This draws the dialog box widget.
180  */
181 #define drawCDKDialog(obj,box) drawCDKObject(obj,box)
182 
183 /*
184  * This erases the dialog box from the screen.
185  */
186 #define eraseCDKDialog(obj) eraseCDKObject(obj)
187 
188 /*
189  * This moves the dialog box to a new screen location.
190  */
191 #define moveCDKDialog(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 positionCDKDialog(widget) positionCDKObject(ObjOf(widget),widget->win)
197 
198 /*
199  * This destroys the widget and all the memory associated with it.
200  */
201 #define destroyCDKDialog(obj) destroyCDKObject(obj)
202 
203 /*
204  * This draws the dialog box buttons.
205  */
206 void drawCDKDialogButtons (
207 		CDKDIALOG *	/* dialog */);
208 
209 /*
210  * These set the pre/post process functions of the dialog widget.
211  */
212 #define setCDKDialogPreProcess(w,f,d)  setCDKObjectPreProcess(ObjOf(w),f,d)
213 #define setCDKDialogPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* CDKDIALOG_H */
220 #endif /* CDKINCLUDES */
221