1/***********************************************************
2
3Copyright 1987, 1988, 1994, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25
26Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28                        All Rights Reserved
29
30Permission to use, copy, modify, and distribute this software and its
31documentation for any purpose and without fee is hereby granted,
32provided that the above copyright notice appear in all copies and that
33both that copyright notice and this permission notice appear in
34supporting documentation, and that the name of Digital not be
35used in advertising or publicity pertaining to distribution of the
36software without specific, written prior permission.
37
38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44SOFTWARE.
45
46******************************************************************/
47
48#ifndef _XawTextSink_h
49#define _XawTextSink_h
50
51#include <X11/Xaw/Text.h>
52
53/***********************************************************************
54 *
55 * TextSink Object
56 *
57 ***********************************************************************/
58
59/* Resources:
60
61 Name		     Class		RepType		Default Value
62 ----		     -----		-------		-------------
63 font                Font            XFontStruct *      XtDefaultFont
64 foreground          Foreground      Pixel              XtDefaultForeground
65 background          Background      Pixel              XtDefaultBackground
66 cursorColor	     Color	      Pixel		XtDefaultForeground
67*/
68
69/* Class record constants */
70
71extern WidgetClass textSinkObjectClass;
72
73typedef struct _TextSinkClassRec *TextSinkObjectClass;
74typedef struct _TextSinkRec      *TextSinkObject;
75
76typedef enum {XawisOn, XawisOff} XawTextInsertState;
77
78#ifndef OLDXAW
79#ifndef XtNcursorColor
80#define XtNcursorColor		"cursorColor"
81#endif
82
83#define XawNtextProperties	"textProperties"
84#define XawCTextProperties	"TextProperties"
85#define XawRTextProperties	"XawTextProperties"
86#endif
87
88/*
89 * Public Functions
90 */
91_XFUNCPROTOBEGIN
92
93/*
94 * Function:
95 *	XawTextSinkDisplayText
96 *
97 * Parameters:
98 *	w	  - the TextSink Object
99 *	x	  - location to start drawing text
100 *	y	  - ""
101 *	pos1	  - location of starting and ending points in the text buffer
102 *	pos2	  - ""
103 *	highlight - highlight this text?
104 *
105 * Description:
106 *	Stub function that in subclasses will display text.
107 *
108 * Note:
109 *	  This function doesn't actually display anything, it is only a place
110 *	holder.
111 */
112void XawTextSinkDisplayText
113(
114 Widget			w,
115#if NeedWidePrototypes
116 int			x,
117 int			y,
118#else
119 Position		x,
120 Position		y,
121#endif
122 XawTextPosition	pos1,
123 XawTextPosition	pos2,
124#if NeedWidePrototypes
125 int			highlight
126#else
127 Boolean		highlight
128#endif
129 );
130
131/*
132 * Function:
133 *	XawTextSinkInsertCursor
134 *
135 * Parameters:
136 *	w	- the TextSink Object.
137 *	x	- location for the cursor.
138 *	y	- ""
139 *	state	- whether to turn the cursor on, or off
140 *
141 * Description:
142 *	Places the InsertCursor.
143 *
144 * Note:
145 *	  This function doesn't actually display anything, it is only a place
146 *	holder.
147 */
148void XawTextSinkInsertCursor
149(
150 Widget			w,
151#if NeedWidePrototypes
152 int			x,
153 int			y,
154 int			state
155#else
156 Position		x,
157 Position		y,
158 XawTextInsertState	state
159#endif
160 );
161
162/*
163 * Function:
164 *	XawTextSinkClearToBackground
165 *
166 * Parameters:
167 *	w	- TextSink Object
168 *	x	- location of area to clear
169 *	y	- ""
170 *	width	- size of area to clear
171 *	height	- ""
172 *
173 * Description:
174 *	Clears a region of the sink to the background color.
175 *
176 * Note:
177 *	  This function doesn't actually display anything, it is only a place
178 *	holder.
179 */
180void XawTextSinkClearToBackground
181(
182 Widget			w,
183#if NeedWidePrototypes
184 int			x,
185 int			y,
186 unsigned int		width,
187 unsigned int		height
188#else
189 Position		x,
190 Position		y,
191 Dimension		width,
192 Dimension		height
193#endif
194 );
195
196/*
197 * Function:
198 *	XawTextSinkFindPosition
199 *
200 * Parameters:
201 *	w		- TextSink Object
202 *	fromPos		- reference position
203 *	fromX		- reference location
204 *	width		- width of section to paint text
205 *	stopAtWordBreak - returned position is a word break?
206 *	resPos		- Position to return
207 *	resWidth	- Width actually used
208 *	resHeight	- Height actually used
209 *
210 * Description:
211 *	Finds a position in the text.
212 */
213void XawTextSinkFindPosition
214(
215 Widget			w,
216 XawTextPosition	fromPos,
217 int			fromX,
218 int			width,
219#if NeedWidePrototypes
220 int			stopAtWordBreak,
221#else
222 Boolean		stopAtWordBreak,
223#endif
224 XawTextPosition*	pos_return,
225 int			*width_return,
226 int			*height_return
227 );
228
229/*
230 * Function:
231 *	XawTextSinkFindDistance
232 *
233 * Parameters:
234 *	w		- TextSink Object
235 *	fromPos		- starting Position
236 *	fromX		- x location of starting Position
237 *	toPos		- end Position
238 *	resWidth	- Distance between fromPos and toPos
239 *	resPos		- Actual toPos used
240 *	resHeight	- Height required by this text
241 *
242 * Description:
243 *	Find the Pixel Distance between two text Positions.
244 */
245void XawTextSinkFindDistance
246(
247 Widget			w,
248 XawTextPosition	fromPos,
249 int			fromX,
250 XawTextPosition	toPos,
251 int			*width_return,
252 XawTextPosition	*pos_return,
253 int			*height_return
254 );
255
256/*
257 * Function:
258 *	XawTextSinkResolve
259 *
260 * Parameters:
261 *	w	- TextSink Object
262 *	pos	- reference Position
263 *	fromx	- reference Location
264 *	width	- width to move
265 *	resPos	- resulting position
266 *
267 * Description:
268 *	Resolves a location to a position.
269 */
270void XawTextSinkResolve
271(
272 Widget			w,
273 XawTextPosition	fromPos,
274 int			fromX,
275 int			width,
276 XawTextPosition	*pos_return
277 );
278
279/*
280 * Function:
281 *	XawTextSinkMaxLines
282 *
283 * Parameters:
284 *	w	- TextSink Object
285 *	height	- height to fit lines into
286 *
287 * Returns:
288 *	Number of lines that will fit
289 *
290 * Description:
291 *	Finds the Maximum number of lines that will fit in a given height.
292 */
293int XawTextSinkMaxLines
294(
295 Widget			w,
296#if NeedWidePrototypes
297 unsigned int		height
298#else
299 Dimension		height
300#endif
301 );
302
303/*
304 * Function:
305 *	XawTextSinkMaxHeight
306 *
307 * Parameters:
308 *	w	- TextSink Object
309 *	lines	- number of lines
310 *
311 * Returns:
312 *	Height
313 *
314 * Description:
315 *	Finds the Minimum height that will contain a given number lines.
316 */
317int XawTextSinkMaxHeight
318(
319 Widget			w,
320 int			lines
321);
322
323/*
324 * Function:
325 *	XawTextSinkSetTabs
326 *
327 * Parameters:
328 *	w		- TextSink Object
329 *	tab_count	- number of tabs in the list
330 *	tabs		- text positions of the tabs
331 * Description:
332 *	Sets the Tab stops.
333 */
334void XawTextSinkSetTabs
335(
336 Widget			w,
337 int			tab_count,
338 int			*tabs
339);
340
341/*
342 * Function:
343 *	XawTextSinkGetCursorBounds
344 *
345 * Parameters:
346 *	w	- TextSink Object
347 *	rect	- X rectance containing the cursor bounds
348 * Description:
349 *	Finds the bounding box for the insert curor (caret).
350 */
351void XawTextSinkGetCursorBounds
352(
353 Widget			w,
354 XRectangle		*rect_return
355);
356
357_XFUNCPROTOEND
358
359#endif /* _XawTextSink_h */
360