17a84e134Smrg/***********************************************************
27a84e134Smrg
37a84e134SmrgCopyright 1987, 1988, 1994, 1998  The Open Group
47a84e134Smrg
57a84e134SmrgPermission to use, copy, modify, distribute, and sell this software and its
67a84e134Smrgdocumentation for any purpose is hereby granted without fee, provided that
77a84e134Smrgthe above copyright notice appear in all copies and that both that
87a84e134Smrgcopyright notice and this permission notice appear in supporting
97a84e134Smrgdocumentation.
107a84e134Smrg
117a84e134SmrgThe above copyright notice and this permission notice shall be included in
127a84e134Smrgall copies or substantial portions of the Software.
137a84e134Smrg
147a84e134SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
157a84e134SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167a84e134SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
177a84e134SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
187a84e134SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
197a84e134SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
207a84e134Smrg
217a84e134SmrgExcept as contained in this notice, the name of The Open Group shall not be
227a84e134Smrgused in advertising or otherwise to promote the sale, use or other dealings
237a84e134Smrgin this Software without prior written authorization from The Open Group.
247a84e134Smrg
257a84e134Smrg
267a84e134SmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
277a84e134Smrg
287a84e134Smrg                        All Rights Reserved
297a84e134Smrg
30421c997bSmrgPermission to use, copy, modify, and distribute this software and its
31421c997bSmrgdocumentation for any purpose and without fee is hereby granted,
327a84e134Smrgprovided that the above copyright notice appear in all copies and that
33421c997bSmrgboth that copyright notice and this permission notice appear in
347a84e134Smrgsupporting documentation, and that the name of Digital not be
357a84e134Smrgused in advertising or publicity pertaining to distribution of the
36421c997bSmrgsoftware without specific, written prior permission.
377a84e134Smrg
387a84e134SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
397a84e134SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
407a84e134SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
417a84e134SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
427a84e134SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
437a84e134SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
447a84e134SmrgSOFTWARE.
457a84e134Smrg
467a84e134Smrg******************************************************************/
477a84e134Smrg
487a84e134Smrg#ifndef _XawTextSink_h
497a84e134Smrg#define _XawTextSink_h
507a84e134Smrg
517a84e134Smrg#include <X11/Xaw/Text.h>
527a84e134Smrg
537a84e134Smrg/***********************************************************************
547a84e134Smrg *
557a84e134Smrg * TextSink Object
567a84e134Smrg *
577a84e134Smrg ***********************************************************************/
587a84e134Smrg
597a84e134Smrg/* Resources:
607a84e134Smrg
617a84e134Smrg Name		     Class		RepType		Default Value
627a84e134Smrg ----		     -----		-------		-------------
637a84e134Smrg font                Font            XFontStruct *      XtDefaultFont
647a84e134Smrg foreground          Foreground      Pixel              XtDefaultForeground
657a84e134Smrg background          Background      Pixel              XtDefaultBackground
667a84e134Smrg cursorColor	     Color	      Pixel		XtDefaultForeground
677a84e134Smrg*/
68421c997bSmrg
697a84e134Smrg/* Class record constants */
707a84e134Smrg
717a84e134Smrgextern WidgetClass textSinkObjectClass;
727a84e134Smrg
737a84e134Smrgtypedef struct _TextSinkClassRec *TextSinkObjectClass;
747a84e134Smrgtypedef struct _TextSinkRec      *TextSinkObject;
757a84e134Smrg
767a84e134Smrgtypedef enum {XawisOn, XawisOff} XawTextInsertState;
777a84e134Smrg
787a84e134Smrg#ifndef OLDXAW
797a84e134Smrg#ifndef XtNcursorColor
807a84e134Smrg#define XtNcursorColor		"cursorColor"
817a84e134Smrg#endif
827a84e134Smrg
837a84e134Smrg#define XawNtextProperties	"textProperties"
847a84e134Smrg#define XawCTextProperties	"TextProperties"
857a84e134Smrg#define XawRTextProperties	"XawTextProperties"
867a84e134Smrg#endif
877a84e134Smrg
887a84e134Smrg/*
897a84e134Smrg * Public Functions
907a84e134Smrg */
917a84e134Smrg_XFUNCPROTOBEGIN
927a84e134Smrg
937a84e134Smrg/*
947a84e134Smrg * Function:
957a84e134Smrg *	XawTextSinkDisplayText
967a84e134Smrg *
977a84e134Smrg * Parameters:
987a84e134Smrg *	w	  - the TextSink Object
997a84e134Smrg *	x	  - location to start drawing text
1007a84e134Smrg *	y	  - ""
1017a84e134Smrg *	pos1	  - location of starting and ending points in the text buffer
1027a84e134Smrg *	pos2	  - ""
1035b16253fSmrg *	highlight - highlight this text?
1047a84e134Smrg *
1057a84e134Smrg * Description:
106421c997bSmrg *	Stub function that in subclasses will display text.
1077a84e134Smrg *
1087a84e134Smrg * Note:
1097a84e134Smrg *	  This function doesn't actually display anything, it is only a place
1107a84e134Smrg *	holder.
1117a84e134Smrg */
1127a84e134Smrgvoid XawTextSinkDisplayText
1137a84e134Smrg(
1147a84e134Smrg Widget			w,
1157a84e134Smrg#if NeedWidePrototypes
1167a84e134Smrg int			x,
1177a84e134Smrg int			y,
1187a84e134Smrg#else
1197a84e134Smrg Position		x,
1207a84e134Smrg Position		y,
1217a84e134Smrg#endif
1227a84e134Smrg XawTextPosition	pos1,
1237a84e134Smrg XawTextPosition	pos2,
1247a84e134Smrg#if NeedWidePrototypes
1257a84e134Smrg int			highlight
1267a84e134Smrg#else
1277a84e134Smrg Boolean		highlight
1287a84e134Smrg#endif
1297a84e134Smrg );
1307a84e134Smrg
1317a84e134Smrg/*
1327a84e134Smrg * Function:
1337a84e134Smrg *	XawTextSinkInsertCursor
1347a84e134Smrg *
1357a84e134Smrg * Parameters:
1367a84e134Smrg *	w	- the TextSink Object.
1377a84e134Smrg *	x	- location for the cursor.
1387a84e134Smrg *	y	- ""
1397a84e134Smrg *	state	- whether to turn the cursor on, or off
1407a84e134Smrg *
1417a84e134Smrg * Description:
1427a84e134Smrg *	Places the InsertCursor.
1437a84e134Smrg *
1447a84e134Smrg * Note:
1457a84e134Smrg *	  This function doesn't actually display anything, it is only a place
1467a84e134Smrg *	holder.
1477a84e134Smrg */
1487a84e134Smrgvoid XawTextSinkInsertCursor
1497a84e134Smrg(
1507a84e134Smrg Widget			w,
1517a84e134Smrg#if NeedWidePrototypes
1527a84e134Smrg int			x,
1537a84e134Smrg int			y,
1547a84e134Smrg int			state
1557a84e134Smrg#else
1567a84e134Smrg Position		x,
1577a84e134Smrg Position		y,
1587a84e134Smrg XawTextInsertState	state
1597a84e134Smrg#endif
1607a84e134Smrg );
1617a84e134Smrg
1627a84e134Smrg/*
1637a84e134Smrg * Function:
1647a84e134Smrg *	XawTextSinkClearToBackground
1657a84e134Smrg *
1667a84e134Smrg * Parameters:
1677a84e134Smrg *	w	- TextSink Object
1687a84e134Smrg *	x	- location of area to clear
1697a84e134Smrg *	y	- ""
1707a84e134Smrg *	width	- size of area to clear
1717a84e134Smrg *	height	- ""
1727a84e134Smrg *
1737a84e134Smrg * Description:
1747a84e134Smrg *	Clears a region of the sink to the background color.
1757a84e134Smrg *
1767a84e134Smrg * Note:
1777a84e134Smrg *	  This function doesn't actually display anything, it is only a place
1787a84e134Smrg *	holder.
1797a84e134Smrg */
1807a84e134Smrgvoid XawTextSinkClearToBackground
1817a84e134Smrg(
1827a84e134Smrg Widget			w,
1837a84e134Smrg#if NeedWidePrototypes
1847a84e134Smrg int			x,
1857a84e134Smrg int			y,
1867a84e134Smrg unsigned int		width,
1877a84e134Smrg unsigned int		height
1887a84e134Smrg#else
1897a84e134Smrg Position		x,
1907a84e134Smrg Position		y,
1917a84e134Smrg Dimension		width,
1927a84e134Smrg Dimension		height
1937a84e134Smrg#endif
1947a84e134Smrg );
1957a84e134Smrg
1967a84e134Smrg/*
1977a84e134Smrg * Function:
1987a84e134Smrg *	XawTextSinkFindPosition
1997a84e134Smrg *
2007a84e134Smrg * Parameters:
2017a84e134Smrg *	w		- TextSink Object
2027a84e134Smrg *	fromPos		- reference position
2037a84e134Smrg *	fromX		- reference location
2047a84e134Smrg *	width		- width of section to paint text
2057a84e134Smrg *	stopAtWordBreak - returned position is a word break?
2067a84e134Smrg *	resPos		- Position to return
2077a84e134Smrg *	resWidth	- Width actually used
2087a84e134Smrg *	resHeight	- Height actually used
2097a84e134Smrg *
2107a84e134Smrg * Description:
2117a84e134Smrg *	Finds a position in the text.
2127a84e134Smrg */
2137a84e134Smrgvoid XawTextSinkFindPosition
2147a84e134Smrg(
2157a84e134Smrg Widget			w,
2167a84e134Smrg XawTextPosition	fromPos,
2177a84e134Smrg int			fromX,
2187a84e134Smrg int			width,
2197a84e134Smrg#if NeedWidePrototypes
2207a84e134Smrg int			stopAtWordBreak,
2217a84e134Smrg#else
2227a84e134Smrg Boolean		stopAtWordBreak,
2237a84e134Smrg#endif
2247a84e134Smrg XawTextPosition*	pos_return,
2257a84e134Smrg int			*width_return,
2267a84e134Smrg int			*height_return
2277a84e134Smrg );
2287a84e134Smrg
2297a84e134Smrg/*
2307a84e134Smrg * Function:
2317a84e134Smrg *	XawTextSinkFindDistance
2327a84e134Smrg *
2337a84e134Smrg * Parameters:
2347a84e134Smrg *	w		- TextSink Object
2357a84e134Smrg *	fromPos		- starting Position
2367a84e134Smrg *	fromX		- x location of starting Position
2377a84e134Smrg *	toPos		- end Position
2387a84e134Smrg *	resWidth	- Distance between fromPos and toPos
2395b16253fSmrg *	resPos		- Actual toPos used
2407a84e134Smrg *	resHeight	- Height required by this text
2417a84e134Smrg *
2427a84e134Smrg * Description:
2437a84e134Smrg *	Find the Pixel Distance between two text Positions.
2447a84e134Smrg */
2457a84e134Smrgvoid XawTextSinkFindDistance
2467a84e134Smrg(
2477a84e134Smrg Widget			w,
2487a84e134Smrg XawTextPosition	fromPos,
2497a84e134Smrg int			fromX,
2507a84e134Smrg XawTextPosition	toPos,
2517a84e134Smrg int			*width_return,
2527a84e134Smrg XawTextPosition	*pos_return,
2537a84e134Smrg int			*height_return
2547a84e134Smrg );
2557a84e134Smrg
2567a84e134Smrg/*
2577a84e134Smrg * Function:
2587a84e134Smrg *	XawTextSinkResolve
2597a84e134Smrg *
2607a84e134Smrg * Parameters:
2617a84e134Smrg *	w	- TextSink Object
2627a84e134Smrg *	pos	- reference Position
2637a84e134Smrg *	fromx	- reference Location
2647a84e134Smrg *	width	- width to move
2657a84e134Smrg *	resPos	- resulting position
2667a84e134Smrg *
2677a84e134Smrg * Description:
2685b16253fSmrg *	Resolves a location to a position.
2697a84e134Smrg */
2707a84e134Smrgvoid XawTextSinkResolve
2717a84e134Smrg(
2727a84e134Smrg Widget			w,
2737a84e134Smrg XawTextPosition	fromPos,
2747a84e134Smrg int			fromX,
2757a84e134Smrg int			width,
2767a84e134Smrg XawTextPosition	*pos_return
2777a84e134Smrg );
2787a84e134Smrg
2797a84e134Smrg/*
2807a84e134Smrg * Function:
2817a84e134Smrg *	XawTextSinkMaxLines
2827a84e134Smrg *
2837a84e134Smrg * Parameters:
2847a84e134Smrg *	w	- TextSink Object
2857a84e134Smrg *	height	- height to fit lines into
2867a84e134Smrg *
2877a84e134Smrg * Returns:
2887a84e134Smrg *	Number of lines that will fit
2897a84e134Smrg *
2907a84e134Smrg * Description:
2917a84e134Smrg *	Finds the Maximum number of lines that will fit in a given height.
2927a84e134Smrg */
2937a84e134Smrgint XawTextSinkMaxLines
2947a84e134Smrg(
2957a84e134Smrg Widget			w,
2967a84e134Smrg#if NeedWidePrototypes
2977a84e134Smrg unsigned int		height
2987a84e134Smrg#else
2997a84e134Smrg Dimension		height
3007a84e134Smrg#endif
3017a84e134Smrg );
3027a84e134Smrg
3037a84e134Smrg/*
3047a84e134Smrg * Function:
3057a84e134Smrg *	XawTextSinkMaxHeight
3067a84e134Smrg *
3077a84e134Smrg * Parameters:
3087a84e134Smrg *	w	- TextSink Object
3097a84e134Smrg *	lines	- number of lines
3107a84e134Smrg *
3117a84e134Smrg * Returns:
3127a84e134Smrg *	Height
3137a84e134Smrg *
3147a84e134Smrg * Description:
3155b16253fSmrg *	Finds the Minimum height that will contain a given number lines.
3167a84e134Smrg */
3177a84e134Smrgint XawTextSinkMaxHeight
3187a84e134Smrg(
3197a84e134Smrg Widget			w,
3207a84e134Smrg int			lines
3217a84e134Smrg);
3227a84e134Smrg
3237a84e134Smrg/*
3247a84e134Smrg * Function:
3257a84e134Smrg *	XawTextSinkSetTabs
3267a84e134Smrg *
3277a84e134Smrg * Parameters:
3287a84e134Smrg *	w		- TextSink Object
3297a84e134Smrg *	tab_count	- number of tabs in the list
3307a84e134Smrg *	tabs		- text positions of the tabs
3317a84e134Smrg * Description:
3327a84e134Smrg *	Sets the Tab stops.
3337a84e134Smrg */
3347a84e134Smrgvoid XawTextSinkSetTabs
3357a84e134Smrg(
3367a84e134Smrg Widget			w,
3377a84e134Smrg int			tab_count,
3387a84e134Smrg int			*tabs
3397a84e134Smrg);
340421c997bSmrg
3417a84e134Smrg/*
3427a84e134Smrg * Function:
3437a84e134Smrg *	XawTextSinkGetCursorBounds
3447a84e134Smrg *
3457a84e134Smrg * Parameters:
3467a84e134Smrg *	w	- TextSink Object
3477a84e134Smrg *	rect	- X rectance containing the cursor bounds
3487a84e134Smrg * Description:
3497a84e134Smrg *	Finds the bounding box for the insert curor (caret).
3507a84e134Smrg */
3517a84e134Smrgvoid XawTextSinkGetCursorBounds
3527a84e134Smrg(
3537a84e134Smrg Widget			w,
3547a84e134Smrg XRectangle		*rect_return
3557a84e134Smrg);
3567a84e134Smrg
3577a84e134Smrg_XFUNCPROTOEND
3587a84e134Smrg
3597a84e134Smrg#endif /* _XawTextSink_h */
360