xref: /386bsd/usr/X386/include/X11/Xaw/TextSink.h (revision a2142627)
1 /*
2  * $XConsortium: TextSink.h,v 1.8 91/02/17 13:20:18 rws Exp $
3  */
4 
5 /***********************************************************
6 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
7 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
8 
9                         All Rights Reserved
10 
11 Permission to use, copy, modify, and distribute this software and its
12 documentation for any purpose and without fee is hereby granted,
13 provided that the above copyright notice appear in all copies and that
14 both that copyright notice and this permission notice appear in
15 supporting documentation, and that the names of Digital or MIT not be
16 used in advertising or publicity pertaining to distribution of the
17 software without specific, written prior permission.
18 
19 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
20 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
21 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
22 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
25 SOFTWARE.
26 
27 ******************************************************************/
28 
29 #ifndef _XawTextSink_h
30 #define _XawTextSink_h
31 
32 /***********************************************************************
33  *
34  * TextSink Object
35  *
36  ***********************************************************************/
37 
38 #include <X11/Object.h>
39 #include <X11/Xfuncproto.h>
40 
41 /* Resources:
42 
43  Name		     Class		RepType		Default Value
44  ----		     -----		-------		-------------
45  font                Font            XFontStruct *      XtDefaultFont
46  foreground          Foreground      Pixel              XtDefaultForeground
47  background          Background      Pixel              XtDefaultBackground
48 
49 */
50 
51 /* Class record constants */
52 
53 extern WidgetClass textSinkObjectClass;
54 
55 typedef struct _TextSinkClassRec *TextSinkObjectClass;
56 typedef struct _TextSinkRec      *TextSinkObject;
57 
58 typedef enum {XawisOn, XawisOff} XawTextInsertState;
59 
60 /************************************************************
61  *
62  * Public Functions.
63  *
64  ************************************************************/
65 
66 _XFUNCPROTOBEGIN
67 
68 /*	Function Name: XawTextSinkDisplayText
69  *	Description: Stub function that in subclasses will display text.
70  *	Arguments: w - the TextSink Object.
71  *                 x, y - location to start drawing text.
72  *                 pos1, pos2 - location of starting and ending points
73  *                              in the text buffer.
74  *                 highlight - hightlight this text?
75  *	Returns: none.
76  *
77  * This function doesn't actually display anything, it is only a place
78  * holder.
79  */
80 
81 extern void XawTextSinkDisplayText(
82 #if NeedFunctionPrototypes
83     Widget		/* w */,
84 #if NeedWidePrototypes
85     /* Position */ int	/* x */,
86     /* Position	*/ int	/* y */,
87 #else
88     Position		/* x */,
89     Position		/* y */,
90 #endif
91     XawTextPosition	/* pos1 */,
92     XawTextPosition	/* pos2 */,
93 #if NeedWidePrototypes
94     /* Boolean */ int	/* highlight */
95 #else
96     Boolean		/* highlight */
97 #endif
98 #endif
99 );
100 
101 /*	Function Name: XawTextSinkInsertCursor
102  *	Description: Places the InsertCursor.
103  *	Arguments: w - the TextSink Object.
104  *                 x, y - location for the cursor.
105  *                 staye - whether to turn the cursor on, or off.
106  *	Returns: none.
107  *
108  * This function doesn't actually display anything, it is only a place
109  * holder.
110  */
111 
112 extern void XawTextSinkInsertCursor(
113 #if NeedFunctionPrototypes
114     Widget		/* w */,
115 #if NeedWidePrototypes
116     /* Position */ int	/* x */,
117     /* Position	*/ int	/* y */,
118     /* XawTextInsertState */ int /* state */
119 #else
120     Position		/* x */,
121     Position		/* y */,
122     XawTextInsertState	/* state */
123 #endif
124 #endif
125 );
126 
127 /*	Function Name: XawTextSinkClearToBackground
128  *	Description: Clears a region of the sink to the background color.
129  *	Arguments: w - the TextSink Object.
130  *                 x, y  - location of area to clear.
131  *                 width, height - size of area to clear
132  *	Returns: void.
133  *
134  * This function doesn't actually display anything, it is only a place
135  * holder.
136  */
137 
138 extern void XawTextSinkClearToBackground(
139 #if NeedFunctionPrototypes
140     Widget		/* w */,
141 #if NeedWidePrototypes
142     /* Position */ int	/* x */,
143     /* Position */ int	/* y */,
144     /* Dimension */ int	/* width */,
145     /* Dimension */ int	/* height */
146 #else
147     Position		/* x */,
148     Position		/* y */,
149     Dimension		/* width */,
150     Dimension		/* height */
151 #endif
152 #endif
153 );
154 
155 /*	Function Name: XawTextSinkFindPosition
156  *	Description: Finds a position in the text.
157  *	Arguments: w - the TextSink Object.
158  *                 fromPos - reference position.
159  *                 fromX   - reference location.
160  *                 width,  - width of section to paint text.
161  *                 stopAtWordBreak - returned position is a word break?
162  *                 resPos - Position to return.      *** RETURNED ***
163  *                 resWidth - Width actually used.   *** RETURNED ***
164  *                 resHeight - Height actually used. *** RETURNED ***
165  *	Returns: none (see above).
166  */
167 
168 extern void XawTextSinkFindPosition(
169 #if NeedFunctionPrototypes
170     Widget		/* w */,
171     XawTextPosition	/* fromPos */,
172     int			/* fromX */,
173     int			/* width */,
174 #if NeedWidePrototypes
175     /* Boolean */ int	/* stopAtWordBreak */,
176 #else
177     Boolean		/* stopAtWordBreak */,
178 #endif
179     XawTextPosition*	/* pos_return */,
180     int*		/* width_return */,
181     int*		/* height_return */
182 #endif
183 );
184 
185 /*	Function Name: XawTextSinkFindDistance
186  *	Description: Find the Pixel Distance between two text Positions.
187  *	Arguments: w - the TextSink Object.
188  *                 fromPos - starting Position.
189  *                 fromX   - x location of starting Position.
190  *                 toPos   - end Position.
191  *                 resWidth - Distance between fromPos and toPos.
192  *                 resPos   - Acutal toPos used.
193  *                 resHeight - Height required by this text.
194  *	Returns: none.
195  */
196 
197 extern void XawTextSinkFindDistance (
198 #if NeedFunctionPrototypes
199     Widget		/* w */,
200     XawTextPosition	/* fromPos */,
201     int			/* fromX */,
202     XawTextPosition     /* toPos */,
203     int*		/* width_return */,
204     XawTextPosition*	/* pos_return */,
205     int*		/* height_return */
206 #endif
207 );
208 
209 /*	Function Name: XawTextSinkResolve
210  *	Description: Resloves a location to a position.
211  *	Arguments: w - the TextSink Object.
212  *                 pos - a reference Position.
213  *                 fromx - a reference Location.
214  *                 width - width to move.
215  *                 resPos - the resulting position.
216  *	Returns: none
217  */
218 
219 extern void XawTextSinkResolve(
220 #if NeedFunctionPrototypes
221     Widget		/* w */,
222     XawTextPosition	/* fromPos */,
223     int			/* fromX */,
224     int			/* width */,
225     XawTextPosition*	/* pos_return */
226 #endif
227 );
228 
229 /*	Function Name: XawTextSinkMaxLines
230  *	Description: Finds the Maximum number of lines that will fit in
231  *                   a given height.
232  *	Arguments: w - the TextSink Object.
233  *                 height - height to fit lines into.
234  *	Returns: the number of lines that will fit.
235  */
236 
237 extern int XawTextSinkMaxLines(
238 #if NeedFunctionPrototypes
239     Widget		/* w */,
240 #if NeedWidePrototypes
241     /* Dimension */ int	/* height */
242 #else
243     Dimension		/* height */
244 #endif
245 #endif
246 );
247 
248 /*	Function Name: XawTextSinkMaxHeight
249  *	Description: Finds the Minium height that will contain a given number
250  *                   lines.
251  *	Arguments: w - the TextSink Object.
252  *                 lines - the number of lines.
253  *	Returns: the height.
254  */
255 
256 extern int XawTextSinkMaxHeight(
257 #if NeedFunctionPrototypes
258     Widget		/* w */,
259     int			/* lines */
260 #endif
261 );
262 
263 /*	Function Name: XawTextSinkSetTabs
264  *	Description: Sets the Tab stops.
265  *	Arguments: w - the TextSink Object.
266  *                 tab_count - the number of tabs in the list.
267  *                 tabs - the text positions of the tabs.
268  *	Returns: none
269  */
270 
271 extern void XawTextSinkSetTabs(
272 #if NeedFunctionPrototypes
273     Widget		/* w */,
274     int			/* tab_count */,
275     int*		/* tabs */
276 #endif
277 );
278 
279 /*	Function Name: XawTextSinkGetCursorBounds
280  *	Description: Finds the bounding box for the insert curor (caret).
281  *	Arguments: w - the TextSinkObject.
282  *                 rect - an X rectance containing the cursor bounds.
283  *	Returns: none (fills in rect).
284  */
285 
286 extern void XawTextSinkGetCursorBounds(
287 #if NeedFunctionPrototypes
288     Widget		/* w */,
289     XRectangle*		/* rect_return */
290 #endif
291 );
292 
293 _XFUNCPROTOEND
294 
295 #endif /* _XawTextSrc_h -- DON'T ADD STUFF AFTER THIS #endif */
296