1 /*
2  * $Id: swindow.h,v 1.24 2012/03/21 21:15:30 tom Exp $
3  */
4 
5 #ifndef CDKINCLUDES
6 #ifndef CDKSWINDOW_H
7 #define CDKSWINDOW_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 scrolling window widget structure.
59  */
60 struct SSwindow {
61    CDKOBJS	obj;
62    WINDOW *	parent;
63    WINDOW *	win;
64    WINDOW *	fieldWin;
65    WINDOW *	shadowWin;
66    chtype **	list;
67    int *	listPos;
68    int *	listLen;
69    int		titleAdj;
70    int		listSize;
71    int		boxHeight;
72    int		boxWidth;
73    int		viewSize;
74    int		maxTopLine;
75    int		currentTop;
76    int		leftChar;
77    int		maxLeftChar;
78    int		widestLine;
79    int		saveLines;
80    EExitType	exitType;
81    boolean	shadow;
82 };
83 typedef struct SSwindow CDKSWINDOW;
84 typedef void (*SWINDOWCB) (CDKSWINDOW *swindow, chtype input);
85 
86 /*
87  * This creates a new pointer to a scrolling window widget.
88  */
89 CDKSWINDOW *newCDKSwindow (
90 		CDKSCREEN *	/* cdkscreen */,
91 		int		/* xpos */,
92 		int		/* ypos */,
93 		int		/* height */,
94 		int		/* width */,
95 		const char *	/* title */,
96 		int		/* saveLines */,
97 		boolean		/* Box */,
98 		boolean		/* shadow */);
99 
100 /*
101  * This activates the scrolling window.
102  */
103 void activateCDKSwindow (
104 		CDKSWINDOW *	/* swindow */,
105 		chtype *	/* actions */);
106 
107 /*
108  * This injects a single character into the scrolling window.
109  */
110 #define injectCDKSwindow(obj,input) injectCDKObject(obj,input,Int)
111 
112 /*
113  * This executes the given command and puts the output of the
114  * command into the scrolling window.
115  */
116 int execCDKSwindow (
117 		CDKSWINDOW *	/* swindow */,
118 		const char *	/* command */,
119 		int		/* insertPos */);
120 
121 /*
122  * This dumps the contents of the scrolling window to the given filename.
123  */
124 int dumpCDKSwindow (
125 		CDKSWINDOW *	/* swindow */,
126 		const char *	/* filename */);
127 
128 /*
129  * This jumps to the given line in the window.
130  */
131 void jumpToLineCDKSwindow (
132 		CDKSWINDOW *	/* swindow */,
133 		int		/* line */);
134 
135 /*
136  * This saves the contents of the scrolling window via an
137  * interactive window.
138  */
139 void saveCDKSwindowInformation (
140 		CDKSWINDOW *	/* swindow */);
141 
142 /*
143  * This loads the window up with information from a filename
144  * interactively provided.
145  */
146 void loadCDKSwindowInformation (
147 		CDKSWINDOW *	/* swindow */);
148 
149 /*
150  * These functions set the attributes of the scrolling window.
151  */
152 void setCDKSwindow (
153 		CDKSWINDOW *	/* swindow */,
154 		CDK_CSTRING2	/* info */,
155 		int		/* lines */,
156 		boolean		/* Box */);
157 
158 /*
159  * This sets the contents of the scrolling window.
160  */
161 void setCDKSwindowContents (
162 		CDKSWINDOW *	/* swindow */,
163 		CDK_CSTRING2	/* info */,
164 		int		/* lines */);
165 
166 chtype **getCDKSwindowContents (
167 		CDKSWINDOW *	/* swindow */,
168 		int *		/* size */);
169 
170 /*
171  * This sets the box attribute of the scrolling window.
172  */
173 void setCDKSwindowBox (
174 		CDKSWINDOW *	/* swindow */,
175 		boolean		/* Box */);
176 
177 boolean getCDKSwindowBox (
178 		CDKSWINDOW *	/* swindow */);
179 
180 /*
181  * These set the drawing characters of the widget.
182  */
183 #define setCDKSwindowULChar(w,c)           setULCharOf(w,c)
184 #define setCDKSwindowURChar(w,c)           setURCharOf(w,c)
185 #define setCDKSwindowLLChar(w,c)           setLLCharOf(w,c)
186 #define setCDKSwindowLRChar(w,c)           setLRCharOf(w,c)
187 #define setCDKSwindowVerticalChar(w,c)     setVTCharOf(w,c)
188 #define setCDKSwindowHorizontalChar(w,c)   setHZCharOf(w,c)
189 #define setCDKSwindowBoxAttribute(w,c)     setBXAttrOf(w,c)
190 
191 /*
192  * This sets the background color of the widget.
193  */
194 #define setCDKSwindowBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c)
195 
196 /*
197  * This sets the background attribute of the widget.
198  */
199 #define setCDKSwindowBackgroundAttrib(w,c) setBKAttrOf(w,c)
200 
201 /*
202  * This draws the scrolling window on the screen.
203  */
204 #define drawCDKSwindow(obj,Box) drawCDKObject(obj,Box)
205 
206 /*
207  * This removes the widget from the screen.
208  */
209 #define eraseCDKSwindow(obj) eraseCDKObject(obj)
210 
211 /*
212  * This cleans out all of the information from the window.
213  */
214 void cleanCDKSwindow (
215 		CDKSWINDOW *	/* swindow */);
216 
217 /*
218  * This adds a line to the window.
219  */
220 void addCDKSwindow (
221 		CDKSWINDOW *	/* swindow */,
222 		const char *	/* info */,
223 		int		/* insertPos */);
224 
225 /*
226  * This trims lines from the window.
227  */
228 void trimCDKSwindow (
229 		CDKSWINDOW *	/* swindow */,
230 		int		/* start */,
231 		int		/* finish */);
232 
233 /*
234  * This moves the window to the given location.
235  */
236 #define moveCDKSwindow(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh)
237 
238 /*
239  * This interactively positions the widget on the screen.
240  */
241 #define positionCDKSwindow(widget) positionCDKObject(ObjOf(widget),widget->win)
242 
243 /*
244  * This destroys the widget and all associated memory.
245  */
246 #define destroyCDKSwindow(obj) destroyCDKObject(obj)
247 
248 /*
249  * These set the pre/post process callback functions.
250  */
251 #define setCDKSwindowPreProcess(w,f,d)  setCDKObjectPreProcess(ObjOf(w),f,d)
252 #define setCDKSwindowPostProcess(w,f,d) setCDKObjectPostProcess(ObjOf(w),f,d)
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif /* CDKSWINDOW_H */
259 #endif /* CDKINCLUDES */
260