749N/A#if ( !defined(lint) && !defined(SABER) )
749N/Astatic char Xrcsid[] = "$XConsortium: TextSink.c,v 1.9 89/11/21 15:53:22 swick Exp $";
749N/A#endif
749N/A
749N/A/*
749N/A * Copyright 1989 Massachusetts Institute of Technology
749N/A *
749N/A * Permission to use, copy, modify, distribute, and sell this software and its
749N/A * documentation for any purpose is hereby granted without fee, provided that
749N/A * the above copyright notice appear in all copies and that both that
749N/A * copyright notice and this permission notice appear in supporting
749N/A * documentation, and that the name of M.I.T. not be used in advertising or
749N/A * publicity pertaining to distribution of the software without specific,
749N/A * written prior permission. M.I.T. makes no representations about the
749N/A * suitability of this software for any purpose. It is provided "as is"
749N/A * without express or implied warranty.
749N/A *
749N/A * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
749N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
749N/A * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
749N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
749N/A * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
749N/A * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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 <./Xaw3_1XawInit.h>
749N/A#include <./Xaw3_1TextSinkP.h>
749N/A#include <./Xaw3_1TextP.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) XtOffset(TextSinkObject, text_sink.field)
749N/Astatic XtResource resources[] = {
749N/A {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
749N/A offset(font), XtRString, XtDefaultFont},
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 register 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)
749N/AWidget request, new;
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/A{
749N/A TextSinkObject sink = (TextSinkObject) w;
749N/A
749N/A if (sink->text_sink.tabs != NULL)
749N/A XtFree((char *) sink->text_sink.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)
749N/AWidget current, request, new;
749N/A{
749N/A TextSinkObject w = (TextSinkObject) new;
749N/A TextSinkObject old_w = (TextSinkObject) current;
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->object.widget_class;
749N/A
749N/A if (w->text_sink.font != old_w->text_sink.font) {
749N/A (*class->text_sink_class.SetTabs)(new, w->text_sink.tab_count,
749N/A w->text_sink.char_tabs);
749N/A ((TextWidget)XtParent(new))->text.redisplay_needed = True;
749N/A } else {
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
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 TextSinkObject sink = (TextSinkObject) w;
749N/A int font_height;
749N/A
749N/A font_height = sink->text_sink.font->ascent + sink->text_sink.font->descent;
749N/A return( ((int) height) / font_height );
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 TextSinkObject sink = (TextSinkObject) w;
749N/A
749N/A return(lines * (sink->text_sink.font->ascent +
749N/A sink->text_sink.font->descent));
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/Astatic void
749N/ASetTabs(w, tab_count, tabs)
749N/AWidget w;
749N/Aint tab_count;
749N/Ashort *tabs;
749N/A{
749N/A TextSinkObject sink = (TextSinkObject) w;
749N/A int i;
749N/A Atom XA_FIGURE_WIDTH;
749N/A unsigned long figure_width = 0;
749N/A XFontStruct *font = sink->text_sink.font;
749N/A
749N/A/*
749N/A * Find the figure width of the current font.
749N/A */
749N/A
749N/A XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", FALSE);
749N/A if ( (XA_FIGURE_WIDTH != NULL) &&
749N/A ( (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)) ||
749N/A (figure_width == 0)) )
749N/A if (font->per_char && font->min_char_or_byte2 <= '$' &&
749N/A font->max_char_or_byte2 >= '$')
749N/A figure_width = font->per_char['$' - font->min_char_or_byte2].width;
749N/A else
749N/A figure_width = font->max_bounds.width;
749N/A
749N/A if (tab_count > sink->text_sink.tab_count) {
749N/A sink->text_sink.tabs = (Position *) XtRealloc((caddr_t)sink->text_sink.tabs,
749N/A (Cardinal) (tab_count * sizeof(Position)));
749N/A sink->text_sink.char_tabs = (short *) XtRealloc(
749N/A (caddr_t) sink->text_sink.char_tabs,
749N/A (Cardinal) (tab_count * sizeof(short)));
749N/A }
749N/A
749N/A for ( i = 0 ; i < tab_count ; i++ ) {
749N/A sink->text_sink.tabs[i] = tabs[i] * figure_width;
749N/A sink->text_sink.char_tabs[i] = tabs[i];
749N/A }
749N/A
749N/A sink->text_sink.tab_count = tab_count;
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/AXawTextSinkDisplayText(w, x, y, pos1, pos2, highlight)
749N/AWidget w;
749N/APosition x, y;
749N/ABoolean highlight;
749N/AXawTextPosition pos1, pos2;
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/AXawTextSinkInsertCursor(w, x, y, state)
749N/AWidget w;
749N/APosition x, y;
749N/AXawTextInsertState state;
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/AXawTextSinkClearToBackground (w, x, y, width, height)
749N/AWidget w;
749N/APosition x, y;
749N/ADimension width, height;
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/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{
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/AXawTextSinkFindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
749N/AWidget w;
749N/AXawTextPosition fromPos, toPos, *resPos;
749N/Aint fromx, *resWidth, *resHeight;
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/AXawTextSinkResolve(w, pos, fromx, width, resPos)
749N/AWidget w;
749N/AXawTextPosition pos;
749N/Aint fromx, width;
749N/AXawTextPosition *resPos;
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/AXawTextSinkMaxLines(w, height)
749N/AWidget w;
749N/ADimension height;
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 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/Aint
749N/AXawTextSinkMaxHeight(w, lines)
749N/AWidget w;
749N/Aint lines;
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/AXawTextSinkSetTabs(w, tab_count, tabs)
749N/AWidget w;
749N/Aint tab_count, *tabs;
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 register short *tab;
749N/A register 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((XtPointer)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/AXawTextSinkGetCursorBounds(w, rect)
749N/AWidget w;
749N/AXRectangle * rect;
749N/A{
749N/A TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
749N/A
749N/A (*class->text_sink_class.GetCursorBounds)(w, rect);
749N/A}