749N/A/* $XConsortium: TextSink.c,v 1.19 94/04/17 20:13:11 kaleb Exp $ */
749N/A/*
749N/A
749N/ACopyright (c) 1989, 1994 X Consortium
749N/A
749N/APermission is hereby granted, free of charge, to any person obtaining a copy
749N/Aof this software and associated documentation files (the "Software"), to deal
749N/Ain the Software without restriction, including without limitation the rights
749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell
749N/Acopies of the Software, and to permit persons to whom the Software is
749N/Afurnished to do so, subject to the following conditions:
749N/A
749N/AThe above copyright notice and this permission notice shall be included in
749N/Aall copies or substantial portions of the Software.
749N/A
749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
749N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
749N/A
749N/AExcept as contained in this notice, the name of the X Consortium shall not be
749N/Aused in advertising or otherwise to promote the sale, use or other dealings
749N/Ain this Software without prior written authorization from the X Consortium.
749N/A
749N/A*/
749N/A
749N/A/*
749N/A * Author: Chris Peterson, MIT X Consortium.
749N/A *
749N/A * Much code taken from X11R3 AsciiSink.
749N/A */
749N/A
749N/A/*
749N/A * TextSink.c - TextSink object. (For use with the text widget).
749N/A *
749N/A */
749N/A
749N/A#include <stdio.h>
749N/A#include <ctype.h>
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/StringDefs.h>
749N/A#include <X11/Xaw/XawInit.h>
749N/A#include <X11/Xaw/TextSinkP.h>
749N/A#include <X11/Xaw/TextP.h>
749N/A
749N/A/****************************************************************
749N/A *
749N/A * Full class record constant
749N/A *
749N/A ****************************************************************/
749N/A
749N/Astatic void ClassPartInitialize(), Initialize(), Destroy();
749N/Astatic Boolean SetValues();
749N/A
749N/Astatic int MaxHeight(), MaxLines();
749N/Astatic void DisplayText(), InsertCursor(), ClearToBackground(), FindPosition();
749N/Astatic void FindDistance(), Resolve(), SetTabs(), GetCursorBounds();
749N/A
749N/A#define offset(field) XtOffsetOf(TextSinkRec, text_sink.field)
749N/Astatic XtResource resources[] = {
749N/A {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
749N/A offset(foreground), XtRString, XtDefaultForeground},
749N/A {XtNbackground, XtCBackground, XtRPixel, sizeof (Pixel),
749N/A offset(background), XtRString, XtDefaultBackground},
749N/A};
749N/A#undef offset
749N/A
749N/A#define SuperClass (&objectClassRec)
749N/ATextSinkClassRec textSinkClassRec = {
749N/A {
749N/A/* core_class fields */
749N/A /* superclass */ (WidgetClass) SuperClass,
749N/A /* class_name */ "TextSink",
749N/A /* widget_size */ sizeof(TextSinkRec),
749N/A /* class_initialize */ XawInitializeWidgetSet,
749N/A /* class_part_initialize */ ClassPartInitialize,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ Initialize,
749N/A /* initialize_hook */ NULL,
749N/A /* obj1 */ NULL,
749N/A /* obj2 */ NULL,
749N/A /* obj3 */ 0,
749N/A /* resources */ resources,
749N/A /* num_resources */ XtNumber(resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* obj4 */ FALSE,
749N/A /* obj5 */ FALSE,
749N/A /* obj6 */ FALSE,
749N/A /* obj7 */ FALSE,
749N/A /* destroy */ Destroy,
749N/A /* obj8 */ NULL,
749N/A /* obj9 */ NULL,
749N/A /* set_values */ SetValues,
749N/A /* set_values_hook */ NULL,
749N/A /* obj10 */ NULL,
749N/A /* get_values_hook */ NULL,
749N/A /* obj11 */ NULL,
749N/A /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* obj12 */ NULL,
749N/A /* obj13 */ NULL,
749N/A /* obj14 */ NULL,
749N/A /* extension */ NULL
749N/A },
749N/A/* textSink_class fields */
749N/A {
749N/A /* DisplayText */ DisplayText,
749N/A /* InsertCursor */ InsertCursor,
749N/A /* ClearToBackground */ ClearToBackground,
749N/A /* FindPosition */ FindPosition,
749N/A /* FindDistance */ FindDistance,
749N/A /* Resolve */ Resolve,
749N/A /* MaxLines */ MaxLines,
749N/A /* MaxHeight */ MaxHeight,
749N/A /* SetTabs */ SetTabs,
749N/A /* GetCursorBounds */ GetCursorBounds,
749N/A }
749N/A};
749N/A
749N/AWidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec;
749N/A
749N/Astatic void
749N/AClassPartInitialize(wc)
749N/AWidgetClass wc;
749N/A{
749N/A TextSinkObjectClass t_src, superC;
749N/A
749N/A t_src = (TextSinkObjectClass) wc;
749N/A superC = (TextSinkObjectClass) t_src->object_class.superclass;
749N/A
749N/A/*
749N/A * We don't need to check for null super since we'll get to TextSink
749N/A * eventually.
749N/A */
749N/A
749N/A if (t_src->text_sink_class.DisplayText == XtInheritDisplayText)
749N/A t_src->text_sink_class.DisplayText = superC->text_sink_class.DisplayText;
749N/A
749N/A if (t_src->text_sink_class.InsertCursor == XtInheritInsertCursor)
749N/A t_src->text_sink_class.InsertCursor =
749N/A superC->text_sink_class.InsertCursor;
749N/A
749N/A if (t_src->text_sink_class.ClearToBackground== XtInheritClearToBackground)
749N/A t_src->text_sink_class.ClearToBackground =
749N/A superC->text_sink_class.ClearToBackground;
749N/A
749N/A if (t_src->text_sink_class.FindPosition == XtInheritFindPosition)
749N/A t_src->text_sink_class.FindPosition =
749N/A superC->text_sink_class.FindPosition;
749N/A
749N/A if (t_src->text_sink_class.FindDistance == XtInheritFindDistance)
749N/A t_src->text_sink_class.FindDistance =
749N/A superC->text_sink_class.FindDistance;
749N/A
749N/A if (t_src->text_sink_class.Resolve == XtInheritResolve)
749N/A t_src->text_sink_class.Resolve = superC->text_sink_class.Resolve;
749N/A
749N/A if (t_src->text_sink_class.MaxLines == XtInheritMaxLines)
749N/A t_src->text_sink_class.MaxLines = superC->text_sink_class.MaxLines;
749N/A
749N/A if (t_src->text_sink_class.MaxHeight == XtInheritMaxHeight)
749N/A t_src->text_sink_class.MaxHeight = superC->text_sink_class.MaxHeight;
749N/A
749N/A if (t_src->text_sink_class.SetTabs == XtInheritSetTabs)
749N/A t_src->text_sink_class.SetTabs = superC->text_sink_class.SetTabs;
749N/A
749N/A if (t_src->text_sink_class.GetCursorBounds == XtInheritGetCursorBounds)
749N/A t_src->text_sink_class.GetCursorBounds =
749N/A superC->text_sink_class.GetCursorBounds;
749N/A}
749N/A
749N/A/* Function Name: Initialize
749N/A * Description: Initializes the TextSink Object.
749N/A * Arguments: request, new - the requested and new values for the object
749N/A * instance.
749N/A * Returns: none.
749N/A *
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AInitialize(request, new, args, num_args)
749N/AWidget request, new;
749N/AArgList args;
749N/ACardinal *num_args;
749N/A{
749N/A TextSinkObject sink = (TextSinkObject) new;
749N/A
749N/A sink->text_sink.tab_count = 0; /* Initialize the tab stops. */
749N/A sink->text_sink.tabs = NULL;
749N/A sink->text_sink.char_tabs = NULL;
749N/A}
749N/A
749N/A/* Function Name: Destroy
749N/A * Description: This function cleans up when the object is
749N/A * destroyed.
749N/A * Arguments: w - the TextSink Object.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/ADestroy(w)
749N/AWidget w;
749N/A{
749N/A TextSinkObject sink = (TextSinkObject) w;
749N/A
749N/A XtFree((char *) sink->text_sink.tabs);
749N/A XtFree((char *) sink->text_sink.char_tabs);
749N/A}
749N/A
749N/A/* Function Name: SetValues
749N/A * Description: Sets the values for the TextSink
749N/A * Arguments: current - current state of the object.
749N/A * request - what was requested.
749N/A * new - what the object will become.
749N/A * Returns: True if redisplay is needed.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean
749N/ASetValues(current, request, new, args, num_args)
749N/AWidget current, request, new;
749N/AArgList args;
749N/ACardinal *num_args;
749N/A{
749N/A TextSinkObject w = (TextSinkObject) new;
749N/A TextSinkObject old_w = (TextSinkObject) current;
749N/A
749N/A if (w->text_sink.foreground != old_w->text_sink.foreground)
749N/A ((TextWidget)XtParent(new))->text.redisplay_needed = True;
749N/A
749N/A return FALSE;
749N/A}
749N/A
749N/A/************************************************************
749N/A *
749N/A * Class specific methods.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: DisplayText
749N/A * Description: Stub function that in subclasses will display text.
749N/A * Arguments: w - the TextSink Object.
749N/A * x, y - location to start drawing text.
749N/A * pos1, pos2 - location of starting and ending points
749N/A * in the text buffer.
749N/A * highlight - hightlight this text?
749N/A * Returns: none.
749N/A *
749N/A * This function doesn't actually display anything, it is only a place
749N/A * holder.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/ADisplayText(w, x, y, pos1, pos2, highlight)
749N/AWidget w;
749N/APosition x, y;
749N/ABoolean highlight;
749N/AXawTextPosition pos1, pos2;
749N/A{
749N/A return;
749N/A}
749N/A
749N/A/* Function Name: InsertCursor
749N/A * Description: Places the InsertCursor.
749N/A * Arguments: w - the TextSink Object.
749N/A * x, y - location for the cursor.
749N/A * staye - whether to turn the cursor on, or off.
749N/A * Returns: none.
749N/A *
749N/A * This function doesn't actually display anything, it is only a place
749N/A * holder.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AInsertCursor(w, x, y, state)
749N/AWidget w;
749N/APosition x, y;
749N/AXawTextInsertState state;
749N/A{
749N/A return;
749N/A}
749N/A
749N/A/* Function Name: ClearToBackground
749N/A * Description: Clears a region of the sink to the background color.
749N/A * Arguments: w - the TextSink Object.
749N/A * x, y - location of area to clear.
749N/A * width, height - size of area to clear
749N/A * Returns: void.
749N/A *
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AClearToBackground (w, x, y, width, height)
749N/AWidget w;
749N/APosition x, y;
749N/ADimension width, height;
749N/A{
749N/A/*
749N/A * Don't clear in height or width are zero.
749N/A * XClearArea() has special semantic for these values.
749N/A */
749N/A
749N/A if ( (height == 0) || (width == 0) ) return;
749N/A XClearArea(XtDisplayOfObject(w), XtWindowOfObject(w),
749N/A x, y, width, height, False);
749N/A}
749N/A
749N/A/* Function Name: FindPosition
749N/A * Description: Finds a position in the text.
749N/A * Arguments: w - the TextSink Object.
749N/A * fromPos - reference position.
749N/A * fromX - reference location.
749N/A * width, - width of section to paint text.
749N/A * stopAtWordBreak - returned position is a word break?
749N/A * resPos - Position to return. *** RETURNED ***
749N/A * resWidth - Width actually used. *** RETURNED ***
749N/A * resHeight - Height actually used. *** RETURNED ***
749N/A * Returns: none (see above).
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AFindPosition(w, fromPos, fromx, width, stopAtWordBreak,
749N/A resPos, resWidth, resHeight)
749N/AWidget w;
749N/AXawTextPosition fromPos;
749N/Aint fromx, width;
749N/ABoolean stopAtWordBreak;
749N/AXawTextPosition *resPos;
749N/Aint *resWidth, *resHeight;
749N/A{
749N/A *resPos = fromPos;
749N/A *resHeight = *resWidth = 0;
749N/A}
749N/A
749N/A/* Function Name: FindDistance
749N/A * Description: Find the Pixel Distance between two text Positions.
749N/A * Arguments: w - the TextSink Object.
749N/A * fromPos - starting Position.
749N/A * fromX - x location of starting Position.
749N/A * toPos - end Position.
749N/A * resWidth - Distance between fromPos and toPos.
749N/A * resPos - Acutal toPos used.
749N/A * resHeight - Height required by this text.
749N/A * Returns: none.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AFindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
749N/AWidget w;
749N/AXawTextPosition fromPos;
749N/Aint fromx;
749N/AXawTextPosition toPos;
749N/Aint *resWidth;
749N/AXawTextPosition *resPos;
749N/Aint *resHeight;
749N/A{
749N/A *resWidth = *resHeight = 0;
749N/A *resPos = fromPos;
749N/A}
749N/A
749N/A/* Function Name: Resolve
749N/A * Description: Resloves a location to a position.
749N/A * Arguments: w - the TextSink Object.
749N/A * pos - a reference Position.
749N/A * fromx - a reference Location.
749N/A * width - width to move.
749N/A * resPos - the resulting position.
749N/A * Returns: none
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AResolve (w, pos, fromx, width, resPos)
749N/AWidget w;
749N/AXawTextPosition pos;
749N/Aint fromx, width;
749N/AXawTextPosition *resPos;
749N/A{
749N/A *resPos = pos;
749N/A}
749N/A
749N/A/* Function Name: MaxLines
749N/A * Description: Finds the Maximum number of lines that will fit in
749N/A * a given height.
749N/A * Arguments: w - the TextSink Object.
749N/A * height - height to fit lines into.
749N/A * Returns: the number of lines that will fit.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic int
749N/AMaxLines(w, height)
749N/AWidget w;
749N/ADimension height;
749N/A{
749N/A /*
749N/A * The fontset has gone down to descent Sink Widget, so
749N/A * the functions such MaxLines, SetTabs... are bound to the descent.
749N/A *
749N/A * by Li Yuhong, Jan. 15, 1991
749N/A */
749N/A return 0;
749N/A}
749N/A
749N/A/* Function Name: MaxHeight
749N/A * Description: Finds the Minium height that will contain a given number
749N/A * lines.
749N/A * Arguments: w - the TextSink Object.
749N/A * lines - the number of lines.
749N/A * Returns: the height.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic int
749N/AMaxHeight(w, lines)
749N/AWidget w;
749N/Aint lines;
749N/A{
749N/A return 0;
749N/A}
749N/A
749N/A/* Function Name: SetTabs
749N/A * Description: Sets the Tab stops.
749N/A * Arguments: w - the TextSink Object.
749N/A * tab_count - the number of tabs in the list.
749N/A * tabs - the text positions of the tabs.
749N/A * Returns: none
749N/A */
749N/A
749N/A/*ARGSUSED*/
749N/Astatic void
749N/ASetTabs(w, tab_count, tabs)
749N/AWidget w;
749N/Aint tab_count;
749N/Ashort *tabs;
749N/A{
749N/A return;
749N/A}
749N/A
749N/A/* Function Name: GetCursorBounds
749N/A * Description: Finds the bounding box for the insert curor (caret).
749N/A * Arguments: w - the TextSinkObject.
749N/A * rect - an X rectance containing the cursor bounds.
749N/A * Returns: none (fills in rect).
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AGetCursorBounds(w, rect)
749N/AWidget w;
749N/AXRectangle * rect;
749N/A{
749N/A rect->x = rect->y = rect->width = rect->height = 0;
749N/A}
749N/A/************************************************************
749N/A *
749N/A * Public Functions.
749N/A *
749N/A ************************************************************/
749N/A
749N/A
749N/A/* Function Name: XawTextSinkDisplayText
749N/A * Description: Stub function that in subclasses will display text.
749N/A * Arguments: w - the TextSink Object.
749N/A * x, y - location to start drawing text.
749N/A * pos1, pos2 - location of starting and ending points
749N/A * in the text buffer.
749N/A * highlight - hightlight this text?
749N/A * Returns: none.
749N/A *
749N/A * This function doesn't actually display anything, it is only a place
749N/A * holder.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkDisplayText(Widget w,
749N/A#if NeedWidePrototypes
749N/A /* Position */ int x, /* Position */ int y,
749N/A#else
749N/A Position x, Position y,
749N/A#endif
749N/A XawTextPosition pos1, XawTextPosition pos2,
749N/A#if NeedWidePrototypes
749N/A /* Boolean */ int highlight)
749N/A#else
749N/A Boolean highlight)
749N/A#endif
749N/A#else
749N/AXawTextSinkDisplayText(w, x, y, pos1, pos2, highlight)
749N/AWidget w;
749N/APosition x, y;
749N/ABoolean highlight;
749N/AXawTextPosition pos1, pos2;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.DisplayText)(w, x, y, pos1, pos2, highlight);
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkInsertCursor
749N/A * Description: Places the InsertCursor.
749N/A * Arguments: w - the TextSink Object.
749N/A * x, y - location for the cursor.
749N/A * staye - whether to turn the cursor on, or off.
749N/A * Returns: none.
749N/A *
749N/A * This function doesn't actually display anything, it is only a place
749N/A * holder.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkInsertCursor(Widget w,
749N/A#if NeedWidePrototypes
749N/A int x, int y, int state)
749N/A#else
749N/A Position x, Position y, XawTextInsertState state)
749N/A#endif
749N/A#else
749N/AXawTextSinkInsertCursor(w, x, y, state)
749N/AWidget w;
749N/APosition x, y;
749N/AXawTextInsertState state;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.InsertCursor)(w, x, y, state);
749N/A}
749N/A
749N/A
749N/A/* Function Name: XawTextSinkClearToBackground
749N/A * Description: Clears a region of the sink to the background color.
749N/A * Arguments: w - the TextSink Object.
749N/A * x, y - location of area to clear.
749N/A * width, height - size of area to clear
749N/A * Returns: void.
749N/A *
749N/A * This function doesn't actually display anything, it is only a place
749N/A * holder.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkClearToBackground (Widget w,
749N/A#if NeedWidePrototypes
749N/A int x, int y, unsigned int width, unsigned int height)
749N/A#else
749N/A Position x, Position y,
749N/A Dimension width, Dimension height)
749N/A#endif
749N/A#else
749N/AXawTextSinkClearToBackground (w, x, y, width, height)
749N/AWidget w;
749N/APosition x, y;
749N/ADimension width, height;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.ClearToBackground)(w, x, y, width, height);
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkFindPosition
749N/A * Description: Finds a position in the text.
749N/A * Arguments: w - the TextSink Object.
749N/A * fromPos - reference position.
749N/A * fromX - reference location.
749N/A * width, - width of section to paint text.
749N/A * stopAtWordBreak - returned position is a word break?
749N/A * resPos - Position to return. *** RETURNED ***
749N/A * resWidth - Width actually used. *** RETURNED ***
749N/A * resHeight - Height actually used. *** RETURNED ***
749N/A * Returns: none (see above).
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkFindPosition(Widget w, XawTextPosition fromPos, int fromx,
749N/A int width,
749N/A#if NeedWidePrototypes
749N/A /* Boolean */ int stopAtWordBreak,
749N/A#else
749N/A Boolean stopAtWordBreak,
749N/A#endif
749N/A XawTextPosition *resPos, int *resWidth, int *resHeight)
749N/A#else
749N/AXawTextSinkFindPosition(w, fromPos, fromx, width, stopAtWordBreak,
749N/A resPos, resWidth, resHeight)
749N/AWidget w;
749N/AXawTextPosition fromPos;
749N/Aint fromx, width;
749N/ABoolean stopAtWordBreak;
749N/AXawTextPosition *resPos;
749N/Aint *resWidth, *resHeight;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.FindPosition)(w, fromPos, fromx, width,
749N/A stopAtWordBreak,
749N/A resPos, resWidth, resHeight);
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkFindDistance
749N/A * Description: Find the Pixel Distance between two text Positions.
749N/A * Arguments: w - the TextSink Object.
749N/A * fromPos - starting Position.
749N/A * fromX - x location of starting Position.
749N/A * toPos - end Position.
749N/A * resWidth - Distance between fromPos and toPos.
749N/A * resPos - Acutal toPos used.
749N/A * resHeight - Height required by this text.
749N/A * Returns: none.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkFindDistance (Widget w, XawTextPosition fromPos, int fromx,
749N/A XawTextPosition toPos, int *resWidth,
749N/A XawTextPosition *resPos, int *resHeight)
749N/A#else
749N/AXawTextSinkFindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
749N/AWidget w;
749N/AXawTextPosition fromPos, toPos, *resPos;
749N/Aint fromx, *resWidth, *resHeight;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.FindDistance)(w, fromPos, fromx, toPos,
749N/A resWidth, resPos, resHeight);
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkResolve
749N/A * Description: Resloves a location to a position.
749N/A * Arguments: w - the TextSink Object.
749N/A * pos - a reference Position.
749N/A * fromx - a reference Location.
749N/A * width - width to move.
749N/A * resPos - the resulting position.
749N/A * Returns: none
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkResolve(Widget w, XawTextPosition pos, int fromx, int width,
749N/A XawTextPosition *resPos)
749N/A#else
749N/AXawTextSinkResolve(w, pos, fromx, width, resPos)
749N/AWidget w;
749N/AXawTextPosition pos;
749N/Aint fromx, width;
749N/AXawTextPosition *resPos;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.Resolve)(w, pos, fromx, width, resPos);
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkMaxLines
749N/A * Description: Finds the Maximum number of lines that will fit in
749N/A * a given height.
749N/A * Arguments: w - the TextSink Object.
749N/A * height - height to fit lines into.
749N/A * Returns: the number of lines that will fit.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Aint
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkMaxLines(Widget w,
749N/A#if NeedWidePrototypes
749N/A /* Dimension */ unsigned int height)
749N/A#else
749N/A Dimension height)
749N/A#endif
749N/A#else
749N/AXawTextSinkMaxLines(w, height)
749N/AWidget w;
749N/ADimension height;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A return((*class->text_sink_class.MaxLines)(w, height));
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkMaxHeight
749N/A * Description: Finds the Minimum height that will contain a given number
749N/A * lines.
749N/A * Arguments: w - the TextSink Object.
749N/A * lines - the number of lines.
749N/A * Returns: the height.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Aint
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkMaxHeight(Widget w, int lines)
749N/A#else
749N/AXawTextSinkMaxHeight(w, lines)
749N/AWidget w;
749N/Aint lines;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A return((*class->text_sink_class.MaxHeight)(w, lines));
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkSetTabs
749N/A * Description: Sets the Tab stops.
749N/A * Arguments: w - the TextSink Object.
749N/A * tab_count - the number of tabs in the list.
749N/A * tabs - the text positions of the tabs.
749N/A * Returns: none
749N/A */
749N/A
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkSetTabs(Widget w, int tab_count, int *tabs)
749N/A#else
749N/AXawTextSinkSetTabs(w, tab_count, tabs)
749N/AWidget w;
749N/Aint tab_count, *tabs;
749N/A#endif
749N/A{
749N/A if (tab_count > 0) {
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A short *char_tabs = (short*)XtMalloc( (unsigned)tab_count*sizeof(short) );
749N/A short *tab;
749N/A int i;
749N/A
749N/A for (i = tab_count, tab = char_tabs; i; i--) *tab++ = (short)*tabs++;
749N/A
749N/A (*class->text_sink_class.SetTabs)(w, tab_count, char_tabs);
749N/A XtFree((char *)char_tabs);
749N/A }
749N/A}
749N/A
749N/A/* Function Name: XawTextSinkGetCursorBounds
749N/A * Description: Finds the bounding box for the insert curor (caret).
749N/A * Arguments: w - the TextSinkObject.
749N/A * rect - an X rectance containing the cursor bounds.
749N/A * Returns: none (fills in rect).
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSinkGetCursorBounds(Widget w, XRectangle *rect)
749N/A#else
749N/AXawTextSinkGetCursorBounds(w, rect)
749N/AWidget w;
749N/AXRectangle * rect;
749N/A#endif
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.GetCursorBounds)(w, rect);
749N/A}